Review Request 123352: Fix DockerStylesComboModel

Friedrich W. H. Kossebau kossebau at kde.org
Thu Apr 16 00:34:54 BST 2015


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/123352/#review79010
-----------------------------------------------------------


> The problem is that the index in the StylesModel is changed but not index in the DockerStylesComboModel.cpp mapping.
Therefor all 3 styles pointing to the same index.

Sir, this was a sub-optimal description of the problem. If you want to help your reviewers, please spent a few more minutes to give a more complete description as you have it in your mind after all your investigation.
To grasp what the issue is in the end if had to debug things myself for an hour, and then also your code changes... Not perfect to win me also for future reviews ;)

So the problem as I understood it now is that once a new style gets added to the source StyleModel, it will invalidate any modelindizes of the styles in the source model which are at the row and below where the new style gets inserted at. StylesModel properly signals that event to the outside world from what I saw. And StylesFilteredModelBase catches that signal, invoking createMapping() for that. Which seems okayish given that there are usually just <100 styles. So I would agree that just recreating the complete mapping including the list of source indices in createMapping() make sense. And it also catches any other possible invalidation of the source indices, e.g. on removing a style.

>From what I tested quickly, it seems to work now as promoted :) No shipit yet, have a few open questions.


plugins/textshape/dialogs/DockerStylesComboModel.cpp (line 152)
<https://git.reviewboard.kde.org/r/123352/#comment53985>

    The old code allowed the NoneStyle only as the first item in the source model. This code is okay in whatever position it is passed.
    So we trust here the source model to pass the NoneStyle as first, or if not, that any other position also makes sense?
    Worth at least a comment, perhaps.



plugins/textshape/dialogs/DockerStylesComboModel.cpp (line 156)
<https://git.reviewboard.kde.org/r/123352/#comment53986>

    Perhaps join this condition with the one before into one or'ed condition, as the handling is identical.



plugins/textshape/dialogs/DockerStylesComboModel.cpp (lines 157 - 158)
<https://git.reviewboard.kde.org/r/123352/#comment53987>

    Why no longer explicitely sort by names? This change is not mentioned in the patch description, please tell the motivation for this change. Can proper sorting be assumed to exist in the source model? I could not find this promise in the API dox of `StylesModel`, so please help me why this change is okay :)


- Friedrich W. H. Kossebau


On April 13, 2015, 2:01 nachm., Thorsten Zachmann wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/123352/
> -----------------------------------------------------------
> 
> (Updated April 13, 2015, 2:01 nachm.)
> 
> 
> Review request for Calligra.
> 
> 
> Repository: calligra
> 
> 
> Description
> -------
> 
> This patch fixes the style combo box showing the wrong name for a style after adding a style.
> 
> To reproduce the problem:
> 
> Create a new stage document (Template Screen Empty):
> Add a text shape
> Write one line of text
> Assign the text the paragraph style Standard.
> Change to center alignment.
> Use the plus button in the paragraph style to assign it the new name S2.
> Change the alignment to right.
> Use the plus button in the paragraph style to assign it the new name S1.
> 
> Now open the combobox and scroll to the top. It will show 3 times S1.
> The problem is that the index in the StylesModel is changed but not index in the DockerStylesComboModel.cpp mapping.
> Therefor all 3 styles pointing to the same index.
> 
> As the model is recreated all the time it just also newly creates the mapping simplifying the code in doing so.
> It also changes the magic -1 to be a Constant.
> 
> 
> Diffs
> -----
> 
>   plugins/textshape/dialogs/DockerStylesComboModel.cpp 409a9f1 
>   plugins/textshape/dialogs/StylesModel.h d15651f 
>   plugins/textshape/dialogs/StylesModel.cpp f996824 
> 
> Diff: https://git.reviewboard.kde.org/r/123352/diff/
> 
> 
> Testing
> -------
> 
> Tested adding of various style with different names. Worked quite nicly
> 
> 
> Thanks,
> 
> Thorsten Zachmann
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/calligra-devel/attachments/20150415/b7b40701/attachment.htm>


More information about the calligra-devel mailing list