diff options
| author | Peter Penz <[email protected]> | 2012-04-24 23:16:35 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2012-04-24 23:18:34 +0200 |
| commit | d9de39172033c28b8f9a7c1573130cf2124b4f7a (patch) | |
| tree | 8292181d95b92f9a5cb9544bd62d83ca8189c1a1 /src/kitemviews/kstandarditemmodel.cpp | |
| parent | ba2593247b7f11c68419bf1fc24cc5ddcaf8e69f (diff) | |
Provide additional default groups for the Places Panel
If Nepomuk is enabled, it is now possible to easily search for
some most common queries by having additional groups.
Diffstat (limited to 'src/kitemviews/kstandarditemmodel.cpp')
| -rw-r--r-- | src/kitemviews/kstandarditemmodel.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/kitemviews/kstandarditemmodel.cpp b/src/kitemviews/kstandarditemmodel.cpp index 86ef9563b..897267df6 100644 --- a/src/kitemviews/kstandarditemmodel.cpp +++ b/src/kitemviews/kstandarditemmodel.cpp @@ -123,7 +123,22 @@ QString KStandardItemModel::roleDescription(const QByteArray& role) const QList<QPair<int, QVariant> > KStandardItemModel::groups() const { - return QList<QPair<int, QVariant> >(); + QList<QPair<int, QVariant> > groups; + + const QByteArray role = sortRole(); + bool isFirstGroupValue = true; + QString groupValue; + const int maxIndex = count() - 1; + for (int i = 0; i <= maxIndex; ++i) { + const QString newGroupValue = m_items.at(i)->dataValue(role).toString(); + if (newGroupValue != groupValue || isFirstGroupValue) { + groupValue = newGroupValue; + groups.append(QPair<int, QVariant>(i, newGroupValue)); + isFirstGroupValue = false; + } + } + + return groups; } #include "kstandarditemmodel.moc" |
