- // 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));
+ QStringList visibleRoles;
+
+ const QStringList additionalInfo = m_node->additionalInfo();
+ if (!additionalInfo.isEmpty()) {
+ // Convert the obsolete values like Icons_Size, Details_Date, ...
+ // to Icons_size, Details_date, ... where the suffix just represents
+ // the internal role. One special-case must be handled: "LinkDestination"
+ // has been used for "destination".
+ visibleRoles.reserve(additionalInfo.count());
+ foreach (const QString& info, additionalInfo) {
+ QString visibleRole = info;
+ int index = visibleRole.indexOf('_');
+ if (index >= 0 && index + 1 < visibleRole.length()) {
+ ++index;
+ if (visibleRole[index] == QLatin1Char('L')) {
+ visibleRole.replace("LinkDestination", "destination");
+ } else {
+ visibleRole[index] = visibleRole[index].toLower();
+ }
+ }
+ visibleRoles.append(visibleRole);