GSoC 2019 : Week 2 - TreeView with a model using QAbstractItemModel
This blog post provides a brief report on the work I have done in the second week in the coding period of the Google Summer of Code program
Work Planned to be Done:
- Construct a model using a QAbstractItemModel.
- Make a Resource file to handle the data provided to make a treeView resembling a Palette.
- Construct a Model using the .xml file containing all the Palette Items.
Work Done:
Construction of a TreeView with a model using the QAbstractItemModel.
I created the model using the QAbstractItemModel as mentioned on the previous blog since QStandardItemModel will not provide the logic for each of the palette Items and also due to its flexibility. Here, I used a .txt file as the data for the model and made certain changes in the way in which the treeView is displayed.
Started making a treeView along with the Palette Box.
I finally started writing the code for the treeView in the Palette Box. Unfortunately, I couldn’t make the model from the .xml (Musescore/share/workspaces/Basic.cpp) file yet. I have learned how the XML parser works and soon I will be implementing the treeView with the data provided in the .xml file as the model.
Currently, I am working on the treeView to be constructed on the Palette Box with a sample text file as a data for the model, later I will code for the treeView using the .xml file as the data for the model, which will need the class XmlReader.
Comments
> Work Planned [...] 3. Construct a Model using the .xml file containing all the Palette Items.
That might have been your plan but I certainly never expected you to get that far in one week. ;)
> Currently, I am working on the treeView to be constructed on the Palette Box with a sample text file as a data for the model, later I will code for the treeView using the .xml file as the data for the model, which will need the class XmlReader.
I'm not sure if this was written before or after our discussion earlier, but now that you know how the model works I suggest you try to create it in MuseScore. Once that is done you can return to the example project to implement a right-click menu (and probably some buttons for people who don't like using a mouse). Once you know how to do that in your example project you can try it in MuseScore... and so on.
This is the best way to do things because: