1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 00:09:47 +01:00

* AlbumView now uses a PlayableModel internally.

This commit is contained in:
Christian Muehlhaeuser 2012-05-31 23:10:27 +02:00
parent 6d057732b5
commit fee2f3a01b
2 changed files with 8 additions and 8 deletions

View File

@ -33,6 +33,7 @@
#include "PlayableItem.h"
#include "AlbumItemDelegate.h"
#include "AlbumModel.h"
#include "PlayableModel.h"
#include "ContextMenu.h"
#include "ViewManager.h"
#include "utils/Logger.h"
@ -115,14 +116,14 @@ AlbumView::setModel( QAbstractItemModel* model )
void
AlbumView::setAlbumModel( AlbumModel* model )
AlbumView::setPlayableModel( PlayableModel* model )
{
m_inited = false;
m_model = model;
if ( m_proxyModel )
{
m_proxyModel->setSourceAlbumModel( m_model );
m_proxyModel->setSourcePlayableModel( m_model );
m_proxyModel->sort( 0 );
}
@ -202,8 +203,7 @@ AlbumView::layoutItems()
#endif
int rectWidth = contentsRect().width() - scrollbar - 3;
int itemWidth = 160;
QSize itemSize = m_proxyModel->data( QModelIndex(), Qt::SizeHintRole ).toSize();
Q_UNUSED( itemSize ); // looks obsolete
// QSize itemSize = m_proxyModel->data( QModelIndex(), Qt::SizeHintRole ).toSize();
int itemsPerRow = qMax( 1, qFloor( rectWidth / itemWidth ) );
// int rightSpacing = rectWidth - ( itemsPerRow * ( itemSize.width() + 16 ) );

View File

@ -34,9 +34,9 @@ namespace Tomahawk
class ContextMenu;
};
class AlbumModel;
class AnimatedSpinner;
class AlbumItemDelegate;
class PlayableModel;
class DLLEXPORT AlbumView : public QListView, public Tomahawk::ViewPage
{
@ -48,13 +48,13 @@ public:
void setProxyModel( AlbumProxyModel* model );
AlbumModel* model() const { return m_model; }
PlayableModel* model() const { return m_model; }
AlbumProxyModel* proxyModel() const { return m_proxyModel; }
bool autoFitItems() const { return m_autoFitItems; }
void setAutoFitItems( bool b ) { m_autoFitItems = b; }
void setAlbumModel( AlbumModel* model );
void setPlayableModel( PlayableModel* model );
void setModel( QAbstractItemModel* model );
virtual QWidget* widget() { return this; }
@ -91,7 +91,7 @@ private slots:
void layoutItems();
private:
AlbumModel* m_model;
PlayableModel* m_model;
AlbumProxyModel* m_proxyModel;
AlbumItemDelegate* m_delegate;
AnimatedSpinner* m_loadingSpinner;