1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-02 18:33:16 +02:00

replace GridView with QmlGridView in FlexibleView

This commit is contained in:
Michael Zanetti
2012-12-16 16:27:53 +01:00
parent 9374b3b50b
commit e2d664704b
5 changed files with 17 additions and 8 deletions

View File

@@ -20,6 +20,8 @@ Rectangle {
cellHeight: cellWidth cellHeight: cellWidth
cellWidth: calculateCoverSize(gridView.width - 3) cellWidth: calculateCoverSize(gridView.width - 3)
cacheBuffer: cellHeight * 5
function calculateCoverSize(rectWidth) { function calculateCoverSize(rectWidth) {
var itemWidth = fontMetrics.width; var itemWidth = fontMetrics.width;
var itemsPerRow = Math.max( 1, Math.floor( rectWidth / itemWidth ) ); var itemsPerRow = Math.max( 1, Math.floor( rectWidth / itemWidth ) );

View File

@@ -26,7 +26,7 @@
#include "playlist/PlayableModel.h" #include "playlist/PlayableModel.h"
#include "playlist/PlaylistModel.h" #include "playlist/PlaylistModel.h"
#include "playlist/TrackView.h" #include "playlist/TrackView.h"
#include "playlist/GridView.h" #include "playlist/QmlGridView.h"
#include "playlist/PlaylistLargeItemDelegate.h" #include "playlist/PlaylistLargeItemDelegate.h"
#include "PlayableProxyModelPlaylistInterface.h" #include "PlayableProxyModelPlaylistInterface.h"
#include "utils/TomahawkUtilsGui.h" #include "utils/TomahawkUtilsGui.h"
@@ -40,7 +40,7 @@ FlexibleView::FlexibleView( QWidget* parent )
, m_header( new DeclarativeHeader( this ) ) , m_header( new DeclarativeHeader( this ) )
, m_trackView( new TrackView() ) , m_trackView( new TrackView() )
, m_detailedView( new TrackView() ) , m_detailedView( new TrackView() )
, m_gridView( new GridView() ) , m_gridView( new QmlGridView() )
, m_model( 0 ) , m_model( 0 )
{ {
qRegisterMetaType< TomahawkUtils::ViewMode >( "TomahawkUtils::ViewMode" ); qRegisterMetaType< TomahawkUtils::ViewMode >( "TomahawkUtils::ViewMode" );
@@ -125,7 +125,7 @@ FlexibleView::setDetailedView( TrackView* view )
void void
FlexibleView::setGridView( GridView* view ) FlexibleView::setGridView( QmlGridView *view )
{ {
if ( m_gridView ) if ( m_gridView )
{ {
@@ -271,7 +271,7 @@ FlexibleView::setEmptyTip( const QString& tip )
{ {
m_trackView->setEmptyTip( tip ); m_trackView->setEmptyTip( tip );
m_detailedView->setEmptyTip( tip ); m_detailedView->setEmptyTip( tip );
m_gridView->setEmptyTip( tip ); // m_gridView->setEmptyTip( tip );
} }

View File

@@ -25,7 +25,7 @@
class QStackedWidget; class QStackedWidget;
class GridView; class QmlGridView;
class TrackView; class TrackView;
class PlayableModel; class PlayableModel;
class PlaylistModel; class PlaylistModel;
@@ -57,13 +57,13 @@ public:
TrackView* trackView() const { return m_trackView; } TrackView* trackView() const { return m_trackView; }
TrackView* detailedView() const { return m_detailedView; } TrackView* detailedView() const { return m_detailedView; }
GridView* gridView() const { return m_gridView; } QmlGridView* gridView() const { return m_gridView; }
void setGuid( const QString& guid ); void setGuid( const QString& guid );
void setTrackView( TrackView* view ); void setTrackView( TrackView* view );
void setDetailedView( TrackView* view ); void setDetailedView( TrackView* view );
void setGridView( GridView* view ); void setGridView( QmlGridView* view );
void setPlayableModel( PlayableModel* model ); void setPlayableModel( PlayableModel* model );
void setPlaylistModel( PlaylistModel* model ); void setPlaylistModel( PlaylistModel* model );
@@ -89,7 +89,7 @@ private:
TrackView* m_trackView; TrackView* m_trackView;
TrackView* m_detailedView; TrackView* m_detailedView;
GridView* m_gridView; QmlGridView* m_gridView;
PlayableModel* m_model; PlayableModel* m_model;
QStackedWidget* m_stack; QStackedWidget* m_stack;

View File

@@ -87,6 +87,12 @@ void QmlGridView::setPlayableModel(PlayableModel *model)
} }
void QmlGridView::setPlaylistInterface(playlistinterface_ptr playlistInterface)
{
proxyModel()->setPlaylistInterface( playlistInterface );
}
void void
QmlGridView::onItemClicked( int index ) QmlGridView::onItemClicked( int index )
{ {

View File

@@ -52,6 +52,7 @@ public:
QWidget *widget() { return this; } QWidget *widget() { return this; }
virtual void setPlaylistInterface(Tomahawk::playlistinterface_ptr playlistInterface);
virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return m_playlistInterface; } virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return m_playlistInterface; }
virtual QString title() const { return m_model->title(); } virtual QString title() const { return m_model->title(); }
virtual QString description() const { return m_model->description(); } virtual QString description() const { return m_model->description(); }