X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/a24327cd50ef17b953ecb908d260b73460158107..ca0d0bb322925e2119f13f76d8e9643d24cbf3e0:/src/views/viewproperties.cpp diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp index ab3af5149..e6dbcd811 100644 --- a/src/views/viewproperties.cpp +++ b/src/views/viewproperties.cpp @@ -37,7 +37,8 @@ ViewProperties::ViewProperties(const QUrl& url) : { GeneralSettings* settings = GeneralSettings::self(); const bool useGlobalViewProps = settings->globalViewProps() || url.isEmpty(); - bool useDetailsViewWithPath = false; + bool useSearchView = false; + bool useTrashView = false; bool useRecentDocumentsView = false; bool useDownloadsView = false; @@ -48,13 +49,19 @@ ViewProperties::ViewProperties(const QUrl& url) : m_filePath = destinationDir(QStringLiteral("global")); } else if (url.scheme().contains(QLatin1String("search"))) { m_filePath = destinationDir(QStringLiteral("search/")) + directoryHashForUrl(url); - useDetailsViewWithPath = true; + useSearchView = true; } else if (url.scheme() == QLatin1String("trash")) { m_filePath = destinationDir(QStringLiteral("trash")); - useDetailsViewWithPath = true; + useTrashView = true; } else if (url.scheme() == QLatin1String("recentdocuments")) { m_filePath = destinationDir(QStringLiteral("recentdocuments")); useRecentDocumentsView = true; + } else if (url.scheme() == QLatin1String("recentlyused")) { + m_filePath = destinationDir(QStringLiteral("recentlyused")); + useRecentDocumentsView = true; + } else if (url.scheme() == QLatin1String("timeline")) { + m_filePath = destinationDir(QStringLiteral("timeline")); + useRecentDocumentsView = true; } else if (url.isLocalFile()) { m_filePath = url.toLocalFile(); @@ -90,23 +97,40 @@ ViewProperties::ViewProperties(const QUrl& url) : // If the .directory file does not exist or the timestamp is too old, // use default values instead. - const bool useDefaultProps = (!useGlobalViewProps || useDetailsViewWithPath) && + const bool useDefaultProps = (!useGlobalViewProps || useSearchView || useTrashView || useRecentDocumentsView || useDownloadsView) && (!QFile::exists(file) || (m_node->timestamp() < settings->viewPropsTimestamp())); if (useDefaultProps) { - if (useDetailsViewWithPath) { + if (useSearchView) { + const QString path = url.path(); + + if (path == QLatin1String("/images")) { + setViewMode(DolphinView::IconsView); + setPreviewsShown(true); + setVisibleRoles({"text", "dimensions", "imageDateTime"}); + } else if (path == QLatin1String("/audio")) { + setViewMode(DolphinView::DetailsView); + setVisibleRoles({"text", "artist", "album", "duration"}); + } else if (path == QLatin1String("/videos")) { + setViewMode(DolphinView::IconsView); + setPreviewsShown(true); + setVisibleRoles({"text"}); + } else { + setViewMode(DolphinView::DetailsView); + setVisibleRoles({"text", "path", "modificationtime"}); + } + } else if (useTrashView) { setViewMode(DolphinView::DetailsView); - setVisibleRoles({"path"}); + setVisibleRoles({"text", "path", "deletiontime"}); } else if (useRecentDocumentsView || useDownloadsView) { setSortRole(QByteArrayLiteral("modificationtime")); setSortOrder(Qt::DescendingOrder); + setSortFoldersFirst(false); + setGroupedSorting(true); if (useRecentDocumentsView) { setViewMode(DolphinView::DetailsView); - setVisibleRoles({QByteArrayLiteral("path")}); - } else if (useDownloadsView) { - setSortFoldersFirst(false); - setGroupedSorting(true); + setVisibleRoles({"text", "path", "modificationtime"}); } } else { // The global view-properties act as default for directories without @@ -245,6 +269,19 @@ bool ViewProperties::sortFoldersFirst() const return m_node->sortFoldersFirst(); } +void ViewProperties::setSortHiddenLast(bool hiddenLast) +{ + if (m_node->sortHiddenLast() != hiddenLast) { + m_node->setSortHiddenLast(hiddenLast); + update(); + } +} + +bool ViewProperties::sortHiddenLast() const +{ + return m_node->sortHiddenLast(); +} + void ViewProperties::setVisibleRoles(const QList& roles) { if (roles == visibleRoles()) { @@ -353,6 +390,7 @@ void ViewProperties::setDirProperties(const ViewProperties& props) setSortRole(props.sortRole()); setSortOrder(props.sortOrder()); setSortFoldersFirst(props.sortFoldersFirst()); + setSortHiddenLast(props.sortHiddenLast()); setVisibleRoles(props.visibleRoles()); setHeaderColumnWidths(props.headerColumnWidths()); m_node->setVersion(props.m_node->version()); @@ -392,7 +430,7 @@ bool ViewProperties::exist() const QString ViewProperties::destinationDir(const QString& subDir) const { - QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation); + QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); path.append("/view_properties/").append(subDir); return path; } @@ -413,7 +451,7 @@ QString ViewProperties::viewModePrefix() const void ViewProperties::convertAdditionalInfo() { - QStringList visibleRoles; + QStringList visibleRoles = m_node->visibleRoles(); const QStringList additionalInfo = m_node->additionalInfo(); if (!additionalInfo.isEmpty()) { @@ -421,7 +459,7 @@ void ViewProperties::convertAdditionalInfo() // 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()); + visibleRoles.reserve(visibleRoles.count() + additionalInfo.count()); for (const QString& info : additionalInfo) { QString visibleRole = info; int index = visibleRole.indexOf('_'); @@ -433,7 +471,9 @@ void ViewProperties::convertAdditionalInfo() visibleRole[index] = visibleRole[index].toLower(); } } - visibleRoles.append(visibleRole); + if (!visibleRoles.contains(visibleRole)) { + visibleRoles.append(visibleRole); + } } }