diff --git a/data/images/closed-padlock.png b/data/images/closed-padlock.png
new file mode 100644
index 000000000..ca5aefaa3
Binary files /dev/null and b/data/images/closed-padlock.png differ
diff --git a/data/images/open-padlock.png b/data/images/open-padlock.png
new file mode 100644
index 000000000..58be8e65f
Binary files /dev/null and b/data/images/open-padlock.png differ
diff --git a/data/sql/dbmigrate-26_to_27.sql b/data/sql/dbmigrate-26_to_27.sql
index 1b8ff87c7..f7c899e68 100644
--- a/data/sql/dbmigrate-26_to_27.sql
+++ b/data/sql/dbmigrate-26_to_27.sql
@@ -1,4 +1,4 @@
--- Script to migate from db version 6 to 27
+-- Script to migate from db version 26 to 27
-- Nothing to do
CREATE TABLE IF NOT EXISTS collection_attributes (
diff --git a/data/sql/dbmigrate-27_to_28.sql b/data/sql/dbmigrate-27_to_28.sql
new file mode 100644
index 000000000..14b1d371b
--- /dev/null
+++ b/data/sql/dbmigrate-27_to_28.sql
@@ -0,0 +1,7 @@
+-- Script to migate from db version 27 to 28.
+-- Added albumartist and discnumber to file_join
+
+ALTER TABLE file_join ADD COLUMN composer INTEGER REFERENCES artist(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED;
+ALTER TABLE file_join ADD COLUMN discnumber INTEGER;
+
+UPDATE settings SET v = '28' WHERE k == 'schema_version';
diff --git a/resources.qrc b/resources.qrc
index 6ef95131e..9b9010880 100644
--- a/resources.qrc
+++ b/resources.qrc
@@ -128,8 +128,11 @@
data/images/headphones.png
data/images/headphones-off.png
data/images/headphones-sidebar.png
+ data/images/closed-padlock.png
+ data/images/open-padlock.png
data/images/headphones-bigger.png
data/images/no-album-no-case.png
data/images/rdio.png
+ data/sql/dbmigrate-27_to_28.sql
diff --git a/src/accounts/xmpp/sip/xmlconsole.cpp b/src/accounts/xmpp/sip/xmlconsole.cpp
index e57969fd1..cb1f3c8ea 100644
--- a/src/accounts/xmpp/sip/xmlconsole.cpp
+++ b/src/accounts/xmpp/sip/xmlconsole.cpp
@@ -276,8 +276,14 @@ void XmlConsole::stackProcess(const QByteArray &data, bool incoming)
break;
case QXmlStreamReader::Characters:
token = d->tokens.isEmpty() ? 0 : d->tokens.last();
- if (token && token->type == QXmlStreamReader::StartElement && !token->startTag.empty)
- d->tokens << new StackToken(d->reader);
+ if (token && token->type == QXmlStreamReader::StartElement && !token->startTag.empty) {
+ if (*token->startTag.name == QLatin1String("auth")
+ && *token->startTag.xmlns == QLatin1String("urn:ietf:params:xml:ns:xmpp-sasl")) {
+ d->tokens << new StackToken(QLatin1String("<>"));
+ } else {
+ d->tokens << new StackToken(d->reader);
+ }
+ }
break;
default:
break;
diff --git a/src/accounts/xmpp/sip/xmlconsole.h b/src/accounts/xmpp/sip/xmlconsole.h
index 4c8476953..2f8e27846 100644
--- a/src/accounts/xmpp/sip/xmlconsole.h
+++ b/src/accounts/xmpp/sip/xmlconsole.h
@@ -110,6 +110,14 @@ private:
endTag.name = new QStringRef(endTag.namePointer, tmp.position(), tmp.length());
}
}
+
+ StackToken(const QString &name)
+ {
+ type = QXmlStreamReader::Characters;
+ charachters.textPointer = new QString(name);
+ charachters.text = new QStringRef(charachters.textPointer);
+ }
+
~StackToken()
{
if (type == QXmlStreamReader::StartElement) {
diff --git a/src/accounts/xmpp/sip/xmppsip.cpp b/src/accounts/xmpp/sip/xmppsip.cpp
index 2a0b07457..20797847d 100644
--- a/src/accounts/xmpp/sip/xmppsip.cpp
+++ b/src/accounts/xmpp/sip/xmppsip.cpp
@@ -52,7 +52,6 @@
#include
#endif
-
#include
#include "utils/logger.h"
@@ -146,6 +145,7 @@ XmppSipPlugin::~XmppSipPlugin()
delete m_client;
}
+
#ifndef ENABLE_HEADLESS
QMenu*
XmppSipPlugin::menu()
@@ -178,6 +178,7 @@ XmppSipPlugin::connectPlugin()
return;
}
+
void
XmppSipPlugin::disconnectPlugin()
{
@@ -203,6 +204,7 @@ XmppSipPlugin::disconnectPlugin()
emit stateChanged( m_state );
}
+
void
XmppSipPlugin::onConnect()
{
@@ -245,6 +247,7 @@ XmppSipPlugin::onConnect()
addMenuHelper();
}
+
void
XmppSipPlugin::onDisconnect( Jreen::Client::DisconnectReason reason )
{
@@ -286,12 +289,14 @@ XmppSipPlugin::onDisconnect( Jreen::Client::DisconnectReason reason )
}
}
+
void
XmppSipPlugin::onError( const Jreen::Connection::SocketError& e )
{
- tLog() << "JABBER error:" << e;
+ tDebug() << "JABBER error:" << e;
}
+
QString
XmppSipPlugin::errorMessage( Jreen::Client::DisconnectReason reason )
{
@@ -341,6 +346,7 @@ XmppSipPlugin::errorMessage( Jreen::Client::DisconnectReason reason )
return QString();
}
+
void
XmppSipPlugin::sendMsg(const QString& to, const QString& msg)
{
@@ -386,6 +392,7 @@ XmppSipPlugin::sendMsg(const QString& to, const QString& msg)
connect(reply, SIGNAL(received(Jreen::IQ)), SLOT(onNewIq(Jreen::IQ)));
}
+
void
XmppSipPlugin::broadcastMsg(const QString& msg)
{
@@ -400,6 +407,7 @@ XmppSipPlugin::broadcastMsg(const QString& msg)
}
}
+
void
XmppSipPlugin::addContact(const QString& jid, const QString& msg)
{
@@ -414,6 +422,7 @@ XmppSipPlugin::addContact(const QString& jid, const QString& msg)
return;
}
+
void
XmppSipPlugin::showAddFriendDialog()
{
@@ -430,6 +439,7 @@ XmppSipPlugin::showAddFriendDialog()
#endif
}
+
QString
XmppSipPlugin::defaultSuffix() const
{
@@ -577,7 +587,7 @@ void XmppSipPlugin::onNewMessage(const Jreen::Message& message)
if( message.subtype() == Jreen::Message::Error )
{
- qDebug() << Q_FUNC_INFO << "Received error message from " << from << ", not answering... (Condition: "
+ tDebug() << Q_FUNC_INFO << "Received error message from " << from << ", not answering... (Condition: "
<< ( message.error().isNull() ? -1 : message.error()->condition() ) << ")";
return;
}
@@ -612,7 +622,7 @@ void XmppSipPlugin::onPresenceReceived( const Jreen::RosterItem::Ptr &item, cons
Jreen::JID jid = presence.from();
QString fulljid( jid.full() );
-// qDebug() << Q_FUNC_INFO << "* New presence:" << fulljid << presence.subtype();
+ qDebug() << Q_FUNC_INFO << "* New presence:" << fulljid << presence.subtype();
if( jid == m_client->jid() )
return;
@@ -626,7 +636,7 @@ void XmppSipPlugin::onPresenceReceived( const Jreen::RosterItem::Ptr &item, cons
Jreen::Capabilities::Ptr caps = presence.payload();
if( caps )
{
-// qDebug() << Q_FUNC_INFO << fulljid << "Running tomahawk: maybe" << "caps " << caps->node() << "requesting disco...";
+ qDebug() << Q_FUNC_INFO << fulljid << "Running tomahawk: maybe" << "caps " << caps->node() << "requesting disco...";
// request disco features
QString node = caps->node() + '#' + caps->ver();
@@ -698,6 +708,7 @@ void XmppSipPlugin::onSubscriptionReceived(const Jreen::RosterItem::Ptr& item, c
#endif
}
+
void
XmppSipPlugin::onSubscriptionRequestConfirmed( int result )
{
@@ -923,7 +934,6 @@ XmppSipPlugin::readUsername()
return credentials.contains( "username" ) ? credentials[ "username" ].toString() : QString();
}
-
QString
XmppSipPlugin::readPassword()
{
diff --git a/src/audiocontrols.cpp b/src/audiocontrols.cpp
index e14bd94c7..f536be7c6 100644
--- a/src/audiocontrols.cpp
+++ b/src/audiocontrols.cpp
@@ -26,7 +26,6 @@
#include "audio/audioengine.h"
#include "playlist/playlistview.h"
#include "database/database.h"
-#include "database/databasecommand_socialaction.h"
#include "widgets/imagebutton.h"
#include "utils/tomahawkutils.h"
#include "utils/logger.h"
@@ -37,8 +36,6 @@
using namespace Tomahawk;
-static QString s_acInfoIdentifier = QString( "AUDIOCONTROLS" );
-
AudioControls::AudioControls( QWidget* parent )
: QWidget( parent )
@@ -99,10 +96,12 @@ AudioControls::AudioControls( QWidget* parent )
ui->volumeSlider->setValue( AudioEngine::instance()->volume() );
m_phononTickCheckTimer.setSingleShot( true );
-
+
m_sliderTimeLine.setCurveShape( QTimeLine::LinearCurve );
ui->seekSlider->setTimeLine( &m_sliderTimeLine );
+ m_defaultCover = QPixmap( RESPATH "images/no-album-no-case.png" ).scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
+
connect( &m_phononTickCheckTimer, SIGNAL( timeout() ), SLOT( phononTickCheckTimeout() ) );
connect( &m_sliderTimeLine, SIGNAL( frameChanged( int ) ), ui->seekSlider, SLOT( setValue( int ) ) );
@@ -136,15 +135,6 @@ AudioControls::AudioControls( QWidget* parent )
connect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), SLOT( onPlaybackTimer( qint64 ) ) );
connect( AudioEngine::instance(), SIGNAL( volumeChanged( int ) ), SLOT( onVolumeChanged( int ) ) );
- m_defaultCover = QPixmap( RESPATH "images/no-album-no-case.png" )
- .scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
-
- connect( Tomahawk::InfoSystem::InfoSystem::instance(),
- SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
- SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
-
- connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
-
ui->buttonAreaLayout->setSpacing( 0 );
ui->stackedLayout->setSpacing( 0 );
ui->stackedLayout->setContentsMargins( 0, 0, 0, 0 );
@@ -198,8 +188,6 @@ AudioControls::onVolumeChanged( int volume )
void
AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
{
- tDebug( LOGEXTRA ) << Q_FUNC_INFO;
-
if ( result.isNull() )
return;
@@ -215,7 +203,7 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
ui->seekSlider->setValue( 0 );
m_phononTickCheckTimer.stop();
-
+
m_sliderTimeLine.stop();
m_sliderTimeLine.setDuration( duration );
m_sliderTimeLine.setFrameRange( 0, duration );
@@ -226,107 +214,90 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
m_noTimeChange = false;
m_lastSliderCheck = 0;
-
- Tomahawk::InfoSystem::InfoStringHash trackInfo;
- trackInfo["artist"] = result->artist()->name();
- trackInfo["album"] = result->album()->name();
-
- Tomahawk::InfoSystem::InfoRequestData requestData;
- requestData.caller = s_acInfoIdentifier;
- requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
- requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
- requestData.customData = QVariantMap();
-
- Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
-}
-
-
-void
-AudioControls::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
-{
- if ( requestData.caller != s_acInfoIdentifier || requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
- {
- return;
- }
-
- if ( m_currentTrack.isNull() )
- {
- tLog() << "Current track is null when trying to apply fetched cover art";
- return;
- }
-
- if ( !output.canConvert< QVariantMap >() )
- {
- tDebug( LOGINFO ) << "Cannot convert fetched art from a QByteArray";
- return;
- }
-
- QVariantMap returnedData = output.value< QVariantMap >();
- const QByteArray ba = returnedData["imgbytes"].toByteArray();
- if ( ba.length() )
- {
- QPixmap pm;
- pm.loadFromData( ba );
-
- if ( pm.isNull() )
- ui->coverImage->setPixmap( m_defaultCover );
- else
- ui->coverImage->setPixmap( pm.scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
- }
-}
-
-
-void
-AudioControls::infoSystemFinished( QString target )
-{
- Q_UNUSED( target );
}
void
AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
{
- tDebug( LOGEXTRA ) << Q_FUNC_INFO;
+ if ( !m_currentTrack.isNull() )
+ {
+ disconnect( m_currentTrack->album().data(), SIGNAL( updated() ), this, SLOT( onAlbumCoverUpdated() ) );
+ disconnect( m_currentTrack->toQuery().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( onSocialActionsLoaded() ) );
+ }
m_currentTrack = result;
+ connect( m_currentTrack->album().data(), SIGNAL( updated() ), SLOT( onAlbumCoverUpdated() ) );
+ connect( m_currentTrack->toQuery().data(), SIGNAL( socialActionsLoaded() ), SLOT( onSocialActionsLoaded() ) );
ui->artistTrackLabel->setResult( result );
ui->albumLabel->setResult( result );
ui->ownerLabel->setText( result->friendlySource() );
- ui->coverImage->setPixmap( m_defaultCover );
+ const QString duration = TomahawkUtils::timeToString( result.data()->duration() );
+ ui->timeLabel->setFixedWidth( ui->timeLabel->fontMetrics().width( QString( duration.length(), QChar( '0' ) ) ) );
ui->timeLabel->setText( TomahawkUtils::timeToString( 0 ) );
- ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( result.data()->duration() ) );
+ ui->timeLeftLabel->setFixedWidth( ui->timeLeftLabel->fontMetrics().width( QString( duration.length() + 1, QChar( '0' ) ) ) );
+ ui->timeLeftLabel->setText( "-" + duration );
ui->stackedLayout->setCurrentWidget( ui->pauseButton );
ui->loveButton->setEnabled( true );
ui->loveButton->setVisible( true );
- result->loadSocialActions();
-
- connect( result.data(), SIGNAL( socialActionsLoaded() ), SLOT( socialActionsLoaded() ) );
+ setAlbumCover();
+ setSocialActions();
}
void
-AudioControls::socialActionsLoaded()
+AudioControls::onAlbumCoverUpdated()
{
- Result* r = qobject_cast< Result* >( sender() );
- Q_ASSERT( r );
+ Album* album = qobject_cast< Album* >( sender() );
+ if ( !album || album != m_currentTrack->album().data() )
+ return;
- if ( m_currentTrack.data() == r )
+ setAlbumCover();
+}
+
+
+void
+AudioControls::setAlbumCover()
+{
+ if ( !m_currentTrack->album()->cover().isNull() )
{
- if ( m_currentTrack->loved() )
- {
- ui->loveButton->setPixmap( RESPATH "images/loved.png" );
- ui->loveButton->setChecked( true );
- }
- else
- {
- ui->loveButton->setPixmap( RESPATH "images/not-loved.png" );
- ui->loveButton->setChecked( false );
- }
+ QPixmap cover;
+ cover.loadFromData( m_currentTrack->album()->cover() );
+ ui->coverImage->setPixmap( cover.scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
+ }
+ else
+ ui->coverImage->setPixmap( m_defaultCover );
+}
+
+
+void
+AudioControls::onSocialActionsLoaded()
+{
+ Query* query = qobject_cast< Query* >( sender() );
+ if ( !query || query != m_currentTrack->toQuery().data() )
+ return;
+
+ setSocialActions();
+}
+
+
+void
+AudioControls::setSocialActions()
+{
+ if ( m_currentTrack->toQuery()->loved() )
+ {
+ ui->loveButton->setPixmap( RESPATH "images/loved.png" );
+ ui->loveButton->setChecked( true );
+ }
+ else
+ {
+ ui->loveButton->setPixmap( RESPATH "images/not-loved.png" );
+ ui->loveButton->setChecked( false );
}
}
@@ -396,12 +367,12 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
m_sliderTimeLine.stop();
return;
}
-
+
ui->seekSlider->blockSignals( true );
if ( sender() != &m_phononTickCheckTimer )
m_phononTickCheckTimer.start( 1000 );
-
+
const int seconds = msElapsed / 1000;
ui->timeLabel->setText( TomahawkUtils::timeToString( seconds ) );
ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( m_currentTrack->duration() - seconds ) );
@@ -616,30 +587,17 @@ AudioControls::droppedTracks( QList< query_ptr > tracks )
void
AudioControls::onLoveButtonClicked( bool checked )
{
- Tomahawk::InfoSystem::InfoStringHash trackInfo;
- trackInfo["title"] = m_currentTrack->track();
- trackInfo["artist"] = m_currentTrack->artist()->name();
- trackInfo["album"] = m_currentTrack->album()->name();
-
if ( checked )
{
- Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
- s_acInfoIdentifier, Tomahawk::InfoSystem::InfoLove,
- QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ) );
-
- DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction( m_currentTrack, QString( "Love" ), QString( "true") );
- Database::instance()->enqueue( QSharedPointer(cmd) );
ui->loveButton->setPixmap( RESPATH "images/loved.png" );
+
+ m_currentTrack->toQuery()->setLoved( true );
}
else
{
- Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
- s_acInfoIdentifier, Tomahawk::InfoSystem::InfoUnLove,
- QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ) );
-
- DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction( m_currentTrack, QString( "Love" ), QString( "false" ) );
- Database::instance()->enqueue( QSharedPointer(cmd) );
ui->loveButton->setPixmap( RESPATH "images/not-loved.png" );
+
+ m_currentTrack->toQuery()->setLoved( false );
}
}
diff --git a/src/audiocontrols.h b/src/audiocontrols.h
index fa047634e..7d7de87c6 100644
--- a/src/audiocontrols.h
+++ b/src/audiocontrols.h
@@ -25,7 +25,6 @@
#include "result.h"
#include "playlistinterface.h"
-#include "infosystem/infosystem.h"
#include "query.h"
class QDropEvent;
@@ -80,14 +79,16 @@ private slots:
void onTrackClicked();
void onLoveButtonClicked( bool );
- void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
- void infoSystemFinished( QString target );
+ void onAlbumCoverUpdated();
void droppedTracks( QList );
- void socialActionsLoaded();
+ void onSocialActionsLoaded();
private:
+ void setAlbumCover();
+ void setSocialActions();
+
Ui::AudioControls *ui;
QPixmap m_defaultCover;
diff --git a/src/audiocontrols.ui b/src/audiocontrols.ui
index 8a96e76de..584cca7d2 100644
--- a/src/audiocontrols.ui
+++ b/src/audiocontrols.ui
@@ -345,6 +345,9 @@
Time
+
+ Qt::AlignLeft|Qt::AlignVCenter
+
-
@@ -371,6 +374,9 @@
Time Left
+
+ Qt::AlignRight|Qt::AlignVCenter
+
diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt
index 6444822d6..b8f88affb 100644
--- a/src/libtomahawk/CMakeLists.txt
+++ b/src/libtomahawk/CMakeLists.txt
@@ -150,7 +150,6 @@ set( libGuiHeaders
contextmenu.h
dropjob.h
- viewpage.h
viewmanager.h
globalactionmanager.h
LatchManager.h
@@ -235,7 +234,6 @@ set( libGuiHeaders
utils/rdioparser.h
utils/shortenedlinkparser.h
utils/dropjobnotifier.h
- utils/tomahawkutilsgui.h
widgets/checkdirtree.h
widgets/querylabel.h
@@ -402,6 +400,14 @@ set( libSources
playlist/dynamic/database/DatabaseControl.cpp
playlist/dynamic/DynamicControl.cpp
+ taghandlers/tag.cpp
+ taghandlers/apetag.cpp
+ taghandlers/asftag.cpp
+ taghandlers/id3v1tag.cpp
+ taghandlers/id3v2tag.cpp
+ taghandlers/mp4tag.cpp
+ taghandlers/oggtag.cpp
+
utils/tomahawkutils.cpp
utils/logger.cpp
utils/qnr_iodevicestream.cpp
@@ -436,6 +442,7 @@ set( libHeaders
albumplaylistinterface.h
playlist.h
playlistplaylistinterface.h
+ viewpage.h
accounts/Account.h
accounts/AccountManager.h
@@ -536,6 +543,7 @@ set( libHeaders
thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.h
+ utils/tomahawkutilsgui.h
utils/xspfloader.h
utils/qnr_iodevicestream.h
)
@@ -547,6 +555,14 @@ set( libHeaders_NoMOC
infosystem/infoplugins/unix/imageconverter.h
+ taghandlers/tag.h
+ taghandlers/apetag.h
+ taghandlers/asftag.h
+ taghandlers/id3v1tag.h
+ taghandlers/id3v2tag.h
+ taghandlers/mp4tag.h
+ taghandlers/oggtag.h
+
utils/tomahawkutils.h
)
diff --git a/src/libtomahawk/LatchManager.cpp b/src/libtomahawk/LatchManager.cpp
index 5e5f3649c..abee22856 100644
--- a/src/libtomahawk/LatchManager.cpp
+++ b/src/libtomahawk/LatchManager.cpp
@@ -22,8 +22,7 @@
#include "audio/audioengine.h"
#include "database/database.h"
-#include
-#include
+#include
#include "sourcelist.h"
#include "database/databasecommand_socialaction.h"
#include "sourceplaylistinterface.h"
@@ -58,7 +57,7 @@ LatchManager::latchRequest( const source_ptr& source )
m_state = Latching;
m_waitingForLatch = source;
- AudioEngine::instance()->playItem( source->getPlaylistInterface(), source->getPlaylistInterface()->nextItem() );
+ AudioEngine::instance()->playItem( source->playlistInterface(), source->playlistInterface()->nextItem() );
}
void
@@ -71,7 +70,7 @@ LatchManager::playlistChanged( Tomahawk::playlistinterface_ptr )
return; // Neither latched on nor waiting to be latched on, no-op
m_latchedOnTo = m_waitingForLatch;
- m_latchedInterface = m_waitingForLatch->getPlaylistInterface();
+ m_latchedInterface = m_waitingForLatch->playlistInterface();
m_waitingForLatch.clear();
m_state = Latched;
@@ -82,7 +81,9 @@ LatchManager::playlistChanged( Tomahawk::playlistinterface_ptr )
cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() );
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
- ActionCollection::instance()->getAction( "latchOn" )->setText( tr( "&Catch Up" ) );
+ QAction *latchOnAction = ActionCollection::instance()->getAction( "latchOn" );
+ latchOnAction->setText( tr( "&Catch Up" ) );
+ latchOnAction->setIcon( QIcon() );
// If not, then keep waiting
return;
@@ -117,7 +118,9 @@ LatchManager::playlistChanged( Tomahawk::playlistinterface_ptr )
m_state = NotLatched;
- ActionCollection::instance()->getAction( "latchOn" )->setText( tr( "&Listen Along" ) );
+ QAction *latchOnAction = ActionCollection::instance()->getAction( "latchOn" );
+ latchOnAction->setText( tr( "&Listen Along" ) );
+ latchOnAction->setIcon( QIcon( RESPATH "images/headphones-sidebar.png" ) );
}
@@ -128,6 +131,7 @@ LatchManager::catchUpRequest()
AudioEngine::instance()->next();
}
+
void
LatchManager::unlatchRequest( const source_ptr& source )
{
@@ -135,5 +139,19 @@ LatchManager::unlatchRequest( const source_ptr& source )
AudioEngine::instance()->stop();
AudioEngine::instance()->setPlaylist( Tomahawk::playlistinterface_ptr() );
- ActionCollection::instance()->getAction( "latchOn" )->setText( tr( "&Listen Along" ) );
+ QAction *latchOnAction = ActionCollection::instance()->getAction( "latchOn" );
+ latchOnAction->setText( tr( "&Listen Along" ) );
+ latchOnAction->setIcon( QIcon( RESPATH "images/headphones-sidebar.png" ) );
+}
+
+
+void
+LatchManager::latchModeChangeRequest( const Tomahawk::source_ptr& source, bool realtime )
+{
+ if ( !isLatched( source ) )
+ return;
+
+ source->playlistInterface()->setLatchMode( realtime ? Tomahawk::PlaylistInterface::RealTime : Tomahawk::PlaylistInterface::StayOnSong );
+ if ( realtime )
+ catchUpRequest();
}
diff --git a/src/libtomahawk/LatchManager.h b/src/libtomahawk/LatchManager.h
index 26d8b8f8f..07c27ba30 100644
--- a/src/libtomahawk/LatchManager.h
+++ b/src/libtomahawk/LatchManager.h
@@ -43,6 +43,7 @@ public slots:
void latchRequest( const Tomahawk::source_ptr& source );
void unlatchRequest( const Tomahawk::source_ptr& source );
void catchUpRequest();
+ void latchModeChangeRequest( const Tomahawk::source_ptr& source, bool realtime );
private slots:
void playlistChanged( Tomahawk::playlistinterface_ptr );
diff --git a/src/libtomahawk/actioncollection.cpp b/src/libtomahawk/actioncollection.cpp
index 802794df1..3088e25b8 100644
--- a/src/libtomahawk/actioncollection.cpp
+++ b/src/libtomahawk/actioncollection.cpp
@@ -46,6 +46,10 @@ ActionCollection::initActions()
latchOff->setIcon( QIcon( RESPATH "images/headphones-off.png" ) );
m_actionCollection[ "latchOff" ] = latchOff;
+ QAction *realtimeFollowingAlong = new QAction( tr( "&Follow in real-time" ), this );
+ realtimeFollowingAlong->setCheckable( true );
+ m_actionCollection[ "realtimeFollowingAlong" ] = realtimeFollowingAlong;
+
bool isPublic = TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::PublicListening;
QAction *privacyToggle = new QAction( ( isPublic ? tr( "&Listen Privately" ) : tr( "&Listen Publicly" ) ), this );
privacyToggle->setIcon( QIcon( RESPATH "images/private-listening.png" ) );
diff --git a/src/libtomahawk/actioncollection.h b/src/libtomahawk/actioncollection.h
index 09ede7839..1183935dc 100644
--- a/src/libtomahawk/actioncollection.h
+++ b/src/libtomahawk/actioncollection.h
@@ -21,7 +21,7 @@
#include "dllmacro.h"
-#include
+#include
class DLLEXPORT ActionCollection : public QObject
{
diff --git a/src/libtomahawk/album.cpp b/src/libtomahawk/album.cpp
index 7515b01bb..fd56e8409 100644
--- a/src/libtomahawk/album.cpp
+++ b/src/libtomahawk/album.cpp
@@ -29,8 +29,11 @@
using namespace Tomahawk;
-Album::Album() {}
-Album::~Album() {}
+
+Album::~Album()
+{
+}
+
album_ptr
Album::get( const Tomahawk::artist_ptr& artist, const QString& name, bool autoCreate )
@@ -68,19 +71,21 @@ Album::Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr&
, m_id( id )
, m_name( name )
, m_artist( artist )
+ , m_infoLoaded( false )
{
+ connect( Tomahawk::InfoSystem::InfoSystem::instance(),
+ SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
+ SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
}
void
Album::onTracksAdded( const QList& tracks )
{
- qDebug() << Q_FUNC_INFO;
-
- Tomahawk::AlbumPlaylistInterface* api = dynamic_cast< Tomahawk::AlbumPlaylistInterface* >( getPlaylistInterface().data() );
+ Tomahawk::AlbumPlaylistInterface* api = dynamic_cast< Tomahawk::AlbumPlaylistInterface* >( playlistInterface().data() );
if ( api )
api->addQueries( tracks );
-
+
emit tracksAdded( tracks );
}
@@ -92,13 +97,61 @@ Album::artist() const
}
+QByteArray
+Album::cover() const
+{
+ if ( !m_infoLoaded )
+ {
+ m_uuid = uuid();
+
+ Tomahawk::InfoSystem::InfoStringHash trackInfo;
+ trackInfo["artist"] = artist()->name();
+ trackInfo["album"] = name();
+
+ Tomahawk::InfoSystem::InfoRequestData requestData;
+ requestData.caller = m_uuid;
+ requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
+ requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
+ requestData.customData = QVariantMap();
+
+ Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
+ }
+
+ return m_cover;
+}
+
+
+void
+Album::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
+{
+ if ( requestData.caller != m_uuid ||
+ requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
+ {
+ return;
+ }
+
+ m_infoLoaded = true;
+ if ( !output.isNull() && output.isValid() )
+ {
+ QVariantMap returnedData = output.value< QVariantMap >();
+ const QByteArray ba = returnedData["imgbytes"].toByteArray();
+ if ( ba.length() )
+ {
+ m_cover = ba;
+ }
+ }
+
+ emit updated();
+}
+
+
Tomahawk::playlistinterface_ptr
-Album::getPlaylistInterface()
+Album::playlistInterface()
{
if ( m_playlistInterface.isNull() )
{
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::AlbumPlaylistInterface( this ) );
}
-
+
return m_playlistInterface;
-}
\ No newline at end of file
+}
diff --git a/src/libtomahawk/album.h b/src/libtomahawk/album.h
index 3ad460afd..b929e9b49 100644
--- a/src/libtomahawk/album.h
+++ b/src/libtomahawk/album.h
@@ -25,6 +25,7 @@
#include "typedefs.h"
#include "playlistinterface.h"
#include "dllmacro.h"
+#include "infosystem/infosystem.h"
namespace Tomahawk
{
@@ -43,23 +44,29 @@ public:
unsigned int id() const { return m_id; }
QString name() const { return m_name; }
artist_ptr artist() const;
+ QByteArray cover() const;
+ bool infoLoaded() const { return m_infoLoaded; }
- Tomahawk::playlistinterface_ptr getPlaylistInterface();
+ Tomahawk::playlistinterface_ptr playlistInterface();
signals:
void tracksAdded( const QList& tracks );
+ void updated();
private slots:
void onTracksAdded( const QList& tracks );
+ void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
+
private:
Q_DISABLE_COPY( Album )
- explicit Album();
unsigned int m_id;
QString m_name;
-
artist_ptr m_artist;
+ QByteArray m_cover;
+ bool m_infoLoaded;
+ mutable QString m_uuid;
Tomahawk::playlistinterface_ptr m_playlistInterface;
};
diff --git a/src/libtomahawk/albumplaylistinterface.cpp b/src/libtomahawk/albumplaylistinterface.cpp
index 791aecafd..912273f09 100644
--- a/src/libtomahawk/albumplaylistinterface.cpp
+++ b/src/libtomahawk/albumplaylistinterface.cpp
@@ -88,11 +88,12 @@ AlbumPlaylistInterface::tracks()
if ( m_queries.isEmpty() && m_album )
{
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks();
- cmd->setAlbum( m_album.data() );
+ cmd->setAlbum( m_album );
cmd->setSortOrder( DatabaseCommand_AllTracks::AlbumPosition );
+ //this takes discnumber into account as well
- connect( cmd, SIGNAL( tracks( QList, QVariant ) ),
- SLOT( onTracksAdded( QList ) ) );
+ connect( cmd, SIGNAL( tracks( QList, QVariant ) ),
+ m_album.data(), SLOT( onTracksAdded( QList ) ) );
Database::instance()->enqueue( QSharedPointer( cmd ) );
}
diff --git a/src/libtomahawk/albumplaylistinterface.h b/src/libtomahawk/albumplaylistinterface.h
index 486a0871a..3cc11a387 100644
--- a/src/libtomahawk/albumplaylistinterface.h
+++ b/src/libtomahawk/albumplaylistinterface.h
@@ -59,7 +59,7 @@ public:
virtual void addQueries( const QList& tracks );
signals:
- void repeatModeChanged( PlaylistInterface::RepeatMode mode );
+ void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
void shuffleModeChanged( bool enabled );
void trackCountChanged( unsigned int tracks );
diff --git a/src/libtomahawk/artist.cpp b/src/libtomahawk/artist.cpp
index eafd6b7e7..0c0ba332c 100644
--- a/src/libtomahawk/artist.cpp
+++ b/src/libtomahawk/artist.cpp
@@ -29,11 +29,6 @@
using namespace Tomahawk;
-Artist::Artist()
-{
-}
-
-
Artist::~Artist()
{
}
@@ -74,24 +69,75 @@ Artist::Artist( unsigned int id, const QString& name )
: QObject()
, m_id( id )
, m_name( name )
+ , m_infoLoaded( false )
{
m_sortname = DatabaseImpl::sortname( name, true );
+
+ connect( Tomahawk::InfoSystem::InfoSystem::instance(),
+ SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
+ SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
}
void
Artist::onTracksAdded( const QList& tracks )
{
- qDebug() << Q_FUNC_INFO;
-
- Tomahawk::ArtistPlaylistInterface* api = dynamic_cast< Tomahawk::ArtistPlaylistInterface* >( getPlaylistInterface().data() );
+ Tomahawk::ArtistPlaylistInterface* api = dynamic_cast< Tomahawk::ArtistPlaylistInterface* >( playlistInterface().data() );
if ( api )
api->addQueries( tracks );
emit tracksAdded( tracks );
}
+
+QByteArray
+Artist::cover() const
+{
+ if ( !m_infoLoaded )
+ {
+ m_uuid = uuid();
+
+ Tomahawk::InfoSystem::InfoStringHash trackInfo;
+ trackInfo["artist"] = name();
+
+ Tomahawk::InfoSystem::InfoRequestData requestData;
+ requestData.caller = m_uuid;
+ requestData.type = Tomahawk::InfoSystem::InfoArtistImages;
+ requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
+ requestData.customData = QVariantMap();
+
+ Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
+ }
+
+ return m_cover;
+}
+
+
+void
+Artist::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
+{
+ if ( requestData.caller != m_uuid ||
+ requestData.type != Tomahawk::InfoSystem::InfoArtistImages )
+ {
+ return;
+ }
+
+ m_infoLoaded = true;
+ if ( !output.isNull() && output.isValid() )
+ {
+ QVariantMap returnedData = output.value< QVariantMap >();
+ const QByteArray ba = returnedData["imgbytes"].toByteArray();
+ if ( ba.length() )
+ {
+ m_cover = ba;
+ }
+ }
+
+ emit updated();
+}
+
+
Tomahawk::playlistinterface_ptr
-Artist::getPlaylistInterface()
+Artist::playlistInterface()
{
if ( m_playlistInterface.isNull() )
{
diff --git a/src/libtomahawk/artist.h b/src/libtomahawk/artist.h
index be7db3704..3e1442023 100644
--- a/src/libtomahawk/artist.h
+++ b/src/libtomahawk/artist.h
@@ -24,6 +24,7 @@
#include "typedefs.h"
#include "dllmacro.h"
+#include "infosystem/infosystem.h"
namespace Tomahawk
{
@@ -35,29 +36,36 @@ Q_OBJECT
public:
static artist_ptr get( const QString& name, bool autoCreate = false );
static artist_ptr get( unsigned int id, const QString& name );
- explicit Artist( unsigned int id, const QString& name );
- explicit Artist();
+ explicit Artist( unsigned int id, const QString& name );
virtual ~Artist();
unsigned int id() const { return m_id; }
QString name() const { return m_name; }
QString sortname() const { return m_sortname; }
+ QByteArray cover() const;
+ bool infoLoaded() const { return m_infoLoaded; }
- Tomahawk::playlistinterface_ptr getPlaylistInterface();
+ Tomahawk::playlistinterface_ptr playlistInterface();
signals:
void tracksAdded( const QList& tracks );
+ void updated();
private slots:
void onTracksAdded( const QList& tracks );
+ void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
+
private:
Q_DISABLE_COPY( Artist )
unsigned int m_id;
QString m_name;
QString m_sortname;
+ QByteArray m_cover;
+ bool m_infoLoaded;
+ mutable QString m_uuid;
Tomahawk::playlistinterface_ptr m_playlistInterface;
};
diff --git a/src/libtomahawk/artistplaylistinterface.cpp b/src/libtomahawk/artistplaylistinterface.cpp
index 6f22397ad..4ab49bc79 100644
--- a/src/libtomahawk/artistplaylistinterface.cpp
+++ b/src/libtomahawk/artistplaylistinterface.cpp
@@ -86,7 +86,7 @@ ArtistPlaylistInterface::tracks()
if ( m_queries.isEmpty() && m_artist )
{
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks();
- cmd->setArtist( m_artist.data() );
+ cmd->setArtist( m_artist );
cmd->setSortOrder( DatabaseCommand_AllTracks::Album );
connect( cmd, SIGNAL( tracks( QList, QVariant ) ),
diff --git a/src/libtomahawk/artistplaylistinterface.h b/src/libtomahawk/artistplaylistinterface.h
index 65f81f7ff..4f178f69c 100644
--- a/src/libtomahawk/artistplaylistinterface.h
+++ b/src/libtomahawk/artistplaylistinterface.h
@@ -58,15 +58,6 @@ public:
virtual void addQueries( const QList& tracks );
-signals:
- void repeatModeChanged( PlaylistInterface::RepeatMode mode );
- void shuffleModeChanged( bool enabled );
-
- void trackCountChanged( unsigned int tracks );
- void sourceTrackCountChanged( unsigned int tracks );
-
- void nextTrackReady();
-
private:
Q_DISABLE_COPY( ArtistPlaylistInterface )
diff --git a/src/libtomahawk/audio/audioengine.cpp b/src/libtomahawk/audio/audioengine.cpp
index 9be1cf518..226d99a3f 100644
--- a/src/libtomahawk/audio/audioengine.cpp
+++ b/src/libtomahawk/audio/audioengine.cpp
@@ -18,8 +18,8 @@
#include "audioengine.h"
-#include
-#include
+#include
+#include
#include "playlistinterface.h"
#include "sourceplaylistinterface.h"
@@ -29,7 +29,7 @@
#include "network/servent.h"
#include "utils/qnr_iodevicestream.h"
#include "headlesscheck.h"
-
+#include "infosystem/infosystem.h"
#include "album.h"
#include "utils/logger.h"
@@ -55,7 +55,6 @@ AudioEngine::AudioEngine()
, m_timeElapsed( 0 )
, m_expectStop( false )
, m_waitingOnNewTrack( false )
- , m_infoSystemConnected( false )
, m_state( Stopped )
{
s_instance = this;
@@ -73,8 +72,10 @@ AudioEngine::AudioEngine()
connect( m_mediaObject, SIGNAL( tick( qint64 ) ), SLOT( timerTriggered( qint64 ) ) );
connect( m_mediaObject, SIGNAL( aboutToFinish() ), SLOT( onAboutToFinish() ) );
- connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ), this, SLOT( onVolumeChanged( qreal ) ) );
+ connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ), SLOT( onVolumeChanged( qreal ) ) );
+ connect( this, SIGNAL( sendWaitingNotification() ), SLOT( sendWaitingNotificationSlot() ), Qt::QueuedConnection );
+
onVolumeChanged( m_audioOutput->volume() );
#ifndef Q_WS_X11
@@ -179,9 +180,7 @@ AudioEngine::stop()
map[ Tomahawk::InfoSystem::InfoNowStopped ] = QVariant();
if ( m_waitingOnNewTrack )
- {
- sendWaitingNotification();
- }
+ emit sendWaitingNotification();
else if ( TomahawkSettings::instance()->verboseNotifications() )
{
QVariantMap stopInfo;
@@ -228,12 +227,12 @@ AudioEngine::canGoNext()
m_playlist.data()->skipRestrictions() == PlaylistInterface::NoSkipForwards )
return false;
- if ( !m_currentTrack.isNull() && !m_playlist.data()->hasNextItem() &&
- ( m_playlist.data()->currentItem().isNull() || ( m_currentTrack->id() == m_playlist.data()->currentItem()->id() ) ) )
+ if ( !m_currentTrack.isNull() && !m_playlist->hasNextItem() &&
+ ( m_playlist->currentItem().isNull() || ( m_currentTrack->id() == m_playlist->currentItem()->id() ) ) )
{
//For instance, when doing a catch-up while listening along, but the person
//you're following hasn't started a new track yet...don't do anything
- tDebug( LOGEXTRA ) << Q_FUNC_INFO << "catch up";
+ tDebug( LOGEXTRA ) << Q_FUNC_INFO << "catch up, but same track or can't move on because don't have next track or it wasn't resolved";
return false;
}
@@ -311,8 +310,13 @@ AudioEngine::mute()
void
-AudioEngine::sendWaitingNotification() const
+AudioEngine::sendWaitingNotificationSlot() const
{
+ tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
+ //since it's async, after this is triggered our result could come in, so don't show the popup in that case
+ if ( !m_playlist.isNull() && m_playlist->hasNextItem() )
+ return;
+
QVariantMap retryInfo;
retryInfo["message"] = QString( "The current track could not be resolved. Tomahawk will pick back up with the next resolvable track from this source." );
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
@@ -324,62 +328,38 @@ AudioEngine::sendWaitingNotification() const
void
AudioEngine::sendNowPlayingNotification()
{
- tDebug( LOGEXTRA ) << Q_FUNC_INFO;
-
- if ( ! m_infoSystemConnected )
+ if ( m_currentTrack->album().isNull() || m_currentTrack->album()->infoLoaded() )
+ onNowPlayingInfoReady();
+ else
{
- connect( Tomahawk::InfoSystem::InfoSystem::instance(),
- SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
- SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
-
- connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
-
- m_infoSystemConnected = true;
+ connect( m_currentTrack->album().data(), SIGNAL( updated() ), SLOT( onNowPlayingInfoReady() ), Qt::UniqueConnection );
+ m_currentTrack->album()->cover();
}
-
- Tomahawk::InfoSystem::InfoStringHash trackInfo;
- trackInfo["artist"] = m_currentTrack->album()->artist()->name();
- trackInfo["album"] = m_currentTrack->album()->name();
-
- Tomahawk::InfoSystem::InfoRequestData requestData;
- requestData.caller = s_aeInfoIdentifier;
- requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
- requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
- requestData.customData = QVariantMap();
-
- Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
}
void
-AudioEngine::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
+AudioEngine::onNowPlayingInfoReady()
{
- if ( requestData.caller != s_aeInfoIdentifier ||
- requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
- {
- return;
- }
-
if ( m_currentTrack.isNull() ||
m_currentTrack->track().isNull() ||
m_currentTrack->artist().isNull() )
return;
+ if ( !m_currentTrack->album().isNull() && sender() && m_currentTrack->album().data() != sender() )
+ return;
+
QVariantMap playInfo;
playInfo["message"] = tr( "Tomahawk is playing \"%1\" by %2%3." )
.arg( m_currentTrack->track() )
.arg( m_currentTrack->artist()->name() )
- .arg( m_currentTrack->album().isNull() ? QString() : tr( " on album %1" ).arg( m_currentTrack->album()->name() ) );
- if ( !output.isNull() && output.isValid() )
+ .arg( m_currentTrack->album().isNull() ? QString() : QString( " %1" ).arg( tr( "on album %1" ).arg( m_currentTrack->album()->name() ) ) );
+
+ if ( !m_currentTrack->album().isNull() )
{
- QVariantMap returnedData = output.value< QVariantMap >();
- const QByteArray ba = returnedData["imgbytes"].toByteArray();
- if ( ba.length() )
- {
- QPixmap pm;
- pm.loadFromData( ba );
- playInfo["image"] = QVariant( pm.toImage() );
- }
+ QImage cover;
+ cover.loadFromData( m_currentTrack->album()->cover() );
+ playInfo["image"] = QVariant( cover );
}
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
@@ -388,13 +368,6 @@ AudioEngine::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData,
}
-void
-AudioEngine::infoSystemFinished( QString caller )
-{
- Q_UNUSED( caller );
-}
-
-
bool
AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
{
@@ -570,7 +543,7 @@ AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk:
{
m_waitingOnNewTrack = true;
if ( isStopped() )
- sendWaitingNotification();
+ emit sendWaitingNotification();
else
stop();
}
@@ -578,8 +551,16 @@ AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk:
void
-AudioEngine::playlistNextTrackReady()
+AudioEngine::onPlaylistNextTrackReady()
{
+ // If in real-time and you have a few seconds left, you're probably lagging -- finish it up
+ if ( m_playlist && m_playlist->latchMode() == PlaylistInterface::RealTime && ( m_waitingOnNewTrack || m_currentTrack.isNull() || m_currentTrack->id() == 0 || ( currentTrackTotalTime() - currentTime() > 6000 ) ) )
+ {
+ m_waitingOnNewTrack = false;
+ loadNextTrack();
+ return;
+ }
+
if ( !m_waitingOnNewTrack )
return;
@@ -697,7 +678,7 @@ AudioEngine::setPlaylist( Tomahawk::playlistinterface_ptr playlist )
m_playlist = playlist;
if ( !m_playlist.isNull() && m_playlist.data() && m_playlist.data()->retryMode() == PlaylistInterface::Retry )
- connect( m_playlist.data(), SIGNAL( nextTrackReady() ), SLOT( playlistNextTrackReady() ) );
+ connect( m_playlist.data(), SIGNAL( nextTrackReady() ), SLOT( onPlaylistNextTrackReady() ) );
emit playlistChanged( playlist );
}
diff --git a/src/libtomahawk/audio/audioengine.h b/src/libtomahawk/audio/audioengine.h
index 4b19a8c02..839f6f11d 100644
--- a/src/libtomahawk/audio/audioengine.h
+++ b/src/libtomahawk/audio/audioengine.h
@@ -26,8 +26,6 @@
#include
#include
-#include "infosystem/infosystem.h"
-
#include "result.h"
#include "typedefs.h"
#include "playlistinterface.h"
@@ -87,18 +85,12 @@ public slots:
void setVolume( int percentage );
void lowerVolume() { setVolume( volume() - AUDIO_VOLUME_STEP ); }
void raiseVolume() { setVolume( volume() + AUDIO_VOLUME_STEP ); }
- void onVolumeChanged( qreal volume ) { emit volumeChanged( volume * 100 ); }
void mute();
void playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::result_ptr& result );
void setPlaylist( Tomahawk::playlistinterface_ptr playlist );
void setQueue( Tomahawk::playlistinterface_ptr queue ) { m_queue = queue; }
- void playlistNextTrackReady();
-
- void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
- void infoSystemFinished( QString caller );
-
signals:
void loading( const Tomahawk::result_ptr& track );
void started( const Tomahawk::result_ptr& track );
@@ -120,6 +112,8 @@ signals:
void error( AudioEngine::AudioErrorCode errorCode );
+ void sendWaitingNotification();
+
private slots:
bool loadTrack( const Tomahawk::result_ptr& result );
void loadPreviousTrack();
@@ -127,9 +121,14 @@ private slots:
void onAboutToFinish();
void onStateChanged( Phonon::State newState, Phonon::State oldState );
+ void onVolumeChanged( qreal volume ) { emit volumeChanged( volume * 100 ); }
void timerTriggered( qint64 time );
void setCurrentTrack( const Tomahawk::result_ptr& result );
+ void onNowPlayingInfoReady();
+ void onPlaylistNextTrackReady();
+
+ void sendWaitingNotificationSlot() const;
private:
void setState( AudioState state );
@@ -137,7 +136,6 @@ private:
bool isHttpResult( const QString& ) const;
bool isLocalResult( const QString& ) const;
- void sendWaitingNotification() const;
void sendNowPlayingNotification();
QSharedPointer m_input;
@@ -154,7 +152,6 @@ private:
unsigned int m_timeElapsed;
bool m_expectStop;
bool m_waitingOnNewTrack;
- bool m_infoSystemConnected;
mutable QStringList m_supportedMimeTypes;
AudioState m_state;
diff --git a/src/libtomahawk/contextmenu.cpp b/src/libtomahawk/contextmenu.cpp
index b13540db0..558b9cb29 100644
--- a/src/libtomahawk/contextmenu.cpp
+++ b/src/libtomahawk/contextmenu.cpp
@@ -32,11 +32,12 @@ using namespace Tomahawk;
ContextMenu::ContextMenu( QWidget* parent )
: QMenu( parent )
+ , m_loveAction( 0 )
{
m_sigmap = new QSignalMapper( this );
connect( m_sigmap, SIGNAL( mapped( int ) ), SLOT( onTriggered( int ) ) );
- m_supportedActions = ActionPlay | ActionQueue | ActionCopyLink;
+ m_supportedActions = ActionPlay | ActionQueue | ActionCopyLink | ActionLove;
}
@@ -59,7 +60,7 @@ ContextMenu::clear()
unsigned int
ContextMenu::itemCount() const
{
- return m_queries.count() + m_artists.count() + m_albums.count();
+ return m_queries.count() + m_artists.count() + m_albums.count();
}
@@ -81,8 +82,17 @@ ContextMenu::setQueries( const QList& queries )
addSeparator();
+ if ( m_supportedActions & ActionLove && itemCount() == 1 )
+ {
+ m_loveAction = addAction( tr( "&Love" ) );
+ m_sigmap->setMapping( m_loveAction, ActionLove );
+
+ connect( queries.first().data(), SIGNAL( socialActionsLoaded() ), SLOT( onSocialActionsLoaded() ) );
+ onSocialActionsLoaded();
+ }
+
if ( m_supportedActions & ActionCopyLink && itemCount() == 1 )
- m_sigmap->setMapping( addAction( tr( "Copy Track &Link" ) ), ActionCopyLink );
+ m_sigmap->setMapping( addAction( tr( "&Copy Track Link" ) ), ActionCopyLink );
addSeparator();
@@ -117,7 +127,7 @@ ContextMenu::setAlbums( const QList& albums )
m_albums << albums;
if ( m_supportedActions & ActionPlay && itemCount() == 1 )
- m_sigmap->setMapping( addAction( tr( "&Play" ) ), ActionPlay );
+ m_sigmap->setMapping( addAction( tr( "Show &Album page" ) ), ActionPlay );
if ( m_supportedActions & ActionQueue )
m_sigmap->setMapping( addAction( tr( "Add to &Queue" ) ), ActionQueue );
@@ -156,7 +166,7 @@ ContextMenu::setArtists( const QList& artists )
m_artists << artists;
if ( m_supportedActions & ActionPlay && itemCount() == 1 )
- m_sigmap->setMapping( addAction( tr( "&Play" ) ), ActionPlay );
+ m_sigmap->setMapping( addAction( tr( "Show &Artist page" ) ), ActionPlay );
if ( m_supportedActions & ActionQueue )
m_sigmap->setMapping( addAction( tr( "Add to &Queue" ) ), ActionQueue );
@@ -197,6 +207,10 @@ ContextMenu::onTriggered( int action )
copyLink();
break;
+ case ActionLove:
+ m_queries.first()->setLoved( !m_queries.first()->loved() );
+ break;
+
default:
emit triggered( action );
}
@@ -232,3 +246,19 @@ ContextMenu::copyLink()
GlobalActionManager::instance()->copyToClipboard( m_queries.first() );
}
}
+
+
+void
+ContextMenu::onSocialActionsLoaded()
+{
+ if ( m_queries.first()->loved() )
+ {
+ m_loveAction->setText( tr( "Un-&Love" ) );
+ m_loveAction->setIcon( QIcon( RESPATH "images/not-loved.png" ) );
+ }
+ else
+ {
+ m_loveAction->setText( tr( "&Love" ) );
+ m_loveAction->setIcon( QIcon( RESPATH "images/loved.png" ) );
+ }
+}
diff --git a/src/libtomahawk/contextmenu.h b/src/libtomahawk/contextmenu.h
index af272262a..7330ef1f8 100644
--- a/src/libtomahawk/contextmenu.h
+++ b/src/libtomahawk/contextmenu.h
@@ -38,7 +38,8 @@ public:
ActionPlay = 1,
ActionQueue = 2,
ActionDelete = 4,
- ActionCopyLink = 8
+ ActionCopyLink = 8,
+ ActionLove = 16
};
explicit ContextMenu( QWidget* parent = 0 );
@@ -68,10 +69,14 @@ private slots:
void copyLink();
void addToQueue();
+ void onSocialActionsLoaded();
+
private:
QSignalMapper* m_sigmap;
int m_supportedActions;
+ QAction* m_loveAction;
+
QList m_queries;
QList m_artists;
QList m_albums;
diff --git a/src/libtomahawk/database/databasecommand_addfiles.cpp b/src/libtomahawk/database/databasecommand_addfiles.cpp
index 845e1384a..c764e6c48 100644
--- a/src/libtomahawk/database/databasecommand_addfiles.cpp
+++ b/src/libtomahawk/database/databasecommand_addfiles.cpp
@@ -80,7 +80,7 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi )
TomahawkSqlQuery query_trackattr = dbi->newquery();
query_file.prepare( "INSERT INTO file(source, url, size, mtime, md5, mimetype, duration, bitrate) VALUES (?, ?, ?, ?, ?, ?, ?, ?)" );
- query_filejoin.prepare( "INSERT INTO file_join(file, artist, album, track, albumpos) VALUES (?, ?, ?, ?, ?)" );
+ query_filejoin.prepare( "INSERT INTO file_join(file, artist, album, track, albumpos, composer, discnumber) VALUES (?, ?, ?, ?, ?, ?, ?)" );
query_trackattr.prepare( "INSERT INTO track_attributes(id, k, v) VALUES (?, ?, ?)" );
int added = 0;
@@ -92,7 +92,8 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi )
{
QVariant& v = *it;
QVariantMap m = v.toMap();
- int fileid = 0, artistid = 0, albumid = 0, trackid = 0;
+
+ int fileid = 0, artistid = 0, albumid = 0, trackid = 0, composerid = 0;
QString url = m.value( "url" ).toString();
int mtime = m.value( "mtime" ).toInt();
@@ -105,6 +106,8 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi )
QString album = m.value( "album" ).toString();
QString track = m.value( "track" ).toString();
uint albumpos = m.value( "albumpos" ).toUInt();
+ QString composer = m.value( "composer" ).toString();
+ uint discnumber = m.value( "discnumber" ).toUInt();
int year = m.value( "year" ).toInt();
query_file.bindValue( 0, srcid );
@@ -134,13 +137,22 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi )
continue;
albumid = dbi->albumId( artistid, album, true );
+ if( !composer.trimmed().isEmpty() )
+ composerid = dbi->artistId( composer, true );
+
// Now add the association
query_filejoin.bindValue( 0, fileid );
query_filejoin.bindValue( 1, artistid );
query_filejoin.bindValue( 2, albumid > 0 ? albumid : QVariant( QVariant::Int ) );
query_filejoin.bindValue( 3, trackid );
query_filejoin.bindValue( 4, albumpos );
- query_filejoin.exec();
+ query_filejoin.bindValue( 5, composerid > 0 ? composerid : QVariant( QVariant::Int ) );
+ query_filejoin.bindValue( 6, discnumber );
+ if ( !query_filejoin.exec() )
+ {
+ qDebug() << "Error inserting into file_join table";
+ continue;
+ }
query_trackattr.bindValue( 0, trackid );
query_trackattr.bindValue( 1, "releaseyear" );
diff --git a/src/libtomahawk/database/databasecommand_alltracks.cpp b/src/libtomahawk/database/databasecommand_alltracks.cpp
index 8f528bd81..359f30d38 100644
--- a/src/libtomahawk/database/databasecommand_alltracks.cpp
+++ b/src/libtomahawk/database/databasecommand_alltracks.cpp
@@ -40,7 +40,7 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
break;
case Album:
- m_orderToken = "album.name, file_join.albumpos";
+ m_orderToken = "album.name, file_join.discnumber, file_join.albumpos";
break;
case ModificationTime:
@@ -48,7 +48,7 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
break;
case AlbumPosition:
- m_orderToken = "file_join.albumpos";
+ m_orderToken = "file_join.discnumber, file_join.albumpos";
break;
}
@@ -60,7 +60,7 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
{
if ( m_album->id() == 0 )
{
- m_artist = m_album->artist().data();
+ m_artist = m_album->artist();
albumToken = QString( "AND album.id IS NULL" );
}
else
@@ -68,11 +68,15 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
}
QString sql = QString(
- "SELECT file.id, artist.name, album.name, track.name, file.size, "
- "file.duration, file.bitrate, file.url, file.source, file.mtime, file.mimetype, file_join.albumpos, artist.id, album.id, track.id "
+ "SELECT file.id, artist.name, album.name, track.name, composer.name, file.size, " //0
+ "file.duration, file.bitrate, file.url, file.source, file.mtime, " //6
+ "file.mimetype, file_join.discnumber, file_join.albumpos, artist.id, " //11
+ "album.id, track.id, composer.id " //15
"FROM file, artist, track, file_join "
"LEFT OUTER JOIN album "
"ON file_join.album = album.id "
+ "LEFT OUTER JOIN artist AS composer "
+ "ON file_join.composer = composer.id "
"WHERE file.id = file_join.file "
"AND file_join.artist = artist.id "
"AND file_join.track = track.id "
@@ -92,15 +96,15 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
while( query.next() )
{
Tomahawk::source_ptr s;
- QString url = query.value( 7 ).toString();
+ QString url = query.value( 8 ).toString();
- if ( query.value( 8 ).toUInt() == 0 )
+ if ( query.value( 9 ).toUInt() == 0 )
{
s = SourceList::instance()->getLocal();
}
else
{
- s = SourceList::instance()->get( query.value( 8 ).toUInt() );
+ s = SourceList::instance()->get( query.value( 9 ).toUInt() );
if ( s.isNull() )
{
Q_ASSERT( false );
@@ -110,26 +114,30 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
url = QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url );
}
- QString artist, track, album;
+ QString artist, track, album, composer;
artist = query.value( 1 ).toString();
album = query.value( 2 ).toString();
track = query.value( 3 ).toString();
+ composer = query.value( 4 ).toString();
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
Tomahawk::query_ptr qry = Tomahawk::Query::get( artist, track, album );
- Tomahawk::artist_ptr artistptr = Tomahawk::Artist::get( query.value( 12 ).toUInt(), artist );
- Tomahawk::album_ptr albumptr = Tomahawk::Album::get( query.value( 13 ).toUInt(), album, artistptr );
+ Tomahawk::artist_ptr artistptr = Tomahawk::Artist::get( query.value( 14 ).toUInt(), artist );
+ Tomahawk::artist_ptr composerptr = Tomahawk::Artist::get( query.value( 17 ).toUInt(), composer );
+ Tomahawk::album_ptr albumptr = Tomahawk::Album::get( query.value( 15 ).toUInt(), album, artistptr );
- result->setTrackId( query.value( 14 ).toUInt() );
+ result->setTrackId( query.value( 16 ).toUInt() );
result->setArtist( artistptr );
result->setAlbum( albumptr );
result->setTrack( query.value( 3 ).toString() );
- result->setSize( query.value( 4 ).toUInt() );
- result->setDuration( query.value( 5 ).toUInt() );
- result->setBitrate( query.value( 6 ).toUInt() );
- result->setModificationTime( query.value( 9 ).toUInt() );
- result->setMimetype( query.value( 10 ).toString() );
- result->setAlbumPos( query.value( 11 ).toUInt() );
+ result->setComposer( composerptr );
+ result->setSize( query.value( 5 ).toUInt() );
+ result->setDuration( query.value( 6 ).toUInt() );
+ result->setBitrate( query.value( 7 ).toUInt() );
+ result->setModificationTime( query.value( 10 ).toUInt() );
+ result->setMimetype( query.value( 11 ).toString() );
+ result->setDiscNumber( query.value( 12 ).toUInt() );
+ result->setAlbumPos( query.value( 13 ).toUInt() );
result->setScore( 1.0 );
result->setCollection( s->collection() );
diff --git a/src/libtomahawk/database/databasecommand_alltracks.h b/src/libtomahawk/database/databasecommand_alltracks.h
index e8e109b5c..bbf653f6b 100644
--- a/src/libtomahawk/database/databasecommand_alltracks.h
+++ b/src/libtomahawk/database/databasecommand_alltracks.h
@@ -26,6 +26,8 @@
#include "collection.h"
#include "typedefs.h"
#include "query.h"
+#include "artist.h"
+#include "album.h"
#include "dllmacro.h"
@@ -55,8 +57,8 @@ public:
virtual bool doesMutates() const { return false; }
virtual QString commandname() const { return "alltracks"; }
- void setArtist( Tomahawk::Artist* artist ) { m_artist = artist; }
- void setAlbum( Tomahawk::Album* album ) { m_album = album; }
+ void setArtist( const Tomahawk::artist_ptr& artist ) { m_artist = artist; }
+ void setAlbum( const Tomahawk::album_ptr& album ) { m_album = album; }
void setLimit( unsigned int amount ) { m_amount = amount; }
void setSortOrder( DatabaseCommand_AllTracks::SortOrder order ) { m_sortOrder = order; }
@@ -69,8 +71,8 @@ signals:
private:
Tomahawk::collection_ptr m_collection;
- Tomahawk::Artist* m_artist;
- Tomahawk::Album* m_album;
+ Tomahawk::artist_ptr m_artist;
+ Tomahawk::album_ptr m_album;
unsigned int m_amount;
DatabaseCommand_AllTracks::SortOrder m_sortOrder;
diff --git a/src/libtomahawk/database/databasecommand_deletefiles.cpp b/src/libtomahawk/database/databasecommand_deletefiles.cpp
index 2aad9f883..6c766d57f 100644
--- a/src/libtomahawk/database/databasecommand_deletefiles.cpp
+++ b/src/libtomahawk/database/databasecommand_deletefiles.cpp
@@ -18,14 +18,14 @@
#include "databasecommand_deletefiles.h"
-#include
+#include
#include "artist.h"
#include "album.h"
#include "collection.h"
#include "source.h"
#include "database/database.h"
-#include "databaseimpl.h"
+#include "database/databaseimpl.h"
#include "network/servent.h"
#include "utils/logger.h"
#include "utils/tomahawkutils.h"
@@ -60,7 +60,7 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
{
Q_ASSERT( !source().isNull() );
- QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id();
+ int srcid = source()->isLocal() ? 0 : source()->id();
TomahawkSqlQuery delquery = dbi->newquery();
if ( m_deleteAll )
@@ -68,8 +68,8 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
TomahawkSqlQuery dirquery = dbi->newquery();
dirquery.prepare( QString( "SELECT id FROM file WHERE source %1" )
.arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) ) );
-
dirquery.exec();
+
while ( dirquery.next() )
m_idList << dirquery.value( 0 ).toUInt();
}
@@ -115,7 +115,8 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
delquery.prepare( QString( "SELECT id FROM file WHERE source = %1 AND url IN ( %2 )" )
.arg( source()->id() )
.arg( idstring ) );
-
+ delquery.exec();
+
idstring = QString();
while ( delquery.next() )
{
@@ -128,7 +129,6 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
delquery.prepare( QString( "DELETE FROM file WHERE source %1 AND id IN ( %2 )" )
.arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) )
.arg( idstring ) );
-
delquery.exec();
}
diff --git a/src/libtomahawk/database/databasecommand_deletefiles.h b/src/libtomahawk/database/databasecommand_deletefiles.h
index f99ecc0b7..f76091ad8 100644
--- a/src/libtomahawk/database/databasecommand_deletefiles.h
+++ b/src/libtomahawk/database/databasecommand_deletefiles.h
@@ -19,9 +19,9 @@
#ifndef DATABASECOMMAND_DELETEFILES_H
#define DATABASECOMMAND_DELETEFILES_H
-#include
-#include
-#include
+#include
+#include
+#include
#include "database/databasecommandloggable.h"
#include "typedefs.h"
diff --git a/src/libtomahawk/database/databasecommand_loadsocialactions.cpp b/src/libtomahawk/database/databasecommand_loadsocialactions.cpp
index 8f2b51e2f..efb5a9d50 100644
--- a/src/libtomahawk/database/databasecommand_loadsocialactions.cpp
+++ b/src/libtomahawk/database/databasecommand_loadsocialactions.cpp
@@ -39,13 +39,11 @@ DatabaseCommand_LoadSocialActions::exec( DatabaseImpl* dbi )
QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id();
- bool autoCreate = false;
- int artid = dbi->artistId( m_artist, autoCreate );
+ int artid = dbi->artistId( m_artist, false );
if( artid < 1 )
return;
- autoCreate = false; // artistId overwrites autoCreate (reference)
- int trkid = dbi->trackId( artid, m_track, autoCreate );
+ int trkid = dbi->trackId( artid, m_track, false );
if( trkid < 1 )
return;
@@ -72,6 +70,6 @@ DatabaseCommand_LoadSocialActions::exec( DatabaseImpl* dbi )
allSocialActions.append( action );
}
- m_result->setAllSocialActions( allSocialActions );
+ m_query->setAllSocialActions( allSocialActions );
}
diff --git a/src/libtomahawk/database/databasecommand_loadsocialactions.h b/src/libtomahawk/database/databasecommand_loadsocialactions.h
index 7a6ea5425..1cf6688d1 100644
--- a/src/libtomahawk/database/databasecommand_loadsocialactions.h
+++ b/src/libtomahawk/database/databasecommand_loadsocialactions.h
@@ -56,17 +56,17 @@ public:
/**
* \brief Overloaded constructor for DatabaseCommand_LoadSocialAction.
- * \param result Pointer to a Tomahawk::Result.
+ * \param result A Tomahawk Query object.
* \param parent Parent class.
*
* Constructor which creates a new database command for loading all social actions.
*/
- explicit DatabaseCommand_LoadSocialActions( Tomahawk::Result* result, QObject* parent = 0 )
- : DatabaseCommand( parent ), m_result( result )
+ explicit DatabaseCommand_LoadSocialActions( const Tomahawk::query_ptr& query, QObject* parent = 0 )
+ : DatabaseCommand( parent ), m_query( query )
{
setSource( SourceList::instance()->getLocal() );
- setArtist( result->artist()->name() );
- setTrack( result->track() );
+ setArtist( query->artist() );
+ setTrack( query->track() );
}
/**
@@ -125,7 +125,7 @@ signals:
void done( QList< Tomahawk::SocialAction >& allSocialActions );
private:
- Tomahawk::Result* m_result;
+ Tomahawk::query_ptr m_query;
QString m_artist;
QString m_track;
diff --git a/src/libtomahawk/database/databasecommand_resolve.cpp b/src/libtomahawk/database/databasecommand_resolve.cpp
index a140417d0..1384f828e 100644
--- a/src/libtomahawk/database/databasecommand_resolve.cpp
+++ b/src/libtomahawk/database/databasecommand_resolve.cpp
@@ -100,16 +100,21 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
QString trksToken = QString( "file_join.track IN (%1)" ).arg( trksl.join( "," ) );
QString sql = QString( "SELECT "
- "url, mtime, size, md5, mimetype, duration, bitrate, file_join.artist, file_join.album, file_join.track, "
- "artist.name as artname, "
- "album.name as albname, "
- "track.name as trkname, "
- "file.source, "
- "file_join.albumpos, "
- "artist.id as artid, "
- "album.id as albid "
+ "url, mtime, size, md5, mimetype, duration, bitrate, " //0
+ "file_join.artist, file_join.album, file_join.track, " //7
+ "file_join.composer, file_join.discnumber, " //10
+ "artist.name as artname, " //12
+ "album.name as albname, " //13
+ "track.name as trkname, " //14
+ "composer.name as cmpname, " //15
+ "file.source, " //16
+ "file_join.albumpos, " //17
+ "artist.id as artid, " //18
+ "album.id as albid, " //19
+ "composer.id as cmpid " //20
"FROM file, file_join, artist, track "
"LEFT JOIN album ON album.id = file_join.album "
+ "LEFT JOIN artist AS composer ON composer.id = file_join.composer "
"WHERE "
"artist.id = file_join.artist AND "
"track.id = file_join.track AND "
@@ -126,16 +131,16 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
source_ptr s;
QString url = files_query.value( 0 ).toString();
- if ( files_query.value( 13 ).toUInt() == 0 )
+ if ( files_query.value( 16 ).toUInt() == 0 )
{
s = SourceList::instance()->getLocal();
}
else
{
- s = SourceList::instance()->get( files_query.value( 13 ).toUInt() );
+ s = SourceList::instance()->get( files_query.value( 16 ).toUInt() );
if( s.isNull() )
{
- qDebug() << "Could not find source" << files_query.value( 13 ).toUInt();
+ qDebug() << "Could not find source" << files_query.value( 16 ).toUInt();
continue;
}
@@ -143,8 +148,12 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
}
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
- Tomahawk::artist_ptr artist = Tomahawk::Artist::get( files_query.value( 15 ).toUInt(), files_query.value( 10 ).toString() );
- Tomahawk::album_ptr album = Tomahawk::Album::get( files_query.value( 16 ).toUInt(), files_query.value( 11 ).toString(), artist );
+ Tomahawk::artist_ptr artist =
+ Tomahawk::Artist::get( files_query.value( 18 ).toUInt(), files_query.value( 12 ).toString() );
+ Tomahawk::album_ptr album =
+ Tomahawk::Album::get( files_query.value( 19 ).toUInt(), files_query.value( 13 ).toString(), artist );
+ Tomahawk::artist_ptr composer =
+ Tomahawk::Artist::get( files_query.value( 20 ).toUInt(), files_query.value( 15 ).toString() );
result->setModificationTime( files_query.value( 1 ).toUInt() );
result->setSize( files_query.value( 2 ).toUInt() );
@@ -152,10 +161,12 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
result->setDuration( files_query.value( 5 ).toUInt() );
result->setBitrate( files_query.value( 6 ).toUInt() );
result->setArtist( artist );
+ result->setComposer( composer );
result->setAlbum( album );
- result->setTrack( files_query.value( 12 ).toString() );
+ result->setDiscNumber( files_query.value( 11 ).toUInt() );
+ result->setTrack( files_query.value( 14 ).toString() );
result->setRID( uuid() );
- result->setAlbumPos( files_query.value( 14 ).toUInt() );
+ result->setAlbumPos( files_query.value( 17 ).toUInt() );
result->setTrackId( files_query.value( 9 ).toUInt() );
TomahawkSqlQuery attrQuery = lib->newquery();
@@ -248,16 +259,21 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
QString albsToken = QString( "file_join.album IN (%1)" ).arg( albsl.join( "," ) );
QString sql = QString( "SELECT "
- "url, mtime, size, md5, mimetype, duration, bitrate, file_join.artist, file_join.album, file_join.track, "
- "artist.name as artname, "
- "album.name as albname, "
- "track.name as trkname, "
- "file.source, "
- "file_join.albumpos, "
- "artist.id as artid, "
- "album.id as albid "
+ "url, mtime, size, md5, mimetype, duration, bitrate, " //0
+ "file_join.artist, file_join.album, file_join.track, " //7
+ "file_join.composer, file_join.discnumber, " //10
+ "artist.name as artname, " //12
+ "album.name as albname, " //13
+ "track.name as trkname, " //14
+ "composer.name as cmpname, " //15
+ "file.source, " //16
+ "file_join.albumpos, " //17
+ "artist.id as artid, " //18
+ "album.id as albid, " //19
+ "composer.id as cmpid " //20
"FROM file, file_join, artist, track "
"LEFT JOIN album ON album.id = file_join.album "
+ "LEFT JOIN artist AS composer ON composer.id = file_join.composer "
"WHERE "
"artist.id = file_join.artist AND "
"track.id = file_join.track AND "
@@ -273,16 +289,16 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
source_ptr s;
QString url = files_query.value( 0 ).toString();
- if ( files_query.value( 13 ).toUInt() == 0 )
+ if ( files_query.value( 16 ).toUInt() == 0 )
{
s = SourceList::instance()->getLocal();
}
else
{
- s = SourceList::instance()->get( files_query.value( 13 ).toUInt() );
+ s = SourceList::instance()->get( files_query.value( 16 ).toUInt() );
if( s.isNull() )
{
- qDebug() << "Could not find source" << files_query.value( 13 ).toUInt();
+ qDebug() << "Could not find source" << files_query.value( 16 ).toUInt();
continue;
}
@@ -290,8 +306,12 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
}
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
- Tomahawk::artist_ptr artist = Tomahawk::Artist::get( files_query.value( 15 ).toUInt(), files_query.value( 10 ).toString() );
- Tomahawk::album_ptr album = Tomahawk::Album::get( files_query.value( 16 ).toUInt(), files_query.value( 11 ).toString(), artist );
+ Tomahawk::artist_ptr artist =
+ Tomahawk::Artist::get( files_query.value( 18 ).toUInt(), files_query.value( 12 ).toString() );
+ Tomahawk::album_ptr album =
+ Tomahawk::Album::get( files_query.value( 19 ).toUInt(), files_query.value( 13 ).toString(), artist );
+ Tomahawk::artist_ptr composer =
+ Tomahawk::Artist::get( files_query.value( 20 ).toUInt(), files_query.value( 15 ).toString() );
result->setModificationTime( files_query.value( 1 ).toUInt() );
result->setSize( files_query.value( 2 ).toUInt() );
@@ -299,12 +319,13 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
result->setDuration( files_query.value( 5 ).toUInt() );
result->setBitrate( files_query.value( 6 ).toUInt() );
result->setArtist( artist );
+ result->setComposer( composer );
result->setAlbum( album );
- result->setTrack( files_query.value( 12 ).toString() );
+ result->setDiscNumber( files_query.value( 11 ).toUInt() );
+ result->setTrack( files_query.value( 14 ).toString() );
result->setRID( uuid() );
- result->setAlbumPos( files_query.value( 14 ).toUInt() );
+ result->setAlbumPos( files_query.value( 17 ).toUInt() );
result->setTrackId( files_query.value( 9 ).toUInt() );
- result->setYear( files_query.value( 17 ).toUInt() );
for ( int k = 0; k < trackPairs.count(); k++ )
{
diff --git a/src/libtomahawk/database/databasecommand_resolve.h b/src/libtomahawk/database/databasecommand_resolve.h
index 52b8fbe18..80cbe5d88 100644
--- a/src/libtomahawk/database/databasecommand_resolve.h
+++ b/src/libtomahawk/database/databasecommand_resolve.h
@@ -22,6 +22,8 @@
#include "databasecommand.h"
#include "databaseimpl.h"
#include "result.h"
+#include "artist.h"
+#include "album.h"
#include
diff --git a/src/libtomahawk/database/databasecommand_socialaction.h b/src/libtomahawk/database/databasecommand_socialaction.h
index 40e23ecf0..5bc480b71 100644
--- a/src/libtomahawk/database/databasecommand_socialaction.h
+++ b/src/libtomahawk/database/databasecommand_socialaction.h
@@ -61,20 +61,20 @@ public:
/**
* \brief Overloaded constructor for DatabaseCommand_SocialAction.
- * \param result Pointer to a Tomahawk::Result.
+ * \param query A Tomahawk Query object.
* \param action Name of the social action to be written to the database.
* \param comment Comment associated with this social action.
* \param parent Parent class.
*
* Constructor which creates a new database command for the specified social action.
*/
- explicit DatabaseCommand_SocialAction( const Tomahawk::result_ptr& result, QString action, QString comment="", QObject* parent = 0 )
- : DatabaseCommandLoggable( parent ), m_result( result ), m_action( action )
+ explicit DatabaseCommand_SocialAction( const Tomahawk::query_ptr& query, QString action, QString comment = "", QObject* parent = 0 )
+ : DatabaseCommandLoggable( parent ), m_query( query ), m_action( action )
{
setSource( SourceList::instance()->getLocal() );
- setArtist( result->artist()->name() );
- setTrack( result->track() );
+ setArtist( query->artist() );
+ setTrack( query->track() );
setComment( comment );
setTimestamp( QDateTime::currentDateTime().toTime_t() );
}
@@ -173,7 +173,7 @@ public:
virtual bool groupable() const { return true; }
private:
- Tomahawk::result_ptr m_result;
+ Tomahawk::query_ptr m_query;
QString m_artist;
QString m_track;
diff --git a/src/libtomahawk/database/databaseimpl.cpp b/src/libtomahawk/database/databaseimpl.cpp
index ef25eac50..847685457 100644
--- a/src/libtomahawk/database/databaseimpl.cpp
+++ b/src/libtomahawk/database/databaseimpl.cpp
@@ -40,7 +40,7 @@
*/
#include "schema.sql.h"
-#define CURRENT_SCHEMA_VERSION 27
+#define CURRENT_SCHEMA_VERSION 28
DatabaseImpl::DatabaseImpl( const QString& dbname, Database* parent )
@@ -80,6 +80,12 @@ DatabaseImpl::DatabaseImpl( const QString& dbname, Database* parent )
m_fuzzyIndex = new FuzzyIndex( *this, schemaUpdated );
tDebug( LOGVERBOSE ) << "Loaded index:" << t.elapsed();
+
+ if ( qApp->arguments().contains( "--dumpdb" ) )
+ {
+ dumpDatabase();
+ ::exit( 0 );
+ }
}
@@ -89,6 +95,34 @@ DatabaseImpl::~DatabaseImpl()
}
+void
+DatabaseImpl::dumpDatabase()
+{
+ QFile dump( "dbdump.txt" );
+ if ( !dump.open( QIODevice::WriteOnly | QIODevice::Text ) )
+ {
+ tDebug() << "Couldn't open dbdump.txt for writing!";
+ Q_ASSERT( false );
+ }
+ else
+ {
+ QTextStream dumpout( &dump );
+ TomahawkSqlQuery query = newquery();
+
+ query.exec( "SELECT * FROM oplog" );
+ while ( query.next() )
+ {
+ dumpout << "ID: " << query.value( 0 ).toInt() << endl
+ << "GUID: " << query.value( 2 ).toString() << endl
+ << "Command: " << query.value( 3 ).toString() << endl
+ << "Singleton: " << query.value( 4 ).toBool() << endl
+ << "JSON: " << ( query.value( 5 ).toBool() ? qUncompress( query.value( 6 ).toByteArray() ) : query.value( 6 ).toByteArray() )
+ << endl << endl << endl;
+ }
+ }
+}
+
+
void
DatabaseImpl::loadIndex()
{
@@ -174,10 +208,11 @@ DatabaseImpl::file( int fid )
Tomahawk::result_ptr r;
TomahawkSqlQuery query = newquery();
query.exec( QString( "SELECT url, mtime, size, md5, mimetype, duration, bitrate, "
- "file_join.artist, file_join.album, file_join.track, "
+ "file_join.artist, file_join.album, file_join.track, file_join.composer, "
"(select name from artist where id = file_join.artist) as artname, "
"(select name from album where id = file_join.album) as albname, "
"(select name from track where id = file_join.track) as trkname, "
+ "(select name from artist where id = file_join.composer) as cmpname, "
"source "
"FROM file, file_join "
"WHERE file.id = file_join.file AND file.id = %1" )
@@ -188,13 +223,13 @@ DatabaseImpl::file( int fid )
Tomahawk::source_ptr s;
QString url = query.value( 0 ).toString();
- if ( query.value( 13 ).toUInt() == 0 )
+ if ( query.value( 15 ).toUInt() == 0 )
{
s = SourceList::instance()->getLocal();
}
else
{
- s = SourceList::instance()->get( query.value( 13 ).toUInt() );
+ s = SourceList::instance()->get( query.value( 15 ).toUInt() );
if ( s.isNull() )
{
return r;
@@ -204,8 +239,9 @@ DatabaseImpl::file( int fid )
}
r = Tomahawk::Result::get( url );
- Tomahawk::artist_ptr artist = Tomahawk::Artist::get( query.value( 7 ).toUInt(), query.value( 10 ).toString() );
- Tomahawk::album_ptr album = Tomahawk::Album::get( query.value( 8 ).toUInt(), query.value( 11 ).toString(), artist );
+ Tomahawk::artist_ptr artist = Tomahawk::Artist::get( query.value( 7 ).toUInt(), query.value( 11 ).toString() );
+ Tomahawk::album_ptr album = Tomahawk::Album::get( query.value( 8 ).toUInt(), query.value( 12 ).toString(), artist );
+ Tomahawk::artist_ptr composer = Tomahawk::Artist::get( query.value( 10 ).toUInt(), query.value( 14 ).toString() );
r->setModificationTime( query.value( 1 ).toUInt() );
r->setSize( query.value( 2 ).toUInt() );
@@ -214,7 +250,8 @@ DatabaseImpl::file( int fid )
r->setBitrate( query.value( 6 ).toUInt() );
r->setArtist( artist );
r->setAlbum( album );
- r->setTrack( query.value( 12 ).toString() );
+ r->setComposer( composer );
+ r->setTrack( query.value( 13 ).toString() );
r->setTrackId( query.value( 9 ).toUInt() );
r->setCollection( s->collection() );
r->setScore( 1.0 );
@@ -523,17 +560,23 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
bool searchlocal = s->isLocal();
QString sql = QString( "SELECT "
- "url, mtime, size, md5, mimetype, duration, bitrate, file_join.artist, file_join.album, file_join.track, "
- "artist.name as artname, "
- "album.name as albname, "
- "track.name as trkname, "
- "file.source, "
- "file_join.albumpos, "
- "artist.id as artid, "
- "album.id as albid, "
- "track_attributes.v as year "
+ "url, mtime, size, md5, mimetype, duration, bitrate, " //0
+ "file_join.artist, file_join.album, file_join.track, " //7
+ "file_join.composer, " //10
+ "artist.name as artname, " //11
+ "album.name as albname, " //12
+ "track.name as trkname, " //13
+ "composer.name as cmpname, " //14
+ "file.source, " //15
+ "file_join.albumpos, " //16
+ "file_join.discnumber, " //17
+ "artist.id as artid, " //18
+ "album.id as albid, " //19
+ "composer.id as cmpid, " //20
+ "track_attributes.v as year " //21
"FROM file, file_join, artist, track, track_attributes "
"LEFT JOIN album ON album.id = file_join.album "
+ "LEFT JOIN artist AS composer on composer.id = file_join.composer "
"WHERE "
"artist.id = file_join.artist AND "
"track.id = file_join.track AND "
@@ -552,13 +595,13 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
Tomahawk::source_ptr s;
QString url = query.value( 0 ).toString();
- if ( query.value( 13 ).toUInt() == 0 )
+ if ( query.value( 15 ).toUInt() == 0 )
{
s = SourceList::instance()->getLocal();
}
else
{
- s = SourceList::instance()->get( query.value( 13 ).toUInt() );
+ s = SourceList::instance()->get( query.value( 15 ).toUInt() );
if ( s.isNull() )
{
return res;
@@ -568,8 +611,9 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
}
res = Tomahawk::Result::get( url );
- Tomahawk::artist_ptr artist = Tomahawk::Artist::get( query.value( 15 ).toUInt(), query.value( 10 ).toString() );
- Tomahawk::album_ptr album = Tomahawk::Album::get( query.value( 16 ).toUInt(), query.value( 11 ).toString(), artist );
+ Tomahawk::artist_ptr artist = Tomahawk::Artist::get( query.value( 18 ).toUInt(), query.value( 11 ).toString() );
+ Tomahawk::album_ptr album = Tomahawk::Album::get( query.value( 19 ).toUInt(), query.value( 12 ).toString(), artist );
+ Tomahawk::artist_ptr composer = Tomahawk::Artist::get( query.value( 20 ).toUInt(), query.value( 14 ).toString() );
res->setModificationTime( query.value( 1 ).toUInt() );
res->setSize( query.value( 2 ).toUInt() );
@@ -578,13 +622,15 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
res->setBitrate( query.value( 6 ).toInt() );
res->setArtist( artist );
res->setAlbum( album );
+ res->setComposer( composer );
res->setScore( 1.0 );
- res->setTrack( query.value( 12 ).toString() );
- res->setAlbumPos( query.value( 14 ).toUInt() );
+ res->setTrack( query.value( 13 ).toString() );
+ res->setAlbumPos( query.value( 16 ).toUInt() );
+ res->setDiscNumber( query.value( 17 ).toUInt() );
res->setRID( uuid() );
res->setTrackId( query.value( 9 ).toUInt() );
res->setCollection( s->collection() );
- res->setYear( query.value( 17 ).toUInt() );
+ res->setYear( query.value( 21 ).toUInt() );
}
return res;
diff --git a/src/libtomahawk/database/databaseimpl.h b/src/libtomahawk/database/databaseimpl.h
index 0cd6b9498..805dbab17 100644
--- a/src/libtomahawk/database/databaseimpl.h
+++ b/src/libtomahawk/database/databaseimpl.h
@@ -52,7 +52,7 @@ public:
TomahawkSqlQuery newquery() { return TomahawkSqlQuery( m_db ); }
QSqlDatabase& database() { return m_db; }
- int artistId( const QString& name_orig, bool autoCreate );
+ int artistId( const QString& name_orig, bool autoCreate ); //also for composers!
int trackId( int artistid, const QString& name_orig, bool autoCreate );
int albumId( int artistid, const QString& name_orig, bool autoCreate );
@@ -84,6 +84,7 @@ public slots:
private:
QString cleanSql( const QString& sql );
bool updateSchema( int oldVersion );
+ void dumpDatabase();
bool m_ready;
QSqlDatabase m_db;
diff --git a/src/libtomahawk/database/databaseresolver.h b/src/libtomahawk/database/databaseresolver.h
index ae7b8fc50..fd27180f5 100644
--- a/src/libtomahawk/database/databaseresolver.h
+++ b/src/libtomahawk/database/databaseresolver.h
@@ -21,6 +21,8 @@
#include "resolver.h"
#include "result.h"
+#include "artist.h"
+#include "album.h"
#include "dllmacro.h"
diff --git a/src/libtomahawk/database/fuzzyindex.cpp b/src/libtomahawk/database/fuzzyindex.cpp
index 39220b68c..b5d4b15a9 100644
--- a/src/libtomahawk/database/fuzzyindex.cpp
+++ b/src/libtomahawk/database/fuzzyindex.cpp
@@ -206,7 +206,7 @@ FuzzyIndex::search( const QString& table, const QString& name )
}
catch( CLuceneError& error )
{
- qDebug() << "Caught CLucene error:" << error.what();
+ tDebug() << "Caught CLucene error:" << error.what();
Q_ASSERT( false );
}
diff --git a/src/libtomahawk/database/schema.sql b/src/libtomahawk/database/schema.sql
index 37ee49156..be05afdf1 100644
--- a/src/libtomahawk/database/schema.sql
+++ b/src/libtomahawk/database/schema.sql
@@ -175,7 +175,9 @@ CREATE TABLE IF NOT EXISTS file_join (
artist INTEGER NOT NULL REFERENCES artist(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
track INTEGER NOT NULL REFERENCES track(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
album INTEGER REFERENCES album(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
- albumpos INTEGER
+ albumpos INTEGER,
+ composer INTEGER REFERENCES artist(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
+ discnumber INTEGER
);
CREATE INDEX file_join_track ON file_join(track);
CREATE INDEX file_join_artist ON file_join(artist);
@@ -292,4 +294,4 @@ CREATE TABLE IF NOT EXISTS settings (
v TEXT NOT NULL DEFAULT ''
);
-INSERT INTO settings(k,v) VALUES('schema_version', '27');
+INSERT INTO settings(k,v) VALUES('schema_version', '28');
diff --git a/src/libtomahawk/database/schema.sql.h b/src/libtomahawk/database/schema.sql.h
index cd7c05b52..4b66ab105 100644
--- a/src/libtomahawk/database/schema.sql.h
+++ b/src/libtomahawk/database/schema.sql.h
@@ -1,5 +1,5 @@
/*
- This file was automatically generated from schema.sql on Wed Nov 16 22:47:16 EST 2011.
+ This file was automatically generated from ./schema.sql on Fri Nov 18 14:00:37 CET 2011.
*/
static const char * tomahawk_schema_sql =
@@ -116,7 +116,9 @@ static const char * tomahawk_schema_sql =
" artist INTEGER NOT NULL REFERENCES artist(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,"
" track INTEGER NOT NULL REFERENCES track(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,"
" album INTEGER REFERENCES album(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,"
-" albumpos INTEGER"
+" albumpos INTEGER,"
+" composer INTEGER REFERENCES artist(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,"
+" discnumber INTEGER"
");"
"CREATE INDEX file_join_track ON file_join(track);"
"CREATE INDEX file_join_artist ON file_join(artist);"
@@ -189,7 +191,7 @@ static const char * tomahawk_schema_sql =
" k TEXT NOT NULL PRIMARY KEY,"
" v TEXT NOT NULL DEFAULT ''"
");"
-"INSERT INTO settings(k,v) VALUES('schema_version', '27');"
+"INSERT INTO settings(k,v) VALUES('schema_version', '28');"
;
const char * get_tomahawk_sql()
diff --git a/src/libtomahawk/dropjob.cpp b/src/libtomahawk/dropjob.cpp
index 3afabb540..6c0ed2f9f 100644
--- a/src/libtomahawk/dropjob.cpp
+++ b/src/libtomahawk/dropjob.cpp
@@ -764,7 +764,7 @@ QList< query_ptr >
DropJob::getArtist( const QString &artist )
{
artist_ptr artistPtr = Artist::get( artist );
- if ( artistPtr->getPlaylistInterface()->tracks().isEmpty() )
+ if ( artistPtr->playlistInterface()->tracks().isEmpty() )
{
connect( artistPtr.data(), SIGNAL( tracksAdded( QList ) ),
SLOT( onTracksAdded( QList ) ) );
@@ -772,7 +772,7 @@ DropJob::getArtist( const QString &artist )
return QList< query_ptr >();
}
else
- return artistPtr->getPlaylistInterface()->tracks();
+ return artistPtr->playlistInterface()->tracks();
}
@@ -785,7 +785,7 @@ DropJob::getAlbum(const QString &artist, const QString &album)
if ( albumPtr.isNull() )
return QList< query_ptr >();
- if ( albumPtr->getPlaylistInterface()->tracks().isEmpty() )
+ if ( albumPtr->playlistInterface()->tracks().isEmpty() )
{
m_dropJob = new DropJobNotifier( QPixmap( RESPATH "images/album-icon.png" ), Album );
connect( albumPtr.data(), SIGNAL( tracksAdded( QList ) ),
@@ -796,7 +796,7 @@ DropJob::getAlbum(const QString &artist, const QString &album)
return QList< query_ptr >();
}
else
- return albumPtr->getPlaylistInterface()->tracks();
+ return albumPtr->playlistInterface()->tracks();
}
diff --git a/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.cpp b/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.cpp
index 02eff8d12..6b19566d5 100644
--- a/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.cpp
+++ b/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.cpp
@@ -45,7 +45,9 @@ ChartsPlugin::ChartsPlugin()
, m_chartsFetchJobs( 0 )
{
/// Add resources here
- m_chartResources << "billboard" << "itunes" << "rdio" << "wearehunted" << "ex.fm";
+ m_chartResources << "billboard" << "itunes" << "rdio" << "wearehunted" << "ex.fm" << "soundcloudwall.com";
+ /// If you add resource, update version aswell
+ m_chartVersion = "1.0";
m_supportedGetTypes << InfoChart << InfoChartCapabilities;
}
@@ -153,7 +155,8 @@ ChartsPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requ
Tomahawk::InfoSystem::InfoStringHash criteria;
criteria[ "InfoChartCapabilities" ] = "chartsplugin";
- emit getCachedInfo( criteria, 604800000, requestData );
+ criteria[ "InfoChartVersion" ] = m_chartVersion;
+ emit getCachedInfo( criteria, 864000000, requestData );
}
void
@@ -182,8 +185,8 @@ ChartsPlugin::notInCacheSlot( QHash criteria, Tomahawk::InfoSy
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "InfoChartCapabilities not in cache! Fetching...";
// we never need to re-fetch
- if ( !m_allChartsMap.isEmpty() )
- return;
+ //if ( !m_allChartsMap.isEmpty() )
+ // return;
/// Then get each chart from resource
@@ -333,6 +336,7 @@ ChartsPlugin::chartTypes()
if( source == "wearehunted" ){
chartName = "WeAreHunted";
}
+
}
}
@@ -422,7 +426,8 @@ ChartsPlugin::chartTypes()
// update cache
Tomahawk::InfoSystem::InfoStringHash criteria;
criteria[ "InfoChartCapabilities" ] = "chartsplugin";
- emit updateCache( criteria, 604800000, request.type, m_allChartsMap );
+ criteria[ "InfoChartVersion" ] = m_chartVersion;
+ emit updateCache( criteria, 864000000, request.type, m_allChartsMap );
}
m_cachedRequests.clear();
}
diff --git a/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.h b/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.h
index 0d527d4c9..983c71de5 100644
--- a/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.h
+++ b/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.h
@@ -72,16 +72,13 @@ private:
void dataError( Tomahawk::InfoSystem::InfoRequestData requestData );
QStringList m_chartResources;
+ QString m_chartVersion;
QList< InfoStringHash > m_charts;
ChartType m_chartType;
-
QVariantMap m_allChartsMap;
-
uint m_chartsFetchJobs;
QList< InfoRequestData > m_cachedRequests;
-
QHash< QString, QString > m_cachedCountries;
-
QWeakPointer< QNetworkAccessManager > m_nam;
};
diff --git a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp b/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp
index f88775781..99f58d815 100644
--- a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp
+++ b/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp
@@ -489,15 +489,26 @@ LastFmPlugin::similarArtistsReturned()
QNetworkReply* reply = qobject_cast( sender() );
QMap< int, QString > similarArtists = lastfm::Artist::getSimilar( reply );
+
+ QStringList sortedArtists;
+ QStringList sortedScores;
QStringList al;
QStringList sl;
- foreach ( const QString& a, similarArtists.values() )
- al << a;
+ foreach ( const QString& artist, similarArtists.values() )
+ al << artist;
+ foreach ( int score, similarArtists.keys() )
+ sl << QString::number( score );
+
+ for ( int i = al.count() - 1; i >= 0; i-- )
+ {
+ sortedArtists << al.at( i );
+ sortedScores << sl.at( i );
+ }
QVariantMap returnedData;
- returnedData["artists"] = al;
- returnedData["score"] = sl;
+ returnedData["artists"] = sortedArtists;
+ returnedData["score"] = sortedScores;
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
@@ -682,25 +693,25 @@ LastFmPlugin::artistImagesReturned()
void
LastFmPlugin::settingsChanged()
{
- if( !m_scrobbler && TomahawkSettings::instance()->scrobblingEnabled() )
+ if ( !m_scrobbler && TomahawkSettings::instance()->scrobblingEnabled() )
{ // can simply create the scrobbler
lastfm::ws::Username = TomahawkSettings::instance()->lastFmUsername();
m_pw = TomahawkSettings::instance()->lastFmPassword();
createScrobbler();
}
- else if( m_scrobbler && !TomahawkSettings::instance()->scrobblingEnabled() )
+ else if ( m_scrobbler && !TomahawkSettings::instance()->scrobblingEnabled() )
{
delete m_scrobbler;
m_scrobbler = 0;
}
- else if( TomahawkSettings::instance()->lastFmUsername() != lastfm::ws::Username ||
+ else if ( TomahawkSettings::instance()->lastFmUsername() != lastfm::ws::Username ||
TomahawkSettings::instance()->lastFmPassword() != m_pw )
{
lastfm::ws::Username = TomahawkSettings::instance()->lastFmUsername();
m_pw = TomahawkSettings::instance()->lastFmPassword();
// credentials have changed, have to re-create scrobbler for them to take effect
- if( m_scrobbler )
+ if ( m_scrobbler )
{
delete m_scrobbler;
m_scrobbler = 0;
@@ -715,17 +726,17 @@ void
LastFmPlugin::onAuthenticated()
{
QNetworkReply* authJob = dynamic_cast( sender() );
- if( !authJob )
+ if ( !authJob )
{
tLog() << Q_FUNC_INFO << "Help! No longer got a last.fm auth job!";
return;
}
- if( authJob->error() == QNetworkReply::NoError )
+ if ( authJob->error() == QNetworkReply::NoError )
{
lastfm::XmlQuery lfm = lastfm::XmlQuery( authJob->readAll() );
- if( lfm.children( "error" ).size() > 0 )
+ if ( lfm.children( "error" ).size() > 0 )
{
tLog() << "Error from authenticating with Last.fm service:" << lfm.text();
TomahawkSettings::instance()->setLastFmSessionKey( QByteArray() );
@@ -737,7 +748,7 @@ LastFmPlugin::onAuthenticated()
TomahawkSettings::instance()->setLastFmSessionKey( lastfm::ws::SessionKey.toLatin1() );
// qDebug() << "Got session key from last.fm";
- if( TomahawkSettings::instance()->scrobblingEnabled() )
+ if ( TomahawkSettings::instance()->scrobblingEnabled() )
m_scrobbler = new lastfm::Audioscrobbler( "thk" );
}
}
@@ -753,7 +764,7 @@ LastFmPlugin::onAuthenticated()
void
LastFmPlugin::createScrobbler()
{
- if( TomahawkSettings::instance()->lastFmSessionKey().isEmpty() ) // no session key, so get one
+ if ( TomahawkSettings::instance()->lastFmSessionKey().isEmpty() ) // no session key, so get one
{
qDebug() << "LastFmPlugin::createScrobbler Session key is empty";
QString authToken = TomahawkUtils::md5( ( lastfm::ws::Username.toLower() + TomahawkUtils::md5( m_pw.toUtf8() ) ).toUtf8() );
@@ -780,14 +791,15 @@ QList
LastFmPlugin::parseTrackList( QNetworkReply* reply )
{
QList tracks;
- try {
+ try
+ {
lastfm::XmlQuery lfm = reply->readAll();
foreach ( lastfm::XmlQuery xq, lfm.children( "track" ) )
{
tracks.append( lastfm::Track( xq ) );
}
}
- catch( lastfm::ws::ParseError& e )
+ catch ( lastfm::ws::ParseError& e )
{
qWarning() << e.what();
}
diff --git a/src/libtomahawk/infosystem/infoplugins/unix/fdonotifyplugin.cpp b/src/libtomahawk/infosystem/infoplugins/unix/fdonotifyplugin.cpp
index 4a72e2ebd..4e3b3881e 100644
--- a/src/libtomahawk/infosystem/infoplugins/unix/fdonotifyplugin.cpp
+++ b/src/libtomahawk/infosystem/infoplugins/unix/fdonotifyplugin.cpp
@@ -42,7 +42,7 @@
#include
#include
-#include
+#include
#include "utils/logger.h"
@@ -84,18 +84,14 @@ FdoNotifyPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type,
arguments << quint32( 0 ); //notification_id
arguments << QString(); //app_icon
arguments << QString( "Tomahawk" ); //summary
- arguments << hash["message"].toString(); //body
+ arguments << hash[ "message" ].toString(); //body
arguments << QStringList(); //actions
QVariantMap dict;
dict["desktop-entry"] = QString( "tomahawk" );
- if ( hash.contains( "image" ) )
- {
- QVariant tempVariant = hash["image"];
- QImage tempImage = tempVariant.value< QImage >();
- dict["image_data"] = ImageConverter::variantForImage( tempImage );
- }
+ if ( hash.contains( "image" ) && hash[ "image" ].canConvert< QImage >() )
+ dict[ "image_data" ] = ImageConverter::variantForImage( hash[ "image" ].value< QImage >() );
else
- dict["image_data"] = ImageConverter::variantForImage( QImage( RESPATH "icons/tomahawk-icon-128x128.png" ) );
+ dict[ "image_data" ] = ImageConverter::variantForImage( QImage( RESPATH "icons/tomahawk-icon-128x128.png" ) );
arguments << dict; //hints
arguments << qint32( -1 ); //expire_timeout
message.setArguments( arguments );
diff --git a/src/libtomahawk/infosystem/infoplugins/unix/imageconverter.cpp b/src/libtomahawk/infosystem/infoplugins/unix/imageconverter.cpp
index 97986cab7..a9966108a 100644
--- a/src/libtomahawk/infosystem/infoplugins/unix/imageconverter.cpp
+++ b/src/libtomahawk/infosystem/infoplugins/unix/imageconverter.cpp
@@ -20,7 +20,7 @@
#include
#include
-#include
+#include
#include "utils/logger.h"
diff --git a/src/libtomahawk/playlist.cpp b/src/libtomahawk/playlist.cpp
index fcf0f3cc3..f093c24f1 100644
--- a/src/libtomahawk/playlist.cpp
+++ b/src/libtomahawk/playlist.cpp
@@ -595,7 +595,7 @@ Playlist::checkRevisionQueue()
Tomahawk::playlistinterface_ptr
-Playlist::getPlaylistInterface()
+Playlist::playlistInterface()
{
if ( m_playlistInterface.isNull() )
{
diff --git a/src/libtomahawk/playlist.h b/src/libtomahawk/playlist.h
index 5a6e04568..5cc6c70cf 100644
--- a/src/libtomahawk/playlist.h
+++ b/src/libtomahawk/playlist.h
@@ -185,7 +185,7 @@ public:
void setUpdater( PlaylistUpdaterInterface* interface ) { m_updater = interface; }
PlaylistUpdaterInterface* updater() const { return m_updater; }
- Tomahawk::playlistinterface_ptr getPlaylistInterface();
+ Tomahawk::playlistinterface_ptr playlistInterface();
signals:
/// emitted when the playlist revision changes (whenever the playlist changes)
diff --git a/src/libtomahawk/playlist/albumitem.cpp b/src/libtomahawk/playlist/albumitem.cpp
index 6495472cd..b59c1e013 100644
--- a/src/libtomahawk/playlist/albumitem.cpp
+++ b/src/libtomahawk/playlist/albumitem.cpp
@@ -74,6 +74,8 @@ AlbumItem::AlbumItem( const Tomahawk::album_ptr& album, AlbumItem* parent, int r
}
toberemoved = false;
+
+ connect( album.data(), SIGNAL( updated() ), SIGNAL( dataChanged() ) );
}
@@ -98,4 +100,6 @@ AlbumItem::AlbumItem( const Tomahawk::artist_ptr& artist, AlbumItem* parent, int
}
toberemoved = false;
+
+ connect( artist.data(), SIGNAL( updated() ), SIGNAL( dataChanged() ) );
}
diff --git a/src/libtomahawk/playlist/albumitem.h b/src/libtomahawk/playlist/albumitem.h
index 8b7cb7774..4da6f9a91 100644
--- a/src/libtomahawk/playlist/albumitem.h
+++ b/src/libtomahawk/playlist/albumitem.h
@@ -24,6 +24,7 @@
#include
#include
+#include "artist.h"
#include "album.h"
#include "dllmacro.h"
@@ -41,7 +42,6 @@ public:
const Tomahawk::artist_ptr& artist() const { return m_artist; }
const Tomahawk::album_ptr& album() const { return m_album; }
- void setCover( const QPixmap& cover ) { this->cover = cover; emit dataChanged(); }
AlbumItem* parent;
QList children;
@@ -49,7 +49,6 @@ public:
int childCount;
QPersistentModelIndex index;
QAbstractItemModel* model;
- QPixmap cover;
bool toberemoved;
signals:
diff --git a/src/libtomahawk/playlist/albumitemdelegate.cpp b/src/libtomahawk/playlist/albumitemdelegate.cpp
index 7860147af..e28208248 100644
--- a/src/libtomahawk/playlist/albumitemdelegate.cpp
+++ b/src/libtomahawk/playlist/albumitemdelegate.cpp
@@ -89,7 +89,19 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
painter->drawLine( shadowRect.bottomLeft() + QPoint( 0, 4 ), shadowRect.bottomRight() + QPoint( 0, 4 ) );
}
- QPixmap cover = item->cover.isNull() ? m_defaultCover : item->cover;
+ QPixmap cover;
+ if ( !item->album().isNull() )
+ {
+ cover.loadFromData( item->album()->cover() );
+ }
+ else if ( !item->artist().isNull() )
+ {
+ cover.loadFromData( item->artist()->cover() );
+ }
+
+ if ( cover.isNull() )
+ cover = m_defaultCover;
+
QRect r = option.rect.adjusted( 6, 5, -6, -41 );
if ( option.state & QStyle::State_Selected )
@@ -167,23 +179,24 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
r.adjust( 4, 0, -4, -1 );
if ( m_hoveringOver == index )
{
- TomahawkUtils::drawQueryBackground( painter, opt.palette, r, 1.5 );
+ TomahawkUtils::drawQueryBackground( painter, opt.palette, r, 1.1 );
painter->setPen( opt.palette.color( QPalette::HighlightedText ) );
}
else
{
+ if ( !( option.state & QStyle::State_Selected ) )
#ifdef Q_WS_MAC
- painter->setPen( opt.palette.color( QPalette::Dark ).darker( 200 ) );
+ painter->setPen( opt.palette.color( QPalette::Dark ).darker( 200 ) );
#else
- painter->setPen( opt.palette.color( QPalette::Dark ) );
+ painter->setPen( opt.palette.color( QPalette::Dark ) );
#endif
}
to.setAlignment( Qt::AlignHCenter | Qt::AlignBottom );
- text = painter->fontMetrics().elidedText( item->album()->artist()->name(), Qt::ElideRight, textRect.width() - 3 );
- painter->drawText( textRect, text, to );
- // Calculate rect of artist on-hover button click area
+ text = painter->fontMetrics().elidedText( item->album()->artist()->name(), Qt::ElideRight, textRect.width() - 10 );
+ painter->drawText( textRect.adjusted( 5, -1, -5, -1 ), text, to );
+ // Calculate rect of artist on-hover button click area
m_artistNameRects[ index ] = r;
}
diff --git a/src/libtomahawk/playlist/albummodel.cpp b/src/libtomahawk/playlist/albummodel.cpp
index 5066c7256..9c552e070 100644
--- a/src/libtomahawk/playlist/albummodel.cpp
+++ b/src/libtomahawk/playlist/albummodel.cpp
@@ -30,8 +30,6 @@
#include "utils/tomahawkutils.h"
#include "utils/logger.h"
-static QString s_tmInfoIdentifier = QString( "ALBUMMODEL" );
-
using namespace Tomahawk;
@@ -40,11 +38,6 @@ AlbumModel::AlbumModel( QObject* parent )
, m_rootItem( new AlbumItem( 0, this ) )
, m_overwriteOnAdd( false )
{
- connect( Tomahawk::InfoSystem::InfoSystem::instance(),
- SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
- SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
-
- connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
}
@@ -123,11 +116,6 @@ AlbumModel::data( const QModelIndex& index, int role ) const
if ( !entry )
return QVariant();
- if ( role == Qt::DecorationRole )
- {
- return entry->cover;
- }
-
if ( role != Qt::DisplayRole ) // && role != Qt::ToolTipRole )
return QVariant();
@@ -187,8 +175,6 @@ AlbumModel::mimeTypes() const
QMimeData*
AlbumModel::mimeData( const QModelIndexList &indexes ) const
{
- qDebug() << Q_FUNC_INFO;
-
QByteArray queryData;
QDataStream queryStream( &queryData, QIODevice::WriteOnly );
@@ -404,89 +390,6 @@ AlbumModel::clear()
}
-bool
-AlbumModel::getCover( const QModelIndex& index )
-{
- AlbumItem* item = itemFromIndex( index );
- if ( !item || !item->cover.isNull() )
- return false;
-
- Tomahawk::InfoSystem::InfoStringHash trackInfo;
- Tomahawk::InfoSystem::InfoRequestData requestData;
-
- if ( !item->artist().isNull() )
- {
- requestData.type = Tomahawk::InfoSystem::InfoArtistImages;
-
- trackInfo["artist"] = item->artist()->name();
- }
- else if ( !item->album().isNull() && !item->album()->artist().isNull() )
- {
- requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
-
- trackInfo["artist"] = item->album()->artist()->name();
- trackInfo["album"] = item->album()->name();
- }
-
- m_coverHash.insert( (qlonglong)item, index );
- trackInfo["pptr"] = QString::number( (qlonglong)item );
-
- requestData.caller = s_tmInfoIdentifier;
- requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
- requestData.customData = QVariantMap();
-
- Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
- return true;
-}
-
-
-void
-AlbumModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
-{
-// qDebug() << Q_FUNC_INFO << " with caller " << requestData.caller;
-
- if ( requestData.caller != s_tmInfoIdentifier ||
- ( requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt && requestData.type != Tomahawk::InfoSystem::InfoArtistImages ) )
- {
- return;
- }
-
- if ( !output.canConvert< QVariantMap >() )
- {
- qDebug() << "Cannot convert fetched art from a QByteArray";
- return;
- }
-
- Tomahawk::InfoSystem::InfoStringHash pptr = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
- QVariantMap returnedData = output.value< QVariantMap >();
- const QByteArray ba = returnedData["imgbytes"].toByteArray();
- if ( ba.length() )
- {
- QPixmap pm;
- pm.loadFromData( ba );
-
- bool ok;
- qlonglong p = pptr["pptr"].toLongLong( &ok );
- AlbumItem* ai = itemFromIndex( m_coverHash.take( p ) );
- if ( !ai )
- return;
-
- if ( !pm.isNull() )
- ai->cover = pm;
-
- if ( ai->index.isValid() )
- emit dataChanged( ai->index, ai->index.sibling( ai->index.row(), columnCount( QModelIndex() ) - 1 ) );
- }
-}
-
-
-void
-AlbumModel::infoSystemFinished( QString target )
-{
- Q_UNUSED( target );
-}
-
-
void
AlbumModel::onDataChanged()
{
diff --git a/src/libtomahawk/playlist/albummodel.h b/src/libtomahawk/playlist/albummodel.h
index 31ae6560a..01d8f0569 100644
--- a/src/libtomahawk/playlist/albummodel.h
+++ b/src/libtomahawk/playlist/albummodel.h
@@ -25,7 +25,6 @@
#include "album.h"
#include "playlistinterface.h"
#include "database/databasecommand_allalbums.h"
-#include "infosystem/infosystem.h"
#include "dllmacro.h"
@@ -67,8 +66,6 @@ public:
void addCollection( const Tomahawk::collection_ptr& collection, bool overwrite = false );
void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllAlbums::SortOrder order, bool overwrite = false );
- bool getCover( const QModelIndex& index );
-
virtual QString title() const { return m_title; }
virtual QString description() const { return m_description; }
virtual void setTitle( const QString& title ) { m_title = title; }
@@ -106,9 +103,6 @@ private slots:
void onSourceAdded( const Tomahawk::source_ptr& source );
void onCollectionChanged();
- void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
- void infoSystemFinished( QString target );
-
private:
QPersistentModelIndex m_currentIndex;
AlbumItem* m_rootItem;
@@ -118,8 +112,6 @@ private:
bool m_overwriteOnAdd;
Tomahawk::collection_ptr m_collection;
-
- QHash m_coverHash;
};
#endif // ALBUMMODEL_H
diff --git a/src/libtomahawk/playlist/albumproxymodel.cpp b/src/libtomahawk/playlist/albumproxymodel.cpp
index 125a81672..be292bba9 100644
--- a/src/libtomahawk/playlist/albumproxymodel.cpp
+++ b/src/libtomahawk/playlist/albumproxymodel.cpp
@@ -141,7 +141,7 @@ AlbumProxyModel::removeIndexes( const QList& indexes )
Tomahawk::playlistinterface_ptr
-AlbumProxyModel::getPlaylistInterface()
+AlbumProxyModel::playlistInterface()
{
if ( m_playlistInterface.isNull() )
{
diff --git a/src/libtomahawk/playlist/albumproxymodel.h b/src/libtomahawk/playlist/albumproxymodel.h
index 9e8cc566d..22036ea2a 100644
--- a/src/libtomahawk/playlist/albumproxymodel.h
+++ b/src/libtomahawk/playlist/albumproxymodel.h
@@ -45,7 +45,7 @@ public:
virtual void emitFilterChanged( const QString &pattern ) { emit filterChanged( pattern ); }
- virtual Tomahawk::playlistinterface_ptr getPlaylistInterface();
+ virtual Tomahawk::playlistinterface_ptr playlistInterface();
signals:
void filterChanged( const QString& filter );
diff --git a/src/libtomahawk/playlist/albumproxymodelplaylistinterface.h b/src/libtomahawk/playlist/albumproxymodelplaylistinterface.h
index 01e34cdc4..16db3cb7c 100644
--- a/src/libtomahawk/playlist/albumproxymodelplaylistinterface.h
+++ b/src/libtomahawk/playlist/albumproxymodelplaylistinterface.h
@@ -63,7 +63,7 @@ signals:
void nextTrackReady();
public slots:
- virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
+ virtual void setRepeatMode( Tomahawk::PlaylistInterface::RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); }
private:
diff --git a/src/libtomahawk/playlist/albumview.cpp b/src/libtomahawk/playlist/albumview.cpp
index e975116aa..6e4ba2ee9 100644
--- a/src/libtomahawk/playlist/albumview.cpp
+++ b/src/libtomahawk/playlist/albumview.cpp
@@ -63,12 +63,6 @@ AlbumView::AlbumView( QWidget* parent )
setAutoFitItems( true );
setProxyModel( new AlbumProxyModel( this ) );
- m_timer.setInterval( SCROLL_TIMEOUT );
-
- connect( verticalScrollBar(), SIGNAL( rangeChanged( int, int ) ), SLOT( onViewChanged() ) );
- connect( verticalScrollBar(), SIGNAL( valueChanged( int ) ), SLOT( onViewChanged() ) );
- connect( &m_timer, SIGNAL( timeout() ), SLOT( onScrollTimeout() ) );
-
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
}
@@ -112,13 +106,10 @@ AlbumView::setAlbumModel( AlbumModel* model )
}
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
- connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) );
connect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onItemCountChanged( unsigned int ) ) );
connect( m_model, SIGNAL( loadingStarted() ), m_loadingSpinner, SLOT( fadeIn() ) );
connect( m_model, SIGNAL( loadingFinished() ), m_loadingSpinner, SLOT( fadeOut() ) );
-
- onViewChanged(); // Fetch covers if albums were added to model before model was attached to view
}
@@ -139,16 +130,6 @@ AlbumView::onItemActivated( const QModelIndex& index )
}
-void
-AlbumView::onViewChanged()
-{
- if ( m_timer.isActive() )
- m_timer.stop();
-
- m_timer.start();
-}
-
-
void
AlbumView::onItemCountChanged( unsigned int items )
{
@@ -166,45 +147,6 @@ AlbumView::onItemCountChanged( unsigned int items )
}
-void
-AlbumView::onScrollTimeout()
-{
- if ( m_timer.isActive() )
- m_timer.stop();
-
- if ( !m_proxyModel->rowCount() )
- return;
-
- QRect viewRect = viewport()->rect();
- int rowHeight = m_proxyModel->data( QModelIndex(), Qt::SizeHintRole ).toSize().height();
- viewRect.adjust( 0, -rowHeight, 0, rowHeight );
-
- bool started = false;
- bool done = false;
- for ( int i = 0; i < m_proxyModel->rowCount(); i++ )
- {
- if ( started && done )
- break;
-
- for ( int j = 0; j < m_proxyModel->columnCount(); j++ )
- {
- QModelIndex idx = m_proxyModel->index( i, j );
- if ( !viewRect.contains( visualRect( idx ) ) )
- {
- done = true;
- break;
- }
-
- started = true;
- done = false;
-
- if ( !m_model->getCover( m_proxyModel->mapToSource( idx ) ) )
- break;
- }
- }
-}
-
-
void
AlbumView::paintEvent( QPaintEvent* event )
{
diff --git a/src/libtomahawk/playlist/albumview.h b/src/libtomahawk/playlist/albumview.h
index 993a2fea7..61cc14d43 100644
--- a/src/libtomahawk/playlist/albumview.h
+++ b/src/libtomahawk/playlist/albumview.h
@@ -53,7 +53,7 @@ public:
void setModel( QAbstractItemModel* model );
virtual QWidget* widget() { return this; }
- virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->getPlaylistInterface(); }
+ virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->playlistInterface(); }
virtual QString title() const { return m_model->title(); }
virtual QString description() const { return m_model->description(); }
@@ -76,9 +76,6 @@ private slots:
void onFilterChanged( const QString& filter );
- void onViewChanged();
- void onScrollTimeout();
-
private:
AlbumModel* m_model;
AlbumProxyModel* m_proxyModel;
@@ -88,8 +85,6 @@ private:
bool m_inited;
bool m_autoFitItems;
-
- QTimer m_timer;
};
#endif // ALBUMVIEW_H
diff --git a/src/libtomahawk/playlist/artistview.cpp b/src/libtomahawk/playlist/artistview.cpp
index 929905f39..808b6c8c5 100644
--- a/src/libtomahawk/playlist/artistview.cpp
+++ b/src/libtomahawk/playlist/artistview.cpp
@@ -80,12 +80,6 @@ ArtistView::ArtistView( QWidget* parent )
setFont( f );
#endif
- m_timer.setInterval( SCROLL_TIMEOUT );
-
- connect( verticalScrollBar(), SIGNAL( rangeChanged( int, int ) ), SLOT( onViewChanged() ) );
- connect( verticalScrollBar(), SIGNAL( valueChanged( int ) ), SLOT( onViewChanged() ) );
- connect( &m_timer, SIGNAL( timeout() ), SLOT( onScrollTimeout() ) );
-
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
connect( this, SIGNAL( customContextMenuRequested( const QPoint& ) ), SLOT( onCustomContextMenu( const QPoint& ) ) );
connect( m_contextMenu, SIGNAL( triggered( int ) ), SLOT( onMenuTriggered( int ) ) );
@@ -135,7 +129,6 @@ ArtistView::setTreeModel( TreeModel* model )
connect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onItemCountChanged( unsigned int ) ) );
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
- connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) );
guid(); // this will set the guid on the header
@@ -188,7 +181,7 @@ ArtistView::onItemActivated( const QModelIndex& index )
else if ( !item->result().isNull() && item->result()->isOnline() )
{
m_model->setCurrentItem( item->index );
- AudioEngine::instance()->playItem( m_proxyModel->getPlaylistInterface(), item->result() );
+ AudioEngine::instance()->playItem( m_proxyModel->playlistInterface(), item->result() );
}
}
}
@@ -248,9 +241,9 @@ ArtistView::onFilterChanged( const QString& )
if ( selectedIndexes().count() )
scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter );
- if ( !proxyModel()->getPlaylistInterface()->filter().isEmpty() && !proxyModel()->getPlaylistInterface()->trackCount() && model()->trackCount() )
+ if ( !proxyModel()->playlistInterface()->filter().isEmpty() && !proxyModel()->playlistInterface()->trackCount() && model()->trackCount() )
{
- m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->getPlaylistInterface()->filter() ) );
+ m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->playlistInterface()->filter() ) );
m_overlay->show();
}
else
@@ -307,45 +300,6 @@ ArtistView::startDrag( Qt::DropActions supportedActions )
}
-void
-ArtistView::onViewChanged()
-{
- if ( m_timer.isActive() )
- m_timer.stop();
-
- m_timer.start();
-}
-
-
-void
-ArtistView::onScrollTimeout()
-{
- qDebug() << Q_FUNC_INFO;
- if ( m_timer.isActive() )
- m_timer.stop();
-
- QModelIndex left = indexAt( viewport()->rect().topLeft() );
- while ( left.isValid() && left.parent().isValid() )
- left = left.parent();
-
- QModelIndex right = indexAt( viewport()->rect().bottomLeft() );
- while ( right.isValid() && right.parent().isValid() )
- right = right.parent();
-
- int max = m_proxyModel->getPlaylistInterface()->trackCount();
- if ( right.isValid() )
- max = right.row() + 1;
-
- if ( !max )
- return;
-
- for ( int i = left.row(); i < max; i++ )
- {
- m_model->getCover( m_proxyModel->mapToSource( m_proxyModel->index( i, 0 ) ) );
- }
-}
-
-
void
ArtistView::onCustomContextMenu( const QPoint& pos )
{
diff --git a/src/libtomahawk/playlist/artistview.h b/src/libtomahawk/playlist/artistview.h
index e67ef37c3..8167f9b73 100644
--- a/src/libtomahawk/playlist/artistview.h
+++ b/src/libtomahawk/playlist/artistview.h
@@ -62,7 +62,7 @@ public:
void setTreeModel( TreeModel* model );
virtual QWidget* widget() { return this; }
- virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->getPlaylistInterface(); }
+ virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->playlistInterface(); }
virtual QString title() const { return m_model->title(); }
virtual QString description() const { return m_model->description(); }
@@ -95,8 +95,6 @@ private slots:
void onItemCountChanged( unsigned int items );
void onFilterChanged( const QString& filter );
void onFilteringStarted();
- void onViewChanged();
- void onScrollTimeout();
void onCustomContextMenu( const QPoint& pos );
void onMenuTriggered( int action );
@@ -115,7 +113,6 @@ private:
Tomahawk::ContextMenu* m_contextMenu;
bool m_showModes;
- QTimer m_timer;
mutable QString m_guid;
};
diff --git a/src/libtomahawk/playlist/collectionproxymodel.cpp b/src/libtomahawk/playlist/collectionproxymodel.cpp
index 1f5df9c7d..6fe08f52e 100644
--- a/src/libtomahawk/playlist/collectionproxymodel.cpp
+++ b/src/libtomahawk/playlist/collectionproxymodel.cpp
@@ -33,7 +33,7 @@ CollectionProxyModel::CollectionProxyModel( QObject* parent )
}
Tomahawk::playlistinterface_ptr
-CollectionProxyModel::getPlaylistInterface()
+CollectionProxyModel::playlistInterface()
{
if ( m_playlistInterface.isNull() )
{
diff --git a/src/libtomahawk/playlist/collectionproxymodel.h b/src/libtomahawk/playlist/collectionproxymodel.h
index 898f05095..872aaf6fa 100644
--- a/src/libtomahawk/playlist/collectionproxymodel.h
+++ b/src/libtomahawk/playlist/collectionproxymodel.h
@@ -32,7 +32,7 @@ public:
explicit CollectionProxyModel( QObject* parent = 0 );
virtual ~CollectionProxyModel() {}
- virtual Tomahawk::playlistinterface_ptr getPlaylistInterface();
+ virtual Tomahawk::playlistinterface_ptr playlistInterface();
};
diff --git a/src/libtomahawk/playlist/collectionview.cpp b/src/libtomahawk/playlist/collectionview.cpp
index cf038d3d5..d8e1d11e1 100644
--- a/src/libtomahawk/playlist/collectionview.cpp
+++ b/src/libtomahawk/playlist/collectionview.cpp
@@ -60,6 +60,7 @@ CollectionView::setTrackModel( TrackModel* model )
setColumnHidden( TrackModel::Score, true ); // Hide score column per default
setColumnHidden( TrackModel::Origin, true ); // Hide origin column per default
+ setColumnHidden( TrackModel::Composer, true ); //Hide composer column per default
setGuid( QString( "collectionview/%1" ).arg( model->columnCount() ) );
sortByColumn( TrackModel::Artist, Qt::AscendingOrder );
diff --git a/src/libtomahawk/playlist/collectionview.h b/src/libtomahawk/playlist/collectionview.h
index ff7471e97..916364099 100644
--- a/src/libtomahawk/playlist/collectionview.h
+++ b/src/libtomahawk/playlist/collectionview.h
@@ -39,7 +39,7 @@ public:
virtual void setModel( QAbstractItemModel* model );
virtual QWidget* widget() { return this; }
- virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->getPlaylistInterface(); }
+ virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->playlistInterface(); }
virtual QString title() const { return model()->title(); }
virtual QString description() const { return model()->description(); }
diff --git a/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp b/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp
index 2cf47020f..b4a07acba 100644
--- a/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp
+++ b/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp
@@ -203,7 +203,7 @@ DynamicWidget::onRevisionLoaded( const Tomahawk::DynamicPlaylistRevision& rev )
Tomahawk::playlistinterface_ptr
DynamicWidget::playlistInterface() const
{
- return m_view->proxyModel()->getPlaylistInterface();
+ return m_view->proxyModel()->playlistInterface();
}
@@ -243,7 +243,7 @@ DynamicWidget::layoutFloatingWidgets()
void
DynamicWidget::playlistChanged( Tomahawk::playlistinterface_ptr pl )
{
- if( pl == m_view->proxyModel()->getPlaylistInterface() ) { // same playlist
+ if( pl == m_view->proxyModel()->playlistInterface() ) { // same playlist
m_activePlaylist = true;
} else {
m_activePlaylist = false;
diff --git a/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.cpp b/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.cpp
index d00059a7e..31d854dc4 100644
--- a/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.cpp
+++ b/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.cpp
@@ -42,10 +42,11 @@ LoadingSpinner::LoadingSpinner( QWidget* parent )
connect( m_showHide, SIGNAL( finished() ), this, SLOT( hideFinished() ) );
m_anim = new QMovie( RESPATH "/images/loading-animation.gif" );
+ m_anim->jumpToNextFrame();
connect( m_anim, SIGNAL( frameChanged( int ) ), this, SLOT( update() ) );
- resize( 31, 31 );
+ resize( m_anim->currentPixmap().size() );
setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
hide();
}
@@ -96,7 +97,7 @@ LoadingSpinner::hideFinished()
QSize
LoadingSpinner::sizeHint() const
{
- return QSize( 31, 31 );
+ return m_anim->currentPixmap().size();
}
diff --git a/src/libtomahawk/playlist/playlistitemdelegate.cpp b/src/libtomahawk/playlist/playlistitemdelegate.cpp
index c1ba1b8b9..ba932a8c1 100644
--- a/src/libtomahawk/playlist/playlistitemdelegate.cpp
+++ b/src/libtomahawk/playlist/playlistitemdelegate.cpp
@@ -56,9 +56,6 @@ PlaylistItemDelegate::PlaylistItemDelegate( TrackView* parent, TrackProxyModel*
m_bottomOption = QTextOption( Qt::AlignBottom );
m_bottomOption.setWrapMode( QTextOption::NoWrap );
- m_centerOption = QTextOption( Qt::AlignVCenter );
- m_centerOption.setWrapMode( QTextOption::NoWrap );
-
m_defaultAvatar = TomahawkUtils::createAvatarFrame( QPixmap( RESPATH "images/user-avatar.png" ) );
}
@@ -252,6 +249,9 @@ PlaylistItemDelegate::paintDetailed( QPainter* painter, const QStyleOptionViewIt
TrackModelItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) );
Q_ASSERT( item );
+ QTextOption textOption( Qt::AlignVCenter | (Qt::Alignment)index.data( Qt::TextAlignmentRole ).toUInt() );
+ textOption.setWrapMode( QTextOption::NoWrap );
+
QStyleOptionViewItemV4 opt = option;
prepareStyleOption( &opt, index, item );
opt.text.clear();
@@ -294,27 +294,25 @@ PlaylistItemDelegate::paintDetailed( QPainter* painter, const QStyleOptionViewIt
}
else if ( item->isPlaying() )
{
+ QRect r = opt.rect.adjusted( 3, 0, 0, 0 );
+
+ // Paint Now Playing Speaker Icon
+ if ( m_view->header()->visualIndex( index.column() ) == 0 )
{
- QRect r = opt.rect.adjusted( 3, 0, 0, 0 );
-
- // Paint Now Playing Speaker Icon
- if ( m_view->header()->visualIndex( index.column() ) == 0 )
- {
- r.adjust( 0, 0, 0, -3 );
- painter->drawPixmap( r.adjusted( 3, 1, 18 - r.width(), 1 ), m_nowPlayingIcon );
- r.adjust( 25, 0, 0, 3 );
- }
-
- painter->setPen( opt.palette.text().color() );
- QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, r.width() - 3 );
- painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, m_centerOption );
+ r.adjust( 0, 0, 0, -3 );
+ painter->drawPixmap( r.adjusted( 3, 1, 18 - r.width(), 1 ), m_nowPlayingIcon );
+ r.adjust( 25, 0, 0, 3 );
}
+
+ painter->setPen( opt.palette.text().color() );
+ QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, r.width() - 3 );
+ painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, textOption );
}
else
{
painter->setPen( opt.palette.text().color() );
- QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, opt.rect.width() - 3 );
- painter->drawText( opt.rect.adjusted( 3, 1, 0, 0 ), text, m_centerOption );
+ QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, opt.rect.width() - 6 );
+ painter->drawText( opt.rect.adjusted( 3, 1, -3, 0 ), text, textOption );
}
painter->restore();
diff --git a/src/libtomahawk/playlist/playlistitemdelegate.h b/src/libtomahawk/playlist/playlistitemdelegate.h
index 5bdf26c71..905a9fe3a 100644
--- a/src/libtomahawk/playlist/playlistitemdelegate.h
+++ b/src/libtomahawk/playlist/playlistitemdelegate.h
@@ -59,7 +59,6 @@ private:
mutable QPixmap m_arrowIcon;
QTextOption m_topOption;
- QTextOption m_centerOption;
QTextOption m_bottomOption;
TrackView* m_view;
diff --git a/src/libtomahawk/playlist/playlistmodel.cpp b/src/libtomahawk/playlist/playlistmodel.cpp
index 99cf1a3a4..4cd5a2b59 100644
--- a/src/libtomahawk/playlist/playlistmodel.cpp
+++ b/src/libtomahawk/playlist/playlistmodel.cpp
@@ -152,7 +152,7 @@ PlaylistModel::append( const Tomahawk::album_ptr& album )
m_isTemporary = true;
}
- append( album->getPlaylistInterface()->tracks() );
+ append( album->playlistInterface()->tracks() );
}
@@ -172,7 +172,7 @@ PlaylistModel::append( const Tomahawk::artist_ptr& artist )
m_isTemporary = true;
}
- append( artist->getPlaylistInterface()->tracks() );
+ append( artist->playlistInterface()->tracks() );
}
diff --git a/src/libtomahawk/playlist/playlistproxymodel.cpp b/src/libtomahawk/playlist/playlistproxymodel.cpp
index ded13bd95..c7fb24a1e 100644
--- a/src/libtomahawk/playlist/playlistproxymodel.cpp
+++ b/src/libtomahawk/playlist/playlistproxymodel.cpp
@@ -28,7 +28,7 @@ PlaylistProxyModel::PlaylistProxyModel( QObject* parent )
}
Tomahawk::playlistinterface_ptr
-PlaylistProxyModel::getPlaylistInterface()
+PlaylistProxyModel::playlistInterface()
{
if ( m_playlistInterface.isNull() )
{
diff --git a/src/libtomahawk/playlist/playlistproxymodel.h b/src/libtomahawk/playlist/playlistproxymodel.h
index b7e1610db..2d0855054 100644
--- a/src/libtomahawk/playlist/playlistproxymodel.h
+++ b/src/libtomahawk/playlist/playlistproxymodel.h
@@ -31,7 +31,7 @@ public:
explicit PlaylistProxyModel( QObject* parent = 0 );
virtual ~PlaylistProxyModel() {}
- virtual Tomahawk::playlistinterface_ptr getPlaylistInterface();
+ virtual Tomahawk::playlistinterface_ptr playlistInterface();
};
#endif // PLAYLISTPROXYMODEL_H
diff --git a/src/libtomahawk/playlist/playlistview.cpp b/src/libtomahawk/playlist/playlistview.cpp
index 2a4815b7e..a69e5b92e 100644
--- a/src/libtomahawk/playlist/playlistview.cpp
+++ b/src/libtomahawk/playlist/playlistview.cpp
@@ -62,6 +62,7 @@ PlaylistView::setPlaylistModel( PlaylistModel* model )
TrackView::setTrackModel( m_model );
setColumnHidden( TrackModel::Age, true ); // Hide age column per default
+ setColumnHidden( TrackModel::Composer, true ); // Hide composer column per default
if ( guid().isEmpty() )
{
diff --git a/src/libtomahawk/playlist/playlistview.h b/src/libtomahawk/playlist/playlistview.h
index f89836fc3..45169fdf8 100644
--- a/src/libtomahawk/playlist/playlistview.h
+++ b/src/libtomahawk/playlist/playlistview.h
@@ -38,7 +38,7 @@ public:
virtual void setModel( QAbstractItemModel* model );
virtual QWidget* widget() { return this; }
- virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->getPlaylistInterface(); }
+ virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->playlistInterface(); }
virtual bool showFilter() const { return true; }
diff --git a/src/libtomahawk/playlist/queueproxymodel.cpp b/src/libtomahawk/playlist/queueproxymodel.cpp
index 718285fbe..fcfcb8cd1 100644
--- a/src/libtomahawk/playlist/queueproxymodel.cpp
+++ b/src/libtomahawk/playlist/queueproxymodel.cpp
@@ -32,7 +32,7 @@ QueueProxyModel::QueueProxyModel( TrackView* parent )
qDebug() << Q_FUNC_INFO;
connect( parent, SIGNAL( itemActivated( QModelIndex ) ), this, SLOT( onIndexActivated( QModelIndex ) ) );
- connect( getPlaylistInterface().data(), SIGNAL( sourceTrackCountChanged( unsigned int ) ), this, SLOT( onTrackCountChanged( unsigned int ) ) );
+ connect( playlistInterface().data(), SIGNAL( sourceTrackCountChanged( unsigned int ) ), this, SLOT( onTrackCountChanged( unsigned int ) ) );
}
@@ -58,7 +58,7 @@ QueueProxyModel::onTrackCountChanged( unsigned int count )
Tomahawk::playlistinterface_ptr
-QueueProxyModel::getPlaylistInterface()
+QueueProxyModel::playlistInterface()
{
if ( m_playlistInterface.isNull() )
{
diff --git a/src/libtomahawk/playlist/queueproxymodel.h b/src/libtomahawk/playlist/queueproxymodel.h
index 5197d443a..9e735a3f9 100644
--- a/src/libtomahawk/playlist/queueproxymodel.h
+++ b/src/libtomahawk/playlist/queueproxymodel.h
@@ -34,7 +34,7 @@ public:
explicit QueueProxyModel( TrackView* parent = 0 );
virtual ~QueueProxyModel();
- virtual Tomahawk::playlistinterface_ptr getPlaylistInterface();
+ virtual Tomahawk::playlistinterface_ptr playlistInterface();
private slots:
void onIndexActivated( const QModelIndex& index );
diff --git a/src/libtomahawk/playlist/queueproxymodelplaylistinterface.h b/src/libtomahawk/playlist/queueproxymodelplaylistinterface.h
index 85c9101c6..142764d9c 100644
--- a/src/libtomahawk/playlist/queueproxymodelplaylistinterface.h
+++ b/src/libtomahawk/playlist/queueproxymodelplaylistinterface.h
@@ -21,6 +21,7 @@
#include "playlistproxymodelplaylistinterface.h"
+#include "result.h"
#include "dllmacro.h"
class QueueProxyModel;
diff --git a/src/libtomahawk/playlist/queueview.ui b/src/libtomahawk/playlist/queueview.ui
index 389406e7a..e22d6c881 100644
--- a/src/libtomahawk/playlist/queueview.ui
+++ b/src/libtomahawk/playlist/queueview.ui
@@ -38,7 +38,7 @@
true
- Open Queue
+ Show Queue
Qt::AlignCenter
diff --git a/src/libtomahawk/playlist/trackheader.cpp b/src/libtomahawk/playlist/trackheader.cpp
index 28440f3eb..99fd2900b 100644
--- a/src/libtomahawk/playlist/trackheader.cpp
+++ b/src/libtomahawk/playlist/trackheader.cpp
@@ -27,7 +27,7 @@ TrackHeader::TrackHeader( TrackView* parent )
, m_parent( parent )
{
QList< double > columnWeights;
- columnWeights << 0.18 << 0.18 << 0.17 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.10; // << 0.05;
+ columnWeights << 0.16 << 0.16 << 0.14 << 0.12 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.09; // << 0.03;
setDefaultColumnWeights( columnWeights );
}
diff --git a/src/libtomahawk/playlist/trackmodel.cpp b/src/libtomahawk/playlist/trackmodel.cpp
index 6461471b4..a9b2c8e9f 100644
--- a/src/libtomahawk/playlist/trackmodel.cpp
+++ b/src/libtomahawk/playlist/trackmodel.cpp
@@ -93,7 +93,7 @@ TrackModel::columnCount( const QModelIndex& parent ) const
case Detailed:
default:
- return 11;
+ return 12;
break;
}
}
@@ -136,6 +136,11 @@ TrackModel::data( const QModelIndex& index, int role ) const
return QSize( 0, 18 );
}
+ if ( role == Qt::TextAlignmentRole )
+ {
+ return QVariant( columnAlignment( index.column() ) );
+ }
+
if ( role == StyleRole )
{
return m_style;
@@ -178,14 +183,17 @@ TrackModel::data( const QModelIndex& index, int role ) const
return query->results().first()->album()->name();
break;
+ case Composer:
+ if ( !query->results().first()->composer().isNull() )
+ return query->results().first()->composer()->name();
+ break;
+
case Duration:
return TomahawkUtils::timeToString( query->results().first()->duration() );
break;
case Bitrate:
- if ( query->results().first()->bitrate() == 0 )
- return QString();
- else
+ if ( query->results().first()->bitrate() > 0 )
return query->results().first()->bitrate();
break;
@@ -194,9 +202,7 @@ TrackModel::data( const QModelIndex& index, int role ) const
break;
case Year:
- if ( query->results().first()->year() == 0 )
- return QString();
- else
+ if ( query->results().first()->year() != 0 )
return query->results().first()->year();
break;
@@ -213,9 +219,16 @@ TrackModel::data( const QModelIndex& index, int role ) const
break;
case AlbumPos:
- if ( query->results().first()->albumpos() == 0 )
- return QString();
- return QString::number( query->results().first()->albumpos() );
+ QString tPos;
+ if ( query->results().first()->albumpos() != 0 )
+ {
+ tPos = QString::number( query->results().first()->albumpos() );
+ if( query->results().first()->discnumber() == 0 )
+ return tPos;
+ else
+ return QString( "%1.%2" ).arg( QString::number( query->results().first()->discnumber() ) )
+ .arg( tPos );
+ }
break;
}
}
@@ -230,12 +243,17 @@ TrackModel::headerData( int section, Qt::Orientation orientation, int role ) con
Q_UNUSED( orientation );
QStringList headers;
- headers << tr( "Artist" ) << tr( "Title" ) << tr( "Album" ) << tr( "Track" ) << tr( "Duration" ) << tr( "Bitrate" ) << tr( "Age" ) << tr( "Year" ) << tr( "Size" ) << tr( "Origin" ) << tr( "Score" );
+ headers << tr( "Artist" ) << tr( "Title" ) << tr( "Composer" ) << tr( "Album" ) << tr( "Track" ) << tr( "Duration" ) << tr( "Bitrate" ) << tr( "Age" ) << tr( "Year" ) << tr( "Size" ) << tr( "Origin" ) << tr( "Score" );
if ( role == Qt::DisplayRole && section >= 0 )
{
return headers.at( section );
}
+ if ( role == Qt::TextAlignmentRole )
+ {
+ return QVariant( columnAlignment( section ) );
+ }
+
return QVariant();
}
@@ -534,3 +552,23 @@ TrackModel::setStyle( TrackModel::TrackItemStyle style )
{
m_style = style;
}
+
+
+Qt::Alignment
+TrackModel::columnAlignment( int column ) const
+{
+ switch( column )
+ {
+ case Age:
+ case AlbumPos:
+ case Bitrate:
+ case Duration:
+ case Filesize:
+ case Year:
+ return Qt::AlignHCenter;
+ break;
+
+ default:
+ return Qt::AlignLeft;
+ }
+}
diff --git a/src/libtomahawk/playlist/trackmodel.h b/src/libtomahawk/playlist/trackmodel.h
index 1850d541a..0de4ee1db 100644
--- a/src/libtomahawk/playlist/trackmodel.h
+++ b/src/libtomahawk/playlist/trackmodel.h
@@ -44,15 +44,16 @@ public:
enum Columns {
Artist = 0,
Track = 1,
- Album = 2,
- AlbumPos = 3,
- Duration = 4,
- Bitrate = 5,
- Age = 6,
- Year = 7,
- Filesize = 8,
- Origin = 9,
- Score = 10,
+ Composer = 2,
+ Album = 3,
+ AlbumPos = 4,
+ Duration = 5,
+ Bitrate = 6,
+ Age = 7,
+ Year = 8,
+ Filesize = 9,
+ Origin = 10,
+ Score = 11
};
explicit TrackModel( QObject* parent = 0 );
@@ -135,6 +136,8 @@ private slots:
void onPlaybackStopped();
private:
+ Qt::Alignment columnAlignment( int column ) const;
+
TrackModelItem* m_rootItem;
QPersistentModelIndex m_currentIndex;
Tomahawk::QID m_currentUuid;
diff --git a/src/libtomahawk/playlist/trackproxymodel.cpp b/src/libtomahawk/playlist/trackproxymodel.cpp
index d78073df3..6b42a6051 100644
--- a/src/libtomahawk/playlist/trackproxymodel.cpp
+++ b/src/libtomahawk/playlist/trackproxymodel.cpp
@@ -55,7 +55,7 @@ TrackProxyModel::setSourceTrackModel( TrackModel* sourceModel )
m_model = sourceModel;
if ( m_model && m_model->metaObject()->indexOfSignal( "trackCountChanged(uint)" ) > -1 )
- connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), getPlaylistInterface().data(), SIGNAL( sourceTrackCountChanged( unsigned int ) ) );
+ connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), playlistInterface().data(), SIGNAL( sourceTrackCountChanged( unsigned int ) ) );
QSortFilterProxyModel::setSourceModel( m_model );
}
@@ -177,6 +177,7 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c
QString track1 = q1->track();
QString track2 = q2->track();
unsigned int albumpos1 = 0, albumpos2 = 0;
+ unsigned int discnumber1 = 0, discnumber2 = 0;
unsigned int bitrate1 = 0, bitrate2 = 0;
unsigned int mtime1 = 0, mtime2 = 0;
unsigned int size1 = 0, size2 = 0;
@@ -189,6 +190,7 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c
album1 = r->album()->name();
track1 = r->track();
albumpos1 = r->albumpos();
+ discnumber1 = r->discnumber();
bitrate1 = r->bitrate();
mtime1 = r->modificationTime();
id1 = r->trackId();
@@ -201,6 +203,7 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c
album2 = r->album()->name();
track2 = r->track();
albumpos2 = r->albumpos();
+ discnumber2 = r->discnumber();
bitrate2 = r->bitrate();
mtime2 = r->modificationTime();
id2 = r->trackId();
@@ -220,10 +223,15 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c
{
if ( album1 == album2 )
{
- if ( albumpos1 == albumpos2 )
- return id1 < id2;
+ if( discnumber1 == discnumber2 )
+ {
+ if ( albumpos1 == albumpos2 )
+ return id1 < id2;
- return albumpos1 < albumpos2;
+ return albumpos1 < albumpos2;
+ }
+
+ return discnumber1 < discnumber2;
}
return QString::localeAwareCompare( album1, album2 ) < 0;
@@ -235,10 +243,15 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c
{
if ( album1 == album2 )
{
- if ( albumpos1 == albumpos2 )
- return id1 < id2;
+ if( discnumber1 == discnumber2 )
+ {
+ if ( albumpos1 == albumpos2 )
+ return id1 < id2;
- return albumpos1 < albumpos2;
+ return albumpos1 < albumpos2;
+ }
+
+ return discnumber1 < discnumber2;
}
return QString::localeAwareCompare( album1, album2 ) < 0;
@@ -275,7 +288,7 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c
Tomahawk::playlistinterface_ptr
-TrackProxyModel::getPlaylistInterface()
+TrackProxyModel::playlistInterface()
{
if ( m_playlistInterface.isNull() )
{
diff --git a/src/libtomahawk/playlist/trackproxymodel.h b/src/libtomahawk/playlist/trackproxymodel.h
index 18f3a127a..9d581d279 100644
--- a/src/libtomahawk/playlist/trackproxymodel.h
+++ b/src/libtomahawk/playlist/trackproxymodel.h
@@ -52,7 +52,7 @@ public:
virtual TrackModelItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
- virtual Tomahawk::playlistinterface_ptr getPlaylistInterface();
+ virtual Tomahawk::playlistinterface_ptr playlistInterface();
signals:
void filterChanged( const QString& filter );
diff --git a/src/libtomahawk/playlist/trackproxymodelplaylistinterface.h b/src/libtomahawk/playlist/trackproxymodelplaylistinterface.h
index afd5bdfb0..94d85556d 100644
--- a/src/libtomahawk/playlist/trackproxymodelplaylistinterface.h
+++ b/src/libtomahawk/playlist/trackproxymodelplaylistinterface.h
@@ -55,7 +55,7 @@ public:
virtual bool shuffled() const { return m_shuffled; }
public slots:
- virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
+ virtual void setRepeatMode( Tomahawk::PlaylistInterface::RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); }
protected:
diff --git a/src/libtomahawk/playlist/trackview.cpp b/src/libtomahawk/playlist/trackview.cpp
index 0bbdcd5fe..7111cd68c 100644
--- a/src/libtomahawk/playlist/trackview.cpp
+++ b/src/libtomahawk/playlist/trackview.cpp
@@ -132,9 +132,6 @@ TrackView::setTrackModel( TrackModel* model )
m_proxyModel->setSourceTrackModel( m_model );
}
- if ( m_model && m_model->metaObject()->indexOfSignal( "itemSizeChanged(QModelIndex)" ) > -1 )
- connect( m_model, SIGNAL( itemSizeChanged( QModelIndex ) ), SLOT( onItemResized( QModelIndex ) ) );
-
connect( m_model, SIGNAL( loadingStarted() ), m_loadingSpinner, SLOT( fadeIn() ) );
connect( m_model, SIGNAL( loadingFinished() ), m_loadingSpinner, SLOT( fadeOut() ) );
@@ -182,7 +179,7 @@ TrackView::onItemActivated( const QModelIndex& index )
{
tDebug() << "Result activated:" << item->query()->toString() << item->query()->results().first()->url();
m_proxyModel->setCurrentIndex( index );
- AudioEngine::instance()->playItem( m_proxyModel->getPlaylistInterface(), item->query()->results().first() );
+ AudioEngine::instance()->playItem( m_proxyModel->playlistInterface(), item->query()->results().first() );
}
emit itemActivated( index );
@@ -369,9 +366,9 @@ TrackView::onFilterChanged( const QString& )
if ( selectedIndexes().count() )
scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter );
- if ( !proxyModel()->getPlaylistInterface()->filter().isEmpty() && !proxyModel()->getPlaylistInterface()->trackCount() && model()->trackCount() )
+ if ( !proxyModel()->playlistInterface()->filter().isEmpty() && !proxyModel()->playlistInterface()->trackCount() && model()->trackCount() )
{
- m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->getPlaylistInterface()->filter() ) );
+ m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->playlistInterface()->filter() ) );
m_overlay->show();
}
else
diff --git a/src/libtomahawk/playlist/treeheader.cpp b/src/libtomahawk/playlist/treeheader.cpp
index 346ec8985..d46ee3aa4 100644
--- a/src/libtomahawk/playlist/treeheader.cpp
+++ b/src/libtomahawk/playlist/treeheader.cpp
@@ -27,7 +27,7 @@ TreeHeader::TreeHeader( ArtistView* parent )
, m_parent( parent )
{
QList< double > columnWeights;
- columnWeights << 0.50 << 0.07 << 0.07 << 0.07 << 0.07 << 0.07; // << 0.12;
+ columnWeights << 0.42 << 0.12 << 0.07 << 0.07 << 0.07 << 0.07 << 0.07; // << 0.11;
setDefaultColumnWeights( columnWeights );
}
diff --git a/src/libtomahawk/playlist/treeitemdelegate.cpp b/src/libtomahawk/playlist/treeitemdelegate.cpp
index 6e1bef875..90fbe4aa7 100644
--- a/src/libtomahawk/playlist/treeitemdelegate.cpp
+++ b/src/libtomahawk/playlist/treeitemdelegate.cpp
@@ -152,8 +152,17 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
QRect r = option.rect.adjusted( 4, 4, -option.rect.width() + option.rect.height() - 4, -4 );
// painter->drawPixmap( r, QPixmap( RESPATH "images/cover-shadow.png" ) );
+ QPixmap cover;
+ if ( !item->album().isNull() )
+ {
+ cover.loadFromData( item->album()->cover() );
+ }
+ else if ( !item->artist().isNull() )
+ {
+ cover.loadFromData( item->artist()->cover() );
+ }
+
QPixmap scover;
- QPixmap cover = item->cover;
if ( cover.isNull() )
{
if ( !item->artist().isNull() )
diff --git a/src/libtomahawk/playlist/treemodel.cpp b/src/libtomahawk/playlist/treemodel.cpp
index d34e69821..24e3073e0 100644
--- a/src/libtomahawk/playlist/treemodel.cpp
+++ b/src/libtomahawk/playlist/treemodel.cpp
@@ -47,8 +47,6 @@ TreeModel::TreeModel( QObject* parent )
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
-
- connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
}
@@ -89,40 +87,6 @@ TreeModel::collection() const
}
-void
-TreeModel::getCover( const QModelIndex& index )
-{
- TreeModelItem* item = itemFromIndex( index );
- if ( !item->cover.isNull() )
- return;
-
- Tomahawk::InfoSystem::InfoStringHash trackInfo;
- Tomahawk::InfoSystem::InfoRequestData requestData;
-
- if ( !item->artist().isNull() )
- {
- trackInfo["artist"] = item->artist()->name();
- requestData.type = Tomahawk::InfoSystem::InfoArtistImages;
- }
- else if ( !item->album().isNull() )
- {
- trackInfo["artist"] = item->album()->artist()->name();
- trackInfo["album"] = item->album()->name();
- requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
- }
- else
- return;
-
- trackInfo["pptr"] = QString::number( (qlonglong)item );
- m_coverHash.insert( (qlonglong)item, index );
-
- requestData.caller = m_infoId;
- requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
- requestData.customData = QVariantMap();
- Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
-}
-
-
void
TreeModel::setCurrentItem( const QModelIndex& index )
{
@@ -238,8 +202,9 @@ int
TreeModel::columnCount( const QModelIndex& parent ) const
{
Q_UNUSED( parent );
+
if ( m_columnStyle == AllColumns )
- return 7;
+ return 8;
else if ( m_columnStyle == TrackOnly )
return 1;
@@ -307,6 +272,12 @@ TreeModel::data( const QModelIndex& index, int role ) const
else if ( !entry->result().isNull() )
{
const result_ptr& result = entry->result();
+ unsigned int discnumber = 0;
+ if ( !entry->query().isNull() )
+ discnumber = entry->query()->discnumber();
+ if ( discnumber == 0 )
+ discnumber = result->discnumber();
+
unsigned int albumpos = 0;
if ( !entry->query().isNull() )
albumpos = entry->query()->albumpos();
@@ -316,26 +287,25 @@ TreeModel::data( const QModelIndex& index, int role ) const
switch( index.column() )
{
case Name:
- return QString( "%1%2" ).arg( albumpos > 0 ? QString( "%1. ").arg( albumpos ) : QString() )
- .arg( result->track() );
+ return QString( "%1%2%3" ).arg( discnumber > 0 ? QString( "%1." ).arg( discnumber ) : QString() )
+ .arg( albumpos > 0 ? QString( "%1. ").arg( albumpos ) : QString() )
+ .arg( result->track() );
case Duration:
return TomahawkUtils::timeToString( result->duration() );
case Bitrate:
- if ( result->bitrate() == 0 )
- return QString();
- else
+ if ( result->bitrate() > 0 )
return result->bitrate();
+ break;
case Age:
return TomahawkUtils::ageToString( QDateTime::fromTime_t( result->modificationTime() ) );
case Year:
- if ( result->year() == 0 )
- return QString();
- else
+ if ( result->year() != 0 )
return result->year();
+ break;
case Filesize:
return TomahawkUtils::filesizeToString( result->size() );
@@ -346,6 +316,11 @@ TreeModel::data( const QModelIndex& index, int role ) const
case AlbumPosition:
return result->albumpos();
+ case Composer:
+ if ( !result->composer().isNull() )
+ return result->composer()->name();
+ break;
+
default:
return QVariant();
}
@@ -356,8 +331,9 @@ TreeModel::data( const QModelIndex& index, int role ) const
switch( index.column() )
{
case Name:
- return QString( "%1%2" ).arg( query->albumpos() > 0 ? QString( "%1. ").arg( query->albumpos() ) : QString() )
- .arg( query->track() );
+ return QString( "%1%2%3" ).arg( query->discnumber() > 0 ? QString( "%1." ).arg( query->discnumber() ) : QString() )
+ .arg( query->albumpos() > 0 ? QString( "%1. ").arg( query->albumpos() ) : QString() )
+ .arg( query->track() );
case AlbumPosition:
return entry->query()->albumpos();
@@ -375,7 +351,7 @@ QVariant
TreeModel::headerData( int section, Qt::Orientation orientation, int role ) const
{
QStringList headers;
- headers << tr( "Name" ) << tr( "Duration" ) << tr( "Bitrate" ) << tr( "Age" ) << tr( "Year" ) << tr( "Size" ) << tr( "Origin" );
+ headers << tr( "Name" ) << tr( "Composer" ) << tr( "Duration" ) << tr( "Bitrate" ) << tr( "Age" ) << tr( "Year" ) << tr( "Size" ) << tr( "Origin" );
if ( orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 )
{
return headers.at( section );
@@ -654,7 +630,7 @@ TreeModel::addTracks( const album_ptr& album, const QModelIndex& parent, bool au
if ( m_mode == DatabaseMode )
{
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( m_collection );
- cmd->setAlbum( album.data() );
+ cmd->setAlbum( album );
cmd->setData( QVariant( rows ) );
connect( cmd, SIGNAL( tracks( QList, QVariant ) ),
@@ -807,8 +783,6 @@ TreeModel::onAlbumsAdded( const QList& albums, const QModel
albumitem = new TreeModelItem( album, parentItem );
albumitem->index = createIndex( parentItem->children.count() - 1, 0, albumitem );
connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
-
- getCover( albumitem->index );
}
emit endInsertRows();
@@ -876,31 +850,6 @@ TreeModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QV
switch ( requestData.type )
{
- case Tomahawk::InfoSystem::InfoAlbumCoverArt:
- case Tomahawk::InfoSystem::InfoArtistImages:
- {
- Tomahawk::InfoSystem::InfoStringHash pptr = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
- QVariantMap returnedData = output.value< QVariantMap >();
- const QByteArray ba = returnedData["imgbytes"].toByteArray();
- if ( ba.length() )
- {
- QPixmap pm;
- pm.loadFromData( ba );
- bool ok;
- qlonglong p = pptr["pptr"].toLongLong( &ok );
- TreeModelItem* ai = itemFromIndex( m_coverHash.take( p ) );
- if ( !ai )
- return;
-
- if ( !pm.isNull() )
- ai->cover = pm;
-
- emit dataChanged( ai->index, ai->index.sibling( ai->index.row(), columnCount( QModelIndex() ) - 1 ) );
- }
-
- break;
- }
-
case Tomahawk::InfoSystem::InfoArtistReleases:
{
QVariantMap returnedData = output.value< QVariantMap >();
@@ -957,6 +906,11 @@ TreeModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QV
QStringList tracks = returnedData[ "tracks" ].toStringList();
QList ql;
+
+ //TODO: Figure out how to do this with a multi-disk album without breaking the
+ // current behaviour. I just know too little about InfoSystem to deal with
+ // it right now, I've only taken the liberty of adding Query::setDiscNumber
+ // which should make this easier. --Teo 11/2011
unsigned int trackNo = 1;
foreach ( const QString& trackName, tracks )
@@ -997,13 +951,6 @@ TreeModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QV
}
-void
-TreeModel::infoSystemFinished( QString target )
-{
- Q_UNUSED( target );
-}
-
-
void
TreeModel::onPlaybackStarted( const Tomahawk::result_ptr& result )
{
diff --git a/src/libtomahawk/playlist/treemodel.h b/src/libtomahawk/playlist/treemodel.h
index ecdd4946c..53578bc8b 100644
--- a/src/libtomahawk/playlist/treemodel.h
+++ b/src/libtomahawk/playlist/treemodel.h
@@ -44,6 +44,7 @@ Q_OBJECT
public:
enum Columns {
Name = 0,
+ Composer,
Duration,
Bitrate,
Age,
@@ -97,8 +98,6 @@ public:
void addAlbums( const Tomahawk::artist_ptr& artist, const QModelIndex& parent, bool autoRefetch = false );
void addTracks( const Tomahawk::album_ptr& album, const QModelIndex& parent, bool autoRefetch = false );
- void getCover( const QModelIndex& index );
-
ColumnStyle columnStyle() const { return m_columnStyle; }
void setColumnStyle( ColumnStyle style );
@@ -150,7 +149,6 @@ private slots:
void onTracksFound( const QList& tracks, const QVariant& variant );
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
- void infoSystemFinished( QString target );
void onPlaybackStarted( const Tomahawk::result_ptr& result );
void onPlaybackStopped();
@@ -174,7 +172,6 @@ private:
QList m_artistsFilter;
Tomahawk::collection_ptr m_collection;
- QHash m_coverHash;
QList m_receivedInfoData;
};
diff --git a/src/libtomahawk/playlist/treemodelitem.cpp b/src/libtomahawk/playlist/treemodelitem.cpp
index 5d0be385e..212a1e0d4 100644
--- a/src/libtomahawk/playlist/treemodelitem.cpp
+++ b/src/libtomahawk/playlist/treemodelitem.cpp
@@ -82,6 +82,8 @@ TreeModelItem::TreeModelItem( const Tomahawk::album_ptr& album, TreeModelItem* p
}
toberemoved = false;
+
+ connect( album.data(), SIGNAL( updated() ), SIGNAL( dataChanged() ) );
}
@@ -109,6 +111,8 @@ TreeModelItem::TreeModelItem( const Tomahawk::artist_ptr& artist, TreeModelItem*
}
toberemoved = false;
+
+ connect( artist.data(), SIGNAL( updated() ), SIGNAL( dataChanged() ) );
}
diff --git a/src/libtomahawk/playlist/treemodelitem.h b/src/libtomahawk/playlist/treemodelitem.h
index 7f6582f58..ab481391c 100644
--- a/src/libtomahawk/playlist/treemodelitem.h
+++ b/src/libtomahawk/playlist/treemodelitem.h
@@ -48,8 +48,6 @@ public:
bool isPlaying() { return m_isPlaying; }
void setIsPlaying( bool b ) { m_isPlaying = b; emit dataChanged(); }
- void setCover( const QPixmap& cover ) { this->cover = cover; emit dataChanged(); }
-
QString name() const;
QString artistName() const;
QString albumName() const;
@@ -60,7 +58,6 @@ public:
int childCount;
QPersistentModelIndex index;
QAbstractItemModel* model;
- QPixmap cover;
bool toberemoved;
bool fetchingMore;
diff --git a/src/libtomahawk/playlist/treeproxymodel.cpp b/src/libtomahawk/playlist/treeproxymodel.cpp
index 10ef415fb..e9494f32e 100644
--- a/src/libtomahawk/playlist/treeproxymodel.cpp
+++ b/src/libtomahawk/playlist/treeproxymodel.cpp
@@ -41,6 +41,7 @@ TreeProxyModel::TreeProxyModel( QObject* parent )
setSourceTreeModel( 0 );
}
+
QPersistentModelIndex
TreeProxyModel::currentIndex() const
{
@@ -109,6 +110,7 @@ TreeProxyModel::onModelReset()
m_albumsFilter.clear();
}
+
void
TreeProxyModel::newFilterFromPlaylistInterface( const QString &pattern )
{
@@ -142,6 +144,7 @@ TreeProxyModel::newFilterFromPlaylistInterface( const QString &pattern )
}
}
+
void
TreeProxyModel::onFilterArtists( const QList& artists )
{
@@ -286,20 +289,39 @@ TreeProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) co
unsigned int albumpos1 = 0;
unsigned int albumpos2 = 0;
+ unsigned int discnumber1 = 0;
+ unsigned int discnumber2 = 0;
if ( !p1->query().isNull() )
+ {
albumpos1 = p1->query()->albumpos();
+ discnumber1 = p1->query()->discnumber();
+ }
if ( !p2->query().isNull() )
+ {
albumpos2 = p2->query()->albumpos();
+ discnumber2 = p2->query()->discnumber();
+ }
+
if ( albumpos1 == 0 && !p1->result().isNull() )
albumpos1 = p1->result()->albumpos();
+ if ( discnumber1 == 0 && !p1->result().isNull() )
+ discnumber1 = p1->result()->discnumber();
+
if ( albumpos2 == 0 && !p2->result().isNull() )
albumpos2 = p2->result()->albumpos();
+ if ( discnumber2 == 0 && !p2->result().isNull() )
+ discnumber2 = p2->result()->discnumber();
const QString& lefts = textForItem( p1 );
const QString& rights = textForItem( p2 );
- if ( albumpos1 != albumpos2 )
- return albumpos1 < albumpos2;
+ if( discnumber1 != discnumber2 )
+ return discnumber1 < discnumber2;
+ else
+ {
+ if ( albumpos1 != albumpos2 )
+ return albumpos1 < albumpos2;
+ }
if ( lefts == rights )
return (qint64)&p1 < (qint64)&p2;
@@ -363,7 +385,7 @@ TreeProxyModel::textForItem( TreeModelItem* item ) const
Tomahawk::playlistinterface_ptr
-TreeProxyModel::getPlaylistInterface()
+TreeProxyModel::playlistInterface()
{
if ( m_playlistInterface.isNull() )
{
diff --git a/src/libtomahawk/playlist/treeproxymodel.h b/src/libtomahawk/playlist/treeproxymodel.h
index 6ce52785a..2aa7b0d27 100644
--- a/src/libtomahawk/playlist/treeproxymodel.h
+++ b/src/libtomahawk/playlist/treeproxymodel.h
@@ -57,7 +57,7 @@ public:
virtual TreeModelItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
- virtual Tomahawk::playlistinterface_ptr getPlaylistInterface();
+ virtual Tomahawk::playlistinterface_ptr playlistInterface();
signals:
void filterChanged( const QString& filter );
diff --git a/src/libtomahawk/playlist/treeproxymodelplaylistinterface.h b/src/libtomahawk/playlist/treeproxymodelplaylistinterface.h
index f38654981..4f6134f44 100644
--- a/src/libtomahawk/playlist/treeproxymodelplaylistinterface.h
+++ b/src/libtomahawk/playlist/treeproxymodelplaylistinterface.h
@@ -74,7 +74,7 @@ signals:
void nextTrackReady();
public slots:
- virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
+ virtual void setRepeatMode( Tomahawk::PlaylistInterface::RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); }
private:
diff --git a/src/libtomahawk/playlistinterface.cpp b/src/libtomahawk/playlistinterface.cpp
index 8c03d9df1..11d60ea3e 100644
--- a/src/libtomahawk/playlistinterface.cpp
+++ b/src/libtomahawk/playlistinterface.cpp
@@ -24,6 +24,7 @@ using namespace Tomahawk;
PlaylistInterface::PlaylistInterface ()
: QObject()
+ , m_latchMode( StayOnSong )
{
qRegisterMetaType( "Tomahawk::PlaylistInterface::RepeatMode" );
}
diff --git a/src/libtomahawk/playlistinterface.h b/src/libtomahawk/playlistinterface.h
index b125d8ae9..8f172a809 100644
--- a/src/libtomahawk/playlistinterface.h
+++ b/src/libtomahawk/playlistinterface.h
@@ -39,6 +39,7 @@ public:
enum SeekRestrictions { NoSeekRestrictions, NoSeek };
enum SkipRestrictions { NoSkipRestrictions, NoSkipForwards, NoSkipBackwards, NoSkip };
enum RetryMode { NoRetry, Retry };
+ enum LatchMode { StayOnSong, RealTime };
explicit PlaylistInterface();
virtual ~PlaylistInterface();
@@ -55,14 +56,20 @@ public:
virtual Tomahawk::result_ptr siblingItem( int itemsAway ) = 0;
virtual PlaylistInterface::RepeatMode repeatMode() const = 0;
+
virtual bool shuffled() const = 0;
+
virtual PlaylistInterface::ViewMode viewMode() const { return Unknown; }
+
virtual PlaylistInterface::SeekRestrictions seekRestrictions() const { return NoSeekRestrictions; }
virtual PlaylistInterface::SkipRestrictions skipRestrictions() const { return NoSkipRestrictions; }
virtual PlaylistInterface::RetryMode retryMode() const { return NoRetry; }
virtual quint32 retryInterval() const { return 30000; }
+ virtual PlaylistInterface::LatchMode latchMode() const { return m_latchMode; }
+ virtual void setLatchMode( PlaylistInterface::LatchMode latchMode ) { m_latchMode = latchMode; }
+
virtual QString filter() const { return m_filter; }
virtual void setFilter( const QString& pattern ) { m_filter = pattern; }
@@ -82,8 +89,12 @@ signals:
void shuffleModeChanged( bool enabled );
void trackCountChanged( unsigned int tracks );
void sourceTrackCountChanged( unsigned int tracks );
+ void latchModeChanged( Tomahawk::PlaylistInterface::LatchMode mode );
void nextTrackReady();
+protected:
+ LatchMode m_latchMode;
+
private:
Q_DISABLE_COPY( PlaylistInterface )
diff --git a/src/libtomahawk/playlistplaylistinterface.h b/src/libtomahawk/playlistplaylistinterface.h
index 94dcacd08..7de2dcef8 100644
--- a/src/libtomahawk/playlistplaylistinterface.h
+++ b/src/libtomahawk/playlistplaylistinterface.h
@@ -56,15 +56,6 @@ public:
virtual void setFilter( const QString& /*pattern*/ ) {}
-signals:
- void repeatModeChanged( PlaylistInterface::RepeatMode mode );
- void shuffleModeChanged( bool enabled );
-
- void trackCountChanged( unsigned int tracks );
- void sourceTrackCountChanged( unsigned int tracks );
-
- void nextTrackReady();
-
public slots:
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
virtual void setShuffled( bool ) {}
diff --git a/src/libtomahawk/query.cpp b/src/libtomahawk/query.cpp
index 11391d8b1..8df9cd6f7 100644
--- a/src/libtomahawk/query.cpp
+++ b/src/libtomahawk/query.cpp
@@ -25,6 +25,8 @@
#include "database/databasecommand_logplayback.h"
#include "database/databasecommand_playbackhistory.h"
#include "database/databasecommand_loadplaylistentries.h"
+#include "database/databasecommand_loadsocialactions.h"
+#include "database/databasecommand_socialaction.h"
#include "album.h"
#include "collection.h"
#include "pipeline.h"
@@ -36,10 +38,6 @@
using namespace Tomahawk;
-static QHash< QString, QWeakPointer< Query > > s_queries;
-static QMutex s_mutex;
-
-
query_ptr
Query::get( const QString& artist, const QString& track, const QString& album, const QID& qid, bool autoResolve )
{
@@ -47,11 +45,11 @@ Query::get( const QString& artist, const QString& track, const QString& album, c
autoResolve = false;
query_ptr q = query_ptr( new Query( artist, track, album, qid, autoResolve ) );
- QMutexLocker lock( &s_mutex );
- s_queries.insert( q->id(), q );
+ q->setWeakRef( q.toWeakRef() );
if ( autoResolve )
Pipeline::instance()->resolve( q );
+
return q;
}
@@ -59,10 +57,13 @@ Query::get( const QString& artist, const QString& track, const QString& album, c
query_ptr
Query::get( const QString& query, const QID& qid )
{
+
query_ptr q = query_ptr( new Query( query, qid ) );
+ q->setWeakRef( q.toWeakRef() );
if ( !qid.isEmpty() )
Pipeline::instance()->resolve( q );
+
return q;
}
@@ -72,6 +73,7 @@ Query::Query( const QString& artist, const QString& track, const QString& album,
, m_artist( artist )
, m_album( album )
, m_track( track )
+ , m_socialActionsLoaded( false )
{
init();
@@ -102,14 +104,7 @@ Query::Query( const QString& query, const QID& qid )
Query::~Query()
{
- if ( !id().isEmpty() )
- {
- QMutexLocker lock( &s_mutex );
- if ( s_queries.contains( id() ) )
- {
- s_queries.remove( id() );
- }
- }
+ m_ownRef.clear();
}
@@ -121,6 +116,7 @@ Query::init()
m_playable = false;
m_duration = -1;
m_albumpos = 0;
+ m_discnumber = 0;
updateSortNames();
}
@@ -132,12 +128,14 @@ Query::updateSortNames()
if ( isFullTextQuery() )
{
m_artistSortname = DatabaseImpl::sortname( m_fullTextQuery, true );
+ m_composerSortName = DatabaseImpl::sortname( m_composer, true );
m_albumSortname = DatabaseImpl::sortname( m_fullTextQuery );
m_trackSortname = m_albumSortname;
}
else
{
m_artistSortname = DatabaseImpl::sortname( m_artist, true );
+ m_composerSortName = DatabaseImpl::sortname( m_composer, true );
m_albumSortname = DatabaseImpl::sortname( m_album );
m_trackSortname = DatabaseImpl::sortname( m_track );
}
@@ -206,7 +204,9 @@ Query::refreshResults()
if ( m_resolveFinished )
{
m_resolveFinished = false;
- Pipeline::instance()->resolve( s_queries.value( id() ) );
+ query_ptr q = m_ownRef.toStrongRef();
+ if ( q )
+ Pipeline::instance()->resolve( q );
}
}
@@ -481,6 +481,99 @@ Query::playedBy() const
return m_playedBy;
}
+
+void
+Query::loadSocialActions()
+{
+ m_socialActionsLoaded = true;
+ query_ptr q = m_ownRef.toStrongRef();
+
+ DatabaseCommand_LoadSocialActions* cmd = new DatabaseCommand_LoadSocialActions( q );
+ connect( cmd, SIGNAL( finished() ), SLOT( onSocialActionsLoaded() ));
+ Database::instance()->enqueue( QSharedPointer(cmd) );
+}
+
+
+void
+Query::onSocialActionsLoaded()
+{
+ parseSocialActions();
+
+ emit socialActionsLoaded();
+}
+
+
+void
+Query::setAllSocialActions( const QList< SocialAction >& socialActions )
+{
+ m_allSocialActions = socialActions;
+}
+
+
+QList< SocialAction >
+Query::allSocialActions()
+{
+ return m_allSocialActions;
+}
+
+
+void
+Query::parseSocialActions()
+{
+ QListIterator< Tomahawk::SocialAction > it( m_allSocialActions );
+ unsigned int highestTimestamp = 0;
+
+ while ( it.hasNext() )
+ {
+ Tomahawk::SocialAction socialAction;
+ socialAction = it.next();
+ if ( socialAction.timestamp.toUInt() > highestTimestamp && socialAction.source.toInt() == SourceList::instance()->getLocal()->id() )
+ {
+ m_currentSocialActions[ socialAction.action.toString() ] = socialAction.value.toBool();
+ }
+ }
+}
+
+
+bool
+Query::loved()
+{
+ if ( m_socialActionsLoaded )
+ {
+ return m_currentSocialActions[ "Love" ].toBool();
+ }
+ else
+ {
+ loadSocialActions();
+ }
+
+ return false;
+}
+
+
+void
+Query::setLoved( bool loved )
+{
+ query_ptr q = m_ownRef.toStrongRef();
+ if ( q )
+ {
+ m_currentSocialActions[ "Loved" ] = loved;
+
+ Tomahawk::InfoSystem::InfoStringHash trackInfo;
+ trackInfo["title"] = track();
+ trackInfo["artist"] = artist();
+ trackInfo["album"] = album();
+
+ Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
+ id(), Tomahawk::InfoSystem::InfoLove,
+ QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ) );
+
+ DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction( q, QString( "Love" ), loved ? QString( "true" ) : QString( "false" ) );
+ Database::instance()->enqueue( QSharedPointer(cmd) );
+ }
+}
+
+
int
Query::levenshtein( const QString& source, const QString& target )
{
diff --git a/src/libtomahawk/query.h b/src/libtomahawk/query.h
index 610c28d26..8dfa3fd40 100644
--- a/src/libtomahawk/query.h
+++ b/src/libtomahawk/query.h
@@ -51,9 +51,6 @@ public:
static query_ptr get( const QString& artist, const QString& track, const QString& album, const QID& qid = QString(), bool autoResolve = true );
static query_ptr get( const QString& query, const QID& qid );
- explicit Query( const QString& artist, const QString& track, const QString& album, const QID& qid, bool autoResolve );
- explicit Query( const QString& query, const QID& qid );
-
virtual ~Query();
/// returns list of all results so far
@@ -82,11 +79,13 @@ public:
QList< QWeakPointer< Tomahawk::Resolver > > resolvedBy() const { return m_resolvers; }
void setArtist( const QString& artist ) { m_artist = artist; updateSortNames(); }
+ void setComposer( const QString& composer ) { m_composer = composer; updateSortNames(); }
void setAlbum( const QString& album ) { m_album = album; updateSortNames(); }
void setTrack( const QString& track ) { m_track = track; updateSortNames(); }
void setResultHint( const QString& resultHint ) { m_resultHint = resultHint; }
void setDuration( int duration ) { m_duration = duration; }
void setAlbumPos( unsigned int albumpos ) { m_albumpos = albumpos; }
+ void setDiscNumber( unsigned int discnumber ) { m_discnumber = discnumber; }
QVariant toVariant() const;
QString toString() const;
@@ -96,15 +95,27 @@ public:
QString albumSortname() const { return m_albumSortname; }
QString trackSortname() const { return m_trackSortname; }
QString artist() const { return m_artist; }
+ QString composer() const { return m_composer; }
QString album() const { return m_album; }
QString track() const { return m_track; }
int duration() const { return m_duration; }
unsigned int albumpos() const { return m_albumpos; }
+ unsigned int discnumber() const { return m_discnumber; }
void setResolveFinished( bool resolved ) { m_resolveFinished = resolved; }
void setPlayedBy( const Tomahawk::source_ptr& source, unsigned int playtime );
+ void setLoved( bool loved );
+ bool loved();
+
+ void loadSocialActions();
+ QList< Tomahawk::SocialAction > allSocialActions();
+ void setAllSocialActions( const QList< Tomahawk::SocialAction >& socialActions );
+
+ QWeakPointer< Tomahawk::Query > weakRef() { return m_ownRef; }
+ void setWeakRef( QWeakPointer< Tomahawk::Query > weakRef ) { m_ownRef = weakRef; }
+
signals:
void resultsAdded( const QList& );
void resultsRemoved( const Tomahawk::result_ptr& );
@@ -117,6 +128,9 @@ signals:
void playableStateChanged( bool state );
void resolvingFinished( bool hasResults );
+ // emitted when social actions are loaded
+ void socialActionsLoaded();
+
public slots:
/// (indirectly) called by resolver plugins when results are found
void addResults( const QList< Tomahawk::result_ptr >& );
@@ -134,9 +148,12 @@ public slots:
private slots:
void onResultStatusChanged();
void refreshResults();
+ void onSocialActionsLoaded();
private:
Query();
+ explicit Query( const QString& artist, const QString& track, const QString& album, const QID& qid, bool autoResolve );
+ explicit Query( const QString& query, const QID& qid );
void init();
@@ -147,6 +164,8 @@ private:
void updateSortNames();
static int levenshtein( const QString& source, const QString& target );
+ void parseSocialActions();
+
QList< Tomahawk::artist_ptr > m_artists;
QList< Tomahawk::album_ptr > m_albums;
QList< Tomahawk::result_ptr > m_results;
@@ -156,22 +175,31 @@ private:
mutable QID m_qid;
QString m_artistSortname;
+ QString m_composerSortName;
QString m_albumSortname;
QString m_trackSortname;
QString m_artist;
+ QString m_composer;
QString m_album;
QString m_track;
QString m_fullTextQuery;
int m_duration;
unsigned int m_albumpos;
+ unsigned int m_discnumber;
QString m_resultHint;
QPair< Tomahawk::source_ptr, unsigned int > m_playedBy;
QList< QWeakPointer< Tomahawk::Resolver > > m_resolvers;
mutable QMutex m_mutex;
+
+ QWeakPointer< Tomahawk::Query > m_ownRef;
+
+ bool m_socialActionsLoaded;
+ QHash< QString, QVariant > m_currentSocialActions;
+ QList< SocialAction > m_allSocialActions;
};
}; //ns
diff --git a/src/libtomahawk/resolvers/scriptresolver.cpp b/src/libtomahawk/resolvers/scriptresolver.cpp
index e03ac5d9f..aa696e2c6 100644
--- a/src/libtomahawk/resolvers/scriptresolver.cpp
+++ b/src/libtomahawk/resolvers/scriptresolver.cpp
@@ -243,12 +243,15 @@ ScriptResolver::handleMsg( const QByteArray& msg )
Tomahawk::artist_ptr ap = Tomahawk::Artist::get( m.value( "artist" ).toString(), false );
rp->setArtist( ap );
rp->setAlbum( Tomahawk::Album::get( ap, m.value( "album" ).toString(), false ) );
+ rp->setAlbumPos( m.value( "albumpos" ).toUInt() );
rp->setTrack( m.value( "track" ).toString() );
rp->setDuration( m.value( "duration" ).toUInt() );
rp->setBitrate( m.value( "bitrate" ).toUInt() );
rp->setSize( m.value( "size" ).toUInt() );
rp->setRID( uuid() );
rp->setFriendlySource( m_name );
+ rp->setYear( m.value( "year ").toUInt() );
+ rp->setDiscNumber( m.value( "discnumber" ).toUInt() );
rp->setMimetype( m.value( "mimetype" ).toString() );
if ( rp->mimetype().isEmpty() )
@@ -256,12 +259,6 @@ ScriptResolver::handleMsg( const QByteArray& msg )
rp->setMimetype( TomahawkUtils::extensionToMimetype( m.value( "extension" ).toString() ) );
Q_ASSERT( !rp->mimetype().isEmpty() );
}
- if ( m.contains( "year" ) )
- {
- QVariantMap attr;
- attr[ "releaseyear" ] = m.value( "year" );
- rp->setAttributes( attr );
- }
results << rp;
}
diff --git a/src/libtomahawk/result.cpp b/src/libtomahawk/result.cpp
index 1fd270c7a..413cb7e39 100644
--- a/src/libtomahawk/result.cpp
+++ b/src/libtomahawk/result.cpp
@@ -20,11 +20,11 @@
#include "album.h"
#include "collection.h"
+#include "source.h"
#include "database/database.h"
#include "database/databasecommand_resolve.h"
#include "database/databasecommand_alltracks.h"
#include "database/databasecommand_addfiles.h"
-#include "database/databasecommand_loadsocialactions.h"
#include "utils/logger.h"
@@ -58,6 +58,7 @@ Result::Result( const QString& url )
, m_size( 0 )
, m_albumpos( 0 )
, m_modtime( 0 )
+ , m_discnumber( 0 )
, m_year( 0 )
, m_score( 0 )
, m_trackId( 0 )
@@ -82,6 +83,12 @@ Result::artist() const
return m_artist;
}
+artist_ptr
+Result::composer() const
+{
+ return m_composer;
+}
+
album_ptr
Result::album() const
@@ -151,6 +158,8 @@ Result::toVariant() const
m.insert( "duration", duration() );
m.insert( "score", score() );
m.insert( "sid", id() );
+ m.insert( "discnumber", discnumber() );
+ m.insert( "composer", composer()->name() );
return m;
}
@@ -164,15 +173,19 @@ Result::toString() const
Tomahawk::query_ptr
-Result::toQuery() const
+Result::toQuery()
{
- Tomahawk::query_ptr query = Tomahawk::Query::get( artist()->name(), track(), album()->name() );
- QList rl;
- rl << Result::get( m_url );
+ if ( m_query.isNull() )
+ {
+ m_query = Tomahawk::Query::get( artist()->name(), track(), album()->name() );
+ QList rl;
+ rl << Result::get( m_url );
- query->addResults( rl );
- query->setResolveFinished( true );
- return query;
+ m_query->addResults( rl );
+ m_query->setResolveFinished( true );
+ }
+
+ return m_query;
}
@@ -200,55 +213,6 @@ Result::onOffline()
}
-void
-Result::loadSocialActions()
-{
- DatabaseCommand_LoadSocialActions* cmd = new DatabaseCommand_LoadSocialActions( this );
- connect( cmd, SIGNAL( finished() ), SLOT( onSocialActionsLoaded() ));
- Database::instance()->enqueue( QSharedPointer(cmd) );
-}
-
-
-void Result::onSocialActionsLoaded()
-{
- parseSocialActions();
-
- emit socialActionsLoaded();
-}
-
-
-void
-Result::setAllSocialActions(QList< SocialAction > socialActions)
-{
- m_allSocialActions = socialActions;
-}
-
-
-QList< SocialAction >
-Result::allSocialActions()
-{
- return m_allSocialActions;
-}
-
-
-void
-Result::parseSocialActions()
-{
- QListIterator< Tomahawk::SocialAction > it( m_allSocialActions );
- unsigned int highestTimestamp = 0;
-
- while ( it.hasNext() )
- {
- Tomahawk::SocialAction socialAction;
- socialAction = it.next();
- if ( socialAction.timestamp.toUInt() > highestTimestamp && socialAction.source.toInt() == SourceList::instance()->getLocal()->id() )
- {
- m_currentSocialActions[ socialAction.action.toString() ] = socialAction.value.toBool();
- }
- }
-}
-
-
void
Result::setArtist( const Tomahawk::artist_ptr& artist )
{
@@ -256,6 +220,13 @@ Result::setArtist( const Tomahawk::artist_ptr& artist )
}
+void
+Result::setComposer( const Tomahawk::artist_ptr &composer )
+{
+ m_composer = composer;
+}
+
+
void
Result::setAlbum( const Tomahawk::album_ptr& album )
{
diff --git a/src/libtomahawk/result.h b/src/libtomahawk/result.h
index e7adc4a6e..2d743e4dd 100644
--- a/src/libtomahawk/result.h
+++ b/src/libtomahawk/result.h
@@ -60,7 +60,7 @@ public:
QVariant toVariant() const;
QString toString() const;
- Tomahawk::query_ptr toQuery() const;
+ Tomahawk::query_ptr toQuery();
float score() const;
RID id() const;
@@ -69,6 +69,7 @@ public:
collection_ptr collection() const;
Tomahawk::artist_ptr artist() const;
Tomahawk::album_ptr album() const;
+ Tomahawk::artist_ptr composer() const;
QString track() const { return m_track; }
QString url() const { return m_url; }
QString mimetype() const { return m_mimetype; }
@@ -80,8 +81,7 @@ public:
unsigned int albumpos() const { return m_albumpos; }
unsigned int modificationTime() const { return m_modtime; }
int year() const { return m_year; }
- bool loved() { return m_currentSocialActions[ "Love" ].toBool(); }
- QList< Tomahawk::SocialAction > allSocialActions();
+ unsigned int discnumber() const { return m_discnumber; }
void setScore( float score ) { m_score = score; }
void setTrackId( unsigned int id ) { m_trackId = id; }
@@ -91,6 +91,7 @@ public:
void setFriendlySource( const QString& s ) { m_friendlySource = s; }
void setArtist( const Tomahawk::artist_ptr& artist );
void setAlbum( const Tomahawk::album_ptr& album );
+ void setComposer( const Tomahawk::artist_ptr& composer );
void setTrack( const QString& track ) { m_track = track; }
void setMimetype( const QString& mimetype ) { m_mimetype = mimetype; }
void setDuration( unsigned int duration ) { m_duration = duration; }
@@ -99,26 +100,18 @@ public:
void setAlbumPos( unsigned int albumpos ) { m_albumpos = albumpos; }
void setModificationTime( unsigned int modtime ) { m_modtime = modtime; }
void setYear( unsigned int year ) { m_year = year; }
- void setLoved( bool loved ) { m_currentSocialActions[ "Loved" ] = loved; }
- void setAllSocialActions( QList< Tomahawk::SocialAction > socialActions );
+ void setDiscNumber( unsigned int discnumber ) { m_discnumber = discnumber; }
- void loadSocialActions();
QVariantMap attributes() const { return m_attributes; }
void setAttributes( const QVariantMap& map ) { m_attributes = map; updateAttributes(); }
unsigned int trackId() const { return m_trackId; }
unsigned int fileId() const { return m_fileId; }
-public slots:
- void onSocialActionsLoaded();
-
signals:
// emitted when the collection this result comes from is going offline/online:
void statusChanged();
- // emitted when social actions are loaded
- void socialActionsLoaded();
-
private slots:
void onOffline();
void onOnline();
@@ -129,13 +122,14 @@ private:
explicit Result();
void updateAttributes();
- void parseSocialActions();
mutable RID m_rid;
collection_ptr m_collection;
+ Tomahawk::query_ptr m_query;
Tomahawk::artist_ptr m_artist;
Tomahawk::album_ptr m_album;
+ Tomahawk::artist_ptr m_composer;
QString m_track;
QString m_url;
QString m_mimetype;
@@ -146,15 +140,12 @@ private:
unsigned int m_size;
unsigned int m_albumpos;
unsigned int m_modtime;
+ unsigned int m_discnumber;
int m_year;
float m_score;
QVariantMap m_attributes;
-
unsigned int m_trackId, m_fileId;
-
- QHash< QString, QVariant > m_currentSocialActions;
- QList< SocialAction > m_allSocialActions;
};
} //ns
diff --git a/src/libtomahawk/source.cpp b/src/libtomahawk/source.cpp
index 575953d07..9d96792db 100644
--- a/src/libtomahawk/source.cpp
+++ b/src/libtomahawk/source.cpp
@@ -302,7 +302,7 @@ Source::trackCount() const
Tomahawk::playlistinterface_ptr
-Source::getPlaylistInterface()
+Source::playlistInterface()
{
if ( m_playlistInterface.isNull() )
{
@@ -323,7 +323,7 @@ Source::onPlaybackStarted( const Tomahawk::query_ptr& query, unsigned int durati
m_currentTrackTimer.start( duration * 1000 + 900000 ); // duration comes in seconds
if ( m_playlistInterface.isNull() )
- getPlaylistInterface();
+ playlistInterface();
emit playbackStarted( query );
}
@@ -361,6 +361,13 @@ Source::addCommand( const QSharedPointer& command )
void
Source::executeCommands()
{
+ if ( QThread::currentThread() != thread() )
+ {
+ tDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
+ QMetaObject::invokeMethod( this, "executeCommands", Qt::QueuedConnection );
+ return;
+ }
+
if ( !m_cmds.isEmpty() )
{
QList< QSharedPointer > cmdGroup;
diff --git a/src/libtomahawk/source.h b/src/libtomahawk/source.h
index e502da0b2..f3361a720 100644
--- a/src/libtomahawk/source.h
+++ b/src/libtomahawk/source.h
@@ -85,7 +85,7 @@ public:
QString textStatus() const { return m_textStatus; }
DBSyncConnection::State state() const { return m_state; }
- Tomahawk::playlistinterface_ptr getPlaylistInterface();
+ Tomahawk::playlistinterface_ptr playlistInterface();
signals:
void syncedWithDatabase();
diff --git a/src/libtomahawk/sourceplaylistinterface.cpp b/src/libtomahawk/sourceplaylistinterface.cpp
index b1ee26ef6..d3ef4f011 100644
--- a/src/libtomahawk/sourceplaylistinterface.cpp
+++ b/src/libtomahawk/sourceplaylistinterface.cpp
@@ -20,20 +20,26 @@
#include "source.h"
#include "pipeline.h"
+#include "audio/audioengine.h"
#include "utils/logger.h"
using namespace Tomahawk;
-SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::Source *source )
+SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::Source *source, Tomahawk::PlaylistInterface::LatchMode latchMode )
: PlaylistInterface()
, m_source( source )
, m_currentItem( 0 )
, m_gotNextItem( false )
{
+ setLatchMode( latchMode );
+
if ( !m_source.isNull() )
connect( m_source.data(), SIGNAL( playbackStarted( const Tomahawk::query_ptr& ) ), SLOT( onSourcePlaybackStarted( const Tomahawk::query_ptr& ) ) );
+
+ if ( AudioEngine::instance() )
+ connect( AudioEngine::instance(), SIGNAL( paused() ), SLOT( audioPaused() ) );
}
@@ -55,15 +61,15 @@ Tomahawk::result_ptr
SourcePlaylistInterface::nextItem()
{
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
- if ( m_source.isNull() || m_source.data()->currentTrack().isNull() || m_source.data()->currentTrack()->results().isEmpty() )
+ if ( !sourceValid() )
{
- tDebug( LOGEXTRA ) << Q_FUNC_INFO << " Results were empty for current track or source no longer valid";
+ tDebug( LOGEXTRA ) << Q_FUNC_INFO << " Source no longer valid";
m_currentItem = Tomahawk::result_ptr();
return m_currentItem;
}
- else if ( !m_gotNextItem )
+ else if ( !hasNextItem() )
{
- tDebug( LOGEXTRA ) << Q_FUNC_INFO << " This song was already fetched";
+ tDebug( LOGEXTRA ) << Q_FUNC_INFO << " This song was already fetched or the source isn't playing anything";
return Tomahawk::result_ptr();
}
@@ -81,12 +87,22 @@ SourcePlaylistInterface::currentItem() const
bool
-SourcePlaylistInterface::hasNextItem()
+SourcePlaylistInterface::sourceValid()
{
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
- if ( m_source.isNull() || m_source.data()->currentTrack().isNull() || m_source.data()->currentTrack()->results().isEmpty() )
+ if ( m_source.isNull() || m_source.data()->currentTrack().isNull() )
return false;
+ return true;
+}
+
+
+bool
+SourcePlaylistInterface::hasNextItem()
+{
+ if ( !sourceValid() )
+ return false;
+
return m_gotNextItem;
}
@@ -95,7 +111,7 @@ QList
SourcePlaylistInterface::tracks()
{
QList tracks;
- return tracks; // FIXME
+ return tracks; // FIXME (with what?)
}
@@ -109,10 +125,10 @@ SourcePlaylistInterface::source() const
void
SourcePlaylistInterface::reset()
{
- if ( !m_currentItem.isNull() )
- m_gotNextItem = true;
- else
+ if ( m_currentItem.isNull() )
m_gotNextItem = false;
+ else
+ m_gotNextItem = true;
}
@@ -122,7 +138,7 @@ SourcePlaylistInterface::onSourcePlaybackStarted( const Tomahawk::query_ptr& que
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
connect( query.data(), SIGNAL( resolvingFinished( bool ) ), SLOT( resolvingFinished( bool ) ) );
Pipeline::instance()->resolve( query, true );
- m_gotNextItem = true;
+ m_gotNextItem = false;
}
@@ -131,5 +147,8 @@ SourcePlaylistInterface::resolvingFinished( bool hasResults )
{
tDebug( LOGEXTRA ) << Q_FUNC_INFO << " and has results? : " << (hasResults ? "true" : "false");
if ( hasResults )
+ {
+ m_gotNextItem = true;
emit nextTrackReady();
+ }
}
diff --git a/src/libtomahawk/sourceplaylistinterface.h b/src/libtomahawk/sourceplaylistinterface.h
index ce03f3c63..0e72632a8 100644
--- a/src/libtomahawk/sourceplaylistinterface.h
+++ b/src/libtomahawk/sourceplaylistinterface.h
@@ -35,7 +35,7 @@ class DLLEXPORT SourcePlaylistInterface : public Tomahawk::PlaylistInterface
Q_OBJECT
public:
- SourcePlaylistInterface( Tomahawk::Source *source );
+ SourcePlaylistInterface( Tomahawk::Source *source, Tomahawk::PlaylistInterface::LatchMode latchMode = PlaylistInterface::StayOnSong );
virtual ~SourcePlaylistInterface();
QList tracks();
@@ -44,6 +44,7 @@ public:
virtual int unfilteredTrackCount() const { return 1; }
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
+ virtual bool sourceValid();
virtual bool hasNextItem();
virtual Tomahawk::result_ptr nextItem();
virtual Tomahawk::result_ptr currentItem() const;
@@ -54,6 +55,8 @@ public:
virtual PlaylistInterface::RetryMode retryMode() const { return Retry; }
virtual quint32 retryInterval() const { return 5000; }
+ virtual void setLatchMode( PlaylistInterface::LatchMode latchMode ) { m_latchMode = latchMode; emit latchModeChanged( latchMode ); }
+
virtual bool shuffled() const { return false; }
virtual void setFilter( const QString& /*pattern*/ ) {}
@@ -64,13 +67,7 @@ public:
public slots:
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
virtual void setShuffled( bool ) {}
-
-signals:
- void repeatModeChanged( PlaylistInterface::RepeatMode mode );
- void shuffleModeChanged( bool enabled );
- void trackCountChanged( unsigned int tracks );
- void sourceTrackCountChanged( unsigned int tracks );
- void nextTrackReady();
+ virtual void audioPaused() { setLatchMode( PlaylistInterface::StayOnSong ); }
private slots:
void onSourcePlaybackStarted( const Tomahawk::query_ptr& query );
diff --git a/src/libtomahawk/taghandlers/apetag.cpp b/src/libtomahawk/taghandlers/apetag.cpp
new file mode 100644
index 000000000..a056e6cd1
--- /dev/null
+++ b/src/libtomahawk/taghandlers/apetag.cpp
@@ -0,0 +1,51 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2011, Teo Mrnjavac
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#include "apetag.h"
+
+namespace Tomahawk
+{
+
+APETag::APETag( TagLib::Tag *tag, TagLib::APE::Tag *apeTag )
+ : Tag( tag )
+ , m_apeTag( apeTag )
+{
+ TagLib::APE::ItemListMap map = m_apeTag->itemListMap();
+ for( TagLib::APE::ItemListMap::ConstIterator it = map.begin();
+ it != map.end(); ++it )
+ {
+ TagLib::String key = it->first;
+ QString val = TStringToQString( it->second.toString() );
+ //some of these are not defined in the item key according to the hydrogenaudio wiki
+ //can I use them anyway? --Teo 11/2011
+ if( key == TagLib::String( "Album Artist" ) )
+ {
+ m_albumArtist = val;
+ }
+ else if( key == TagLib::String( "Composer" ) )
+ {
+ m_composer = val;
+ }
+ else if( key == TagLib::String( "Disc" ) )
+ {
+ m_discNumber = processDiscNumber( val );
+ }
+ }
+}
+
+}
diff --git a/src/libtomahawk/taghandlers/apetag.h b/src/libtomahawk/taghandlers/apetag.h
new file mode 100644
index 000000000..316381960
--- /dev/null
+++ b/src/libtomahawk/taghandlers/apetag.h
@@ -0,0 +1,43 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2011, Teo Mrnjavac
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#ifndef APETAG_H
+#define APETAG_H
+
+#include "tag.h"
+#include
+
+namespace Tomahawk
+{
+
+class DLLEXPORT APETag : public Tag
+{
+public:
+ APETag( TagLib::Tag *, TagLib::APE::Tag * );
+
+ virtual QString albumArtist() const { return m_albumArtist; }
+ virtual QString composer() const { return m_composer; }
+ virtual unsigned int discNumber() const { return m_discNumber; }
+
+private:
+ TagLib::APE::Tag *m_apeTag;
+};
+
+}
+
+#endif // APETAG_H
diff --git a/src/libtomahawk/taghandlers/asftag.cpp b/src/libtomahawk/taghandlers/asftag.cpp
new file mode 100644
index 000000000..9a56fad68
--- /dev/null
+++ b/src/libtomahawk/taghandlers/asftag.cpp
@@ -0,0 +1,49 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2011, Teo Mrnjavac
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#include "asftag.h"
+
+namespace Tomahawk
+{
+
+ASFTag::ASFTag( TagLib::Tag *tag, TagLib::ASF::Tag *asfTag )
+ : Tag( tag )
+ , m_asfTag( asfTag )
+{
+ TagLib::ASF::AttributeListMap map = m_asfTag->attributeListMap();
+ for( TagLib::ASF::AttributeListMap::ConstIterator it = map.begin();
+ it != map.end(); ++it )
+ {
+ TagLib::String key = it->first;
+ QString val = TStringToQString( it->second[ 0 ].toString() );
+ if( key == TagLib::String( "WM/AlbumTitle" ) ) //album artist
+ {
+ m_albumArtist = val;
+ }
+ else if( key == TagLib::String( "WM/Composer" ) )
+ {
+ m_composer = val;
+ }
+ else if( key == TagLib::String( "WM/PartOfSet" ) )
+ {
+ m_discNumber = processDiscNumber( val );
+ }
+ }
+}
+
+}
diff --git a/src/libtomahawk/taghandlers/asftag.h b/src/libtomahawk/taghandlers/asftag.h
new file mode 100644
index 000000000..c2123db4c
--- /dev/null
+++ b/src/libtomahawk/taghandlers/asftag.h
@@ -0,0 +1,43 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2011, Teo Mrnjavac
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#ifndef ASFTAG_H
+#define ASFTAG_H
+
+#include "tag.h"
+#include
+
+namespace Tomahawk
+{
+
+class DLLEXPORT ASFTag : public Tag
+{
+public:
+ ASFTag( TagLib::Tag *, TagLib::ASF::Tag * );
+
+ virtual QString albumArtist() const { return m_albumArtist; }
+ virtual QString composer() const { return m_composer; }
+ virtual unsigned int discNumber() const { return m_discNumber; }
+
+private:
+ TagLib::ASF::Tag *m_asfTag;
+};
+
+}
+
+#endif // ASFTAG_H
diff --git a/src/libtomahawk/taghandlers/id3v1tag.cpp b/src/libtomahawk/taghandlers/id3v1tag.cpp
new file mode 100644
index 000000000..d822e4cd3
--- /dev/null
+++ b/src/libtomahawk/taghandlers/id3v1tag.cpp
@@ -0,0 +1,28 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2011, Teo Mrnjavac
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#include "id3v1tag.h"
+
+namespace Tomahawk
+{
+
+ID3v1Tag::ID3v1Tag( TagLib::Tag *tag )
+ : Tag( tag )
+{}
+
+}
diff --git a/src/libtomahawk/taghandlers/id3v1tag.h b/src/libtomahawk/taghandlers/id3v1tag.h
new file mode 100644
index 000000000..87298c953
--- /dev/null
+++ b/src/libtomahawk/taghandlers/id3v1tag.h
@@ -0,0 +1,40 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2011, Teo Mrnjavac
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#ifndef ID3V1TAG_H
+#define ID3V1TAG_H
+
+#include "tag.h"
+#include
+
+namespace Tomahawk
+{
+
+class DLLEXPORT ID3v1Tag : public Tag
+{
+public:
+ ID3v1Tag( TagLib::Tag * );
+
+ virtual QString albumArtist() const { return QString(); }
+ virtual QString composer() const { return QString(); }
+ virtual unsigned int discNumber() const { return 0; }
+};
+
+}
+
+#endif // ID3V1TAG_H
diff --git a/src/libtomahawk/taghandlers/id3v2tag.cpp b/src/libtomahawk/taghandlers/id3v2tag.cpp
new file mode 100644
index 000000000..04452854a
--- /dev/null
+++ b/src/libtomahawk/taghandlers/id3v2tag.cpp
@@ -0,0 +1,56 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2011, Teo Mrnjavac
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#include "id3v2tag.h"
+#include
+
+namespace Tomahawk
+{
+
+ID3v2Tag::ID3v2Tag( TagLib::Tag *tag, TagLib::ID3v2::Tag *id3v2Tag )
+ : Tag( tag )
+ , m_id3v2Tag( id3v2Tag )
+{
+ TagLib::ID3v2::FrameList fList = m_id3v2Tag->frameList();
+ for( TagLib::ID3v2::FrameList::ConstIterator it = fList.begin();
+ it != fList.end(); ++it )
+ {
+ TagLib::String frameId = TagLib::String( (*it)->frameID() );
+ TagLib::ID3v2::TextIdentificationFrame *frame =
+ dynamic_cast< TagLib::ID3v2::TextIdentificationFrame * >( *it );
+ if( frame )
+ {
+ QString val = TStringToQString( frame->fieldList().toString( '\n' ) );
+
+ if( frameId == TagLib::String( "TPE2" ) ) //album artist
+ {
+ m_albumArtist = val;
+ }
+ else if( frameId == TagLib::String( "TCOM" ) ) //composer
+ {
+ m_composer = val;
+ }
+ else if( frameId == TagLib::String( "TPOS" ) ) //disc number
+ {
+ m_discNumber = processDiscNumber( val );
+ }
+ }
+ }
+}
+
+}
diff --git a/src/libtomahawk/taghandlers/id3v2tag.h b/src/libtomahawk/taghandlers/id3v2tag.h
new file mode 100644
index 000000000..2460d5a91
--- /dev/null
+++ b/src/libtomahawk/taghandlers/id3v2tag.h
@@ -0,0 +1,43 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2011, Teo Mrnjavac
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#ifndef ID3V2TAG_H
+#define ID3V2TAG_H
+
+#include "tag.h"
+#include
+
+namespace Tomahawk
+{
+
+class DLLEXPORT ID3v2Tag : public Tag
+{
+public:
+ ID3v2Tag( TagLib::Tag *, TagLib::ID3v2::Tag * );
+
+ virtual QString albumArtist() const { return m_albumArtist; }
+ virtual QString composer() const { return m_composer; }
+ virtual unsigned int discNumber() const { return m_discNumber; }
+
+private:
+ TagLib::ID3v2::Tag *m_id3v2Tag;
+};
+
+}
+
+#endif // ID3V2TAG_H
diff --git a/src/libtomahawk/taghandlers/mp4tag.cpp b/src/libtomahawk/taghandlers/mp4tag.cpp
new file mode 100644
index 000000000..49e34cb98
--- /dev/null
+++ b/src/libtomahawk/taghandlers/mp4tag.cpp
@@ -0,0 +1,49 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2011, Teo Mrnjavac
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#include "mp4tag.h"
+
+namespace Tomahawk
+{
+
+MP4Tag::MP4Tag( TagLib::Tag *tag, TagLib::MP4::Tag *mp4Tag )
+ : Tag( tag )
+ , m_mp4Tag( mp4Tag )
+{
+ TagLib::MP4::ItemListMap map = m_mp4Tag->itemListMap();
+ for( TagLib::MP4::ItemListMap::ConstIterator it = map.begin();
+ it != map.end(); ++it )
+ {
+ TagLib::String key = it->first;
+ QString val = TStringToQString( it->second.toStringList().toString( '\n' ) );
+ if( key == TagLib::String( "aART" ) ) //album artist
+ {
+ m_albumArtist = val;
+ }
+ else if( key == TagLib::String( "\xA9wrt" ) ) //composer
+ {
+ m_composer = val;
+ }
+ else if( key == TagLib::String( "disk" ) ) //disk number
+ {
+ m_discNumber = processDiscNumber( val );
+ }
+ }
+}
+
+}
diff --git a/src/libtomahawk/taghandlers/mp4tag.h b/src/libtomahawk/taghandlers/mp4tag.h
new file mode 100644
index 000000000..9e0adf93a
--- /dev/null
+++ b/src/libtomahawk/taghandlers/mp4tag.h
@@ -0,0 +1,42 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2011, Teo Mrnjavac
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#ifndef MP4TAG_H
+#define MP4TAG_H
+
+#include "tag.h"
+#include
+
+namespace Tomahawk
+{
+
+class DLLEXPORT MP4Tag : public Tag
+{
+public:
+ MP4Tag( TagLib::Tag *, TagLib::MP4::Tag * );
+
+ virtual QString albumArtist() const { return m_albumArtist; }
+ virtual QString composer() const { return m_composer; }
+ virtual unsigned int discNumber() const { return m_discNumber; }
+
+private:
+ TagLib::MP4::Tag *m_mp4Tag;
+};
+
+}
+#endif // MP4TAG_H
diff --git a/src/libtomahawk/taghandlers/oggtag.cpp b/src/libtomahawk/taghandlers/oggtag.cpp
new file mode 100644
index 000000000..fed675a79
--- /dev/null
+++ b/src/libtomahawk/taghandlers/oggtag.cpp
@@ -0,0 +1,49 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2011, Teo Mrnjavac
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#include "oggtag.h"
+
+namespace Tomahawk
+{
+
+OggTag::OggTag( TagLib::Tag *tag, TagLib::Ogg::XiphComment *xiphComment )
+ : Tag( tag )
+ , m_xiphComment( xiphComment )
+{
+ TagLib::Ogg::FieldListMap map = m_xiphComment->fieldListMap();
+ for( TagLib::Ogg::FieldListMap::ConstIterator it = map.begin();
+ it != map.end(); ++it )
+ {
+ TagLib::String key = it->first;
+ QString val = TStringToQString( it->second.toString( '\n' ) );
+ if( key == TagLib::String( "ALBUMARTIST" ) )
+ {
+ m_albumArtist = val;
+ }
+ else if( key == TagLib::String( "COMPOSER" ) )
+ {
+ m_composer = val;
+ }
+ else if( key == TagLib::String( "DISCNUMBER" ) )
+ {
+ m_discNumber = processDiscNumber( val );
+ }
+ }
+}
+
+}
diff --git a/src/libtomahawk/taghandlers/oggtag.h b/src/libtomahawk/taghandlers/oggtag.h
new file mode 100644
index 000000000..0979ef994
--- /dev/null
+++ b/src/libtomahawk/taghandlers/oggtag.h
@@ -0,0 +1,43 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2011, Teo Mrnjavac
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#ifndef OGGTAG_H
+#define OGGTAG_H
+
+#include "tag.h"
+#include
+
+namespace Tomahawk
+{
+
+class DLLEXPORT OggTag : public Tag
+{
+public:
+ OggTag( TagLib::Tag *, TagLib::Ogg::XiphComment * );
+
+ virtual QString albumArtist() const { return m_albumArtist; }
+ virtual QString composer() const { return m_composer; }
+ virtual unsigned int discNumber() const { return m_discNumber; }
+
+private:
+ TagLib::Ogg::XiphComment *m_xiphComment;
+};
+
+}
+
+#endif // OGGTAG_H
diff --git a/src/libtomahawk/taghandlers/tag.cpp b/src/libtomahawk/taghandlers/tag.cpp
new file mode 100644
index 000000000..698cc0e07
--- /dev/null
+++ b/src/libtomahawk/taghandlers/tag.cpp
@@ -0,0 +1,123 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2011, Teo Mrnjavac
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#include "tag.h"
+
+#include "apetag.h"
+#include "asftag.h"
+#include "id3v1tag.h"
+#include "id3v2tag.h"
+#include "mp4tag.h"
+#include "oggtag.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+namespace Tomahawk
+{
+
+/*static*/ Tag* Tag::fromFile( const TagLib::FileRef &f )
+{
+ Tag *t = 0;
+
+ if( TagLib::Ogg::Vorbis::File *file =
+ dynamic_cast< TagLib::Ogg::Vorbis::File * >( f.file() ) )
+ {
+ if( file->tag() )
+ t = new OggTag( f.tag(), file->tag() );
+ }
+ else if( TagLib::Ogg::FLAC::File *file =
+ dynamic_cast< TagLib::Ogg::FLAC::File * >( f.file() ) )
+ {
+ if( file->tag() )
+ t = new OggTag( f.tag(), file->tag() );
+ }
+ else if( TagLib::Ogg::Speex::File *file =
+ dynamic_cast< TagLib::Ogg::Speex::File * >( f.file() ) )
+ {
+ if( file->tag() )
+ t = new OggTag( f.tag(), file->tag() );
+ }
+ else if( TagLib::FLAC::File *file =
+ dynamic_cast< TagLib::FLAC::File * >( f.file() ) )
+ {
+ if( file->xiphComment() )
+ t = new OggTag( f.tag(), file->xiphComment() );
+ else if( file->ID3v2Tag() )
+ t = new ID3v2Tag( f.tag(), file->ID3v2Tag() );
+ else if( file->ID3v1Tag() )
+ t = new ID3v1Tag( f.tag() );
+ }
+ else if( TagLib::MPEG::File *file =
+ dynamic_cast< TagLib::MPEG::File * >( f.file() ) )
+ {
+ if( file->ID3v2Tag() )
+ t = new ID3v2Tag( f.tag(), file->ID3v2Tag() );
+ else if( file->APETag() )
+ t = new APETag( f.tag(), file->APETag() );
+ else if( file->ID3v1Tag() )
+ t = new ID3v1Tag( f.tag() );
+ }
+ else if( TagLib::MP4::File *file =
+ dynamic_cast< TagLib::MP4::File * >( f.file() ) )
+ {
+ if( file->tag() )
+ t = new MP4Tag( f.tag(), file->tag() );
+ }
+ else if( TagLib::MPC::File *file =
+ dynamic_cast< TagLib::MPC::File * >( f.file() ) )
+ {
+ if( file->APETag() )
+ t = new APETag( f.tag(), file->APETag() );
+ else if( file->ID3v1Tag() )
+ t = new ID3v1Tag( f.tag() );
+ }
+ else if( TagLib::ASF::File *file =
+ dynamic_cast< TagLib::ASF::File * >( f.file() ) )
+ {
+ if( file->tag() )
+ t = new ASFTag( f.tag(), file->tag() );
+ }
+
+
+ return t;
+}
+
+unsigned int Tag::processDiscNumber( const QString &s ) const
+{
+ int disc;
+ if( s.indexOf( '/' ) != -1 )
+ disc = s.split( '/', QString::SkipEmptyParts ).value( 0 ).toInt();
+ else if( s.indexOf( ':' ) != -1 )
+ disc = s.split( '/', QString::SkipEmptyParts ).value( 0 ).toInt();
+ else
+ disc = s.toInt();
+
+ return disc;
+}
+
+}
diff --git a/src/libtomahawk/taghandlers/tag.h b/src/libtomahawk/taghandlers/tag.h
new file mode 100644
index 000000000..c1bf51ea2
--- /dev/null
+++ b/src/libtomahawk/taghandlers/tag.h
@@ -0,0 +1,72 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2011, Teo Mrnjavac
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#ifndef TAG_H
+#define TAG_H
+
+#include "dllmacro.h"
+
+#include
+
+#include
+#include
+
+namespace Tomahawk
+{
+
+class DLLEXPORT Tag
+{
+public:
+ static Tag *fromFile( const TagLib::FileRef &f );
+
+ //getter-setters for common TagLib items
+ virtual QString title() const { return TStringToQString( m_tag->title() ).trimmed(); }
+ virtual QString artist() const { return TStringToQString( m_tag->artist() ).trimmed(); }
+ virtual QString album() const { return TStringToQString( m_tag->album() ).trimmed(); }
+ virtual QString comment() const { return TStringToQString( m_tag->comment() ).trimmed(); }
+ virtual QString genre() const { return TStringToQString( m_tag->genre() ).trimmed(); }
+ virtual unsigned int year() const { return m_tag->year(); }
+ virtual unsigned int track() const { return m_tag->track(); }
+ virtual void setTitle( const QString &s ) { m_tag->setTitle( TagLib::String( s.toUtf8().data(), TagLib::String::UTF8 ) ); }
+ virtual void setArtist( const QString &s ) { m_tag->setArtist( TagLib::String( s.toUtf8().data(), TagLib::String::UTF8 ) ); }
+ virtual void setAlbum( const QString &s ) { m_tag->setAlbum( TagLib::String( s.toUtf8().data(), TagLib::String::UTF8 ) ); }
+ virtual void setComment( const QString &s ) { m_tag->setComment( TagLib::String( s.toUtf8().data(), TagLib::String::UTF8 ) ); }
+ virtual void setGenre( const QString &s ) { m_tag->setGenre( TagLib::String( s.toUtf8().data(), TagLib::String::UTF8 ) ); }
+ virtual void setYear( unsigned int i ) { m_tag->setYear( i ); }
+ virtual void setTrack( unsigned int i ) { m_tag->setTrack( i ); }
+ virtual bool isEmpty() const { return m_tag->isEmpty(); }
+
+ virtual QString albumArtist() const = 0;
+ virtual QString composer() const = 0;
+ virtual unsigned int discNumber() const = 0;
+ //TODO: add support for writing those 3 items with TagLib's addField/setField
+
+protected:
+ Tag( TagLib::Tag *tag ) : m_tag( tag ), m_discNumber( 0 ) {}
+
+ unsigned int processDiscNumber( const QString & ) const;
+
+ TagLib::Tag *m_tag;
+ QString m_albumArtist;
+ QString m_composer;
+ unsigned int m_discNumber;
+};
+
+}
+
+#endif // TAG_H
diff --git a/src/libtomahawk/utils/stylehelper.cpp b/src/libtomahawk/utils/stylehelper.cpp
index b3d3787a0..7d6dcea0e 100644
--- a/src/libtomahawk/utils/stylehelper.cpp
+++ b/src/libtomahawk/utils/stylehelper.cpp
@@ -47,6 +47,8 @@ StyleHelper::headerHighlightColor()
void
StyleHelper::horizontalHeader( QPainter* painter, const QRect& r )
{
+ painter->save();
+
QRect upperHalf( 0, 0, r.width(), r.height() / 2 );
QRect lowerHalf( 0, upperHalf.height(), r.width(), r.height() );
painter->fillRect( upperHalf, StyleHelper::headerUpperColor() );
@@ -64,6 +66,8 @@ StyleHelper::horizontalHeader( QPainter* painter, const QRect& r )
painter->setPen( lineColor );
painter->drawLine( line );
}
+
+ painter->restore();
}
diff --git a/src/libtomahawk/utils/tomahawkutilsgui.cpp b/src/libtomahawk/utils/tomahawkutilsgui.cpp
index d4def733f..4d1d419d5 100644
--- a/src/libtomahawk/utils/tomahawkutilsgui.cpp
+++ b/src/libtomahawk/utils/tomahawkutilsgui.cpp
@@ -161,7 +161,7 @@ drawBackgroundAndNumbers( QPainter* painter, const QString& text, const QRect& f
void
drawQueryBackground( QPainter* p, const QPalette& palette, const QRect& r, qreal lightnessFactor )
{
- p->setPen( palette.mid().color().lighter( lightnessFactor * 100 ) );
+ p->setPen( palette.highlight().color().lighter( lightnessFactor * 100 ) );
p->setBrush( palette.highlight().color().lighter( lightnessFactor * 100 ) );
p->drawRoundedRect( r, 4.0, 4.0 );
}
diff --git a/src/libtomahawk/viewmanager.cpp b/src/libtomahawk/viewmanager.cpp
index 209855da1..674043939 100644
--- a/src/libtomahawk/viewmanager.cpp
+++ b/src/libtomahawk/viewmanager.cpp
@@ -140,13 +140,16 @@ ViewManager::createPageForPlaylist( const playlist_ptr& pl )
return view;
}
+
playlist_ptr
ViewManager::playlistForPage( ViewPage* page ) const
{
playlist_ptr p;
if ( dynamic_cast< PlaylistView* >( page ) && dynamic_cast< PlaylistView* >( page )->playlistModel() &&
!dynamic_cast< PlaylistView* >( page )->playlistModel()->playlist().isNull() )
+ {
p = dynamic_cast< PlaylistView* >( page )->playlistModel()->playlist();
+ }
else if ( dynamic_cast< DynamicWidget* >( page ) )
p = dynamic_cast< DynamicWidget* >( page )->playlist();
@@ -484,13 +487,15 @@ ViewManager::historyBack()
delete oldPage;
}
+
void
ViewManager::removeFromHistory ( ViewPage* p )
{
if ( currentPage() == p )
{
historyBack();
- } else
+ }
+ else
{
m_pageHistory.removeAll( p );
delete p;
@@ -498,6 +503,7 @@ ViewManager::removeFromHistory ( ViewPage* p )
}
+
void
ViewManager::setFilter( const QString& filter )
{
@@ -645,16 +651,16 @@ ViewManager::updateView()
if ( currentPlaylistInterface() )
{
connect( currentPlaylistInterface().data(), SIGNAL( sourceTrackCountChanged( unsigned int ) ),
- SIGNAL( numTracksChanged( unsigned int ) ) );
+ SIGNAL( numTracksChanged( unsigned int ) ) );
connect( currentPlaylistInterface().data(), SIGNAL( trackCountChanged( unsigned int ) ),
- SIGNAL( numShownChanged( unsigned int ) ) );
+ SIGNAL( numShownChanged( unsigned int ) ) );
connect( currentPlaylistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
- SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
+ SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
connect( currentPlaylistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ),
- SIGNAL( shuffleModeChanged( bool ) ) );
+ SIGNAL( shuffleModeChanged( bool ) ) );
m_infobar->setFilter( currentPlaylistInterface()->filter() );
}
@@ -717,12 +723,17 @@ ViewManager::loadCurrentPlaylistSettings()
{
TomahawkSettings* s = TomahawkSettings::instance();
Tomahawk::playlist_ptr pl = playlistForInterface( currentPlaylistInterface() );
- if ( !pl.isNull() ) {
+
+ if ( !pl.isNull() )
+ {
currentPlaylistInterface()->setShuffled( s->shuffleState( pl->guid() ));
currentPlaylistInterface()->setRepeatMode( s->repeatMode( pl->guid() ));
- } else {
+ }
+ else
+ {
Tomahawk::dynplaylist_ptr dynPl = dynamicPlaylistForInterface( currentPlaylistInterface() );
- if ( !dynPl.isNull() ) {
+ if ( !dynPl.isNull() )
+ {
currentPlaylistInterface()->setShuffled( s->shuffleState( dynPl->guid() ));
}
}
@@ -783,8 +794,7 @@ ViewManager::setShuffled( bool enabled )
void
-ViewManager::createPlaylist( const Tomahawk::source_ptr& src,
- const QVariant& contents )
+ViewManager::createPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents )
{
Tomahawk::playlist_ptr p = Tomahawk::playlist_ptr( new Tomahawk::Playlist( src ) );
QJson::QObjectHelper::qvariant2qobject( contents.toMap(), p.data() );
@@ -793,8 +803,7 @@ ViewManager::createPlaylist( const Tomahawk::source_ptr& src,
void
-ViewManager::createDynamicPlaylist( const Tomahawk::source_ptr& src,
- const QVariant& contents )
+ViewManager::createDynamicPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents )
{
Tomahawk::dynplaylist_ptr p = Tomahawk::dynplaylist_ptr( new Tomahawk::DynamicPlaylist( src, contents.toMap().value( "type", QString() ).toString() ) );
QJson::QObjectHelper::qvariant2qobject( contents.toMap(), p.data() );
@@ -838,6 +847,7 @@ ViewManager::pageForInterface( Tomahawk::playlistinterface_ptr interface ) const
return 0;
}
+
Tomahawk::playlistinterface_ptr
ViewManager::currentPlaylistInterface() const
{
@@ -854,6 +864,7 @@ ViewManager::currentPage() const
return m_pageHistory.isEmpty() ? 0 : m_pageHistory.front();
}
+
Tomahawk::playlist_ptr
ViewManager::playlistForInterface( Tomahawk::playlistinterface_ptr interface ) const
{
diff --git a/src/libtomahawk/widgets/Breadcrumb.cpp b/src/libtomahawk/widgets/Breadcrumb.cpp
index 30f12942e..975a5c2b0 100644
--- a/src/libtomahawk/widgets/Breadcrumb.cpp
+++ b/src/libtomahawk/widgets/Breadcrumb.cpp
@@ -33,7 +33,6 @@ using namespace Tomahawk;
Breadcrumb::Breadcrumb( QWidget* parent, Qt::WindowFlags f )
: QWidget( parent, f )
, m_model( 0 )
-
, m_buttonlayout( new QHBoxLayout( this ) )
{
m_buttonlayout->setSpacing( 0 );
@@ -48,11 +47,12 @@ Breadcrumb::Breadcrumb( QWidget* parent, Qt::WindowFlags f )
show();
}
+
Breadcrumb::~Breadcrumb()
{
-
}
+
void
Breadcrumb::setModel( QAbstractItemModel* model )
{
@@ -64,6 +64,7 @@ Breadcrumb::setModel( QAbstractItemModel* model )
updateButtons( QModelIndex() );
}
+
void
Breadcrumb::setRootIcon( const QPixmap& pm )
{
@@ -85,6 +86,7 @@ Breadcrumb::paintEvent( QPaintEvent* )
StyleHelper::horizontalHeader( &p, rect() );
}
+
// updateFrom is the item that has changed---all children must be recomputed
// if invalid, redo the whole breadcrumb
void
@@ -127,7 +129,7 @@ Breadcrumb::updateButtons( const QModelIndex& updateFrom )
{
QPropertyAnimation* animation = new QPropertyAnimation( btn, "pos" );
animation->setDuration( 300 );
- animation->setStartValue( m_buttons.last()->pos());
+ animation->setStartValue( m_buttons.last()->pos() );
animation->setEndValue( btn->pos() );
animation->start( QAbstractAnimation::DeleteWhenStopped );
}
@@ -162,6 +164,7 @@ Breadcrumb::updateButtons( const QModelIndex& updateFrom )
emit activateIndex( idx );
}
+
void
Breadcrumb::breadcrumbComboChanged( const QModelIndex& childSelected )
{
diff --git a/src/libtomahawk/widgets/BreadcrumbButton.cpp b/src/libtomahawk/widgets/BreadcrumbButton.cpp
index aa60a5f35..4b479c21e 100644
--- a/src/libtomahawk/widgets/BreadcrumbButton.cpp
+++ b/src/libtomahawk/widgets/BreadcrumbButton.cpp
@@ -23,6 +23,7 @@
#include "combobox.h"
#include "utils/stylehelper.h"
#include "utils/tomahawkutilsgui.h"
+#include "utils/logger.h"
#include
#include
@@ -49,6 +50,7 @@ BreadcrumbButton::BreadcrumbButton( Breadcrumb* parent, QAbstractItemModel* mode
connect( m_combo, SIGNAL( activated( int ) ), SLOT( comboboxActivated( int ) ) );
}
+
void
BreadcrumbButton::paintEvent( QPaintEvent* )
{
@@ -59,23 +61,22 @@ BreadcrumbButton::paintEvent( QPaintEvent* )
StyleHelper::horizontalHeader( &p, r ); // draw the background
- if( !hasChildren() )
+ if ( !hasChildren() )
return;
bool reverse = opt.direction == Qt::RightToLeft;
int menuButtonWidth = 12;
int rightSpacing = 10;
- int left = !reverse ? r.right()-rightSpacing - menuButtonWidth : r.left();
- int right = !reverse ? r.right()-rightSpacing : r.left() + menuButtonWidth;
+ int left = !reverse ? r.right() - rightSpacing - menuButtonWidth : r.left();
+ int right = !reverse ? r.right() - rightSpacing : r.left() + menuButtonWidth;
int height = r.height();
QRect arrowRect( ( left + right ) / 2 + ( reverse ? 6 : -6 ), 0, height, height );
QStyleOption arrowOpt = opt;
arrowOpt.rect = arrowRect;
- QLine l1( left, 0, right, height/2 );
- QLine l2( left, height, right, height/2 );
-
+ QLine l1( left, 0, right, height / 2 );
+ QLine l2( left, height, right, height / 2 );
p.setRenderHint( QPainter::Antialiasing, true );
@@ -94,6 +95,7 @@ BreadcrumbButton::paintEvent( QPaintEvent* )
p.drawLine( l2 );
}
+
QSize
BreadcrumbButton::sizeHint() const
{
@@ -125,7 +127,6 @@ BreadcrumbButton::setParentIndex( const QModelIndex& idx )
}
}
-
if ( m_combo->count() && list.count() )
{
// Check if it's the same, Don't change if it is, as it'll cause flickering
@@ -152,6 +153,7 @@ BreadcrumbButton::setParentIndex( const QModelIndex& idx )
m_combo->adjustSize();
}
+
void
BreadcrumbButton::comboboxActivated( int idx )
{
@@ -171,6 +173,7 @@ BreadcrumbButton::hasChildren() const
return m_model->rowCount( m_model->index( m_combo->currentIndex(), 0, m_parentIndex ) ) > 0;
}
+
QModelIndex
BreadcrumbButton::currentIndex() const
{
diff --git a/src/libtomahawk/widgets/BreadcrumbButton.h b/src/libtomahawk/widgets/BreadcrumbButton.h
index d7efaa96d..9735bfff7 100644
--- a/src/libtomahawk/widgets/BreadcrumbButton.h
+++ b/src/libtomahawk/widgets/BreadcrumbButton.h
@@ -42,6 +42,7 @@ public:
// calculated immediately after loading, or what the user has selected if he has made
// a manua;l selection
QModelIndex currentIndex() const;
+
protected:
virtual void paintEvent( QPaintEvent* );
virtual QSize sizeHint() const;
diff --git a/src/libtomahawk/widgets/combobox.cpp b/src/libtomahawk/widgets/combobox.cpp
index e02016cf1..11cb959f5 100644
--- a/src/libtomahawk/widgets/combobox.cpp
+++ b/src/libtomahawk/widgets/combobox.cpp
@@ -19,6 +19,8 @@
#include "combobox.h"
#include "utils/stylehelper.h"
+#include "utils/tomahawkutilsgui.h"
+#include "utils/logger.h"
#include
#include
@@ -37,6 +39,13 @@ ComboBox::~ComboBox()
}
+QSize
+ComboBox::sizeHint() const
+{
+ return QComboBox::sizeHint() + QSize( 8, 0 );
+}
+
+
void
ComboBox::paintEvent( QPaintEvent* )
{
@@ -45,24 +54,26 @@ ComboBox::paintEvent( QPaintEvent* )
QStyleOptionComboBox cb;
initStyleOption( &cb );
QRect r = cb.rect;
+ r.setHeight( TomahawkUtils::headerHeight() );
StyleHelper::horizontalHeader( &p, r );
if ( cb.state & QStyle::State_MouseOver )
{
+ p.save();
QRect highlightRect( r );
QSize shrink( 3, 4 );
QSize hS( highlightRect.size() );
hS -= shrink;
highlightRect.setSize( hS );
highlightRect.translate( 0, 2 );
- p.save();
p.setRenderHint( QPainter::Antialiasing );
p.setBrush( StyleHelper::headerHighlightColor() );
p.drawRoundedRect( highlightRect, 10.0, 10.0 );
p.restore();
}
+ p.save();
QTextOption to( Qt::AlignVCenter );
r.adjust( 8, 0, -8, 0 );
p.setPen( Qt::white );
@@ -78,4 +89,5 @@ ComboBox::paintEvent( QPaintEvent* )
QStyleOption arrowOpt = cb;
arrowOpt.rect = arrowRect;
StyleHelper::drawArrow( QStyle::PE_IndicatorArrowDown, &p, &arrowOpt );
+ p.restore();
}
diff --git a/src/libtomahawk/widgets/combobox.h b/src/libtomahawk/widgets/combobox.h
index 18176bf87..d28e30843 100644
--- a/src/libtomahawk/widgets/combobox.h
+++ b/src/libtomahawk/widgets/combobox.h
@@ -36,6 +36,9 @@ public:
ComboBox( QWidget* parent = 0 );
virtual ~ComboBox();
+ virtual QSize sizeHint() const;
+
+protected:
virtual void paintEvent( QPaintEvent* );
};
diff --git a/src/libtomahawk/widgets/headerbreadcrumb.cpp b/src/libtomahawk/widgets/headerbreadcrumb.cpp
index 1166e9e15..a638164d0 100644
--- a/src/libtomahawk/widgets/headerbreadcrumb.cpp
+++ b/src/libtomahawk/widgets/headerbreadcrumb.cpp
@@ -24,22 +24,25 @@
#include
#include
-HeaderBreadCrumb::HeaderBreadCrumb(BreadcrumbButtonFactory *buttonFactory, QWidget *parent) :
- BreadcrumbBar(buttonFactory, parent)
+HeaderBreadCrumb::HeaderBreadCrumb( BreadcrumbButtonFactory* buttonFactory, QWidget* parent )
+ : BreadcrumbBar( buttonFactory, parent )
{
}
-HeaderBreadCrumb::HeaderBreadCrumb(QWidget *parent) :
- BreadcrumbBar(parent)
+
+HeaderBreadCrumb::HeaderBreadCrumb( QWidget* parent )
+ : BreadcrumbBar( parent )
{
}
+
HeaderBreadCrumb::~HeaderBreadCrumb()
{
}
-void HeaderBreadCrumb::paintEvent(QPaintEvent *event)
+
+void HeaderBreadCrumb::paintEvent( QPaintEvent* /* event */ )
{
- QStylePainter p(this);
- StyleHelper::horizontalHeader(&p, rect());
+ QStylePainter p( this );
+ StyleHelper::horizontalHeader( &p, rect() );
}
diff --git a/src/libtomahawk/widgets/headerbreadcrumb.h b/src/libtomahawk/widgets/headerbreadcrumb.h
index f06c5240d..8b15ca5a8 100644
--- a/src/libtomahawk/widgets/headerbreadcrumb.h
+++ b/src/libtomahawk/widgets/headerbreadcrumb.h
@@ -30,13 +30,12 @@ class HeaderBreadCrumb : public BreadcrumbBar
{
Q_OBJECT
public:
- HeaderBreadCrumb(BreadcrumbButtonFactory *buttonFactory, QWidget *parent = 0);
- HeaderBreadCrumb(QWidget *parent = 0);
+ HeaderBreadCrumb( BreadcrumbButtonFactory* buttonFactory, QWidget* parent = 0 );
+ HeaderBreadCrumb( QWidget* parent = 0 );
~HeaderBreadCrumb();
protected:
-
- virtual void paintEvent(QPaintEvent *event);
+ virtual void paintEvent( QPaintEvent* event );
};
#endif
diff --git a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.cpp b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.cpp
index 0b70bb809..178af0175 100644
--- a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.cpp
+++ b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.cpp
@@ -87,8 +87,6 @@ AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, ModelMode st
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
- connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
-
load( album );
}
@@ -192,6 +190,9 @@ AlbumInfoWidget::descriptionType()
void
AlbumInfoWidget::load( const album_ptr& album )
{
+ if ( !m_album.isNull() )
+ disconnect( m_album.data(), SIGNAL( updated() ), this, SLOT( onAlbumCoverUpdated() ) );
+
m_album = album;
m_title = album->name();
m_description = album->artist()->name();
@@ -201,17 +202,8 @@ AlbumInfoWidget::load( const album_ptr& album )
m_tracksModel->addTracks( album, QModelIndex(), true );
loadAlbums( true );
- Tomahawk::InfoSystem::InfoStringHash trackInfo;
- trackInfo["artist"] = album->artist()->name();
- trackInfo["album"] = album->name();
-
- Tomahawk::InfoSystem::InfoRequestData requestData;
- requestData.caller = m_infoId;
- requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
- requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
- requestData.customData = QVariantMap();
-
- Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
+ connect( m_album.data(), SIGNAL( updated() ), SLOT( onAlbumCoverUpdated() ) );
+ onAlbumCoverUpdated();
}
@@ -245,6 +237,17 @@ AlbumInfoWidget::loadAlbums( bool autoRefetch )
}
+void
+AlbumInfoWidget::onAlbumCoverUpdated()
+{
+ if ( m_album->cover().isNull() )
+ return;
+
+ m_pixmap.loadFromData( m_album->cover() );
+ emit pixmapChanged( m_pixmap );
+}
+
+
void
AlbumInfoWidget::gotAlbums( const QList& albums )
{
@@ -269,11 +272,6 @@ AlbumInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDa
if ( output.canConvert< QVariantMap >() )
{
- if ( requestData.type == InfoSystem::InfoAlbumCoverArt && trackInfo["album"] != m_album->name() )
- {
- qDebug() << "Returned info was for:" << trackInfo["album"] << "- was looking for:" << m_album->name();
- return;
- }
if ( requestData.type == InfoSystem::InfoArtistReleases && trackInfo["artist"] != m_album->artist()->name() )
{
qDebug() << "Returned info was for:" << trackInfo["artist"] << "- was looking for:" << m_album->artist()->name();
@@ -284,18 +282,6 @@ AlbumInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDa
QVariantMap returnedData = output.value< QVariantMap >();
switch ( requestData.type )
{
- case Tomahawk::InfoSystem::InfoAlbumCoverArt:
- {
- const QByteArray ba = returnedData["imgbytes"].toByteArray();
- if ( ba.length() )
- {
- m_pixmap.loadFromData( ba );
- emit pixmapChanged( m_pixmap );
- }
-
- break;
- }
-
case Tomahawk::InfoSystem::InfoArtistReleases:
{
QStringList albums = returnedData[ "albums" ].toStringList();
@@ -335,13 +321,6 @@ AlbumInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDa
}
-void
-AlbumInfoWidget::infoSystemFinished( QString target )
-{
- Q_UNUSED( target );
-}
-
-
void
AlbumInfoWidget::changeEvent( QEvent* e )
{
diff --git a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.h b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.h
index 56ce5dc4e..23aafb046 100644
--- a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.h
+++ b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.h
@@ -94,9 +94,9 @@ protected:
private slots:
void loadAlbums( bool autoRefetch = false );
void gotAlbums( const QList& albums );
+ void onAlbumCoverUpdated();
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
- void infoSystemFinished( QString target );
void onModeToggle();
void onAlbumsModeToggle();
diff --git a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp
index 0bdcb51de..178713c04 100644
--- a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp
+++ b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp
@@ -21,6 +21,7 @@
#include "ui_ArtistInfoWidget.h"
#include "audio/audioengine.h"
+#include "playlist/trackheader.h"
#include "playlist/treemodel.h"
#include "playlist/playlistmodel.h"
#include "playlist/treeproxymodel.h"
@@ -68,10 +69,13 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
m_relatedModel = new TreeModel( ui->relatedArtists );
m_relatedModel->setColumnStyle( TreeModel::TrackOnly );
ui->relatedArtists->setTreeModel( m_relatedModel );
+ ui->relatedArtists->setSortingEnabled( false );
+ ui->relatedArtists->proxyModel()->sort( -1 );
m_topHitsModel = new PlaylistModel( ui->topHits );
m_topHitsModel->setStyle( TrackModel::Short );
ui->topHits->setTrackModel( m_topHitsModel );
+ ui->topHits->setSortingEnabled( false );
m_pixmap = QPixmap( RESPATH "images/no-album-no-case.png" ).scaledToWidth( 48, Qt::SmoothTransformation );
@@ -89,8 +93,6 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
- connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
-
load( artist );
}
@@ -182,6 +184,9 @@ ArtistInfoWidget::jumpToCurrentTrack()
void
ArtistInfoWidget::load( const artist_ptr& artist )
{
+ if ( !m_artist.isNull() )
+ disconnect( m_artist.data(), SIGNAL( updated() ), this, SLOT( onArtistImageUpdated() ) );
+
m_artist = artist;
m_title = artist->name();
m_albumsModel->addAlbums( artist, QModelIndex(), true );
@@ -199,10 +204,6 @@ ArtistInfoWidget::load( const artist_ptr& artist )
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
- requestData.type = Tomahawk::InfoSystem::InfoArtistImages;
- requestData.requestId = TomahawkUtils::infosystemRequestId();
- Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
-
requestData.type = Tomahawk::InfoSystem::InfoArtistSimilars;
requestData.requestId = TomahawkUtils::infosystemRequestId();
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
@@ -210,6 +211,9 @@ ArtistInfoWidget::load( const artist_ptr& artist )
requestData.type = Tomahawk::InfoSystem::InfoArtistSongs;
requestData.requestId = TomahawkUtils::infosystemRequestId();
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
+
+ connect( m_artist.data(), SIGNAL( updated() ), SLOT( onArtistImageUpdated() ) );
+ onArtistImageUpdated();
}
@@ -252,31 +256,17 @@ ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestD
{
const QStringList tracks = returnedData["tracks"].toStringList();
+ QList< query_ptr > queries;
int i = 0;
foreach ( const QString& track, tracks )
{
- query_ptr query = Query::get( m_artist->name(), track, QString(), uuid() );
- m_topHitsModel->append( query );
+ queries << Query::get( m_artist->name(), track, QString(), uuid() );
if ( ++i == 15 )
break;
}
- break;
- }
- case InfoSystem::InfoArtistImages:
- {
- const QByteArray ba = returnedData["imgbytes"].toByteArray();
- if ( ba.length() )
- {
- QPixmap pm;
- pm.loadFromData( ba );
-
- if ( !pm.isNull() )
- m_pixmap = pm.scaledToHeight( 48, Qt::SmoothTransformation );
-
- emit pixmapChanged( m_pixmap );
- }
+ m_topHitsModel->append( queries );
break;
}
@@ -297,9 +287,13 @@ ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestD
void
-ArtistInfoWidget::infoSystemFinished( QString target )
+ArtistInfoWidget::onArtistImageUpdated()
{
- Q_UNUSED( target );
+ if ( m_artist->cover().isNull() )
+ return;
+
+ m_pixmap.loadFromData( m_artist->cover() );
+ emit pixmapChanged( m_pixmap );
}
diff --git a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.h b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.h
index b851a7325..fb1568792 100644
--- a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.h
+++ b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.h
@@ -93,7 +93,7 @@ private slots:
void setMode( Tomahawk::ModelMode mode );
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
- void infoSystemFinished( QString target );
+ void onArtistImageUpdated();
void onModeToggle();
void onLoadingStarted();
diff --git a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget_p.h b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget_p.h
index a50bb1a31..91b673a6a 100644
--- a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget_p.h
+++ b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget_p.h
@@ -35,27 +35,27 @@ public:
: PlaylistInterface()
, m_w( w )
{
- connect( m_w->ui->albums->proxyModel(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
+ connect( m_w->ui->albums->proxyModel()->playlistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
SLOT( anyRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
- connect( m_w->ui->relatedArtists->proxyModel(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
+ connect( m_w->ui->relatedArtists->proxyModel()->playlistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
SLOT( anyRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
- connect( m_w->ui->topHits->proxyModel(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
+ connect( m_w->ui->topHits->proxyModel()->playlistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
SLOT( anyRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
- connect( m_w->ui->albums->proxyModel(), SIGNAL( shuffleModeChanged( bool ) ),
+ connect( m_w->ui->albums->proxyModel()->playlistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ),
SLOT( anyShuffleChanged( bool ) ) );
- connect( m_w->ui->relatedArtists->proxyModel(), SIGNAL( shuffleModeChanged( bool ) ),
+ connect( m_w->ui->relatedArtists->proxyModel()->playlistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ),
SLOT( anyShuffleChanged( bool ) ) );
- connect( m_w->ui->topHits->proxyModel(), SIGNAL( shuffleModeChanged( bool ) ),
+ connect( m_w->ui->topHits->proxyModel()->playlistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ),
SLOT( anyShuffleChanged( bool ) ) );
}
virtual ~MetaPlaylistInterface() {}
// Any one is fine, we keep them all synched
- virtual RepeatMode repeatMode() const { return m_w->ui->albums->proxyModel()->getPlaylistInterface()->repeatMode(); }
+ virtual RepeatMode repeatMode() const { return m_w->ui->albums->proxyModel()->playlistInterface()->repeatMode(); }
- virtual bool shuffled() const { return m_w->ui->albums->proxyModel()->getPlaylistInterface()->shuffled(); }
+ virtual bool shuffled() const { return m_w->ui->albums->proxyModel()->playlistInterface()->shuffled(); }
// Do nothing
virtual Tomahawk::result_ptr currentItem() const { return Tomahawk::result_ptr(); }
@@ -74,16 +74,16 @@ public:
public slots:
virtual void setRepeatMode( RepeatMode mode )
{
- m_w->ui->albums->proxyModel()->getPlaylistInterface()->setRepeatMode( mode );
- m_w->ui->relatedArtists->proxyModel()->getPlaylistInterface()->setRepeatMode( mode );
- m_w->ui->topHits->proxyModel()->getPlaylistInterface()->setRepeatMode( mode );
+ m_w->ui->albums->proxyModel()->playlistInterface()->setRepeatMode( mode );
+ m_w->ui->relatedArtists->proxyModel()->playlistInterface()->setRepeatMode( mode );
+ m_w->ui->topHits->proxyModel()->playlistInterface()->setRepeatMode( mode );
}
virtual void setShuffled( bool enabled )
{
- m_w->ui->albums->proxyModel()->getPlaylistInterface()->setShuffled( enabled );
- m_w->ui->relatedArtists->proxyModel()->getPlaylistInterface()->setShuffled( enabled );
- m_w->ui->topHits->proxyModel()->getPlaylistInterface()->setShuffled( enabled );
+ m_w->ui->albums->proxyModel()->playlistInterface()->setShuffled( enabled );
+ m_w->ui->relatedArtists->proxyModel()->playlistInterface()->setShuffled( enabled );
+ m_w->ui->topHits->proxyModel()->playlistInterface()->setShuffled( enabled );
}
signals:
diff --git a/src/libtomahawk/widgets/whatshotwidget.cpp b/src/libtomahawk/widgets/whatshotwidget.cpp
index 062139050..114e12e61 100644
--- a/src/libtomahawk/widgets/whatshotwidget.cpp
+++ b/src/libtomahawk/widgets/whatshotwidget.cpp
@@ -57,8 +57,8 @@ WhatsHotWidget::WhatsHotWidget( QWidget* parent )
{
ui->setupUi( this );
- ui->additionsView->setFrameShape( QFrame::NoFrame );
- ui->additionsView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
+ ui->albumsView->setFrameShape( QFrame::NoFrame );
+ ui->albumsView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
TomahawkUtils::unmarginLayout( layout() );
TomahawkUtils::unmarginLayout( ui->stackLeft->layout() );
@@ -91,7 +91,7 @@ WhatsHotWidget::WhatsHotWidget( QWidget* parent )
ui->artistsViewLeft->setAttribute( Qt::WA_MacShowFocusRect, 0 );
ui->artistsViewLeft->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
- ui->artistsViewLeft->header()->setVisible( false );
+ ui->artistsViewLeft->header()->setVisible( true );
m_playlistInterface = Tomahawk::playlistinterface_ptr( new ChartsPlaylistInterface( this ) );
@@ -257,7 +257,8 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
connect( loader, SIGNAL( artists( Tomahawk::ChartDataLoader*, QList< Tomahawk::artist_ptr > ) ), this, SLOT( chartArtistsLoaded( Tomahawk::ChartDataLoader*, QList< Tomahawk::artist_ptr > ) ) );
TreeModel* artistsModel = new TreeModel( ui->artistsViewLeft );
- artistsModel->setColumnStyle( TreeModel::TrackOnly );
+ artistsModel->setMode( InfoSystemMode );
+ artistsModel->setColumnStyle( TreeModel::AllColumns );
m_artistModels[ chartId ] = artistsModel;
@@ -272,7 +273,7 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
connect( loader, SIGNAL( albums( Tomahawk::ChartDataLoader*, QList< Tomahawk::album_ptr > ) ), this, SLOT( chartAlbumsLoaded( Tomahawk::ChartDataLoader*, QList< Tomahawk::album_ptr > ) ) );
- AlbumModel* albumModel = new AlbumModel( ui->additionsView );
+ AlbumModel* albumModel = new AlbumModel( ui->albumsView );
m_albumModels[ chartId ] = albumModel;
@@ -448,8 +449,8 @@ WhatsHotWidget::parseNode( QStandardItem* parentItem, const QString &label, cons
void
WhatsHotWidget::setLeftViewAlbums( AlbumModel* model )
{
- ui->additionsView->setAlbumModel( model );
- ui->additionsView->proxyModel()->sort( -1 ); // disable sorting, must be called after artistsViewLeft->setTreeModel
+ ui->albumsView->setAlbumModel( model );
+ ui->albumsView->proxyModel()->sort( -1 ); // disable sorting, must be called after artistsViewLeft->setTreeModel
ui->stackLeft->setCurrentIndex( 2 );
}
diff --git a/src/libtomahawk/widgets/whatshotwidget.ui b/src/libtomahawk/widgets/whatshotwidget.ui
index 7c635acf8..d62df772d 100644
--- a/src/libtomahawk/widgets/whatshotwidget.ui
+++ b/src/libtomahawk/widgets/whatshotwidget.ui
@@ -47,7 +47,7 @@
-
-
+
true
diff --git a/src/libtomahawk/widgets/whatshotwidget_p.h b/src/libtomahawk/widgets/whatshotwidget_p.h
index b9602ae94..0baf2f7cc 100644
--- a/src/libtomahawk/widgets/whatshotwidget_p.h
+++ b/src/libtomahawk/widgets/whatshotwidget_p.h
@@ -39,22 +39,22 @@ public:
: PlaylistInterface()
, m_w( w )
{
- connect( m_w->ui->tracksViewLeft->proxyModel()->getPlaylistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
+ connect( m_w->ui->tracksViewLeft->proxyModel()->playlistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
SLOT( anyRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
- connect( m_w->ui->artistsViewLeft->proxyModel()->getPlaylistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
+ connect( m_w->ui->artistsViewLeft->proxyModel()->playlistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
SLOT( anyRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
- connect( m_w->ui->tracksViewLeft->proxyModel()->getPlaylistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ),
+ connect( m_w->ui->tracksViewLeft->proxyModel()->playlistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ),
SLOT( anyShuffleChanged( bool ) ) );
- connect( m_w->ui->artistsViewLeft->proxyModel()->getPlaylistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ),
+ connect( m_w->ui->artistsViewLeft->proxyModel()->playlistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ),
SLOT( anyShuffleChanged( bool ) ) );
}
virtual ~ChartsPlaylistInterface() {}
// Any one is fine, we keep them all synched
- virtual RepeatMode repeatMode() const { return m_w->ui->tracksViewLeft->proxyModel()->getPlaylistInterface()->repeatMode(); }
+ virtual RepeatMode repeatMode() const { return m_w->ui->tracksViewLeft->proxyModel()->playlistInterface()->repeatMode(); }
- virtual bool shuffled() const { return m_w->ui->tracksViewLeft->proxyModel()->getPlaylistInterface()->shuffled(); }
+ virtual bool shuffled() const { return m_w->ui->tracksViewLeft->proxyModel()->playlistInterface()->shuffled(); }
// Do nothing
virtual Tomahawk::result_ptr currentItem() const { return Tomahawk::result_ptr(); }
@@ -73,14 +73,14 @@ public:
public slots:
virtual void setRepeatMode( RepeatMode mode )
{
- m_w->ui->tracksViewLeft->proxyModel()->getPlaylistInterface()->setRepeatMode( mode );
- m_w->ui->artistsViewLeft->proxyModel()->getPlaylistInterface()->setRepeatMode( mode );
+ m_w->ui->tracksViewLeft->proxyModel()->playlistInterface()->setRepeatMode( mode );
+ m_w->ui->artistsViewLeft->proxyModel()->playlistInterface()->setRepeatMode( mode );
}
virtual void setShuffled( bool enabled )
{
- m_w->ui->tracksViewLeft->proxyModel()->getPlaylistInterface()->setShuffled( enabled );
- m_w->ui->artistsViewLeft->proxyModel()->getPlaylistInterface()->setShuffled( enabled );
+ m_w->ui->tracksViewLeft->proxyModel()->playlistInterface()->setShuffled( enabled );
+ m_w->ui->artistsViewLeft->proxyModel()->playlistInterface()->setShuffled( enabled );
}
signals:
diff --git a/src/musicscanner.cpp b/src/musicscanner.cpp
index 84c22d3e1..14f619aeb 100644
--- a/src/musicscanner.cpp
+++ b/src/musicscanner.cpp
@@ -18,7 +18,7 @@
#include "musicscanner.h"
-#include
+#include
#include "utils/tomahawkutils.h"
#include "tomahawksettings.h"
@@ -29,6 +29,7 @@
#include "database/databasecommand_collectionstats.h"
#include "database/databasecommand_addfiles.h"
#include "database/databasecommand_deletefiles.h"
+#include "taghandlers/tag.h"
#include "utils/logger.h"
@@ -333,7 +334,9 @@ MusicScanner::readFile( const QFileInfo& fi )
int bitrate = 0;
int duration = 0;
- TagLib::Tag *tag = f.tag();
+
+ Tag *tag = Tag::fromFile( f );
+
if ( f.audioProperties() )
{
TagLib::AudioProperties *properties = f.audioProperties();
@@ -341,9 +344,9 @@ MusicScanner::readFile( const QFileInfo& fi )
bitrate = properties->bitrate();
}
- QString artist = TStringToQString( tag->artist() ).trimmed();
- QString album = TStringToQString( tag->album() ).trimmed();
- QString track = TStringToQString( tag->title() ).trimmed();
+ QString artist = tag->artist().trimmed();
+ QString album = tag->album().trimmed();
+ QString track = tag->title().trimmed();
if ( artist.isEmpty() || track.isEmpty() )
{
// FIXME: do some clever filename guessing
@@ -367,6 +370,9 @@ MusicScanner::readFile( const QFileInfo& fi )
m["track"] = track;
m["albumpos"] = tag->track();
m["year"] = tag->year();
+ m["albumartist"] = tag->albumArtist();
+ m["composer"] = tag->composer();
+ m["discnumber"] = tag->discNumber();
m["hash"] = ""; // TODO
m_scanned++;
diff --git a/src/musicscanner.h b/src/musicscanner.h
index ed59d3cc5..e5ed08369 100644
--- a/src/musicscanner.h
+++ b/src/musicscanner.h
@@ -26,15 +26,15 @@
#include
#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
#include
// descend dir tree comparing dir mtimes to last known mtime
diff --git a/src/scanmanager.cpp b/src/scanmanager.cpp
index a9061cb2f..1209f58ce 100644
--- a/src/scanmanager.cpp
+++ b/src/scanmanager.cpp
@@ -18,9 +18,9 @@
#include "scanmanager.h"
-#include
-#include
-#include
+#include
+#include
+#include
#include "musicscanner.h"
#include "tomahawksettings.h"
diff --git a/src/scanmanager.h b/src/scanmanager.h
index c08a070d6..77632c2f2 100644
--- a/src/scanmanager.h
+++ b/src/scanmanager.h
@@ -21,12 +21,12 @@
#include "typedefs.h"
-#include
-#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
+#include
+#include
+#include
class MusicScanner;
class QThread;
diff --git a/src/sourcetree/items/sourceitem.cpp b/src/sourcetree/items/sourceitem.cpp
index 9eafeab36..f4084b38e 100644
--- a/src/sourcetree/items/sourceitem.cpp
+++ b/src/sourcetree/items/sourceitem.cpp
@@ -108,7 +108,7 @@ SourceItem::SourceItem( SourcesModel* mdl, SourceTreeItem* parent, const Tomahaw
SLOT( onAutoPlaylistsAdded( QList ) ), Qt::QueuedConnection );
connect( source->collection().data(), SIGNAL( stationsAdded( QList ) ),
SLOT( onStationsAdded( QList ) ), Qt::QueuedConnection );
-
+
if ( m_source->isLocal() )
QTimer::singleShot( 0, this, SLOT( requestExpanding() ) );
}
@@ -193,12 +193,23 @@ SourceItem::localLatchedOn() const
}
+Tomahawk::PlaylistInterface::LatchMode
+SourceItem::localLatchMode() const
+{
+ if ( !m_source.isNull() && !m_source->isLocal() )
+ return m_source->playlistInterface()->latchMode();
+
+ return Tomahawk::PlaylistInterface::StayOnSong;
+}
+
+
void
SourceItem::latchedOff( const source_ptr& from, const source_ptr& to )
{
if ( from->isLocal() && ( m_source == to || m_source == from ) )
{
m_latchedOn = false;
+ disconnect( m_latchedOnTo->playlistInterface().data(), SIGNAL( latchModeChanged( Tomahawk::PlaylistInterface::LatchMode ) ) );
m_latchedOnTo.clear();
emit updated();
}
@@ -212,11 +223,20 @@ SourceItem::latchedOn( const source_ptr& from, const source_ptr& to )
{
m_latchedOn = true;
m_latchedOnTo = to;
+ connect( m_latchedOnTo->playlistInterface().data(), SIGNAL( latchModeChanged( Tomahawk::PlaylistInterface::LatchMode ) ), SLOT( latchModeChanged( Tomahawk::PlaylistInterface::LatchMode ) ) );
emit updated();
}
}
+void
+SourceItem::latchModeChanged( Tomahawk::PlaylistInterface::LatchMode mode )
+{
+ Q_UNUSED( mode );
+ emit updated();
+}
+
+
void
SourceItem::playlistsAddedInternal( SourceTreeItem* parent, const QList< dynplaylist_ptr >& playlists )
{
diff --git a/src/sourcetree/items/sourceitem.h b/src/sourcetree/items/sourceitem.h
index 0b9230a8e..4aa84443d 100644
--- a/src/sourcetree/items/sourceitem.h
+++ b/src/sourcetree/items/sourceitem.h
@@ -42,6 +42,7 @@ public:
virtual int IDValue() const;
virtual bool localLatchedOn() const;
+ virtual Tomahawk::PlaylistInterface::LatchMode localLatchMode() const;
Tomahawk::source_ptr source() const;
@@ -63,6 +64,7 @@ private slots:
void latchedOn( const Tomahawk::source_ptr&, const Tomahawk::source_ptr& );
void latchedOff( const Tomahawk::source_ptr&, const Tomahawk::source_ptr& );
+ void latchModeChanged( Tomahawk::PlaylistInterface::LatchMode mode );
void requestExpanding();
diff --git a/src/sourcetree/sourcedelegate.cpp b/src/sourcetree/sourcedelegate.cpp
index ad0fd4855..61362ae6f 100644
--- a/src/sourcetree/sourcedelegate.cpp
+++ b/src/sourcetree/sourcedelegate.cpp
@@ -66,6 +66,8 @@ SourceDelegate::SourceDelegate( QAbstractItemView* parent )
m_headphonesOff.load( RESPATH "images/headphones-off.png" );
m_headphonesOn.load( RESPATH "images/headphones-sidebar.png" );
+ m_realtimeLocked.load( RESPATH "images/closed-padlock.png" );
+ m_realtimeUnlocked.load( RESPATH "images/open-padlock.png" );
m_nowPlayingSpeaker.load( RESPATH "images/now-playing-speaker.png" );
m_nowPlayingSpeakerDark.load( RESPATH "images/now-playing-speaker-dark.png" );
}
@@ -187,13 +189,13 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem&
if ( desc.isEmpty() )
desc = tr( "Online" );
- textRect = option.rect.adjusted( iconRect.width() + 8, painter->fontMetrics().height() + 9, -figWidth - 24, -6 );
painter->setFont( normal );
+ textRect = option.rect.adjusted( iconRect.width() + 8, option.rect.height() / 2, -figWidth - 24, -6 );
+
bool privacyOn = TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::FullyPrivate;
if ( !colItem->source().isNull() && colItem->source()->isLocal() && privacyOn )
{
QRect pmRect = textRect;
- pmRect.setTop( pmRect.bottom() - painter->fontMetrics().height() + 3 );
pmRect.setRight( pmRect.left() + pmRect.height() );
ActionCollection::instance()->getAction( "togglePrivacy" )->icon().paint( painter, pmRect );
textRect.adjust( pmRect.width() + 3, 0, 0, 0 );
@@ -201,30 +203,44 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem&
if ( isPlaying || ( !colItem->source().isNull() && colItem->source()->isLocal() ) )
{
// Show a listen icon
- QPixmap pm;
+ QPixmap listenAlongPixmap;
+ QPixmap realtimeListeningAlongPixmap;
if ( index.data( SourcesModel::LatchedOnRole ).toBool() )
{
// Currently listening along
- pm = m_headphonesOn;
+ listenAlongPixmap = m_headphonesOn;
+ if ( !colItem->source()->isLocal() )
+ {
+ realtimeListeningAlongPixmap =
+ colItem->source()->playlistInterface()->latchMode() == Tomahawk::PlaylistInterface::RealTime ?
+ m_realtimeLocked : m_realtimeUnlocked;
+ }
}
else if ( !colItem->source()->isLocal() )
{
- pm = m_headphonesOff;
+ listenAlongPixmap = m_headphonesOff;
}
- if ( !pm.isNull() )
+ if ( !listenAlongPixmap.isNull() )
{
QRect pmRect = textRect;
- pmRect.setTop( pmRect.bottom() - painter->fontMetrics().height() + 3 );
pmRect.setRight( pmRect.left() + pmRect.height() );
- painter->drawPixmap( pmRect, pm.scaledToHeight( pmRect.height(), Qt::SmoothTransformation ) );
+ painter->drawPixmap( pmRect, listenAlongPixmap.scaledToHeight( pmRect.height(), Qt::SmoothTransformation ) );
+ textRect.adjust( pmRect.width() + 3, 0, 0, 0 );
+ }
+
+ if ( !realtimeListeningAlongPixmap.isNull() )
+ {
+ QRect pmRect = textRect;
+ pmRect.setRight( pmRect.left() + pmRect.height() );
+ painter->drawPixmap( pmRect, realtimeListeningAlongPixmap.scaledToHeight( pmRect.height(), Qt::SmoothTransformation ) );
textRect.adjust( pmRect.width() + 3, 0, 0, 0 );
}
}
text = painter->fontMetrics().elidedText( desc, Qt::ElideRight, textRect.width() );
- QTextOption to( Qt::AlignBottom );
- painter->drawText( textRect, text, to );
+ QTextOption to( Qt::AlignVCenter );
+ painter->drawText( textRect.adjusted( 0, 0, 0, 2 ), text, to );
if ( status )
{
@@ -578,15 +594,23 @@ SourceDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QSt
const int height = fm.height() + 3;
QRect headphonesRect( option.rect.height() + 10, o.rect.bottom() - height, height, height );
- if ( headphonesRect.contains( ev->pos() ) )
+ bool headphonesRectContainsClick = headphonesRect.contains( ev->pos() );
+ QRect lockRect( option.rect.height() + 20, o.rect.bottom() - height, height, height );
+ bool lockRectContainsClick = lockRect.contains( ev->pos() );
+ if ( headphonesRectContainsClick || lockRectContainsClick )
{
if ( event->type() == QEvent::MouseButtonRelease )
{
- if ( index.data( SourcesModel::LatchedOnRole ).toBool() )
- // unlatch
- emit latchOff( colItem->source() );
- else
- emit latchOn( colItem->source() );
+ if ( headphonesRectContainsClick )
+ {
+ if ( index.data( SourcesModel::LatchedOnRole ).toBool() )
+ // unlatch
+ emit latchOff( colItem->source() );
+ else
+ emit latchOn( colItem->source() );
+ }
+ else // it's in the lock rect
+ emit toggleRealtimeLatch( colItem->source(), !index.data( SourcesModel::LatchedRealtimeRole ).toBool() );
}
return true;
}
diff --git a/src/sourcetree/sourcedelegate.h b/src/sourcetree/sourcedelegate.h
index 2fc371ba8..1f6cea627 100644
--- a/src/sourcetree/sourcedelegate.h
+++ b/src/sourcetree/sourcedelegate.h
@@ -44,6 +44,7 @@ public:
signals:
void latchOn( const Tomahawk::source_ptr& idx );
void latchOff( const Tomahawk::source_ptr& idx );
+ void toggleRealtimeLatch( const Tomahawk::source_ptr& idx, bool realtime );
protected:
virtual QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
@@ -69,7 +70,7 @@ private:
QMimeData *m_dropMimeData;
mutable SourceTreeItem::DropType m_hoveredDropType; // Hack to keep easily track of the current highlighted DropType in paint()
QMap< QModelIndex, AnimationHelper* > m_expandedMap;
- QPixmap m_headphonesOn, m_headphonesOff, m_nowPlayingSpeaker, m_nowPlayingSpeakerDark;
+ QPixmap m_headphonesOn, m_headphonesOff, m_realtimeLocked, m_realtimeUnlocked, m_nowPlayingSpeaker, m_nowPlayingSpeakerDark;
QMap< int, SourceTreeItem::DropType > m_dropTypeMap;
QMap< int, QString > m_dropTypeTextMap;
diff --git a/src/sourcetree/sourcesmodel.cpp b/src/sourcetree/sourcesmodel.cpp
index 6e81995fc..dfe877d96 100644
--- a/src/sourcetree/sourcesmodel.cpp
+++ b/src/sourcetree/sourcesmodel.cpp
@@ -127,6 +127,15 @@ SourcesModel::data( const QModelIndex& index, int role ) const
}
return false;
}
+ case SourcesModel::LatchedRealtimeRole:
+ {
+ if ( itemFromIndex( index )->type() == Collection )
+ {
+ SourceItem* cItem = qobject_cast< SourceItem* >( itemFromIndex( index ) );
+ return cItem->localLatchMode() == Tomahawk::PlaylistInterface::RealTime;
+ }
+ return false;
+ }
}
return QVariant();
}
diff --git a/src/sourcetree/sourcesmodel.h b/src/sourcetree/sourcesmodel.h
index 6f2e69605..969067396 100644
--- a/src/sourcetree/sourcesmodel.h
+++ b/src/sourcetree/sourcesmodel.h
@@ -70,7 +70,8 @@ public:
SourceTreeItemTypeRole = Qt::UserRole + 11,
SortRole = Qt::UserRole + 12,
IDRole = Qt::UserRole + 13,
- LatchedOnRole = Qt::UserRole + 14
+ LatchedOnRole = Qt::UserRole + 14,
+ LatchedRealtimeRole = Qt::UserRole + 15
};
SourcesModel( QObject* parent = 0 );
diff --git a/src/sourcetree/sourcesproxymodel.cpp b/src/sourcetree/sourcesproxymodel.cpp
index 2b5eeec94..a0db5e2ea 100644
--- a/src/sourcetree/sourcesproxymodel.cpp
+++ b/src/sourcetree/sourcesproxymodel.cpp
@@ -19,7 +19,7 @@
#include "sourcesproxymodel.h"
-#include
+#include
#include "sourcelist.h"
#include "sourcesmodel.h"
diff --git a/src/sourcetree/sourcesproxymodel.h b/src/sourcetree/sourcesproxymodel.h
index 1d66277f9..60e24e62b 100644
--- a/src/sourcetree/sourcesproxymodel.h
+++ b/src/sourcetree/sourcesproxymodel.h
@@ -19,7 +19,7 @@
#ifndef SOURCESPROXYMODEL_H
#define SOURCESPROXYMODEL_H
-#include
+#include
class SourcesModel;
diff --git a/src/sourcetree/sourcetreeview.cpp b/src/sourcetree/sourcetreeview.cpp
index 242315b4b..7e74c08f9 100644
--- a/src/sourcetree/sourcetreeview.cpp
+++ b/src/sourcetree/sourcetreeview.cpp
@@ -86,6 +86,7 @@ SourceTreeView::SourceTreeView( QWidget* parent )
m_delegate = new SourceDelegate( this );
connect( m_delegate, SIGNAL( latchOn( Tomahawk::source_ptr ) ), SLOT( latchOnOrCatchUp( Tomahawk::source_ptr ) ) );
connect( m_delegate, SIGNAL( latchOff( Tomahawk::source_ptr ) ), SLOT( latchOff( Tomahawk::source_ptr ) ) );
+ connect( m_delegate, SIGNAL( toggleRealtimeLatch( Tomahawk::source_ptr, bool ) ), m_latchManager, SLOT( latchModeChangeRequest( Tomahawk::source_ptr,bool ) ) );
setItemDelegate( m_delegate );
@@ -118,6 +119,7 @@ SourceTreeView::SourceTreeView( QWidget* parent )
connect( this, SIGNAL( latchRequest( Tomahawk::source_ptr ) ), m_latchManager, SLOT( latchRequest( Tomahawk::source_ptr ) ) );
connect( this, SIGNAL( unlatchRequest( Tomahawk::source_ptr ) ), m_latchManager, SLOT( unlatchRequest( Tomahawk::source_ptr ) ) );
connect( this, SIGNAL( catchUpRequest() ), m_latchManager, SLOT( catchUpRequest() ) );
+ connect( this, SIGNAL( latchModeChangeRequest( Tomahawk::source_ptr, bool ) ), m_latchManager, SLOT( latchModeChangeRequest( Tomahawk::source_ptr, bool ) ) );
connect( ActionCollection::instance(), SIGNAL( privacyModeChanged() ), SLOT( repaint() ) );
}
@@ -162,10 +164,14 @@ SourceTreeView::setupMenus()
{
if ( m_latchManager->isLatched( source ) )
{
- m_latchMenu.addSeparator();
QAction *latchOffAction = ActionCollection::instance()->getAction( "latchOff" );
m_latchMenu.addAction( latchOffAction );
- connect( latchOffAction, SIGNAL( triggered() ), SLOT( latchOff() ), Qt::QueuedConnection );
+ connect( latchOffAction, SIGNAL( triggered() ), SLOT( latchOff() ) );
+ m_latchMenu.addSeparator();
+ QAction *latchRealtimeAction = ActionCollection::instance()->getAction( "realtimeFollowingAlong" );
+ latchRealtimeAction->setChecked( source->playlistInterface()->latchMode() == Tomahawk::PlaylistInterface::RealTime );
+ m_latchMenu.addAction( latchRealtimeAction );
+ connect( latchRealtimeAction, SIGNAL( toggled( bool ) ), SLOT( latchModeToggled( bool ) ) );
}
}
}
@@ -416,6 +422,24 @@ SourceTreeView::latchOff( const Tomahawk::source_ptr& source )
}
+void
+SourceTreeView::latchModeToggled( bool checked )
+{
+
+ disconnect( this, SLOT( latchOff() ) );
+ qDebug() << Q_FUNC_INFO;
+ if ( !m_contextMenuIndex.isValid() )
+ return;
+
+ SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( m_contextMenuIndex, SourcesModel::SourceTreeItemTypeRole ).toInt();
+ if( type != SourcesModel::Collection )
+ return;
+
+ const SourceItem* item = itemFromIndex< SourceItem >( m_contextMenuIndex );
+ const source_ptr source = item->source();
+ emit latchModeChangeRequest( source, checked );
+}
+
void
SourceTreeView::renamePlaylist()
diff --git a/src/sourcetree/sourcetreeview.h b/src/sourcetree/sourcetreeview.h
index 4a518cac7..0d6a9b7b1 100644
--- a/src/sourcetree/sourcetreeview.h
+++ b/src/sourcetree/sourcetreeview.h
@@ -58,6 +58,7 @@ signals:
void latchRequest( const Tomahawk::source_ptr& source );
void unlatchRequest( const Tomahawk::source_ptr& source );
void catchUpRequest();
+ void latchModeChangeRequest( const Tomahawk::source_ptr& source, bool realtime );
private slots:
void onItemExpanded( const QModelIndex& idx );
@@ -75,6 +76,7 @@ private slots:
void latchOff();
void latchOnOrCatchUp( const Tomahawk::source_ptr& source );
void latchOff( const Tomahawk::source_ptr& source );
+ void latchModeToggled( bool checked );
void onCustomContextMenu( const QPoint& pos );
diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp
index 350b4cdc5..69714edd5 100644
--- a/src/tomahawkapp.cpp
+++ b/src/tomahawkapp.cpp
@@ -315,16 +315,15 @@ TomahawkApp::~TomahawkApp()
Pipeline::instance()->stop();
- if ( !m_database.isNull() )
- delete m_database.data();
-
- delete Pipeline::instance();
-
#ifndef ENABLE_HEADLESS
delete m_mainwindow;
delete AtticaManager::instance();
#endif
+ if ( !m_database.isNull() )
+ delete m_database.data();
+
+ delete Pipeline::instance();
tLog() << "Finished shutdown.";
}
@@ -346,10 +345,10 @@ TomahawkApp::printHelp()
echo( "Options are:\n" );
echo( " --help Show this help\n" );
echo( " --http Initialize HTTP server\n" );
- echo( " --filescan Scan for files on startup\n" );
+ echo( " --filescan Scan files on startup\n" );
echo( " --hide Hide main window on startup\n" );
echo( " --testdb Use a test database instead of real collection\n" );
- echo( " --noupnp Disable UPNP\n" );
+ echo( " --noupnp Disable UPnP\n" );
echo( " --nosip Disable SIP\n" );
echo( "\nurl is a tomahawk:// command or alternatively a url that Tomahawk can recognize.\n" );
echo( "For more documentation, see http://wiki.tomahawk-player.org/mediawiki/index.php/Tomahawk://_Links\n" );
@@ -423,10 +422,12 @@ TomahawkApp::registerMetaTypes()
qRegisterMetaType< Tomahawk::InfoSystem::InfoType >( "Tomahawk::InfoSystem::InfoType" );
qRegisterMetaType< Tomahawk::InfoSystem::InfoRequestData >( "Tomahawk::InfoSystem::InfoRequestData" );
qRegisterMetaType< Tomahawk::InfoSystem::InfoSystemCache* >( "Tomahawk::InfoSystem::InfoSystemCache*" );
-
qRegisterMetaType< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > ");
+
qRegisterMetaTypeStreamOperators< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > ");
qRegisterMetaType< QPersistentModelIndex >( "QPersistentModelIndex" );
+
+ qRegisterMetaType< Tomahawk::PlaylistInterface::LatchMode >( "Tomahawk::PlaylistInterface::LatchMode" );
}
diff --git a/src/tomahawkwindow.cpp b/src/tomahawkwindow.cpp
index 55deb5c8d..38099b7f1 100644
--- a/src/tomahawkwindow.cpp
+++ b/src/tomahawkwindow.cpp
@@ -224,7 +224,7 @@ TomahawkWindow::setupSideBar()
m_queueModel->setStyle( PlaylistModel::Short );
m_queueView->queue()->setPlaylistModel( m_queueModel );
m_queueView->queue()->playlistModel()->setReadOnly( false );
- AudioEngine::instance()->setQueue( m_queueView->queue()->proxyModel()->getPlaylistInterface() );
+ AudioEngine::instance()->setQueue( m_queueView->queue()->proxyModel()->playlistInterface() );
m_sidebar->addWidget( m_searchWidget );
m_sidebar->addWidget( m_sourcetree );