Debian Codegraph @

src/playlist/navigators/RepeatAlbumNavigator.cpp

raw
1 /****************************************************************************************
2 * Copyright (c) 2008 Nikolaj Hald Nielsen <[email protected]> *
3 * Copyright (c) 2008 Soren Harward <[email protected]> *
4 * Copyright (c) 2009 Téo Mrnjavac <[email protected]> *
5 * Copyright (c) 2010 Nanno Langstraat <[email protected]> *
6 * *
7 * This program is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU General Public License as published by the Free Software *
9 * Foundation; either version 2 of the License, or (at your option) version 3 or *
10 * any later version accepted by the membership of KDE e.V. (or its successor approved *
11 * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of *
12 * version 3 of the license. *
13 * *
14 * This program is distributed in the hope that it will be useful, but WITHOUT ANY *
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
16 * PARTICULAR PURPOSE. See the GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License along with *
19 * this program. If not, see <http://www.gnu.org/licenses/>. *
20 ****************************************************************************************/
21
22 #define DEBUG_PREFIX "Playlist::RepeatAlbumNavigator"
23
24 #include "RepeatAlbumNavigator.h"
25
26 #include "core/support/Debug.h"
27 #include "core/meta/Meta.h"
28
29
30 Playlist::RepeatAlbumNavigator::RepeatAlbumNavigator()
31 {
32 loadFromSourceModel();
33 }
34
35 void
36 Playlist::RepeatAlbumNavigator::planOne()
37 {
38 DEBUG_BLOCK
39
40 if ( m_plannedItems.isEmpty() )
41 {
42 ItemList itemsInAlbum = m_itemsPerAlbum.value( currentAlbum() ); // May be default-constructed empty list.
43
44 int currentRow = itemsInAlbum.indexOf( currentItem() );
45 if ( currentRow != -1 )
46 {
47 int nextRow = (currentRow + 1) % itemsInAlbum.size(); // Circulate within same album
48 m_plannedItems.append( itemsInAlbum.at( nextRow ) );
49 }
50 else // This happens if 'currentItem() == 0'.
51 {
52 quint64 item = bestFallbackItem();
53 if ( item )
54 m_plannedItems.append( item );
55 }
56 }
57 }