+ AdditionalInfoAccessor& infoAccessor = AdditionalInfoAccessor::instance();
+ const KFileItemDelegate::InformationList infoKeys = infoAccessor.keys();
+
+ foreach (const KFileItemDelegate::Information info, infoKeys) {
+ if (decodedInfo & infoAccessor.bitValue(info)) {
+ usedInfo.append(info);
+ }
+ }
+
+ return usedInfo;
+}
+
+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.
+ //
+ // For the details-view a special case must be respected: Per default the size
+ // and date should be shown without creating a .directory file. Only if
+ // the user explictly has modified the properties of the details view (marked
+ // by "CustomizedDetails"), also a details-view with no additional information
+ // is accepted.
+
+ KFileItemDelegate::InformationList usedInfo;
+
+ // 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));
+ usedInfo.append(infoHash.value(key));
+ }
+ }
+
+ // For the details view the size and date should be shown per default
+ // until the additional information has been explicitly changed by the user
+ const bool useDefaultValues = usedInfo.isEmpty()
+ && (m_node->viewMode() == DolphinView::DetailsView)
+ && !infoStringList.contains(CustomizedDetailsString);
+ if (useDefaultValues) {
+ usedInfo.append(KFileItemDelegate::Size);
+ usedInfo.append(KFileItemDelegate::ModificationTime);
+ }
+
+ return usedInfo;
+}
+
+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;
+}
+
+bool ViewProperties::isPartOfHome(const QString& filePath)
+{
+ // For performance reasons cache the path in a static QString
+ // (see QDir::homePath() for more details)
+ static QString homePath;
+ if (homePath.isEmpty()) {
+ homePath = QDir::homePath();
+ Q_ASSERT(!homePath.isEmpty());
+ }
+
+ return filePath.startsWith(homePath);