+QList<QByteArray> ViewProperties::visibleRoles() const
+{
+ // The shown additional information is stored for each view-mode separately as
+ // string with the view-mode as prefix. Example:
+ //
+ // AdditionalInfo=Details_size,Details_date,Details_owner,Icons_size
+ //
+ // To get the representation as QList<QByteArray>, 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 explicitly has modified the properties of the details view (marked
+ // by "CustomizedDetails"), also a details-view with no additional information
+ // is accepted.
+
+ QList<QByteArray> roles{"text"};
+
+ // Iterate through all stored keys and append all roles that match to
+ // the current view mode.
+ const QString prefix = viewModePrefix();
+ const int prefixLength = prefix.length();
+
+ const QStringList visibleRoles = m_node->visibleRoles();
+ for (const QString& visibleRole : visibleRoles) {
+ if (visibleRole.startsWith(prefix)) {
+ const QByteArray role = visibleRole.right(visibleRole.length() - prefixLength).toLatin1();
+ if (role != "text") {
+ roles.append(role);
+ }
+ }
+ }
+
+ // 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 = roles.count() == 1 // "text"
+ && (m_node->viewMode() == DolphinView::DetailsView)
+ && !visibleRoles.contains(CustomizedDetailsString);
+ if (useDefaultValues) {
+ roles.append("size");
+ roles.append("modificationtime");
+ }
+
+ return roles;
+}
+
+void ViewProperties::setHeaderColumnWidths(const QList<int>& widths)
+{
+ if (m_node->headerColumnWidths() != widths) {
+ m_node->setHeaderColumnWidths(widths);
+ update();
+ }