diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 24cbc2be8..8d23fa300 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -211,23 +211,44 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) QString QCMakeCacheModel::prefix(const QString& s) { QString prefix = s.section('_', 0, 0); + if(prefix == s) + { + prefix = QString(); + } return prefix; } void QCMakeCacheModel::breakProperties(const QSet& props, QMap& result) { + QMap tmp; // return a map of properties grouped by prefixes, and sorted foreach(QCMakeProperty p, props) { QString prefix = QCMakeCacheModel::prefix(p.Key); - result[prefix].append(p); + tmp[prefix].append(p); } + // sort it and re-org any properties with only one sub item + QCMakePropertyList reorgProps; QMap::iterator iter; - for(iter = result.begin(); iter != result.end(); ++iter) + for(iter = tmp.begin(); iter != tmp.end();) { - qSort(*iter); + if(iter->count() == 1) + { + reorgProps.append((*iter)[0]); + iter = tmp.erase(iter); + } + else + { + qSort(*iter); + ++iter; + } } + if(reorgProps.count()) + { + tmp[QCMakeCacheModel::prefix("NOPREFIX")] += reorgProps; + } + result = tmp; } QCMakePropertyList QCMakeCacheModel::properties() const