mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Merge branch 'release/22.04'
This commit is contained in:
commit
df75b31304
|
@ -37,7 +37,8 @@ ViewProperties::ViewProperties(const QUrl& url) :
|
||||||
{
|
{
|
||||||
GeneralSettings* settings = GeneralSettings::self();
|
GeneralSettings* settings = GeneralSettings::self();
|
||||||
const bool useGlobalViewProps = settings->globalViewProps() || url.isEmpty();
|
const bool useGlobalViewProps = settings->globalViewProps() || url.isEmpty();
|
||||||
bool useDetailsViewWithPath = false;
|
bool useSearchView = false;
|
||||||
|
bool useTrashView = false;
|
||||||
bool useRecentDocumentsView = false;
|
bool useRecentDocumentsView = false;
|
||||||
bool useDownloadsView = false;
|
bool useDownloadsView = false;
|
||||||
|
|
||||||
|
@ -48,16 +49,19 @@ ViewProperties::ViewProperties(const QUrl& url) :
|
||||||
m_filePath = destinationDir(QStringLiteral("global"));
|
m_filePath = destinationDir(QStringLiteral("global"));
|
||||||
} else if (url.scheme().contains(QLatin1String("search"))) {
|
} else if (url.scheme().contains(QLatin1String("search"))) {
|
||||||
m_filePath = destinationDir(QStringLiteral("search/")) + directoryHashForUrl(url);
|
m_filePath = destinationDir(QStringLiteral("search/")) + directoryHashForUrl(url);
|
||||||
useDetailsViewWithPath = true;
|
useSearchView = true;
|
||||||
} else if (url.scheme() == QLatin1String("trash")) {
|
} else if (url.scheme() == QLatin1String("trash")) {
|
||||||
m_filePath = destinationDir(QStringLiteral("trash"));
|
m_filePath = destinationDir(QStringLiteral("trash"));
|
||||||
useDetailsViewWithPath = true;
|
useTrashView = true;
|
||||||
} else if (url.scheme() == QLatin1String("recentdocuments")) {
|
} else if (url.scheme() == QLatin1String("recentdocuments")) {
|
||||||
m_filePath = destinationDir(QStringLiteral("recentdocuments"));
|
m_filePath = destinationDir(QStringLiteral("recentdocuments"));
|
||||||
useRecentDocumentsView = true;
|
useRecentDocumentsView = true;
|
||||||
} else if (url.scheme() == QLatin1String("recentlyused")) {
|
} else if (url.scheme() == QLatin1String("recentlyused")) {
|
||||||
m_filePath = destinationDir(QStringLiteral("recentlyused"));
|
m_filePath = destinationDir(QStringLiteral("recentlyused"));
|
||||||
useRecentDocumentsView = true;
|
useRecentDocumentsView = true;
|
||||||
|
} else if (url.scheme() == QLatin1String("timeline")) {
|
||||||
|
m_filePath = destinationDir(QStringLiteral("timeline"));
|
||||||
|
useRecentDocumentsView = true;
|
||||||
} else if (url.isLocalFile()) {
|
} else if (url.isLocalFile()) {
|
||||||
m_filePath = url.toLocalFile();
|
m_filePath = url.toLocalFile();
|
||||||
|
|
||||||
|
@ -93,23 +97,40 @@ ViewProperties::ViewProperties(const QUrl& url) :
|
||||||
|
|
||||||
// If the .directory file does not exist or the timestamp is too old,
|
// If the .directory file does not exist or the timestamp is too old,
|
||||||
// use default values instead.
|
// use default values instead.
|
||||||
const bool useDefaultProps = (!useGlobalViewProps || useDetailsViewWithPath) &&
|
const bool useDefaultProps = (!useGlobalViewProps || useSearchView || useTrashView || useRecentDocumentsView || useDownloadsView) &&
|
||||||
(!QFile::exists(file) ||
|
(!QFile::exists(file) ||
|
||||||
(m_node->timestamp() < settings->viewPropsTimestamp()));
|
(m_node->timestamp() < settings->viewPropsTimestamp()));
|
||||||
if (useDefaultProps) {
|
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);
|
setViewMode(DolphinView::DetailsView);
|
||||||
setVisibleRoles({"path"});
|
setVisibleRoles({"text", "path", "deletiontime"});
|
||||||
} else if (useRecentDocumentsView || useDownloadsView) {
|
} else if (useRecentDocumentsView || useDownloadsView) {
|
||||||
setSortRole(QByteArrayLiteral("modificationtime"));
|
setSortRole(QByteArrayLiteral("modificationtime"));
|
||||||
setSortOrder(Qt::DescendingOrder);
|
setSortOrder(Qt::DescendingOrder);
|
||||||
|
setSortFoldersFirst(false);
|
||||||
|
setGroupedSorting(true);
|
||||||
|
|
||||||
if (useRecentDocumentsView) {
|
if (useRecentDocumentsView) {
|
||||||
setViewMode(DolphinView::DetailsView);
|
setViewMode(DolphinView::DetailsView);
|
||||||
setVisibleRoles({QByteArrayLiteral("path")});
|
setVisibleRoles({"text", "path", "modificationtime"});
|
||||||
} else if (useDownloadsView) {
|
|
||||||
setSortFoldersFirst(false);
|
|
||||||
setGroupedSorting(true);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// The global view-properties act as default for directories without
|
// The global view-properties act as default for directories without
|
||||||
|
@ -430,7 +451,7 @@ QString ViewProperties::viewModePrefix() const
|
||||||
|
|
||||||
void ViewProperties::convertAdditionalInfo()
|
void ViewProperties::convertAdditionalInfo()
|
||||||
{
|
{
|
||||||
QStringList visibleRoles;
|
QStringList visibleRoles = m_node->visibleRoles();
|
||||||
|
|
||||||
const QStringList additionalInfo = m_node->additionalInfo();
|
const QStringList additionalInfo = m_node->additionalInfo();
|
||||||
if (!additionalInfo.isEmpty()) {
|
if (!additionalInfo.isEmpty()) {
|
||||||
|
@ -438,7 +459,7 @@ void ViewProperties::convertAdditionalInfo()
|
||||||
// to Icons_size, Details_date, ... where the suffix just represents
|
// to Icons_size, Details_date, ... where the suffix just represents
|
||||||
// the internal role. One special-case must be handled: "LinkDestination"
|
// the internal role. One special-case must be handled: "LinkDestination"
|
||||||
// has been used for "destination".
|
// has been used for "destination".
|
||||||
visibleRoles.reserve(additionalInfo.count());
|
visibleRoles.reserve(visibleRoles.count() + additionalInfo.count());
|
||||||
for (const QString& info : additionalInfo) {
|
for (const QString& info : additionalInfo) {
|
||||||
QString visibleRole = info;
|
QString visibleRole = info;
|
||||||
int index = visibleRole.indexOf('_');
|
int index = visibleRole.indexOf('_');
|
||||||
|
@ -450,7 +471,9 @@ void ViewProperties::convertAdditionalInfo()
|
||||||
visibleRole[index] = visibleRole[index].toLower();
|
visibleRole[index] = visibleRole[index].toLower();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
visibleRoles.append(visibleRole);
|
if (!visibleRoles.contains(visibleRole)) {
|
||||||
|
visibleRoles.append(visibleRole);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue