Models and Views: PlayList
Models and Views PlayList
- Qt 4 models and views (Section 17.3)
- QActions and QMenus (Section 11.6)
This application has a "central widget" that should display the current playlist. Sometimes it will be a view of a PlayList, but other times, it will show us the contents of a Database. One approach, shown in Figure 25.8 is to make both classes multiply-inherit from QAbstractTableModel, so they can both be viewed in a QTableView.
Figure 25.8. PlayListTableModel
To model a collection of DataObjects as a table, you can reuse DataObjectTableModel. This class determines what to display in each column based on Qt properties. This makes PlayListView much easier to write.
Write a PlayListView class. You do not need to write any code for databases, but keep the design considerations of Figure 25.8 in mind as you write it.
Enhance the GUI you wrote in Section 25.8, by adding a load playlist button. Add a QAction-derived class called LoadPlayListAction. Write the action so that it fills up the contents of the PlayListView.
Make the Mp3Player work so that it can automatically play one song after another in the loaded playlist.
Категории