Changeset View
Changeset View
Standalone View
Standalone View
src/views/viewproperties.cpp
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 76 | #endif | |||
---|---|---|---|---|---|
85 | 85 | | |||
86 | // If the .directory file does not exist or the timestamp is too old, | 86 | // If the .directory file does not exist or the timestamp is too old, | ||
87 | // use default values instead. | 87 | // use default values instead. | ||
88 | const bool useDefaultProps = (!useGlobalViewProps || useDetailsViewWithPath) && | 88 | const bool useDefaultProps = (!useGlobalViewProps || useDetailsViewWithPath) && | ||
89 | (!QFile::exists(file) || | 89 | (!QFile::exists(file) || | ||
90 | (m_node->timestamp() < settings->viewPropsTimestamp())); | 90 | (m_node->timestamp() < settings->viewPropsTimestamp())); | ||
91 | if (useDefaultProps) { | 91 | if (useDefaultProps) { | ||
92 | if (useDetailsViewWithPath) { | 92 | if (useDetailsViewWithPath) { | ||
93 | setViewMode(DolphinView::DetailsView); | 93 | setViewMode(DolphinView::Mode::DetailsView); | ||
94 | setVisibleRoles({"path"}); | 94 | setVisibleRoles({"path"}); | ||
95 | } else { | 95 | } else { | ||
96 | // The global view-properties act as default for directories without | 96 | // The global view-properties act as default for directories without | ||
97 | // any view-property configuration. Constructing a ViewProperties | 97 | // any view-property configuration. Constructing a ViewProperties | ||
98 | // instance for an empty QUrl ensures that the global view-properties | 98 | // instance for an empty QUrl ensures that the global view-properties | ||
99 | // are loaded. | 99 | // are loaded. | ||
100 | QUrl emptyUrl; | 100 | QUrl emptyUrl; | ||
101 | ViewProperties defaultProps(emptyUrl); | 101 | ViewProperties defaultProps(emptyUrl); | ||
Show All 32 Lines | 131 | { | |||
134 | } | 134 | } | ||
135 | 135 | | |||
136 | delete m_node; | 136 | delete m_node; | ||
137 | m_node = nullptr; | 137 | m_node = nullptr; | ||
138 | } | 138 | } | ||
139 | 139 | | |||
140 | void ViewProperties::setViewMode(DolphinView::Mode mode) | 140 | void ViewProperties::setViewMode(DolphinView::Mode mode) | ||
141 | { | 141 | { | ||
142 | if (m_node->viewMode() != mode) { | 142 | if (DolphinView::Mode(m_node->viewMode()) != mode) { | ||
143 | m_node->setViewMode(mode); | 143 | m_node->setViewMode(static_cast<int>(mode)); | ||
144 | update(); | 144 | update(); | ||
145 | } | 145 | } | ||
146 | } | 146 | } | ||
147 | 147 | | |||
148 | DolphinView::Mode ViewProperties::viewMode() const | 148 | DolphinView::Mode ViewProperties::viewMode() const | ||
149 | { | 149 | { | ||
150 | const int mode = qBound(0, m_node->viewMode(), 2); | 150 | const int mode = qBound(0, m_node->viewMode(), 2); | ||
151 | return static_cast<DolphinView::Mode>(mode); | 151 | return DolphinView::Mode(mode); | ||
152 | } | 152 | } | ||
153 | 153 | | |||
154 | void ViewProperties::setPreviewsShown(bool show) | 154 | void ViewProperties::setPreviewsShown(bool show) | ||
155 | { | 155 | { | ||
156 | if (m_node->previewsShown() != show) { | 156 | if (m_node->previewsShown() != show) { | ||
157 | m_node->setPreviewsShown(show); | 157 | m_node->setPreviewsShown(show); | ||
158 | update(); | 158 | update(); | ||
159 | } | 159 | } | ||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | 233 | { | |||
250 | 250 | | |||
251 | // Add the updated values for the current view-mode | 251 | // Add the updated values for the current view-mode | ||
252 | newVisibleRoles.reserve(roles.count()); | 252 | newVisibleRoles.reserve(roles.count()); | ||
253 | foreach (const QByteArray& role, roles) { | 253 | foreach (const QByteArray& role, roles) { | ||
254 | newVisibleRoles.append(prefix + role); | 254 | newVisibleRoles.append(prefix + role); | ||
255 | } | 255 | } | ||
256 | 256 | | |||
257 | if (oldVisibleRoles != newVisibleRoles) { | 257 | if (oldVisibleRoles != newVisibleRoles) { | ||
258 | const bool markCustomizedDetails = (m_node->viewMode() == DolphinView::DetailsView) | 258 | const bool markCustomizedDetails = (DolphinView::Mode(m_node->viewMode()) == DolphinView::Mode::DetailsView) | ||
259 | && !newVisibleRoles.contains(CustomizedDetailsString); | 259 | && !newVisibleRoles.contains(CustomizedDetailsString); | ||
260 | if (markCustomizedDetails) { | 260 | if (markCustomizedDetails) { | ||
261 | // The additional information of the details-view has been modified. Set a marker, | 261 | // The additional information of the details-view has been modified. Set a marker, | ||
262 | // so that it is allowed to also show no additional information without doing the | 262 | // so that it is allowed to also show no additional information without doing the | ||
263 | // fallback to show the size and date per default. | 263 | // fallback to show the size and date per default. | ||
264 | newVisibleRoles.append(CustomizedDetailsString); | 264 | newVisibleRoles.append(CustomizedDetailsString); | ||
265 | } | 265 | } | ||
266 | 266 | | |||
Show All 33 Lines | 299 | if (role != "text") { | |||
300 | roles.append(role); | 300 | roles.append(role); | ||
301 | } | 301 | } | ||
302 | } | 302 | } | ||
303 | } | 303 | } | ||
304 | 304 | | |||
305 | // For the details view the size and date should be shown per default | 305 | // For the details view the size and date should be shown per default | ||
306 | // until the additional information has been explicitly changed by the user | 306 | // until the additional information has been explicitly changed by the user | ||
307 | const bool useDefaultValues = roles.count() == 1 // "text" | 307 | const bool useDefaultValues = roles.count() == 1 // "text" | ||
308 | && (m_node->viewMode() == DolphinView::DetailsView) | 308 | && (DolphinView::Mode(m_node->viewMode()) == DolphinView::Mode::DetailsView) | ||
309 | && !visibleRoles.contains(CustomizedDetailsString); | 309 | && !visibleRoles.contains(CustomizedDetailsString); | ||
310 | if (useDefaultValues) { | 310 | if (useDefaultValues) { | ||
311 | roles.append("size"); | 311 | roles.append("size"); | ||
312 | roles.append("modificationtime"); | 312 | roles.append("modificationtime"); | ||
313 | } | 313 | } | ||
314 | 314 | | |||
315 | return roles; | 315 | return roles; | ||
316 | } | 316 | } | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 378 | { | |||
380 | path.append("/view_properties/").append(subDir); | 380 | path.append("/view_properties/").append(subDir); | ||
381 | return path; | 381 | return path; | ||
382 | } | 382 | } | ||
383 | 383 | | |||
384 | QString ViewProperties::viewModePrefix() const | 384 | QString ViewProperties::viewModePrefix() const | ||
385 | { | 385 | { | ||
386 | QString prefix; | 386 | QString prefix; | ||
387 | 387 | | |||
388 | switch (m_node->viewMode()) { | 388 | switch (DolphinView::Mode(m_node->viewMode())) { | ||
389 | case DolphinView::IconsView: prefix = QStringLiteral("Icons_"); break; | 389 | case DolphinView::Mode::IconsView: prefix = QStringLiteral("Icons_"); break; | ||
390 | case DolphinView::CompactView: prefix = QStringLiteral("Compact_"); break; | 390 | case DolphinView::Mode::CompactView: prefix = QStringLiteral("Compact_"); break; | ||
391 | case DolphinView::DetailsView: prefix = QStringLiteral("Details_"); break; | 391 | case DolphinView::Mode::DetailsView: prefix = QStringLiteral("Details_"); break; | ||
392 | default: qCWarning(DolphinDebug) << "Unknown view-mode of the view properties"; | 392 | default: qCWarning(DolphinDebug) << "Unknown view-mode of the view properties"; | ||
393 | } | 393 | } | ||
394 | 394 | | |||
395 | return prefix; | 395 | return prefix; | ||
396 | } | 396 | } | ||
397 | 397 | | |||
398 | void ViewProperties::convertAdditionalInfo() | 398 | void ViewProperties::convertAdditionalInfo() | ||
399 | { | 399 | { | ||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |