1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 23:39:42 +01:00

* Resize ContextPage's columns.

This commit is contained in:
Christian Muehlhaeuser 2011-09-04 08:45:31 +02:00
parent 05315b14bd
commit 12c5b18b05
7 changed files with 34 additions and 11 deletions

View File

@ -31,6 +31,7 @@ RelatedArtistsContext::RelatedArtistsContext()
, m_infoId( uuid() )
{
m_relatedView = new ArtistView();
m_relatedView->setGuid( "RelatedArtistsContext" );
m_relatedModel = new TreeModel( m_relatedView );
m_relatedModel->setColumnStyle( TreeModel::TrackOnly );
m_relatedView->setTreeModel( m_relatedModel );

View File

@ -20,6 +20,7 @@
#include "playlist/playlistmodel.h"
#include "playlist/playlistview.h"
#include "playlist/trackheader.h"
using namespace Tomahawk;
@ -29,12 +30,14 @@ TopTracksContext::TopTracksContext()
, m_infoId( uuid() )
{
m_topHitsView = new PlaylistView();
m_topHitsView->setGuid( "TopTracksContext" );
m_topHitsView->setUpdatesContextView( false );
m_topHitsModel = new PlaylistModel( m_topHitsView );
m_topHitsModel->setStyle( TrackModel::Short );
m_topHitsView->setTrackModel( m_topHitsModel );
m_topHitsView->setPlaylistModel( m_topHitsModel );
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();
pal.setColor( QPalette::Window, QColor( 0, 0, 0, 0 ) );

View File

@ -178,6 +178,11 @@ ArtistView::resizeEvent( QResizeEvent* event )
{
QTreeView::resizeEvent( event );
m_header->checkState();
if ( model()->columnCount( QModelIndex() ) == 1 )
{
m_header->resizeSection( 0, event->size().width() );
}
}
@ -333,5 +338,8 @@ ArtistView::jumpToCurrentTrack()
QString
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;
}

View File

@ -40,6 +40,9 @@ public:
explicit ArtistView( QWidget* parent = 0 );
~ArtistView();
virtual QString guid() const;
virtual void setGuid( const QString& guid ) { m_guid = guid; }
void setProxyModel( TreeProxyModel* model );
TreeModel* model() const { return m_model; }
@ -64,8 +67,6 @@ public:
virtual bool jumpToCurrentTrack();
QString guid() const;
public slots:
void onItemActivated( const QModelIndex& index );
@ -96,6 +97,7 @@ private:
bool m_showModes;
QTimer m_timer;
mutable QString m_guid;
};
#endif // ARTISTVIEW_H

View File

@ -62,13 +62,16 @@ PlaylistView::setPlaylistModel( PlaylistModel* model )
TrackView::setTrackModel( m_model );
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() ) );
}
else
{
setGuid( QString( "playlistview/%1" ).arg( m_model->columnCount() ) );
if ( !m_model->playlist().isNull() )
{
setGuid( QString( "playlistview/%1/%2" ).arg( m_model->columnCount() ).arg( m_model->playlist()->guid() ) );
}
else
{
setGuid( QString( "playlistview/%1" ).arg( m_model->columnCount() ) );
}
}
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );

View File

@ -228,6 +228,11 @@ TrackView::resizeEvent( QResizeEvent* event )
// restoreState keeps overwriting our previous sort-order
sortByColumn( sortSection, sortOrder );
}
if ( model()->columnCount() == 1 )
{
m_header->resizeSection( 0, event->size().width() );
}
}

View File

@ -821,6 +821,7 @@ TreeModel::onDataChanged()
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount( QModelIndex() ) - 1 ) );
}
void
TreeModel::setColumnStyle( TreeModel::ColumnStyle style )
{