┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views/viewproperties.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-04-21 21:28:16 +0200
committerPeter Penz <[email protected]>2012-04-21 21:32:42 +0200
commitae4d11d918938fd9087f2035dac247969c1f2313 (patch)
tree0303667797c81814b46b9ed5ed20b48ef31f2d71 /src/views/viewproperties.cpp
parent47d7cdffdd2d2c04067a5088eaeff67add53dde3 (diff)
Prepare view-engine for non-KFileItem usecase
Up to now the view-engine only provided a model-implementation that supports file-items. The view-engine always had been designed to be able to work with any kind of model, so now a KStandardItemModel is available. The plan is to convert the places panel to the new view-engine. It should be no problem to fix this until the feature freeze - in the worst case the places-panel code could be reverted while still keeping the KStandardItemModel changes.
Diffstat (limited to 'src/views/viewproperties.cpp')
-rw-r--r--src/views/viewproperties.cpp31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp
index 83958ad00..d19b3bfda 100644
--- a/src/views/viewproperties.cpp
+++ b/src/views/viewproperties.cpp
@@ -33,8 +33,9 @@
#include <QFileInfo>
namespace {
- const int CurrentViewPropertiesVersion = 2;
const int AdditionalInfoViewPropertiesVersion = 1;
+ const int NameRolePropertiesVersion = 2;
+ const int CurrentViewPropertiesVersion = 3;
// String representation to mark the additional properties of
// the details view as customized by the user. See
@@ -256,7 +257,7 @@ QList<QByteArray> ViewProperties::visibleRoles() const
// is accepted.
QList<QByteArray> roles;
- roles.append("name");
+ roles.append("text");
// Iterate through all stored keys and append all roles that match to
// the curren view mode.
@@ -264,16 +265,19 @@ QList<QByteArray> ViewProperties::visibleRoles() const
const int prefixLength = prefix.length();
QStringList visibleRoles = m_node->visibleRoles();
- if (visibleRoles.isEmpty() && m_node->version() <= AdditionalInfoViewPropertiesVersion) {
+ const int version = m_node->version();
+ if (visibleRoles.isEmpty() && version <= AdditionalInfoViewPropertiesVersion) {
// Convert the obsolete additionalInfo-property from older versions into the
// visibleRoles-property
visibleRoles = const_cast<ViewProperties*>(this)->convertAdditionalInfo();
+ } else if (version <= NameRolePropertiesVersion) {
+ visibleRoles = const_cast<ViewProperties*>(this)->convertNameRole();
}
foreach (const QString& visibleRole, visibleRoles) {
if (visibleRole.startsWith(prefix)) {
const QByteArray role = visibleRole.right(visibleRole.length() - prefixLength).toLatin1();
- if (role != "name") {
+ if (role != "text") {
roles.append(role);
}
}
@@ -281,7 +285,7 @@ QList<QByteArray> ViewProperties::visibleRoles() const
// 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 // "name"
+ const bool useDefaultValues = roles.count() == 1 // "text"
&& (m_node->viewMode() == DolphinView::DetailsView)
&& !visibleRoles.contains(CustomizedDetailsString);
if (useDefaultValues) {
@@ -403,6 +407,23 @@ QStringList ViewProperties::convertAdditionalInfo()
return visibleRoles;
}
+QStringList ViewProperties::convertNameRole()
+{
+ QStringList visibleRoles = m_node->visibleRoles();
+ for (int i = 0; i < visibleRoles.count(); ++i) {
+ if (visibleRoles[i].endsWith("_name")) {
+ const int leftLength = visibleRoles[i].length() - 5;
+ visibleRoles[i] = visibleRoles[i].left(leftLength) + "_text";
+ }
+ }
+
+ m_node->setVisibleRoles(visibleRoles);
+ update();
+
+ return visibleRoles;
+}
+
+
bool ViewProperties::isPartOfHome(const QString& filePath)
{
// For performance reasons cache the path in a static QString