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/dolphinviewactionhandler.cpp | |
| 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/dolphinviewactionhandler.cpp')
| -rw-r--r-- | src/views/dolphinviewactionhandler.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp index e504fd831..de3facd14 100644 --- a/src/views/dolphinviewactionhandler.cpp +++ b/src/views/dolphinviewactionhandler.cpp @@ -594,6 +594,8 @@ void DolphinViewActionHandler::slotSortOrderChanged(Qt::SortOrder order) const bool sortDescending = (order == Qt::DescendingOrder); descending->setChecked(sortDescending); ascending->setChecked(!sortDescending); + const QByteArray currentRole = m_currentView->sortRole(); + m_currentView->setPreferredSortOrder(currentRole, order); } void DolphinViewActionHandler::slotSortFoldersFirstChanged(bool foldersFirst) @@ -723,13 +725,13 @@ void DolphinViewActionHandler::slotSortRoleChanged(const QByteArray &role) if (role == "text" || role == "type" || role == "extension" || role == "tags" || role == "comment") { descending->setText(i18nc("Sort descending", "Z-A")); ascending->setText(i18nc("Sort ascending", "A-Z")); - } else if (role == "size") { + } else if (role == "size" || role == "width" || role == "height" || role == "pageCount" || role == "wordCount" || role == "lineCount") { descending->setText(i18nc("Sort descending", "Largest First")); ascending->setText(i18nc("Sort ascending", "Smallest First")); - } else if (role == "modificationtime" || role == "creationtime" || role == "accesstime") { + } else if (role == "modificationtime" || role == "creationtime" || role == "accesstime" || role == "imageDateTime" || role == "releaseYear") { descending->setText(i18nc("Sort descending", "Newest First")); ascending->setText(i18nc("Sort ascending", "Oldest First")); - } else if (role == "rating") { + } else if (role == "rating" || role == "bitrate" || role == "frameRate") { descending->setText(i18nc("Sort descending", "Highest First")); ascending->setText(i18nc("Sort ascending", "Lowest First")); } else { |
