+ QString sortRole = m_node->sortRole();
+ if (sortRole == QLatin1String("name")) {
+ sortRole = QStringLiteral("text");
+ }
+
+ m_node->setVisibleRoles(visibleRoles);
+ m_node->setSortRole(sortRole);
+ m_node->setVersion(NameRolePropertiesVersion);
+ 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
+ // (see QDir::homePath() for more details)
+ static QString homePath;
+ if (homePath.isEmpty()) {
+ homePath = QDir::homePath();
+ Q_ASSERT(!homePath.isEmpty());
+ }
+
+ return filePath.startsWith(homePath);
+}
+
+QString ViewProperties::directoryHashForUrl(const QUrl& url)
+{
+ const QByteArray hashValue = QCryptographicHash::hash(url.toEncoded(), QCryptographicHash::Sha1);
+ QString hashString = hashValue.toBase64();
+ hashString.replace('/', '-');
+ return hashString;