mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 00:54:20 +02:00
* Store / restore column widths uniquely to a TrackView's guid.
This commit is contained in:
@@ -13,6 +13,7 @@ using namespace Tomahawk;
|
|||||||
CollectionView::CollectionView( QWidget* parent )
|
CollectionView::CollectionView( QWidget* parent )
|
||||||
: TrackView( parent )
|
: TrackView( parent )
|
||||||
{
|
{
|
||||||
|
setGuid( "collectionview" );
|
||||||
setProxyModel( new CollectionProxyModel( this ) );
|
setProxyModel( new CollectionProxyModel( this ) );
|
||||||
|
|
||||||
setSortingEnabled( true );
|
setSortingEnabled( true );
|
||||||
|
@@ -31,6 +31,8 @@ public:
|
|||||||
|
|
||||||
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent );
|
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent );
|
||||||
|
|
||||||
|
Tomahawk::playlist_ptr playlist() const { return m_playlist; }
|
||||||
|
|
||||||
void loadPlaylist( const Tomahawk::playlist_ptr& playlist );
|
void loadPlaylist( const Tomahawk::playlist_ptr& playlist );
|
||||||
void loadHistory( const Tomahawk::source_ptr& source, unsigned int amount = 100 );
|
void loadHistory( const Tomahawk::source_ptr& source, unsigned int amount = 100 );
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
#include "playlist/playlistmodel.h"
|
||||||
#include "playlist/playlistproxymodel.h"
|
#include "playlist/playlistproxymodel.h"
|
||||||
#include "widgets/overlaywidget.h"
|
#include "widgets/overlaywidget.h"
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@ using namespace Tomahawk;
|
|||||||
PlaylistView::PlaylistView( QWidget* parent )
|
PlaylistView::PlaylistView( QWidget* parent )
|
||||||
: TrackView( parent )
|
: TrackView( parent )
|
||||||
{
|
{
|
||||||
|
setGuid( "playlistview" );
|
||||||
setProxyModel( new PlaylistProxyModel( this ) );
|
setProxyModel( new PlaylistProxyModel( this ) );
|
||||||
|
|
||||||
setContextMenuPolicy( Qt::CustomContextMenu );
|
setContextMenuPolicy( Qt::CustomContextMenu );
|
||||||
@@ -27,8 +29,13 @@ PlaylistView::~PlaylistView()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistView::setModel( TrackModel* model )
|
PlaylistView::setModel( PlaylistModel* model )
|
||||||
{
|
{
|
||||||
|
if ( !model->playlist().isNull() )
|
||||||
|
setGuid( QString( "playlistview/%1" ).arg( model->playlist()->guid() ) );
|
||||||
|
|
||||||
|
m_model = model;
|
||||||
|
|
||||||
TrackView::setModel( model );
|
TrackView::setModel( model );
|
||||||
setColumnHidden( 5, true ); // Hide age column per default
|
setColumnHidden( 5, true ); // Hide age column per default
|
||||||
|
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
|
class PlaylistModel;
|
||||||
|
|
||||||
class DLLEXPORT PlaylistView : public TrackView
|
class DLLEXPORT PlaylistView : public TrackView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -15,7 +17,8 @@ public:
|
|||||||
explicit PlaylistView( QWidget* parent = 0 );
|
explicit PlaylistView( QWidget* parent = 0 );
|
||||||
~PlaylistView();
|
~PlaylistView();
|
||||||
|
|
||||||
virtual void setModel( TrackModel* model );
|
PlaylistModel* playlistModel() const { return m_model; }
|
||||||
|
virtual void setModel( PlaylistModel* model );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent( QKeyEvent* event );
|
void keyPressEvent( QKeyEvent* event );
|
||||||
@@ -30,6 +33,8 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void setupMenus();
|
void setupMenus();
|
||||||
|
|
||||||
|
PlaylistModel* m_model;
|
||||||
|
|
||||||
QMenu m_itemMenu;
|
QMenu m_itemMenu;
|
||||||
|
|
||||||
QAction* m_playItemAction;
|
QAction* m_playItemAction;
|
||||||
|
@@ -18,15 +18,15 @@ TrackHeader::TrackHeader( TrackView* parent )
|
|||||||
, m_hiddenPct( 0.0 )
|
, m_hiddenPct( 0.0 )
|
||||||
, m_init( false )
|
, m_init( false )
|
||||||
{
|
{
|
||||||
setStretchLastSection( false );
|
setStretchLastSection( true );
|
||||||
setResizeMode( QHeaderView::Interactive );
|
setResizeMode( QHeaderView::Interactive );
|
||||||
setMinimumSectionSize( 60 );
|
setMinimumSectionSize( 60 );
|
||||||
setDefaultAlignment( Qt::AlignLeft );
|
setDefaultAlignment( Qt::AlignLeft );
|
||||||
setMovable( true );
|
setMovable( true );
|
||||||
// setCascadingSectionResizes( true );
|
// setCascadingSectionResizes( true );
|
||||||
|
|
||||||
m_menu->addAction( tr( "Resize columns to fit window" ), this, SLOT( onToggleResizeColumns() ) );
|
// m_menu->addAction( tr( "Resize columns to fit window" ), this, SLOT( onToggleResizeColumns() ) );
|
||||||
m_menu->addSeparator();
|
// m_menu->addSeparator();
|
||||||
|
|
||||||
connect( this, SIGNAL( sectionResized( int, int, int ) ), SLOT( onSectionResized( int, int, int ) ) );
|
connect( this, SIGNAL( sectionResized( int, int, int ) ), SLOT( onSectionResized( int, int, int ) ) );
|
||||||
connect( m_sigmap, SIGNAL( mapped( int ) ), SLOT( toggleVisibility( int ) ) );
|
connect( m_sigmap, SIGNAL( mapped( int ) ), SLOT( toggleVisibility( int ) ) );
|
||||||
@@ -90,7 +90,7 @@ TrackHeader::onResized()
|
|||||||
void
|
void
|
||||||
TrackHeader::restoreColumnsState()
|
TrackHeader::restoreColumnsState()
|
||||||
{
|
{
|
||||||
QList<QVariant> list = TomahawkSettings::instance()->playlistColumnSizes();
|
QList<QVariant> list = TomahawkSettings::instance()->playlistColumnSizes( m_parent->guid() );
|
||||||
|
|
||||||
if ( list.count() != count() ) // FIXME: const
|
if ( list.count() != count() ) // FIXME: const
|
||||||
{
|
{
|
||||||
@@ -112,7 +112,7 @@ TrackHeader::saveColumnsState()
|
|||||||
foreach( double w, m_columnWeights )
|
foreach( double w, m_columnWeights )
|
||||||
wlist << QVariant( w );
|
wlist << QVariant( w );
|
||||||
|
|
||||||
TomahawkSettings::instance()->setPlaylistColumnSizes( wlist );
|
TomahawkSettings::instance()->setPlaylistColumnSizes( m_parent->guid(), wlist );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -57,7 +57,7 @@ TrackView::~TrackView()
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
delete m_overlay;
|
delete m_header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -22,16 +22,18 @@ public:
|
|||||||
explicit TrackView( QWidget* parent = 0 );
|
explicit TrackView( QWidget* parent = 0 );
|
||||||
~TrackView();
|
~TrackView();
|
||||||
|
|
||||||
|
virtual QString guid() const { return m_guid; }
|
||||||
|
virtual void setGuid( const QString& guid ) { m_guid = guid; }
|
||||||
|
|
||||||
|
virtual void setModel( TrackModel* model );
|
||||||
void setProxyModel( TrackProxyModel* model );
|
void setProxyModel( TrackProxyModel* model );
|
||||||
|
|
||||||
TrackModel* model() const { return m_model; }
|
virtual TrackModel* model() const { return m_model; }
|
||||||
TrackProxyModel* proxyModel() const { return m_proxyModel; }
|
TrackProxyModel* proxyModel() const { return m_proxyModel; }
|
||||||
PlaylistItemDelegate* delegate() const { return m_delegate; }
|
PlaylistItemDelegate* delegate() const { return m_delegate; }
|
||||||
TrackHeader* header() const { return m_header; }
|
TrackHeader* header() const { return m_header; }
|
||||||
OverlayWidget* overlay() const { return m_overlay; }
|
OverlayWidget* overlay() const { return m_overlay; }
|
||||||
|
|
||||||
virtual void setModel( TrackModel* model );
|
|
||||||
|
|
||||||
QModelIndex contextMenuIndex() const { return m_contextMenuIndex; }
|
QModelIndex contextMenuIndex() const { return m_contextMenuIndex; }
|
||||||
void setContextMenuIndex( const QModelIndex& idx ) { m_contextMenuIndex = idx; }
|
void setContextMenuIndex( const QModelIndex& idx ) { m_contextMenuIndex = idx; }
|
||||||
|
|
||||||
@@ -59,6 +61,7 @@ private slots:
|
|||||||
void onFilterChanged( const QString& filter );
|
void onFilterChanged( const QString& filter );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString m_guid;
|
||||||
TrackModel* m_model;
|
TrackModel* m_model;
|
||||||
TrackProxyModel* m_proxyModel;
|
TrackProxyModel* m_proxyModel;
|
||||||
PlaylistItemDelegate* m_delegate;
|
PlaylistItemDelegate* m_delegate;
|
||||||
|
@@ -185,16 +185,16 @@ TomahawkSettings::setMainWindowState( const QByteArray& state )
|
|||||||
|
|
||||||
|
|
||||||
QList<QVariant>
|
QList<QVariant>
|
||||||
TomahawkSettings::playlistColumnSizes() const
|
TomahawkSettings::playlistColumnSizes( const QString& playlistid ) const
|
||||||
{
|
{
|
||||||
return value( "ui/playlist/columnSize" ).toList();
|
return value( QString( "ui/playlist/%1/columnSizes" ).arg( playlistid ) ).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkSettings::setPlaylistColumnSizes( const QList<QVariant>& cols )
|
TomahawkSettings::setPlaylistColumnSizes( const QString& playlistid, const QList<QVariant>& cols )
|
||||||
{
|
{
|
||||||
setValue( "ui/playlist/columnSize", cols );
|
setValue( QString( "ui/playlist/%1/columnSizes" ).arg( playlistid ), cols );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -32,8 +32,8 @@ public:
|
|||||||
void setMainWindowState( const QByteArray& state );
|
void setMainWindowState( const QByteArray& state );
|
||||||
|
|
||||||
/// Playlist stuff
|
/// Playlist stuff
|
||||||
QList<QVariant> playlistColumnSizes() const;
|
QList<QVariant> playlistColumnSizes( const QString& playlistid ) const;
|
||||||
void setPlaylistColumnSizes( const QList<QVariant>& cols );
|
void setPlaylistColumnSizes( const QString& playlistid, const QList<QVariant>& cols );
|
||||||
|
|
||||||
QList<Tomahawk::playlist_ptr> recentlyPlayedPlaylists() const;
|
QList<Tomahawk::playlist_ptr> recentlyPlayedPlaylists() const;
|
||||||
void appendRecentlyPlayedPlaylist( const Tomahawk::playlist_ptr& playlist );
|
void appendRecentlyPlayedPlaylist( const Tomahawk::playlist_ptr& playlist );
|
||||||
|
Reference in New Issue
Block a user