| 1 | /* |
| 2 | This file is part of the KDE project |
| 3 | SPDX-FileCopyrightText: 2012 Dawit Alemayehu <adawit@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef KPARTS_LISTINGNOTIFICATIONEXTENSION_H |
| 9 | #define KPARTS_LISTINGNOTIFICATIONEXTENSION_H |
| 10 | |
| 11 | #include <kparts/kparts_export.h> |
| 12 | |
| 13 | #include <QObject> |
| 14 | #include <memory> |
| 15 | |
| 16 | class KFileItemList; |
| 17 | |
| 18 | namespace KParts |
| 19 | { |
| 20 | class ReadOnlyPart; |
| 21 | class ListingNotificationExtensionPrivate; |
| 22 | |
| 23 | /*! |
| 24 | * \class KParts::ListingNotificationExtension |
| 25 | * \inheaderfile KParts/ListingNotificationExtension |
| 26 | * \inmodule KParts |
| 27 | * |
| 28 | * \brief An extension for receiving listing change notification. |
| 29 | * |
| 30 | * This extension is intended for implementation by parts that provide listing |
| 31 | * services, e.g. file management and is intended to notify about changes to |
| 32 | * a given listing. For example, if file management part implemented this extension |
| 33 | * it would emit itemsDeleted and itemsAdded signal whenever new files |
| 34 | * or folders are deleted and added to a directory respectively. |
| 35 | * |
| 36 | * \since 4.9.2 |
| 37 | */ |
| 38 | class KPARTS_EXPORT ListingNotificationExtension : public QObject |
| 39 | { |
| 40 | Q_OBJECT |
| 41 | |
| 42 | public: |
| 43 | /*! |
| 44 | * Supported notification event types. |
| 45 | * |
| 46 | * \value None |
| 47 | * \value ItemsAdded New items added to the listing. |
| 48 | * \value ItemsDeleted Items deleted from the listing. |
| 49 | * |
| 50 | */ |
| 51 | enum NotificationEventType { |
| 52 | None = 0x00, |
| 53 | ItemsAdded = 0x01, |
| 54 | ItemsDeleted = 0x02, |
| 55 | }; |
| 56 | |
| 57 | Q_DECLARE_FLAGS(NotificationEventTypes, NotificationEventType) |
| 58 | |
| 59 | /*! Constructor */ |
| 60 | ListingNotificationExtension(KParts::ReadOnlyPart *parent); |
| 61 | |
| 62 | ~ListingNotificationExtension() override; |
| 63 | |
| 64 | /*! |
| 65 | * Returns the OR'ed value of the notification types supported by the part |
| 66 | * that implements this extension. |
| 67 | * |
| 68 | * By default this function returns None. |
| 69 | */ |
| 70 | virtual NotificationEventTypes supportedNotificationEventTypes() const; |
| 71 | |
| 72 | /*! |
| 73 | * Queries \a obj for a child object which inherits from this class. |
| 74 | */ |
| 75 | static ListingNotificationExtension *childObject(QObject *obj); |
| 76 | |
| 77 | Q_SIGNALS: |
| 78 | /*! |
| 79 | * This signal is emitted when one of the notification events listed |
| 80 | * in NotificationEventType occur. |
| 81 | */ |
| 82 | void listingEvent(KParts::ListingNotificationExtension::NotificationEventType, const KFileItemList &); |
| 83 | |
| 84 | private: |
| 85 | std::unique_ptr<ListingNotificationExtension> const d; |
| 86 | }; |
| 87 | |
| 88 | Q_DECLARE_OPERATORS_FOR_FLAGS(ListingNotificationExtension::NotificationEventTypes) |
| 89 | |
| 90 | } |
| 91 | |
| 92 | #endif /* KPARTS_LISTINGNOTIFICATIONEXTENSION_H */ |
| 93 | |