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.
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
Add objects filter to the objects dock #1566
Add objects filter to the objects dock #1566
Changes from 16 commits
bd138a3
9b2c9a5
59d44b4
a821e3d
eb8e1ae
afaf337
6d42d49
0553dbb
2ffaefd
eeb0dd7
e72855d
6ebcdf9
a46173b
6b522ae
4dc0fdb
e425e53
12eaea7
5f6f1df
184bff3
d302c97
3c0a470
9a51d46
e4f3b46
5a59bd7
fd400ad
1ad9ef2
a440d16
b62505e
04cbe51
7bdad99
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we check the state of the model instead? I think
mObjectsView->objectsFilterModel()->filterRegExp().isEmpty()
should work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried doing that but couldn't get it to work properly.
The filter is shared between documents, so suppose we switched from a non-filtered map to a filtered map, the above condition will be satisfied and the state of the new map will be saved overwriting the original saved state, I couldn't figure a clean way to prevent this from happening.
I changed the mFilterWasEmpty map to a single bool variable and got it work properly but had to introduce a small hack for this particular case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, makes sense, thanks for the explanation!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coding style: please put a space after
if
(also fix other three cases)Typo: Resotre
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this seems to work, it is missing a translation step. The returned
index
is an index into themProxyModel
, which is the source model formObjectsFilterModel
. So this should be:There are more functions below missing this.
Since there are a lot of places where you have to make this double translation, I would suggest to introduce two helper functions, for example
mapFromViewModel
andmapToViewModel
. Also, since there are two proxies now, a variable likeproxyIndex
should probably be renamed toviewIndex
for clarity.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a somewhat interesting and not entirely correct check. There is no model, because the parent index is invalid, so a more sensible check may be
if (!sourceParent.isValid())
. However, either check won't work since layers now form a hierarchy and an object layer within a group layer will have a valid parent, which would lead those object layers to be filtered as if they were an object.Of course, group layers are a problem of their own as well, since whether they should be filtered or not would depend on whether any of their child layers are object groups that contain any non-filtered objects.
Fortunately, we know we're dealing with a
MapObjectModel
and I would suggest working through its interface directly instead of requesting data throughQt::DisplayRole
. That way, you can usetoGroupLayer
,toObjectGroup
andtoMapObject
. And to avoid having to convert betweenReversingProxyModel
indexes here, I would change the order in which the two proxies are applied so that the filtering happens before the reversing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree on working directly with the objects, I think it will be better(using toMapObject), I will try doing that and will refactor the proxies code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my previous comment I suggested to replace this code, but just a note here: since
sourceModel()->rowCount(index)
is relatively slow the result should really be saved in a local variable for use in the loop.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
childIndex.isValid()
should not be necessary since you're only requesting data from valid indexes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"type" is a confusing variable name here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be called
groupIndex
according to naming style, but I think it should instead be a convenience override to the previously suggestedmapToViewModel
helper function. Should be markedconst
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean by convenience override.
But here is what I did so far, I moved the getGroupIndex function from the objects dock to the objects view (it uses mapToViewModel for conversion), then made it private and made public helper functions in the objects view(isGroupExpanded, setGroupExpanded), so that the objectsDock can use them without worrying about the conversion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use
nullptr
instead of0
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguments are missing a
&
.