Skip to content

Restore directories-first order of passwords tree view on non-Mac platforms#475

Merged
annejan merged 4 commits into
IJHack:masterfrom
maciejsszmigiero:directories-first-order-fix
Sep 23, 2019
Merged

Restore directories-first order of passwords tree view on non-Mac platforms#475
annejan merged 4 commits into
IJHack:masterfrom
maciejsszmigiero:directories-first-order-fix

Conversation

@maciejsszmigiero

Copy link
Copy Markdown
Contributor

Since commit b4dc9e6 ("Auto update CHANGELOG and sorting of treeview")
directories are no longer listed first in the tree view of passwords.

This is because a simple sort of the tree view widget (as enabled by the
aforementioned commit) does its work by sorting the backing
StoreModel (QSortFilterProxyModel), which in turn does just a simple
lexicographical order sort on the path of each its item.

Before that commit the sort was done by QFileSystemModel via
QFileSystemModelSorter, which always places its directories first on
non-Mac platforms.

Unfortunately, QFileSystemModelSorter is an internal Qt helper class, so we
can't just use it directly, we need to open-code a bit of logic from
QFileSystemModelSorter::compareNodes() into StoreModel::lessThan() to
restore the old behavior.

This PR also contains 3 small improvements around the modified code (in
separate commits).

When we are setting the source model in StoreModel::setModelAndStore() set
it also for StoreModel base class to make the extra setSourceModel() call
unnecessary.
…tforms

Since commit b4dc9e6 ("Auto update CHANGELOG and sorting of treeview")
directories are no longer listed first in the tree view of passwords.

This is because a simple sort of the tree view widget (as enabled by the
aforementioned commit) does its work by sorting the backing
StoreModel (QSortFilterProxyModel), which in turn does just a simple
lexicographical order sort on the path of each its item.

Before that commit the sort was done by QFileSystemModel via
QFileSystemModelSorter, which always places its directories first on
non-Mac platforms.

Unfortunately, QFileSystemModelSorter is an internal Qt helper class, so we
can't just use it directly, we need to open-code a bit of logic from
QFileSystemModelSorter::compareNodes() into StoreModel::lessThan() to
restore the old behavior.
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.01%) to 6.938% when pulling a06be7f on maciejsszmigiero:directories-first-order-fix into f9f9fba on IJHack:master.

1 similar comment
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.01%) to 6.938% when pulling a06be7f on maciejsszmigiero:directories-first-order-fix into f9f9fba on IJHack:master.

@codecov

codecov Bot commented Sep 21, 2019

Copy link
Copy Markdown

Codecov Report

Merging #475 into master will decrease coverage by 0.02%.
The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #475      +/-   ##
========================================
- Coverage    7.32%   7.3%   -0.03%     
========================================
  Files          44     44              
  Lines        2798   2806       +8     
========================================
  Hits          205    205              
- Misses       2593   2601       +8
Impacted Files Coverage Δ
src/storemodel.h 0% <ø> (ø) ⬆️
src/mainwindow.cpp 0% <0%> (ø) ⬆️
src/storemodel.cpp 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f9f9fba...a06be7f. Read the comment docs.

@annejan annejan merged commit 9e73083 into IJHack:master Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants