| 1 |
/**************************************************************************************** |
| 2 |
* Copyright (c) 2008 Nikolaj Hald Nielsen <[email protected]> * |
| 3 |
* Copyright (c) 2010 Oleksandr Khayrullin <[email protected]> * |
| 4 |
* Copyright (c) 2010 Nanno Langstraat <[email protected]> * |
| 5 |
* * |
| 6 |
* This program is free software; you can redistribute it and/or modify it under * |
| 7 |
* the terms of the GNU General Public License as published by the Free Software * |
| 8 |
* Foundation; either version 2 of the License, or (at your option) any later * |
| 9 |
* version. * |
| 10 |
* * |
| 11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * |
| 12 |
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * |
| 13 |
* PARTICULAR PURPOSE. See the GNU General Public License for more details. * |
| 14 |
* * |
| 15 |
* You should have received a copy of the GNU General Public License along with * |
| 16 |
* this program. If not, see <http://www.gnu.org/licenses/>. * |
| 17 |
****************************************************************************************/ |
| 18 |
|
| 19 |
#include "LayoutItemConfig.h" |
| 20 |
|
| 21 |
#include "core/meta/Meta.h" |
| 22 |
#include "playlist/proxymodels/GroupingProxy.h" // For 'GroupMode' |
| 23 |
|
| 24 |
using namespace Playlist; |
| 25 |
|
| 26 |
LayoutItemConfigRowElement::LayoutItemConfigRowElement( int value, qreal size, |
| 27 |
bool bold, bool italic, bool underline, |
| 28 |
Qt::Alignment alignment, |
| 29 |
const QString &prefix , |
| 30 |
const QString &suffix ) |
| 31 |
: m_value( value ) |
| 32 |
, m_size( size ) |
| 33 |
, m_bold( bold ) |
| 34 |
, m_italic( italic ) |
| 35 |
, m_underline( underline ) |
| 36 |
, m_alignment( alignment ) |
| 37 |
, m_prefix( prefix ) |
| 38 |
, m_suffix( suffix ) |
| 39 |
{ |
| 40 |
} |
| 41 |
|
| 42 |
int LayoutItemConfigRowElement::value() const |
| 43 |
{ |
| 44 |
return m_value; |
| 45 |
} |
| 46 |
|
| 47 |
qreal LayoutItemConfigRowElement::size() const |
| 48 |
{ |
| 49 |
return m_size; |
| 50 |
} |
| 51 |
|
| 52 |
void LayoutItemConfigRowElement::setSize( qreal size ) |
| 53 |
{ |
| 54 |
m_size = size; |
| 55 |
} |
| 56 |
|
| 57 |
bool LayoutItemConfigRowElement::bold() const |
| 58 |
{ |
| 59 |
return m_bold; |
| 60 |
} |
| 61 |
|
| 62 |
bool LayoutItemConfigRowElement::italic() const |
| 63 |
{ |
| 64 |
return m_italic; |
| 65 |
} |
| 66 |
|
| 67 |
bool LayoutItemConfigRowElement::underline() const |
| 68 |
{ |
| 69 |
return m_underline; |
| 70 |
} |
| 71 |
|
| 72 |
Qt::Alignment LayoutItemConfigRowElement::alignment() const |
| 73 |
{ |
| 74 |
return m_alignment; |
| 75 |
} |
| 76 |
|
| 77 |
QString LayoutItemConfigRowElement::prefix() const |
| 78 |
{ |
| 79 |
return m_prefix; |
| 80 |
} |
| 81 |
|
| 82 |
QString LayoutItemConfigRowElement::suffix() const |
| 83 |
{ |
| 84 |
return m_suffix; |
| 85 |
} |
| 86 |
|
| 87 |
////////////////////////////////////////////// |
| 88 |
|
| 89 |
void LayoutItemConfigRow::addElement( const LayoutItemConfigRowElement &element ) |
| 90 |
{ |
| 91 |
m_elements.append( element ); |
| 92 |
} |
| 93 |
|
| 94 |
int LayoutItemConfigRow::count() |
| 95 |
{ |
| 96 |
return m_elements.count(); |
| 97 |
} |
| 98 |
|
| 99 |
LayoutItemConfigRowElement LayoutItemConfigRow::element( int at ) |
| 100 |
{ |
| 101 |
return m_elements.at( at ); |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
////////////////////////////////////////////// |
| 106 |
|
| 107 |
LayoutItemConfig::LayoutItemConfig() |
| 108 |
: m_showCover( false ) |
| 109 |
, m_activeIndicatorRow( 0 ) |
| 110 |
{ |
| 111 |
} |
| 112 |
|
| 113 |
LayoutItemConfig::~LayoutItemConfig() |
| 114 |
{ |
| 115 |
} |
| 116 |
|
| 117 |
int LayoutItemConfig::rows() const |
| 118 |
{ |
| 119 |
return m_rows.size(); |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
LayoutItemConfigRow Playlist::LayoutItemConfig::row( int at ) const |
| 124 |
{ |
| 125 |
return m_rows.at( at ); |
| 126 |
} |
| 127 |
|
| 128 |
void Playlist::LayoutItemConfig::addRow( const LayoutItemConfigRow &row ) |
| 129 |
{ |
| 130 |
m_rows.append( row ); |
| 131 |
} |
| 132 |
|
| 133 |
bool LayoutItemConfig::showCover() const |
| 134 |
{ |
| 135 |
return m_showCover; |
| 136 |
} |
| 137 |
|
| 138 |
void Playlist::LayoutItemConfig::setShowCover( bool showCover ) |
| 139 |
{ |
| 140 |
m_showCover = showCover; |
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
int Playlist::LayoutItemConfig::activeIndicatorRow() const |
| 146 |
{ |
| 147 |
return m_activeIndicatorRow; |
| 148 |
} |
| 149 |
|
| 150 |
void Playlist::LayoutItemConfig::setActiveIndicatorRow( int row ) |
| 151 |
{ |
| 152 |
m_activeIndicatorRow = row; |
| 153 |
} |
| 154 |
|
| 155 |
////////////////////////////////////////////// |
| 156 |
|
| 157 |
|
| 158 |
Playlist::PlaylistLayout::PlaylistLayout() |
| 159 |
: m_isEditable(false) |
| 160 |
, m_isDirty(false) |
| 161 |
, m_inlineControls(false) |
| 162 |
, m_tooltips(false) |
| 163 |
{} |
| 164 |
|
| 165 |
Playlist::PlaylistLayout::Part |
| 166 |
Playlist::PlaylistLayout::partForItem( const QModelIndex &index ) const |
| 167 |
{ |
| 168 |
switch ( index.data( GroupRole ).toInt() ) |
| 169 |
{ |
| 170 |
case Grouping::Head: // GroupMode |
| 171 |
case Grouping::Body: |
| 172 |
case Grouping::Tail: |
| 173 |
{ |
| 174 |
Meta::TrackPtr track = index.data( TrackRole ).value<Meta::TrackPtr>(); |
| 175 |
|
| 176 |
if( !track->artist() || !track->album() || !track->album()->albumArtist() || ( track->artist()->name() != track->album()->albumArtist()->name() ) ) |
| 177 |
return VariousArtistsBody; |
| 178 |
else |
| 179 |
return StandardBody; |
| 180 |
} |
| 181 |
|
| 182 |
case Grouping::None: |
| 183 |
default: |
| 184 |
return Single; |
| 185 |
} |
| 186 |
} |
| 187 |
|
| 188 |
LayoutItemConfig |
| 189 |
Playlist::PlaylistLayout::layoutForPart( Part part ) const |
| 190 |
{ |
| 191 |
return m_layoutItemConfigs[part]; |
| 192 |
} |
| 193 |
|
| 194 |
void |
| 195 |
Playlist::PlaylistLayout::setLayoutForPart( Part part, const LayoutItemConfig &itemConfig ) |
| 196 |
{ |
| 197 |
m_layoutItemConfigs[part] = itemConfig; |
| 198 |
} |
| 199 |
|
| 200 |
bool Playlist::PlaylistLayout::isEditable() const |
| 201 |
{ |
| 202 |
return m_isEditable; |
| 203 |
} |
| 204 |
|
| 205 |
bool Playlist::PlaylistLayout::isDirty() const |
| 206 |
{ |
| 207 |
return m_isDirty; |
| 208 |
} |
| 209 |
|
| 210 |
void Playlist::PlaylistLayout::setEditable( bool editable ) |
| 211 |
{ |
| 212 |
m_isEditable = editable; |
| 213 |
} |
| 214 |
|
| 215 |
void Playlist::PlaylistLayout::setDirty( bool dirty ) |
| 216 |
{ |
| 217 |
m_isDirty = dirty; |
| 218 |
} |
| 219 |
|
| 220 |
bool Playlist::PlaylistLayout::inlineControls() |
| 221 |
{ |
| 222 |
return m_inlineControls; |
| 223 |
} |
| 224 |
void Playlist::PlaylistLayout::setInlineControls( bool inlineControls ) |
| 225 |
{ |
| 226 |
m_inlineControls = inlineControls; |
| 227 |
} |
| 228 |
|
| 229 |
bool Playlist::PlaylistLayout::tooltips() |
| 230 |
{ |
| 231 |
return m_tooltips; |
| 232 |
} |
| 233 |
void Playlist::PlaylistLayout::setTooltips( bool tooltips ) |
| 234 |
{ |
| 235 |
m_tooltips = tooltips; |
| 236 |
} |
| 237 |
|
| 238 |
QString Playlist::PlaylistLayout::groupBy() |
| 239 |
{ |
| 240 |
return m_groupBy; |
| 241 |
} |
| 242 |
|
| 243 |
void Playlist::PlaylistLayout::setGroupBy( const QString& groupBy ) |
| 244 |
{ |
| 245 |
m_groupBy = groupBy; |
| 246 |
} |