File indexing completed on 2024-11-17 04:54:26
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Kevin Ottens <ervin@kde.org> 0003 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 0007 0008 #ifndef DOMAIN_DATASOURCE_H 0009 #define DOMAIN_DATASOURCE_H 0010 0011 #include <QMetaType> 0012 #include <QObject> 0013 #include <QSharedPointer> 0014 #include <QString> 0015 0016 namespace Domain { 0017 0018 // cppcheck somehow doesn't see the ctor in here 0019 // cppcheck-suppress noConstructor 0020 class DataSource : public QObject 0021 { 0022 Q_OBJECT 0023 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) 0024 Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged) 0025 Q_PROPERTY(Domain::DataSource::ContentTypes contentTypes READ contentTypes WRITE setContentTypes NOTIFY contentTypesChanged) 0026 Q_PROPERTY(bool selected READ isSelected WRITE setSelected NOTIFY selectedChanged) 0027 public: 0028 typedef QSharedPointer<DataSource> Ptr; 0029 typedef QList<DataSource::Ptr> List; 0030 0031 enum ContentType { 0032 NoContent = 0, 0033 Tasks, 0034 }; 0035 Q_ENUM(ContentType) 0036 Q_DECLARE_FLAGS(ContentTypes, ContentType) 0037 0038 explicit DataSource(QObject *parent = nullptr); 0039 virtual ~DataSource(); 0040 0041 QString name() const; 0042 QString iconName() const; 0043 ContentTypes contentTypes() const; 0044 bool isSelected() const; 0045 0046 public slots: 0047 void setName(const QString &name); 0048 void setIconName(const QString &iconName); 0049 void setContentTypes(Domain::DataSource::ContentTypes types); 0050 void setSelected(bool selected); 0051 0052 signals: 0053 void nameChanged(const QString &name); 0054 void iconNameChanged(const QString &iconName); 0055 void contentTypesChanged(Domain::DataSource::ContentTypes types); 0056 void selectedChanged(bool selected); 0057 0058 private: 0059 QString m_name; 0060 QString m_iconName; 0061 ContentTypes m_contentTypes; 0062 bool m_selected; 0063 }; 0064 0065 } 0066 0067 Q_DECLARE_METATYPE(Domain::DataSource::Ptr) 0068 Q_DECLARE_METATYPE(Domain::DataSource::ContentTypes) 0069 Q_DECLARE_OPERATORS_FOR_FLAGS(Domain::DataSource::ContentTypes) 0070 0071 #endif // DOMAIN_DATASOURCE_H