mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
* AlbumView now uses a PlayableModel internally.
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
#include "PlayableItem.h"
|
#include "PlayableItem.h"
|
||||||
#include "AlbumItemDelegate.h"
|
#include "AlbumItemDelegate.h"
|
||||||
#include "AlbumModel.h"
|
#include "AlbumModel.h"
|
||||||
|
#include "PlayableModel.h"
|
||||||
#include "ContextMenu.h"
|
#include "ContextMenu.h"
|
||||||
#include "ViewManager.h"
|
#include "ViewManager.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
@@ -115,14 +116,14 @@ AlbumView::setModel( QAbstractItemModel* model )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AlbumView::setAlbumModel( AlbumModel* model )
|
AlbumView::setPlayableModel( PlayableModel* model )
|
||||||
{
|
{
|
||||||
m_inited = false;
|
m_inited = false;
|
||||||
m_model = model;
|
m_model = model;
|
||||||
|
|
||||||
if ( m_proxyModel )
|
if ( m_proxyModel )
|
||||||
{
|
{
|
||||||
m_proxyModel->setSourceAlbumModel( m_model );
|
m_proxyModel->setSourcePlayableModel( m_model );
|
||||||
m_proxyModel->sort( 0 );
|
m_proxyModel->sort( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,8 +203,7 @@ AlbumView::layoutItems()
|
|||||||
#endif
|
#endif
|
||||||
int rectWidth = contentsRect().width() - scrollbar - 3;
|
int rectWidth = contentsRect().width() - scrollbar - 3;
|
||||||
int itemWidth = 160;
|
int itemWidth = 160;
|
||||||
QSize itemSize = m_proxyModel->data( QModelIndex(), Qt::SizeHintRole ).toSize();
|
// QSize itemSize = m_proxyModel->data( QModelIndex(), Qt::SizeHintRole ).toSize();
|
||||||
Q_UNUSED( itemSize ); // looks obsolete
|
|
||||||
|
|
||||||
int itemsPerRow = qMax( 1, qFloor( rectWidth / itemWidth ) );
|
int itemsPerRow = qMax( 1, qFloor( rectWidth / itemWidth ) );
|
||||||
// int rightSpacing = rectWidth - ( itemsPerRow * ( itemSize.width() + 16 ) );
|
// int rightSpacing = rectWidth - ( itemsPerRow * ( itemSize.width() + 16 ) );
|
||||||
|
@@ -34,9 +34,9 @@ namespace Tomahawk
|
|||||||
class ContextMenu;
|
class ContextMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AlbumModel;
|
|
||||||
class AnimatedSpinner;
|
class AnimatedSpinner;
|
||||||
class AlbumItemDelegate;
|
class AlbumItemDelegate;
|
||||||
|
class PlayableModel;
|
||||||
|
|
||||||
class DLLEXPORT AlbumView : public QListView, public Tomahawk::ViewPage
|
class DLLEXPORT AlbumView : public QListView, public Tomahawk::ViewPage
|
||||||
{
|
{
|
||||||
@@ -48,13 +48,13 @@ public:
|
|||||||
|
|
||||||
void setProxyModel( AlbumProxyModel* model );
|
void setProxyModel( AlbumProxyModel* model );
|
||||||
|
|
||||||
AlbumModel* model() const { return m_model; }
|
PlayableModel* model() const { return m_model; }
|
||||||
AlbumProxyModel* proxyModel() const { return m_proxyModel; }
|
AlbumProxyModel* proxyModel() const { return m_proxyModel; }
|
||||||
|
|
||||||
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; }
|
||||||
|
|
||||||
void setAlbumModel( AlbumModel* model );
|
void setPlayableModel( PlayableModel* model );
|
||||||
void setModel( QAbstractItemModel* model );
|
void setModel( QAbstractItemModel* model );
|
||||||
|
|
||||||
virtual QWidget* widget() { return this; }
|
virtual QWidget* widget() { return this; }
|
||||||
@@ -91,7 +91,7 @@ private slots:
|
|||||||
void layoutItems();
|
void layoutItems();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AlbumModel* m_model;
|
PlayableModel* m_model;
|
||||||
AlbumProxyModel* m_proxyModel;
|
AlbumProxyModel* m_proxyModel;
|
||||||
AlbumItemDelegate* m_delegate;
|
AlbumItemDelegate* m_delegate;
|
||||||
AnimatedSpinner* m_loadingSpinner;
|
AnimatedSpinner* m_loadingSpinner;
|
||||||
|
Reference in New Issue
Block a user