ENH: group together items with no prefix and items that won't be

grouped with others.
This commit is contained in:
Clinton Stimpson 2008-06-10 18:53:22 -04:00
parent 3e909b5908
commit 2d37d2a48d
1 changed files with 24 additions and 3 deletions

View File

@ -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<QCMakeProperty>& props,
QMap<QString, QCMakePropertyList>& result)
{
QMap<QString, QCMakePropertyList> 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<QString, QCMakePropertyList>::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