1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-05 05:37:29 +02:00

Introduce Locker style for PlayableProxyModel.

This commit is contained in:
Christian Muehlhaeuser
2015-04-10 05:58:30 +02:00
parent cea45a9bf4
commit 3734167a14
4 changed files with 21 additions and 10 deletions

View File

@@ -120,7 +120,7 @@ PlayableModel::columnCount( const QModelIndex& parent ) const
{ {
Q_UNUSED( parent ); Q_UNUSED( parent );
return 12; return 13;
} }

View File

@@ -49,8 +49,9 @@ PlayableProxyModel::PlayableProxyModel( QObject* parent )
PlayableProxyModel::setSourcePlayableModel( NULL ); PlayableProxyModel::setSourcePlayableModel( NULL );
m_headerStyle[ Fancy ] << PlayableModel::Name; m_headerStyle[ Fancy ] << PlayableModel::Name;
m_headerStyle[ Detailed ] << PlayableModel::Artist << PlayableModel::Track << PlayableModel::Composer << PlayableModel::Album << PlayableModel::Download << PlayableModel::AlbumPos << PlayableModel::Duration << PlayableModel::Bitrate << PlayableModel::Age << PlayableModel::Year << PlayableModel::Filesize << PlayableModel::Origin << PlayableModel::Score; m_headerStyle[ Detailed ] << PlayableModel::Artist << PlayableModel::Track << PlayableModel::Composer << PlayableModel::Album << PlayableModel::AlbumPos << PlayableModel::Duration << PlayableModel::Bitrate << PlayableModel::Age << PlayableModel::Year << PlayableModel::Filesize << PlayableModel::Origin << PlayableModel::Score;
m_headerStyle[ Collection ] << PlayableModel::Name << PlayableModel::Composer << PlayableModel::Duration << PlayableModel::Bitrate << PlayableModel::Age << PlayableModel::Year << PlayableModel::Filesize << PlayableModel::Origin; m_headerStyle[ Collection ] << PlayableModel::Artist << PlayableModel::Track << PlayableModel::Composer << PlayableModel::Album << PlayableModel::AlbumPos << PlayableModel::Duration << PlayableModel::Bitrate << PlayableModel::Age << PlayableModel::Year << PlayableModel::Filesize;
m_headerStyle[ Locker ] << PlayableModel::Artist << PlayableModel::Track << PlayableModel::Composer << PlayableModel::Album << PlayableModel::Download << PlayableModel::AlbumPos << PlayableModel::Duration << PlayableModel::Bitrate << PlayableModel::Age << PlayableModel::Year << PlayableModel::Filesize;
} }
@@ -607,12 +608,16 @@ PlayableProxyModel::columnCount( const QModelIndex& parent ) const
break; break;
case Collection: case Collection:
return 8; return 10;
break;
case Locker:
return 11;
break; break;
case Detailed: case Detailed:
default: default:
return 13; return 12;
break; break;
} }
} }
@@ -669,12 +674,16 @@ PlayableProxyModel::columnWeights() const
break; break;
case Collection: case Collection:
w << 0.42 << 0.12 << 0.07 << 0.07 << 0.07 << 0.07 << 0.07; // << 0.11; w << 0.16 << 0.17 << 0.15 << 0.15 << 0.06 << 0.06 << 0.06 << 0.06 << 0.06; // << 0.07;
break;
case Locker:
w << 0.14 << 0.15 << 0.12 << 0.12 << 0.12 << 0.06 << 0.06 << 0.06 << 0.06 << 0.06; // << 0.05;
break; break;
case Detailed: case Detailed:
default: default:
w << 0.12 << 0.12 << 0.12 << 0.12 << 0.06 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.09; // << 0.03; w << 0.15 << 0.16 << 0.13 << 0.13 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.08; // << 0.05;
break; break;
} }

View File

@@ -47,7 +47,7 @@ Q_OBJECT
public: public:
enum PlayableItemStyle enum PlayableItemStyle
{ Detailed = 0, Fancy = 1, Collection = 2 }; { Detailed = 0, Fancy = 1, Collection = 2, Locker = 3 };
enum PlayableProxyModelRole enum PlayableProxyModelRole
{ StyleRole = Qt::UserRole + 1, TypeRole }; { StyleRole = Qt::UserRole + 1, TypeRole };

View File

@@ -102,7 +102,7 @@ PlaylistItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModel
QSize size = QStyledItemDelegate::sizeHint( option, index ); QSize size = QStyledItemDelegate::sizeHint( option, index );
{ {
if ( m_model->style() == PlayableProxyModel::Detailed ) if ( m_model->style() != PlayableProxyModel::Fancy )
{ {
int rowHeight = option.fontMetrics.height() * 1.6; int rowHeight = option.fontMetrics.height() * 1.6;
size.setHeight( rowHeight ); size.setHeight( rowHeight );
@@ -217,6 +217,8 @@ PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& opti
const int style = index.data( PlayableProxyModel::StyleRole ).toInt(); const int style = index.data( PlayableProxyModel::StyleRole ).toInt();
switch ( style ) switch ( style )
{ {
case PlayableProxyModel::Collection:
case PlayableProxyModel::Locker:
case PlayableProxyModel::Detailed: case PlayableProxyModel::Detailed:
paintDetailed( painter, option, index ); paintDetailed( painter, option, index );
break; break;
@@ -855,7 +857,7 @@ PlaylistItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, con
} }
else if ( hoveringInfo ) else if ( hoveringInfo )
{ {
if ( m_model->style() != PlayableProxyModel::Detailed ) if ( m_model->style() == PlayableProxyModel::Fancy )
{ {
if ( item->query() ) if ( item->query() )
ViewManager::instance()->show( item->query()->track()->toQuery() ); ViewManager::instance()->show( item->query()->track()->toQuery() );