Changeset View
Changeset View
Standalone View
Standalone View
src/views/viewproperties.cpp
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
44 | ViewProperties::ViewProperties(const QUrl& url) : | 44 | ViewProperties::ViewProperties(const QUrl& url) : | ||
45 | m_changedProps(false), | 45 | m_changedProps(false), | ||
46 | m_autoSave(true), | 46 | m_autoSave(true), | ||
47 | m_node(nullptr) | 47 | m_node(nullptr) | ||
48 | { | 48 | { | ||
49 | GeneralSettings* settings = GeneralSettings::self(); | 49 | GeneralSettings* settings = GeneralSettings::self(); | ||
50 | const bool useGlobalViewProps = settings->globalViewProps() || url.isEmpty(); | 50 | const bool useGlobalViewProps = settings->globalViewProps() || url.isEmpty(); | ||
51 | bool useDetailsViewWithPath = false; | 51 | bool useDetailsViewWithPath = false; | ||
52 | bool useRecentDocumentsView = false; | ||||
53 | bool useDownloadsView = false; | ||||
52 | 54 | | |||
53 | // We try and save it to the file .directory in the directory being viewed. | 55 | // We try and save it to the file .directory in the directory being viewed. | ||
54 | // If the directory is not writable by the user or the directory is not local, | 56 | // If the directory is not writable by the user or the directory is not local, | ||
55 | // we store the properties information in a local file. | 57 | // we store the properties information in a local file. | ||
56 | if (useGlobalViewProps) { | 58 | if (useGlobalViewProps) { | ||
57 | m_filePath = destinationDir(QStringLiteral("global")); | 59 | m_filePath = destinationDir(QStringLiteral("global")); | ||
58 | } else if (url.scheme().contains(QStringLiteral("search"))) { | 60 | } else if (url.scheme().contains(QStringLiteral("search"))) { | ||
59 | m_filePath = destinationDir(QStringLiteral("search/")) + directoryHashForUrl(url); | 61 | m_filePath = destinationDir(QStringLiteral("search/")) + directoryHashForUrl(url); | ||
60 | useDetailsViewWithPath = true; | 62 | useDetailsViewWithPath = true; | ||
61 | } else if (url.scheme() == QLatin1String("trash")) { | 63 | } else if (url.scheme() == QLatin1String("trash")) { | ||
62 | m_filePath = destinationDir(QStringLiteral("trash")); | 64 | m_filePath = destinationDir(QStringLiteral("trash")); | ||
63 | useDetailsViewWithPath = true; | 65 | useDetailsViewWithPath = true; | ||
66 | } else if (url.scheme() == QLatin1String("recentdocuments")) { | ||||
67 | m_filePath = destinationDir(QStringLiteral("recentdocuments")); | ||||
68 | useRecentDocumentsView = true; | ||||
69 | } else if (url == QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation))) { | ||||
70 | useDownloadsView = true; | ||||
64 | } else if (url.isLocalFile()) { | 71 | } else if (url.isLocalFile()) { | ||
65 | m_filePath = url.toLocalFile(); | 72 | m_filePath = url.toLocalFile(); | ||
66 | 73 | | |||
67 | bool useDestinationDir = !isPartOfHome(m_filePath); | 74 | bool useDestinationDir = !isPartOfHome(m_filePath); | ||
68 | if (!useDestinationDir) { | 75 | if (!useDestinationDir) { | ||
69 | const QFileInfo dirInfo(m_filePath); | 76 | const QFileInfo dirInfo(m_filePath); | ||
70 | const QFileInfo fileInfo(m_filePath + QDir::separator() + ViewPropertiesFileName); | 77 | const QFileInfo fileInfo(m_filePath + QDir::separator() + ViewPropertiesFileName); | ||
71 | useDestinationDir = !dirInfo.isWritable() || (dirInfo.size() > 0 && fileInfo.exists() && !(fileInfo.isReadable() && fileInfo.isWritable())); | 78 | useDestinationDir = !dirInfo.isWritable() || (dirInfo.size() > 0 && fileInfo.exists() && !(fileInfo.isReadable() && fileInfo.isWritable())); | ||
Show All 17 Lines | |||||
89 | // use default values instead. | 96 | // use default values instead. | ||
90 | const bool useDefaultProps = (!useGlobalViewProps || useDetailsViewWithPath) && | 97 | const bool useDefaultProps = (!useGlobalViewProps || useDetailsViewWithPath) && | ||
91 | (!QFile::exists(file) || | 98 | (!QFile::exists(file) || | ||
92 | (m_node->timestamp() < settings->viewPropsTimestamp())); | 99 | (m_node->timestamp() < settings->viewPropsTimestamp())); | ||
93 | if (useDefaultProps) { | 100 | if (useDefaultProps) { | ||
94 | if (useDetailsViewWithPath) { | 101 | if (useDetailsViewWithPath) { | ||
95 | setViewMode(DolphinView::DetailsView); | 102 | setViewMode(DolphinView::DetailsView); | ||
96 | setVisibleRoles({"path"}); | 103 | setVisibleRoles({"path"}); | ||
104 | } else if (useRecentDocumentsView || useDownloadsView) { | ||||
105 | setSortRole(QByteArrayLiteral("modificationtime")); | ||||
106 | setSortOrder(Qt::DescendingOrder); | ||||
107 | | ||||
108 | if (useRecentDocumentsView) { | ||||
109 | setViewMode(DolphinView::DetailsView); | ||||
110 | setVisibleRoles({"path"}); | ||||
elvisangelaccio: Nitpick: `QByteArrayLiteral` also here. | |||||
111 | } else if (useDownloadsView) { | ||||
112 | setSortFoldersFirst(false); | ||||
113 | setGroupedSorting(true); | ||||
114 | } | ||||
97 | } else { | 115 | } else { | ||
98 | // The global view-properties act as default for directories without | 116 | // The global view-properties act as default for directories without | ||
99 | // any view-property configuration. Constructing a ViewProperties | 117 | // any view-property configuration. Constructing a ViewProperties | ||
100 | // instance for an empty QUrl ensures that the global view-properties | 118 | // instance for an empty QUrl ensures that the global view-properties | ||
101 | // are loaded. | 119 | // are loaded. | ||
102 | QUrl emptyUrl; | 120 | QUrl emptyUrl; | ||
103 | ViewProperties defaultProps(emptyUrl); | 121 | ViewProperties defaultProps(emptyUrl); | ||
104 | setDirProperties(defaultProps); | 122 | setDirProperties(defaultProps); | ||
▲ Show 20 Lines • Show All 389 Lines • Show Last 20 Lines |
Nitpick: QByteArrayLiteral also here.