File indexing completed on 2024-05-19 04:49:49
0001 /**************************************************************************************** 0002 * Copyright (c) 2008 Nikolaj Hald Nielsen <nhn@kde.org> * 0003 * Copyright (c) 2010 Oleksandr Khayrullin <saniokh@gmail.com> * 0004 * Copyright (c) 2010 Nanno Langstraat <langstr@gmail.com> * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify it under * 0007 * the terms of the GNU General Public License as published by the Free Software * 0008 * Foundation; either version 2 of the License, or (at your option) any later * 0009 * version. * 0010 * * 0011 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0012 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0013 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License along with * 0016 * this program. If not, see <http://www.gnu.org/licenses/>. * 0017 ****************************************************************************************/ 0018 0019 #include "LayoutItemConfig.h" 0020 0021 #include "core/meta/Meta.h" 0022 #include "playlist/proxymodels/GroupingProxy.h" // For 'GroupMode' 0023 0024 using namespace Playlist; 0025 0026 LayoutItemConfigRowElement::LayoutItemConfigRowElement( int value, qreal size, 0027 bool bold, bool italic, bool underline, 0028 Qt::Alignment alignment, 0029 const QString &prefix , 0030 const QString &suffix ) 0031 : m_value( value ) 0032 , m_size( size ) 0033 , m_bold( bold ) 0034 , m_italic( italic ) 0035 , m_underline( underline ) 0036 , m_alignment( alignment ) 0037 , m_prefix( prefix ) 0038 , m_suffix( suffix ) 0039 { 0040 } 0041 0042 int LayoutItemConfigRowElement::value() const 0043 { 0044 return m_value; 0045 } 0046 0047 qreal LayoutItemConfigRowElement::size() const 0048 { 0049 return m_size; 0050 } 0051 0052 void LayoutItemConfigRowElement::setSize( qreal size ) 0053 { 0054 m_size = size; 0055 } 0056 0057 bool LayoutItemConfigRowElement::bold() const 0058 { 0059 return m_bold; 0060 } 0061 0062 bool LayoutItemConfigRowElement::italic() const 0063 { 0064 return m_italic; 0065 } 0066 0067 bool LayoutItemConfigRowElement::underline() const 0068 { 0069 return m_underline; 0070 } 0071 0072 Qt::Alignment LayoutItemConfigRowElement::alignment() const 0073 { 0074 return m_alignment; 0075 } 0076 0077 QString LayoutItemConfigRowElement::prefix() const 0078 { 0079 return m_prefix; 0080 } 0081 0082 QString LayoutItemConfigRowElement::suffix() const 0083 { 0084 return m_suffix; 0085 } 0086 0087 ////////////////////////////////////////////// 0088 0089 void LayoutItemConfigRow::addElement( const LayoutItemConfigRowElement &element ) 0090 { 0091 m_elements.append( element ); 0092 } 0093 0094 int LayoutItemConfigRow::count() 0095 { 0096 return m_elements.count(); 0097 } 0098 0099 LayoutItemConfigRowElement LayoutItemConfigRow::element( int at ) 0100 { 0101 return m_elements.at( at ); 0102 } 0103 0104 0105 ////////////////////////////////////////////// 0106 0107 LayoutItemConfig::LayoutItemConfig() 0108 : m_showCover( false ) 0109 , m_activeIndicatorRow( 0 ) 0110 { 0111 } 0112 0113 LayoutItemConfig::~LayoutItemConfig() 0114 { 0115 } 0116 0117 int LayoutItemConfig::rows() const 0118 { 0119 return m_rows.size(); 0120 } 0121 0122 0123 LayoutItemConfigRow Playlist::LayoutItemConfig::row( int at ) const 0124 { 0125 return m_rows.at( at ); 0126 } 0127 0128 void Playlist::LayoutItemConfig::addRow( const LayoutItemConfigRow &row ) 0129 { 0130 m_rows.append( row ); 0131 } 0132 0133 bool LayoutItemConfig::showCover() const 0134 { 0135 return m_showCover; 0136 } 0137 0138 void Playlist::LayoutItemConfig::setShowCover( bool showCover ) 0139 { 0140 m_showCover = showCover; 0141 } 0142 0143 0144 0145 int Playlist::LayoutItemConfig::activeIndicatorRow() const 0146 { 0147 return m_activeIndicatorRow; 0148 } 0149 0150 void Playlist::LayoutItemConfig::setActiveIndicatorRow( int row ) 0151 { 0152 m_activeIndicatorRow = row; 0153 } 0154 0155 ////////////////////////////////////////////// 0156 0157 0158 Playlist::PlaylistLayout::PlaylistLayout() 0159 : m_isEditable(false) 0160 , m_isDirty(false) 0161 , m_inlineControls(false) 0162 , m_tooltips(false) 0163 {} 0164 0165 Playlist::PlaylistLayout::Part 0166 Playlist::PlaylistLayout::partForItem( const QModelIndex &index ) const 0167 { 0168 switch ( index.data( GroupRole ).toInt() ) 0169 { 0170 case Grouping::Head: // GroupMode 0171 case Grouping::Body: 0172 case Grouping::Tail: 0173 { 0174 Meta::TrackPtr track = index.data( TrackRole ).value<Meta::TrackPtr>(); 0175 0176 if( !track->artist() || !track->album() || !track->album()->albumArtist() || ( track->artist()->name() != track->album()->albumArtist()->name() ) ) 0177 return VariousArtistsBody; 0178 else 0179 return StandardBody; 0180 } 0181 0182 case Grouping::None: 0183 default: 0184 return Single; 0185 } 0186 } 0187 0188 LayoutItemConfig 0189 Playlist::PlaylistLayout::layoutForPart( Part part ) const 0190 { 0191 return m_layoutItemConfigs[part]; 0192 } 0193 0194 void 0195 Playlist::PlaylistLayout::setLayoutForPart( Part part, const LayoutItemConfig &itemConfig ) 0196 { 0197 m_layoutItemConfigs[part] = itemConfig; 0198 } 0199 0200 bool Playlist::PlaylistLayout::isEditable() const 0201 { 0202 return m_isEditable; 0203 } 0204 0205 bool Playlist::PlaylistLayout::isDirty() const 0206 { 0207 return m_isDirty; 0208 } 0209 0210 void Playlist::PlaylistLayout::setEditable( bool editable ) 0211 { 0212 m_isEditable = editable; 0213 } 0214 0215 void Playlist::PlaylistLayout::setDirty( bool dirty ) 0216 { 0217 m_isDirty = dirty; 0218 } 0219 0220 bool Playlist::PlaylistLayout::inlineControls() 0221 { 0222 return m_inlineControls; 0223 } 0224 void Playlist::PlaylistLayout::setInlineControls( bool inlineControls ) 0225 { 0226 m_inlineControls = inlineControls; 0227 } 0228 0229 bool Playlist::PlaylistLayout::tooltips() 0230 { 0231 return m_tooltips; 0232 } 0233 void Playlist::PlaylistLayout::setTooltips( bool tooltips ) 0234 { 0235 m_tooltips = tooltips; 0236 } 0237 0238 QString Playlist::PlaylistLayout::groupBy() 0239 { 0240 return m_groupBy; 0241 } 0242 0243 void Playlist::PlaylistLayout::setGroupBy( const QString& groupBy ) 0244 { 0245 m_groupBy = groupBy; 0246 }