diff options
| author | Nathan Williams <[email protected]> | 2025-09-11 02:28:16 +0000 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2025-09-11 02:28:16 +0000 |
| commit | ad6ccf2b86b3e97138d13518bd6ea8fd670d3530 (patch) | |
| tree | 037014cce040a7108bedf351e632dd6ad499daca /src/views/dolphinview.h | |
| parent | 1aff5f40191b08f4b9361af74bb65bfcc43ad41f (diff) | |
dolphinview: add preferred sort order for roles
BUG: 425457
This commit ensures that both the menu and column headers in table view
will have the same default sorting (ascending/descending) for each role.
It also saves the user's preferences for each role throughout the session.
Previously, sorting by "Modified" would always sort by "Oldest First."
If the user then changed to "Newest First" and sorted again by "Name,"
files would be sorted in reverse alphabetical order (Z-A).
Now, sorting by "Modified" defaults to "Newest First." If a user switches
between multiple roles, the default for each role will be used unless
the user changes to a non-default sort order. In that case, the user's
preference will be applied.
Defaults:
**Descending Order:**
Time-based roles
- modificationtime
- creationtime
- accesstime
- deletiontime
- imageDateTime
- releaseYear
Size/dimension roles
- size
- width
- height
- pageCount
- wordCount
- lineCount
Quality/Quantity roles
- rating
- duration
- bitrate
- frameRate
**Ascending order:**
- Text based roles (A-Z)
- All other roles
Diffstat (limited to 'src/views/dolphinview.h')
| -rw-r--r-- | src/views/dolphinview.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index f491b6dd5..7c077d292 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -234,6 +234,18 @@ public: QList<QByteArray> visibleRoles() const; /** + * Returns the preferred sort order for a given role, taking into account + * user preferences and default sort orders. + */ + Qt::SortOrder preferredSortOrder(const QByteArray &role) const; + + /** + * Sets the preferred sort order for a given role. This remembers user + * preferences when switching between different sort roles. + */ + void setPreferredSortOrder(const QByteArray &role, Qt::SortOrder order); + + /** * Refreshes the view to get synchronized with the settings (e.g. icons size, * font, ...). */ @@ -337,6 +349,13 @@ public: static QUrl openItemAsFolderUrl(const KFileItem &item, const bool browseThroughArchives = true); /** + * Set the default order for a given sort role. + * Time-based roles, size/dimension roles, and quality/quantity roles + * default to descending order. All other roles default to ascending order. + */ + static Qt::SortOrder defaultSortOrderForRole(const QByteArray &role); + + /** * Hides tooltip displayed over element. */ void hideToolTip(const ToolTipManager::HideBehavior behavior = ToolTipManager::HideBehavior::Later); @@ -988,6 +1007,9 @@ private: /// Used for selection mode. @see setSelectionMode() std::unique_ptr<QProxyStyle> m_proxyStyle; + /// Hash table of user-preferred sort orders for each role + QHash<QByteArray, Qt::SortOrder> m_rolesSortOrder; + // For unit tests friend class TestBase; friend class DolphinDetailsViewTest; |
