summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2013-08-06 15:30:56 +0200
committerKarsten Heimrich <karsten.heimrich@digia.com>2013-08-07 12:09:20 +0200
commit0476fb13e05c6442c785501ea1eacfc4304d6cdd (patch)
tree75662fe8b0fcd0c4796f199566dfff4a3790d88e
parentcf4960e84c35054efc72c683b8062d78fcb6a842 (diff)
Fix component selection shows wrong package sizes.
Task-number: QTIFW-302 This patch extends patch d4642f3ff. Reduce the number of calls to calculate the uncompressed size to do it only once per model update. We need to update the current selected component to reflect possible sub-node changes. Change-Id: I4a8121148f1974872b3c43d2f58351aad9c59421 Reviewed-by: Niels Weber <niels.weber@digia.com> Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
-rw-r--r--src/libs/installer/componentmodel.cpp8
-rw-r--r--src/libs/installer/packagemanagergui.cpp23
2 files changed, 12 insertions, 19 deletions
diff --git a/src/libs/installer/componentmodel.cpp b/src/libs/installer/componentmodel.cpp
index d4536e249..5285154f6 100644
--- a/src/libs/installer/componentmodel.cpp
+++ b/src/libs/installer/componentmodel.cpp
@@ -399,10 +399,6 @@ void ComponentModel::slotModelReset()
m_initialCheckedState[component->checkState()].insert(component);
}
- // update all checked components uncompressed size (important for nodes)
- foreach (QInstaller::Component *component, checked)
- component->updateUncompressedSize();
-
m_currentCheckedState = m_initialCheckedState;
updateAndEmitModelState(); // update the internal state
}
@@ -524,6 +520,10 @@ QSet<QModelIndex> ComponentModel::updateCheckedState(const ComponentSet &compone
break;
}
}
+
+ // update all nodes uncompressed size
+ foreach (Component *const node, m_rootComponentList)
+ node->updateUncompressedSize(); // this is a recursive call
return changed;
}
diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp
index 295057a44..0ff96b954 100644
--- a/src/libs/installer/packagemanagergui.cpp
+++ b/src/libs/installer/packagemanagergui.cpp
@@ -980,9 +980,9 @@ public:
m_treeView->setObjectName(QLatin1String("ComponentsTreeView"));
connect(m_allModel, SIGNAL(checkStateChanged(QInstaller::ComponentModel::ModelState)), this,
- SLOT(onCheckStateChanged(QInstaller::ComponentModel::ModelState)));
+ SLOT(onModelStateChanged(QInstaller::ComponentModel::ModelState)));
connect(m_updaterModel, SIGNAL(checkStateChanged(QInstaller::ComponentModel::ModelState)), this,
- SLOT(onCheckStateChanged(QInstaller::ComponentModel::ModelState)));
+ SLOT(onModelStateChanged(QInstaller::ComponentModel::ModelState)));
QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->addWidget(m_treeView, 3);
@@ -1044,8 +1044,6 @@ public:
{
m_checkDefault->setVisible(m_core->isInstaller() || m_core->isPackageManager());
if (m_treeView->selectionModel()) {
- disconnect(m_currentModel, SIGNAL(checkStateChanged(QModelIndex)), this,
- SLOT(currentCheckedChanged(QModelIndex)));
disconnect(m_treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
this, SLOT(currentSelectedChanged(QModelIndex)));
}
@@ -1070,8 +1068,6 @@ public:
hasChildren = m_currentModel->hasChildren(m_currentModel->index(row, 0));
m_treeView->setRootIsDecorated(hasChildren);
- connect(m_currentModel, SIGNAL(checkStateChanged(QModelIndex)), this,
- SLOT(currentCheckedChanged(QModelIndex)));
connect(m_treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
this, SLOT(currentSelectedChanged(QModelIndex)));
@@ -1079,12 +1075,6 @@ public:
}
public slots:
- void currentCheckedChanged(const QModelIndex &current)
- {
- if (m_treeView->selectionModel()->currentIndex() == current)
- currentSelectedChanged(current);
- }
-
void currentSelectedChanged(const QModelIndex &current)
{
if (!current.isValid())
@@ -1098,7 +1088,7 @@ public slots:
if ((m_core->isUninstaller()) || (!component))
return;
- if ((component->checkState() != Qt::Unchecked) && (component->updateUncompressedSize() > 0)) {
+ if (component->isSelected() && (component->value(scUncompressedSizeSum).toLongLong() > 0)) {
m_sizeLabel->setText(ComponentSelectionPage::tr("This component "
"will occupy approximately %1 on your hard disk drive.")
.arg(humanReadableSize(component->value(scUncompressedSizeSum).toLongLong())));
@@ -1120,10 +1110,9 @@ public slots:
m_currentModel->setCheckedState(ComponentModel::DefaultChecked);
}
- void onCheckStateChanged(QInstaller::ComponentModel::ModelState state)
+ void onModelStateChanged(QInstaller::ComponentModel::ModelState state)
{
q->setModified(state != ComponentModel::DefaultChecked);
-
// If all components in the checked list are only checkable when run without forced installation, set
// ComponentModel::AllUnchecked as well, as we cannot uncheck anything. Helps to keep the UI correct.
if ((!m_core->noForceInstallation()) && (m_currentModel->checked() == m_currentModel->uncheckable()))
@@ -1133,6 +1122,10 @@ public slots:
m_checkAll->setEnabled(state.testFlag(ComponentModel::AllChecked) == false);
m_uncheckAll->setEnabled(state.testFlag(ComponentModel::AllUnchecked) == false);
m_checkDefault->setEnabled(state.testFlag(ComponentModel::DefaultChecked) == false);
+
+ // update the current selected node (important to reflect possible sub-node changes)
+ if (m_treeView->selectionModel())
+ currentSelectedChanged(m_treeView->selectionModel()->currentIndex());
}
public: