forked from qt-creator/qt-creator
CMakePM: Remove grouping of cmake cache variables
Having groups made from the first underscore is not necessarily helpful. In some cases it creates empty groups, which can confuse users. We have filter and search functionality in the list, which can help with finding the right items. Fixes: QTCREATORBUG-26218 Change-Id: I751a59b49184ea57f55d3832ef4edc8a3c33e0da Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -278,50 +278,11 @@ void ConfigModel::setConfiguration(const QList<ConfigModel::InternalDataItem> &c
|
||||
generateTree();
|
||||
}
|
||||
|
||||
static QString prefix(const QString &key)
|
||||
{
|
||||
int pos = key.indexOf('_');
|
||||
if (pos > 0)
|
||||
return key.left(pos);
|
||||
return key;
|
||||
}
|
||||
|
||||
void ConfigModel::generateTree()
|
||||
{
|
||||
QList<QString> prefixList;
|
||||
|
||||
// Generate nodes for *all* prefixes
|
||||
QHash<QString, QList<Utils::TreeItem *>> prefixes;
|
||||
for (const InternalDataItem &di : qAsConst(m_configuration)) {
|
||||
const QString p = prefix(di.key);
|
||||
if (!prefixes.contains(p)) {
|
||||
prefixes.insert(p, {});
|
||||
prefixList.append(p);
|
||||
}
|
||||
}
|
||||
|
||||
// Fill prefix nodes:
|
||||
for (InternalDataItem &di : m_configuration)
|
||||
prefixes[prefix(di.key)].append(new Internal::ConfigModelTreeItem(&di));
|
||||
|
||||
auto root = new Utils::TreeItem;
|
||||
|
||||
for (const QString &p : qAsConst(prefixList)) {
|
||||
const QList<Utils::TreeItem *> &prefixItemList = prefixes.value(p);
|
||||
QTC_ASSERT(!prefixItemList.isEmpty(), continue);
|
||||
|
||||
if (prefixItemList.count() == 1) {
|
||||
root->appendChild(prefixItemList.at(0));
|
||||
} else {
|
||||
Utils::TreeItem *sti = new Utils::StaticTreeItem(p);
|
||||
for (Utils::TreeItem *const ti : prefixItemList)
|
||||
sti->appendChild(ti);
|
||||
root->appendChild(sti);
|
||||
}
|
||||
prefixes.remove(p);
|
||||
}
|
||||
QTC_CHECK(prefixes.isEmpty());
|
||||
|
||||
for (InternalDataItem &di : m_configuration)
|
||||
root->appendChild(new Internal::ConfigModelTreeItem(&di));
|
||||
setRootItem(root);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user