23.2.  Playlist

[ fromfile: homework/singleplaylist.xml id: playlist ]

  1. Take your starting point example and make it possible to load, save, and clear the current playlist. The model for a playlist should be stored in a class derived (directly or indirectly) from QAbstractItemModel, called PlayListModel.

    The PlayListModel should manage a collection of MetaDataValue (or similar) instances.

    Instead of using a QTableWidget, as the Qt Phonon Example does, extend a QTableView and call it PlayListView.

    The relationships between these classes are shown in Figure 23.2.

    If you wish, reuse the classes MetaDataObject, DataObjectTableModel, SimpleDelegate and others you find in libmetadata from the source tarball in dist.

  2. Make the application remember in QSettings the current playlist filename, table column widths, and size/position of the main window when the user exits.

  3. Restore these QSettings values on startup.

  4. Implement the following player/playlist actions: next, previous, playNext (after this one is done), addFiles, clear, save as, save, and open. Put these actions in the main menu and the context menu of the playlist view. Ensure the named actions actually control the player.

  5. (Optional): Implement a clipboard and actions that work on multiple selections in the table view: removeFiles, copy, cut, and paste here.

Figure 23.2.  Single Playlist

Single Playlist

  See solutions/audiojukebox/singlePlaylist