+QList<QPair<int, QVariant> > KFileItemModel::nameRoleGroups() const
+{
+ Q_ASSERT(!m_data.isEmpty());
+
+ const int maxIndex = count() - 1;
+ QList<QPair<int, QVariant> > groups;
+
+ QString groupValue;
+ QChar firstChar;
+ bool isLetter = false;
+ for (int i = 0; i <= maxIndex; ++i) {
+ const QString name = m_data.at(i).value("name").toString();
+
+ // Use the first character of the name as group indication
+ QChar newFirstChar = name.at(0).toUpper();
+ if (newFirstChar == QLatin1Char('~') && name.length() > 1) {
+ newFirstChar = name.at(1);
+ }
+
+ if (firstChar != newFirstChar) {
+ QString newGroupValue;
+ if (newFirstChar >= QLatin1Char('A') && newFirstChar <= QLatin1Char('Z')) {
+ // Apply group 'A' - 'Z'
+ newGroupValue = newFirstChar;
+ isLetter = true;
+ } else if (newFirstChar >= QLatin1Char('0') && newFirstChar <= QLatin1Char('9')) {
+ // Apply group 'Numerics' for any name that starts with a digit
+ newGroupValue = i18nc("@title:group", "Numerics");
+ isLetter = false;
+ } else {
+ if (isLetter) {
+ // If the current group is 'A' - 'Z' check whether a locale character
+ // fits into the existing group.
+ const QChar prevChar(firstChar.unicode() - ushort(1));
+ const QChar nextChar(firstChar.unicode() + ushort(1));
+ const QString currChar(newFirstChar);
+ const bool partOfCurrentGroup = currChar.localeAwareCompare(prevChar) > 0 &&
+ currChar.localeAwareCompare(nextChar) < 0;
+ if (partOfCurrentGroup) {
+ continue;
+ }
+ }
+ newGroupValue = i18nc("@title:group", "Others");
+ isLetter = false;
+ }
+
+ if (newGroupValue != groupValue) {
+ groupValue = newGroupValue;
+ groups.append(QPair<int, QVariant>(i, newGroupValue));
+ }
+
+ firstChar = newFirstChar;
+ }
+ }
+ return groups;
+}
+
+QList<QPair<int, QVariant> > KFileItemModel::sizeRoleGroups() const
+{
+ Q_ASSERT(!m_data.isEmpty());
+
+ return QList<QPair<int, QVariant> >();
+}
+
+QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() const
+{
+ Q_ASSERT(!m_data.isEmpty());
+ return QList<QPair<int, QVariant> >();
+}
+
+QList<QPair<int, QVariant> > KFileItemModel::permissionRoleGroups() const
+{
+ Q_ASSERT(!m_data.isEmpty());
+ return QList<QPair<int, QVariant> >();
+}
+
+QList<QPair<int, QVariant> > KFileItemModel::ownerRoleGroups() const
+{
+ Q_ASSERT(!m_data.isEmpty());
+ return QList<QPair<int, QVariant> >();
+}
+
+QList<QPair<int, QVariant> > KFileItemModel::groupRoleGroups() const
+{
+ Q_ASSERT(!m_data.isEmpty());
+ return QList<QPair<int, QVariant> >();
+}
+
+QList<QPair<int, QVariant> > KFileItemModel::typeRoleGroups() const
+{
+ Q_ASSERT(!m_data.isEmpty());
+ return QList<QPair<int, QVariant> >();
+}
+
+QList<QPair<int, QVariant> > KFileItemModel::destinationRoleGroups() const
+{
+ Q_ASSERT(!m_data.isEmpty());
+ return QList<QPair<int, QVariant> >();
+}
+
+QList<QPair<int, QVariant> > KFileItemModel::pathRoleGroups() const
+{
+ Q_ASSERT(!m_data.isEmpty());
+ return QList<QPair<int, QVariant> >();
+}
+