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 ListingNotificationExtension listingnotificationextension.h <KParts/ListingNotificationExtension> |
25 | * |
26 | * @short An extension for receiving listing change notification. |
27 | * |
28 | * This extension is intended for implementation by parts that provide listing |
29 | * services, e.g. file management and is intended to notify about changes to |
30 | * a given listing. For example, if file management part implemented this extension |
31 | * it would emit @ref itemsDeleted and @ref itemsAdded signal whenever new files |
32 | * or folders are deleted and added to a directory respectively. |
33 | * |
34 | * @since 4.9.2 |
35 | */ |
36 | class KPARTS_EXPORT ListingNotificationExtension : public QObject |
37 | { |
38 | Q_OBJECT |
39 | |
40 | public: |
41 | /** |
42 | * Supported notification event types. |
43 | * @see NotificationEventTypes |
44 | */ |
45 | enum NotificationEventType { |
46 | None = 0x00, |
47 | ItemsAdded = 0x01, /*!< New items added to the listing. */ |
48 | ItemsDeleted = 0x02, /*!< Items deleted from the listing. */ |
49 | }; |
50 | |
51 | /** |
52 | * Stores a combination of #NotificationEventType values. |
53 | */ |
54 | Q_DECLARE_FLAGS(NotificationEventTypes, NotificationEventType) |
55 | |
56 | /*! Constructor */ |
57 | ListingNotificationExtension(KParts::ReadOnlyPart *parent); |
58 | |
59 | /*! Destructor */ |
60 | ~ListingNotificationExtension() override; |
61 | |
62 | /** |
63 | * Returns the OR'ed value of the notification types supported by the part |
64 | * that implements this extension. |
65 | * |
66 | * By default this function returns None. |
67 | */ |
68 | virtual NotificationEventTypes supportedNotificationEventTypes() const; |
69 | |
70 | /** |
71 | * Queries @p obj for a child object which inherits from this class. |
72 | */ |
73 | static ListingNotificationExtension *childObject(QObject *obj); |
74 | |
75 | Q_SIGNALS: |
76 | /** |
77 | * This signal is emitted when one of the notification events listed |
78 | * in @ref NotificationEventType occur. |
79 | */ |
80 | void listingEvent(KParts::ListingNotificationExtension::NotificationEventType, const KFileItemList &); |
81 | |
82 | private: |
83 | std::unique_ptr<ListingNotificationExtension> const d; |
84 | }; |
85 | |
86 | Q_DECLARE_OPERATORS_FOR_FLAGS(ListingNotificationExtension::NotificationEventTypes) |
87 | |
88 | } |
89 | |
90 | #endif /* KPARTS_LISTINGNOTIFICATIONEXTENSION_H */ |
91 | |