ComponentModel Class
class QInstaller::ComponentModelThe ComponentModel class holds a data model for visual representation of available components to install. More...
Header: | #include <ComponentModel> |
Inherits: | QAbstractItemModel |
Public Types
flags | ModelState |
Public Functions
ComponentModel(int columns, QInstaller::PackageManagerCore *core = 0) | |
virtual | ~ComponentModel() |
QSet<QInstaller::Component *> | checked() const |
QInstaller::ComponentModel::ModelState | checkedState() const |
QInstaller::Component * | componentFromIndex(const QModelIndex &index) const |
QInstaller::PackageManagerCore * | core() const |
QModelIndex | indexFromComponentName(const QString &name) const |
QSet<QInstaller::Component *> | partially() const |
QSet<QInstaller::Component *> | uncheckable() const |
QSet<QInstaller::Component *> | unchecked() const |
Reimplemented Public Functions
virtual int | columnCount(const QModelIndex &parent = QModelIndex()) const override |
virtual QVariant | data(const QModelIndex &index, int role = Qt::DisplayRole) const override |
virtual Qt::ItemFlags | flags(const QModelIndex &index) const override |
virtual QVariant | headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override |
virtual QModelIndex | index(int row, int column, const QModelIndex &parent = QModelIndex()) const override |
virtual QModelIndex | parent(const QModelIndex &child) const override |
virtual int | rowCount(const QModelIndex &parent = QModelIndex()) const override |
virtual bool | setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override |
virtual bool | setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override |
Public Slots
void | reset(QList<QInstaller::Component *> rootComponents = QList<Component *>()) |
void | setCheckedState(QInstaller::ComponentModel::ModelStateFlag state) |
Signals
void | checkStateChanged(QInstaller::ComponentModel::ModelState state) |
Member Function Documentation
[explicit]
ComponentModel::ComponentModel(int columns, QInstaller::PackageManagerCore *core = 0)
Constructs a component model with the given number of columns and core as parent.
[virtual noexcept]
ComponentModel::~ComponentModel()
Destroys the component model.
[signal]
void ComponentModel::checkStateChanged(QInstaller::ComponentModel::ModelState state)
This signal is emitted whenever the checked state of a model is changed after all state calculations have taken place. The state is a combination of ModelStateFlag
values indicating whether the model has its default checked state, all components are checked or unchecked, or some individual component's checked state has changed.
QSet<QInstaller::Component *> ComponentModel::checked() const
Returns a list of checked components.
QInstaller::ComponentModel::ModelState ComponentModel::checkedState() const
Returns the current checked state of the model.
See also setCheckedState().
[override virtual]
int ComponentModel::columnCount(const QModelIndex &parent = QModelIndex()) const
Reimplements: QAbstractItemModel::columnCount(const QModelIndex &parent) const.
Returns the number of columns of the given parent.
QInstaller::Component *ComponentModel::componentFromIndex(const QModelIndex &index) const
Translates between a given QModelIndex index and its associated Component. Returns the component if the index is valid or 0
if an invalid QModelIndex is given.
QInstaller::PackageManagerCore *ComponentModel::core() const
Returns a pointer to the PackageManagerCore this model belongs to.
[override virtual]
QVariant ComponentModel::data(const QModelIndex &index, int role = Qt::DisplayRole) const
Reimplements: QAbstractItemModel::data(const QModelIndex &index, int role) const.
Returns the data stored under the given role for the item referred to by the index.
Note: An invalid QVariant is returned if the given index is invalid. Qt::CheckStateRole is only supported for the first column of the model. Qt::EditRole, Qt::DisplayRole and Qt::ToolTipRole are specifically handled for columns greater than the first column and translate to Qt::UserRole + index.column()
.
See also setData().
[override virtual]
Qt::ItemFlags ComponentModel::flags(const QModelIndex &index) const
Reimplements: QAbstractItemModel::flags(const QModelIndex &index) const.
Returns the item flags for the given index.
Returns a combination of flags that enables the item (Qt::ItemIsEnabled) and allows it to be selected (Qt::ItemIsSelectable) and to be checked (Qt::ItemIsUserCheckable).
[override virtual]
QVariant ComponentModel::headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
Reimplements: QAbstractItemModel::headerData(int section, Qt::Orientation orientation, int role) const.
Returns the data for the given role and section in the header with the specified orientation. An invalid QVariant is returned if section is out of bounds, orientation is not Qt::Horizontal or role is anything else than Qt::DisplayRole.
See also setHeaderData().
[override virtual]
QModelIndex ComponentModel::index(int row, int column, const QModelIndex &parent = QModelIndex()) const
Reimplements: QAbstractItemModel::index(int row, int column, const QModelIndex &parent) const.
Returns the index of the item in the model specified by the given row, column, and parent index.
QModelIndex ComponentModel::indexFromComponentName(const QString &name) const
Translates between a given component name and its associated QModelIndex. Returns the QModelIndex that represents the component or an invalid QModelIndex if the component does not exist in the model.
[override virtual]
QModelIndex ComponentModel::parent(const QModelIndex &child) const
Reimplements: QAbstractItemModel::parent(const QModelIndex &index) const.
Returns the parent item of the given child. If the item has no parent, an invalid QModelIndex is returned.
QSet<QInstaller::Component *> ComponentModel::partially() const
Returns a list of partially checked components.
[slot]
void ComponentModel::reset(QList<QInstaller::Component *> rootComponents = QList<Component *>())
Resets model and sets rootComponents to be the list of currently shown components.
The model is repopulated and the individual component's checked state is used to show the check mark in front of the visual component representation. The modelAboutToBeReset() and modelReset() signals are emitted.
[override virtual]
int ComponentModel::rowCount(const QModelIndex &parent = QModelIndex()) const
Reimplements: QAbstractItemModel::rowCount(const QModelIndex &parent) const.
Returns the number of items under the given parent. When the parent index is invalid, the returned value is the root item count.
[slot]
void ComponentModel::setCheckedState(QInstaller::ComponentModel::ModelStateFlag state)
Sets the checked state of every component in the model to be state.
The ComponentModel::PartiallyChecked flag is ignored by this function. Note that components are not changed if they are not checkable. The modelCheckStateChanged() signal is emitted.
See also checkedState().
[override virtual]
bool ComponentModel::setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole)
Reimplements: QAbstractItemModel::setData(const QModelIndex &index, const QVariant &value, int role).
Sets the role data for the item at index to value. Returns true if successful; otherwise returns false. The dataChanged() signal is emitted if the data was successfully set.
See also data().
[override virtual]
bool ComponentModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole)
Reimplements: QAbstractItemModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role).
Sets the data for the given role and section in the header with the specified orientation to the value supplied. Returns true
if the header's data was updated; otherwise returns false
. The headerDataChanged() signal is emitted if the data was successfully set.
Note: Only Qt::Horizontal orientation is supported.
See also headerData().
QSet<QInstaller::Component *> ComponentModel::uncheckable() const
Returns a list of components whose checked state cannot be changed. If package manager core is run with no forced installation argument, the list will always be empty.
QSet<QInstaller::Component *> ComponentModel::unchecked() const
Returns a list of unchecked components.
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. The Qt Company, Qt and their respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.