File indexing completed on 2024-09-15 11:59:50
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2000-2012 David Faure <faure@kde.org> 0004 SPDX-FileCopyrightText: 2006 Thiago Macieira <thiago@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef KDIRNOTIFY_H 0010 #define KDIRNOTIFY_H 0011 0012 #include "kiocore_export.h" 0013 0014 #include <QByteArray> 0015 #ifdef QT_DBUS_LIB 0016 #include <QDBusAbstractInterface> 0017 #include <QList> 0018 #include <QMap> 0019 #include <QObject> 0020 #include <QString> 0021 #include <QStringList> 0022 #include <QVariant> 0023 0024 class QDBusConnection; 0025 0026 /** 0027 * \class OrgKdeKDirNotifyInterface kdirnotify.h KDirNotify 0028 * 0029 * \brief Proxy class for interface org.kde.KDirNotify. 0030 * 0031 * KDirNotify can be used to inform KIO about changes in real or virtual file systems. 0032 * Classes like KDirModel connect to the signals as in the following example to 0033 * be able to keep caches up-to-date. 0034 * 0035 * \code 0036 * kdirnotify = new org::kde::KDirNotify(QString(), QString(), QDBusConnection::sessionBus(), this); 0037 * connect(kdirnotify, &KDirNotify::FileRenamedWithLocalPath, 0038 * this, [this](const QString &src, const QString &dst, const QString &dstPath) { 0039 * slotFileRenamed(src, dst, dstPath); 0040 * }); 0041 * 0042 * connect(kdirnotify, &KDirNotify::FilesAdded, 0043 * this, [this](const QString &directory) { slotFilesAdded(directory); }); 0044 * 0045 * connect(kdirnotify, &KDirNotify::FilesChanged, 0046 * this, [this](const QStringList &fileList) { slotFilesChanged(fileList); }); 0047 * 0048 * connect(kdirnotify, &KDirNotify::FilesRemoved, 0049 * this, [this](const QStringList &fileList) { slotFilesRemoved(fileList); }); 0050 * \endcode 0051 * 0052 * Especially noteworthy are the empty strings for both \p service and \p path. That 0053 * way the client will connect to signals emitted by any application. 0054 * 0055 * The second usage is to actually emit the signals. For that emitFileRenamed() and friends are 0056 * to be used. 0057 */ 0058 class KIOCORE_EXPORT OrgKdeKDirNotifyInterface : public QDBusAbstractInterface 0059 { 0060 Q_OBJECT 0061 public: 0062 static inline const char *staticInterfaceName() 0063 { 0064 return "org.kde.KDirNotify"; 0065 } 0066 0067 public: 0068 /** 0069 * Create a new KDirNotify interface. 0070 * 0071 * \param service The service whose signals one wants to listed to. Use an empty 0072 * string to connect to all services/applications. 0073 * \param path The path to the D-Bus object whose signals one wants to listed to. 0074 * Use an empty string to connect to signals from all objects. 0075 * \param connection Typically QDBusConnection::sessionBus(). 0076 * \param parent The parent QObject. 0077 */ 0078 OrgKdeKDirNotifyInterface(const QString &service, 0079 const QString &path, 0080 const QDBusConnection &connection = QDBusConnection::sessionBus(), 0081 QObject *parent = nullptr); 0082 0083 /** 0084 * Destructor. 0085 */ 0086 ~OrgKdeKDirNotifyInterface() override; 0087 0088 public Q_SLOTS: // METHODS 0089 Q_SIGNALS: // SIGNALS 0090 void FileRenamed(const QString &src, const QString &dst); 0091 void FileRenamedWithLocalPath(const QString &src, const QString &dst, const QString &dstPath); 0092 void FileMoved(const QString &src, const QString &dst); 0093 void FilesAdded(const QString &directory); 0094 void FilesChanged(const QStringList &fileList); 0095 void FilesRemoved(const QStringList &fileList); 0096 void enteredDirectory(const QString &url); 0097 void leftDirectory(const QString &url); 0098 0099 public: 0100 static void emitFileRenamed(const QUrl &src, const QUrl &dst); 0101 /** 0102 * \param src The old URL of the file that has been renamed. 0103 * \param dst The new URL of the file after it was renamed. 0104 * \param dstPath The local path of the file after it was renamed. This may be empty 0105 * and should otherwise be used to update UDS_LOCAL_PATH. 0106 * @since 5.20 0107 */ 0108 static void emitFileRenamedWithLocalPath(const QUrl &src, const QUrl &dst, const QString &dstPath); 0109 static void emitFileMoved(const QUrl &src, const QUrl &dst); 0110 static void emitFilesAdded(const QUrl &directory); 0111 static void emitFilesChanged(const QList<QUrl> &fileList); 0112 static void emitFilesRemoved(const QList<QUrl> &fileList); 0113 static void emitEnteredDirectory(const QUrl &url); 0114 static void emitLeftDirectory(const QUrl &url); 0115 }; 0116 0117 namespace org 0118 { 0119 namespace kde 0120 { 0121 typedef ::OrgKdeKDirNotifyInterface KDirNotify; 0122 } 0123 } 0124 #endif 0125 #endif