mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 19:30:21 +02:00
* Resize ContextPage's columns.
This commit is contained in:
@@ -31,6 +31,7 @@ RelatedArtistsContext::RelatedArtistsContext()
|
|||||||
, m_infoId( uuid() )
|
, m_infoId( uuid() )
|
||||||
{
|
{
|
||||||
m_relatedView = new ArtistView();
|
m_relatedView = new ArtistView();
|
||||||
|
m_relatedView->setGuid( "RelatedArtistsContext" );
|
||||||
m_relatedModel = new TreeModel( m_relatedView );
|
m_relatedModel = new TreeModel( m_relatedView );
|
||||||
m_relatedModel->setColumnStyle( TreeModel::TrackOnly );
|
m_relatedModel->setColumnStyle( TreeModel::TrackOnly );
|
||||||
m_relatedView->setTreeModel( m_relatedModel );
|
m_relatedView->setTreeModel( m_relatedModel );
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "playlist/playlistmodel.h"
|
#include "playlist/playlistmodel.h"
|
||||||
#include "playlist/playlistview.h"
|
#include "playlist/playlistview.h"
|
||||||
|
#include "playlist/trackheader.h"
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
@@ -29,12 +30,14 @@ TopTracksContext::TopTracksContext()
|
|||||||
, m_infoId( uuid() )
|
, m_infoId( uuid() )
|
||||||
{
|
{
|
||||||
m_topHitsView = new PlaylistView();
|
m_topHitsView = new PlaylistView();
|
||||||
|
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( TrackModel::Short );
|
m_topHitsModel->setStyle( TrackModel::Short );
|
||||||
m_topHitsView->setTrackModel( m_topHitsModel );
|
m_topHitsView->setPlaylistModel( m_topHitsModel );
|
||||||
m_topHitsView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
m_topHitsView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||||
m_topHitsView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
m_topHitsView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||||
|
m_topHitsView->setHeaderHidden( true );
|
||||||
|
|
||||||
QPalette pal = m_topHitsView->palette();
|
QPalette pal = m_topHitsView->palette();
|
||||||
pal.setColor( QPalette::Window, QColor( 0, 0, 0, 0 ) );
|
pal.setColor( QPalette::Window, QColor( 0, 0, 0, 0 ) );
|
||||||
|
@@ -178,6 +178,11 @@ ArtistView::resizeEvent( QResizeEvent* event )
|
|||||||
{
|
{
|
||||||
QTreeView::resizeEvent( event );
|
QTreeView::resizeEvent( event );
|
||||||
m_header->checkState();
|
m_header->checkState();
|
||||||
|
|
||||||
|
if ( model()->columnCount( QModelIndex() ) == 1 )
|
||||||
|
{
|
||||||
|
m_header->resizeSection( 0, event->size().width() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -333,5 +338,8 @@ ArtistView::jumpToCurrentTrack()
|
|||||||
QString
|
QString
|
||||||
ArtistView::guid() const
|
ArtistView::guid() const
|
||||||
{
|
{
|
||||||
return QString( "artistview/%1" ).arg( m_model->columnCount( QModelIndex() ) );
|
if ( m_guid.isEmpty() )
|
||||||
|
m_guid = QString( "artistview/%1" ).arg( m_model->columnCount( QModelIndex() ) );
|
||||||
|
|
||||||
|
return m_guid;
|
||||||
}
|
}
|
||||||
|
@@ -40,6 +40,9 @@ public:
|
|||||||
explicit ArtistView( QWidget* parent = 0 );
|
explicit ArtistView( QWidget* parent = 0 );
|
||||||
~ArtistView();
|
~ArtistView();
|
||||||
|
|
||||||
|
virtual QString guid() const;
|
||||||
|
virtual void setGuid( const QString& guid ) { m_guid = guid; }
|
||||||
|
|
||||||
void setProxyModel( TreeProxyModel* model );
|
void setProxyModel( TreeProxyModel* model );
|
||||||
|
|
||||||
TreeModel* model() const { return m_model; }
|
TreeModel* model() const { return m_model; }
|
||||||
@@ -64,8 +67,6 @@ public:
|
|||||||
|
|
||||||
virtual bool jumpToCurrentTrack();
|
virtual bool jumpToCurrentTrack();
|
||||||
|
|
||||||
QString guid() const;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onItemActivated( const QModelIndex& index );
|
void onItemActivated( const QModelIndex& index );
|
||||||
|
|
||||||
@@ -96,6 +97,7 @@ private:
|
|||||||
|
|
||||||
bool m_showModes;
|
bool m_showModes;
|
||||||
QTimer m_timer;
|
QTimer m_timer;
|
||||||
|
mutable QString m_guid;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ARTISTVIEW_H
|
#endif // ARTISTVIEW_H
|
||||||
|
@@ -62,13 +62,16 @@ PlaylistView::setPlaylistModel( PlaylistModel* model )
|
|||||||
TrackView::setTrackModel( m_model );
|
TrackView::setTrackModel( m_model );
|
||||||
setColumnHidden( TrackModel::Age, true ); // Hide age column per default
|
setColumnHidden( TrackModel::Age, true ); // Hide age column per default
|
||||||
|
|
||||||
if ( guid().isEmpty() && !m_model->playlist().isNull() )
|
if ( guid().isEmpty() )
|
||||||
{
|
{
|
||||||
setGuid( QString( "playlistview/%1/%2" ).arg( m_model->columnCount() ).arg( m_model->playlist()->guid() ) );
|
if ( !m_model->playlist().isNull() )
|
||||||
}
|
{
|
||||||
else
|
setGuid( QString( "playlistview/%1/%2" ).arg( m_model->columnCount() ).arg( m_model->playlist()->guid() ) );
|
||||||
{
|
}
|
||||||
setGuid( QString( "playlistview/%1" ).arg( m_model->columnCount() ) );
|
else
|
||||||
|
{
|
||||||
|
setGuid( QString( "playlistview/%1" ).arg( m_model->columnCount() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||||
|
@@ -228,6 +228,11 @@ TrackView::resizeEvent( QResizeEvent* event )
|
|||||||
// restoreState keeps overwriting our previous sort-order
|
// restoreState keeps overwriting our previous sort-order
|
||||||
sortByColumn( sortSection, sortOrder );
|
sortByColumn( sortSection, sortOrder );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( model()->columnCount() == 1 )
|
||||||
|
{
|
||||||
|
m_header->resizeSection( 0, event->size().width() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -821,6 +821,7 @@ TreeModel::onDataChanged()
|
|||||||
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount( QModelIndex() ) - 1 ) );
|
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount( QModelIndex() ) - 1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TreeModel::setColumnStyle( TreeModel::ColumnStyle style )
|
TreeModel::setColumnStyle( TreeModel::ColumnStyle style )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user