summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjkobus <jaroslaw.kobus@theqtcompany.com>2014-11-20 12:46:37 +0100
committerJarek Kobus <jaroslaw.kobus@theqtcompany.com>2014-11-20 12:50:30 +0100
commitb54bab7af0c1560f8504c30dfd4e3b16c2c5ff32 (patch)
tree39c6c04dbaca96a9bb9d32a6a0635c79a415f025 /src
parent948888ea8384515d7c674bd036e9c5fae838ac9a (diff)
Optimize the code which determines the check state of a parent component
Change-Id: Ia47c95dbee7477deac4d89384950b9bf962b6e6d Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/libs/installer/componentmodel.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/libs/installer/componentmodel.cpp b/src/libs/installer/componentmodel.cpp
index a452829fd..e4158549c 100644
--- a/src/libs/installer/componentmodel.cpp
+++ b/src/libs/installer/componentmodel.cpp
@@ -469,32 +469,35 @@ struct NameGreaterThan
}
};
+// call it only for items with childern
static Qt::CheckState verifyPartiallyChecked(Component *component)
{
- int checked = 0;
- int unchecked = 0;
+ bool anyChecked = false;
+ bool anyUnchecked = false;
const int count = component->childCount();
for (int i = 0; i < count; ++i) {
switch (component->childAt(i)->checkState()) {
case Qt::Checked: {
- ++checked;
+ anyChecked = true;
} break;
case Qt::Unchecked: {
- ++unchecked;
+ anyUnchecked = true;
} break;
default:
- break;
+ return Qt::PartiallyChecked;
}
+ if (anyChecked && anyUnchecked)
+ return Qt::PartiallyChecked;
}
- if (checked == count)
+ if (anyChecked)
return Qt::Checked;
- if (unchecked == count)
+ if (anyUnchecked)
return Qt::Unchecked;
- return Qt::PartiallyChecked;
+ return Qt::PartiallyChecked; // never hit here
}
} // namespace ComponentModelPrivate