diff options
Diffstat (limited to 'api/logic/InstanceList.h')
-rw-r--r-- | api/logic/InstanceList.h | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/api/logic/InstanceList.h b/api/logic/InstanceList.h index bb879c83..7fe5ea34 100644 --- a/api/logic/InstanceList.h +++ b/api/logic/InstanceList.h @@ -31,75 +31,75 @@ class BaseInstance; class MULTIMC_LOGIC_EXPORT InstanceList : public QAbstractListModel { - Q_OBJECT + Q_OBJECT public: - explicit InstanceList(QObject *parent = 0); - virtual ~InstanceList(); + explicit InstanceList(QObject *parent = 0); + virtual ~InstanceList(); public: - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - - enum AdditionalRoles - { - GroupRole = Qt::UserRole, - InstancePointerRole = 0x34B1CB48, ///< Return pointer to real instance - InstanceIDRole = 0x34B1CB49 ///< Return id if the instance - }; - /*! - * \brief Error codes returned by functions in the InstanceList class. - * NoError Indicates that no error occurred. - * UnknownError indicates that an unspecified error occurred. - */ - enum InstListError - { - NoError = 0, - UnknownError - }; - - InstancePtr at(int i) const - { - return m_instances.at(i); - } - - int count() const - { - return m_instances.count(); - } - - InstListError loadList(bool complete = false); - void saveNow(); - - /// Add an instance provider. Takes ownership of it. Should only be done before the first load. - void addInstanceProvider(BaseInstanceProvider * provider); - - InstancePtr getInstanceById(QString id) const; - QModelIndex getInstanceIndexById(const QString &id) const; - QStringList getGroups(); - - void deleteGroup(const QString & name); + QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role) const; + Qt::ItemFlags flags(const QModelIndex &index) const; + + enum AdditionalRoles + { + GroupRole = Qt::UserRole, + InstancePointerRole = 0x34B1CB48, ///< Return pointer to real instance + InstanceIDRole = 0x34B1CB49 ///< Return id if the instance + }; + /*! + * \brief Error codes returned by functions in the InstanceList class. + * NoError Indicates that no error occurred. + * UnknownError indicates that an unspecified error occurred. + */ + enum InstListError + { + NoError = 0, + UnknownError + }; + + InstancePtr at(int i) const + { + return m_instances.at(i); + } + + int count() const + { + return m_instances.count(); + } + + InstListError loadList(bool complete = false); + void saveNow(); + + /// Add an instance provider. Takes ownership of it. Should only be done before the first load. + void addInstanceProvider(BaseInstanceProvider * provider); + + InstancePtr getInstanceById(QString id) const; + QModelIndex getInstanceIndexById(const QString &id) const; + QStringList getGroups(); + + void deleteGroup(const QString & name); signals: - void dataIsInvalid(); + void dataIsInvalid(); private slots: - void propertiesChanged(BaseInstance *inst); - void groupsPublished(QSet<QString>); - void providerUpdated(); + void propertiesChanged(BaseInstance *inst); + void groupsPublished(QSet<QString>); + void providerUpdated(); private: - int getInstIndex(BaseInstance *inst) const; - void suspendWatch(); - void resumeWatch(); - void add(const QList<InstancePtr> &list); + int getInstIndex(BaseInstance *inst) const; + void suspendWatch(); + void resumeWatch(); + void add(const QList<InstancePtr> &list); protected: - int m_watchLevel = 0; - QSet<BaseInstanceProvider *> m_updatedProviders; - QList<InstancePtr> m_instances; - QSet<QString> m_groups; - QVector<shared_qobject_ptr<BaseInstanceProvider>> m_providers; + int m_watchLevel = 0; + QSet<BaseInstanceProvider *> m_updatedProviders; + QList<InstancePtr> m_instances; + QSet<QString> m_groups; + QVector<shared_qobject_ptr<BaseInstanceProvider>> m_providers; }; |