mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-02-26 04:43:06 +01:00
* Made QHeaderView behave, mostly.
* Removed online / offline button again.
This commit is contained in:
parent
0934b443f4
commit
6e708cc0c4
@ -13,7 +13,6 @@ 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 );
|
||||||
@ -37,6 +36,7 @@ void
|
|||||||
CollectionView::setModel( TrackModel* model )
|
CollectionView::setModel( TrackModel* model )
|
||||||
{
|
{
|
||||||
TrackView::setModel( model );
|
TrackView::setModel( model );
|
||||||
|
setGuid( "collectionview" );
|
||||||
|
|
||||||
connect( model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
connect( model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ 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 );
|
||||||
@ -31,14 +30,16 @@ PlaylistView::~PlaylistView()
|
|||||||
void
|
void
|
||||||
PlaylistView::setModel( PlaylistModel* model )
|
PlaylistView::setModel( PlaylistModel* model )
|
||||||
{
|
{
|
||||||
if ( !model->playlist().isNull() )
|
|
||||||
setGuid( QString( "playlistview/%1" ).arg( model->playlist()->guid() ) );
|
|
||||||
|
|
||||||
m_model = model;
|
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
|
||||||
|
|
||||||
|
if ( !model->playlist().isNull() )
|
||||||
|
setGuid( QString( "playlistview/%1" ).arg( model->playlist()->guid() ) );
|
||||||
|
else
|
||||||
|
setGuid( "playlistview" );
|
||||||
|
|
||||||
connect( model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
connect( model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,28 +14,27 @@ TrackHeader::TrackHeader( TrackView* parent )
|
|||||||
, m_parent( parent )
|
, m_parent( parent )
|
||||||
, m_menu( new QMenu( this ) )
|
, m_menu( new QMenu( this ) )
|
||||||
, m_sigmap( new QSignalMapper( this ) )
|
, m_sigmap( new QSignalMapper( this ) )
|
||||||
, m_hiddenWidth( 0 )
|
|
||||||
, m_hiddenPct( 0.0 )
|
|
||||||
, m_init( false )
|
, m_init( false )
|
||||||
{
|
{
|
||||||
setStretchLastSection( true );
|
|
||||||
setResizeMode( QHeaderView::Interactive );
|
setResizeMode( QHeaderView::Interactive );
|
||||||
setMinimumSectionSize( 60 );
|
setMinimumSectionSize( 60 );
|
||||||
setDefaultAlignment( Qt::AlignLeft );
|
setDefaultAlignment( Qt::AlignLeft );
|
||||||
setMovable( true );
|
setMovable( true );
|
||||||
|
setStretchLastSection( 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 ) ) );
|
||||||
connect( m_sigmap, SIGNAL( mapped( int ) ), SLOT( toggleVisibility( int ) ) );
|
connect( m_sigmap, SIGNAL( mapped( int ) ), SLOT( toggleVisibility( int ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TrackHeader::~TrackHeader()
|
TrackHeader::~TrackHeader()
|
||||||
{
|
{
|
||||||
saveColumnsState();
|
qDebug() << "Storing for:" << m_parent->guid();
|
||||||
|
TomahawkSettings::instance()->setPlaylistColumnSizes( m_parent->guid(), saveState() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -47,75 +46,35 @@ TrackHeader::visibleSectionCount() const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackHeader::onSectionResized( int logicalidx, int oldSize, int newSize )
|
TrackHeader::checkState()
|
||||||
{
|
{
|
||||||
if ( !m_init )
|
if ( !count() || m_init )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int width = m_parent->viewport()->width();
|
qDebug() << "Restoring for:" << m_parent->guid();
|
||||||
for ( int x = 0; x < m_columnWeights.count(); x++ )
|
|
||||||
{
|
|
||||||
if ( sectionSize( x ) )
|
|
||||||
{
|
|
||||||
// not hidden
|
|
||||||
m_columnWeights[x] = (double)sectionSize( x ) / (double)width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TrackHeader::onResized()
|
|
||||||
{
|
|
||||||
if ( !m_init && count() )
|
|
||||||
restoreColumnsState();
|
|
||||||
|
|
||||||
m_init = false;
|
|
||||||
|
|
||||||
int width = m_parent->viewport()->width();
|
|
||||||
for ( int x = 0; x < m_columnWeights.count(); x++ )
|
|
||||||
{
|
|
||||||
if ( sectionSize( x ) )
|
|
||||||
{
|
|
||||||
// not hidden
|
|
||||||
double nw = (double)width * m_columnWeights[x];
|
|
||||||
resizeSection( x, qMax( minimumSectionSize(), int( nw ) ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_init = true;
|
m_init = true;
|
||||||
}
|
QByteArray state = TomahawkSettings::instance()->playlistColumnSizes( m_parent->guid() );
|
||||||
|
|
||||||
|
if ( !state.isEmpty() )
|
||||||
void
|
restoreState( state );
|
||||||
TrackHeader::restoreColumnsState()
|
|
||||||
{
|
|
||||||
QList<QVariant> list = TomahawkSettings::instance()->playlistColumnSizes( m_parent->guid() );
|
|
||||||
|
|
||||||
if ( list.count() != count() ) // FIXME: const
|
|
||||||
{
|
|
||||||
m_columnWeights << 0.21 << 0.22 << 0.20 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.12;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach( const QVariant& v, list )
|
QList< double > m_columnWeights;
|
||||||
m_columnWeights << v.toDouble();
|
m_columnWeights << 0.21 << 0.22 << 0.20 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05; // << 0.12;
|
||||||
|
|
||||||
|
for ( int i = 0; i < count(); i++ )
|
||||||
|
{
|
||||||
|
if ( isSectionHidden( i ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
double nw = (double)m_parent->width() * m_columnWeights.at( i );
|
||||||
|
qDebug() << "Setting default size:" << i << nw;
|
||||||
|
resizeSection( i, qMax( minimumSectionSize(), int( nw - 0.5 ) ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TrackHeader::saveColumnsState()
|
|
||||||
{
|
|
||||||
QList<QVariant> wlist;
|
|
||||||
|
|
||||||
foreach( double w, m_columnWeights )
|
|
||||||
wlist << QVariant( w );
|
|
||||||
|
|
||||||
TomahawkSettings::instance()->setPlaylistColumnSizes( m_parent->guid(), wlist );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackHeader::addColumnToMenu( int index )
|
TrackHeader::addColumnToMenu( int index )
|
||||||
{
|
{
|
||||||
@ -158,6 +117,4 @@ TrackHeader::toggleVisibility( int index )
|
|||||||
showSection( index );
|
showSection( index );
|
||||||
else
|
else
|
||||||
hideSection( index );
|
hideSection( index );
|
||||||
|
|
||||||
onResized();
|
|
||||||
}
|
}
|
||||||
|
@ -19,32 +19,24 @@ public:
|
|||||||
int visibleSectionCount() const;
|
int visibleSectionCount() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onResized();
|
|
||||||
void toggleVisibility( int index );
|
void toggleVisibility( int index );
|
||||||
|
void checkState();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void contextMenuEvent( QContextMenuEvent* e );
|
void contextMenuEvent( QContextMenuEvent* e );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSectionResized( int logicalIndex, int oldSize, int newSize );
|
// void onSectionResized( int index );
|
||||||
|
|
||||||
void onToggleResizeColumns();
|
void onToggleResizeColumns();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addColumnToMenu( int index );
|
void addColumnToMenu( int index );
|
||||||
|
|
||||||
void restoreColumnsState();
|
|
||||||
void saveColumnsState();
|
|
||||||
|
|
||||||
TrackView* m_parent;
|
TrackView* m_parent;
|
||||||
|
|
||||||
QMenu* m_menu;
|
QMenu* m_menu;
|
||||||
QSignalMapper* m_sigmap;
|
QSignalMapper* m_sigmap;
|
||||||
QList<QAction*> m_visActions;
|
QList<QAction*> m_visActions;
|
||||||
|
|
||||||
QList<double> m_columnWeights;
|
|
||||||
int m_hiddenWidth;
|
|
||||||
double m_hiddenPct;
|
|
||||||
bool m_init;
|
bool m_init;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ TrackModel::headerData( int section, Qt::Orientation orientation, int role ) con
|
|||||||
{
|
{
|
||||||
QStringList headers;
|
QStringList headers;
|
||||||
headers << tr( "Artist" ) << tr( "Track" ) << tr( "Album" ) << tr( "Duration" ) << tr( "Bitrate" ) << tr( "Age" ) << tr( "Year" ) << tr( "Size" ) << tr( "Origin" );
|
headers << tr( "Artist" ) << tr( "Track" ) << tr( "Album" ) << tr( "Duration" ) << tr( "Bitrate" ) << tr( "Age" ) << tr( "Year" ) << tr( "Size" ) << tr( "Origin" );
|
||||||
if ( orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 )
|
if ( role == Qt::DisplayRole && section >= 0 )
|
||||||
{
|
{
|
||||||
return headers.at( section );
|
return headers.at( section );
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ TrackView::TrackView( QWidget* parent )
|
|||||||
setRootIsDecorated( false );
|
setRootIsDecorated( false );
|
||||||
setUniformRowHeights( true );
|
setUniformRowHeights( true );
|
||||||
setMinimumWidth( 300 );
|
setMinimumWidth( 300 );
|
||||||
|
setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
|
||||||
|
|
||||||
setHeader( m_header );
|
setHeader( m_header );
|
||||||
|
|
||||||
@ -61,6 +62,13 @@ TrackView::~TrackView()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TrackView::setGuid( const QString& guid )
|
||||||
|
{
|
||||||
|
m_guid = guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackView::setProxyModel( TrackProxyModel* model )
|
TrackView::setProxyModel( TrackProxyModel* model )
|
||||||
{
|
{
|
||||||
@ -156,7 +164,7 @@ TrackView::addItemsToQueue()
|
|||||||
void
|
void
|
||||||
TrackView::resizeEvent( QResizeEvent* event )
|
TrackView::resizeEvent( QResizeEvent* event )
|
||||||
{
|
{
|
||||||
m_header->onResized();
|
m_header->checkState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ public:
|
|||||||
~TrackView();
|
~TrackView();
|
||||||
|
|
||||||
virtual QString guid() const { return m_guid; }
|
virtual QString guid() const { return m_guid; }
|
||||||
virtual void setGuid( const QString& guid ) { m_guid = guid; }
|
virtual void setGuid( const QString& guid );
|
||||||
|
|
||||||
virtual void setModel( TrackModel* model );
|
virtual void setModel( TrackModel* model );
|
||||||
void setProxyModel( TrackProxyModel* model );
|
void setProxyModel( TrackProxyModel* model );
|
||||||
|
@ -184,17 +184,17 @@ TomahawkSettings::setMainWindowState( const QByteArray& state )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<QVariant>
|
QByteArray
|
||||||
TomahawkSettings::playlistColumnSizes( const QString& playlistid ) const
|
TomahawkSettings::playlistColumnSizes( const QString& playlistid ) const
|
||||||
{
|
{
|
||||||
return value( QString( "ui/playlist/%1/columnSizes" ).arg( playlistid ) ).toList();
|
return value( QString( "ui/playlist/%1/columnSizes" ).arg( playlistid ) ).toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkSettings::setPlaylistColumnSizes( const QString& playlistid, const QList<QVariant>& cols )
|
TomahawkSettings::setPlaylistColumnSizes( const QString& playlistid, const QByteArray& state )
|
||||||
{
|
{
|
||||||
setValue( QString( "ui/playlist/%1/columnSizes" ).arg( playlistid ), cols );
|
setValue( QString( "ui/playlist/%1/columnSizes" ).arg( playlistid ), state );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,8 +32,8 @@ public:
|
|||||||
void setMainWindowState( const QByteArray& state );
|
void setMainWindowState( const QByteArray& state );
|
||||||
|
|
||||||
/// Playlist stuff
|
/// Playlist stuff
|
||||||
QList<QVariant> playlistColumnSizes( const QString& playlistid ) const;
|
QByteArray playlistColumnSizes( const QString& playlistid ) const;
|
||||||
void setPlaylistColumnSizes( const QString& playlistid, const QList<QVariant>& cols );
|
void setPlaylistColumnSizes( const QString& playlistid, const QByteArray& state );
|
||||||
|
|
||||||
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 );
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QSplitter>
|
||||||
#include <QStyleOption>
|
#include <QStyleOption>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
@ -19,8 +20,12 @@ ProxyStyle::drawControl( ControlElement ce, const QStyleOption* opt, QPainter* p
|
|||||||
{
|
{
|
||||||
if ( ce == CE_Splitter )
|
if ( ce == CE_Splitter )
|
||||||
{
|
{
|
||||||
p->setPen( QColor( 0x8c, 0x8c, 0x8c ) );
|
const QSplitter* splitter = qobject_cast< const QSplitter* >( w );
|
||||||
p->drawLine( opt->rect.topLeft(), opt->rect.bottomRight() );
|
if ( !splitter->sizes().contains( 0 ) )
|
||||||
|
{
|
||||||
|
p->setPen( QColor( 0x8c, 0x8c, 0x8c ) );
|
||||||
|
p->drawLine( opt->rect.topLeft(), opt->rect.bottomRight() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
QProxyStyle::drawControl( ce, opt, p, w );
|
QProxyStyle::drawControl( ce, opt, p, w );
|
||||||
|
@ -87,22 +87,22 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
|||||||
sidebar->addWidget( transferView );
|
sidebar->addWidget( transferView );
|
||||||
sidebar->hide( 1, false );
|
sidebar->hide( 1, false );
|
||||||
|
|
||||||
QWidget* buttonWidget = new QWidget();
|
/* QWidget* buttonWidget = new QWidget();
|
||||||
buttonWidget->setLayout( new QVBoxLayout() );
|
buttonWidget->setLayout( new QVBoxLayout() );
|
||||||
m_statusButton = new QPushButton();
|
m_statusButton = new QPushButton();
|
||||||
buttonWidget->layout()->addWidget( m_statusButton );
|
buttonWidget->layout()->addWidget( m_statusButton );*/
|
||||||
|
|
||||||
sidebarWidget->layout()->addWidget( sidebar );
|
sidebarWidget->layout()->addWidget( sidebar );
|
||||||
sidebarWidget->layout()->addWidget( buttonWidget );
|
// sidebarWidget->layout()->addWidget( buttonWidget );
|
||||||
|
|
||||||
sidebarWidget->setContentsMargins( 0, 0, 0, 0 );
|
sidebarWidget->setContentsMargins( 0, 0, 0, 0 );
|
||||||
sidebarWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
|
sidebarWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
|
||||||
sidebarWidget->layout()->setMargin( 0 );
|
sidebarWidget->layout()->setMargin( 0 );
|
||||||
sidebarWidget->layout()->setSpacing( 0 );
|
sidebarWidget->layout()->setSpacing( 0 );
|
||||||
buttonWidget->setContentsMargins( 0, 0, 0, 0 );
|
/* buttonWidget->setContentsMargins( 0, 0, 0, 0 );
|
||||||
buttonWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
|
buttonWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
|
||||||
buttonWidget->layout()->setMargin( 0 );
|
buttonWidget->layout()->setMargin( 0 );
|
||||||
buttonWidget->layout()->setSpacing( 0 );
|
buttonWidget->layout()->setSpacing( 0 );*/
|
||||||
|
|
||||||
ui->splitter->addWidget( sidebarWidget );
|
ui->splitter->addWidget( sidebarWidget );
|
||||||
ui->splitter->addWidget( PlaylistManager::instance()->widget() );
|
ui->splitter->addWidget( PlaylistManager::instance()->widget() );
|
||||||
@ -181,7 +181,7 @@ TomahawkWindow::setupSignals()
|
|||||||
connect( ui->actionCreate_New_Station, SIGNAL( triggered() ), SLOT( createStation() ));
|
connect( ui->actionCreate_New_Station, SIGNAL( triggered() ), SLOT( createStation() ));
|
||||||
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
|
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
|
||||||
connect( ui->actionExit, SIGNAL( triggered() ), APP, SLOT( quit() ) );
|
connect( ui->actionExit, SIGNAL( triggered() ), APP, SLOT( quit() ) );
|
||||||
connect( m_statusButton, SIGNAL( clicked() ), APP->sipHandler(), SLOT( toggleConnect() ) );
|
// connect( m_statusButton, SIGNAL( clicked() ), APP->sipHandler(), SLOT( toggleConnect() ) );
|
||||||
|
|
||||||
// <SipHandler>
|
// <SipHandler>
|
||||||
connect( APP->sipHandler(), SIGNAL( connected() ), SLOT( onSipConnected() ) );
|
connect( APP->sipHandler(), SIGNAL( connected() ), SLOT( onSipConnected() ) );
|
||||||
@ -392,14 +392,14 @@ TomahawkWindow::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
|||||||
void
|
void
|
||||||
TomahawkWindow::onSipConnected()
|
TomahawkWindow::onSipConnected()
|
||||||
{
|
{
|
||||||
m_statusButton->setText( tr( "Online" ) );
|
// m_statusButton->setText( tr( "Online" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkWindow::onSipDisconnected()
|
TomahawkWindow::onSipDisconnected()
|
||||||
{
|
{
|
||||||
m_statusButton->setText( tr( "Offline" ) );
|
// m_statusButton->setText( tr( "Offline" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user