-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement item categorization #44
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support to categorize images into sections.
This took longer than expected because I restructured the entire asynchronous model fillup: Previously, there was one huge class
SortedImageModel
, which took care of initial filling of the model and watching the directory for any changes. This has been split up.Now, there is an
ImageSectionDataContainer
which contains the sections and the individual images (or regular files). This container is threadsafe and accessed for reading by the UI thread and for writing by abackgroundThread
. The container is populated by aDirectoryWorker
, whenever the directory is changed. Additionally, it watches this directory for changes, adds or removes files, and triggers asynchronous decoding for any new files.The container in turn is a friend of the
SortedImageModel
. When adding or removing items, the container calls thebeginInsert-
/beginRemoveRows
functions of the model. In order for this to work without potential deadlocks or delays in event processing, theDirectoryWorker
and theSortedImageModel
are both living in thebackgroundThread
, so that we can useQt::DirectConnection
.We cannot set the
SortedImageModel
directly for aQListView
as both would be living in different threads. However, theQListView
has set aQSortFilterProxyModel
anyway, which are both living in the UI thread. And the latter then has set theSortedImageModel
. Not sure if this is supposed to work, but so far it does.While the model is filled up in the background, one may observe flickering in the QListView (i.e. any already drawn items disappear, appear again, and so on). Not sure how to fix that.
Special thanks to @pmfoss for demonstrating how to implement this kind of item categorization!