| 56 | }; |
| 57 | |
| 58 | class InstanceList : public QAbstractListModel |
| 59 | { |
| 60 | Q_OBJECT |
| 61 | |
| 62 | public: |
| 63 | explicit InstanceList(SettingsObjectPtr settings, const QString & instDir, QObject *parent = 0); |
| 64 | virtual ~InstanceList(); |
| 65 | |
| 66 | public: |
| 67 | QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override; |
| 68 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; |
| 69 | QVariant data(const QModelIndex &index, int role) const override; |
| 70 | Qt::ItemFlags flags(const QModelIndex &index) const override; |
| 71 | |
| 72 | bool setData(const QModelIndex & index, const QVariant & value, int role) override; |
| 73 | |
| 74 | enum AdditionalRoles |
| 75 | { |
| 76 | GroupRole = Qt::UserRole, |
| 77 | InstancePointerRole = 0x34B1CB48, ///< Return pointer to real instance |
| 78 | InstanceIDRole = 0x34B1CB49 ///< Return id if the instance |
| 79 | }; |
| 80 | /*! |
| 81 | * \brief Error codes returned by functions in the InstanceList class. |
| 82 | * NoError Indicates that no error occurred. |
| 83 | * UnknownError indicates that an unspecified error occurred. |
| 84 | */ |
| 85 | enum InstListError |
| 86 | { |
| 87 | NoError = 0, |
| 88 | UnknownError |
| 89 | }; |
| 90 | |
| 91 | InstancePtr at(int i) const |
| 92 | { |
| 93 | return m_instances.at(i); |
| 94 | } |
| 95 | |
| 96 | int count() const |
| 97 | { |
| 98 | return m_instances.count(); |
| 99 | } |
| 100 | |
| 101 | InstListError loadList(); |
| 102 | void saveNow(); |
| 103 | |
| 104 | /* O(n) */ |
| 105 | InstancePtr getInstanceById(QString id) const; |
| 106 | /* O(n) */ |
| 107 | InstancePtr getInstanceByManagedName(const QString& managed_name) const; |
| 108 | QModelIndex getInstanceIndexById(const QString &id) const; |
| 109 | QStringList getGroups(); |
| 110 | bool isGroupCollapsed(const QString &groupName); |
| 111 | |
| 112 | GroupId getInstanceGroup(const InstanceId & id) const; |
| 113 | void setInstanceGroup(const InstanceId & id, const GroupId& name); |
| 114 | |
| 115 | void deleteGroup(const GroupId & name); |
nothing calls this directly
no test coverage detected