mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 07:07:05 +02:00
* Make TrackView's columns movable again.
* Tweak some default sizes.
This commit is contained in:
@@ -34,7 +34,7 @@ TrackView::TrackView( QWidget* parent )
|
|||||||
setDragDropOverwriteMode( false );
|
setDragDropOverwriteMode( false );
|
||||||
setAllColumnsShowFocus( true );
|
setAllColumnsShowFocus( true );
|
||||||
setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
|
setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
|
||||||
setMinimumWidth( 690 );
|
setMinimumWidth( 700 );
|
||||||
|
|
||||||
setHeader( m_header );
|
setHeader( m_header );
|
||||||
|
|
||||||
@@ -148,7 +148,6 @@ TrackView::addItemsToQueue()
|
|||||||
void
|
void
|
||||||
TrackView::resizeEvent( QResizeEvent* event )
|
TrackView::resizeEvent( QResizeEvent* event )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
m_header->onResized();
|
m_header->onResized();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,6 +378,7 @@ TrackHeader::TrackHeader( TrackView* parent )
|
|||||||
setResizeMode( QHeaderView::Interactive );
|
setResizeMode( QHeaderView::Interactive );
|
||||||
setMinimumSectionSize( 60 );
|
setMinimumSectionSize( 60 );
|
||||||
setDefaultAlignment( Qt::AlignLeft );
|
setDefaultAlignment( Qt::AlignLeft );
|
||||||
|
setMovable( true );
|
||||||
|
|
||||||
connect( this, SIGNAL( sectionResized( int, int, int ) ), SLOT( onSectionResized( int, int, int ) ) );
|
connect( this, SIGNAL( sectionResized( int, int, int ) ), SLOT( onSectionResized( int, int, int ) ) );
|
||||||
}
|
}
|
||||||
@@ -390,44 +390,36 @@ TrackHeader::~TrackHeader()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uint negativeWidth = 0;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackHeader::onSectionResized( int logicalIndex, int oldSize, int newSize )
|
TrackHeader::onSectionResized( int logicalidx, int oldSize, int newSize )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
if ( !m_init )
|
if ( !m_init )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
blockSignals( true );
|
blockSignals( true );
|
||||||
|
|
||||||
if ( newSize < 0 )
|
int visualidx = visualIndex( logicalidx );
|
||||||
resizeSection( logicalIndex, 0 );
|
|
||||||
|
|
||||||
for ( int i = logicalIndex + 1; i < count(); i++ )
|
for ( int i = visualidx + 1; i < count(); i++ )
|
||||||
{
|
{
|
||||||
int ns = sectionSize( i ) + oldSize - newSize;
|
int ns = sectionSize( logicalIndex( i ) ) + oldSize - newSize;
|
||||||
|
|
||||||
if ( ns < minimumSectionSize() )
|
if ( ns < minimumSectionSize() )
|
||||||
{
|
{
|
||||||
resizeSection( logicalIndex, newSize - ( minimumSectionSize() - ns ) );
|
resizeSection( logicalidx, newSize - ( minimumSectionSize() - ns ) );
|
||||||
ns = minimumSectionSize();
|
ns = minimumSectionSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
resizeSection( i, ns );
|
resizeSection( logicalIndex( i ), ns );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
blockSignals( false );
|
blockSignals( false );
|
||||||
|
|
||||||
negativeWidth = 0;
|
|
||||||
uint w = 0;
|
uint w = 0;
|
||||||
|
|
||||||
for ( int x = 0; x < m_columnWeights.count(); x++ )
|
for ( int x = 0; x < m_columnWeights.count(); x++ )
|
||||||
{
|
{
|
||||||
w += sectionSize( x );
|
w += sectionSize( x );
|
||||||
negativeWidth += sectionSize( x );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int x = 0; x < m_columnWeights.count(); x++ )
|
for ( int x = 0; x < m_columnWeights.count(); x++ )
|
||||||
@@ -435,15 +427,13 @@ TrackHeader::onSectionResized( int logicalIndex, int oldSize, int newSize )
|
|||||||
m_columnWeights[x] = (double)sectionSize( x ) / double( w );
|
m_columnWeights[x] = (double)sectionSize( x ) / double( w );
|
||||||
}
|
}
|
||||||
|
|
||||||
negativeWidth -= w;
|
saveColumnsState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackHeader::onResized()
|
TrackHeader::onResized()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
if ( !m_init && count() )
|
if ( !m_init && count() )
|
||||||
restoreColumnsState();
|
restoreColumnsState();
|
||||||
|
|
||||||
@@ -476,10 +466,9 @@ TrackHeader::restoreColumnsState()
|
|||||||
TomahawkSettings* s = APP->settings();
|
TomahawkSettings* s = APP->settings();
|
||||||
QList<QVariant> list = s->playlistColumnSizes();
|
QList<QVariant> list = s->playlistColumnSizes();
|
||||||
|
|
||||||
qDebug() << "COOOOOOUNT:" << count() << list.count();
|
|
||||||
if ( list.count() != count() ) // FIXME: const
|
if ( list.count() != count() ) // FIXME: const
|
||||||
{
|
{
|
||||||
m_columnWeights << 0.19 << 0.24 << 0.18 << 0.07 << 0.07 << 0.11 << 0.14;
|
m_columnWeights << 0.20 << 0.24 << 0.19 << 0.07 << 0.07 << 0.07 << 0.15;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -496,10 +485,7 @@ TrackHeader::saveColumnsState()
|
|||||||
QList<QVariant> wlist;
|
QList<QVariant> wlist;
|
||||||
|
|
||||||
foreach( double w, m_columnWeights )
|
foreach( double w, m_columnWeights )
|
||||||
{
|
|
||||||
wlist << QVariant( w );
|
wlist << QVariant( w );
|
||||||
// qDebug() << "Storing weight for column" << i++ << w;
|
|
||||||
}
|
|
||||||
|
|
||||||
s->setPlaylistColumnSizes( wlist );
|
s->setPlaylistColumnSizes( wlist );
|
||||||
}
|
}
|
||||||
|
@@ -64,6 +64,7 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
|||||||
ui->splitter->addWidget( m_playlistManager->widget() );
|
ui->splitter->addWidget( m_playlistManager->widget() );
|
||||||
ui->splitter->setStretchFactor( 0, 1 );
|
ui->splitter->setStretchFactor( 0, 1 );
|
||||||
ui->splitter->setStretchFactor( 1, 3 );
|
ui->splitter->setStretchFactor( 1, 3 );
|
||||||
|
ui->splitter->setCollapsible( 1, false );
|
||||||
|
|
||||||
ui->sidebarSplitter->setChildrenCollapsible( false );
|
ui->sidebarSplitter->setChildrenCollapsible( false );
|
||||||
ui->sidebarSplitter->setGreedyWidget( 0 );
|
ui->sidebarSplitter->setGreedyWidget( 0 );
|
||||||
|
Reference in New Issue
Block a user