From fa6a2533d0476bf9f36e9e1012fa13222b4c2995 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sat, 26 Feb 2011 01:21:27 +0100 Subject: [PATCH] * Scanning status should have priority over now-playing information. --- src/libtomahawk/source.cpp | 6 +-- src/sourcetree/sourcesmodel.cpp | 14 ++++--- src/sourcetree/sourcetreeview.cpp | 66 +++++++++++++++---------------- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/libtomahawk/source.cpp b/src/libtomahawk/source.cpp index e6400344f..0c24deb26 100644 --- a/src/libtomahawk/source.cpp +++ b/src/libtomahawk/source.cpp @@ -159,7 +159,7 @@ Source::scanningProgress( unsigned int files ) void Source::scanningFinished( unsigned int files ) { - m_textStatus = tr( "Online" ); + m_textStatus = QString(); emit stateChanged(); } @@ -183,14 +183,14 @@ Source::onStateChanged( DBSyncConnection::State newstate, DBSyncConnection::Stat msg = tr( "Saving" ); break; case DBSyncConnection::SYNCED: - msg = tr( "Online" ); + msg = QString(); break; case DBSyncConnection::SCANNING: msg = tr( "Scanning (%L1 tracks)" ).arg( info ); break; default: - msg = "???"; + msg = QString(); } m_textStatus = msg; diff --git a/src/sourcetree/sourcesmodel.cpp b/src/sourcetree/sourcesmodel.cpp index 3a8cf60ce..a84c7da7a 100644 --- a/src/sourcetree/sourcesmodel.cpp +++ b/src/sourcetree/sourcesmodel.cpp @@ -124,13 +124,15 @@ SourcesModel::appendItem( const source_ptr& source ) // qDebug() << "Appending source item:" << item->source()->username(); invisibleRootItem()->appendRow( item->columns() ); -// m_parent->setIndexWidget( m_parent->model()->index( rowCount() - 1, 0 ), item->widget() ); - connect( source.data(), SIGNAL( offline() ), SLOT( onSourceChanged() ) ); - connect( source.data(), SIGNAL( online() ), SLOT( onSourceChanged() ) ); - connect( source.data(), SIGNAL( stats( QVariantMap ) ), SLOT( onSourceChanged() ) ); - connect( source.data(), SIGNAL( playbackStarted( Tomahawk::query_ptr ) ), SLOT( onSourceChanged() ) ); - connect( source.data(), SIGNAL( stateChanged() ), SLOT( onSourceChanged() ) ); + if ( !source.isNull() ) + { + connect( source.data(), SIGNAL( offline() ), SLOT( onSourceChanged() ) ); + connect( source.data(), SIGNAL( online() ), SLOT( onSourceChanged() ) ); + connect( source.data(), SIGNAL( stats( QVariantMap ) ), SLOT( onSourceChanged() ) ); + connect( source.data(), SIGNAL( playbackStarted( Tomahawk::query_ptr ) ), SLOT( onSourceChanged() ) ); + connect( source.data(), SIGNAL( stateChanged() ), SLOT( onSourceChanged() ) ); + } return true; // FIXME } diff --git a/src/sourcetree/sourcetreeview.cpp b/src/sourcetree/sourcetreeview.cpp index dbee09d92..916d725a0 100644 --- a/src/sourcetree/sourcetreeview.cpp +++ b/src/sourcetree/sourcetreeview.cpp @@ -469,7 +469,7 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co QString desc = status ? sti->source()->textStatus() : tr( "Offline" ); if ( sti->source().isNull() ) desc = tr( "All available tracks" ); - if ( status && !sti->source()->currentTrack().isNull() ) + if ( status && desc.isEmpty() && !sti->source()->currentTrack().isNull() ) desc = sti->source()->currentTrack()->artist() + " - " + sti->source()->currentTrack()->track(); if ( desc.isEmpty() ) desc = tr( "Online" ); @@ -479,41 +479,39 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co text = painter->fontMetrics().elidedText( desc, Qt::ElideRight, textRect.width() ); painter->drawText( textRect, text ); - if ( !status ) + if ( status ) { - painter->restore(); - return; + painter->setRenderHint( QPainter::Antialiasing ); + + QRect figRect = o.rect.adjusted( o.rect.width() - figWidth - 18, 0, -10, -o.rect.height() + 16 ); + int hd = ( option.rect.height() - figRect.height() ) / 2; + figRect.adjust( 0, hd, 0, hd ); + + QColor figColor( 167, 183, 211 ); + painter->setPen( figColor ); + painter->setBrush( figColor ); + + QPen origpen = painter->pen(); + QPen pen = origpen; + pen.setWidth( 1.0 ); + painter->setPen( pen ); + painter->drawRect( figRect ); + + QPainterPath ppath; + ppath.moveTo( QPoint( figRect.x(), figRect.y() ) ); + ppath.quadTo( QPoint( figRect.x() - 8, figRect.y() + figRect.height() / 2 ), QPoint( figRect.x(), figRect.y() + figRect.height() ) ); + painter->drawPath( ppath ); + ppath.moveTo( QPoint( figRect.x() + figRect.width(), figRect.y() ) ); + ppath.quadTo( QPoint( figRect.x() + figRect.width() + 8, figRect.y() + figRect.height() / 2 ), QPoint( figRect.x() + figRect.width(), figRect.y() + figRect.height() ) ); + painter->drawPath( ppath ); + + painter->setPen( origpen ); + + QTextOption to( Qt::AlignCenter ); + painter->setFont( bold ); + painter->setPen( Qt::white ); + painter->drawText( figRect, tracks, to ); } - painter->setRenderHint( QPainter::Antialiasing ); - - QRect figRect = o.rect.adjusted( o.rect.width() - figWidth - 18, 0, -10, -o.rect.height() + 16 ); - int hd = ( option.rect.height() - figRect.height() ) / 2; - figRect.adjust( 0, hd, 0, hd ); - - QColor figColor( 167, 183, 211 ); - painter->setPen( figColor ); - painter->setBrush( figColor ); - - QPen origpen = painter->pen(); - QPen pen = origpen; - pen.setWidth( 1.0 ); - painter->setPen( pen ); - painter->drawRect( figRect ); - - QPainterPath ppath; - ppath.moveTo( QPoint( figRect.x(), figRect.y() ) ); - ppath.quadTo( QPoint( figRect.x() - 8, figRect.y() + figRect.height() / 2 ), QPoint( figRect.x(), figRect.y() + figRect.height() ) ); - painter->drawPath( ppath ); - ppath.moveTo( QPoint( figRect.x() + figRect.width(), figRect.y() ) ); - ppath.quadTo( QPoint( figRect.x() + figRect.width() + 8, figRect.y() + figRect.height() / 2 ), QPoint( figRect.x() + figRect.width(), figRect.y() + figRect.height() ) ); - painter->drawPath( ppath ); - - painter->setPen( origpen ); - - QTextOption to( Qt::AlignCenter ); - painter->setFont( bold ); - painter->setPen( Qt::white ); - painter->drawText( figRect, tracks, to ); painter->restore(); }