1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2000-2012 David Faure <faure@kde.org> |
4 | SPDX-FileCopyrightText: 2006 Thiago Macieira <thiago@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-or-later |
7 | */ |
8 | |
9 | #ifndef KDIRNOTIFY_H |
10 | #define KDIRNOTIFY_H |
11 | |
12 | #include "kiocore_export.h" |
13 | |
14 | #include <QByteArray> |
15 | #ifdef QT_DBUS_LIB |
16 | #include <QDBusAbstractInterface> |
17 | #include <QList> |
18 | #include <QMap> |
19 | #include <QObject> |
20 | #include <QString> |
21 | #include <QStringList> |
22 | #include <QVariant> |
23 | |
24 | class QDBusConnection; |
25 | |
26 | /*! |
27 | * \class OrgKdeKDirNotifyInterface |
28 | * \inheaderfile KDirNotify |
29 | * \inmodule KIOCore |
30 | * |
31 | * \brief Proxy class for interface org.kde.KDirNotify. |
32 | * |
33 | * KDirNotify can be used to inform KIO about changes in real or virtual file systems. |
34 | * Classes like KDirModel connect to the signals as in the following example to |
35 | * be able to keep caches up-to-date. |
36 | * |
37 | * \code |
38 | * kdirnotify = new org::kde::KDirNotify(QString(), QString(), QDBusConnection::sessionBus(), this); |
39 | * connect(kdirnotify, &KDirNotify::FileRenamedWithLocalPath, |
40 | * this, [this](const QString &src, const QString &dst, const QString &dstPath) { |
41 | * slotFileRenamed(src, dst, dstPath); |
42 | * }); |
43 | * |
44 | * connect(kdirnotify, &KDirNotify::FilesAdded, |
45 | * this, [this](const QString &directory) { slotFilesAdded(directory); }); |
46 | * |
47 | * connect(kdirnotify, &KDirNotify::FilesChanged, |
48 | * this, [this](const QStringList &fileList) { slotFilesChanged(fileList); }); |
49 | * |
50 | * connect(kdirnotify, &KDirNotify::FilesRemoved, |
51 | * this, [this](const QStringList &fileList) { slotFilesRemoved(fileList); }); |
52 | * \endcode |
53 | * |
54 | * Especially noteworthy are the empty strings for both service and path. That |
55 | * way the client will connect to signals emitted by any application. |
56 | * |
57 | * The second usage is to actually emit the signals. For that emitFileRenamed() and friends are |
58 | * to be used. |
59 | */ |
60 | class KIOCORE_EXPORT OrgKdeKDirNotifyInterface : public QDBusAbstractInterface |
61 | { |
62 | Q_OBJECT |
63 | public: |
64 | static inline const char *staticInterfaceName() |
65 | { |
66 | return "org.kde.KDirNotify" ; |
67 | } |
68 | |
69 | public: |
70 | /*! |
71 | * Create a new KDirNotify interface. |
72 | * |
73 | * \param service The service whose signals one wants to listed to. Use an empty |
74 | * string to connect to all services/applications. |
75 | * |
76 | * \param path The path to the D-Bus object whose signals one wants to listed to. |
77 | * Use an empty string to connect to signals from all objects. |
78 | * |
79 | * \param connection Typically QDBusConnection::sessionBus(). |
80 | * |
81 | * \param parent The parent QObject. |
82 | */ |
83 | OrgKdeKDirNotifyInterface(const QString &service, |
84 | const QString &path, |
85 | const QDBusConnection &connection = QDBusConnection::sessionBus(), |
86 | QObject *parent = nullptr); |
87 | |
88 | ~OrgKdeKDirNotifyInterface() override; |
89 | |
90 | public Q_SLOTS: // METHODS |
91 | Q_SIGNALS: // SIGNALS |
92 | /*! |
93 | */ |
94 | void FileRenamed(const QString &src, const QString &dst); |
95 | /*! |
96 | */ |
97 | void FileRenamedWithLocalPath(const QString &src, const QString &dst, const QString &dstPath); |
98 | /*! |
99 | */ |
100 | void FileMoved(const QString &src, const QString &dst); |
101 | /*! |
102 | */ |
103 | void FilesAdded(const QString &directory); |
104 | /*! |
105 | */ |
106 | void FilesChanged(const QStringList &fileList); |
107 | /*! |
108 | */ |
109 | void FilesRemoved(const QStringList &fileList); |
110 | /*! |
111 | */ |
112 | void enteredDirectory(const QString &url); |
113 | /*! |
114 | */ |
115 | void leftDirectory(const QString &url); |
116 | |
117 | public: |
118 | static void emitFileRenamed(const QUrl &src, const QUrl &dst); |
119 | /*! |
120 | * \param src The old URL of the file that has been renamed. |
121 | * |
122 | * \param dst The new URL of the file after it was renamed. |
123 | * |
124 | * \param dstPath The local path of the file after it was renamed. This may be empty |
125 | * and should otherwise be used to update UDS_LOCAL_PATH. |
126 | * |
127 | * \since 5.20 |
128 | */ |
129 | static void emitFileRenamedWithLocalPath(const QUrl &src, const QUrl &dst, const QString &dstPath); |
130 | /*! |
131 | */ |
132 | static void emitFileMoved(const QUrl &src, const QUrl &dst); |
133 | /*! |
134 | */ |
135 | static void emitFilesAdded(const QUrl &directory); |
136 | /*! |
137 | */ |
138 | static void emitFilesChanged(const QList<QUrl> &fileList); |
139 | /*! |
140 | */ |
141 | static void emitFilesRemoved(const QList<QUrl> &fileList); |
142 | /*! |
143 | */ |
144 | static void emitEnteredDirectory(const QUrl &url); |
145 | /*! |
146 | */ |
147 | static void emitLeftDirectory(const QUrl &url); |
148 | }; |
149 | |
150 | namespace org |
151 | { |
152 | namespace kde |
153 | { |
154 | typedef ::OrgKdeKDirNotifyInterface KDirNotify; |
155 | } |
156 | } |
157 | #endif |
158 | #endif |
159 | |