This week I worked on making the UI interactive and configuring the interaction between the comment model and the storyboard model. I also implemented the switching of modes.
The comment model stores the name and visibility of comment fields. It is responsible for the comments menu’s items. Storyboard model’s items have fields to store the contents of each comment field. So whenever a comment is added to the comment model we need to add a child to each storyboard item. Similarly with removing and moving (reordering) of comment items. I connected signals for removing, adding and moving items from the comment model to storyboard model. This signals were used to perform the required actions. Remove and add signals were easy, but qt does not use the moveRows(..) function for drag and drop. Instead it inserts the row to be moved in the desired place and deletes the row. So basically the moving is faked. This results in rowsAdded, dataChanged and rowsRemoved signals. To get the rowsMoved signal I had to reimplement the mimeData and dropMimeData and call moveRows explicitly. Also we must return false in the dropMimeData function otherwise the row at previous position will be deleted as qt assumes the default actions are being followed.
For drawing the comment boxes we use a QtextDocument and a scrollbar. We store the value to which the item has been scrolled to in a Qt::UserRole field in the index in the model, and use that value to draw the desired part of the text. This makes sure that the data that was visible in the QTextEdit widget while editing is visible when the editor is closed. We also have signals for the scroll bar and its buttons.
There are 3 modes, row, column and grid. Since we have used a QListView it was very easy to implement the three modes. Only the row mode required some extra work as we had to change the orientation of the individual items.
This week I would implement the 3 views, try to get the UI tested by users and run unit tests on the models and debug any problems so far.