summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/componentmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/installer/componentmodel.cpp')
-rw-r--r--src/libs/installer/componentmodel.cpp41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/libs/installer/componentmodel.cpp b/src/libs/installer/componentmodel.cpp
index 88e502164..3bb9bc72e 100644
--- a/src/libs/installer/componentmodel.cpp
+++ b/src/libs/installer/componentmodel.cpp
@@ -58,14 +58,14 @@ namespace QInstaller {
*/
/*!
- \fn void QInstaller::ComponentModel::checkStateChanged(const QModelIndex &index)
+ \fn void QInstaller::ComponentModel::componentsCheckStateChanged(const QList<QModelIndex> &indexes)
- This signal is emitted whenever the checked state of a component is changed. The \a index value
- indicates the QModelIndex representation of the component as seen from the model.
+ This signal is emitted whenever the checked state of components are changed. The \a indexes value
+ indicates the QModelIndexes representation of the components as seen from the model.
*/
/*!
- \fn void QInstaller::ComponentModel::checkStateChanged(QInstaller::ComponentModel::ModelState state)
+ \fn void QInstaller::ComponentModel::modelCheckStateChanged(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 \a state is a combination of \c ModelStateFlag values
@@ -238,7 +238,7 @@ QVariant ComponentModel::data(const QModelIndex &index, int role) const
/*!
Sets the \a role data for the item at \a index to \a value. Returns true if successful;
otherwise returns false. The dataChanged() signal is emitted if the data was successfully set.
- The checkStateChanged() signals are emitted in addition if the checked state of the item is set.
+ The componentsCheckStateChanged() signal is emitted in addition if the checked state of the item is set.
*/
bool ComponentModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
@@ -260,12 +260,13 @@ bool ComponentModel::setData(const QModelIndex &index, const QVariant &value, in
const Qt::CheckState oldValue = component->checkState();
newValue = (oldValue == Qt::Checked) ? Qt::Unchecked : Qt::Checked;
}
- QSet<QModelIndex> changed = updateCheckedState(nodes << component, newValue);
+ const QList<QModelIndex> changed = updateCheckedState(nodes << component, newValue);
foreach (const QModelIndex &changedIndex, changed) {
emit dataChanged(changedIndex, changedIndex);
- emit checkStateChanged(changedIndex);
}
- updateAndEmitModelState(); // update the internal state
+ updateModelState();
+ if (changed.count() > 0)
+ emit componentsCheckStateChanged(changed);
} else {
component->setData(value, role);
emit dataChanged(index, index);
@@ -425,12 +426,12 @@ void ComponentModel::reset(QList<Component *> rootComponents)
Sets the checked state of every component in the model to be \a state.
The ComponentModel::PartiallyChecked flag is ignored by this function. Note that components
- are not changed if they are not checkable. The dataChanged() and checkStateChanged() signals
+ are not changed if they are not checkable. The dataChanged() and componentsCheckStateChanged() signals
are emitted.
*/
void ComponentModel::setCheckedState(QInstaller::ComponentModel::ModelStateFlag state)
{
- QSet<QModelIndex> changed;
+ QList<QModelIndex> changed;
switch (state) {
case AllChecked:
changed = updateCheckedState(m_currentCheckedState[Qt::Unchecked], Qt::Checked);
@@ -453,9 +454,9 @@ void ComponentModel::setCheckedState(QInstaller::ComponentModel::ModelStateFlag
// notify about changes done to the model
foreach (const QModelIndex &index, changed) {
emit dataChanged(index, index);
- emit checkStateChanged(index);
}
- updateAndEmitModelState(); // update the internal state
+ updateModelState();
+ emit modelCheckStateChanged(m_modelState);
}
@@ -493,10 +494,11 @@ void ComponentModel::postModelReset()
}
m_currentCheckedState = m_initialCheckedState;
- updateAndEmitModelState(); // update the internal state
+ updateModelState(); // update the internal state
+ emit modelCheckStateChanged(m_modelState);
}
-void ComponentModel::updateAndEmitModelState()
+void ComponentModel::updateModelState()
{
m_modelState = ComponentModel::DefaultChecked;
if (m_initialCheckedState != m_currentCheckedState)
@@ -511,8 +513,6 @@ void ComponentModel::updateAndEmitModelState()
m_modelState |= ComponentModel::AllChecked;
m_modelState &= ~ComponentModel::PartiallyChecked;
}
-
- emit checkStateChanged(m_modelState);
}
void ComponentModel::collectComponents(Component *const component, const QModelIndex &parent) const
@@ -556,7 +556,7 @@ static Qt::CheckState verifyPartiallyChecked(Component *component)
} // namespace ComponentModelPrivate
-QSet<QModelIndex> ComponentModel::updateCheckedState(const ComponentSet &components, Qt::CheckState state)
+QList<QModelIndex> ComponentModel::updateCheckedState(const ComponentSet &components, const Qt::CheckState state)
{
// get all parent nodes for the components we're going to update
QMultiMap<QString, Component *> sortedNodesMap;
@@ -567,7 +567,7 @@ QSet<QModelIndex> ComponentModel::updateCheckedState(const ComponentSet &compone
}
}
- QSet<QModelIndex> changed;
+ QList<QModelIndex> changed;
const ComponentList sortedNodes = sortedNodesMap.values();
// we can start in descending order to check node and tri-state nodes properly
for (int i = sortedNodes.count(); i > 0; i--) {
@@ -589,7 +589,10 @@ QSet<QModelIndex> ComponentModel::updateCheckedState(const ComponentSet &compone
continue;
node->setCheckState(newState);
- changed.insert(indexFromComponentName(node->treeName()));
+ QModelIndex index = indexFromComponentName(node->treeName());
+ //Prepend to the list so that install order is correct (parent first)
+ if (!changed.contains(index))
+ changed.prepend(indexFromComponentName(node->treeName()));
m_currentCheckedState[Qt::Checked].remove(node);
m_currentCheckedState[Qt::Unchecked].remove(node);