diff options
author | kh1 <karsten.heimrich@digia.com> | 2013-03-11 14:51:16 +0100 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2013-03-15 13:14:41 +0100 |
commit | 7796a25de086de6276d5128d50469ab260528eeb (patch) | |
tree | 4a64a94c8e3e23b5fa8311f05f91eeb1772da4d1 /src/libs/installer/componentmodel.h | |
parent | bbebc83ebf22b6286a82586fa8845cb3c0e94d4e (diff) |
Add component model behavior auto test and fix broken model.
Task-number: QTIFW-84
Task-number: QTIFW-213
Change-Id: I8fc9035ba3b14c2c12a1672b74869bece68c8ee9
Reviewed-by: Niels Weber <niels.weber@digia.com>
Reviewed-by: Rainer Keller <rainer.keller@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/libs/installer/componentmodel.h')
-rw-r--r-- | src/libs/installer/componentmodel.h | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/src/libs/installer/componentmodel.h b/src/libs/installer/componentmodel.h index b43bfc75a..a691906a4 100644 --- a/src/libs/installer/componentmodel.h +++ b/src/libs/installer/componentmodel.h @@ -57,11 +57,23 @@ class PackageManagerCore; class INSTALLER_EXPORT ComponentModel : public QAbstractItemModel { Q_OBJECT + typedef QSet<Component *> ComponentSet; + typedef QList<Component *> ComponentList; public: + enum ModelStateFlag { + AllChecked = 0x01, + AllUnchecked = 0x02, + DefaultChecked = 0x04, + PartiallyChecked = 0x08 + }; + Q_DECLARE_FLAGS(ModelState, ModelStateFlag); + explicit ComponentModel(int columns, PackageManagerCore *core = 0); ~ComponentModel(); + Qt::ItemFlags flags(const QModelIndex &index) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; @@ -75,49 +87,50 @@ public: bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole); - Qt::ItemFlags flags(const QModelIndex &index) const; - PackageManagerCore *packageManagerCore() const; + QSet<Component *> checked() const; + QSet<Component *> partially() const; + QSet<Component *> unchecked() const; + QSet<Component *> uncheckable() const; - bool defaultCheckState() const; - bool hasCheckedComponents() const; - QList<Component*> checkedComponents() const; + PackageManagerCore *core() const; + ComponentModel::ModelState checkedState() const; QModelIndex indexFromComponentName(const QString &name) const; Component* componentFromIndex(const QModelIndex &index) const; public Q_SLOTS: - void selectAll(); - void deselectAll(); - void selectDefault(); - void setRootComponents(QList<QInstaller::Component*> rootComponents); - void appendRootComponents(QList<QInstaller::Component*> rootComponents); + void setCheckedState(QInstaller::ComponentModel::ModelStateFlag state); Q_SIGNALS: - void defaultCheckStateChanged(bool changed); void checkStateChanged(const QModelIndex &index); + void checkStateChanged(QInstaller::ComponentModel::ModelState state); private Q_SLOTS: void slotModelReset(); - void slotCheckStateChanged(const QModelIndex &index); private: - QSet<QString> select(Qt::CheckState state); - void updateCache(const QModelIndex &parent) const; - QModelIndexList collectComponents(const QModelIndex &parent) const; + void updateAndEmitModelState(); + void collectComponents(Component *const component, const QModelIndex &parent) const; + QSet<QModelIndex> updateCheckedState(const ComponentSet &components, Qt::CheckState state); private: PackageManagerCore *m_core; - int m_rootIndex; + ModelState m_modelState; + ComponentSet m_uncheckable; QVector<QVariant> m_headerData; - QSet<QString> m_initialCheckedSet; - QSet<QString> m_currentCheckedSet; - QList<Component*> m_rootComponentList; + ComponentList m_rootComponentList; + QHash<Qt::CheckState, ComponentSet> m_initialCheckedState; + QHash<Qt::CheckState, ComponentSet> m_currentCheckedState; mutable QHash<QString, QPersistentModelIndex> m_indexByNameCache; }; +Q_DECLARE_OPERATORS_FOR_FLAGS(ComponentModel::ModelState); } // namespace QInstaller +Q_DECLARE_METATYPE(QInstaller::ComponentModel::ModelState); +Q_DECLARE_METATYPE(QInstaller::ComponentModel::ModelStateFlag); + #endif // COMPONENTMODEL_H |