+QList<KUrl> KMetaDataWidget::Private::sortedKeys(const QHash<KUrl, Nepomuk::Variant>& data) const
+{
+ const KNfoTranslator& nfo = KNfoTranslator::instance();
+
+ // Create a map, where the translated label prefixed with the
+ // sort priority acts as key. The data of each entry is the URI
+ // of the data. By this the all URIs are sorted by the sort priority
+ // and sub sorted by the translated labels.
+ QMap<QString, KUrl> map;
+ QHash<KUrl, Nepomuk::Variant>::const_iterator hashIt = data.constBegin();
+ while (hashIt != data.constEnd()) {
+ const KUrl uri = hashIt.key();
+
+ QString key = q->model()->group(uri);
+ key += nfo.translation(uri);
+
+ map.insert(key, uri);
+ ++hashIt;
+ }
+
+ // Apply the URIs from the map to the list that will get returned.
+ // The list will then be alphabetically ordered by the translated labels of the URIs.
+ QList<KUrl> list;
+ QMap<QString, KUrl>::const_iterator mapIt = map.constBegin();
+ while (mapIt != map.constEnd()) {
+ list.append(mapIt.value());
+ ++mapIt;
+ }
+
+ return list;
+}
+