diff options
| author | Don Nguyen <[email protected]> | 2017-01-21 00:04:38 +0100 |
|---|---|---|
| committer | Albert Astals Cid <[email protected]> | 2017-01-21 00:04:38 +0100 |
| commit | 0aed243bebae72d85aa06032bdf2d6ba2b58141d (patch) | |
| tree | ab1ec32cfc392baf0db70db26940397f448a2dde /src/views/viewproperties.cpp | |
| parent | d8ffea247626842ac0f9e5048c8be05c250ff719 (diff) | |
Change "Date" to "Modified" and allow access to new "Accessed" time field
This is merge of #128964 and #128942. This will impelement changing the "Date" field to "Modified" and allow a new "Accessed" time field to be available. This also includes changes to update configuration files.
REVIEW: 129077
Diffstat (limited to 'src/views/viewproperties.cpp')
| -rw-r--r-- | src/views/viewproperties.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp index 597baa293..ca52be890 100644 --- a/src/views/viewproperties.cpp +++ b/src/views/viewproperties.cpp @@ -35,7 +35,8 @@ namespace { const int AdditionalInfoViewPropertiesVersion = 1; const int NameRolePropertiesVersion = 2; - const int CurrentViewPropertiesVersion = 3; + const int DateRolePropertiesVersion = 4; + const int CurrentViewPropertiesVersion = 4; // String representation to mark the additional properties of // the details view as customized by the user. See @@ -123,6 +124,11 @@ ViewProperties::ViewProperties(const QUrl& url) : Q_ASSERT(m_node->version() == NameRolePropertiesVersion); } + if (m_node->version() < DateRolePropertiesVersion) { + convertDateRoleToModificationTimeRole(); + Q_ASSERT(m_node->version() == DateRolePropertiesVersion); + } + m_node->setVersion(CurrentViewPropertiesVersion); } } @@ -309,7 +315,7 @@ QList<QByteArray> ViewProperties::visibleRoles() const && !visibleRoles.contains(CustomizedDetailsString); if (useDefaultValues) { roles.append("size"); - roles.append("date"); + roles.append("modificationtime"); } return roles; @@ -448,6 +454,27 @@ void ViewProperties::convertNameRoleToTextRole() update(); } +void ViewProperties::convertDateRoleToModificationTimeRole() +{ + QStringList visibleRoles = m_node->visibleRoles(); + for (int i = 0; i < visibleRoles.count(); ++i) { + if (visibleRoles[i].endsWith(QLatin1String("_date"))) { + const int leftLength = visibleRoles[i].length() - 5; + visibleRoles[i] = visibleRoles[i].left(leftLength) + "_modificationtime"; + } + } + + QString sortRole = m_node->sortRole(); + if (sortRole == QLatin1String("date")) { + sortRole = QStringLiteral("modificationtime"); + } + + m_node->setVisibleRoles(visibleRoles); + m_node->setSortRole(sortRole); + m_node->setVersion(DateRolePropertiesVersion); + update(); +} + bool ViewProperties::isPartOfHome(const QString& filePath) { // For performance reasons cache the path in a static QString |
