1 /***************************************************************************
2 * Copyright (c) 2007 Nikolaj Hald Nielsen <nhnFreespirit@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
20 #include "PlaylistAlbumGroup.h"
26 AlbumGroup::AlbumGroup()
32 AlbumGroup::~AlbumGroup()
39 void Playlist::AlbumGroup::addRow(int row
)
43 //Does this row fit in any of our existing groups?
45 for ( int i
= 0; i
< m_groups
.count(); i
++ ) {
47 if ( m_groups
[i
].rows
.last() == row
- 1 ) {
48 m_groups
[i
].rows
.append( row
);
54 //no group found, create new one:
57 newGroup
.collapsed
= false;
58 newGroup
.rows
.append( row
);
59 m_groups
.append( newGroup
);
63 int Playlist::AlbumGroup::groupMode( int row
)
67 foreach( Group group
, m_groups
) {
68 if ( group
.rows
.contains( row
) ) {
70 debug() << "row " << row
<< " is collapsed= " << group
.collapsed
;
72 if ( group
.rows
.count() < 2 )
74 else if ( group
.rows
.first() == row
) {
75 if ( !group
.collapsed
)
78 return Head_Collapsed
;
79 } else if ( group
.rows
.last() == row
) {
80 if ( !group
.collapsed
)
85 if ( !group
.collapsed
)
97 void Playlist::AlbumGroup::setCollapsed(int row
, bool collapsed
)
100 for (int i
= 0; i
< m_groups
.count(); i
++ ) {
101 if ( m_groups
[ i
].rows
.contains( row
) ) {
102 m_groups
[ i
].collapsed
= collapsed
;
103 debug() << "row " << row
<< " collapsed = " << m_groups
[ i
].collapsed
;
108 int Playlist::AlbumGroup::elementsInGroup(int row
)
111 foreach( Group group
, m_groups
) {
112 if ( group
.rows
.contains( row
) ) {
113 return group
.rows
.count();