23.4.  Source Selector

[ fromfile: homework/sourceselector.xml id: sourceselector ]

Selecting from a variety of different "sources" is what makes a player very powerful and useful. A source could be any of the following:

One interesting thing they all have in common is that each can be viewed with a QAbstractItemView.

The SourceSelector widget, shown docked on the left in Figure 23.3, permits the user to select the currently viewed "source", which in this case, corresponds to a list of songs.

At any given time, if the user clicks on another "source" in that widget, then the "current playlist" should switch to the chosen one, and the MP3 player should start playing songs from this new playlist next.

Figure 23.3.  Source Selector View

Source Selector View

By clicking on a source in the selector model, the application should change the currently visible table or list view in the central widget. Figure 23.4 shows one possible way to design the classes that provide a view and a selector of a collection of sources.

At any given time, the user can perform an action, Show Now Playing, that changes the central widget so that it is showing what is currently playing, instead of what was last selected by the user in the source selector.

Figure 23.4.  Source Selector and related classes

Source Selector and related classes