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

Merge remote-tracking branch 'origin/master' into specfilescanning

This commit is contained in:
Jeff Mitchell
2012-07-02 17:55:02 -04:00
28 changed files with 551 additions and 184 deletions

View File

@@ -48,6 +48,7 @@ set( libGuiSources
infobar/InfoBar.cpp infobar/InfoBar.cpp
playlist/FlexibleView.cpp
playlist/TreeModel.cpp playlist/TreeModel.cpp
playlist/TreeProxyModel.cpp playlist/TreeProxyModel.cpp
playlist/TreeProxyModelPlaylistInterface.cpp playlist/TreeProxyModelPlaylistInterface.cpp

View File

@@ -27,6 +27,7 @@
#include "infobar/InfoBar.h" #include "infobar/InfoBar.h"
#include "topbar/TopBar.h" #include "topbar/TopBar.h"
#include "FlexibleView.h"
#include "TreeModel.h" #include "TreeModel.h"
#include "PlaylistModel.h" #include "PlaylistModel.h"
#include "PlaylistView.h" #include "PlaylistView.h"
@@ -94,6 +95,7 @@ ViewManager::ViewManager( QObject* parent )
m_widget->layout()->addWidget( m_contextWidget ); m_widget->layout()->addWidget( m_contextWidget );
m_superCollectionView = new TreeView(); m_superCollectionView = new TreeView();
m_superCollectionView->proxyModel()->setStyle( PlayableProxyModel::Collection );
m_superCollectionModel = new TreeModel( m_superCollectionView ); m_superCollectionModel = new TreeModel( m_superCollectionView );
m_superCollectionView->setTreeModel( m_superCollectionModel ); m_superCollectionView->setTreeModel( m_superCollectionModel );
m_superCollectionView->setShowModes( false ); m_superCollectionView->setShowModes( false );
@@ -137,16 +139,20 @@ ViewManager::~ViewManager()
} }
PlaylistView* FlexibleView*
ViewManager::createPageForPlaylist( const playlist_ptr& pl ) ViewManager::createPageForPlaylist( const playlist_ptr& playlist )
{ {
PlaylistView* view = new PlaylistView(); FlexibleView* view = new FlexibleView();
PlaylistModel* model = new PlaylistModel(); PlaylistModel* model = new PlaylistModel();
view->setPlaylistModel( model ); view->setPlayableModel( model );
model->loadPlaylist( pl );
pl->resolve(); PlaylistView* pv = new PlaylistView();
pv->setPlaylistModel( model );
view->setDetailedView( pv );
model->loadPlaylist( playlist );
playlist->resolve();
m_playlistViews.insert( pl, view );
return view; return view;
} }
@@ -170,11 +176,12 @@ ViewManager::playlistForPage( ViewPage* page ) const
Tomahawk::ViewPage* Tomahawk::ViewPage*
ViewManager::show( const Tomahawk::playlist_ptr& playlist ) ViewManager::show( const Tomahawk::playlist_ptr& playlist )
{ {
PlaylistView* view; FlexibleView* view;
if ( !m_playlistViews.contains( playlist ) || m_playlistViews.value( playlist ).isNull() ) if ( !m_playlistViews.contains( playlist ) || m_playlistViews.value( playlist ).isNull() )
{ {
view = createPageForPlaylist( playlist ); view = createPageForPlaylist( playlist );
m_playlistViews.insert( playlist, view );
} }
else else
{ {
@@ -182,7 +189,6 @@ ViewManager::show( const Tomahawk::playlist_ptr& playlist )
} }
setPage( view ); setPage( view );
emit numSourcesChanged( SourceList::instance()->count() ); emit numSourcesChanged( SourceList::instance()->count() );
return view; return view;
@@ -303,6 +309,7 @@ ViewManager::show( const Tomahawk::collection_ptr& collection )
if ( !m_treeViews.contains( collection ) || m_treeViews.value( collection ).isNull() ) if ( !m_treeViews.contains( collection ) || m_treeViews.value( collection ).isNull() )
{ {
view = new TreeView(); view = new TreeView();
view->proxyModel()->setStyle( PlayableProxyModel::Collection );
TreeModel* model = new TreeModel(); TreeModel* model = new TreeModel();
view->setTreeModel( model ); view->setTreeModel( model );
@@ -486,7 +493,7 @@ ViewManager::showRecentPlaysPage()
RecentlyPlayedModel* raModel = new RecentlyPlayedModel( pv ); RecentlyPlayedModel* raModel = new RecentlyPlayedModel( pv );
raModel->setTitle( tr( "Recently Played Tracks" ) ); raModel->setTitle( tr( "Recently Played Tracks" ) );
raModel->setDescription( tr( "Recently played tracks from all your friends" ) ); raModel->setDescription( tr( "Recently played tracks from all your friends" ) );
raModel->setStyle( PlayableModel::Large ); pv->proxyModel()->setStyle( PlayableProxyModel::Large );
PlaylistLargeItemDelegate* del = new PlaylistLargeItemDelegate( PlaylistLargeItemDelegate::RecentlyPlayed, pv, pv->proxyModel() ); PlaylistLargeItemDelegate* del = new PlaylistLargeItemDelegate( PlaylistLargeItemDelegate::RecentlyPlayed, pv, pv->proxyModel() );
connect( del, SIGNAL( updateIndex( QModelIndex ) ), pv, SLOT( update( QModelIndex ) ) ); connect( del, SIGNAL( updateIndex( QModelIndex ) ), pv, SLOT( update( QModelIndex ) ) );
@@ -737,12 +744,16 @@ ViewManager::saveCurrentPlaylistSettings()
TomahawkSettings* s = TomahawkSettings::instance(); TomahawkSettings* s = TomahawkSettings::instance();
Tomahawk::playlist_ptr pl = playlistForInterface( currentPlaylistInterface() ); Tomahawk::playlist_ptr pl = playlistForInterface( currentPlaylistInterface() );
if ( !pl.isNull() ) { if ( !pl.isNull() )
{
s->setShuffleState( pl->guid(), currentPlaylistInterface()->shuffled() ); s->setShuffleState( pl->guid(), currentPlaylistInterface()->shuffled() );
s->setRepeatMode( pl->guid(), currentPlaylistInterface()->repeatMode() ); s->setRepeatMode( pl->guid(), currentPlaylistInterface()->repeatMode() );
} else { }
else
{
Tomahawk::dynplaylist_ptr dynPl = dynamicPlaylistForInterface( currentPlaylistInterface() ); Tomahawk::dynplaylist_ptr dynPl = dynamicPlaylistForInterface( currentPlaylistInterface() );
if ( !dynPl.isNull() ) { if ( !dynPl.isNull() )
{
s->setShuffleState( dynPl->guid(), currentPlaylistInterface()->shuffled() ); s->setShuffleState( dynPl->guid(), currentPlaylistInterface()->shuffled() );
s->setRepeatMode( dynPl->guid(), currentPlaylistInterface()->repeatMode() ); s->setRepeatMode( dynPl->guid(), currentPlaylistInterface()->repeatMode() );
} }
@@ -977,7 +988,7 @@ ViewManager::currentPage() const
Tomahawk::playlist_ptr Tomahawk::playlist_ptr
ViewManager::playlistForInterface( Tomahawk::playlistinterface_ptr interface ) const ViewManager::playlistForInterface( Tomahawk::playlistinterface_ptr interface ) const
{ {
foreach ( QWeakPointer<PlaylistView> view, m_playlistViews.values() ) foreach ( QWeakPointer<FlexibleView> view, m_playlistViews.values() )
{ {
if ( !view.isNull() && view.data()->playlistInterface() == interface ) if ( !view.isNull() && view.data()->playlistInterface() == interface )
{ {

View File

@@ -40,6 +40,7 @@ class ArtistInfoWidget;
class TreeView; class TreeView;
class CollectionModel; class CollectionModel;
class ContextWidget; class ContextWidget;
class FlexibleView;
class PlaylistModel; class PlaylistModel;
class PlaylistView; class PlaylistView;
class TrackProxyModel; class TrackProxyModel;
@@ -104,7 +105,7 @@ public:
// only use this is you need to create a playlist and show it directly and want it to be // only use this is you need to create a playlist and show it directly and want it to be
// linked to the sidebar. call it right after creating the playlist // linked to the sidebar. call it right after creating the playlist
PlaylistView* createPageForPlaylist( const Tomahawk::playlist_ptr& pl ); FlexibleView* createPageForPlaylist( const Tomahawk::playlist_ptr& playlist );
bool isTomahawkLoaded() const { return m_loaded; } bool isTomahawkLoaded() const { return m_loaded; }
@@ -220,7 +221,7 @@ private:
QHash< Tomahawk::artist_ptr, QWeakPointer<ArtistInfoWidget> > m_artistViews; QHash< Tomahawk::artist_ptr, QWeakPointer<ArtistInfoWidget> > m_artistViews;
QHash< Tomahawk::album_ptr, QWeakPointer<AlbumInfoWidget> > m_albumViews; QHash< Tomahawk::album_ptr, QWeakPointer<AlbumInfoWidget> > m_albumViews;
QHash< Tomahawk::query_ptr, QWeakPointer<TrackInfoWidget> > m_trackViews; QHash< Tomahawk::query_ptr, QWeakPointer<TrackInfoWidget> > m_trackViews;
QHash< Tomahawk::playlist_ptr, QWeakPointer<PlaylistView> > m_playlistViews; QHash< Tomahawk::playlist_ptr, QWeakPointer<FlexibleView> > m_playlistViews;
QHash< Tomahawk::source_ptr, QWeakPointer<SourceInfoWidget> > m_sourceViews; QHash< Tomahawk::source_ptr, QWeakPointer<SourceInfoWidget> > m_sourceViews;
QList<Tomahawk::ViewPage*> m_pageHistoryBack; QList<Tomahawk::ViewPage*> m_pageHistoryBack;

View File

@@ -35,7 +35,7 @@ RelatedArtistsContext::RelatedArtistsContext()
m_relatedView->setGuid( "RelatedArtistsContext" ); m_relatedView->setGuid( "RelatedArtistsContext" );
m_relatedView->setUpdatesContextView( false ); m_relatedView->setUpdatesContextView( false );
m_relatedModel = new TreeModel( m_relatedView ); m_relatedModel = new TreeModel( m_relatedView );
m_relatedModel->setStyle( TreeModel::Large ); m_relatedView->proxyModel()->setStyle( PlayableProxyModel::Large );
m_relatedView->setTreeModel( m_relatedModel ); m_relatedView->setTreeModel( m_relatedModel );
m_relatedView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_relatedView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
m_relatedView->setSortingEnabled( false ); m_relatedView->setSortingEnabled( false );

View File

@@ -33,7 +33,7 @@ TopTracksContext::TopTracksContext()
m_topHitsView->setGuid( "TopTracksContext" ); m_topHitsView->setGuid( "TopTracksContext" );
m_topHitsView->setUpdatesContextView( false ); m_topHitsView->setUpdatesContextView( false );
m_topHitsModel = new PlaylistModel( m_topHitsView ); m_topHitsModel = new PlaylistModel( m_topHitsView );
m_topHitsModel->setStyle( PlayableModel::Short ); m_topHitsView->proxyModel()->setStyle( PlayableProxyModel::Short );
m_topHitsView->setPlaylistModel( m_topHitsModel ); m_topHitsView->setPlaylistModel( m_topHitsModel );
m_topHitsView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_topHitsView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );

View File

@@ -34,7 +34,7 @@ CustomPlaylistView::CustomPlaylistView( CustomPlaylistView::PlaylistType type, c
, m_model( new PlaylistModel( this ) ) , m_model( new PlaylistModel( this ) )
{ {
// Generate the tracks, add them to the playlist // Generate the tracks, add them to the playlist
m_model->setStyle( PlayableModel::Large ); proxyModel()->setStyle( PlayableProxyModel::Large );
setPlaylistModel( m_model ); setPlaylistModel( m_model );
generateTracks(); generateTracks();

View File

@@ -0,0 +1,237 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2012, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "FlexibleView.h"
#include <QRadioButton>
#include <QStackedWidget>
#include <QVBoxLayout>
#include "playlist/PlayableModel.h"
#include "playlist/TrackView.h"
#include "playlist/GridView.h"
#include "playlist/PlaylistLargeItemDelegate.h"
#include "utils/Closure.h"
#include "utils/TomahawkUtilsGui.h"
#include "utils/Logger.h"
using namespace Tomahawk;
FlexibleView::FlexibleView( QWidget* parent )
: QWidget( parent )
, m_trackView( new TrackView() )
, m_detailedView( new TrackView() )
, m_gridView( new GridView() )
, m_model( 0 )
{
qRegisterMetaType< FlexibleViewMode >( "FlexibleViewMode" );
PlaylistLargeItemDelegate* del = new PlaylistLargeItemDelegate( PlaylistLargeItemDelegate::LovedTracks, m_trackView, m_trackView->proxyModel() );
connect( del, SIGNAL( updateIndex( QModelIndex ) ), m_trackView, SLOT( update( QModelIndex ) ) );
m_trackView->setItemDelegate( del );
m_trackView->proxyModel()->setStyle( PlayableProxyModel::Large );
m_stack = new QStackedWidget();
setLayout( new QVBoxLayout() );
TomahawkUtils::unmarginLayout( layout() );
QWidget* modeBar = new QWidget();
modeBar->setLayout( new QHBoxLayout() );
TomahawkUtils::unmarginLayout( modeBar->layout() );
QWidget* modeWidget = new QWidget();
modeWidget->setLayout( new QHBoxLayout() );
modeWidget->setFixedSize( QSize( 87, 30 ) );
TomahawkUtils::unmarginLayout( modeWidget->layout() );
QRadioButton* radioNormal = new QRadioButton();
radioNormal->setObjectName( "radioNormal" );
QRadioButton* radioDetailed = new QRadioButton();
radioDetailed->setObjectName( "radioDetailed" );
QRadioButton* radioCloud = new QRadioButton();
radioCloud->setObjectName( "radioCloud" );
radioNormal->setFocusPolicy( Qt::NoFocus );
radioDetailed->setFocusPolicy( Qt::NoFocus );
radioCloud->setFocusPolicy( Qt::NoFocus );
QFile f( RESPATH "stylesheets/topbar-radiobuttons.css" );
f.open( QFile::ReadOnly );
QString css = QString::fromAscii( f.readAll() );
f.close();
modeWidget->setStyleSheet( css );
modeWidget->layout()->addWidget( radioNormal );
modeWidget->layout()->addWidget( radioDetailed );
modeWidget->layout()->addWidget( radioCloud );
modeWidget->layout()->addItem( new QSpacerItem( 1, 1, QSizePolicy::Expanding, QSizePolicy::Fixed ) );
modeBar->layout()->addItem( new QSpacerItem( 1, 1, QSizePolicy::Expanding, QSizePolicy::Fixed ) );
modeBar->layout()->addWidget( modeWidget );
modeBar->layout()->addItem( new QSpacerItem( 1, 1, QSizePolicy::Expanding, QSizePolicy::Fixed ) );
layout()->addWidget( modeBar );
layout()->addWidget( m_stack );
m_stack->addWidget( m_trackView );
m_stack->addWidget( m_detailedView );
m_stack->addWidget( m_gridView );
radioNormal->setChecked( true );
setCurrentMode( Flat );
NewClosure( radioNormal, SIGNAL( clicked() ), const_cast< FlexibleView* >( this ), SLOT( setCurrentMode( FlexibleViewMode ) ), Flat )->setAutoDelete( false );
NewClosure( radioDetailed, SIGNAL( clicked() ), const_cast< FlexibleView* >( this ), SLOT( setCurrentMode( FlexibleViewMode ) ), Detailed )->setAutoDelete( false );
NewClosure( radioCloud, SIGNAL( clicked() ), const_cast< FlexibleView* >( this ), SLOT( setCurrentMode( FlexibleViewMode ) ), Grid )->setAutoDelete( false );
}
FlexibleView::~FlexibleView()
{
tDebug() << Q_FUNC_INFO;
}
void
FlexibleView::setTrackView( TrackView* view )
{
if ( m_trackView )
{
delete m_trackView;
}
m_trackView = view;
m_stack->addWidget( view );
}
void
FlexibleView::setDetailedView( TrackView* view )
{
if ( m_detailedView )
{
delete m_detailedView;
}
m_detailedView = view;
m_stack->addWidget( view );
}
void
FlexibleView::setGridView( GridView* view )
{
if ( m_gridView )
{
delete m_gridView;
}
m_gridView = view;
m_stack->addWidget( view );
}
void
FlexibleView::setPlayableModel( PlayableModel* model )
{
if ( m_model )
{
delete m_model;
}
m_model = model;
m_trackView->setPlayableModel( model );
m_detailedView->setPlayableModel( model );
m_gridView->setPlayableModel( model );
m_trackView->setSortingEnabled( false );
m_trackView->sortByColumn( -1 );
m_trackView->proxyModel()->sort( -1 );
m_detailedView->proxyModel()->sort( -1 );
m_gridView->proxyModel()->sort( -1 );
}
void
FlexibleView::setCurrentMode( FlexibleViewMode mode )
{
m_mode = mode;
switch ( mode )
{
case Flat:
{
m_stack->setCurrentWidget( m_trackView );
break;
}
case Detailed:
{
m_stack->setCurrentWidget( m_detailedView );
break;
}
case Grid:
{
m_stack->setCurrentWidget( m_gridView );
break;
}
}
emit modeChanged( mode );
}
Tomahawk::playlistinterface_ptr
FlexibleView::playlistInterface() const
{
return m_trackView->playlistInterface();
}
QString
FlexibleView::title() const
{
return m_trackView->title();
}
QString
FlexibleView::description() const
{
return m_trackView->description();
}
QPixmap
FlexibleView::pixmap() const
{
return m_trackView->pixmap();
}
bool
FlexibleView::jumpToCurrentTrack()
{
m_trackView->jumpToCurrentTrack();
m_detailedView->jumpToCurrentTrack();
m_gridView->jumpToCurrentTrack();
return true;
}

View File

@@ -0,0 +1,83 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2012, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FLEXIBLEVIEW_H
#define FLEXIBLEVIEW_H
#include "ViewPage.h"
#include "PlaylistInterface.h"
#include "DllMacro.h"
class QStackedWidget;
class GridView;
class TrackView;
class PlayableModel;
class DLLEXPORT FlexibleView : public QWidget, public Tomahawk::ViewPage
{
Q_OBJECT
public:
enum FlexibleViewMode
{ Flat = 0, Detailed = 1, Grid = 2 };
explicit FlexibleView( QWidget* parent = 0 );
~FlexibleView();
virtual QWidget* widget() { return this; }
virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
virtual QString title() const;
virtual QString description() const;
virtual QPixmap pixmap() const;
virtual bool showStatsBar() const { return false; }
virtual bool showFilter() const { return true; }
// virtual void setShowModes( bool b ) { m_showModes = b; }
virtual bool showModes() const { return false; }
virtual bool jumpToCurrentTrack();
void setTrackView( TrackView* view );
void setDetailedView( TrackView* view );
void setGridView( GridView* view );
void setPlayableModel( PlayableModel* model );
public slots:
void setCurrentMode( FlexibleViewMode mode );
signals:
void modeChanged( FlexibleViewMode mode );
private:
TrackView* m_trackView;
TrackView* m_detailedView;
GridView* m_gridView;
PlayableModel* m_model;
QStackedWidget* m_stack;
FlexibleViewMode m_mode;
};
Q_DECLARE_METATYPE( FlexibleView::FlexibleViewMode );
#endif // FLEXIBLEVIEW_H

View File

@@ -64,8 +64,13 @@ GridItemDelegate::GridItemDelegate( QAbstractItemView* parent, PlayableProxyMode
QSize QSize
GridItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const GridItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
{ {
QSize size = QStyledItemDelegate::sizeHint( option, index ); if ( m_itemSize.isNull() )
return size; {
QSize size = QStyledItemDelegate::sizeHint( option, index );
return size;
}
else
return m_itemSize;
} }

View File

@@ -41,6 +41,9 @@ Q_OBJECT
public: public:
GridItemDelegate( QAbstractItemView* parent = 0, PlayableProxyModel* proxy = 0 ); GridItemDelegate( QAbstractItemView* parent = 0, PlayableProxyModel* proxy = 0 );
QSize itemSize() const { return m_itemSize; }
void setItemSize( const QSize& size ) { m_itemSize = size; }
protected: protected:
void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const; void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const; QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
@@ -70,6 +73,7 @@ private:
QAbstractItemView* m_view; QAbstractItemView* m_view;
PlayableProxyModel* m_model; PlayableProxyModel* m_model;
QSize m_itemSize;
mutable QHash< QPersistentModelIndex, QRect > m_artistNameRects; mutable QHash< QPersistentModelIndex, QRect > m_artistNameRects;
mutable QHash< QPersistentModelIndex, QSharedPointer< Tomahawk::PixmapDelegateFader > > m_covers; mutable QHash< QPersistentModelIndex, QSharedPointer< Tomahawk::PixmapDelegateFader > > m_covers;

View File

@@ -229,7 +229,7 @@ GridView::verifySize()
const int overlapRows = m_model->rowCount( QModelIndex() ) % itemsPerRow; const int overlapRows = m_model->rowCount( QModelIndex() ) % itemsPerRow;
const int rows = floor( (double)m_model->rowCount( QModelIndex() ) / (double)itemsPerRow ); const int rows = floor( (double)m_model->rowCount( QModelIndex() ) / (double)itemsPerRow );
const int newHeight = rows * m_model->itemSize().height(); const int newHeight = rows * m_delegate->itemSize().height();
if ( newHeight > 0 ) if ( newHeight > 0 )
setFixedHeight( newHeight ); setFixedHeight( newHeight );
@@ -258,7 +258,7 @@ GridView::layoutItems()
const int extraSpace = remSpace / itemsPerRow; const int extraSpace = remSpace / itemsPerRow;
const int newItemWidth = itemWidth + extraSpace; const int newItemWidth = itemWidth + extraSpace;
m_model->setItemSize( QSize( newItemWidth, newItemWidth ) ); m_delegate->setItemSize( QSize( newItemWidth, newItemWidth ) );
verifySize(); verifySize();
if ( !m_inited ) if ( !m_inited )

View File

@@ -50,6 +50,7 @@ public:
PlayableModel* model() const { return m_model; } PlayableModel* model() const { return m_model; }
PlayableProxyModel* proxyModel() const { return m_proxyModel; } PlayableProxyModel* proxyModel() const { return m_proxyModel; }
GridItemDelegate* delegate() const { return m_delegate; }
bool autoFitItems() const { return m_autoFitItems; } bool autoFitItems() const { return m_autoFitItems; }
void setAutoFitItems( bool b ) { m_autoFitItems = b; } void setAutoFitItems( bool b ) { m_autoFitItems = b; }

View File

@@ -41,7 +41,6 @@ PlayableModel::PlayableModel( QObject* parent, bool loading )
: QAbstractItemModel( parent ) : QAbstractItemModel( parent )
, m_rootItem( new PlayableItem( 0, this ) ) , m_rootItem( new PlayableItem( 0, this ) )
, m_readOnly( true ) , m_readOnly( true )
, m_style( Detailed )
, m_loading( loading ) , m_loading( loading )
{ {
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlaybackStarted( Tomahawk::result_ptr ) ), Qt::DirectConnection ); connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlaybackStarted( Tomahawk::result_ptr ) ), Qt::DirectConnection );
@@ -49,9 +48,6 @@ PlayableModel::PlayableModel( QObject* parent, bool loading )
m_header << tr( "Artist" ) << tr( "Title" ) << tr( "Composer" ) << tr( "Album" ) << tr( "Track" ) << tr( "Duration" ) m_header << tr( "Artist" ) << tr( "Title" ) << tr( "Composer" ) << tr( "Album" ) << tr( "Track" ) << tr( "Duration" )
<< tr( "Bitrate" ) << tr( "Age" ) << tr( "Year" ) << tr( "Size" ) << tr( "Origin" ) << tr( "Score" ) << tr( "Name" ); << tr( "Bitrate" ) << tr( "Age" ) << tr( "Year" ) << tr( "Size" ) << tr( "Origin" ) << tr( "Score" ) << tr( "Name" );
m_headerStyle[ Detailed ] << Artist << Track << Composer << Album << AlbumPos << Duration << Bitrate << Age << Year << Filesize << Origin << Score;
m_headerStyle[ Collection ] << Name << Composer << Duration << Bitrate << Age << Year << Filesize << Origin;
} }
@@ -94,23 +90,7 @@ PlayableModel::columnCount( const QModelIndex& parent ) const
{ {
Q_UNUSED( parent ); Q_UNUSED( parent );
switch ( m_style ) return 12;
{
case Short:
case ShortWithAvatars:
case Large:
return 1;
break;
case Collection:
return 8;
break;
case Detailed:
default:
return 12;
break;
}
} }
@@ -183,10 +163,7 @@ PlayableModel::queryData( const query_ptr& query, int column, int role ) const
if ( role != Qt::DisplayRole ) // && role != Qt::ToolTipRole ) if ( role != Qt::DisplayRole ) // && role != Qt::ToolTipRole )
return QVariant(); return QVariant();
if ( !m_headerStyle.contains( m_style ) ) switch ( column )
return query->track();
switch( m_headerStyle[ m_style ].at( column ) )
{ {
case Artist: case Artist:
return query->artist(); return query->artist();
@@ -229,7 +206,7 @@ PlayableModel::queryData( const query_ptr& query, int column, int role ) const
} }
if ( query->numResults() ) if ( query->numResults() )
{ {
switch( m_headerStyle[ m_style ].at( column ) ) switch ( column )
{ {
case Bitrate: case Bitrate:
if ( query->results().first()->bitrate() > 0 ) if ( query->results().first()->bitrate() > 0 )
@@ -283,16 +260,6 @@ PlayableModel::data( const QModelIndex& index, int role ) const
return QVariant( columnAlignment( index.column() ) ); return QVariant( columnAlignment( index.column() ) );
} }
if ( role == StyleRole )
{
return m_style;
}
if ( role == Qt::SizeHintRole && !m_itemSize.isEmpty() )
{
return m_itemSize;
}
if ( !entry->query().isNull() ) if ( !entry->query().isNull() )
{ {
return queryData( entry->query()->displayQuery(), index.column(), role ); return queryData( entry->query()->displayQuery(), index.column(), role );
@@ -317,10 +284,8 @@ PlayableModel::headerData( int section, Qt::Orientation orientation, int role )
if ( role == Qt::DisplayRole && section >= 0 ) if ( role == Qt::DisplayRole && section >= 0 )
{ {
if ( m_headerStyle.contains( m_style ) ) if ( section < m_header.count() )
{ return m_header.at( section );
return m_header.at( m_headerStyle[ m_style ].at( section ) );
}
else else
return tr( "Name" ); return tr( "Name" );
} }
@@ -334,28 +299,6 @@ PlayableModel::headerData( int section, Qt::Orientation orientation, int role )
} }
void
PlayableModel::updateDetailedInfo( const QModelIndex& index )
{
if ( style() != PlayableModel::Short && style() != PlayableModel::Large )
return;
PlayableItem* item = itemFromIndex( index );
if ( item->query().isNull() )
return;
if ( style() == PlayableModel::Short || style() == PlayableModel::Large )
{
item->query()->cover( QSize( 0, 0 ) );
}
if ( style() == PlayableModel::Large )
{
item->query()->loadSocialActions();
}
}
void void
PlayableModel::setCurrentItem( const QModelIndex& index ) PlayableModel::setCurrentItem( const QModelIndex& index )
{ {
@@ -717,47 +660,10 @@ PlayableModel::ensureResolved()
} }
void
PlayableModel::setStyle( PlayableModel::PlayableItemStyle style )
{
m_style = style;
}
QList< double >
PlayableModel::columnWeights() const
{
QList< double > w;
switch ( m_style )
{
case Short:
case ShortWithAvatars:
case Large:
w << 1.0;
break;
case Collection:
w << 0.42 << 0.12 << 0.07 << 0.07 << 0.07 << 0.07 << 0.07; // << 0.11;
break;
case Detailed:
default:
w << 0.16 << 0.16 << 0.14 << 0.12 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.09; // << 0.03;
break;
}
return w;
}
Qt::Alignment Qt::Alignment
PlayableModel::columnAlignment( int column ) const PlayableModel::columnAlignment( int column ) const
{ {
if ( !m_headerStyle.contains( m_style ) ) switch ( column )
return Qt::AlignLeft;
switch( m_headerStyle[ m_style ].at( column ) )
{ {
case Age: case Age:
case AlbumPos: case AlbumPos:

View File

@@ -38,12 +38,6 @@ class DLLEXPORT PlayableModel : public QAbstractItemModel
Q_OBJECT Q_OBJECT
public: public:
enum PlayableItemStyle
{ Detailed = 0, Short = 1, ShortWithAvatars = 2, Large = 3, Collection = 4 };
enum PlayableModelRole
{ StyleRole = Qt::UserRole + 1 };
enum Columns { enum Columns {
Artist = 0, Artist = 0,
Track = 1, Track = 1,
@@ -63,9 +57,6 @@ public:
explicit PlayableModel( QObject* parent = 0, bool loading = true ); explicit PlayableModel( QObject* parent = 0, bool loading = true );
virtual ~PlayableModel(); virtual ~PlayableModel();
PlayableModel::PlayableItemStyle style() const { return m_style; }
void setStyle( PlayableModel::PlayableItemStyle style );
virtual QModelIndex index( int row, int column, const QModelIndex& parent ) const; virtual QModelIndex index( int row, int column, const QModelIndex& parent ) const;
virtual QModelIndex parent( const QModelIndex& child ) const; virtual QModelIndex parent( const QModelIndex& child ) const;
@@ -87,8 +78,6 @@ public:
virtual int columnCount( const QModelIndex& parent = QModelIndex() ) const; virtual int columnCount( const QModelIndex& parent = QModelIndex() ) const;
virtual bool hasChildren( const QModelIndex& parent ) const; virtual bool hasChildren( const QModelIndex& parent ) const;
QList< double > columnWeights() const;
virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const; virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
virtual QVariant headerData( int section, Qt::Orientation orientation, int role ) const; virtual QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
@@ -113,11 +102,6 @@ public:
/// Returns a flat list of all tracks in this model /// Returns a flat list of all tracks in this model
QList< Tomahawk::query_ptr > queries() const; QList< Tomahawk::query_ptr > queries() const;
void updateDetailedInfo( const QModelIndex& index );
QSize itemSize() const { return m_itemSize; }
void setItemSize( const QSize& size ) { m_itemSize = size; }
void startLoading(); void startLoading();
void finishLoading(); void finishLoading();
@@ -176,7 +160,6 @@ private:
PlayableItem* m_rootItem; PlayableItem* m_rootItem;
QPersistentModelIndex m_currentIndex; QPersistentModelIndex m_currentIndex;
Tomahawk::QID m_currentUuid; Tomahawk::QID m_currentUuid;
QSize m_itemSize;
bool m_readOnly; bool m_readOnly;
@@ -184,10 +167,8 @@ private:
QString m_description; QString m_description;
QPixmap m_icon; QPixmap m_icon;
QHash< PlayableItemStyle, QList<Columns> > m_headerStyle;
QStringList m_header; QStringList m_header;
PlayableItemStyle m_style;
bool m_loading; bool m_loading;
}; };

View File

@@ -36,12 +36,16 @@ PlayableProxyModel::PlayableProxyModel( QObject* parent )
, m_showOfflineResults( true ) , m_showOfflineResults( true )
, m_hideDupeItems( false ) , m_hideDupeItems( false )
, m_maxVisibleItems( -1 ) , m_maxVisibleItems( -1 )
, m_style( Detailed )
{ {
setFilterCaseSensitivity( Qt::CaseInsensitive ); setFilterCaseSensitivity( Qt::CaseInsensitive );
setSortCaseSensitivity( Qt::CaseInsensitive ); setSortCaseSensitivity( Qt::CaseInsensitive );
setDynamicSortFilter( true ); setDynamicSortFilter( true );
setSourcePlayableModel( 0 ); setSourcePlayableModel( 0 );
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;
} }
@@ -461,3 +465,116 @@ PlayableProxyModel::playlistInterface()
return m_playlistInterface; return m_playlistInterface;
} }
int
PlayableProxyModel::columnCount( const QModelIndex& parent ) const
{
Q_UNUSED( parent );
switch ( m_style )
{
case Short:
case ShortWithAvatars:
case Large:
return 1;
break;
case Collection:
return 8;
break;
case Detailed:
default:
return 12;
break;
}
}
QVariant
PlayableProxyModel::data( const QModelIndex& index, int role ) const
{
if ( role == StyleRole )
{
return m_style;
}
if ( !sourceModel() )
return QVariant();
if ( !m_headerStyle.contains( m_style ) )
return QVariant();
PlayableModel::Columns col = m_headerStyle[ m_style ].at( index.column() );
QModelIndex sourceIdx = mapToSource( index );
QModelIndex idx = sourceModel()->index( sourceIdx.row(), (int)col, sourceIdx.parent() );
return idx.data( role );
}
QVariant
PlayableProxyModel::headerData( int section, Qt::Orientation orientation, int role ) const
{
if ( !sourceModel() )
return QVariant();
if ( !m_headerStyle.contains( m_style ) )
return QVariant();
if ( section < m_headerStyle[ m_style ].count() )
{
PlayableModel::Columns col = m_headerStyle[ m_style ].at( section );
return sourceModel()->headerData( (int)col, orientation, role );
}
else
return sourceModel()->headerData( 255, orientation, role );
}
QList< double >
PlayableProxyModel::columnWeights() const
{
QList< double > w;
switch ( m_style )
{
case Short:
case ShortWithAvatars:
case Large:
w << 1.0;
break;
case Collection:
w << 0.42 << 0.12 << 0.07 << 0.07 << 0.07 << 0.07 << 0.07; // << 0.11;
break;
case Detailed:
default:
w << 0.16 << 0.16 << 0.14 << 0.12 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.09; // << 0.03;
break;
}
return w;
}
void
PlayableProxyModel::updateDetailedInfo( const QModelIndex& index )
{
if ( style() != PlayableProxyModel::Short && style() != PlayableProxyModel::Large )
return;
PlayableItem* item = itemFromIndex( mapToSource( index ) );
if ( item->query().isNull() )
return;
if ( style() == PlayableProxyModel::Short || style() == PlayableProxyModel::Large )
{
item->query()->cover( QSize( 0, 0 ) );
}
if ( style() == PlayableProxyModel::Large )
{
item->query()->loadSocialActions();
}
}

View File

@@ -32,6 +32,12 @@ class DLLEXPORT PlayableProxyModel : public QSortFilterProxyModel
Q_OBJECT Q_OBJECT
public: public:
enum PlayableItemStyle
{ Detailed = 0, Short = 1, ShortWithAvatars = 2, Large = 3, Collection = 4 };
enum PlayableProxyModelRole
{ StyleRole = Qt::UserRole + 1 };
explicit PlayableProxyModel ( QObject* parent = 0 ); explicit PlayableProxyModel ( QObject* parent = 0 );
virtual ~PlayableProxyModel() {} virtual ~PlayableProxyModel() {}
@@ -41,6 +47,9 @@ public:
virtual bool isLoading() const; virtual bool isLoading() const;
PlayableProxyModel::PlayableItemStyle style() const { return m_style; }
void setStyle( PlayableProxyModel::PlayableItemStyle style ) { m_style = style; }
virtual QPersistentModelIndex currentIndex() const { return mapFromSource( m_model->currentItem() ); } virtual QPersistentModelIndex currentIndex() const { return mapFromSource( m_model->currentItem() ); }
virtual void setCurrentIndex( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); } virtual void setCurrentIndex( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); }
@@ -63,6 +72,14 @@ public:
virtual Tomahawk::playlistinterface_ptr playlistInterface(); virtual Tomahawk::playlistinterface_ptr playlistInterface();
QList< double > columnWeights() const;
virtual int columnCount( const QModelIndex& parent = QModelIndex() ) const;
virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
virtual QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
void updateDetailedInfo( const QModelIndex& index );
signals: signals:
void filterChanged( const QString& filter ); void filterChanged( const QString& filter );
@@ -86,6 +103,9 @@ private:
bool m_showOfflineResults; bool m_showOfflineResults;
bool m_hideDupeItems; bool m_hideDupeItems;
int m_maxVisibleItems; int m_maxVisibleItems;
QHash< PlayableItemStyle, QList<PlayableModel::Columns> > m_headerStyle;
PlayableItemStyle m_style;
}; };
#endif // TRACKPROXYMODEL_H #endif // TRACKPROXYMODEL_H

View File

@@ -67,8 +67,8 @@ PlaylistItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModel
if ( index.isValid() ) if ( index.isValid() )
{ {
int style = index.data( PlayableModel::StyleRole ).toInt(); int style = index.data( PlayableProxyModel::StyleRole ).toInt();
if ( style == PlayableModel::Short || style == PlayableModel::ShortWithAvatars ) if ( style == PlayableProxyModel::Short || style == PlayableProxyModel::ShortWithAvatars )
{ {
int rowHeight = option.fontMetrics.height() + 8; int rowHeight = option.fontMetrics.height() + 8;
size.setHeight( rowHeight * 2 ); size.setHeight( rowHeight * 2 );
@@ -101,17 +101,17 @@ PlaylistItemDelegate::prepareStyleOption( QStyleOptionViewItemV4* option, const
void void
PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{ {
int style = index.data( PlayableModel::StyleRole ).toInt(); int style = index.data( PlayableProxyModel::StyleRole ).toInt();
switch ( style ) switch ( style )
{ {
case PlayableModel::Detailed: case PlayableProxyModel::Detailed:
paintDetailed( painter, option, index ); paintDetailed( painter, option, index );
break; break;
case PlayableModel::Short: case PlayableProxyModel::Short:
paintShort( painter, option, index ); paintShort( painter, option, index );
break; break;
case PlayableModel::ShortWithAvatars: case PlayableProxyModel::ShortWithAvatars:
paintShort( painter, option, index, true ); paintShort( painter, option, index, true );
break; break;
} }

View File

@@ -62,15 +62,15 @@ PlaylistView::setPlaylistModel( PlaylistModel* model )
setColumnHidden( PlayableModel::Age, true ); // Hide age column per default setColumnHidden( PlayableModel::Age, true ); // Hide age column per default
setColumnHidden( PlayableModel::Composer, true ); // Hide composer column per default setColumnHidden( PlayableModel::Composer, true ); // Hide composer column per default
if ( guid().isEmpty() ) if ( guid().isEmpty() && proxyModel()->columnCount() > 1 )
{ {
if ( !m_model->playlist().isNull() ) if ( !m_model->playlist().isNull() )
{ {
setGuid( QString( "playlistview/%1/%2" ).arg( m_model->columnCount() ).arg( m_model->playlist()->guid() ) ); setGuid( QString( "playlistview/%1/%2" ).arg( proxyModel()->columnCount() ).arg( m_model->playlist()->guid() ) );
} }
else else
{ {
setGuid( QString( "playlistview/%1" ).arg( m_model->columnCount() ) ); setGuid( QString( "playlistview/%1" ).arg( proxyModel()->columnCount() ) );
} }
} }

View File

@@ -47,7 +47,7 @@ QueueView::QueueView( AnimatedSplitter* parent )
ui->queue->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Ignored ); ui->queue->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Ignored );
PlaylistModel* queueModel = new PlaylistModel( this ); PlaylistModel* queueModel = new PlaylistModel( this );
queueModel->setStyle( PlaylistModel::Short ); ui->queue->proxyModel()->setStyle( PlayableProxyModel::Short );
queueModel->finishLoading(); queueModel->finishLoading();
ui->queue->setPlaylistModel( queueModel ); ui->queue->setPlaylistModel( queueModel );
queueModel->setReadOnly( false ); queueModel->setReadOnly( false );

View File

@@ -153,13 +153,13 @@ TrackView::setPlayableModel( PlayableModel* model )
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) ); connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) );
setAcceptDrops( true ); setAcceptDrops( true );
m_header->setDefaultColumnWeights( model->columnWeights() ); m_header->setDefaultColumnWeights( m_proxyModel->columnWeights() );
switch( model->style() ) switch( m_proxyModel->style() )
{ {
case PlayableModel::Short: case PlayableProxyModel::Short:
case PlayableModel::ShortWithAvatars: case PlayableProxyModel::ShortWithAvatars:
case PlayableModel::Large: case PlayableProxyModel::Large:
setHeaderHidden( true ); setHeaderHidden( true );
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
break; break;
@@ -184,7 +184,7 @@ TrackView::setEmptyTip( const QString& tip )
void void
TrackView::onViewChanged() TrackView::onViewChanged()
{ {
if ( m_model->style() != PlayableModel::Short && m_model->style() != PlayableModel::Large ) // eventual FIXME? if ( m_proxyModel->style() != PlayableProxyModel::Short && m_proxyModel->style() != PlayableProxyModel::Large ) // eventual FIXME?
return; return;
if ( m_timer.isActive() ) if ( m_timer.isActive() )
@@ -217,7 +217,7 @@ TrackView::onScrollTimeout()
for ( int i = left.row(); i <= max; i++ ) for ( int i = left.row(); i <= max; i++ )
{ {
m_model->updateDetailedInfo( m_proxyModel->mapToSource( m_proxyModel->index( i, 0 ) ) ); m_proxyModel->updateDetailedInfo( m_proxyModel->index( i, 0 ) );
} }
} }
@@ -621,7 +621,7 @@ TrackView::updateHoverIndex( const QPoint& pos )
repaint(); repaint();
} }
if ( !m_model || m_model->style() != PlayableModel::Detailed ) if ( !m_model || m_proxyModel->style() != PlayableProxyModel::Detailed )
return; return;
if ( idx.column() == PlayableModel::Artist || idx.column() == PlayableModel::Album || idx.column() == PlayableModel::Track ) if ( idx.column() == PlayableModel::Artist || idx.column() == PlayableModel::Album || idx.column() == PlayableModel::Track )
@@ -673,7 +673,7 @@ TrackView::mousePressEvent( QMouseEvent* event )
{ {
QTreeView::mousePressEvent( event ); QTreeView::mousePressEvent( event );
if ( !m_model || m_model->style() != PlayableModel::Detailed ) if ( !m_model || m_proxyModel->style() != PlayableProxyModel::Detailed )
return; return;
QModelIndex idx = indexAt( event->pos() ); QModelIndex idx = indexAt( event->pos() );

View File

@@ -41,7 +41,6 @@ TreeModel::TreeModel( QObject* parent )
: PlayableModel( parent ) : PlayableModel( parent )
, m_mode( DatabaseMode ) , m_mode( DatabaseMode )
{ {
setStyle( Collection );
setIcon( QPixmap( RESPATH "images/music-icon.png" ) ); setIcon( QPixmap( RESPATH "images/music-icon.png" ) );
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlaybackStarted( Tomahawk::result_ptr ) ), Qt::DirectConnection ); connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlaybackStarted( Tomahawk::result_ptr ) ), Qt::DirectConnection );

View File

@@ -145,8 +145,8 @@ TreeView::setTreeModel( TreeModel* model )
guid(); // this will set the guid on the header guid(); // this will set the guid on the header
m_header->setDefaultColumnWeights( model->columnWeights() ); m_header->setDefaultColumnWeights( m_proxyModel->columnWeights() );
if ( model->style() == PlayableModel::Large ) if ( m_proxyModel->style() == PlayableProxyModel::Large )
{ {
setHeaderHidden( true ); setHeaderHidden( true );
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
@@ -439,7 +439,7 @@ TreeView::updateHoverIndex( const QPoint& pos )
repaint(); repaint();
} }
if ( !m_model || m_model->style() != PlayableModel::Collection ) if ( !m_model || m_proxyModel->style() != PlayableProxyModel::Collection )
return; return;
PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( idx ) ); PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( idx ) );
@@ -492,7 +492,7 @@ TreeView::mousePressEvent( QMouseEvent* event )
{ {
QTreeView::mousePressEvent( event ); QTreeView::mousePressEvent( event );
if ( !m_model || m_model->style() != PlayableModel::Collection ) if ( !m_model || m_proxyModel->style() != PlayableProxyModel::Collection )
return; return;
QModelIndex idx = indexAt( event->pos() ); QModelIndex idx = indexAt( event->pos() );

View File

@@ -69,7 +69,7 @@ SocialPlaylistWidget::SocialPlaylistWidget ( QWidget* parent )
m_topForeignTracksModel = new PlaylistModel( ui->newTracksView ); m_topForeignTracksModel = new PlaylistModel( ui->newTracksView );
ui->newTracksView->setPlaylistModel( m_topForeignTracksModel ); ui->newTracksView->setPlaylistModel( m_topForeignTracksModel );
m_topForeignTracksModel->setStyle( PlayableModel::Short ); ui->newTracksView->proxyModel()->setStyle( PlayableProxyModel::Short );
ui->newTracksView->overlay()->setEnabled( false ); ui->newTracksView->overlay()->setEnabled( false );
m_popularNewAlbumsModel = new PlayableModel( ui->newAlbumsView ); m_popularNewAlbumsModel = new PlayableModel( ui->newAlbumsView );

View File

@@ -69,7 +69,7 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
updatePlaylists(); updatePlaylists();
m_tracksModel = new RecentlyPlayedModel( ui->tracksView ); m_tracksModel = new RecentlyPlayedModel( ui->tracksView );
m_tracksModel->setStyle( PlayableModel::ShortWithAvatars ); ui->tracksView->proxyModel()->setStyle( PlayableProxyModel::ShortWithAvatars );
ui->tracksView->overlay()->setEnabled( false ); ui->tracksView->overlay()->setEnabled( false );
ui->tracksView->setPlaylistModel( m_tracksModel ); ui->tracksView->setPlaylistModel( m_tracksModel );
m_tracksModel->setSource( source_ptr() ); m_tracksModel->setSource( source_ptr() );

View File

@@ -262,7 +262,6 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
TreeModel* artistsModel = new TreeModel( ui->artistsViewLeft ); TreeModel* artistsModel = new TreeModel( ui->artistsViewLeft );
artistsModel->setMode( InfoSystemMode ); artistsModel->setMode( InfoSystemMode );
artistsModel->setStyle( PlayableModel::Collection );
artistsModel->startLoading(); artistsModel->startLoading();
m_artistModels[ chartId ] = artistsModel; m_artistModels[ chartId ] = artistsModel;
@@ -293,7 +292,6 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
connect( loader, SIGNAL( tracks( Tomahawk::ChartDataLoader*, QList< Tomahawk::query_ptr > ) ), this, SLOT( chartTracksLoaded( Tomahawk::ChartDataLoader*, QList< Tomahawk::query_ptr > ) ) ); connect( loader, SIGNAL( tracks( Tomahawk::ChartDataLoader*, QList< Tomahawk::query_ptr > ) ), this, SLOT( chartTracksLoaded( Tomahawk::ChartDataLoader*, QList< Tomahawk::query_ptr > ) ) );
PlaylistModel* trackModel = new PlaylistModel( ui->tracksViewLeft ); PlaylistModel* trackModel = new PlaylistModel( ui->tracksViewLeft );
trackModel->setStyle( PlayableModel::Large );
trackModel->startLoading(); trackModel->startLoading();
m_trackModels[ chartId ] = trackModel; m_trackModels[ chartId ] = trackModel;
@@ -463,6 +461,7 @@ WhatsHotWidget::setLeftViewAlbums( PlayableModel* model )
void void
WhatsHotWidget::setLeftViewArtists( TreeModel* model ) WhatsHotWidget::setLeftViewArtists( TreeModel* model )
{ {
ui->artistsViewLeft->proxyModel()->setStyle( PlayableProxyModel::Collection );
ui->artistsViewLeft->setTreeModel( model ); ui->artistsViewLeft->setTreeModel( model );
ui->artistsViewLeft->proxyModel()->sort( -1 ); // disable sorting, must be called after artistsViewLeft->setTreeModel ui->artistsViewLeft->proxyModel()->sort( -1 ); // disable sorting, must be called after artistsViewLeft->setTreeModel
ui->stackLeft->setCurrentIndex( 1 ); ui->stackLeft->setCurrentIndex( 1 );
@@ -472,6 +471,7 @@ WhatsHotWidget::setLeftViewArtists( TreeModel* model )
void void
WhatsHotWidget::setLeftViewTracks( PlaylistModel* model ) WhatsHotWidget::setLeftViewTracks( PlaylistModel* model )
{ {
ui->tracksViewLeft->proxyModel()->setStyle( PlayableProxyModel::Large );
ui->tracksViewLeft->setPlaylistModel( model ); ui->tracksViewLeft->setPlaylistModel( model );
ui->tracksViewLeft->proxyModel()->sort( -1 ); ui->tracksViewLeft->proxyModel()->sort( -1 );
ui->stackLeft->setCurrentIndex( 0 ); ui->stackLeft->setCurrentIndex( 0 );

View File

@@ -25,6 +25,7 @@
#include <QScrollBar> #include <QScrollBar>
#include "audio/AudioEngine.h" #include "audio/AudioEngine.h"
#include "playlist/GridItemDelegate.h"
#include "playlist/PlayableModel.h" #include "playlist/PlayableModel.h"
#include "playlist/TreeModel.h" #include "playlist/TreeModel.h"
#include "playlist/PlaylistModel.h" #include "playlist/PlaylistModel.h"
@@ -73,7 +74,7 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
ui->topHits->setEmptyTip( tr( "Sorry, we could not find any related artists!" ) ); ui->topHits->setEmptyTip( tr( "Sorry, we could not find any related artists!" ) );
m_topHitsModel = new PlaylistModel( ui->topHits ); m_topHitsModel = new PlaylistModel( ui->topHits );
m_topHitsModel->setStyle( PlayableModel::Short ); ui->topHits->proxyModel()->setStyle( PlayableProxyModel::Short );
ui->topHits->setPlayableModel( m_topHitsModel ); ui->topHits->setPlayableModel( m_topHitsModel );
ui->topHits->setSortingEnabled( false ); ui->topHits->setSortingEnabled( false );
ui->topHits->setEmptyTip( tr( "Sorry, we could not find any top hits for this artist!" ) ); ui->topHits->setEmptyTip( tr( "Sorry, we could not find any top hits for this artist!" ) );
@@ -82,13 +83,13 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
ui->relatedArtists->setWrapping( false ); ui->relatedArtists->setWrapping( false );
ui->relatedArtists->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->relatedArtists->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->relatedArtists->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); ui->relatedArtists->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
m_relatedModel->setItemSize( QSize( 170, 170 ) ); ui->relatedArtists->delegate()->setItemSize( QSize( 170, 170 ) );
ui->albums->setAutoFitItems( false ); ui->albums->setAutoFitItems( false );
ui->albums->setWrapping( false ); ui->albums->setWrapping( false );
ui->albums->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->albums->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->albums->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); ui->albums->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
m_albumsModel->setItemSize( QSize( 170, 170 ) ); ui->albums->delegate()->setItemSize( QSize( 170, 170 ) );
ui->albums->proxyModel()->setHideDupeItems( true ); ui->albums->proxyModel()->setHideDupeItems( true );
ui->topHits->setFrameShape( QFrame::StyledPanel ); ui->topHits->setFrameShape( QFrame::StyledPanel );

View File

@@ -50,13 +50,13 @@ SourceInfoWidget::SourceInfoWidget( const Tomahawk::source_ptr& source, QWidget*
ui->splitter->setStretchFactor( 1, 1 ); ui->splitter->setStretchFactor( 1, 1 );
m_recentTracksModel = new RecentlyAddedModel( ui->recentCollectionView ); m_recentTracksModel = new RecentlyAddedModel( ui->recentCollectionView );
m_recentTracksModel->setStyle( PlayableModel::Short ); ui->recentCollectionView->proxyModel()->setStyle( PlayableProxyModel::Short );
ui->recentCollectionView->setPlayableModel( m_recentTracksModel ); ui->recentCollectionView->setPlayableModel( m_recentTracksModel );
ui->recentCollectionView->sortByColumn( PlayableModel::Age, Qt::DescendingOrder ); ui->recentCollectionView->sortByColumn( PlayableModel::Age, Qt::DescendingOrder );
m_recentTracksModel->setSource( source ); m_recentTracksModel->setSource( source );
m_historyModel = new RecentlyPlayedModel( ui->historyView ); m_historyModel = new RecentlyPlayedModel( ui->historyView );
m_historyModel->setStyle( PlayableModel::Short ); ui->historyView->proxyModel()->setStyle( PlayableProxyModel::Short );
ui->historyView->setPlaylistModel( m_historyModel ); ui->historyView->setPlaylistModel( m_historyModel );
m_historyModel->setSource( source ); m_historyModel->setSource( source );

View File

@@ -513,7 +513,7 @@ SourceItem::latestAdditionsClicked()
cv->setAttribute( Qt::WA_MacShowFocusRect, 0 ); cv->setAttribute( Qt::WA_MacShowFocusRect, 0 );
RecentlyAddedModel* raModel = new RecentlyAddedModel( cv ); RecentlyAddedModel* raModel = new RecentlyAddedModel( cv );
raModel->setStyle( PlayableModel::Large ); cv->proxyModel()->setStyle( PlayableProxyModel::Large );
raModel->setTitle( tr( "Latest Additions" ) ); raModel->setTitle( tr( "Latest Additions" ) );
if ( m_source->isLocal() ) if ( m_source->isLocal() )
@@ -556,7 +556,7 @@ SourceItem::recentPlaysClicked()
pv->setAttribute( Qt::WA_MacShowFocusRect, 0 ); pv->setAttribute( Qt::WA_MacShowFocusRect, 0 );
RecentlyPlayedModel* raModel = new RecentlyPlayedModel( pv ); RecentlyPlayedModel* raModel = new RecentlyPlayedModel( pv );
raModel->setStyle( PlayableModel::Large ); pv->proxyModel()->setStyle( PlayableProxyModel::Large );
raModel->setTitle( tr( "Recently Played Tracks" ) ); raModel->setTitle( tr( "Recently Played Tracks" ) );
if ( m_source->isLocal() ) if ( m_source->isLocal() )