File indexing completed on 2024-05-12 05:10:50
0001 /* 0002 SPDX-FileCopyrightText: 2013 Sérgio Martins <iamsergio@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "akonadi-calendar_export.h" 0010 #include "calendarbase.h" 0011 0012 #include <QObject> 0013 0014 #include <memory> 0015 0016 namespace Akonadi 0017 { 0018 class IncidenceChanger; 0019 class TodoPurgerPrivate; 0020 0021 /** 0022 * @short Class to delete completed to-dos. 0023 * 0024 * @author Sérgio Martins <iamsergio@gmail.com> 0025 * @since 4.12 0026 */ 0027 class AKONADI_CALENDAR_EXPORT TodoPurger : public QObject 0028 { 0029 Q_OBJECT 0030 public: 0031 explicit TodoPurger(QObject *parent = nullptr); 0032 ~TodoPurger() override; 0033 0034 /** 0035 * Sets an IncidenceChanger. 0036 * If you don't call this method, an internal IncidenceChanger will be created. 0037 * Use this if you want more control over the deletion operations, like iTip management, ACL, undo/redo support. 0038 */ 0039 void setIncidenceChager(IncidenceChanger *changer); 0040 0041 /** 0042 * Sets the calendar to be used for retrieving the to-do hierarchy. 0043 * If you don't call this method, an internal FetchJobCalendar will be created. 0044 * Use this if you want to reuse an existing calendar, for performance reasons for example. 0045 */ 0046 void setCalendar(const CalendarBase::Ptr &calendar); 0047 0048 /** 0049 * Deletes completed to-dos. A to-do with incomplete children won't be deleted. 0050 * @see purgeCompletedTodos() 0051 */ 0052 void purgeCompletedTodos(); 0053 0054 /** 0055 * Use this after receiving the an unsuccessful todosPurged() signal to get a i18n error message. 0056 */ 0057 [[nodiscard]] QString lastError() const; 0058 0059 Q_SIGNALS: 0060 /** 0061 * Emitted when purging completed to-dos finished. 0062 * @param success True if the operation could be completed. @see lastError() 0063 * @param numDeleted Number of to-dos that were deleted. 0064 * @param numIgnored Number of completed to-dos that weren't deleted because they are read-only 0065 * or have incomplete or read-only children. 0066 */ 0067 void todosPurged(bool success, int numDeleted, int numIgnored); 0068 0069 private: 0070 std::unique_ptr<TodoPurgerPrivate> const d; 0071 }; 0072 }