Register some enums/structs as Qt meta-type

Reuired when creating a Plasmoid because these
types might be accessed from QML then
This commit is contained in:
Martchus 2017-04-23 13:48:55 +02:00
parent 4fa0ff30db
commit 01610f5027
4 changed files with 20 additions and 2 deletions

View File

@ -23,7 +23,6 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingConfig
QString syncthingUrl() const;
};
} // namespace Data
#endif // DATA_SYNCTHINGCONFIG_H

View File

@ -22,6 +22,7 @@ QT_FORWARD_DECLARE_CLASS(QJsonObject)
QT_FORWARD_DECLARE_CLASS(QJsonArray)
namespace Data {
Q_NAMESPACE
struct SyncthingConnectionSettings;
@ -38,6 +39,7 @@ enum class SyncthingStatus
OutOfSync,
BeingDestroyed
};
Q_ENUM_NS(SyncthingStatus)
enum class SyncthingErrorCategory
{
@ -45,6 +47,7 @@ enum class SyncthingErrorCategory
SpecificRequest,
Parsing
};
Q_ENUM_NS(SyncthingErrorCategory)
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingLogEntry
{
@ -61,7 +64,9 @@ class LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingConnection : public QObject
Q_OBJECT
Q_PROPERTY(QString syncthingUrl READ syncthingUrl WRITE setSyncthingUrl)
Q_PROPERTY(QByteArray apiKey READ apiKey WRITE setApiKey)
Q_PROPERTY(SyncthingStatus status READ status NOTIFY statusChanged)
Q_PROPERTY(Data::SyncthingStatus status READ status NOTIFY statusChanged)
Q_PROPERTY(QString statusText READ statusText NOTIFY statusChanged)
Q_PROPERTY(bool connected READ isConnected NOTIFY statusChanged)
Q_PROPERTY(bool hasUnreadNotifications READ hasUnreadNotifications)
Q_PROPERTY(bool hasOutOfSyncDirs READ hasOutOfSyncDirs)
Q_PROPERTY(int trafficPollInterval READ trafficPollInterval WRITE setTrafficPollInterval)
@ -518,4 +523,6 @@ inline const std::vector<SyncthingDir *> &SyncthingConnection::completedDirs() c
}
Q_DECLARE_METATYPE(Data::SyncthingLogEntry)
#endif // SYNCTHINGCONNECTION_H

View File

@ -7,8 +7,10 @@
#include <QString>
#include <QStringList>
#include <QMetaType>
namespace Data {
Q_NAMESPACE
enum class SyncthingDevStatus
{
@ -20,6 +22,7 @@ enum class SyncthingDevStatus
OutOfSync,
Rejected
};
Q_ENUM_NS(SyncthingDevStatus)
QString statusString(SyncthingDevStatus status);
@ -53,4 +56,6 @@ inline SyncthingDev::SyncthingDev(const QString &id, const QString &name) :
} // namespace Data
Q_DECLARE_METATYPE(Data::SyncthingDev)
#endif // DATA_SYNCTHINGDEV_H

View File

@ -6,11 +6,13 @@
#include <c++utilities/chrono/datetime.h>
#include <QString>
#include <QMetaType>
#include <QFileInfo>
QT_FORWARD_DECLARE_CLASS(QJsonObject)
namespace Data {
Q_NAMESPACE
enum class SyncthingDirStatus
{
@ -21,6 +23,7 @@ enum class SyncthingDirStatus
Synchronizing,
OutOfSync
};
Q_ENUM_NS(SyncthingDirStatus)
QString statusString(SyncthingDirStatus status);
@ -111,4 +114,8 @@ inline QString SyncthingDir::displayName() const
} // namespace Data
Q_DECLARE_METATYPE(Data::SyncthingDirError)
Q_DECLARE_METATYPE(Data::SyncthingItemDownloadProgress)
Q_DECLARE_METATYPE(Data::SyncthingDir)
#endif // DATA_SYNCTHINGDIR_H