+ AdditionalInfoAccessor& infoAccessor = AdditionalInfoAccessor::instance();
+ const KFileItemDelegate::InformationList infoKeys = infoAccessor.keys();
+
+ foreach (const KFileItemDelegate::Information info, infoKeys) {
+ if (decodedInfo & infoAccessor.bitValue(info)) {
+ usedInfos.append(info);
+ }
+ }
+
+ return usedInfos;
+}
+
+KFileItemDelegate::InformationList ViewProperties::additionalInfoV2() const
+{
+ // The shown additional information is stored for each view-mode separately as
+ // string with the view-mode as prefix. Example:
+ //
+ // AdditionalInfoV2=Details_Size,Details_Date,Details_Owner,Icon_Size
+ //
+ // To get the representation as KFileItemDelegate::InformationList, the current
+ // view-mode must be checked and the values of this mode added to the list.
+
+ KFileItemDelegate::InformationList usedInfos;
+
+ // infoHash allows to get the mapped KFileItemDelegate::Information value
+ // for a stored string-value in a fast way
+ static QHash<QString, KFileItemDelegate::Information> infoHash;
+ if (infoHash.isEmpty()) {
+ AdditionalInfoAccessor& infoAccessor = AdditionalInfoAccessor::instance();
+ const KFileItemDelegate::InformationList keys = infoAccessor.keys();
+ foreach (const KFileItemDelegate::Information key, keys) {
+ infoHash.insert(infoAccessor.value(key), key);
+ }
+ }
+
+ // Iterate through all stored keys stored as strings and map them to
+ // the corresponding KFileItemDelegate::Information values.
+ const QString prefix = viewModePrefix();
+ const int prefixLength = prefix.length();
+ const QStringList infoStringList = m_node->additionalInfoV2();
+ foreach (const QString& infoString, infoStringList) {
+ if (infoString.startsWith(prefix)) {
+ const QString key = infoString.right(infoString.length() - prefixLength);
+ Q_ASSERT(infoHash.contains(key));
+ usedInfos.append(infoHash.value(key));
+ }
+ }
+
+ return usedInfos;
+}
+
+QString ViewProperties::viewModePrefix() const
+{
+ QString prefix;
+
+ switch (m_node->viewMode()) {
+ case DolphinView::DetailsView: prefix = "Details_"; break;
+ case DolphinView::IconsView: prefix = "Icons_"; break;
+ case DolphinView::ColumnView: prefix = "Column_"; break;
+ default: kWarning() << "Unknown view-mode of the view properties";
+ }
+
+ return prefix;