File indexing completed on 2024-04-28 15:29:21

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2012 Dawit Alemayehu <adawit@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KPARTS_LISTINGNOTIFICATIONEXTENSION_H
0009 #define KPARTS_LISTINGNOTIFICATIONEXTENSION_H
0010 
0011 #include <kparts/kparts_export.h>
0012 
0013 #include <QObject>
0014 #include <memory>
0015 
0016 class KFileItemList;
0017 
0018 namespace KParts
0019 {
0020 class ReadOnlyPart;
0021 class ListingNotificationExtensionPrivate;
0022 
0023 /**
0024  * @class ListingNotificationExtension listingnotificationextension.h <KParts/ListingNotificationExtension>
0025  *
0026  * @short An extension for receiving listing change notification.
0027  *
0028  * This extension is intended for implementation by parts that provide listing
0029  * services, e.g. file management and is intended to notify about changes to
0030  * a given listing. For example, if file management part implemented this extension
0031  * it would emit @ref itemsDeleted and @ref itemsAdded signal whenever new files
0032  * or folders are deleted and added to a directory respectively.
0033  *
0034  * @since 4.9.2
0035  */
0036 class KPARTS_EXPORT ListingNotificationExtension : public QObject
0037 {
0038     Q_OBJECT
0039 
0040 public:
0041     /**
0042      * Supported notification event types.
0043      * @see NotificationEventTypes
0044      */
0045     enum NotificationEventType {
0046         None = 0x00,
0047         ItemsAdded = 0x01, /*!< New items added to the listing. */
0048         ItemsDeleted = 0x02, /*!< Items deleted from the listing. */
0049     };
0050 
0051     /**
0052      * Stores a combination of #NotificationEventType values.
0053      */
0054     Q_DECLARE_FLAGS(NotificationEventTypes, NotificationEventType)
0055 
0056     /*! Constructor */
0057     ListingNotificationExtension(KParts::ReadOnlyPart *parent);
0058 
0059     /*! Destructor */
0060     ~ListingNotificationExtension() override;
0061 
0062     /**
0063      * Returns the OR'ed value of the notification types supported by the part
0064      * that implements this extension.
0065      *
0066      * By default this function returns None.
0067      */
0068     virtual NotificationEventTypes supportedNotificationEventTypes() const;
0069 
0070     /**
0071      * Queries @p obj for a child object which inherits from this class.
0072      */
0073     static ListingNotificationExtension *childObject(QObject *obj);
0074 
0075 Q_SIGNALS:
0076     /**
0077      * This signal is emitted when one of the notification events listed
0078      * in @ref NotificationEventType occur.
0079      */
0080     void listingEvent(KParts::ListingNotificationExtension::NotificationEventType, const KFileItemList &);
0081 
0082 private:
0083     std::unique_ptr<ListingNotificationExtension> const d;
0084 };
0085 
0086 Q_DECLARE_OPERATORS_FOR_FLAGS(ListingNotificationExtension::NotificationEventTypes)
0087 
0088 }
0089 
0090 #endif /* KPARTS_LISTINGNOTIFICATIONEXTENSION_H */