From 9c341bb3e68f2464bf193f82bd7f26d256a4ec5c Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 24 Jul 2011 18:36:39 +0200 Subject: [PATCH] * Disable qDebug() logging for release builds. Use tLog() for logging from NOW on. --- src/PipelineStatusView.cpp | 2 + src/PipelineStatusView.h | 2 - src/audiocontrols.cpp | 6 +- src/configdelegatebase.cpp | 5 +- src/diagnosticsdialog.cpp | 4 +- src/diagnosticsdialog.h | 1 - src/libtomahawk/CMakeLists.txt | 1 + src/libtomahawk/aclsystem.cpp | 4 +- src/libtomahawk/album.cpp | 4 +- src/libtomahawk/artist.cpp | 4 +- src/libtomahawk/audio/audioengine.cpp | 3 + src/libtomahawk/collection.cpp | 2 + src/libtomahawk/collection.h | 1 - src/libtomahawk/contextMenu.cpp | 4 +- src/libtomahawk/database/database.cpp | 2 + .../database/databasecollection.cpp | 2 + src/libtomahawk/database/databasecommand.cpp | 5 +- .../databasecommand_addclientauth.cpp | 19 ++-- .../database/databasecommand_addfiles.cpp | 2 + .../database/databasecommand_addsource.cpp | 7 +- .../database/databasecommand_allalbums.cpp | 1 + .../database/databasecommand_allartists.cpp | 2 + .../database/databasecommand_alltracks.cpp | 1 + .../databasecommand_clientauthvalid.cpp | 27 ++++-- .../databasecommand_collectionstats.cpp | 3 +- .../databasecommand_createdynamicplaylist.cpp | 1 + .../databasecommand_createplaylist.cpp | 1 + .../databasecommand_deletedynamicplaylist.cpp | 5 +- .../database/databasecommand_deletefiles.cpp | 1 + .../databasecommand_deleteplaylist.cpp | 5 +- .../database/databasecommand_dirmtimes.cpp | 1 + .../database/databasecommand_filemtimes.cpp | 1 + .../databasecommand_importplaylist.cpp | 7 +- .../databasecommand_loadallautoplaylists.cpp | 4 +- .../databasecommand_loadallplaylists.cpp | 4 +- .../databasecommand_loadallsources.cpp | 6 +- .../databasecommand_loadallstations.cpp | 4 +- .../databasecommand_loaddynamicplaylist.cpp | 37 +++++--- .../database/databasecommand_loadfile.cpp | 3 +- .../database/databasecommand_loadops.cpp | 4 +- .../databasecommand_loadplaylistentries.cpp | 29 +++--- .../databasecommand_loadsocialactions.cpp | 4 +- .../database/databasecommand_logplayback.cpp | 1 + .../databasecommand_modifyplaylist.cpp | 7 +- .../databasecommand_playbackhistory.cpp | 2 + .../databasecommand_renameplaylist.cpp | 1 + .../database/databasecommand_resolve.cpp | 1 + ...basecommand_setdynamicplaylistrevision.cpp | 93 +++++++++++-------- .../databasecommand_setplaylistrevision.cpp | 1 + .../database/databasecommand_socialaction.cpp | 1 + .../databasecommand_sourceoffline.cpp | 7 +- .../databasecommand_updatesearchindex.cpp | 12 ++- .../database/databasecommandloggable.cpp | 4 +- src/libtomahawk/database/databaseimpl.cpp | 1 + src/libtomahawk/database/databaseimpl.h | 1 - src/libtomahawk/database/databaseresolver.cpp | 4 +- src/libtomahawk/database/databaseworker.cpp | 1 + src/libtomahawk/database/fuzzyindex.cpp | 9 +- src/libtomahawk/database/localcollection.cpp | 5 + src/libtomahawk/database/tomahawksqlquery.h | 4 +- src/libtomahawk/functimeout.h | 1 - src/libtomahawk/globalactionmanager.cpp | 32 ++++--- .../infoplugins/generic/echonestplugin.cpp | 7 +- .../infoplugins/generic/lastfmplugin.cpp | 7 +- .../infoplugins/generic/lastfmplugin.h | 1 + .../infoplugins/generic/musicbrainzPlugin.cpp | 6 +- .../infoplugins/generic/musixmatchplugin.cpp | 10 +- .../infoplugins/mac/adiumplugin.cpp | 7 +- .../infoplugins/unix/fdonotifyplugin.cpp | 3 + .../infoplugins/unix/imageconverter.cpp | 2 + src/libtomahawk/infosystem/infosystem.cpp | 3 +- .../infosystem/infosystemcache.cpp | 39 ++++---- .../infosystem/infosystemworker.cpp | 3 +- src/libtomahawk/network/bufferiodevice.cpp | 5 +- src/libtomahawk/network/bufferiodevice.h | 7 +- src/libtomahawk/network/connection.cpp | 3 +- src/libtomahawk/network/connection.h | 3 +- src/libtomahawk/network/controlconnection.cpp | 1 + src/libtomahawk/network/dbsyncconnection.cpp | 3 +- src/libtomahawk/network/msg.h | 6 +- src/libtomahawk/network/msgprocessor.cpp | 3 +- src/libtomahawk/network/portfwdthread.cpp | 4 +- src/libtomahawk/network/remotecollection.cpp | 11 ++- src/libtomahawk/network/servent.cpp | 13 +-- src/libtomahawk/network/streamconnection.cpp | 1 + src/libtomahawk/pipeline.cpp | 3 +- src/libtomahawk/playlist.cpp | 2 + src/libtomahawk/playlist.h | 3 +- src/libtomahawk/playlist/albumitem.cpp | 5 +- .../playlist/albumitemdelegate.cpp | 2 +- src/libtomahawk/playlist/albummodel.cpp | 2 +- src/libtomahawk/playlist/albumproxymodel.cpp | 2 +- src/libtomahawk/playlist/albumview.cpp | 2 +- src/libtomahawk/playlist/artistview.cpp | 2 +- .../playlist/collectionflatmodel.cpp | 2 +- .../playlist/collectionproxymodel.cpp | 2 +- src/libtomahawk/playlist/collectionview.cpp | 2 +- .../playlist/dynamic/DynamicControl.cpp | 10 +- .../playlist/dynamic/DynamicModel.cpp | 12 +++ .../playlist/dynamic/DynamicPlaylist.cpp | 75 +++++++++------ .../playlist/dynamic/DynamicPlaylist.h | 55 ++++++----- .../playlist/dynamic/DynamicView.cpp | 34 ++++--- .../playlist/dynamic/GeneratorFactory.cpp | 30 +++--- .../playlist/dynamic/GeneratorFactory.h | 18 ++-- .../playlist/dynamic/GeneratorInterface.cpp | 36 ++++--- .../playlist/dynamic/GeneratorInterface.h | 47 +++++----- .../dynamic/echonest/EchonestControl.cpp | 46 +++++++-- .../dynamic/echonest/EchonestGenerator.cpp | 31 ++++++- .../dynamic/echonest/EchonestSteerer.cpp | 89 ++++++++++-------- .../dynamic/widgets/CollapsibleControls.cpp | 60 +++++++----- .../dynamic/widgets/DynamicControlList.cpp | 52 +++++++---- .../dynamic/widgets/DynamicControlWrapper.cpp | 74 ++++++++------- .../dynamic/widgets/DynamicSetupWidget.cpp | 54 ++++++----- .../dynamic/widgets/DynamicWidget.cpp | 29 +++++- .../dynamic/widgets/LoadingSpinner.cpp | 47 ++++++---- .../dynamic/widgets/MiscControlWidgets.cpp | 11 ++- .../dynamic/widgets/ReadOrWriteWidget.cpp | 38 +++++--- src/libtomahawk/playlist/infobar/infobar.cpp | 1 + .../playlist/playlistitemdelegate.cpp | 2 +- src/libtomahawk/playlist/playlistmodel.cpp | 2 +- .../playlist/playlistproxymodel.cpp | 4 +- src/libtomahawk/playlist/playlistview.cpp | 2 +- src/libtomahawk/playlist/queueproxymodel.cpp | 3 +- src/libtomahawk/playlist/queueview.cpp | 2 +- src/libtomahawk/playlist/topbar/lineedit.cpp | 2 - src/libtomahawk/playlist/topbar/topbar.cpp | 1 + src/libtomahawk/playlist/trackheader.cpp | 2 +- src/libtomahawk/playlist/trackmodel.cpp | 2 +- src/libtomahawk/playlist/trackmodelitem.cpp | 5 +- src/libtomahawk/playlist/trackproxymodel.cpp | 2 +- src/libtomahawk/playlist/trackview.cpp | 12 +-- src/libtomahawk/playlist/treeheader.cpp | 2 +- src/libtomahawk/playlist/treeitemdelegate.cpp | 2 +- src/libtomahawk/playlist/treemodel.cpp | 2 +- src/libtomahawk/playlist/treemodelitem.cpp | 3 +- src/libtomahawk/playlist/treeproxymodel.cpp | 2 +- src/libtomahawk/playlistinterface.h | 2 +- src/libtomahawk/query.cpp | 4 +- src/libtomahawk/resolver.cpp | 3 +- src/libtomahawk/result.cpp | 4 +- src/libtomahawk/sip/SipHandler.cpp | 1 + src/libtomahawk/sip/SipHandler.h | 1 - src/libtomahawk/sip/SipModel.cpp | 14 ++- src/libtomahawk/sip/SipPlugin.cpp | 22 ++++- src/libtomahawk/sip/sipinfo.cpp | 26 +++++- src/libtomahawk/sip/sipinfo.h | 6 +- src/libtomahawk/source.cpp | 2 + src/libtomahawk/sourcelist.cpp | 4 +- src/libtomahawk/sourceplaylistinterface.cpp | 5 +- src/libtomahawk/tomahawksettings.cpp | 4 +- src/libtomahawk/utils/animatedcounterlabel.h | 3 +- src/libtomahawk/utils/animatedsplitter.cpp | 2 + src/libtomahawk/utils/animatedsplitter.h | 1 - src/libtomahawk/utils/elidedlabel.cpp | 2 + src/libtomahawk/utils/imagebutton.cpp | 19 ++-- src/libtomahawk/utils/logger.cpp | 85 +++++++++++++++++ src/libtomahawk/utils/logger.h | 21 +++++ src/libtomahawk/utils/progresstreeview.cpp | 5 +- src/libtomahawk/utils/proxystyle.cpp | 5 +- src/libtomahawk/utils/querylabel.cpp | 5 +- src/libtomahawk/utils/tomahawkutils.cpp | 16 ++-- src/libtomahawk/utils/tomahawkutils.h | 1 + src/libtomahawk/utils/widgetdragfilter.cpp | 46 +++++---- src/libtomahawk/utils/xspfgenerator.cpp | 8 +- src/libtomahawk/utils/xspfloader.cpp | 2 + src/libtomahawk/utils/xspfloader.h | 1 - src/libtomahawk/viewmanager.cpp | 2 + src/libtomahawk/viewpage.cpp | 4 +- src/libtomahawk/widgets/HeaderLabel.cpp | 5 +- .../widgets/infowidgets/ArtistInfoWidget.cpp | 5 +- .../widgets/infowidgets/sourceinfowidget.cpp | 5 +- src/libtomahawk/widgets/newplaylistwidget.cpp | 8 +- src/libtomahawk/widgets/overlaywidget.cpp | 3 +- .../widgets/playlisttypeselectordlg.cpp | 17 +++- src/libtomahawk/widgets/searchwidget.cpp | 7 +- .../widgets/welcomeplaylistmodel.cpp | 9 +- src/libtomahawk/widgets/welcomewidget.cpp | 17 ++-- src/mac/macshortcuthandler.cpp | 5 +- src/mac/tomahawkapp_mac.mm | 2 +- src/musicscanner.cpp | 2 + src/musicscanner.h | 9 +- src/resolverconfigdelegate.cpp | 4 +- src/resolvers/qtscriptresolver.cpp | 3 + src/resolvers/qtscriptresolver.h | 1 - src/resolvers/scriptresolver.cpp | 2 + src/resolversmodel.cpp | 2 + src/scanmanager.cpp | 5 +- src/scrobbler.cpp | 3 + src/settingsdialog.cpp | 5 +- src/sip/jabber/avatarmanager.cpp | 4 +- .../jabber/googlewrapper/googlewrapper.cpp | 10 +- src/sip/jabber/jabber.cpp | 10 +- src/sip/jabber/tomahawksipmessage.cpp | 3 + src/sip/jabber/tomahawksipmessagefactory.cpp | 3 +- src/sip/jabber/xmlconsole.cpp | 9 +- src/sip/twitter/tomahawkoauthtwitter.cpp | 7 +- src/sip/twitter/twitter.cpp | 4 +- src/sip/twitter/twitterconfigwidget.cpp | 3 + src/sip/zeroconf/tomahawkzeroconf.h | 3 +- src/sip/zeroconf/zeroconf.cpp | 6 +- src/sipconfigdelegate.cpp | 11 ++- src/sourcetree/items/categoryitems.cpp | 24 ++++- src/sourcetree/items/collectionitem.cpp | 8 +- src/sourcetree/items/genericpageitems.cpp | 8 +- src/sourcetree/items/playlistitems.cpp | 8 +- src/sourcetree/items/sourcetreeitem.cpp | 4 +- src/sourcetree/sourcesmodel.cpp | 13 ++- src/sourcetree/sourcesproxymodel.cpp | 3 +- src/sourcetree/sourcetreeview.cpp | 27 +++--- src/tomahawkapp.cpp | 78 ++-------------- src/tomahawktrayicon.cpp | 12 ++- src/tomahawkwindow.cpp | 2 + src/transferview.cpp | 2 + src/transferview.h | 2 - src/web/api_v1.cpp | 3 + src/xmppbot/xmppbot.cpp | 3 + 216 files changed, 1386 insertions(+), 826 deletions(-) create mode 100644 src/libtomahawk/utils/logger.cpp create mode 100644 src/libtomahawk/utils/logger.h diff --git a/src/PipelineStatusView.cpp b/src/PipelineStatusView.cpp index de0efe281..c9efda9a6 100644 --- a/src/PipelineStatusView.cpp +++ b/src/PipelineStatusView.cpp @@ -23,6 +23,8 @@ #include "libtomahawk/pipeline.h" +#include "utils/logger.h" + using namespace Tomahawk; diff --git a/src/PipelineStatusView.h b/src/PipelineStatusView.h index df3a72542..bfd53ebc8 100644 --- a/src/PipelineStatusView.h +++ b/src/PipelineStatusView.h @@ -19,7 +19,6 @@ #ifndef PIPELINESTATUSVIEW_H #define PIPELINESTATUSVIEW_H -#include #include #include "typedefs.h" @@ -35,7 +34,6 @@ public: explicit PipelineStatusView( AnimatedSplitter* parent ); virtual ~PipelineStatusView() { - qDebug() << Q_FUNC_INFO; } QSize sizeHint() const; diff --git a/src/audiocontrols.cpp b/src/audiocontrols.cpp index 1cb79e41b..6a2605df2 100644 --- a/src/audiocontrols.cpp +++ b/src/audiocontrols.cpp @@ -23,13 +23,15 @@ #include "audio/audioengine.h" #include "viewmanager.h" -#include "utils/imagebutton.h" -#include "utils/tomahawkutils.h" #include "database/database.h" #include "database/databasecommand_socialaction.h" #include "album.h" +#include "utils/imagebutton.h" +#include "utils/tomahawkutils.h" +#include "utils/logger.h" + using namespace Tomahawk; static QString s_acInfoIdentifier = QString( "AUDIOCONTROLS" ); diff --git a/src/configdelegatebase.cpp b/src/configdelegatebase.cpp index ead45d233..ce6f2baae 100644 --- a/src/configdelegatebase.cpp +++ b/src/configdelegatebase.cpp @@ -18,12 +18,13 @@ #include "configdelegatebase.h" -#include "utils/tomahawkutils.h" - #include #include #include +#include "utils/tomahawkutils.h" +#include "utils/logger.h" + ConfigDelegateBase::ConfigDelegateBase ( QObject* parent ) : QStyledItemDelegate ( parent ) { diff --git a/src/diagnosticsdialog.cpp b/src/diagnosticsdialog.cpp index 59470407c..0d46ced6f 100644 --- a/src/diagnosticsdialog.cpp +++ b/src/diagnosticsdialog.cpp @@ -24,12 +24,14 @@ #include #include -#include #include #include #include #include +#include "utils/logger.h" + + DiagnosticsDialog::DiagnosticsDialog( QWidget *parent ) : QDialog( parent ) , ui( new Ui::DiagnosticsDialog ) diff --git a/src/diagnosticsdialog.h b/src/diagnosticsdialog.h index dac82aef3..e3fed2b59 100644 --- a/src/diagnosticsdialog.h +++ b/src/diagnosticsdialog.h @@ -20,7 +20,6 @@ #define DIAGNOSTICSDIALOG_H #include -#include namespace Ui { diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index b5fbd59f3..aeafd7c39 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -159,6 +159,7 @@ set( libSources utils/querylabel.cpp utils/elidedlabel.cpp utils/imagebutton.cpp + utils/logger.cpp utils/progresstreeview.cpp utils/proxystyle.cpp utils/widgetdragfilter.cpp diff --git a/src/libtomahawk/aclsystem.cpp b/src/libtomahawk/aclsystem.cpp index 0b87e3a1a..c31247332 100644 --- a/src/libtomahawk/aclsystem.cpp +++ b/src/libtomahawk/aclsystem.cpp @@ -18,12 +18,14 @@ #include "aclsystem.h" -#include #include #include #include +#include "utils/logger.h" + + ACLSystem* ACLSystem::s_instance = 0; ACLSystem* diff --git a/src/libtomahawk/album.cpp b/src/libtomahawk/album.cpp index f8ebc9853..6481bc3d7 100644 --- a/src/libtomahawk/album.cpp +++ b/src/libtomahawk/album.cpp @@ -18,12 +18,12 @@ #include "album.h" -#include - #include "collection.h" #include "database/database.h" #include "database/databasecommand_alltracks.h" +#include "utils/logger.h" + using namespace Tomahawk; diff --git a/src/libtomahawk/artist.cpp b/src/libtomahawk/artist.cpp index ec96f206b..abc06c467 100644 --- a/src/libtomahawk/artist.cpp +++ b/src/libtomahawk/artist.cpp @@ -18,12 +18,12 @@ #include "artist.h" -#include - #include "collection.h" #include "database/database.h" #include "database/databasecommand_alltracks.h" +#include "utils/logger.h" + using namespace Tomahawk; diff --git a/src/libtomahawk/audio/audioengine.cpp b/src/libtomahawk/audio/audioengine.cpp index f2bdceb16..3c7a91b4e 100644 --- a/src/libtomahawk/audio/audioengine.cpp +++ b/src/libtomahawk/audio/audioengine.cpp @@ -30,12 +30,15 @@ #include "album.h" +#include "utils/logger.h" + using namespace Tomahawk; AudioEngine* AudioEngine::s_instance = 0; static QString s_aeInfoIdentifier = QString( "AUDIOENGINE" ); + AudioEngine* AudioEngine::instance() { diff --git a/src/libtomahawk/collection.cpp b/src/libtomahawk/collection.cpp index fd2252a39..6555b7d94 100644 --- a/src/libtomahawk/collection.cpp +++ b/src/libtomahawk/collection.cpp @@ -24,6 +24,8 @@ #include "dynamic/DynamicPlaylist.h" #include "playlist.h" +#include "utils/logger.h" + using namespace Tomahawk; diff --git a/src/libtomahawk/collection.h b/src/libtomahawk/collection.h index fd496cc3a..f916e8b10 100644 --- a/src/libtomahawk/collection.h +++ b/src/libtomahawk/collection.h @@ -30,7 +30,6 @@ #include #include #include -#include #include "functimeout.h" #include "playlist.h" diff --git a/src/libtomahawk/contextMenu.cpp b/src/libtomahawk/contextMenu.cpp index 82053fba2..9a3c0efd0 100644 --- a/src/libtomahawk/contextMenu.cpp +++ b/src/libtomahawk/contextMenu.cpp @@ -18,12 +18,12 @@ #include "contextMenu.h" -#include - #include "globalactionmanager.h" #include "playlistview.h" #include "viewmanager.h" +#include "utils/logger.h" + using namespace Tomahawk; diff --git a/src/libtomahawk/database/database.cpp b/src/libtomahawk/database/database.cpp index 8e76ea47b..3ab6eaeae 100644 --- a/src/libtomahawk/database/database.cpp +++ b/src/libtomahawk/database/database.cpp @@ -18,6 +18,8 @@ #include "database.h" +#include "utils/logger.h" + #define DEFAULT_WORKER_THREADS 4 #define MAX_WORKER_THREADS 16 diff --git a/src/libtomahawk/database/databasecollection.cpp b/src/libtomahawk/database/databasecollection.cpp index f0eb88873..d62271c6f 100644 --- a/src/libtomahawk/database/databasecollection.cpp +++ b/src/libtomahawk/database/databasecollection.cpp @@ -26,6 +26,8 @@ #include "databasecommand_loadallautoplaylists.h" #include "databasecommand_loadallstations.h" +#include "utils/logger.h" + using namespace Tomahawk; diff --git a/src/libtomahawk/database/databasecommand.cpp b/src/libtomahawk/database/databasecommand.cpp index 7537bd121..30034f0dc 100644 --- a/src/libtomahawk/database/databasecommand.cpp +++ b/src/libtomahawk/database/databasecommand.cpp @@ -18,8 +18,6 @@ #include "databasecommand.h" -#include - #include "databasecommand_addfiles.h" #include "databasecommand_createplaylist.h" #include "databasecommand_deletefiles.h" @@ -31,7 +29,8 @@ #include "databasecommand_deletedynamicplaylist.h" #include "databasecommand_setdynamicplaylistrevision.h" #include "databasecommand_socialaction.h" -#include "databasecommand_loadsocialactions.h" + +#include "utils/logger.h" DatabaseCommand::DatabaseCommand( QObject* parent ) diff --git a/src/libtomahawk/database/databasecommand_addclientauth.cpp b/src/libtomahawk/database/databasecommand_addclientauth.cpp index a1aacc48f..4b99a03cd 100644 --- a/src/libtomahawk/database/databasecommand_addclientauth.cpp +++ b/src/libtomahawk/database/databasecommand_addclientauth.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,9 +18,12 @@ #include "databasecommand_addclientauth.h" -DatabaseCommand_AddClientAuth::DatabaseCommand_AddClientAuth( const QString& clientToken, - const QString& website, - const QString& name, +#include "utils/logger.h" + + +DatabaseCommand_AddClientAuth::DatabaseCommand_AddClientAuth( const QString& clientToken, + const QString& website, + const QString& name, const QString& userAgent, QObject* parent ) : DatabaseCommand( parent ) @@ -31,7 +34,8 @@ DatabaseCommand_AddClientAuth::DatabaseCommand_AddClientAuth( const QString& cli { } -void DatabaseCommand_AddClientAuth::exec(DatabaseImpl* lib) + +void DatabaseCommand_AddClientAuth::exec( DatabaseImpl* lib ) { TomahawkSqlQuery q = lib->newquery(); q.prepare( "INSERT INTO http_client_auth (token, website, name, ua, mtime, permissions) VALUES (?, ?, ?, ?, ?, ?)" ); @@ -41,8 +45,9 @@ void DatabaseCommand_AddClientAuth::exec(DatabaseImpl* lib) q.addBindValue( m_userAgent ); q.addBindValue( 0 ); q.addBindValue( "*" ); - - if( !q.exec() ) { + + if ( !q.exec() ) + { qWarning() << "Failed to insert http client into auth table!"; } } diff --git a/src/libtomahawk/database/databasecommand_addfiles.cpp b/src/libtomahawk/database/databasecommand_addfiles.cpp index b02e23378..03511b951 100644 --- a/src/libtomahawk/database/databasecommand_addfiles.cpp +++ b/src/libtomahawk/database/databasecommand_addfiles.cpp @@ -28,6 +28,8 @@ #include "databaseimpl.h" #include "network/controlconnection.h" +#include "utils/logger.h" + using namespace Tomahawk; diff --git a/src/libtomahawk/database/databasecommand_addsource.cpp b/src/libtomahawk/database/databasecommand_addsource.cpp index 5af922f5e..63d2540b7 100644 --- a/src/libtomahawk/database/databasecommand_addsource.cpp +++ b/src/libtomahawk/database/databasecommand_addsource.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -16,9 +16,12 @@ * along with Tomahawk. If not, see . */ -#include #include "databasecommand_addsource.h" + +#include + #include "databaseimpl.h" +#include "utils/logger.h" DatabaseCommand_addSource::DatabaseCommand_addSource( const QString& username, const QString& fname, QObject* parent ) diff --git a/src/libtomahawk/database/databasecommand_allalbums.cpp b/src/libtomahawk/database/databasecommand_allalbums.cpp index b854f9142..f57bde620 100644 --- a/src/libtomahawk/database/databasecommand_allalbums.cpp +++ b/src/libtomahawk/database/databasecommand_allalbums.cpp @@ -21,6 +21,7 @@ #include #include "databaseimpl.h" +#include "utils/logger.h" void diff --git a/src/libtomahawk/database/databasecommand_allartists.cpp b/src/libtomahawk/database/databasecommand_allartists.cpp index 41b7e3079..80168e88a 100644 --- a/src/libtomahawk/database/databasecommand_allartists.cpp +++ b/src/libtomahawk/database/databasecommand_allartists.cpp @@ -21,6 +21,8 @@ #include #include "databaseimpl.h" +#include "utils/logger.h" + void DatabaseCommand_AllArtists::exec( DatabaseImpl* dbi ) diff --git a/src/libtomahawk/database/databasecommand_alltracks.cpp b/src/libtomahawk/database/databasecommand_alltracks.cpp index 60d444b33..b611f8b74 100644 --- a/src/libtomahawk/database/databasecommand_alltracks.cpp +++ b/src/libtomahawk/database/databasecommand_alltracks.cpp @@ -24,6 +24,7 @@ #include "artist.h" #include "album.h" #include "sourcelist.h" +#include "utils/logger.h" void diff --git a/src/libtomahawk/database/databasecommand_clientauthvalid.cpp b/src/libtomahawk/database/databasecommand_clientauthvalid.cpp index be0e4d495..97e783838 100644 --- a/src/libtomahawk/database/databasecommand_clientauthvalid.cpp +++ b/src/libtomahawk/database/databasecommand_clientauthvalid.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,27 +18,36 @@ #include "databasecommand_clientauthvalid.h" +#include "utils/logger.h" + + DatabaseCommand_ClientAuthValid::DatabaseCommand_ClientAuthValid( const QString& clientToken, QObject* parent ) : DatabaseCommand( parent ) , m_clientToken( clientToken ) { - } -void DatabaseCommand_ClientAuthValid::exec(DatabaseImpl* lib) + +void DatabaseCommand_ClientAuthValid::exec( DatabaseImpl* lib ) { TomahawkSqlQuery q = lib->newquery(); - q.prepare( "SELECT name FROM http_client_auth WHERE token = ?" ); + q.prepare( "SELECT name FROM http_client_auth WHERE token = ?" ); q.addBindValue( m_clientToken ); - - if( q.exec() ) { - if( q.next() ) { + + if ( q.exec() ) + { + if ( q.next() ) + { QString name = q.value( 0 ).toString(); emit authValid( m_clientToken, name, true ); - } else { + } + else + { emit authValid( m_clientToken, QString(), false ); } - } else { + } + else + { qWarning() << "Failed to query http auth table for client:" << m_clientToken; } } diff --git a/src/libtomahawk/database/databasecommand_collectionstats.cpp b/src/libtomahawk/database/databasecommand_collectionstats.cpp index 081b24ade..dec833e8f 100644 --- a/src/libtomahawk/database/databasecommand_collectionstats.cpp +++ b/src/libtomahawk/database/databasecommand_collectionstats.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -19,6 +19,7 @@ #include "databasecommand_collectionstats.h" #include "databaseimpl.h" +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/database/databasecommand_createdynamicplaylist.cpp b/src/libtomahawk/database/databasecommand_createdynamicplaylist.cpp index 597f0c07d..12b459c0a 100644 --- a/src/libtomahawk/database/databasecommand_createdynamicplaylist.cpp +++ b/src/libtomahawk/database/databasecommand_createdynamicplaylist.cpp @@ -27,6 +27,7 @@ #include "network/servent.h" #include "viewmanager.h" +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/database/databasecommand_createplaylist.cpp b/src/libtomahawk/database/databasecommand_createplaylist.cpp index 3c81a728d..516197ab7 100644 --- a/src/libtomahawk/database/databasecommand_createplaylist.cpp +++ b/src/libtomahawk/database/databasecommand_createplaylist.cpp @@ -22,6 +22,7 @@ #include "network/servent.h" #include "viewmanager.h" +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/database/databasecommand_deletedynamicplaylist.cpp b/src/libtomahawk/database/databasecommand_deletedynamicplaylist.cpp index 718fcfc03..5f0e1c1f0 100644 --- a/src/libtomahawk/database/databasecommand_deletedynamicplaylist.cpp +++ b/src/libtomahawk/database/databasecommand_deletedynamicplaylist.cpp @@ -18,10 +18,11 @@ #include "databasecommand_deletedynamicplaylist.h" +#include + #include "dynamic/DynamicPlaylist.h" #include "network/servent.h" - -#include +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/database/databasecommand_deletefiles.cpp b/src/libtomahawk/database/databasecommand_deletefiles.cpp index 3add060ce..c8ecda316 100644 --- a/src/libtomahawk/database/databasecommand_deletefiles.cpp +++ b/src/libtomahawk/database/databasecommand_deletefiles.cpp @@ -27,6 +27,7 @@ #include "databasecommand_collectionstats.h" #include "databaseimpl.h" #include "network/controlconnection.h" +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/database/databasecommand_deleteplaylist.cpp b/src/libtomahawk/database/databasecommand_deleteplaylist.cpp index d87699594..a6d04cae0 100644 --- a/src/libtomahawk/database/databasecommand_deleteplaylist.cpp +++ b/src/libtomahawk/database/databasecommand_deleteplaylist.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -21,6 +21,7 @@ #include #include "network/servent.h" +#include "utils/logger.h" using namespace Tomahawk; @@ -57,7 +58,7 @@ DatabaseCommand_DeletePlaylist::postCommitHook() qDebug() << "Source has gone offline, not emitting to GUI."; return; } - + playlist_ptr playlist = source()->collection()->playlist( m_playlistguid ); Q_ASSERT( !playlist.isNull() ); diff --git a/src/libtomahawk/database/databasecommand_dirmtimes.cpp b/src/libtomahawk/database/databasecommand_dirmtimes.cpp index d2a878f94..f3729bb50 100644 --- a/src/libtomahawk/database/databasecommand_dirmtimes.cpp +++ b/src/libtomahawk/database/databasecommand_dirmtimes.cpp @@ -21,6 +21,7 @@ #include #include "databaseimpl.h" +#include "utils/logger.h" void diff --git a/src/libtomahawk/database/databasecommand_filemtimes.cpp b/src/libtomahawk/database/databasecommand_filemtimes.cpp index be371bce9..f7e83311c 100644 --- a/src/libtomahawk/database/databasecommand_filemtimes.cpp +++ b/src/libtomahawk/database/databasecommand_filemtimes.cpp @@ -21,6 +21,7 @@ #include #include "databaseimpl.h" +#include "utils/logger.h" void diff --git a/src/libtomahawk/database/databasecommand_importplaylist.cpp b/src/libtomahawk/database/databasecommand_importplaylist.cpp index 2d5fdddc2..96a6c82c9 100644 --- a/src/libtomahawk/database/databasecommand_importplaylist.cpp +++ b/src/libtomahawk/database/databasecommand_importplaylist.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -23,8 +23,11 @@ #include "tomahawk/query.h" #include "tomahawk/playlist.h" #include "databaseimpl.h" +#include "utils/logger.h" -void DatabaseCommand_ImportPlaylist::exec(DatabaseImpl * dbi) + +void +DatabaseCommand_ImportPlaylist::exec( DatabaseImpl * dbi ) { /* qDebug() << "Importing playlist of" << m_playlist->length() << "tracks"; diff --git a/src/libtomahawk/database/databasecommand_loadallautoplaylists.cpp b/src/libtomahawk/database/databasecommand_loadallautoplaylists.cpp index 7278db812..378dd0d9d 100644 --- a/src/libtomahawk/database/databasecommand_loadallautoplaylists.cpp +++ b/src/libtomahawk/database/databasecommand_loadallautoplaylists.cpp @@ -22,11 +22,13 @@ #include "dynamic/DynamicPlaylist.h" #include "databaseimpl.h" +#include "utils/logger.h" using namespace Tomahawk; -void DatabaseCommand_LoadAllAutoPlaylists::exec( DatabaseImpl* dbi ) +void +DatabaseCommand_LoadAllAutoPlaylists::exec( DatabaseImpl* dbi ) { TomahawkSqlQuery query = dbi->newquery(); diff --git a/src/libtomahawk/database/databasecommand_loadallplaylists.cpp b/src/libtomahawk/database/databasecommand_loadallplaylists.cpp index c2f0782bc..9ed6ddea3 100644 --- a/src/libtomahawk/database/databasecommand_loadallplaylists.cpp +++ b/src/libtomahawk/database/databasecommand_loadallplaylists.cpp @@ -22,11 +22,13 @@ #include "playlist.h" #include "databaseimpl.h" +#include "utils/logger.h" using namespace Tomahawk; -void DatabaseCommand_LoadAllPlaylists::exec( DatabaseImpl* dbi ) +void +DatabaseCommand_LoadAllPlaylists::exec( DatabaseImpl* dbi ) { TomahawkSqlQuery query = dbi->newquery(); diff --git a/src/libtomahawk/database/databasecommand_loadallsources.cpp b/src/libtomahawk/database/databasecommand_loadallsources.cpp index 79e09387c..ee20e1d88 100644 --- a/src/libtomahawk/database/databasecommand_loadallsources.cpp +++ b/src/libtomahawk/database/databasecommand_loadallsources.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -23,11 +23,13 @@ #include "network/servent.h" #include "source.h" #include "databaseimpl.h" +#include "utils/logger.h" using namespace Tomahawk; -void DatabaseCommand_LoadAllSources::exec( DatabaseImpl* dbi ) +void +DatabaseCommand_LoadAllSources::exec( DatabaseImpl* dbi ) { TomahawkSqlQuery query = dbi->newquery(); diff --git a/src/libtomahawk/database/databasecommand_loadallstations.cpp b/src/libtomahawk/database/databasecommand_loadallstations.cpp index 9f75c7f2e..bd5b6e488 100644 --- a/src/libtomahawk/database/databasecommand_loadallstations.cpp +++ b/src/libtomahawk/database/databasecommand_loadallstations.cpp @@ -22,11 +22,13 @@ #include "dynamic/DynamicPlaylist.h" #include "databaseimpl.h" +#include "utils/logger.h" using namespace Tomahawk; -void DatabaseCommand_LoadAllStations::exec( DatabaseImpl* dbi ) +void +DatabaseCommand_LoadAllStations::exec( DatabaseImpl* dbi ) { TomahawkSqlQuery query = dbi->newquery(); diff --git a/src/libtomahawk/database/databasecommand_loaddynamicplaylist.cpp b/src/libtomahawk/database/databasecommand_loaddynamicplaylist.cpp index f8b449e61..f120baa80 100644 --- a/src/libtomahawk/database/databasecommand_loaddynamicplaylist.cpp +++ b/src/libtomahawk/database/databasecommand_loaddynamicplaylist.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -26,6 +26,7 @@ #include "dynamic/DynamicControl.h" #include "dynamic/GeneratorInterface.h" #include +#include "utils/logger.h" using namespace Tomahawk; @@ -34,39 +35,40 @@ void DatabaseCommand_LoadDynamicPlaylist::exec( DatabaseImpl* dbi ) { qDebug() << "Loading dynamic playlist guid" << guid(); - // load the entries first + // load the entries first generateEntries( dbi ); - + // now load the controls etc - + TomahawkSqlQuery controlsQuery = dbi->newquery(); controlsQuery.prepare("SELECT playlist_revision.playlist, controls, plmode, pltype " "FROM dynamic_playlist_revision, playlist_revision " "WHERE dynamic_playlist_revision.guid = ? AND playlist_revision.guid = dynamic_playlist_revision.guid"); controlsQuery.addBindValue( revisionGuid() ); controlsQuery.exec(); - + QString type; GeneratorMode mode; - + QList< QVariantMap > controls; QString playlist_guid; qDebug() << "Loading controls..." << revisionGuid(); // qDebug() << "SELECT playlist_revision.playlist, controls, plmode, pltype " // "FROM dynamic_playlist_revision, playlist_revision " // "WHERE dynamic_playlist_revision.guid = "<< revisionGuid() << " AND playlist_revision.guid = dynamic_playlist_revision.guid"; - if( controlsQuery.first() ) + + if( controlsQuery.first() ) { playlist_guid = controlsQuery.value( 0 ).toString(); QJson::Parser parser; bool ok; QVariant v = parser.parse( controlsQuery.value(1).toByteArray(), &ok ); Q_ASSERT( ok && v.type() == QVariant::List ); //TODO - - + + type = controlsQuery.value( 3 ).toString(); mode = static_cast( controlsQuery.value( 2 ).toInt() ); - + QStringList controlIds = v.toStringList(); qDebug() << "Got controls in dynamic playlist, loading:" << controlIds << controlsQuery.value(1); foreach( const QString& controlId, controlIds ) @@ -88,7 +90,9 @@ DatabaseCommand_LoadDynamicPlaylist::exec( DatabaseImpl* dbi ) controls << c; } } - } else { + } + else + { // No controls, lets load the info we need directly from the playlist table TomahawkSqlQuery info = dbi->newquery(); info.prepare( QString( "SELECT dynamic_playlist.pltype, dynamic_playlist.plmode FROM playlist, dynamic_playlist WHERE playlist.guid = \"%1\" AND playlist.guid = dynamic_playlist.guid" ).arg( playlist_guid ) ); @@ -102,12 +106,15 @@ DatabaseCommand_LoadDynamicPlaylist::exec( DatabaseImpl* dbi ) type = info.value( 0 ).toString(); mode = static_cast( info.value( 1 ).toInt() ); } - - if( mode == OnDemand ) { + + if( mode == OnDemand ) + { Q_ASSERT( m_entrymap.isEmpty() ); // ondemand should have no entry - + emit done( revisionGuid(), m_islatest, type, controls, true ); - } else { + } + else + { emit done( revisionGuid(), m_guids, m_oldentries, type, controls, m_islatest, m_entrymap, true ); } } diff --git a/src/libtomahawk/database/databasecommand_loadfile.cpp b/src/libtomahawk/database/databasecommand_loadfile.cpp index 8890b3ee5..a7b38b52b 100644 --- a/src/libtomahawk/database/databasecommand_loadfile.cpp +++ b/src/libtomahawk/database/databasecommand_loadfile.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -20,6 +20,7 @@ #include "databaseimpl.h" #include "collection.h" +#include "utils/logger.h" DatabaseCommand_LoadFile::DatabaseCommand_LoadFile( const QString& id, QObject* parent ) diff --git a/src/libtomahawk/database/databasecommand_loadops.cpp b/src/libtomahawk/database/databasecommand_loadops.cpp index afc131da4..730060170 100644 --- a/src/libtomahawk/database/databasecommand_loadops.cpp +++ b/src/libtomahawk/database/databasecommand_loadops.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,6 +18,8 @@ #include "databasecommand_loadops.h" +#include "utils/logger.h" + void DatabaseCommand_loadOps::exec( DatabaseImpl* dbi ) diff --git a/src/libtomahawk/database/databasecommand_loadplaylistentries.cpp b/src/libtomahawk/database/databasecommand_loadplaylistentries.cpp index f29dc8a40..cd6f5fb0f 100644 --- a/src/libtomahawk/database/databasecommand_loadplaylistentries.cpp +++ b/src/libtomahawk/database/databasecommand_loadplaylistentries.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -21,6 +21,7 @@ #include #include "databaseimpl.h" +#include "utils/logger.h" using namespace Tomahawk; @@ -30,7 +31,7 @@ DatabaseCommand_LoadPlaylistEntries::exec( DatabaseImpl* dbi ) { qDebug() << "Loading playlist entries for revision" << m_revguid; generateEntries( dbi ); - + emit done( m_revguid, m_guids, m_oldentries, m_islatest, m_entrymap, true ); } @@ -44,27 +45,27 @@ DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi ) "WHERE guid = :guid"); query_entries.bindValue( ":guid", m_revguid ); query_entries.exec(); - + // qDebug() << "trying to load entries:" << m_revguid; QString prevrev; QJson::Parser parser; bool ok; - + if( query_entries.next() ) { // entries should be a list of strings: QVariant v = parser.parse( query_entries.value(0).toByteArray(), &ok ); Q_ASSERT( ok && v.type() == QVariant::List ); //TODO m_guids = v.toStringList(); - + QString inclause = QString("('%1')").arg(m_guids.join("', '")); - + TomahawkSqlQuery query = dbi->newquery(); QString sql = QString("SELECT guid, trackname, artistname, albumname, annotation, " "duration, addedon, addedby, result_hint " "FROM playlist_item " "WHERE guid IN %1").arg( inclause ); //qDebug() << sql; - + query.exec( sql ); while( query.next() ) { @@ -74,14 +75,14 @@ DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi ) e->setDuration( query.value( 5 ).toUInt() ); e->setLastmodified( 0 ); // TODO e->lastmodified = query.value(6).toInt(); e->setResultHint( query.value( 8 ).toString() ); - + Tomahawk::query_ptr q = Tomahawk::Query::get( query.value( 2 ).toString(), query.value( 1 ).toString(), query.value( 3 ).toString() ); q->setResultHint( query.value( 8 ).toString() ); e->setQuery( q ); - + m_entrymap.insert( e->guid(), e ); } - + prevrev = query_entries.value( 4 ).toString(); } @@ -89,7 +90,7 @@ DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi ) { qDebug() << "Playlist has no current revision data"; } - + if( prevrev.length() ) { TomahawkSqlQuery query_entries_old = dbi->newquery(); @@ -100,19 +101,19 @@ DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi ) query_entries_old.addBindValue( m_revguid ); query_entries_old.addBindValue( query_entries.value( 1 ).toString() ); query_entries_old.addBindValue( prevrev ); - + query_entries_old.exec(); if( !query_entries_old.next() ) { return; Q_ASSERT( false ); } - + QVariant v = parser.parse( query_entries_old.value( 0 ).toByteArray(), &ok ); Q_ASSERT( ok && v.type() == QVariant::List ); //TODO m_oldentries = v.toStringList(); m_islatest = query_entries_old.value( 1 ).toBool(); } - + // qDebug() << Q_FUNC_INFO << "entrymap:" << m_entrymap; } diff --git a/src/libtomahawk/database/databasecommand_loadsocialactions.cpp b/src/libtomahawk/database/databasecommand_loadsocialactions.cpp index 4a29e9359..f5d5a97ed 100644 --- a/src/libtomahawk/database/databasecommand_loadsocialactions.cpp +++ b/src/libtomahawk/database/databasecommand_loadsocialactions.cpp @@ -24,6 +24,7 @@ #include "databaseimpl.h" #include "network/servent.h" #include "result.h" +#include "utils/logger.h" using namespace Tomahawk; @@ -60,7 +61,8 @@ DatabaseCommand_LoadSocialActions::exec( DatabaseImpl* dbi ) query.exec(); QList< Tomahawk::SocialAction > allSocialActions; - while ( query.next() ) { + while ( query.next() ) + { Tomahawk::SocialAction action; action.action = query.value( 0 ); // action action.value = query.value( 1 ); // comment diff --git a/src/libtomahawk/database/databasecommand_logplayback.cpp b/src/libtomahawk/database/databasecommand_logplayback.cpp index b6aeff307..d0ea76350 100644 --- a/src/libtomahawk/database/databasecommand_logplayback.cpp +++ b/src/libtomahawk/database/databasecommand_logplayback.cpp @@ -24,6 +24,7 @@ #include "database/database.h" #include "databaseimpl.h" #include "network/servent.h" +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/database/databasecommand_modifyplaylist.cpp b/src/libtomahawk/database/databasecommand_modifyplaylist.cpp index 1d60da687..405ececa7 100644 --- a/src/libtomahawk/database/databasecommand_modifyplaylist.cpp +++ b/src/libtomahawk/database/databasecommand_modifyplaylist.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,6 +18,8 @@ #include "databasecommand_modifyplaylist.h" +#include "utils/logger.h" + using namespace Tomahawk; @@ -30,7 +32,8 @@ DatabaseCommand_ModifyPlaylist::DatabaseCommand_ModifyPlaylist( Playlist* playli } -void DatabaseCommand_ModifyPlaylist::exec( DatabaseImpl* lib ) +void +DatabaseCommand_ModifyPlaylist::exec( DatabaseImpl* lib ) { Q_UNUSED( lib ); } diff --git a/src/libtomahawk/database/databasecommand_playbackhistory.cpp b/src/libtomahawk/database/databasecommand_playbackhistory.cpp index 6e5c3af8d..c24190d96 100644 --- a/src/libtomahawk/database/databasecommand_playbackhistory.cpp +++ b/src/libtomahawk/database/databasecommand_playbackhistory.cpp @@ -23,6 +23,8 @@ #include "databaseimpl.h" #include "sourcelist.h" +#include "utils/logger.h" + void DatabaseCommand_PlaybackHistory::exec( DatabaseImpl* dbi ) diff --git a/src/libtomahawk/database/databasecommand_renameplaylist.cpp b/src/libtomahawk/database/databasecommand_renameplaylist.cpp index 2912068f8..e7b6736a8 100644 --- a/src/libtomahawk/database/databasecommand_renameplaylist.cpp +++ b/src/libtomahawk/database/databasecommand_renameplaylist.cpp @@ -22,6 +22,7 @@ #include "network/servent.h" #include "collection.h" +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/database/databasecommand_resolve.cpp b/src/libtomahawk/database/databasecommand_resolve.cpp index 053283b47..2585f4443 100644 --- a/src/libtomahawk/database/databasecommand_resolve.cpp +++ b/src/libtomahawk/database/databasecommand_resolve.cpp @@ -20,6 +20,7 @@ #include "album.h" #include "sourcelist.h" +#include "utils/logger.h" #define MINSCORE 0.5 diff --git a/src/libtomahawk/database/databasecommand_setdynamicplaylistrevision.cpp b/src/libtomahawk/database/databasecommand_setdynamicplaylistrevision.cpp index 728af40a9..f18011933 100644 --- a/src/libtomahawk/database/databasecommand_setdynamicplaylistrevision.cpp +++ b/src/libtomahawk/database/databasecommand_setdynamicplaylistrevision.cpp @@ -23,8 +23,10 @@ #include "tomahawksqlquery.h" #include "dynamic/DynamicPlaylist.h" #include "dynamic/DynamicControl.h" +#include "utils/logger.h" -DatabaseCommand_SetDynamicPlaylistRevision::DatabaseCommand_SetDynamicPlaylistRevision(const Tomahawk::source_ptr& s, + +DatabaseCommand_SetDynamicPlaylistRevision::DatabaseCommand_SetDynamicPlaylistRevision( const Tomahawk::source_ptr& s, const QString& playlistguid, const QString& newrev, const QString& oldrev, @@ -42,7 +44,8 @@ DatabaseCommand_SetDynamicPlaylistRevision::DatabaseCommand_SetDynamicPlaylistRe } -DatabaseCommand_SetDynamicPlaylistRevision::DatabaseCommand_SetDynamicPlaylistRevision(const Tomahawk::source_ptr& s, + +DatabaseCommand_SetDynamicPlaylistRevision::DatabaseCommand_SetDynamicPlaylistRevision( const Tomahawk::source_ptr& s, const QString& playlistguid, const QString& newrev, const QString& oldrev, @@ -57,22 +60,25 @@ DatabaseCommand_SetDynamicPlaylistRevision::DatabaseCommand_SetDynamicPlaylistRe } -QVariantList DatabaseCommand_SetDynamicPlaylistRevision::controlsV() + +QVariantList +DatabaseCommand_SetDynamicPlaylistRevision::controlsV() { - if( m_controls.isEmpty() ) + if ( m_controls.isEmpty() ) return m_controlsV; - if( !m_controls.isEmpty() && m_controlsV.isEmpty() ) + if ( !m_controls.isEmpty() && m_controlsV.isEmpty() ) { - foreach( const dyncontrol_ptr& control, m_controls ) + foreach ( const dyncontrol_ptr& control, m_controls ) { m_controlsV << QJson::QObjectHelper::qobject2qvariant( control.data() ); } } - return m_controlsV; + return m_controlsV; } + void DatabaseCommand_SetDynamicPlaylistRevision::postCommitHook() { @@ -93,7 +99,7 @@ DatabaseCommand_SetDynamicPlaylistRevision::postCommitHook() // private, but we are a friend. will recall itself in its own thread: dynplaylist_ptr playlist = source()->collection()->autoPlaylist( playlistguid() ); - if( playlist.isNull() ) + if ( playlist.isNull() ) playlist = source()->collection()->station( playlistguid() ); // workaround a bug in pre-0.1.0 tomahawks. they created dynamic playlists in OnDemand mode *always*, and then set the mode to the real one. @@ -103,36 +109,40 @@ DatabaseCommand_SetDynamicPlaylistRevision::postCommitHook() qDebug() << "Does this need FIXING?" << playlist->mode() << source()->collection()->autoPlaylist( playlistguid() ).isNull() << source()->collection()->station( playlistguid() ).isNull(); if( playlist->mode() == Static && source()->collection()->autoPlaylist( playlistguid() ).isNull() ) // should be here source()->collection()->moveStationToAuto( playlistguid() ); - else if( playlist->mode() == OnDemand && source()->collection()->station( playlistguid() ).isNull() ) // should be here + else if ( playlist->mode() == OnDemand && source()->collection()->station( playlistguid() ).isNull() ) // should be here source()->collection()->moveAutoToStation( playlistguid() ); + if ( playlist.isNull() ) { qDebug() <<"Got null playlist with guid:" << playlistguid() << "from source and collection:" << source()->friendlyName() << source()->collection()->name() << "and mode is static?:" << (m_mode == Static); Q_ASSERT( !playlist.isNull() ); return; } - if( !m_controlsV.isEmpty() && m_controls.isEmpty() ) { + if ( !m_controlsV.isEmpty() && m_controls.isEmpty() ) + { QList controlMap; foreach( const QVariant& v, m_controlsV ) controlMap << v.toMap(); - if( m_mode == OnDemand ) + if ( m_mode == OnDemand ) playlist->setRevision( newrev(), true, // this *is* the newest revision so far m_type, controlMap, m_applied ); - else - playlist->setRevision( newrev(), - orderedentriesguids, - m_previous_rev_orderedguids, - m_type, - controlMap, - true, // this *is* the newest revision so far - m_addedmap, - m_applied ); - } else { - if( m_mode == OnDemand ) + else + playlist->setRevision( newrev(), + orderedentriesguids, + m_previous_rev_orderedguids, + m_type, + controlMap, + true, // this *is* the newest revision so far + m_addedmap, + m_applied ); + } + else + { + if ( m_mode == OnDemand ) playlist->setRevision( newrev(), true, // this *is* the newest revision so far m_type, @@ -148,8 +158,9 @@ DatabaseCommand_SetDynamicPlaylistRevision::postCommitHook() m_addedmap, m_applied ); } - if( source()->isLocal() ) - Servent::instance()->triggerDBSync(); + + if ( source()->isLocal() ) + Servent::instance()->triggerDBSync(); } @@ -159,12 +170,17 @@ DatabaseCommand_SetDynamicPlaylistRevision::exec( DatabaseImpl* lib ) DatabaseCommand_SetPlaylistRevision::exec( lib ); QVariantList newcontrols; - if( m_controlsV.isEmpty() && !m_controls.isEmpty() ) { - foreach( const dyncontrol_ptr& control, m_controls ) { + if ( m_controlsV.isEmpty() && !m_controls.isEmpty() ) + { + foreach( const dyncontrol_ptr& control, m_controls ) + { newcontrols << control->id(); } - } else if( !m_controlsV.isEmpty() ) { - foreach( const QVariant& v, m_controlsV ) { + } + else if( !m_controlsV.isEmpty() ) + { + foreach( const QVariant& v, m_controlsV ) + { newcontrols << v.toMap().value( "id" ); } } @@ -188,14 +204,15 @@ DatabaseCommand_SetDynamicPlaylistRevision::exec( DatabaseImpl* lib ) TomahawkSqlQuery delQuery = lib->newquery(); delQuery.prepare( "DELETE FROM dynamic_playlist_controls WHERE playlist = ?" ); delQuery.addBindValue( m_playlistguid ); - if( !delQuery.exec() ) - qWarning() << "Failed to delete controls from dynamic playlist controls table"; + if ( !delQuery.exec() ) + qWarning() << "Failed to delete controls from dynamic playlist controls table"; TomahawkSqlQuery controlsQuery = lib->newquery(); controlsQuery.prepare( "INSERT INTO dynamic_playlist_controls( id, playlist, selectedType, match, input ) " "VALUES( ?, ?, ?, ?, ? )" ); - if( m_controlsV.isEmpty() && !m_controls.isEmpty() ) { - foreach( const dyncontrol_ptr& control, m_controls ) + if ( m_controlsV.isEmpty() && !m_controls.isEmpty() ) + { + foreach ( const dyncontrol_ptr& control, m_controls ) { qDebug() << "inserting dynamic control:" << control->id() << m_playlistguid << control->selectedType() << control->match() << control->input(); controlsQuery.addBindValue( control->id() ); @@ -206,8 +223,11 @@ DatabaseCommand_SetDynamicPlaylistRevision::exec( DatabaseImpl* lib ) controlsQuery.exec(); } - } else { - foreach( const QVariant& v, m_controlsV ) { + } + else + { + foreach ( const QVariant& v, m_controlsV ) + { QVariantMap control = v.toMap(); qDebug() << "inserting dynamic control from JSON:" << control.value( "id" ) << m_playlistguid << control.value( "selectedType" ) << control.value( "match" ) << control.value( "input" ); controlsQuery.addBindValue( control.value( "id" ) ); @@ -220,7 +240,7 @@ DatabaseCommand_SetDynamicPlaylistRevision::exec( DatabaseImpl* lib ) } } - if( m_applied ) + if ( m_applied ) { qDebug() << "updating dynamic playlist, optimistic locking okay"; @@ -230,8 +250,5 @@ DatabaseCommand_SetDynamicPlaylistRevision::exec( DatabaseImpl* lib ) query2.bindValue( 1, m_mode ); query2.bindValue( 2, m_playlistguid ); query2.exec(); - } - - } diff --git a/src/libtomahawk/database/databasecommand_setplaylistrevision.cpp b/src/libtomahawk/database/databasecommand_setplaylistrevision.cpp index 269236858..0f104fa15 100644 --- a/src/libtomahawk/database/databasecommand_setplaylistrevision.cpp +++ b/src/libtomahawk/database/databasecommand_setplaylistrevision.cpp @@ -22,6 +22,7 @@ #include "tomahawksqlquery.h" #include "network/servent.h" +#include "utils/logger.h" DatabaseCommand_SetPlaylistRevision::DatabaseCommand_SetPlaylistRevision( diff --git a/src/libtomahawk/database/databasecommand_socialaction.cpp b/src/libtomahawk/database/databasecommand_socialaction.cpp index d284d432c..1dc8b4d54 100644 --- a/src/libtomahawk/database/databasecommand_socialaction.cpp +++ b/src/libtomahawk/database/databasecommand_socialaction.cpp @@ -23,6 +23,7 @@ #include "database/database.h" #include "databaseimpl.h" #include "network/servent.h" +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/database/databasecommand_sourceoffline.cpp b/src/libtomahawk/database/databasecommand_sourceoffline.cpp index e09186ddc..6adfdabfe 100644 --- a/src/libtomahawk/database/databasecommand_sourceoffline.cpp +++ b/src/libtomahawk/database/databasecommand_sourceoffline.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,6 +18,8 @@ #include "databasecommand_sourceoffline.h" +#include "utils/logger.h" + DatabaseCommand_SourceOffline::DatabaseCommand_SourceOffline( int id ) : DatabaseCommand() @@ -26,7 +28,8 @@ DatabaseCommand_SourceOffline::DatabaseCommand_SourceOffline( int id ) } -void DatabaseCommand_SourceOffline::exec( DatabaseImpl* lib ) +void +DatabaseCommand_SourceOffline::exec( DatabaseImpl* lib ) { TomahawkSqlQuery q = lib->newquery(); q.exec( QString( "UPDATE source SET isonline = 'false' WHERE id = %1" ) diff --git a/src/libtomahawk/database/databasecommand_updatesearchindex.cpp b/src/libtomahawk/database/databasecommand_updatesearchindex.cpp index 8362c9749..bac5d2994 100644 --- a/src/libtomahawk/database/databasecommand_updatesearchindex.cpp +++ b/src/libtomahawk/database/databasecommand_updatesearchindex.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,6 +18,8 @@ #include "databasecommand_updatesearchindex.h" +#include "utils/logger.h" + DatabaseCommand_UpdateSearchIndex::DatabaseCommand_UpdateSearchIndex() : DatabaseCommand() @@ -29,17 +31,17 @@ void DatabaseCommand_UpdateSearchIndex::indexTable( DatabaseImpl* db, const QString& table ) { qDebug() << Q_FUNC_INFO; - + TomahawkSqlQuery query = db->newquery(); qDebug() << "Building index for" << table; query.exec( QString( "SELECT id, name FROM %1" ).arg( table ) ); - + QMap< unsigned int, QString > fields; while ( query.next() ) { fields.insert( query.value( 0 ).toUInt(), query.value( 1 ).toString() ); } - + db->m_fuzzyIndex->appendFields( table, fields ); qDebug() << "Building index for" << table << "finished."; } @@ -49,7 +51,7 @@ void DatabaseCommand_UpdateSearchIndex::exec( DatabaseImpl* db ) { db->m_fuzzyIndex->beginIndexing(); - + indexTable( db, "artist" ); indexTable( db, "album" ); indexTable( db, "track" ); diff --git a/src/libtomahawk/database/databasecommandloggable.cpp b/src/libtomahawk/database/databasecommandloggable.cpp index 9c193b454..c665f0c89 100644 --- a/src/libtomahawk/database/databasecommandloggable.cpp +++ b/src/libtomahawk/database/databasecommandloggable.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,4 +18,4 @@ #include "databasecommandloggable.h" - +#include "utils/logger.h" diff --git a/src/libtomahawk/database/databaseimpl.cpp b/src/libtomahawk/database/databaseimpl.cpp index b7bb8d159..389838e3a 100644 --- a/src/libtomahawk/database/databaseimpl.cpp +++ b/src/libtomahawk/database/databaseimpl.cpp @@ -31,6 +31,7 @@ #include "artist.h" #include "album.h" #include "utils/tomahawkutils.h" +#include "utils/logger.h" /* !!!! You need to manually generate schema.sql.h when the schema changes: cd src/libtomahawk/database diff --git a/src/libtomahawk/database/databaseimpl.h b/src/libtomahawk/database/databaseimpl.h index cb0eda4c9..c7688b718 100644 --- a/src/libtomahawk/database/databaseimpl.h +++ b/src/libtomahawk/database/databaseimpl.h @@ -27,7 +27,6 @@ #include #include #include -#include #include #include diff --git a/src/libtomahawk/database/databaseresolver.cpp b/src/libtomahawk/database/databaseresolver.cpp index e5da896af..2ae56e3ce 100644 --- a/src/libtomahawk/database/databaseresolver.cpp +++ b/src/libtomahawk/database/databaseresolver.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -22,6 +22,8 @@ #include "database/database.h" #include "database/databasecommand_resolve.h" +#include "utils/logger.h" + DatabaseResolver::DatabaseResolver( int weight ) : Resolver() diff --git a/src/libtomahawk/database/databaseworker.cpp b/src/libtomahawk/database/databaseworker.cpp index 95120f8c7..9498e81be 100644 --- a/src/libtomahawk/database/databaseworker.cpp +++ b/src/libtomahawk/database/databaseworker.cpp @@ -24,6 +24,7 @@ #include "database/database.h" #include "database/databasecommandloggable.h" +#include "utils/logger.h" DatabaseWorker::DatabaseWorker( DatabaseImpl* lib, Database* db, bool mutates ) diff --git a/src/libtomahawk/database/fuzzyindex.cpp b/src/libtomahawk/database/fuzzyindex.cpp index 31d4f5754..d5b34a48b 100644 --- a/src/libtomahawk/database/fuzzyindex.cpp +++ b/src/libtomahawk/database/fuzzyindex.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,14 +18,15 @@ #include "fuzzyindex.h" -#include "databaseimpl.h" -#include "utils/tomahawkutils.h" - #include #include #include +#include "databaseimpl.h" +#include "utils/tomahawkutils.h" +#include "utils/logger.h" + using namespace lucene::analysis; using namespace lucene::document; using namespace lucene::store; diff --git a/src/libtomahawk/database/localcollection.cpp b/src/libtomahawk/database/localcollection.cpp index 9a8882aab..eb03377d8 100644 --- a/src/libtomahawk/database/localcollection.cpp +++ b/src/libtomahawk/database/localcollection.cpp @@ -23,6 +23,8 @@ #include "sourcelist.h" #include "viewmanager.h" #include +#include "utils/logger.h" + LocalCollection::LocalCollection( const Tomahawk::source_ptr& source, QObject* parent ) : DatabaseCollection( source, parent ) @@ -30,6 +32,7 @@ LocalCollection::LocalCollection( const Tomahawk::source_ptr& source, QObject* p } + Tomahawk::playlist_ptr LocalCollection::bookmarksPlaylist() { @@ -39,6 +42,7 @@ LocalCollection::bookmarksPlaylist() return playlist( TomahawkSettings::instance()->bookmarkPlaylist() ); } + void LocalCollection::createBookmarksPlaylist() { @@ -54,6 +58,7 @@ LocalCollection::createBookmarksPlaylist() } } + void LocalCollection::created() { diff --git a/src/libtomahawk/database/tomahawksqlquery.h b/src/libtomahawk/database/tomahawksqlquery.h index 76f65605c..a50d59124 100644 --- a/src/libtomahawk/database/tomahawksqlquery.h +++ b/src/libtomahawk/database/tomahawksqlquery.h @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -24,6 +24,8 @@ #include #include +#include "utils/logger.h" + #define TOMAHAWK_QUERY_THRESHOLD 60 class TomahawkSqlQuery : public QSqlQuery diff --git a/src/libtomahawk/functimeout.h b/src/libtomahawk/functimeout.h index bbb632f59..060a2fe9f 100644 --- a/src/libtomahawk/functimeout.h +++ b/src/libtomahawk/functimeout.h @@ -21,7 +21,6 @@ #include #include -#include #include #include "boost/function.hpp" diff --git a/src/libtomahawk/globalactionmanager.cpp b/src/libtomahawk/globalactionmanager.cpp index 6169a40c7..5978ca636 100644 --- a/src/libtomahawk/globalactionmanager.cpp +++ b/src/libtomahawk/globalactionmanager.cpp @@ -18,23 +18,25 @@ #include "globalactionmanager.h" -#include "audio/audioengine.h" -#include "utils/xspfloader.h" -#include "sourcelist.h" -#include "playlist/dynamic/GeneratorInterface.h" -#include "viewmanager.h" -#include "playlist/topbar/topbar.h" -#include "pipeline.h" -#include "database/localcollection.h" -#include "playlist/playlistview.h" -#include "echonest/Playlist.h" -#include "album.h" - +#include +#include #include -#include -#include -#include + +#include "album.h" +#include "sourcelist.h" +#include "pipeline.h" +#include "viewmanager.h" +#include "audio/audioengine.h" +#include "database/localcollection.h" +#include "playlist/dynamic/GeneratorInterface.h" +#include "playlist/topbar/topbar.h" +#include "playlist/playlistview.h" + +#include "echonest/Playlist.h" + +#include "utils/xspfloader.h" #include "utils/xspfgenerator.h" +#include "utils/logger.h" GlobalActionManager* GlobalActionManager::s_instance = 0; diff --git a/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.cpp b/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.cpp index dbd060364..bdcf190eb 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.cpp +++ b/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.cpp @@ -21,6 +21,7 @@ #include #include "utils/tomahawkutils.h" +#include "utils/logger.h" #include @@ -56,7 +57,7 @@ EchoNestPlugin::namChangedSlot( QNetworkAccessManager *nam ) qDebug() << "Could not get old proxyFactory!"; return; } - + currNam->setConfiguration( nam->configuration() ); currNam->setNetworkAccessible( nam->networkAccessible() ); TomahawkUtils::NetworkProxyFactory* newProxyFactory = new TomahawkUtils::NetworkProxyFactory(); @@ -96,7 +97,7 @@ EchoNestPlugin::getSongProfile( uint requestId, const Tomahawk::InfoSystem::Info { //WARNING: Totally not implemented yet Q_UNUSED( item ); - + if( !isValidTrackData( requestId, requestData ) ) return; @@ -314,4 +315,4 @@ EchoNestPlugin::artistFromReply( QNetworkReply* reply ) } return artist; } -// \ No newline at end of file +// \ No newline at end of file diff --git a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp b/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp index 6c3d9cff2..b80324541 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp +++ b/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp @@ -28,6 +28,7 @@ #include "audio/audioengine.h" #include "tomahawksettings.h" #include "utils/tomahawkutils.h" +#include "utils/logger.h" #include #include @@ -483,7 +484,7 @@ LastFmPlugin::topTracksReturned() returnedData["tracks"] = topTracks; Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(); - + emit info( reply->property( "requestId" ).toUInt(), requestData, @@ -523,7 +524,7 @@ LastFmPlugin::coverArtReturned() returnedData["url"] = reply->url().toString(); Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(); - + emit info( reply->property( "requestId" ).toUInt(), requestData, @@ -581,7 +582,7 @@ LastFmPlugin::artistImagesReturned() returnedData["url"] = reply->url().toString(); Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(); - + emit info( reply->property( "requestId" ).toUInt(), requestData, returnedData ); Tomahawk::InfoSystem::InfoCriteriaHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash>(); diff --git a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.h b/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.h index dc1c2add6..dcd6eae2c 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.h +++ b/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.h @@ -17,6 +17,7 @@ #ifndef LASTFMPLUGIN_H #define LASTFMPLUGIN_H + #include "infosystem/infosystem.h" #include "infosystem/infosystemworker.h" #include "result.h" diff --git a/src/libtomahawk/infosystem/infoplugins/generic/musicbrainzPlugin.cpp b/src/libtomahawk/infosystem/infoplugins/generic/musicbrainzPlugin.cpp index 89292f44c..d64f2f88c 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/musicbrainzPlugin.cpp +++ b/src/libtomahawk/infosystem/infoplugins/generic/musicbrainzPlugin.cpp @@ -18,14 +18,14 @@ #include "musicbrainzPlugin.h" -#include "utils/tomahawkutils.h" - #include #include +#include "utils/tomahawkutils.h" +#include "utils/logger.h" + using namespace Tomahawk::InfoSystem; -// for internal neatness MusicBrainzPlugin::MusicBrainzPlugin() : InfoPlugin() diff --git a/src/libtomahawk/infosystem/infoplugins/generic/musixmatchplugin.cpp b/src/libtomahawk/infosystem/infoplugins/generic/musixmatchplugin.cpp index 70cef35d9..ca2b96858 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/musixmatchplugin.cpp +++ b/src/libtomahawk/infosystem/infoplugins/generic/musixmatchplugin.cpp @@ -18,13 +18,15 @@ #include "musixmatchplugin.h" -#include "utils/tomahawkutils.h" - #include #include +#include "utils/tomahawkutils.h" +#include "utils/logger.h" + using namespace Tomahawk::InfoSystem; + // for internal neatness MusixMatchPlugin::MusixMatchPlugin() @@ -46,7 +48,7 @@ MusixMatchPlugin::namChangedSlot( QNetworkAccessManager *nam ) qDebug() << Q_FUNC_INFO; if( !nam ) return; - + m_nam = QWeakPointer< QNetworkAccessManager >( nam ); } @@ -110,7 +112,7 @@ MusixMatchPlugin::trackSearchSlot() QNetworkReply* oldReply = qobject_cast( sender() ); if ( !oldReply ) return; //timeout will handle it - + QDomDocument doc; doc.setContent(oldReply->readAll()); qDebug() << doc.toString(); diff --git a/src/libtomahawk/infosystem/infoplugins/mac/adiumplugin.cpp b/src/libtomahawk/infosystem/infoplugins/mac/adiumplugin.cpp index 823968b03..c901e52f9 100644 --- a/src/libtomahawk/infosystem/infoplugins/mac/adiumplugin.cpp +++ b/src/libtomahawk/infosystem/infoplugins/mac/adiumplugin.cpp @@ -25,6 +25,7 @@ #include "result.h" #include "tomahawksettings.h" #include "globalactionmanager.h" +#include "utils/logger.h" #include "adiumplugin.h" #include "adium.h" @@ -178,21 +179,21 @@ AdiumPlugin::audioFinished( const QVariant &input ) //qDebug() << Q_FUNC_INFO; } -void +void AdiumPlugin::audioStopped() { qDebug() << Q_FUNC_INFO; setStatus( "" ); } -void +void AdiumPlugin::audioPaused() { qDebug() << Q_FUNC_INFO; m_pauseTimer->start( 60 * 1000 ); } -void +void AdiumPlugin::audioResumed( const QVariant &input ) { qDebug() << Q_FUNC_INFO; diff --git a/src/libtomahawk/infosystem/infoplugins/unix/fdonotifyplugin.cpp b/src/libtomahawk/infosystem/infoplugins/unix/fdonotifyplugin.cpp index 82ce1bf3c..4a72e2ebd 100644 --- a/src/libtomahawk/infosystem/infoplugins/unix/fdonotifyplugin.cpp +++ b/src/libtomahawk/infosystem/infoplugins/unix/fdonotifyplugin.cpp @@ -44,8 +44,11 @@ #include #include +#include "utils/logger.h" + using namespace Tomahawk::InfoSystem; + FdoNotifyPlugin::FdoNotifyPlugin() : InfoPlugin() { diff --git a/src/libtomahawk/infosystem/infoplugins/unix/imageconverter.cpp b/src/libtomahawk/infosystem/infoplugins/unix/imageconverter.cpp index 1d08fcf43..97986cab7 100644 --- a/src/libtomahawk/infosystem/infoplugins/unix/imageconverter.cpp +++ b/src/libtomahawk/infosystem/infoplugins/unix/imageconverter.cpp @@ -22,6 +22,8 @@ #include #include +#include "utils/logger.h" + namespace ImageConverter { diff --git a/src/libtomahawk/infosystem/infosystem.cpp b/src/libtomahawk/infosystem/infosystem.cpp index 6be0d5f7c..c274e393d 100644 --- a/src/libtomahawk/infosystem/infosystem.cpp +++ b/src/libtomahawk/infosystem/infosystem.cpp @@ -20,9 +20,10 @@ #include "infosystem.h" #include "tomahawksettings.h" -#include "utils/tomahawkutils.h" #include "infosystemcache.h" #include "infosystemworker.h" +#include "utils/tomahawkutils.h" +#include "utils/logger.h" namespace Tomahawk { diff --git a/src/libtomahawk/infosystem/infosystemcache.cpp b/src/libtomahawk/infosystem/infosystemcache.cpp index 5a5ff57dd..6c7361713 100644 --- a/src/libtomahawk/infosystem/infosystemcache.cpp +++ b/src/libtomahawk/infosystem/infosystemcache.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -24,6 +24,7 @@ #include "infosystemcache.h" #include "tomahawksettings.h" +#include "utils/logger.h" namespace Tomahawk @@ -46,7 +47,7 @@ InfoSystemCache::InfoSystemCache( QObject* parent ) qDebug() << "Cache version outdated, old:" << s->infoSystemCacheVersion() << "new:" << m_cacheVersion << "Doing upgrade, if any..."; - + uint current = s->infoSystemCacheVersion(); while( current < m_cacheVersion ) { @@ -55,7 +56,7 @@ InfoSystemCache::InfoSystemCache( QObject* parent ) } s->setInfoSystemCacheVersion( m_cacheVersion ); } - + m_pruneTimer.setInterval( 300000 ); m_pruneTimer.setSingleShot( false ); connect( &m_pruneTimer, SIGNAL( timeout() ), SLOT( pruneTimerFired() ) ); @@ -76,7 +77,7 @@ InfoSystemCache::doUpgrade( uint oldVersion, uint newVersion ) if ( oldVersion == 0 || oldVersion == 1 ) { qDebug() << Q_FUNC_INFO << "Wiping cache"; - + for ( int i = 0; i <= InfoNoInfo; i++ ) { InfoType type = (InfoType)(i); @@ -87,7 +88,7 @@ InfoSystemCache::doUpgrade( uint oldVersion, uint newVersion ) if ( !QFile::remove( file.canonicalFilePath() ) ) qDebug() << "During upgrade, failed to remove cache file " << file.canonicalFilePath(); } - } + } } } @@ -99,7 +100,7 @@ InfoSystemCache::pruneTimerFired() qDebug() << "Pruning infosystemcache"; qlonglong currentMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch(); - + for ( int i = 0; i <= InfoNoInfo; i++ ) { InfoType type = (InfoType)(i); @@ -140,7 +141,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCr emit notInCache( requestId, criteria, requestData ); return; } - + const QString cacheDir = m_cacheBaseDir + QString::number( (int)requestData.type ); QDir dir( cacheDir ); if ( !dir.exists() ) @@ -150,7 +151,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCr emit notInCache( requestId, criteria, requestData ); return; } - + QFileInfoList fileList = dir.entryInfoList( QDir::Files | QDir::NoDotAndDotDot ); foreach ( QFileInfo file, fileList ) { @@ -178,7 +179,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCr qDebug() << "Failed to remove stale cache file " << file.canonicalFilePath(); else qDebug() << "Removed stale cache file " << file.canonicalFilePath(); - + fileLocationHash.remove( criteriaHashVal ); m_fileLocationCache[ requestData.type ] = fileLocationHash; m_dataCache.remove( criteriaHashValWithType ); @@ -190,18 +191,18 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCr else if ( newMaxAge > 0 ) { const QString newFilePath = QString( file.dir().canonicalPath() + '/' + criteriaHashVal + '.' + QString::number( QDateTime::currentMSecsSinceEpoch() + newMaxAge ) ); - + if ( !QFile::rename( file.canonicalFilePath(), newFilePath ) ) { qDebug() << Q_FUNC_INFO << " notInCache -- failed to move old cache file to new location"; emit notInCache( requestId, criteria, requestData ); return; } - + fileLocationHash[ criteriaHashVal ] = newFilePath; m_fileLocationCache[ requestData.type ] = fileLocationHash; } - + if ( !m_dataCache.contains( criteriaHashValWithType ) ) { QSettings cachedSettings( fileLocationHash[ criteriaHashVal ], QSettings::IniFormat ); @@ -221,7 +222,7 @@ void InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output ) { qDebug() << Q_FUNC_INFO; - + const QString criteriaHashVal = criteriaMd5( criteria ); const QString criteriaHashValWithType = criteriaMd5( criteria, type ); const QString cacheDir = m_cacheBaseDir + QString::number( (int)type ); @@ -237,15 +238,15 @@ InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteri } fileLocationHash[ criteriaHashVal ] = settingsFilePath; m_fileLocationCache[ type ] = fileLocationHash; - + QSettings cachedSettings( fileLocationHash[ criteriaHashVal ], QSettings::IniFormat ); cachedSettings.setValue( "data", output ); - + m_dataCache.insert( criteriaHashValWithType, new QVariant( output ) ); - + return; } - + QDir dir( cacheDir ); if( !dir.exists( cacheDir ) ) { @@ -256,7 +257,7 @@ InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteri return; } } - + QSettings cachedSettings( settingsFilePath, QSettings::IniFormat ); QStringList keys = criteria.keys(); cachedSettings.beginGroup( "criteria" ); @@ -264,7 +265,7 @@ InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteri cachedSettings.setValue( keys.at( i ), criteria[keys.at( i )] ); cachedSettings.endGroup(); cachedSettings.setValue( "data", output ); - + fileLocationHash[criteriaHashVal] = settingsFilePath; m_fileLocationCache[type] = fileLocationHash; m_dataCache.insert( criteriaHashValWithType, new QVariant( output ) ); diff --git a/src/libtomahawk/infosystem/infosystemworker.cpp b/src/libtomahawk/infosystem/infosystemworker.cpp index 1cd811fda..b11eaea51 100644 --- a/src/libtomahawk/infosystem/infosystemworker.cpp +++ b/src/libtomahawk/infosystem/infosystemworker.cpp @@ -22,12 +22,13 @@ #include "config.h" #include "infosystemworker.h" -#include "utils/tomahawkutils.h" #include "infosystemcache.h" #include "infoplugins/generic/echonestplugin.h" #include "infoplugins/generic/musixmatchplugin.h" #include "infoplugins/generic/lastfmplugin.h" #include "infoplugins/generic/musicbrainzPlugin.h" +#include "utils/tomahawkutils.h" +#include "utils/logger.h" #ifdef Q_WS_MAC #include "infoplugins/mac/adiumplugin.h" diff --git a/src/libtomahawk/network/bufferiodevice.cpp b/src/libtomahawk/network/bufferiodevice.cpp index bceca0745..a7bf026e6 100644 --- a/src/libtomahawk/network/bufferiodevice.cpp +++ b/src/libtomahawk/network/bufferiodevice.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,10 +18,11 @@ #include "bufferiodevice.h" -#include #include #include +#include "utils/logger.h" + // Msgs are framed, this is the size each msg we send containing audio data: #define BLOCKSIZE 4096 diff --git a/src/libtomahawk/network/bufferiodevice.h b/src/libtomahawk/network/bufferiodevice.h index 4e0244991..a118b9edd 100644 --- a/src/libtomahawk/network/bufferiodevice.h +++ b/src/libtomahawk/network/bufferiodevice.h @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -21,7 +21,6 @@ #include #include -#include #include class BufferIODevice : public QIODevice @@ -40,12 +39,12 @@ public: virtual qint64 bytesAvailable() const; virtual qint64 size() const; virtual bool atEnd() const; - virtual qint64 pos() const { qDebug() << Q_FUNC_INFO << m_pos; return m_pos; } + virtual qint64 pos() const { return m_pos; } void addData( int block, const QByteArray& ba ); void clear(); - OpenMode openMode() const { qDebug() << "openMode"; return QIODevice::ReadOnly | QIODevice::Unbuffered; } + OpenMode openMode() const { return QIODevice::ReadOnly | QIODevice::Unbuffered; } void inputComplete( const QString& errmsg = "" ); diff --git a/src/libtomahawk/network/connection.cpp b/src/libtomahawk/network/connection.cpp index 59342fba9..42b484c1f 100644 --- a/src/libtomahawk/network/connection.cpp +++ b/src/libtomahawk/network/connection.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -22,6 +22,7 @@ #include #include "network/servent.h" +#include "utils/logger.h" #define PROTOVER "4" // must match remote peer, or we can't talk. diff --git a/src/libtomahawk/network/connection.h b/src/libtomahawk/network/connection.h index 95c94980f..057a1dbbe 100644 --- a/src/libtomahawk/network/connection.h +++ b/src/libtomahawk/network/connection.h @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/src/libtomahawk/network/controlconnection.cpp b/src/libtomahawk/network/controlconnection.cpp index ee1cc4294..5284f3254 100644 --- a/src/libtomahawk/network/controlconnection.cpp +++ b/src/libtomahawk/network/controlconnection.cpp @@ -24,6 +24,7 @@ #include "dbsyncconnection.h" #include "sourcelist.h" #include +#include "utils/logger.h" #define TCP_TIMEOUT 600 diff --git a/src/libtomahawk/network/dbsyncconnection.cpp b/src/libtomahawk/network/dbsyncconnection.cpp index 4b6fa6ea1..a9199b1f5 100644 --- a/src/libtomahawk/network/dbsyncconnection.cpp +++ b/src/libtomahawk/network/dbsyncconnection.cpp @@ -30,8 +30,6 @@ #include "dbsyncconnection.h" -#include - #include "database/database.h" #include "database/databasecommand.h" #include "database/databasecommand_collectionstats.h" @@ -39,6 +37,7 @@ #include "remotecollection.h" #include "source.h" #include "sourcelist.h" +#include "utils/logger.h" // close the dbsync connection after this much inactivity. // it's automatically reestablished as needed. diff --git a/src/libtomahawk/network/msg.h b/src/libtomahawk/network/msg.h index d79fd0982..058d89270 100644 --- a/src/libtomahawk/network/msg.h +++ b/src/libtomahawk/network/msg.h @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -26,13 +26,14 @@ Use static factory method to create, pass around shared pointers: msp_ptr */ + #ifndef MSG_H #define MSG_H + #include #include #include #include -#include #include #include @@ -155,5 +156,4 @@ private: bool m_json_parsed; }; - #endif // MSG_H diff --git a/src/libtomahawk/network/msgprocessor.cpp b/src/libtomahawk/network/msgprocessor.cpp index 85bdcd26c..9b26d7fe9 100644 --- a/src/libtomahawk/network/msgprocessor.cpp +++ b/src/libtomahawk/network/msgprocessor.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -19,6 +19,7 @@ #include "msgprocessor.h" #include "network/servent.h" +#include "utils/logger.h" MsgProcessor::MsgProcessor( quint32 mode, quint32 t ) : diff --git a/src/libtomahawk/network/portfwdthread.cpp b/src/libtomahawk/network/portfwdthread.cpp index b2af82f17..0f7e5aece 100644 --- a/src/libtomahawk/network/portfwdthread.cpp +++ b/src/libtomahawk/network/portfwdthread.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -19,12 +19,12 @@ #include "portfwdthread.h" #include -#include #include #include #include #include "portfwd/portfwd.h" +#include "utils/logger.h" PortFwdThread::PortFwdThread( unsigned int port ) diff --git a/src/libtomahawk/network/remotecollection.cpp b/src/libtomahawk/network/remotecollection.cpp index e73966cac..0740e0358 100644 --- a/src/libtomahawk/network/remotecollection.cpp +++ b/src/libtomahawk/network/remotecollection.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,8 +18,11 @@ #include "remotecollection.h" +#include "utils/logger.h" + using namespace Tomahawk; + RemoteCollection::RemoteCollection( source_ptr source, QObject* parent ) : DatabaseCollection( source, parent ) { @@ -29,7 +32,8 @@ RemoteCollection::RemoteCollection( source_ptr source, QObject* parent ) // adding/removing is done by dbsyncconnection, and the dbcmd objects that modify // the database will make us emit the appropriate signals (tracksAdded etc.) -void RemoteCollection::addTracks( const QList& newitems ) +void +RemoteCollection::addTracks( const QList& newitems ) { Q_UNUSED( newitems ); qDebug() << Q_FUNC_INFO; @@ -37,7 +41,8 @@ void RemoteCollection::addTracks( const QList& newitems ) } -void RemoteCollection::removeTracks( const QDir& dir ) +void +RemoteCollection::removeTracks( const QDir& dir ) { Q_UNUSED( dir ); qDebug() << Q_FUNC_INFO; diff --git a/src/libtomahawk/network/servent.cpp b/src/libtomahawk/network/servent.cpp index da0a8550b..bd5005f75 100644 --- a/src/libtomahawk/network/servent.cpp +++ b/src/libtomahawk/network/servent.cpp @@ -40,8 +40,9 @@ #include "portfwdthread.h" #include "tomahawksettings.h" -#include "utils/tomahawkutils.h" #include +#include "utils/tomahawkutils.h" +#include "utils/logger.h" using namespace Tomahawk; @@ -287,8 +288,8 @@ Servent::incomingConnection( int sd ) return; } - connect( sock, SIGNAL( readyRead() ), SLOT( readyRead() ), Qt::QueuedConnection ); - connect( sock, SIGNAL( disconnected() ), sock, SLOT( deleteLater() ), Qt::QueuedConnection ); + connect( sock, SIGNAL( readyRead() ), SLOT( readyRead() ) ); + connect( sock, SIGNAL( disconnected() ), sock, SLOT( deleteLater() ) ); // qDebug() << "connection accepted."; } @@ -541,9 +542,9 @@ Servent::connectToPeer( const QString& ha, int port, const QString &key, Connect sock->_outbound = true; //qDebug() << "connectToPeer, sock:" << sock->thread(); - connect( sock, SIGNAL( connected() ), SLOT( socketConnected() ), Qt::QueuedConnection ); + connect( sock, SIGNAL( connected() ), SLOT( socketConnected() ) ); connect( sock, SIGNAL( error( QAbstractSocket::SocketError ) ), - SLOT( socketError( QAbstractSocket::SocketError ) ), Qt::QueuedConnection ); + SLOT( socketError( QAbstractSocket::SocketError ) ) ); //qDebug() << "About to connectToHost..."; sock->connectToHost( ha, port, QTcpSocket::ReadWrite ); @@ -553,7 +554,7 @@ Servent::connectToPeer( const QString& ha, int port, const QString &key, Connect void -Servent::reverseOfferRequest( ControlConnection* orig_conn, const QString &theirdbid, const QString& key, const QString& theirkey ) +Servent::reverseOfferRequest( ControlConnection* orig_conn, const QString& theirdbid, const QString& key, const QString& theirkey ) { Q_ASSERT( this->thread() == QThread::currentThread() ); diff --git a/src/libtomahawk/network/streamconnection.cpp b/src/libtomahawk/network/streamconnection.cpp index e33ed6196..37035d488 100644 --- a/src/libtomahawk/network/streamconnection.cpp +++ b/src/libtomahawk/network/streamconnection.cpp @@ -27,6 +27,7 @@ #include "database/databasecommand_loadfile.h" #include "database/database.h" #include "sourcelist.h" +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/pipeline.cpp b/src/libtomahawk/pipeline.cpp index 8a253ce3a..4e422601a 100644 --- a/src/libtomahawk/pipeline.cpp +++ b/src/libtomahawk/pipeline.cpp @@ -18,12 +18,13 @@ #include "pipeline.h" -#include #include #include "functimeout.h" #include "database/database.h" +#include "utils/logger.h" + #define DEFAULT_CONCURRENT_QUERIES 4 #define MAX_CONCURRENT_QUERIES 16 #define CLEANUP_TIMEOUT 5 * 60 * 1000 diff --git a/src/libtomahawk/playlist.cpp b/src/libtomahawk/playlist.cpp index f72bb91be..c40db7232 100644 --- a/src/libtomahawk/playlist.cpp +++ b/src/libtomahawk/playlist.cpp @@ -33,6 +33,8 @@ #include "source.h" #include "sourcelist.h" +#include "utils/logger.h" + using namespace Tomahawk; diff --git a/src/libtomahawk/playlist.h b/src/libtomahawk/playlist.h index a74729f7d..8ba6fd65a 100644 --- a/src/libtomahawk/playlist.h +++ b/src/libtomahawk/playlist.h @@ -21,7 +21,6 @@ #include #include -#include #include #include @@ -274,7 +273,7 @@ private: bool m_shared; result_ptr m_currentItem; - + QList< plentry_ptr > m_initEntries; QList< plentry_ptr > m_entries; diff --git a/src/libtomahawk/playlist/albumitem.cpp b/src/libtomahawk/playlist/albumitem.cpp index 398703e68..bad9eac64 100644 --- a/src/libtomahawk/playlist/albumitem.cpp +++ b/src/libtomahawk/playlist/albumitem.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -19,8 +19,7 @@ #include "albumitem.h" #include "utils/tomahawkutils.h" - -#include +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/playlist/albumitemdelegate.cpp b/src/libtomahawk/playlist/albumitemdelegate.cpp index aac8c1777..af5d1b9da 100644 --- a/src/libtomahawk/playlist/albumitemdelegate.cpp +++ b/src/libtomahawk/playlist/albumitemdelegate.cpp @@ -19,7 +19,6 @@ #include "albumitemdelegate.h" #include -#include #include #include @@ -27,6 +26,7 @@ #include "result.h" #include "utils/tomahawkutils.h" +#include "utils/logger.h" #include "playlist/albumitem.h" #include "playlist/albumproxymodel.h" diff --git a/src/libtomahawk/playlist/albummodel.cpp b/src/libtomahawk/playlist/albummodel.cpp index 345c19d35..1d215040d 100644 --- a/src/libtomahawk/playlist/albummodel.cpp +++ b/src/libtomahawk/playlist/albummodel.cpp @@ -18,7 +18,6 @@ #include "albummodel.h" -#include #include #include #include @@ -26,6 +25,7 @@ #include "database/database.h" #include "utils/tomahawkutils.h" +#include "utils/logger.h" static QString s_tmInfoIdentifier = QString( "ALBUMMODEL" ); diff --git a/src/libtomahawk/playlist/albumproxymodel.cpp b/src/libtomahawk/playlist/albumproxymodel.cpp index 6bafcdce5..44e219a6c 100644 --- a/src/libtomahawk/playlist/albumproxymodel.cpp +++ b/src/libtomahawk/playlist/albumproxymodel.cpp @@ -18,10 +18,10 @@ #include "albumproxymodel.h" -#include #include #include "query.h" +#include "utils/logger.h" AlbumProxyModel::AlbumProxyModel( QObject* parent ) diff --git a/src/libtomahawk/playlist/albumview.cpp b/src/libtomahawk/playlist/albumview.cpp index 71a522733..4dbee7bad 100644 --- a/src/libtomahawk/playlist/albumview.cpp +++ b/src/libtomahawk/playlist/albumview.cpp @@ -18,7 +18,6 @@ #include "albumview.h" -#include #include #include #include @@ -29,6 +28,7 @@ #include "tomahawksettings.h" #include "albumitemdelegate.h" #include "viewmanager.h" +#include "utils/logger.h" static QString s_tmInfoIdentifier = QString( "ALBUMMODEL" ); diff --git a/src/libtomahawk/playlist/artistview.cpp b/src/libtomahawk/playlist/artistview.cpp index a7cb548c3..49b1e1153 100644 --- a/src/libtomahawk/playlist/artistview.cpp +++ b/src/libtomahawk/playlist/artistview.cpp @@ -18,7 +18,6 @@ #include "artistview.h" -#include #include #include #include @@ -31,6 +30,7 @@ #include "treeheader.h" #include "treeitemdelegate.h" #include "viewmanager.h" +#include "utils/logger.h" static QString s_tmInfoIdentifier = QString( "TREEMODEL" ); diff --git a/src/libtomahawk/playlist/collectionflatmodel.cpp b/src/libtomahawk/playlist/collectionflatmodel.cpp index 2090b6cba..37556400b 100644 --- a/src/libtomahawk/playlist/collectionflatmodel.cpp +++ b/src/libtomahawk/playlist/collectionflatmodel.cpp @@ -18,12 +18,12 @@ #include "collectionflatmodel.h" -#include #include #include #include "database/database.h" #include "sourcelist.h" +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/playlist/collectionproxymodel.cpp b/src/libtomahawk/playlist/collectionproxymodel.cpp index a7eb2f572..dc050511c 100644 --- a/src/libtomahawk/playlist/collectionproxymodel.cpp +++ b/src/libtomahawk/playlist/collectionproxymodel.cpp @@ -18,11 +18,11 @@ #include "collectionproxymodel.h" -#include #include #include "album.h" #include "query.h" +#include "utils/logger.h" CollectionProxyModel::CollectionProxyModel( QObject* parent ) diff --git a/src/libtomahawk/playlist/collectionview.cpp b/src/libtomahawk/playlist/collectionview.cpp index d64dca9e7..f87a33922 100644 --- a/src/libtomahawk/playlist/collectionview.cpp +++ b/src/libtomahawk/playlist/collectionview.cpp @@ -18,12 +18,12 @@ #include "collectionview.h" -#include #include #include #include "playlist/collectionproxymodel.h" #include "widgets/overlaywidget.h" +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/playlist/dynamic/DynamicControl.cpp b/src/libtomahawk/playlist/dynamic/DynamicControl.cpp index ae81f8665..31ec92315 100644 --- a/src/libtomahawk/playlist/dynamic/DynamicControl.cpp +++ b/src/libtomahawk/playlist/dynamic/DynamicControl.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,21 +18,23 @@ #include "DynamicControl.h" +#include "utils/logger.h" + + Tomahawk::DynamicControl::DynamicControl( const QStringList& typeSelectors ) : m_typeSelectors( typeSelectors ) { - } + Tomahawk::DynamicControl::~DynamicControl() { - } + Tomahawk::DynamicControl::DynamicControl(const QString& selectedType, const QStringList& typeSelectors, QObject* parent) : QObject(parent) , m_selectedType( selectedType ) , m_typeSelectors( typeSelectors ) { - } diff --git a/src/libtomahawk/playlist/dynamic/DynamicModel.cpp b/src/libtomahawk/playlist/dynamic/DynamicModel.cpp index b101834df..1f5807d70 100644 --- a/src/libtomahawk/playlist/dynamic/DynamicModel.cpp +++ b/src/libtomahawk/playlist/dynamic/DynamicModel.cpp @@ -20,9 +20,11 @@ #include "GeneratorInterface.h" #include "audio/audioengine.h" #include +#include "utils/logger.h" using namespace Tomahawk; + DynamicModel::DynamicModel( QObject* parent ) : PlaylistModel( parent ) , m_onDemandRunning( false ) @@ -36,11 +38,13 @@ DynamicModel::DynamicModel( QObject* parent ) } + DynamicModel::~DynamicModel() { } + void DynamicModel::loadPlaylist( const Tomahawk::dynplaylist_ptr& playlist, bool loadEntries ) { @@ -61,6 +65,7 @@ DynamicModel::loadPlaylist( const Tomahawk::dynplaylist_ptr& playlist, bool load emit trackCountChanged( rowCount( QModelIndex() ) ); } + QString DynamicModel::description() const { @@ -81,6 +86,7 @@ DynamicModel::startOnDemand() m_onDemandRunning = true; } + void DynamicModel::newTrackGenerated( const Tomahawk::query_ptr& query ) { @@ -102,6 +108,7 @@ DynamicModel::newTrackGenerated( const Tomahawk::query_ptr& query ) } } + void DynamicModel::stopOnDemand( bool stopPlaying ) { @@ -112,6 +119,7 @@ DynamicModel::stopOnDemand( bool stopPlaying ) disconnect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), this, SLOT( newTrackLoading() ) ); } + void DynamicModel::changeStation() { @@ -121,6 +129,7 @@ DynamicModel::changeStation() m_playlist->generator()->startOnDemand(); } + void DynamicModel::trackResolveFinished( bool success ) { @@ -177,6 +186,7 @@ DynamicModel::newTrackLoading() } } + void DynamicModel::tracksGenerated( const QList< query_ptr > entries, int limitResolvedTo ) { @@ -192,6 +202,7 @@ DynamicModel::tracksGenerated( const QList< query_ptr > entries, int limitResolv } } + void DynamicModel::filterUnresolved( const QList< query_ptr >& entries ) { @@ -203,6 +214,7 @@ DynamicModel::filterUnresolved( const QList< query_ptr >& entries ) Pipeline::instance()->resolve( entries, true ); } + void DynamicModel::filteringTrackResolved( bool successful ) { diff --git a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp index 205c7e8e2..c456fc1c5 100644 --- a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp +++ b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp @@ -27,11 +27,13 @@ #include "database/databasecommand_loaddynamicplaylist.h" #include "database/databasecommand_deletedynamicplaylist.h" #include "tomahawksettings.h" +#include "utils/logger.h" using namespace Tomahawk; -DynamicPlaylist::DynamicPlaylist(const Tomahawk::source_ptr& author, const QString& type ) -: Playlist(author) + +DynamicPlaylist::DynamicPlaylist( const Tomahawk::source_ptr& author, const QString& type ) + : Playlist( author ) { qDebug() << Q_FUNC_INFO << "JSON"; m_generator = geninterface_ptr( GeneratorFactory::create( type ) ); @@ -43,6 +45,7 @@ DynamicPlaylist::~DynamicPlaylist() } + // Called by loadAllPlaylists command DynamicPlaylist::DynamicPlaylist ( const Tomahawk::source_ptr& src, const QString& currentrevision, @@ -55,7 +58,7 @@ DynamicPlaylist::DynamicPlaylist ( const Tomahawk::source_ptr& src, bool shared, int lastmod, const QString& guid ) -: Playlist( src, currentrevision, title, info, creator, createdOn, shared, lastmod, guid ) + : Playlist( src, currentrevision, title, info, creator, createdOn, shared, lastmod, guid ) { // qDebug() << "Creating Dynamic Playlist 1"; // TODO instantiate generator @@ -73,37 +76,42 @@ DynamicPlaylist::DynamicPlaylist ( const Tomahawk::source_ptr& author, const QString& type, GeneratorMode mode, bool shared ) -: Playlist ( author, guid, title, info, creator, shared ) + : Playlist ( author, guid, title, info, creator, shared ) { // qDebug() << "Creating Dynamic Playlist 2"; m_generator = geninterface_ptr( GeneratorFactory::create( type ) ); m_generator->setMode( mode ); } + geninterface_ptr DynamicPlaylist::generator() const { return m_generator; } + int DynamicPlaylist::mode() const { return m_generator->mode(); } + void -DynamicPlaylist::setGenerator(const Tomahawk::geninterface_ptr& gen_ptr) +DynamicPlaylist::setGenerator( const Tomahawk::geninterface_ptr& gen_ptr ) { m_generator = gen_ptr; } + QString DynamicPlaylist::type() const { return m_generator->type(); } + void DynamicPlaylist::setMode( int mode ) { @@ -111,7 +119,6 @@ DynamicPlaylist::setMode( int mode ) } - dynplaylist_ptr DynamicPlaylist::create( const Tomahawk::source_ptr& author, const QString& guid, @@ -120,8 +127,7 @@ DynamicPlaylist::create( const Tomahawk::source_ptr& author, const QString& creator, GeneratorMode mode, bool shared, - const QString& type -) + const QString& type ) { dynplaylist_ptr dynplaylist = dynplaylist_ptr( new DynamicPlaylist( author, guid, title, info, creator, type, mode, shared ) ); @@ -130,16 +136,17 @@ DynamicPlaylist::create( const Tomahawk::source_ptr& author, Database::instance()->enqueue( QSharedPointer(cmd) ); dynplaylist->reportCreated( dynplaylist ); return dynplaylist; - } + void DynamicPlaylist::createNewRevision( const QString& newUuid ) { if( mode() == Static ) { createNewRevision( newUuid.isEmpty() ? uuid() : newUuid, currentrevision(), type(), generator()->controls(), entries() ); - } else if( mode() == OnDemand ) + } + else if( mode() == OnDemand ) { createNewRevision( newUuid.isEmpty() ? uuid() : newUuid, currentrevision(), type(), generator()->controls()); } @@ -183,6 +190,7 @@ DynamicPlaylist::createNewRevision( const QString& newrev, Database::instance()->enqueue( QSharedPointer( cmd ) ); } + // create a new revision that will be an ondemand playlist, as it has no entries void DynamicPlaylist::createNewRevision( const QString& newrev, @@ -206,6 +214,7 @@ DynamicPlaylist::createNewRevision( const QString& newrev, Database::instance()->enqueue( QSharedPointer( cmd ) ); } + void DynamicPlaylist::loadRevision( const QString& rev ) { @@ -247,6 +256,7 @@ DynamicPlaylist::loadRevision( const QString& rev ) Database::instance()->enqueue( QSharedPointer( cmd ) ); } + bool DynamicPlaylist::remove( const Tomahawk::dynplaylist_ptr& playlist ) { @@ -260,6 +270,7 @@ DynamicPlaylist::remove( const Tomahawk::dynplaylist_ptr& playlist ) return false; } + void DynamicPlaylist::reportCreated( const Tomahawk::dynplaylist_ptr& self ) { @@ -276,6 +287,7 @@ DynamicPlaylist::reportCreated( const Tomahawk::dynplaylist_ptr& self ) author()->collection()->addStation( self ); } + void DynamicPlaylist::reportDeleted( const Tomahawk::dynplaylist_ptr& self ) { @@ -290,7 +302,9 @@ DynamicPlaylist::reportDeleted( const Tomahawk::dynplaylist_ptr& self ) emit deleted( self ); } -void DynamicPlaylist::addEntries(const QList< query_ptr >& queries, const QString& oldrev) + +void +DynamicPlaylist::addEntries(const QList< query_ptr >& queries, const QString& oldrev) { Q_ASSERT( m_generator->mode() == Static ); @@ -300,7 +314,9 @@ void DynamicPlaylist::addEntries(const QList< query_ptr >& queries, const QStrin createNewRevision( newrev, oldrev, m_generator->type(), m_generator->controls(), el ); } -void DynamicPlaylist::addEntry(const Tomahawk::query_ptr& query, const QString& oldrev) + +void +DynamicPlaylist::addEntry(const Tomahawk::query_ptr& query, const QString& oldrev) { QList queries; queries << query; @@ -308,14 +324,16 @@ void DynamicPlaylist::addEntry(const Tomahawk::query_ptr& query, const QString& addEntries( queries, oldrev ); } -void DynamicPlaylist::setRevision( const QString& rev, - const QList< QString >& neworderedguids, - const QList< QString >& oldorderedguids, - const QString& type, - const QList< dyncontrol_ptr >& controls, - bool is_newest_rev, - const QMap< QString, plentry_ptr >& addedmap, - bool applied) + +void +DynamicPlaylist::setRevision( const QString& rev, + const QList< QString >& neworderedguids, + const QList< QString >& oldorderedguids, + const QString& type, + const QList< dyncontrol_ptr >& controls, + bool is_newest_rev, + const QMap< QString, plentry_ptr >& addedmap, + bool applied ) { // we're probably being called by a database worker thread if( QThread::currentThread() != thread() ) @@ -383,14 +401,15 @@ DynamicPlaylist::setRevision( const QString& rev, QList controls = variantsToControl( controlsV ); setRevision( rev, neworderedguids, oldorderedguids, type, controls, is_newest_rev, addedmap, applied ); - } -void DynamicPlaylist::setRevision( const QString& rev, - bool is_newest_rev, - const QString& type, - const QList< dyncontrol_ptr >& controls, - bool applied ) + +void +DynamicPlaylist::setRevision( const QString& rev, + bool is_newest_rev, + const QString& type, + const QList< dyncontrol_ptr >& controls, + bool applied ) { if( QThread::currentThread() != thread() ) { @@ -451,7 +470,9 @@ DynamicPlaylist::setRevision( const QString& rev, setRevision( rev, is_newest_rev, type, controls, applied ); } -QList< dyncontrol_ptr > DynamicPlaylist::variantsToControl( const QList< QVariantMap >& controlsV ) + +QList< dyncontrol_ptr > +DynamicPlaylist::variantsToControl( const QList< QVariantMap >& controlsV ) { QList realControls; foreach( QVariantMap controlV, controlsV ) { diff --git a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h index 90a63da6e..e8ab3cc0a 100644 --- a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h +++ b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.h @@ -77,16 +77,15 @@ public: /// Generate an empty dynamic playlist with default generator static Tomahawk::dynplaylist_ptr create( const source_ptr& author, - const QString& guid, - const QString& title, - const QString& info, - const QString& creator, - GeneratorMode mode, - bool shared, - const QString& type = QString() - ); - static bool remove( const dynplaylist_ptr& playlist ); + const QString& guid, + const QString& title, + const QString& info, + const QString& creator, + GeneratorMode mode, + bool shared, + const QString& type = QString() ); + static bool remove( const dynplaylist_ptr& playlist ); virtual void loadRevision( const QString& rev = "" ); // :-( int becuase qjson chokes on my enums @@ -107,7 +106,7 @@ public: // maybe friend QObjectHelper and make them private? explicit DynamicPlaylist( const source_ptr& author, const QString& type ); void setMode( int mode ); - void setType( const QString& /*type*/ ) { /** TODO */; } + void setType( const QString& /*type*/ ) { /** TODO */; } void setGenerator( const geninterface_ptr& gen_ptr ); // @@ -165,31 +164,29 @@ public slots: private: // called from loadAllPlaylists DB cmd via databasecollection (in GUI thread) explicit DynamicPlaylist( const source_ptr& src, - const QString& currentrevision, - const QString& title, - const QString& info, - const QString& creator, - uint createdOn, - const QString& type, - GeneratorMode mode, - bool shared, - int lastmod, - const QString& guid = "" ); // populate db + const QString& currentrevision, + const QString& title, + const QString& info, + const QString& creator, + uint createdOn, + const QString& type, + GeneratorMode mode, + bool shared, + int lastmod, + const QString& guid = "" ); // populate db // called when creating new playlist explicit DynamicPlaylist( const source_ptr& author, - const QString& guid, - const QString& title, - const QString& info, - const QString& creator, - const QString& type, - GeneratorMode mode, - bool shared ); + const QString& guid, + const QString& title, + const QString& info, + const QString& creator, + const QString& type, + GeneratorMode mode, + bool shared ); -private: QList< dyncontrol_ptr > variantsToControl( const QList< QVariantMap >& controlsV ); geninterface_ptr m_generator; - }; }; // namespace diff --git a/src/libtomahawk/playlist/dynamic/DynamicView.cpp b/src/libtomahawk/playlist/dynamic/DynamicView.cpp index ab1a67deb..6fe7d0459 100644 --- a/src/libtomahawk/playlist/dynamic/DynamicView.cpp +++ b/src/libtomahawk/playlist/dynamic/DynamicView.cpp @@ -18,18 +18,18 @@ #include "DynamicView.h" -#include "widgets/overlaywidget.h" +#include +#include +#include +#include +#include + #include "playlistmodel.h" #include "trackproxymodel.h" #include "trackheader.h" - -#include -#include -#include -#include - #include "DynamicModel.h" -#include +#include "widgets/overlaywidget.h" +#include "utils/logger.h" using namespace Tomahawk; @@ -38,6 +38,7 @@ using namespace Tomahawk; #define SLIDE_OFFSET 500 #define LONG_MULT 0 // to avoid superfast slides when the length is long, make it longer incrementally + DynamicView::DynamicView( QWidget* parent ) : PlaylistView( parent ) , m_onDemand( false ) @@ -65,11 +66,13 @@ DynamicView::DynamicView( QWidget* parent ) connect( &m_fadeOutAnim, SIGNAL( finished() ), this, SLOT( animFinished() ) ); } + DynamicView::~DynamicView() { } + void DynamicView::setDynamicModel( DynamicModel* model) { @@ -80,6 +83,7 @@ DynamicView::setDynamicModel( DynamicModel* model) connect( m_model, SIGNAL( checkForOverflow() ), this, SLOT( checkForOverflow() ) ); } + void DynamicView::setOnDemand( bool onDemand ) { @@ -91,12 +95,14 @@ DynamicView::setOnDemand( bool onDemand ) setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded ); } + void DynamicView::setReadOnly( bool readOnly ) { m_readOnly = readOnly; } + void DynamicView::showMessageTimeout( const QString& title, const QString& body ) { @@ -107,15 +113,17 @@ DynamicView::showMessageTimeout( const QString& title, const QString& body ) overlay()->show( 10 ); } + void -DynamicView::showMessage(const QString& message) +DynamicView::showMessage( const QString& message ) { overlay()->setText( message ); overlay()->show(); } + void -DynamicView::setDynamicWorking(bool working) +DynamicView::setDynamicWorking( bool working ) { m_working = working; if( working ) @@ -148,6 +156,7 @@ DynamicView::onTrackCountChanged( unsigned int tracks ) } } + void DynamicView::checkForOverflow() { @@ -173,6 +182,7 @@ DynamicView::checkForOverflow() } } + void DynamicView::collapseEntries( int startRow, int num, int numToKeep ) { @@ -257,6 +267,7 @@ DynamicView::collapseEntries( int startRow, int num, int numToKeep ) proxyModel()->removeIndexes( todel ); } + QPixmap DynamicView::backgroundBetween( QRect rect, int rowStart ) { @@ -286,6 +297,7 @@ DynamicView::backgroundBetween( QRect rect, int rowStart ) return bg; } + void DynamicView::animFinished() { @@ -294,6 +306,7 @@ DynamicView::animFinished() m_checkOnCollapse = false; } + void DynamicView::paintEvent( QPaintEvent* event ) { @@ -326,4 +339,3 @@ DynamicView::paintEvent( QPaintEvent* event ) } } } - diff --git a/src/libtomahawk/playlist/dynamic/GeneratorFactory.cpp b/src/libtomahawk/playlist/dynamic/GeneratorFactory.cpp index dd4e44a96..ebcde7288 100644 --- a/src/libtomahawk/playlist/dynamic/GeneratorFactory.cpp +++ b/src/libtomahawk/playlist/dynamic/GeneratorFactory.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -19,49 +19,55 @@ #include "dynamic/GeneratorFactory.h" #include "dynamic/GeneratorInterface.h" +#include "utils/logger.h" + using namespace Tomahawk; + QHash< QString, GeneratorFactoryInterface* > GeneratorFactory::s_factories = QHash< QString, GeneratorFactoryInterface* >(); -geninterface_ptr +geninterface_ptr GeneratorFactory::create ( const QString& type ) { if( type.isEmpty() && !s_factories.isEmpty() ) // default, return first return geninterface_ptr( s_factories.begin().value()->create() ); - + if( !s_factories.contains( type ) ) return geninterface_ptr(); - + return geninterface_ptr( s_factories.value( type )->create() ); } -dyncontrol_ptr -GeneratorFactory::createControl(const QString& generatorType, const QString& controlType) + +dyncontrol_ptr +GeneratorFactory::createControl( const QString& generatorType, const QString& controlType ) { if( generatorType.isEmpty() || !s_factories.contains( generatorType ) ) return dyncontrol_ptr(); - + return s_factories.value( generatorType )->createControl( controlType ); } -void +void GeneratorFactory::registerFactory ( const QString& type, GeneratorFactoryInterface* interface ) { s_factories.insert( type, interface ); } -QStringList + +QStringList GeneratorFactory::types() { return s_factories.keys(); } -QStringList -GeneratorFactory::typeSelectors(const QString& type) + +QStringList +GeneratorFactory::typeSelectors( const QString& type ) { if( !s_factories.contains( type ) ) return QStringList(); - + return s_factories.value( type )->typeSelectors(); } diff --git a/src/libtomahawk/playlist/dynamic/GeneratorFactory.h b/src/libtomahawk/playlist/dynamic/GeneratorFactory.h index 56a131cd1..e6dcbdc3f 100644 --- a/src/libtomahawk/playlist/dynamic/GeneratorFactory.h +++ b/src/libtomahawk/playlist/dynamic/GeneratorFactory.h @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -27,8 +27,9 @@ #include "dllmacro.h" -namespace Tomahawk { - +namespace Tomahawk +{ + /** * Generators should subclass this and have it create the custom Generator */ @@ -38,14 +39,14 @@ public: GeneratorFactoryInterface() {} virtual ~GeneratorFactoryInterface() {} - + virtual GeneratorInterface* create() = 0; /** * Create a control for this generator, not tied to this generator itself. Used when loading dynamic * playlists from a dbcmd. */ virtual dyncontrol_ptr createControl( const QString& controlType = QString() ) = 0; - + virtual QStringList typeSelectors() const = 0; }; @@ -58,16 +59,15 @@ public: static geninterface_ptr create( const QString& type ); // only used when loading from dbcmd static dyncontrol_ptr createControl( const QString& generatorType, const QString& controlType = QString() ); - + static void registerFactory( const QString& type, GeneratorFactoryInterface* interface ); static QStringList types(); static QStringList typeSelectors( const QString& type ); - + private: static QHash s_factories; - -}; +}; }; diff --git a/src/libtomahawk/playlist/dynamic/GeneratorInterface.cpp b/src/libtomahawk/playlist/dynamic/GeneratorInterface.cpp index 0ccf5888a..eb24c4293 100644 --- a/src/libtomahawk/playlist/dynamic/GeneratorInterface.cpp +++ b/src/libtomahawk/playlist/dynamic/GeneratorInterface.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,58 +18,68 @@ #include "dynamic/GeneratorInterface.h" -Tomahawk::GeneratorInterface::GeneratorInterface( QObject* parent ): QObject( parent ) -{ +#include "utils/logger.h" + +Tomahawk::GeneratorInterface::GeneratorInterface( QObject* parent ) + : QObject( parent ) +{ } + Tomahawk::GeneratorInterface::~GeneratorInterface() { - } -QList< Tomahawk::dyncontrol_ptr > + +QList< Tomahawk::dyncontrol_ptr > Tomahawk::GeneratorInterface::controls() { // if( m_controls.isEmpty() ) { // return a default control (so the user can add more) // return QList< Tomahawk::dyncontrol_ptr >() << createControl(); // } - + return m_controls; } -QPixmap + +QPixmap Tomahawk::GeneratorInterface::logo() { return QPixmap(); } -void + +void Tomahawk::GeneratorInterface::addControl( const Tomahawk::dyncontrol_ptr& control ) { m_controls << control; } -void + +void Tomahawk::GeneratorInterface::clearControls() { m_controls.clear(); } -void + +void Tomahawk::GeneratorInterface::setControls( const QList< Tomahawk::dyncontrol_ptr >& controls ) { m_controls = controls; } -void Tomahawk::GeneratorInterface::removeControl(const Tomahawk::dyncontrol_ptr& control) + +void +Tomahawk::GeneratorInterface::removeControl( const Tomahawk::dyncontrol_ptr& control ) { m_controls.removeAll( control ); } -Tomahawk::dyncontrol_ptr -Tomahawk::GeneratorInterface::createControl(const QString& type) +Tomahawk::dyncontrol_ptr +Tomahawk::GeneratorInterface::createControl( const QString& type ) { Q_UNUSED( type ); Q_ASSERT( false ); diff --git a/src/libtomahawk/playlist/dynamic/GeneratorInterface.h b/src/libtomahawk/playlist/dynamic/GeneratorInterface.h index 238c14ff6..3f7d11873 100644 --- a/src/libtomahawk/playlist/dynamic/GeneratorInterface.h +++ b/src/libtomahawk/playlist/dynamic/GeneratorInterface.h @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -29,73 +29,74 @@ #include "dllmacro.h" -namespace Tomahawk { - +namespace Tomahawk +{ + /** * The abstract interface for Dynamic Playlist Generators. Generators have the following features: * - They create new DynamicControls that are appropriate for the generator * - They expose a list of controls that this generator currently is operating on * - They have a mode of OnDemand or Static - * + * * And they generate tracks in two ways: * - Statically (ask for X tracks, get X tracks) - * - On Demand (as for next track, ask for next track again, etc) + * - On Demand (as for next track, ask for next track again, etc) */ class DLLEXPORT GeneratorInterface : public QObject { Q_OBJECT - Q_PROPERTY( QString type READ type ) + Q_PROPERTY( QString type READ type ) /// oh qjson. - Q_PROPERTY( int mode READ mode WRITE setMode ) - + Q_PROPERTY( int mode READ mode WRITE setMode ) + public: // can't inline constructors/destructors for forward declared shared pointer types explicit GeneratorInterface( QObject* parent = 0 ); virtual ~GeneratorInterface(); - + // Can't make it pure otherwise we can't shove it in QVariants :-/ // empty QString means use default /// The generator will keep track of all the controls it creates. No need to tell it about controls /// you ask it to create virtual dyncontrol_ptr createControl( const QString& type = QString() ); - + /// A logo to display for this generator, if it has one virtual QPixmap logo(); - + /** * Generate tracks from the controls in this playlist. If this generator is in static * mode, then it will return the desired number of tracks. If the generator is in OnDemand * mode, this will do nothing. - * + * * Connect to the generated() signal for the results. - * + * */ virtual void generate( int number = -1 ) { Q_UNUSED( number ); } - + /** * Starts an on demand session for this generator. Listen to the nextTrack() signal to get * the first generated track */ virtual void startOnDemand() {} - + /** * Get the next on demand track. * \param rating Rating from 1-5, -1 for none */ virtual void fetchNext( int rating = -1 ) { Q_UNUSED( rating ) } - + /** * Return a sentence that describes this generator's controls. TODO english only ATM */ virtual QString sentenceSummary() { return QString(); } - + /** * If an OnDemand playlist can be steered, this returns true. * If so, the generator should also provide a steering widget * in steeringWidget() */ virtual bool onDemandSteerable() const { return false; } - + /** * Returns a widget used to steer the OnDemand dynamic playlist. * If this generator doesn't support this (and returns false for @@ -103,25 +104,25 @@ public: * for reacting to changes in the widget. */ virtual QWidget* steeringWidget() { return 0; } - + /// The type of this generator QString type() const { return m_type; } - + int mode() const { return (int)m_mode; } void setMode( int mode ) { m_mode = (GeneratorMode)mode; } - + // control functions QList< dyncontrol_ptr > controls(); void addControl( const dyncontrol_ptr& control ); void clearControls(); void setControls( const QList< dyncontrol_ptr>& controls ); void removeControl( const dyncontrol_ptr& control ); - + signals: void error( const QString& title, const QString& body); void generated( const QList< Tomahawk::query_ptr>& queries ); void nextTrackGenerated( const Tomahawk::query_ptr& track ); - + protected: QString m_type; GeneratorMode m_mode; diff --git a/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp b/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp index f34b09692..c182c986b 100644 --- a/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp +++ b/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp @@ -18,21 +18,24 @@ #include "dynamic/echonest/EchonestControl.h" -#include "dynamic/widgets/MiscControlWidgets.h" - -#include - #include #include #include +#include +#include + +#include "dynamic/widgets/MiscControlWidgets.h" +#include #include "EchonestGenerator.h" -#include -#include + +#include "utils/logger.h" + QHash< QString, QStringList > Tomahawk::EchonestControl::s_suggestCache = QHash< QString, QStringList >(); bool Tomahawk::EchonestControl::s_fetchingMoodsAndStyles = false; int Tomahawk::EchonestControl::s_stylePollCount = 0; + Tomahawk::EchonestControl::EchonestControl( const QString& selectedType, const QStringList& typeSelectors, QObject* parent ) : DynamicControl ( selectedType.isEmpty() ? "Artist" : selectedType, typeSelectors, parent ) { @@ -48,18 +51,21 @@ Tomahawk::EchonestControl::EchonestControl( const QString& selectedType, const Q updateWidgets(); } + QWidget* Tomahawk::EchonestControl::inputField() { return m_input.data(); } + QWidget* Tomahawk::EchonestControl::matchSelector() { return m_match.data(); } + void Tomahawk::EchonestControl::setSelectedType ( const QString& type ) { @@ -76,6 +82,7 @@ Tomahawk::EchonestControl::setSelectedType ( const QString& type ) } } + Echonest::DynamicPlaylist::PlaylistParamData Tomahawk::EchonestControl::toENParam() const { @@ -87,24 +94,28 @@ Tomahawk::EchonestControl::toENParam() const return m_data; } + QString Tomahawk::EchonestControl::input() const { return m_data.second.toString(); } + QString Tomahawk::EchonestControl::match() const { return m_matchData; } + QString Tomahawk::EchonestControl::matchString() const { return m_matchString; } + QString Tomahawk::EchonestControl::summary() const { @@ -114,20 +125,23 @@ Tomahawk::EchonestControl::summary() const return m_summary; } + void -Tomahawk::EchonestControl::setInput(const QString& input) +Tomahawk::EchonestControl::setInput( const QString& input ) { m_data.second = input; updateWidgetsFromData(); } + void -Tomahawk::EchonestControl::setMatch(const QString& match) +Tomahawk::EchonestControl::setMatch( const QString& match ) { m_matchData = match; updateWidgetsFromData(); } + void Tomahawk::EchonestControl::updateWidgets() { @@ -378,6 +392,7 @@ Tomahawk::EchonestControl::updateWidgets() calculateSummary(); } + void Tomahawk::EchonestControl::setupMinMaxWidgets( Echonest::DynamicPlaylist::PlaylistParam min, Echonest::DynamicPlaylist::PlaylistParam max, const QString& leftL, const QString& rightL, int maxRange ) { @@ -455,6 +470,7 @@ Tomahawk::EchonestControl::updateData() calculateSummary(); } + void Tomahawk::EchonestControl::updateFromComboAndSlider( bool smooth ) { @@ -470,6 +486,7 @@ Tomahawk::EchonestControl::updateFromComboAndSlider( bool smooth ) } } + void Tomahawk::EchonestControl::updateFromLabelAndCombo() { @@ -521,6 +538,7 @@ Tomahawk::EchonestControl::updateWidgetsFromData() calculateSummary(); } + void Tomahawk::EchonestControl::updateToComboAndSlider( bool smooth ) { @@ -532,7 +550,9 @@ Tomahawk::EchonestControl::updateToComboAndSlider( bool smooth ) ls->slider()->setValue( m_data.second.toDouble() * ( smooth ? 10000. : 1 ) ); } -void Tomahawk::EchonestControl::updateToLabelAndCombo() + +void +Tomahawk::EchonestControl::updateToLabelAndCombo() { QComboBox* s = qobject_cast< QComboBox* >( m_input.data() ); if( s ) { @@ -540,6 +560,7 @@ void Tomahawk::EchonestControl::updateToLabelAndCombo() } } + void Tomahawk::EchonestControl::editingFinished() { @@ -547,6 +568,7 @@ Tomahawk::EchonestControl::editingFinished() m_editingTimer.start(); } + void Tomahawk::EchonestControl::editTimerFired() { @@ -558,6 +580,7 @@ Tomahawk::EchonestControl::editTimerFired() m_cacheData = m_data.second; } + void Tomahawk::EchonestControl::artistTextEdited( const QString& text ) { @@ -587,6 +610,7 @@ Tomahawk::EchonestControl::artistTextEdited( const QString& text ) } } + void Tomahawk::EchonestControl::suggestFinished() { @@ -621,6 +645,7 @@ Tomahawk::EchonestControl::suggestFinished() addArtistSuggestions( suggestions ); } + void Tomahawk::EchonestControl::addArtistSuggestions( const QStringList& suggestions ) { @@ -632,6 +657,7 @@ Tomahawk::EchonestControl::addArtistSuggestions( const QStringList& suggestions l->completer()->complete(); } + void Tomahawk::EchonestControl::calculateSummary() { @@ -704,6 +730,7 @@ Tomahawk::EchonestControl::calculateSummary() m_summary = summary; } + void Tomahawk::EchonestControl::checkForMoodsOrStylesFetched() { @@ -717,6 +744,7 @@ Tomahawk::EchonestControl::checkForMoodsOrStylesFetched() } } + bool Tomahawk::EchonestControl::insertMoodsAndStyles() { diff --git a/src/libtomahawk/playlist/dynamic/echonest/EchonestGenerator.cpp b/src/libtomahawk/playlist/dynamic/echonest/EchonestGenerator.cpp index 2feadd9ee..d6ff1d0e5 100644 --- a/src/libtomahawk/playlist/dynamic/echonest/EchonestGenerator.cpp +++ b/src/libtomahawk/playlist/dynamic/echonest/EchonestGenerator.cpp @@ -21,16 +21,21 @@ #include "dynamic/echonest/EchonestSteerer.h" #include "query.h" #include "utils/tomahawkutils.h" +#include "utils/logger.h" using namespace Tomahawk; + QVector< QString > EchonestGenerator::s_moods = QVector< QString >(); QVector< QString > EchonestGenerator::s_styles = QVector< QString >(); QNetworkReply* EchonestGenerator::s_moodsJob = 0; QNetworkReply* EchonestGenerator::s_stylesJob = 0; + EchonestFactory::EchonestFactory() -{} +{ +} + GeneratorInterface* EchonestFactory::create() @@ -38,12 +43,14 @@ EchonestFactory::create() return new EchonestGenerator(); } + dyncontrol_ptr EchonestFactory::createControl( const QString& controlType ) { return dyncontrol_ptr( new EchonestControl( controlType, typeSelectors() ) ); } + QStringList EchonestFactory::typeSelectors() const { @@ -52,6 +59,7 @@ EchonestFactory::typeSelectors() const << "Longitude" << "Latitude" << "Mode" << "Key" << "Sorting"; } + EchonestGenerator::EchonestGenerator ( QObject* parent ) : GeneratorInterface ( parent ) , m_dynPlaylist( new Echonest::DynamicPlaylist() ) @@ -73,11 +81,13 @@ EchonestGenerator::EchonestGenerator ( QObject* parent ) // qDebug() << "ECHONEST:" << m_logo.size(); } + EchonestGenerator::~EchonestGenerator() { delete m_dynPlaylist; } + dyncontrol_ptr EchonestGenerator::createControl( const QString& type ) { @@ -85,6 +95,7 @@ EchonestGenerator::createControl( const QString& type ) return m_controls.last(); } + QPixmap EchonestGenerator::logo() { return m_logo; @@ -112,6 +123,7 @@ EchonestGenerator::generate( int number ) } } + void EchonestGenerator::startOnDemand() { @@ -124,6 +136,7 @@ EchonestGenerator::startOnDemand() } } + void EchonestGenerator::doGenerate( const Echonest::DynamicPlaylist::PlaylistParams& paramsIn ) { @@ -139,6 +152,7 @@ EchonestGenerator::doGenerate( const Echonest::DynamicPlaylist::PlaylistParams& connect( reply, SIGNAL( finished() ), this, SLOT( staticFinished() ) ); } + void EchonestGenerator::doStartOnDemand( const Echonest::DynamicPlaylist::PlaylistParams& params ) { @@ -199,6 +213,7 @@ EchonestGenerator::staticFinished() emit generated( queries ); } + void EchonestGenerator::getParams() throw( std::runtime_error ) { @@ -241,6 +256,7 @@ EchonestGenerator::getParams() throw( std::runtime_error ) } } + void EchonestGenerator::songLookupFinished() { @@ -295,6 +311,7 @@ EchonestGenerator::dynamicStarted() } } + void EchonestGenerator::dynamicFetched() { @@ -318,6 +335,7 @@ EchonestGenerator::dynamicFetched() } } + void EchonestGenerator::steerDescription( const QString& desc ) { @@ -326,6 +344,7 @@ EchonestGenerator::steerDescription( const QString& desc ) m_steerData.second = desc; } + void EchonestGenerator::steerField( const QString& field ) { @@ -334,6 +353,7 @@ EchonestGenerator::steerField( const QString& field ) m_steerData.second = field; } + void EchonestGenerator::resetSteering() { @@ -365,6 +385,7 @@ EchonestGenerator::onlyThisArtistType( Echonest::DynamicPlaylist::ArtistTypeEnum return false; } + Echonest::DynamicPlaylist::ArtistTypeEnum EchonestGenerator::appendRadioType( Echonest::DynamicPlaylist::PlaylistParams& params ) const throw( std::runtime_error ) { @@ -392,13 +413,15 @@ EchonestGenerator::appendRadioType( Echonest::DynamicPlaylist::PlaylistParams& p return static_cast< Echonest::DynamicPlaylist::ArtistTypeEnum >( params.last().second.toInt() ); } + query_ptr -EchonestGenerator::queryFromSong(const Echonest::Song& song) +EchonestGenerator::queryFromSong( const Echonest::Song& song ) { // track[ "album" ] = song.release(); // TODO should we include it? can be quite specific return Query::get( song.artistName(), song.title(), QString(), uuid() ); } + QWidget* EchonestGenerator::steeringWidget() { @@ -517,12 +540,14 @@ EchonestGenerator::sentenceSummary() return sentence; } + QVector< QString > EchonestGenerator::moods() { return s_moods; } + void EchonestGenerator::moodsReceived() { @@ -537,12 +562,14 @@ EchonestGenerator::moodsReceived() s_moodsJob = 0; } + QVector< QString > EchonestGenerator::styles() { return s_styles; } + void EchonestGenerator::stylesReceived() { diff --git a/src/libtomahawk/playlist/dynamic/echonest/EchonestSteerer.cpp b/src/libtomahawk/playlist/dynamic/echonest/EchonestSteerer.cpp index f8f36a34a..1678a1fbe 100644 --- a/src/libtomahawk/playlist/dynamic/echonest/EchonestSteerer.cpp +++ b/src/libtomahawk/playlist/dynamic/echonest/EchonestSteerer.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,23 +18,26 @@ #include "dynamic/echonest/EchonestSteerer.h" -#include "utils/tomahawkutils.h" - #include #include #include #include #include -#include #include #include -#include #include +#include +#include + +#include "utils/tomahawkutils.h" +#include "utils/logger.h" + using namespace Tomahawk; #define ANIM_DURATION 300 + EchonestSteerer::EchonestSteerer( QWidget* parent ) : QWidget( parent ) , m_layout( new QHBoxLayout ) @@ -46,10 +49,10 @@ EchonestSteerer::EchonestSteerer( QWidget* parent ) , m_steerBottom( 0 ) , m_reset( 0 ) , m_expanding( true ) - + { m_layout->setContentsMargins( 8, 8, 8, 8 ); - + m_textL->setSpacing( 0 ); m_steerTop = new QLabel( tr( "Steer this station:" ), this ); QFont f = m_steerTop->font(); @@ -61,9 +64,9 @@ EchonestSteerer::EchonestSteerer( QWidget* parent ) f.setPointSize( f.pointSize() - 3 ); m_steerBottom->setFont( f ); m_textL->addWidget( m_steerBottom ); - + m_layout->addLayout( m_textL, 1 ); - + m_amplifier = new QComboBox( this ); m_amplifier->addItem( tr( "Much less" ), "^.1" ); m_amplifier->addItem( tr( "Less" ), "^.5" ); @@ -84,34 +87,34 @@ EchonestSteerer::EchonestSteerer( QWidget* parent ) m_field->addItem( tr( "By Description" ), "desc"); m_layout->addWidget( m_amplifier ); m_layout->addWidget( m_field ); - + connect( m_amplifier, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changed() ) ); connect( m_field, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changed() ) ); - + m_description = new QLineEdit( this ); m_description->setPlaceholderText( tr( "Enter a description" ) ); m_description->hide(); - + connect( m_description, SIGNAL( textChanged( QString ) ), this, SLOT( changed() ) ); - + m_reset = initButton( this ); m_reset->setIcon( QIcon( RESPATH "images/view-refresh.png" ) ); m_reset->setToolTip( tr( "Reset all steering commands" ) ); m_layout->addWidget( m_reset ); - + connect( m_reset, SIGNAL( clicked( bool ) ), this, SLOT( resetSteering( bool ) ) ); - + setLayout( m_layout ); setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); - + m_resizeAnim.setDuration( ANIM_DURATION ); m_resizeAnim.setEasingCurve( QEasingCurve::InOutQuad ); m_resizeAnim.setDirection( QTimeLine::Forward ); m_resizeAnim.setUpdateInterval( 8 ); - + connect( &m_resizeAnim, SIGNAL( frameChanged( int ) ), this, SLOT( resizeFrame( int ) ) ); - - + + m_fadeAnim = new QPropertyAnimation( this, "opacity", this ); m_fadeAnim->setDuration( ANIM_DURATION ); m_fadeAnim->setStartValue( 0 ); @@ -119,17 +122,19 @@ EchonestSteerer::EchonestSteerer( QWidget* parent ) resize( sizeHint() ); } -void + +void EchonestSteerer::paintEvent( QPaintEvent* ) { QPainter p( this ); QRect r = contentsRect(); QPalette pal = palette(); - + DynamicWidget::paintRoundedFilledRect( p, pal, r, m_opacity ); } -void + +void EchonestSteerer::setOpacity( qreal opacity ) { m_opacity = opacity; @@ -138,16 +143,18 @@ EchonestSteerer::setOpacity( qreal opacity ) repaint(); } -void + +void EchonestSteerer::fadeIn() { m_fadeAnim->setDirection( QAbstractAnimation::Forward ); m_fadeAnim->start(); - + show(); } -void + +void EchonestSteerer::fadeOut() { m_fadeAnim->setDirection( QAbstractAnimation::Backward ); @@ -155,35 +162,35 @@ EchonestSteerer::fadeOut() } -void +void EchonestSteerer::changed() { bool keep = false; if( m_amplifier->itemData( m_amplifier->currentIndex() ).toString().isEmpty() ) { // Keep Current keep = true; - + emit reset(); } - + if( m_field->itemData( m_field->currentIndex() ).toString() != "desc" ) { if( !keep ) { QString steer = m_field->itemData( m_field->currentIndex() ).toString() + m_amplifier->itemData( m_amplifier->currentIndex() ).toString(); emit steerField( steer ); } - + // if description was shown, animate to shrink if( m_layout->indexOf( m_description ) > 0 ) { m_expanding = false; int start = width(); int end = start - m_layout->spacing() - m_description->sizeHint().width();; - + m_layout->removeWidget( m_description ); m_description->hide(); m_layout->setStretchFactor( m_textL, 1 ); - + m_resizeAnim.setFrameRange( start, end ); m_resizeAnim.start(); - + qDebug() << "COLLAPSING FROM" << start << "TO" << end; } } else { // description, so put in the description field @@ -191,39 +198,41 @@ EchonestSteerer::changed() QString steer = m_description->text() + m_amplifier->itemData( m_amplifier->currentIndex() ).toString(); emit steerDescription( steer ); } - + if( m_layout->indexOf( m_description ) == -1 ) { // animate to expand m_layout->insertWidget( m_layout->count() - 1, m_description, 1 ); m_layout->setStretchFactor( m_textL, 0 ); m_description->show(); - + m_expanding = true; int start = width(); int end = start + m_layout->spacing() + m_description->sizeHint().width(); m_resizeAnim.setFrameRange( start, end ); m_resizeAnim.start(); - + qDebug() << "EXPANDING FROM" << start << "TO" << end; } } } -void + +void EchonestSteerer::resizeFrame( int width ) { // qDebug() << "RESIZING TO:" << width; resize( width, sizeHint().height() ); repaint(); - + emit resized(); } -void + +void EchonestSteerer::resetSteering( bool automatic ) { m_amplifier->setCurrentIndex( 3 ); - + if( !automatic ) { m_description->clear(); m_field->setCurrentIndex( 0 ); @@ -232,7 +241,7 @@ EchonestSteerer::resetSteering( bool automatic ) } -QToolButton* +QToolButton* EchonestSteerer::initButton( QWidget* parent ) { QToolButton* btn = new QToolButton( parent ); diff --git a/src/libtomahawk/playlist/dynamic/widgets/CollapsibleControls.cpp b/src/libtomahawk/playlist/dynamic/widgets/CollapsibleControls.cpp index 65ac1564b..7c4fc1640 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/CollapsibleControls.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/CollapsibleControls.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -34,8 +34,11 @@ #include #include +#include "utils/logger.h" + using namespace Tomahawk; + CollapsibleControls::CollapsibleControls( QWidget* parent ) : QWidget( parent ) , m_isLocal( true ) @@ -43,6 +46,7 @@ CollapsibleControls::CollapsibleControls( QWidget* parent ) init(); } + CollapsibleControls::CollapsibleControls( const dynplaylist_ptr& playlist, bool isLocal, QWidget* parent ) : QWidget( parent ) , m_dynplaylist( playlist ) @@ -52,31 +56,33 @@ CollapsibleControls::CollapsibleControls( const dynplaylist_ptr& playlist, bool setControls( m_dynplaylist, m_isLocal ); } + Tomahawk::CollapsibleControls::~CollapsibleControls() { } -void + +void CollapsibleControls::init() { m_timeline = new QTimeLine( 250, this ); m_timeline->setUpdateInterval( 5 ); m_animHeight = -1; m_collapseAnimation = false; - + connect( m_timeline, SIGNAL( frameChanged( int ) ), this, SLOT( onAnimationStep( int ) ) ); connect( m_timeline, SIGNAL( finished() ), this, SLOT( onAnimationFinished() ) ); - + m_layout = new QStackedLayout; setContentsMargins( 0, 0, 0, 0 ); m_layout->setContentsMargins( 0, 0, 0, 0 ); m_layout->setSpacing( 0 ); - + m_controls = new Tomahawk::DynamicControlList( this ); m_layout->addWidget( m_controls ); connect( m_controls, SIGNAL( toggleCollapse() ), this, SLOT( toggleCollapse() ) ); - + m_summaryWidget = new QWidget( this ); m_summaryWidget->setMinimumHeight( 24 ); m_summaryWidget->setMaximumHeight( 24 ); @@ -85,7 +91,7 @@ CollapsibleControls::init() m_summaryWidget->setLayout( m_summaryLayout ); m_summaryLayout->setMargin( 0 ); m_summaryWidget->setContentsMargins( 3, 0, 0, 0 ); - + m_summary = new ElidedLabel( m_summaryWidget ); QFont f = m_summary->font(); f.setPointSize( f.pointSize() + 1 ); @@ -104,37 +110,38 @@ CollapsibleControls::init() m_expandL->setCurrentIndex( 0 ); else m_expandL->setCurrentIndex( 1 ); - + m_layout->addWidget( m_summaryWidget ); connect( m_summaryExpand, SIGNAL( clicked( bool ) ), this, SLOT( toggleCollapse() ) ); - + if( m_isLocal ) m_layout->setCurrentWidget( m_controls ); else m_layout->setCurrentWidget( m_summary ); - + connect( m_controls, SIGNAL( controlChanged( Tomahawk::dyncontrol_ptr ) ), SIGNAL( controlChanged( Tomahawk::dyncontrol_ptr ) ) ); connect( m_controls, SIGNAL( controlsChanged() ), SIGNAL( controlsChanged() ) ); - + setLayout( m_layout ); - + setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); } -QList< DynamicControlWrapper* > +QList< DynamicControlWrapper* > Tomahawk::CollapsibleControls::controls() const { return m_controls->controls(); } -void + +void CollapsibleControls::setControls( const dynplaylist_ptr& playlist, bool isLocal ) { m_dynplaylist = playlist; m_isLocal = isLocal; m_controls->setControls( m_dynplaylist->generator(), m_dynplaylist->generator()->controls() ); - + if( !m_isLocal ) { m_expandL->setCurrentIndex( 1 ); m_summary->setText( m_dynplaylist->generator()->sentenceSummary() ); @@ -145,7 +152,8 @@ CollapsibleControls::setControls( const dynplaylist_ptr& playlist, bool isLocal } } -void + +void CollapsibleControls::toggleCollapse() { // qDebug() << "TOGGLING SIZEHINTS:" << m_controls->height() << m_summaryWidget->sizeHint(); @@ -154,23 +162,24 @@ CollapsibleControls::toggleCollapse() if( m_layout->currentWidget() == m_controls ) { m_summary->setText( m_dynplaylist->generator()->sentenceSummary() ); m_controls->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored ); - + m_timeline->setDirection( QTimeLine::Backward ); m_timeline->start(); - + m_collapseAnimation = true; } else { m_summaryWidget->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored ); m_layout->setCurrentWidget( m_controls ); - + m_timeline->setDirection( QTimeLine::Forward ); m_timeline->start(); - + m_collapseAnimation = false; } } -void + +void CollapsibleControls::onAnimationStep( int step ) { // qDebug() << "ANIMATION STEP:" << step; @@ -179,13 +188,14 @@ CollapsibleControls::onAnimationStep( int step ) setMaximumHeight( m_animHeight ); } -void + +void CollapsibleControls::onAnimationFinished() { // qDebug() << "ANIMATION DONE:" << m_animHeight; setMaximumHeight( m_animHeight ); m_animHeight = -1; - + if( m_collapseAnimation ) { m_layout->setCurrentWidget( m_summaryWidget ); } else { @@ -193,7 +203,9 @@ CollapsibleControls::onAnimationFinished() } } -QSize CollapsibleControls::sizeHint() const + +QSize +CollapsibleControls::sizeHint() const { if( m_animHeight >= 0 ) { return QSize( QWidget::sizeHint().width(), m_animHeight ); diff --git a/src/libtomahawk/playlist/dynamic/widgets/DynamicControlList.cpp b/src/libtomahawk/playlist/dynamic/widgets/DynamicControlList.cpp index e041c38ae..b074d07fa 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/DynamicControlList.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/DynamicControlList.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -30,9 +30,11 @@ #include "DynamicControlWrapper.h" #include "dynamic/GeneratorInterface.h" #include "utils/tomahawkutils.h" +#include "utils/logger.h" using namespace Tomahawk; + DynamicControlList::DynamicControlList( QWidget* parent ) : QWidget( parent ) , m_layout( new QGridLayout ) @@ -40,6 +42,7 @@ DynamicControlList::DynamicControlList( QWidget* parent ) init(); } + DynamicControlList::DynamicControlList( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, QWidget* parent ) : QWidget( parent ) , m_generator( generator ) @@ -49,12 +52,14 @@ DynamicControlList::DynamicControlList( const geninterface_ptr& generator, const setControls( generator, controls ); } + DynamicControlList::~DynamicControlList() { } -void + +void DynamicControlList::init() { qDebug() << "GRIDLAYOUT: " << m_layout->rowCount(); @@ -69,7 +74,7 @@ DynamicControlList::init() m_layout->setContentsMargins( 0, 0, 0, 0 ); #endif m_layout->setSizeConstraint( QLayout::SetMinimumSize ); - + m_collapseLayout = new QHBoxLayout(); m_collapseLayout->setContentsMargins( 0, 0, 0, 0 ); m_collapseLayout->setMargin( 0 ); @@ -87,14 +92,15 @@ DynamicControlList::init() m_addControl->setContentsMargins( 0, 0, 0, 0 ); m_collapseLayout->addWidget( m_addControl ); m_collapse->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); - + connect( m_collapse, SIGNAL( clicked() ), this, SIGNAL( toggleCollapse() ) ); connect( m_addControl, SIGNAL( clicked() ), this, SLOT( addNewControl() ) ); - + setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); } -void + +void DynamicControlList::setControls( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls ) { if( m_controls.size() == controls.size() && controls.size() > 0 ) { // check if we're setting the same controls we already have, and exit if we are @@ -109,14 +115,14 @@ DynamicControlList::setControls( const geninterface_ptr& generator, const QList< return; } } - + if( !m_controls.isEmpty() ) { qDeleteAll( m_controls ); m_controls.clear(); } - + m_layout->removeItem( m_collapseLayout ); - + m_generator = generator; if( controls.isEmpty() ) { qDebug() << "CREATING DEFAULT CONTROL"; @@ -124,50 +130,56 @@ DynamicControlList::setControls( const geninterface_ptr& generator, const QList< connect( ctrlW, SIGNAL( removeControl() ), this, SLOT( removeControl() ) ); connect( ctrlW, SIGNAL( changed() ), this, SLOT( controlChanged() ) ); m_controls << ctrlW; - } else + } else { foreach( const dyncontrol_ptr& control, controls ) { DynamicControlWrapper* ctrlW = new DynamicControlWrapper( control, m_layout, m_controls.size(), this ); connect( ctrlW, SIGNAL( removeControl() ), this, SLOT( removeControl() ) ); connect( ctrlW, SIGNAL( changed() ), this, SLOT( controlChanged() ) ); - + m_controls << ctrlW; } } m_layout->addItem( m_collapseLayout, m_layout->rowCount(), 0, 1, 4, Qt::AlignCenter ); - + } -void DynamicControlList::addNewControl() + +void +DynamicControlList::addNewControl() { m_layout->removeItem( m_collapseLayout ); - + dyncontrol_ptr control = m_generator->createControl(); m_controls.append( new DynamicControlWrapper( control, m_layout, m_layout->rowCount(), this ) ); connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) ); connect( m_controls.last(), SIGNAL( changed() ), this, SLOT( controlChanged() ) ); - + m_layout->addItem( m_collapseLayout, m_layout->rowCount(), 0, 1, 4, Qt::AlignCenter ); emit controlsChanged(); } -void DynamicControlList::removeControl() + +void +DynamicControlList::removeControl() { DynamicControlWrapper* w = qobject_cast( sender() ); w->removeFromLayout(); m_controls.removeAll( w ); - + m_generator->removeControl( w->control() ); delete w; - + emit controlsChanged(); } -void DynamicControlList::controlChanged() + +void +DynamicControlList::controlChanged() { Q_ASSERT( sender() && qobject_cast(sender()) ); DynamicControlWrapper* widget = qobject_cast(sender()); - + qDebug() << "control changed!"; foreach( DynamicControlWrapper* c, m_controls ) qDebug() << c->control()->id() << c->control()->selectedType() << c->control()->match() << c->control()->input(); diff --git a/src/libtomahawk/playlist/dynamic/widgets/DynamicControlWrapper.cpp b/src/libtomahawk/playlist/dynamic/widgets/DynamicControlWrapper.cpp index 79fb4e87c..e62d3a170 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/DynamicControlWrapper.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/DynamicControlWrapper.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,20 +18,21 @@ #include "DynamicControlWrapper.h" -#include "dynamic/DynamicControl.h" -#include "utils/tomahawkutils.h" - -#include #include #include #include #include #include #include -#include +#include + +#include "dynamic/DynamicControl.h" +#include "utils/tomahawkutils.h" +#include "utils/logger.h" using namespace Tomahawk; + DynamicControlWrapper::DynamicControlWrapper( const Tomahawk::dyncontrol_ptr& control, QGridLayout* layout, int row, QWidget* parent ) : QObject( parent ) , m_parent( parent ) @@ -42,67 +43,69 @@ DynamicControlWrapper::DynamicControlWrapper( const Tomahawk::dyncontrol_ptr& co , m_layout( QWeakPointer< QGridLayout >( layout ) ) { qDebug() << "CREATING DYNAMIC CONTROL WRAPPER WITH ROW:" << row << layout; - + m_typeSelector = new QComboBox( m_parent ); - + m_matchSelector = QWeakPointer( control->matchSelector() ); m_entryWidget = QWeakPointer( control->inputField() ); - + m_minusButton = initButton( m_parent ); m_minusButton->setIcon( QIcon( RESPATH "images/list-remove.png" ) ); connect( m_minusButton, SIGNAL( clicked( bool ) ), this, SIGNAL( removeControl() ) ); - - + m_plusL = new QStackedLayout(); m_plusL->setContentsMargins( 0, 0, 0, 0 ); m_plusL->setMargin( 0 ); m_plusL->addWidget( m_minusButton ); m_plusL->addWidget( createDummy( m_minusButton, m_parent ) ); // :-( - - connect( m_typeSelector, SIGNAL( activated( QString) ), SLOT( typeSelectorChanged( QString ) ) ); + + connect( m_typeSelector, SIGNAL( activated( QString) ), SLOT( typeSelectorChanged( QString ) ) ); connect( m_control.data(), SIGNAL( changed() ), this, SIGNAL( changed() ) ); - + m_layout.data()->addWidget( m_typeSelector, row, 0, Qt::AlignLeft ); - + if( !control.isNull() ) { foreach( const QString& type, control->typeSelectors() ) m_typeSelector->addItem( type ); } - + typeSelectorChanged( m_control.isNull() ? "" : m_control->selectedType(), true ); - + m_layout.data()->addLayout( m_plusL, m_row, 3, Qt::AlignCenter ); m_plusL->setCurrentIndex( 0 ); } + DynamicControlWrapper::~DynamicControlWrapper() { // remove the controls widgets from our layout so they are not parented // we don't want to auto-delete them since the control should own them // if we delete them, then the control will be holding on to null ptrs removeFromLayout(); - + if( !m_entryWidget.isNull() ) m_control->inputField()->setParent( 0 ); if( !m_matchSelector.isNull() ) m_control->matchSelector()->setParent( 0 ); - + delete m_typeSelector; delete m_minusButton; } -dyncontrol_ptr + +dyncontrol_ptr DynamicControlWrapper::control() const { return m_control; } -void + +void DynamicControlWrapper::removeFromLayout() { if( m_layout.isNull() ) return; - + if( !m_matchSelector.isNull() ) m_layout.data()->removeWidget( m_matchSelector.data() ); if( !m_entryWidget.isNull() ) @@ -112,7 +115,7 @@ DynamicControlWrapper::removeFromLayout() } -QToolButton* +QToolButton* DynamicControlWrapper::initButton( QWidget* parent ) { QToolButton* btn = new QToolButton( parent ); @@ -125,7 +128,8 @@ DynamicControlWrapper::initButton( QWidget* parent ) return btn; } -QWidget* + +QWidget* DynamicControlWrapper::createDummy( QWidget* fromW, QWidget* parent ) { QWidget* dummy = new QWidget( parent ); @@ -138,22 +142,22 @@ DynamicControlWrapper::createDummy( QWidget* fromW, QWidget* parent ) } -void +void DynamicControlWrapper::typeSelectorChanged( const QString& type, bool firstLoad ) { Q_ASSERT( !m_layout.isNull() ); m_layout.data()->removeWidget( m_matchSelector.data() ); m_layout.data()->removeWidget( m_entryWidget.data() ); - + if( m_control->selectedType() != type && !firstLoad ) m_control->setSelectedType( type ); - - + + int idx = m_typeSelector->findText( type ); if( idx > -1 ) m_typeSelector->setCurrentIndex( idx ); - + if( m_control->matchSelector() ) { m_matchSelector = QWeakPointer( m_control->matchSelector() ); m_layout.data()->addWidget( m_matchSelector.data(), m_row, 1, Qt::AlignCenter ); @@ -164,28 +168,30 @@ DynamicControlWrapper::typeSelectorChanged( const QString& type, bool firstLoad m_layout.data()->addWidget( m_entryWidget.data(), m_row, 2 ); m_entryWidget.data()->show(); } - + emit changed(); } + + /* -void +void DynamicControlWrapper::enterEvent(QEvent* ev) { m_mouseOver = true; if( m_isLocal ) m_plusL->setCurrentIndex( 0 ); - + if( ev ) QObject::enterEvent( ev ); } -void +void DynamicControlWrapper::leaveEvent(QEvent* ev) { m_mouseOver = true; if( m_isLocal ) m_plusL->setCurrentIndex( 1 ); - + if( ev ) QWidget::leaveEvent( ev ); } diff --git a/src/libtomahawk/playlist/dynamic/widgets/DynamicSetupWidget.cpp b/src/libtomahawk/playlist/dynamic/widgets/DynamicSetupWidget.cpp index 8eec49f0a..d3c05aff3 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/DynamicSetupWidget.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/DynamicSetupWidget.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -33,6 +33,8 @@ #include #include +#include "utils/logger.h" + using namespace Tomahawk; @@ -46,19 +48,18 @@ DynamicSetupWidget::DynamicSetupWidget( const Tomahawk::dynplaylist_ptr& playlis , m_generateButton( 0 ) , m_genNumber( 0 ) { - setContentsMargins( 0, 0, 0, 0 ); m_headerText = new QLabel( tr( "Type:" ), this ); m_layout->addWidget( m_headerText ); - + QComboBox * genCombo = new QComboBox( this ); foreach( const QString& type, GeneratorFactory::types() ) genCombo->addItem( type ); m_generatorCombo = new ReadOrWriteWidget( genCombo, m_playlist->author()->isLocal(), this ); m_generatorCombo->setLabel( playlist->generator()->type().replace( 0, 1, playlist->generator()->type().at( 0 ).toUpper() ) ); - + m_layout->addWidget( m_generatorCombo ); - + m_generateButton = new QPushButton( tr( "Generate" ), this ); m_generateButton->setAttribute( Qt::WA_LayoutUsesWidgetRect ); connect( m_generateButton, SIGNAL( clicked( bool ) ), this, SLOT( generatePressed( bool ) ) ); @@ -66,8 +67,7 @@ DynamicSetupWidget::DynamicSetupWidget( const Tomahawk::dynplaylist_ptr& playlis m_generateButton->hide(); else m_layout->addWidget( m_generateButton ); - - + m_genNumber = new QSpinBox( this ); m_genNumber->setValue( 15 ); m_genNumber->setMinimum( 0 ); @@ -75,79 +75,85 @@ DynamicSetupWidget::DynamicSetupWidget( const Tomahawk::dynplaylist_ptr& playlis m_genNumber->hide(); else m_layout->addWidget( m_genNumber ); - + m_layout->addSpacing( 30 ); - + m_logo = new QLabel( this ); if( !m_playlist->generator()->logo().isNull() ) { QPixmap p = m_playlist->generator()->logo().scaledToHeight( 22, Qt::SmoothTransformation ); m_logo->setPixmap( p ); } m_layout->addWidget(m_logo); - + setLayout( m_layout ); - + m_fadeAnim = new QPropertyAnimation( this, "opacity" ); m_fadeAnim->setDuration( 250 ); m_fadeAnim->setStartValue( 0.00 ); m_fadeAnim->setEndValue( .86 ); - + setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); resize( sizeHint() ); } + DynamicSetupWidget::~DynamicSetupWidget() { } -void + +void DynamicSetupWidget::setPlaylist( const Tomahawk::dynplaylist_ptr& playlist ) { Q_UNUSED( playlist ); } -void + +void DynamicSetupWidget::fadeIn() { m_fadeAnim->setDirection( QAbstractAnimation::Forward ); m_fadeAnim->start(); - + show(); } -void + +void DynamicSetupWidget::fadeOut() { - m_fadeAnim->setDirection( QAbstractAnimation::Backward ); + m_fadeAnim->setDirection( QAbstractAnimation::Backward ); m_fadeAnim->start(); - + } -void + +void DynamicSetupWidget::generatePressed( bool ) { emit generatePressed( m_genNumber->value() ); } -void +void DynamicSetupWidget::setOpacity( qreal opacity ) { m_opacity = opacity; - + if( m_opacity == 0 ) hide(); repaint(); } -void + +void DynamicSetupWidget::paintEvent( QPaintEvent* e ) { QPainter p( this ); QRect r = contentsRect(); QPalette pal = palette(); - + DynamicWidget::paintRoundedFilledRect( p, pal, r, m_opacity ); - + QWidget::paintEvent( e ); } diff --git a/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp b/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp index b0e4048f4..f3248eccc 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include "DynamicControlList.h" #include "dynamic/DynamicModel.h" @@ -36,17 +38,16 @@ #include "DynamicControlWrapper.h" #include "viewmanager.h" #include "dynamic/DynamicView.h" -#include #include "DynamicSetupWidget.h" -#include - #include "audiocontrols.h" #include "LoadingSpinner.h" +#include "utils/logger.h" using namespace Tomahawk; + DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget* parent ) - : QWidget(parent) + : QWidget( parent ) , m_layout( new QVBoxLayout ) , m_resolveOnNextLoad( false ) , m_seqRevLaunched( 0 ) @@ -99,10 +100,12 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistChanged( Tomahawk::PlaylistInterface* ) ) ); } + DynamicWidget::~DynamicWidget() { } + void DynamicWidget::loadDynamicPlaylist( const Tomahawk::dynplaylist_ptr& playlist ) { @@ -183,12 +186,14 @@ DynamicWidget::onRevisionLoaded( const Tomahawk::DynamicPlaylistRevision& rev ) } } + PlaylistInterface* DynamicWidget::playlistInterface() const { return m_view->proxyModel(); } + QSize DynamicWidget::sizeHint() const { @@ -197,12 +202,14 @@ DynamicWidget::sizeHint() const return QSize( 5000, 5000 ); } + void DynamicWidget::resizeEvent(QResizeEvent* ) { layoutFloatingWidgets(); } + void DynamicWidget::layoutFloatingWidgets() { @@ -219,6 +226,7 @@ DynamicWidget::layoutFloatingWidgets() } } + void DynamicWidget::playlistChanged( PlaylistInterface* pl ) { @@ -234,6 +242,7 @@ DynamicWidget::playlistChanged( PlaylistInterface* pl ) } } + void DynamicWidget::showEvent(QShowEvent* ) { @@ -252,6 +261,7 @@ DynamicWidget::generate( int num ) m_playlist->generator()->generate( num ); } + void DynamicWidget::stationFailed( const QString& msg ) { @@ -262,6 +272,7 @@ DynamicWidget::stationFailed( const QString& msg ) stopStation( false ); } + void DynamicWidget::trackStarted() { @@ -272,6 +283,7 @@ DynamicWidget::trackStarted() } } + void DynamicWidget::tracksAdded() { @@ -291,6 +303,7 @@ DynamicWidget::stopStation( bool stopPlaying ) m_setup->fadeIn(); } + void DynamicWidget::startStation() { @@ -317,12 +330,14 @@ DynamicWidget::startStation() } } + void DynamicWidget::playlistTypeChanged( QString ) { // TODO } + void DynamicWidget::tracksGenerated( const QList< query_ptr >& queries ) { @@ -354,6 +369,7 @@ DynamicWidget::controlsChanged() emit descriptionChanged( m_playlist->generator()->sentenceSummary() ); } + void DynamicWidget::controlChanged( const Tomahawk::dyncontrol_ptr& control ) { @@ -368,6 +384,7 @@ DynamicWidget::controlChanged( const Tomahawk::dyncontrol_ptr& control ) emit descriptionChanged( m_playlist->generator()->sentenceSummary() ); } + void DynamicWidget::showPreview() { @@ -388,6 +405,7 @@ DynamicWidget::generatorError( const QString& title, const QString& content ) m_view->showMessageTimeout( title, content ); } + void DynamicWidget::paintRoundedFilledRect( QPainter& p, QPalette& pal, QRect& r, qreal opacity ) { @@ -407,6 +425,7 @@ DynamicWidget::paintRoundedFilledRect( QPainter& p, QPalette& pal, QRect& r, qre p.drawRoundedRect( r, 10, 10 ); } + bool DynamicWidget::jumpToCurrentTrack() { @@ -414,6 +433,7 @@ DynamicWidget::jumpToCurrentTrack() return true; } + void DynamicWidget::onDeleted() { @@ -421,6 +441,7 @@ DynamicWidget::onDeleted() deleteLater(); } + void DynamicWidget::onChanged() { diff --git a/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.cpp b/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.cpp index e1a5d91a8..15005537b 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/LoadingSpinner.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -21,15 +21,17 @@ #include #include #include -#include +#include #include #include "utils/tomahawkutils.h" +#include "utils/logger.h" #define ANIM_LENGTH 300 + LoadingSpinner::LoadingSpinner( QWidget* parent ) - : QWidget(parent) + : QWidget( parent ) , m_showHide( new QTimeLine ) { m_showHide->setDuration( 300 ); @@ -38,21 +40,23 @@ LoadingSpinner::LoadingSpinner( QWidget* parent ) m_showHide->setUpdateInterval( 20 ); connect( m_showHide, SIGNAL( frameChanged( int ) ), this, SLOT( update() ) ); connect( m_showHide, SIGNAL( finished() ), this, SLOT( hideFinished() ) ); - + m_anim = new QMovie( RESPATH "/images/loading-animation.gif" ); - + connect( m_anim, SIGNAL( frameChanged( int ) ), this, SLOT( update() ) ); - + setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); hide(); } + LoadingSpinner::~LoadingSpinner() { } -void + +void LoadingSpinner::fadeIn() { show(); @@ -61,7 +65,8 @@ LoadingSpinner::fadeIn() m_showHide->start(); } -void + +void LoadingSpinner::fadeOut() { m_showHide->setDirection( QTimeLine::Backward ); @@ -71,7 +76,8 @@ LoadingSpinner::fadeOut() m_showHide->start(); } -void + +void LoadingSpinner::hideFinished() { if( m_showHide->direction() == QTimeLine::Backward ) { @@ -81,24 +87,26 @@ LoadingSpinner::hideFinished() } -QSize +QSize LoadingSpinner::sizeHint() const { return QSize( 31, 31 ); } -void + +void LoadingSpinner::resizeEvent( QResizeEvent* ) { reposition(); } -void + +void LoadingSpinner::reposition() { if( !parentWidget() ) return; - + int x = ( parentWidget()->width() / 2 ) - ( width() / 2 ); int y = ( parentWidget()->height() / 2 ) - ( height() / 2 ); move( x, y ); @@ -106,18 +114,17 @@ LoadingSpinner::reposition() } -void +void LoadingSpinner::paintEvent( QPaintEvent* ev ) { Q_UNUSED( ev ); QPainter p( this ); - + // qDebug() << "FADING" << ( m_showHide->state() == QTimeLine::Running ) << "at frame:" << m_showHide->currentValue(); - if( m_showHide->state() == QTimeLine::Running ) { // showing or hiding + if( m_showHide->state() == QTimeLine::Running ) + { // showing or hiding p.setOpacity( (qreal)m_showHide->currentValue() ); } - p.drawPixmap( rect(), m_anim->currentPixmap() ); - - -} + p.drawPixmap( rect(), m_anim->currentPixmap() ); +} diff --git a/src/libtomahawk/playlist/dynamic/widgets/MiscControlWidgets.cpp b/src/libtomahawk/playlist/dynamic/widgets/MiscControlWidgets.cpp index 7ac128829..da8872ff6 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/MiscControlWidgets.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/MiscControlWidgets.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -22,20 +22,23 @@ #include #include +#include "utils/logger.h" + using namespace Tomahawk; + LabeledSlider::LabeledSlider( const QString& leftT, const QString& rightT, QWidget* parent ) : QWidget( parent ) { setLayout( new QHBoxLayout ); layout()->setMargin( 0 ); - + m_leftLabel = new QLabel( leftT, this ); layout()->addWidget( m_leftLabel ); - + m_slider = new QSlider( Qt::Horizontal, this ); layout()->addWidget( m_slider ); - + m_rightLabel = new QLabel( rightT, this ); layout()->addWidget( m_rightLabel ); } diff --git a/src/libtomahawk/playlist/dynamic/widgets/ReadOrWriteWidget.cpp b/src/libtomahawk/playlist/dynamic/widgets/ReadOrWriteWidget.cpp index 2e3da1aad..3685822bb 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/ReadOrWriteWidget.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/ReadOrWriteWidget.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -20,7 +20,9 @@ #include #include -#include + +#include "utils/logger.h" + ReadOrWriteWidget::ReadOrWriteWidget( QWidget* writableWidget, bool writable, QWidget* parent) : QWidget( parent ) @@ -30,22 +32,23 @@ ReadOrWriteWidget::ReadOrWriteWidget( QWidget* writableWidget, bool writable, QW , m_writable( writable ) { m_label = new QLabel( QString(), this ); - + m_layout = new QStackedLayout( this ); if( writableWidget ) m_layout->addWidget( writableWidget ); - + m_layout->addWidget( m_label ); - + setWritable( m_writable ); - + setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); setContentsMargins( 0, 0, 0, 0 ); m_layout->setContentsMargins( 0, 0, 0, 0 ); m_layout->setSpacing( 0 ); } -void + +void ReadOrWriteWidget::setWritable( bool write ) { m_writable = write; @@ -55,42 +58,49 @@ ReadOrWriteWidget::setWritable( bool write ) m_layout->setCurrentWidget( m_label ); } -void + +void ReadOrWriteWidget::setWritableWidget( QWidget* w ) { if( m_writableWidget ) { m_layout->removeWidget( m_writableWidget ); } - + m_writableWidget = w; m_layout->insertWidget( 0, m_writableWidget ); } -bool + +bool ReadOrWriteWidget::writable() const { return m_writable; } -QWidget* + +QWidget* ReadOrWriteWidget::writableWidget() const { return m_writableWidget; } -QString + +QString ReadOrWriteWidget::label() const { return m_label->text(); } -void + +void ReadOrWriteWidget::setLabel( const QString& label ) { m_label->setText( label ); } -QSize ReadOrWriteWidget::sizeHint() const + +QSize +ReadOrWriteWidget::sizeHint() const { if( m_writableWidget ) { return m_writableWidget->sizeHint(); diff --git a/src/libtomahawk/playlist/infobar/infobar.cpp b/src/libtomahawk/playlist/infobar/infobar.cpp index 8edc51b20..d4e10e827 100644 --- a/src/libtomahawk/playlist/infobar/infobar.cpp +++ b/src/libtomahawk/playlist/infobar/infobar.cpp @@ -24,6 +24,7 @@ #include #include "utils/tomahawkutils.h" +#include "utils/logger.h" #define IMAGE_HEIGHT 64 diff --git a/src/libtomahawk/playlist/playlistitemdelegate.cpp b/src/libtomahawk/playlist/playlistitemdelegate.cpp index ac2336b3c..63efdc34f 100644 --- a/src/libtomahawk/playlist/playlistitemdelegate.cpp +++ b/src/libtomahawk/playlist/playlistitemdelegate.cpp @@ -19,7 +19,6 @@ #include "playlistitemdelegate.h" #include -#include #include #include "query.h" @@ -34,6 +33,7 @@ #include "trackheader.h" #include "utils/tomahawkutils.h" +#include "utils/logger.h" #define PLAYING_ICON QString( RESPATH "images/now-playing-speaker.png" ) #define ARROW_ICON QString( RESPATH "images/forward.png" ) diff --git a/src/libtomahawk/playlist/playlistmodel.cpp b/src/libtomahawk/playlist/playlistmodel.cpp index e7c712591..121ef9f82 100644 --- a/src/libtomahawk/playlist/playlistmodel.cpp +++ b/src/libtomahawk/playlist/playlistmodel.cpp @@ -18,7 +18,6 @@ #include "playlistmodel.h" -#include #include #include @@ -27,6 +26,7 @@ #include "database/database.h" #include "database/databasecommand_playbackhistory.h" #include "dynamic/GeneratorInterface.h" +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/playlist/playlistproxymodel.cpp b/src/libtomahawk/playlist/playlistproxymodel.cpp index 272721234..45c234980 100644 --- a/src/libtomahawk/playlist/playlistproxymodel.cpp +++ b/src/libtomahawk/playlist/playlistproxymodel.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,6 +18,8 @@ #include "playlistproxymodel.h" +#include "utils/logger.h" + PlaylistProxyModel::PlaylistProxyModel( QObject* parent ) : TrackProxyModel( parent ) diff --git a/src/libtomahawk/playlist/playlistview.cpp b/src/libtomahawk/playlist/playlistview.cpp index 5a8ce4a9f..06a496d4f 100644 --- a/src/libtomahawk/playlist/playlistview.cpp +++ b/src/libtomahawk/playlist/playlistview.cpp @@ -18,13 +18,13 @@ #include "playlistview.h" -#include #include #include #include "playlist/playlistproxymodel.h" #include "widgets/overlaywidget.h" #include "viewmanager.h" +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/playlist/queueproxymodel.cpp b/src/libtomahawk/playlist/queueproxymodel.cpp index 8fbff81b9..9685d4744 100644 --- a/src/libtomahawk/playlist/queueproxymodel.cpp +++ b/src/libtomahawk/playlist/queueproxymodel.cpp @@ -18,9 +18,8 @@ #include "queueproxymodel.h" -#include - #include "viewmanager.h" +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/playlist/queueview.cpp b/src/libtomahawk/playlist/queueview.cpp index d361b7342..1f2893c5e 100644 --- a/src/libtomahawk/playlist/queueview.cpp +++ b/src/libtomahawk/playlist/queueview.cpp @@ -18,11 +18,11 @@ #include "queueview.h" -#include #include #include "playlist/queueproxymodel.h" #include "widgets/overlaywidget.h" +#include "utils/logger.h" #ifdef Q_WS_MAC #define MINIMUM_HEIGHT 38 diff --git a/src/libtomahawk/playlist/topbar/lineedit.cpp b/src/libtomahawk/playlist/topbar/lineedit.cpp index 9070986a2..4df64a56c 100644 --- a/src/libtomahawk/playlist/topbar/lineedit.cpp +++ b/src/libtomahawk/playlist/topbar/lineedit.cpp @@ -34,8 +34,6 @@ #include #include -#include - SideWidget::SideWidget(QWidget *parent) : QWidget(parent) { diff --git a/src/libtomahawk/playlist/topbar/topbar.cpp b/src/libtomahawk/playlist/topbar/topbar.cpp index 2504fe1dc..97dfbb4d4 100644 --- a/src/libtomahawk/playlist/topbar/topbar.cpp +++ b/src/libtomahawk/playlist/topbar/topbar.cpp @@ -24,6 +24,7 @@ #include #include "utils/tomahawkutils.h" +#include "utils/logger.h" #define MAXDUDES 3 #define DUDEWIDTH 10 diff --git a/src/libtomahawk/playlist/trackheader.cpp b/src/libtomahawk/playlist/trackheader.cpp index 10a2c239c..cfaf0801e 100644 --- a/src/libtomahawk/playlist/trackheader.cpp +++ b/src/libtomahawk/playlist/trackheader.cpp @@ -19,12 +19,12 @@ #include "trackheader.h" #include -#include #include #include "tomahawksettings.h" #include "playlist/trackmodel.h" #include "playlist/trackview.h" +#include "utils/logger.h" TrackHeader::TrackHeader( TrackView* parent ) diff --git a/src/libtomahawk/playlist/trackmodel.cpp b/src/libtomahawk/playlist/trackmodel.cpp index 8073d81b0..710f0ebe0 100644 --- a/src/libtomahawk/playlist/trackmodel.cpp +++ b/src/libtomahawk/playlist/trackmodel.cpp @@ -18,7 +18,6 @@ #include "trackmodel.h" -#include #include #include @@ -27,6 +26,7 @@ #include "album.h" #include "pipeline.h" +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/playlist/trackmodelitem.cpp b/src/libtomahawk/playlist/trackmodelitem.cpp index b421bb3f8..36f1883c1 100644 --- a/src/libtomahawk/playlist/trackmodelitem.cpp +++ b/src/libtomahawk/playlist/trackmodelitem.cpp @@ -18,11 +18,10 @@ #include "trackmodelitem.h" -#include "utils/tomahawkutils.h" #include "playlist.h" #include "query.h" - -#include +#include "utils/tomahawkutils.h" +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/playlist/trackproxymodel.cpp b/src/libtomahawk/playlist/trackproxymodel.cpp index abb54a01f..407b8b9d2 100644 --- a/src/libtomahawk/playlist/trackproxymodel.cpp +++ b/src/libtomahawk/playlist/trackproxymodel.cpp @@ -18,11 +18,11 @@ #include "trackproxymodel.h" -#include #include #include "album.h" #include "query.h" +#include "utils/logger.h" TrackProxyModel::TrackProxyModel( QObject* parent ) diff --git a/src/libtomahawk/playlist/trackview.cpp b/src/libtomahawk/playlist/trackview.cpp index 0746a43bd..e6c0dce12 100644 --- a/src/libtomahawk/playlist/trackview.cpp +++ b/src/libtomahawk/playlist/trackview.cpp @@ -18,16 +18,10 @@ #include "trackview.h" -#include #include #include #include -#include "audio/audioengine.h" -#include "utils/tomahawkutils.h" -#include "widgets/overlaywidget.h" -#include "dynamic/widgets/LoadingSpinner.h" - #include "trackheader.h" #include "viewmanager.h" #include "queueview.h" @@ -35,6 +29,12 @@ #include "trackproxymodel.h" #include "track.h" +#include "audio/audioengine.h" +#include "widgets/overlaywidget.h" +#include "dynamic/widgets/LoadingSpinner.h" +#include "utils/tomahawkutils.h" +#include "utils/logger.h" + using namespace Tomahawk; diff --git a/src/libtomahawk/playlist/treeheader.cpp b/src/libtomahawk/playlist/treeheader.cpp index 72bc75192..076cd3eea 100644 --- a/src/libtomahawk/playlist/treeheader.cpp +++ b/src/libtomahawk/playlist/treeheader.cpp @@ -19,12 +19,12 @@ #include "treeheader.h" #include -#include #include #include "tomahawksettings.h" #include "playlist/treemodel.h" #include "playlist/artistview.h" +#include "utils/logger.h" TreeHeader::TreeHeader( ArtistView* parent ) diff --git a/src/libtomahawk/playlist/treeitemdelegate.cpp b/src/libtomahawk/playlist/treeitemdelegate.cpp index feb67ba38..5bd0eefcb 100644 --- a/src/libtomahawk/playlist/treeitemdelegate.cpp +++ b/src/libtomahawk/playlist/treeitemdelegate.cpp @@ -19,7 +19,6 @@ #include "treeitemdelegate.h" #include -#include #include #include #include @@ -28,6 +27,7 @@ #include "result.h" #include "utils/tomahawkutils.h" +#include "utils/logger.h" #include "treemodelitem.h" #include "treeproxymodel.h" diff --git a/src/libtomahawk/playlist/treemodel.cpp b/src/libtomahawk/playlist/treemodel.cpp index 066c1a569..067013e0b 100644 --- a/src/libtomahawk/playlist/treemodel.cpp +++ b/src/libtomahawk/playlist/treemodel.cpp @@ -18,7 +18,6 @@ #include "treemodel.h" -#include #include #include #include @@ -28,6 +27,7 @@ #include "database/databasecommand_alltracks.h" #include "database/database.h" #include "utils/tomahawkutils.h" +#include "utils/logger.h" static QString s_tmInfoIdentifier = QString( "TREEMODEL" ); diff --git a/src/libtomahawk/playlist/treemodelitem.cpp b/src/libtomahawk/playlist/treemodelitem.cpp index 5406be52f..a9e07a1e3 100644 --- a/src/libtomahawk/playlist/treemodelitem.cpp +++ b/src/libtomahawk/playlist/treemodelitem.cpp @@ -19,10 +19,9 @@ #include "treemodelitem.h" #include "utils/tomahawkutils.h" +#include "utils/logger.h" #include "album.h" -#include - using namespace Tomahawk; diff --git a/src/libtomahawk/playlist/treeproxymodel.cpp b/src/libtomahawk/playlist/treeproxymodel.cpp index b1e3450b5..8b8327045 100644 --- a/src/libtomahawk/playlist/treeproxymodel.cpp +++ b/src/libtomahawk/playlist/treeproxymodel.cpp @@ -18,10 +18,10 @@ #include "treeproxymodel.h" -#include #include #include "query.h" +#include "utils/logger.h" TreeProxyModel::TreeProxyModel( QObject* parent ) diff --git a/src/libtomahawk/playlistinterface.h b/src/libtomahawk/playlistinterface.h index c84c3b45f..9f46a3b11 100644 --- a/src/libtomahawk/playlistinterface.h +++ b/src/libtomahawk/playlistinterface.h @@ -19,7 +19,6 @@ #ifndef PLAYLISTINTERFACE_H #define PLAYLISTINTERFACE_H -#include #include #include @@ -27,6 +26,7 @@ #include "dllmacro.h" #include "result.h" +#include "utils/logger.h" namespace Tomahawk { diff --git a/src/libtomahawk/query.cpp b/src/libtomahawk/query.cpp index b4622c36b..30aa0c421 100644 --- a/src/libtomahawk/query.cpp +++ b/src/libtomahawk/query.cpp @@ -18,17 +18,19 @@ #include "query.h" -#include "collection.h" #include #include "database/database.h" #include "database/databasecommand_logplayback.h" #include "database/databasecommand_playbackhistory.h" #include "database/databasecommand_loadplaylistentries.h" +#include "collection.h" #include "pipeline.h" #include "resolver.h" #include "sourcelist.h" +#include "utils/logger.h" + using namespace Tomahawk; diff --git a/src/libtomahawk/resolver.cpp b/src/libtomahawk/resolver.cpp index d0a6beb73..2a21ad755 100644 --- a/src/libtomahawk/resolver.cpp +++ b/src/libtomahawk/resolver.cpp @@ -21,12 +21,11 @@ #include #include #include -#include #include -#include #include #include +#include "utils/logger.h" Tomahawk::ExternalResolver::ErrorState Tomahawk::ExternalResolver::error() const diff --git a/src/libtomahawk/result.cpp b/src/libtomahawk/result.cpp index c9ceffeb1..bdbf2d1a6 100644 --- a/src/libtomahawk/result.cpp +++ b/src/libtomahawk/result.cpp @@ -27,6 +27,8 @@ #include "database/databasecommand_loadfile.h" #include "database/databasecommand_loadsocialactions.h" +#include "utils/logger.h" + using namespace Tomahawk; @@ -204,7 +206,7 @@ Result::parseSocialActions() { QListIterator< Tomahawk::SocialAction > it( m_allSocialActions ); unsigned int highestTimestamp = 0; - + while ( it.hasNext() ) { Tomahawk::SocialAction socialAction; diff --git a/src/libtomahawk/sip/SipHandler.cpp b/src/libtomahawk/sip/SipHandler.cpp index 9fcedee97..25aeba36b 100644 --- a/src/libtomahawk/sip/SipHandler.cpp +++ b/src/libtomahawk/sip/SipHandler.cpp @@ -30,6 +30,7 @@ #include "network/controlconnection.h" #include "sourcelist.h" #include "tomahawksettings.h" +#include "utils/logger.h" #include "config.h" diff --git a/src/libtomahawk/sip/SipHandler.h b/src/libtomahawk/sip/SipHandler.h index 74a2e5df5..8eed7f3a2 100644 --- a/src/libtomahawk/sip/SipHandler.h +++ b/src/libtomahawk/sip/SipHandler.h @@ -22,7 +22,6 @@ #include "sip/SipPlugin.h" #include "dllmacro.h" -#include #include #include #include diff --git a/src/libtomahawk/sip/SipModel.cpp b/src/libtomahawk/sip/SipModel.cpp index 96f82747d..863769cbb 100644 --- a/src/libtomahawk/sip/SipModel.cpp +++ b/src/libtomahawk/sip/SipModel.cpp @@ -22,6 +22,9 @@ #include "sip/SipHandler.h" #include "sip/SipPlugin.h" +#include "utils/logger.h" + + SipModel::SipModel( QObject* parent ) : QAbstractItemModel( parent ) { @@ -41,9 +44,9 @@ SipModel::SipModel( QObject* parent ) SipModel::~SipModel() { - } + QVariant SipModel::data( const QModelIndex& index, int role ) const { @@ -105,6 +108,7 @@ SipModel::data( const QModelIndex& index, int role ) const return QVariant(); } + bool SipModel::setData( const QModelIndex& index, const QVariant& value, int role ) { @@ -127,6 +131,7 @@ SipModel::setData( const QModelIndex& index, const QVariant& value, int role ) return false; } + QModelIndex SipModel::index( int row, int column, const QModelIndex& parent ) const { @@ -142,6 +147,7 @@ SipModel::index( int row, int column, const QModelIndex& parent ) const return QModelIndex(); } + QModelIndex SipModel::parent( const QModelIndex& child ) const { @@ -155,6 +161,7 @@ SipModel::parent( const QModelIndex& child ) const return QModelIndex(); } + int SipModel::rowCount( const QModelIndex& parent ) const { @@ -169,6 +176,7 @@ SipModel::rowCount( const QModelIndex& parent ) const return 0; } + int SipModel::columnCount(const QModelIndex& parent) const { @@ -176,6 +184,7 @@ SipModel::columnCount(const QModelIndex& parent) const return 1; } + Qt::ItemFlags SipModel::flags( const QModelIndex& index ) const { @@ -184,6 +193,7 @@ SipModel::flags( const QModelIndex& index ) const return QAbstractItemModel::flags( index ) | Qt::ItemIsUserCheckable; } + void SipModel::pluginAdded( SipPlugin* p ) { @@ -195,6 +205,7 @@ SipModel::pluginAdded( SipPlugin* p ) endInsertRows(); } + void SipModel::pluginRemoved( SipPlugin* p ) { @@ -203,6 +214,7 @@ SipModel::pluginRemoved( SipPlugin* p ) endRemoveRows(); } + void SipModel::pluginStateChanged( SipPlugin* p ) { diff --git a/src/libtomahawk/sip/SipPlugin.cpp b/src/libtomahawk/sip/SipPlugin.cpp index 6ddc1e298..9dfb6cfd5 100644 --- a/src/libtomahawk/sip/SipPlugin.cpp +++ b/src/libtomahawk/sip/SipPlugin.cpp @@ -21,6 +21,9 @@ #include +#include "utils/logger.h" + + QString SipPluginFactory::generateId() { @@ -28,6 +31,7 @@ SipPluginFactory::generateId() return factoryId() + "_" + uniq; } + SipPlugin::SipPlugin( const QString& pluginId, QObject* parent ) : QObject( parent ) , m_pluginId( pluginId ) @@ -38,7 +42,9 @@ SipPlugin::SipPlugin( const QString& pluginId, QObject* parent ) connect( this, SIGNAL( peerOffline( QString ) ), this, SLOT( onPeerOffline( QString ) ) ); } -QString SipPlugin::pluginId() const + +QString +SipPlugin::pluginId() const { return m_pluginId; } @@ -57,18 +63,21 @@ SipPlugin::configWidget() return 0; } + QString SipPlugin::errorMessage() const { return m_cachedError; } + QIcon SipPlugin::icon() const { return QIcon(); } + const QStringList SipPlugin::peersOnline() const { @@ -82,6 +91,7 @@ SipPlugin::refreshProxy() qDebug() << Q_FUNC_INFO << "Not implemented"; } + void SipPlugin::onError( int code, const QString& error ) { @@ -89,6 +99,7 @@ SipPlugin::onError( int code, const QString& error ) m_cachedError = error; } + void SipPlugin::onStateChange( SipPlugin::ConnectionState state ) { @@ -96,8 +107,9 @@ SipPlugin::onStateChange( SipPlugin::ConnectionState state ) m_cachedError.clear(); } + void -SipPlugin::onPeerOnline(const QString& peerId) +SipPlugin::onPeerOnline( const QString& peerId ) { if( !m_peersOnline.contains( peerId ) ) { @@ -105,15 +117,15 @@ SipPlugin::onPeerOnline(const QString& peerId) } } + void -SipPlugin::onPeerOffline(const QString& peerId) +SipPlugin::onPeerOffline( const QString& peerId ) { m_peersOnline.removeAll( peerId ); } + void SipPlugin::deletePlugin() { - } - diff --git a/src/libtomahawk/sip/sipinfo.cpp b/src/libtomahawk/sip/sipinfo.cpp index 2b211cff4..ca861d5b0 100644 --- a/src/libtomahawk/sip/sipinfo.cpp +++ b/src/libtomahawk/sip/sipinfo.cpp @@ -23,7 +23,9 @@ #include -class SipInfoPrivate : public QSharedData { + +class SipInfoPrivate : public QSharedData +{ public: SipInfoPrivate() : port( -1 ) @@ -47,23 +49,25 @@ public: QString key; }; + SipInfo::SipInfo() { d = new SipInfoPrivate; } + SipInfo::SipInfo(const SipInfo& other) : QObject() , d( other.d ) { - } + SipInfo::~SipInfo() { - } + SipInfo& SipInfo::operator=( const SipInfo& other ) { @@ -71,6 +75,7 @@ SipInfo::operator=( const SipInfo& other ) return *this; } + void SipInfo::clear() { @@ -81,6 +86,7 @@ SipInfo::clear() d->key = QString(); } + bool SipInfo::isValid() const { @@ -99,12 +105,14 @@ SipInfo::isValid() const return false; } + void -SipInfo::setVisible(bool visible) +SipInfo::setVisible( bool visible ) { d->visible.setValue(visible); } + bool SipInfo::isVisible() const { @@ -113,12 +121,14 @@ SipInfo::isVisible() const return d->visible.toBool(); } + void SipInfo::setHost( const QHostInfo& host ) { d->host = host; } + const QHostInfo SipInfo::host() const { @@ -127,12 +137,14 @@ SipInfo::host() const return d->host; } + void SipInfo::setPort( int port ) { d->port = port; } + int SipInfo::port() const { @@ -141,12 +153,14 @@ SipInfo::port() const return d->port; } + void SipInfo::setUniqname( const QString& uniqname ) { d->uniqname = uniqname; } + const QString SipInfo::uniqname() const { @@ -155,12 +169,14 @@ SipInfo::uniqname() const return d->uniqname; } + void SipInfo::setKey( const QString& key ) { d->key = key; } + const QString SipInfo::key() const { @@ -169,6 +185,7 @@ SipInfo::key() const return d->key; } + const QString SipInfo::toJson() const { @@ -190,6 +207,7 @@ SipInfo::toJson() const return QString::fromAscii( ba ); } + const SipInfo SipInfo::fromJson( QString json ) { diff --git a/src/libtomahawk/sip/sipinfo.h b/src/libtomahawk/sip/sipinfo.h index 7ebb4e2d1..1a6b0f2aa 100644 --- a/src/libtomahawk/sip/sipinfo.h +++ b/src/libtomahawk/sip/sipinfo.h @@ -19,14 +19,14 @@ #ifndef SIPINFO_H #define SIPINFO_H -#include #include #include -class SipInfoPrivate; - +#include "utils/logger.h" #include "../dllmacro.h" +class SipInfoPrivate; + class DLLEXPORT SipInfo : public QObject { Q_OBJECT diff --git a/src/libtomahawk/source.cpp b/src/libtomahawk/source.cpp index 9f35df6ea..8656ca358 100644 --- a/src/libtomahawk/source.cpp +++ b/src/libtomahawk/source.cpp @@ -29,6 +29,8 @@ #include +#include "utils/logger.h" + using namespace Tomahawk; diff --git a/src/libtomahawk/sourcelist.cpp b/src/libtomahawk/sourcelist.cpp index aad583902..f9dece3ea 100644 --- a/src/libtomahawk/sourcelist.cpp +++ b/src/libtomahawk/sourcelist.cpp @@ -18,13 +18,13 @@ #include "sourcelist.h" -#include - #include "database/database.h" #include "database/databasecommand_loadallsources.h" #include "network/remotecollection.h" #include "network/controlconnection.h" +#include "utils/logger.h" + using namespace Tomahawk; SourceList* SourceList::s_instance = 0; diff --git a/src/libtomahawk/sourceplaylistinterface.cpp b/src/libtomahawk/sourceplaylistinterface.cpp index 75c67839b..02b9e3c4b 100644 --- a/src/libtomahawk/sourceplaylistinterface.cpp +++ b/src/libtomahawk/sourceplaylistinterface.cpp @@ -18,13 +18,14 @@ #include "sourceplaylistinterface.h" -#include - #include "source.h" #include "pipeline.h" +#include "utils/logger.h" + using namespace Tomahawk; + SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::source_ptr& source ) : PlaylistInterface( this ) , m_source( source ) diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp index d05152b25..e8b65791d 100644 --- a/src/libtomahawk/tomahawksettings.cpp +++ b/src/libtomahawk/tomahawksettings.cpp @@ -24,10 +24,12 @@ #endif #include -#include + #include "sip/SipHandler.h" #include "playlistinterface.h" +#include "utils/logger.h" + #define VERSION 3 using namespace Tomahawk; diff --git a/src/libtomahawk/utils/animatedcounterlabel.h b/src/libtomahawk/utils/animatedcounterlabel.h index ab430397e..39e102140 100644 --- a/src/libtomahawk/utils/animatedcounterlabel.h +++ b/src/libtomahawk/utils/animatedcounterlabel.h @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/src/libtomahawk/utils/animatedsplitter.cpp b/src/libtomahawk/utils/animatedsplitter.cpp index fc5d4898d..2fd423e44 100644 --- a/src/libtomahawk/utils/animatedsplitter.cpp +++ b/src/libtomahawk/utils/animatedsplitter.cpp @@ -18,6 +18,8 @@ #include "animatedsplitter.h" +#include "utils/logger.h" + #define ANIMATION_TIME 400 diff --git a/src/libtomahawk/utils/animatedsplitter.h b/src/libtomahawk/utils/animatedsplitter.h index 20cb283eb..f28c1eb7d 100644 --- a/src/libtomahawk/utils/animatedsplitter.h +++ b/src/libtomahawk/utils/animatedsplitter.h @@ -19,7 +19,6 @@ #ifndef ANIMATEDSPLITTER_H #define ANIMATEDSPLITTER_H -#include #include #include diff --git a/src/libtomahawk/utils/elidedlabel.cpp b/src/libtomahawk/utils/elidedlabel.cpp index f43502175..66fe1f037 100644 --- a/src/libtomahawk/utils/elidedlabel.cpp +++ b/src/libtomahawk/utils/elidedlabel.cpp @@ -24,6 +24,8 @@ #include #include +#include "utils/logger.h" + ElidedLabel::ElidedLabel( QWidget* parent, Qt::WindowFlags flags ) : QFrame( parent, flags ) diff --git a/src/libtomahawk/utils/imagebutton.cpp b/src/libtomahawk/utils/imagebutton.cpp index 90eb1c521..d921db24a 100644 --- a/src/libtomahawk/utils/imagebutton.cpp +++ b/src/libtomahawk/utils/imagebutton.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -25,7 +25,8 @@ #include #include #include -#include + +#include "utils/logger.h" ImageButton::ImageButton( QWidget* parent ) @@ -76,24 +77,24 @@ ImageButton::paintEvent( QPaintEvent* event ) { QPainter p( this ); p.setClipRect( event->rect() ); - + QIcon::Mode mode = isDown() ? QIcon::Active - : isEnabled() - ? QIcon::Normal + : isEnabled() + ? QIcon::Normal : QIcon::Disabled; - + QIcon::State state = isChecked() - ? QIcon::On + ? QIcon::On : QIcon::Off; - + icon().paint( &p, rect(), Qt::AlignCenter, mode, state ); } void ImageButton::setPixmap( const QString& path, const QIcon::State state, const QIcon::Mode mode ) -{ +{ setPixmap( QPixmap( path ), state, mode ); } diff --git a/src/libtomahawk/utils/logger.cpp b/src/libtomahawk/utils/logger.cpp new file mode 100644 index 000000000..fd740048f --- /dev/null +++ b/src/libtomahawk/utils/logger.cpp @@ -0,0 +1,85 @@ +#include "logger.h" + +#include +#include + +#include +#include +#include +#include + +#include "utils/tomahawkutils.h" + +#define LOGFILE TomahawkUtils::appLogDir().filePath( "Tomahawk.log" ).toLocal8Bit() +#define LOGFILE_SIZE 1024 * 512 + +using namespace std; +ofstream logfile; + +namespace Logger +{ + +void +TomahawkLogHandler( QtMsgType type, const char *msg ) +{ + static QMutex s_mutex; + + QMutexLocker locker( &s_mutex ); + switch( type ) + { + case QtDebugMsg: +// logfile << QTime::currentTime().toString().toAscii().data() << " Debug: " << msg << "\n"; + break; + + case QtCriticalMsg: + logfile << QTime::currentTime().toString().toAscii().data() << " Critical: " << msg << endl; + break; + + case QtWarningMsg: + logfile << QTime::currentTime().toString().toAscii().data() << " Warning: " << msg << endl; + break; + + case QtFatalMsg: + logfile << QTime::currentTime().toString().toAscii().data() << " Fatal: " << msg << endl; + logfile.flush(); + + cout << msg << endl; + cout.flush(); + abort(); + break; + } + + cout << msg << "\n"; + cout.flush(); + logfile.flush(); +} + + +void +setupLogfile() +{ + if ( QFileInfo( LOGFILE ).size() > LOGFILE_SIZE ) + { + QByteArray lc; + { + QFile f( LOGFILE ); + f.open( QIODevice::ReadOnly | QIODevice::Text ); + lc = f.readAll(); + f.close(); + } + + QFile::remove( LOGFILE ); + + { + QFile f( LOGFILE ); + f.open( QIODevice::WriteOnly | QIODevice::Text ); + f.write( lc.right( LOGFILE_SIZE - (LOGFILE_SIZE / 4) ) ); + f.close(); + } + } + + logfile.open( LOGFILE, ios::app ); + qInstallMsgHandler( TomahawkLogHandler ); +} + +} // ns diff --git a/src/libtomahawk/utils/logger.h b/src/libtomahawk/utils/logger.h new file mode 100644 index 000000000..866bae248 --- /dev/null +++ b/src/libtomahawk/utils/logger.h @@ -0,0 +1,21 @@ +#ifndef LOGGER_H +#define LOGGER_H + +#include + +#include "dllmacro.h" + +#define tLog( PARAM ) qDebug( PARAM ) + +// Disable qDebug in release builds. +#ifdef QT_NO_DEBUG +#define qDebug QT_NO_QDEBUG_MACRO +#endif + +namespace Logger +{ + DLLEXPORT void TomahawkLogHandler( QtMsgType type, const char *msg ); + DLLEXPORT void setupLogfile(); +} + +#endif \ No newline at end of file diff --git a/src/libtomahawk/utils/progresstreeview.cpp b/src/libtomahawk/utils/progresstreeview.cpp index 2458de911..4a2ef9698 100644 --- a/src/libtomahawk/utils/progresstreeview.cpp +++ b/src/libtomahawk/utils/progresstreeview.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,6 +18,9 @@ #include "progresstreeview.h" +#include "utils/logger.h" + + ProgressTreeView::ProgressTreeView( QWidget* parent ) : QTreeView( parent ) , m_progressBar( 0 ) diff --git a/src/libtomahawk/utils/proxystyle.cpp b/src/libtomahawk/utils/proxystyle.cpp index 2e358751a..1e906f0f6 100644 --- a/src/libtomahawk/utils/proxystyle.cpp +++ b/src/libtomahawk/utils/proxystyle.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,12 +18,13 @@ #include "proxystyle.h" -#include #include #include #include #include +#include "utils/logger.h" + #define ARROW_WIDTH 7 #define ARROW_HEIGHT 7 diff --git a/src/libtomahawk/utils/querylabel.cpp b/src/libtomahawk/utils/querylabel.cpp index 19a1f61ce..33a671a2a 100644 --- a/src/libtomahawk/utils/querylabel.cpp +++ b/src/libtomahawk/utils/querylabel.cpp @@ -24,15 +24,16 @@ #include #include -#include "tomahawkutils.h" #include "artist.h" #include "album.h" #include "query.h" - +#include "tomahawkutils.h" +#include "utils/logger.h" #define BOXMARGIN 2 #define DASH " - " + QueryLabel::QueryLabel( QWidget* parent, Qt::WindowFlags flags ) : QFrame( parent, flags ) , m_type( Complete ) diff --git a/src/libtomahawk/utils/tomahawkutils.cpp b/src/libtomahawk/utils/tomahawkutils.cpp index 970a99c51..3d74347db 100644 --- a/src/libtomahawk/utils/tomahawkutils.cpp +++ b/src/libtomahawk/utils/tomahawkutils.cpp @@ -18,13 +18,9 @@ #include "tomahawkutils.h" -#include -#include "config.h" - #include #include #include -#include #include #include #include @@ -42,18 +38,20 @@ #include #endif +#include +#include "utils/logger.h" +#include "config.h" + namespace TomahawkUtils { #ifdef Q_WS_MAC - QString appSupportFolderPath() { // honestly, it is *always* this --mxcl return QDir::home().filePath( "Library/Application Support" ); } - #endif // Q_WS_MAC @@ -406,7 +404,7 @@ NetworkProxyFactory::setNoProxyHosts( const QStringList& hosts ) newList << munge; //TODO: wildcard support } - qDebug() << Q_FUNC_INFO << " No-proxy hosts: " << newList; + qDebug() << Q_FUNC_INFO << "No-proxy hosts:" << newList; m_noProxyHosts = newList; } @@ -417,8 +415,8 @@ NetworkProxyFactory::setProxy( const QNetworkProxy& proxy ) m_proxy = proxy; if ( !TomahawkSettings::instance()->proxyDns() ) m_proxy.setCapabilities( QNetworkProxy::TunnelingCapability | QNetworkProxy::ListeningCapability | QNetworkProxy::UdpTunnelingCapability ); - qDebug() << Q_FUNC_INFO << " Proxy using host " << proxy.hostName() << " and port " << proxy.port(); - qDebug() << Q_FUNC_INFO << " setting proxy to use proxy DNS?" << (TomahawkSettings::instance()->proxyDns() ? "true" : "false"); + qDebug() << Q_FUNC_INFO << "Proxy using host" << proxy.hostName() << "and port" << proxy.port(); + qDebug() << Q_FUNC_INFO << "setting proxy to use proxy DNS?" << (TomahawkSettings::instance()->proxyDns() ? "true" : "false"); } diff --git a/src/libtomahawk/utils/tomahawkutils.h b/src/libtomahawk/utils/tomahawkutils.h index f3c1263c1..933f5c05c 100644 --- a/src/libtomahawk/utils/tomahawkutils.h +++ b/src/libtomahawk/utils/tomahawkutils.h @@ -20,6 +20,7 @@ #define TOMAHAWKUTILS_H #include "dllmacro.h" + #include #include #include diff --git a/src/libtomahawk/utils/widgetdragfilter.cpp b/src/libtomahawk/utils/widgetdragfilter.cpp index fe5216669..e3d1f5665 100644 --- a/src/libtomahawk/utils/widgetdragfilter.cpp +++ b/src/libtomahawk/utils/widgetdragfilter.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -17,13 +17,15 @@ */ #include "widgetdragfilter.h" -#include + #include #include -#include #include -WidgetDragFilter::WidgetDragFilter(QObject* parent) +#include "utils/logger.h" + + +WidgetDragFilter::WidgetDragFilter( QObject* parent ) : QObject( parent ) , m_dragStarted( false ) { @@ -32,11 +34,13 @@ WidgetDragFilter::WidgetDragFilter(QObject* parent) m_target.data()->installEventFilter( this ); } -bool WidgetDragFilter::eventFilter(QObject* obj, QEvent* event) + +bool +WidgetDragFilter::eventFilter( QObject* obj, QEvent* event ) { - if( m_target.isNull() || m_target.data() != obj ) + if( m_target.isNull() || m_target.data() != obj ) return false; - + if( event->type() == QEvent::MouseButtonPress ) { QMouseEvent *mouseEvent = static_cast( event ); if( !canDrag( obj, mouseEvent ) ) @@ -52,7 +56,7 @@ bool WidgetDragFilter::eventFilter(QObject* obj, QEvent* event) QMouseEvent* e = static_cast(event); if( !canDrag( obj, e ) ) { m_dragStarted = false; - + return false; } if( e->buttons().testFlag( Qt::LeftButton ) ) { @@ -65,34 +69,36 @@ bool WidgetDragFilter::eventFilter(QObject* obj, QEvent* event) return false; } + /** * Make sure we can really drag this widget. Checks inspired by Oxygen's oxygenwindowmanager.cpp */ -bool WidgetDragFilter::canDrag(QObject* obj, QMouseEvent* ev) const +bool +WidgetDragFilter::canDrag( QObject* obj, QMouseEvent* ev ) const { if( !obj->isWidgetType() ) return false; - + QWidget* w = static_cast< QWidget* >( obj ); - + if( QWidget::mouseGrabber() ) return false; - + if( w->cursor().shape() != Qt::ArrowCursor ) return false; - + // Now we check various things about the child position and mouse QPoint position( ev->pos() ); QWidget* child = w->childAt( position ); - + if( child && child->cursor().shape() != Qt::ArrowCursor ) return false; - - // Don't want to drag menubars when selecting an action + + // Don't want to drag menubars when selecting an action if( QMenuBar* menuBar = qobject_cast( w ) ) { // check if there is an active action if( menuBar->activeAction() && menuBar->activeAction()->isEnabled() ) return false; - + // check if action at position exists and is enabled if( QAction* action = menuBar->actionAt( position ) ) { @@ -101,8 +107,8 @@ bool WidgetDragFilter::canDrag(QObject* obj, QMouseEvent* ev) const } // return true in all other cases return true; - - } - + + } + return true; } diff --git a/src/libtomahawk/utils/xspfgenerator.cpp b/src/libtomahawk/utils/xspfgenerator.cpp index e2688987d..89285f6f7 100644 --- a/src/libtomahawk/utils/xspfgenerator.cpp +++ b/src/libtomahawk/utils/xspfgenerator.cpp @@ -18,13 +18,17 @@ #include "xspfgenerator.h" + #include -#include #include #include +#include +#include "utils/logger.h" + using namespace Tomahawk; + XSPFGenerator::XSPFGenerator( const playlist_ptr& pl, QObject* parent ) : QObject( parent ) , m_playlist( pl ) @@ -32,9 +36,9 @@ XSPFGenerator::XSPFGenerator( const playlist_ptr& pl, QObject* parent ) QTimer::singleShot( 0, this, SLOT( generate() ) ); } + XSPFGenerator::~XSPFGenerator() { - } diff --git a/src/libtomahawk/utils/xspfloader.cpp b/src/libtomahawk/utils/xspfloader.cpp index d395f0aa2..ef750060b 100644 --- a/src/libtomahawk/utils/xspfloader.cpp +++ b/src/libtomahawk/utils/xspfloader.cpp @@ -23,12 +23,14 @@ #include #include "utils/tomahawkutils.h" +#include "utils/logger.h" #include "sourcelist.h" #include "playlist.h" using namespace Tomahawk; + void XSPFLoader::setOverrideTitle( const QString& newTitle ) { diff --git a/src/libtomahawk/utils/xspfloader.h b/src/libtomahawk/utils/xspfloader.h index f7b8c4194..105b1b101 100644 --- a/src/libtomahawk/utils/xspfloader.h +++ b/src/libtomahawk/utils/xspfloader.h @@ -23,7 +23,6 @@ #ifndef XSPFLOADER_H #define XSPFLOADER_H -#include #include #include #include diff --git a/src/libtomahawk/viewmanager.cpp b/src/libtomahawk/viewmanager.cpp index e02441276..93794a4d7 100644 --- a/src/libtomahawk/viewmanager.cpp +++ b/src/libtomahawk/viewmanager.cpp @@ -48,6 +48,8 @@ #include "widgets/infowidgets/ArtistInfoWidget.h" #include "widgets/newplaylistwidget.h" +#include "utils/logger.h" + #define FILTER_TIMEOUT 280 using namespace Tomahawk; diff --git a/src/libtomahawk/viewpage.cpp b/src/libtomahawk/viewpage.cpp index 4cd52c941..931e99622 100644 --- a/src/libtomahawk/viewpage.cpp +++ b/src/libtomahawk/viewpage.cpp @@ -1,5 +1,5 @@ /* === This file is part of Tomahawk Player - === - * + * * Copyright 2010-2011, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify @@ -18,7 +18,7 @@ #include "viewpage.h" -#include +#include "utils/logger.h" using namespace Tomahawk; diff --git a/src/libtomahawk/widgets/HeaderLabel.cpp b/src/libtomahawk/widgets/HeaderLabel.cpp index 208abed60..3b98ad3e7 100644 --- a/src/libtomahawk/widgets/HeaderLabel.cpp +++ b/src/libtomahawk/widgets/HeaderLabel.cpp @@ -18,9 +18,10 @@ #include "HeaderLabel.h" -#include #include +#include "utils/logger.h" + #define FONT_SIZE 16 @@ -54,7 +55,7 @@ HeaderLabel::sizeHint() const void -HeaderLabel::paintEvent( QPaintEvent* event ) +HeaderLabel::paintEvent( QPaintEvent* /* event */ ) { QPainter p( this ); QRect r = contentsRect(); diff --git a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp index 17b54b64f..6bb59acbe 100644 --- a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp +++ b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.cpp @@ -19,8 +19,6 @@ #include "ArtistInfoWidget.h" #include "ui_ArtistInfoWidget.h" -#include "utils/tomahawkutils.h" - #include "viewmanager.h" #include "playlist/treemodel.h" #include "playlist/playlistmodel.h" @@ -28,6 +26,9 @@ #include "database/databasecommand_alltracks.h" #include "database/databasecommand_allalbums.h" +#include "utils/tomahawkutils.h" +#include "utils/logger.h" + #include "widgets/overlaywidget.h" static QString s_aiInfoIdentifier = QString( "ArtistInfoWidget" ); diff --git a/src/libtomahawk/widgets/infowidgets/sourceinfowidget.cpp b/src/libtomahawk/widgets/infowidgets/sourceinfowidget.cpp index 228284d19..3396aed50 100644 --- a/src/libtomahawk/widgets/infowidgets/sourceinfowidget.cpp +++ b/src/libtomahawk/widgets/infowidgets/sourceinfowidget.cpp @@ -19,8 +19,6 @@ #include "sourceinfowidget.h" #include "ui_sourceinfowidget.h" -#include "utils/tomahawkutils.h" - #include "viewmanager.h" #include "playlist/albummodel.h" #include "playlist/collectionflatmodel.h" @@ -29,6 +27,9 @@ #include "database/databasecommand_alltracks.h" #include "database/databasecommand_allalbums.h" +#include "utils/tomahawkutils.h" +#include "utils/logger.h" + #include "widgets/overlaywidget.h" diff --git a/src/libtomahawk/widgets/newplaylistwidget.cpp b/src/libtomahawk/widgets/newplaylistwidget.cpp index 2bb826b49..81d1d4a10 100644 --- a/src/libtomahawk/widgets/newplaylistwidget.cpp +++ b/src/libtomahawk/widgets/newplaylistwidget.cpp @@ -22,16 +22,14 @@ #include #include -#include "utils/tomahawkutils.h" - +#include "sourcelist.h" #include "viewmanager.h" #include "playlist/playlistmodel.h" - #include "widgets/overlaywidget.h" #include "utils/xspfloader.h" - -#include "sourcelist.h" +#include "utils/tomahawkutils.h" +#include "utils/logger.h" #define FILTER_TIMEOUT 280 diff --git a/src/libtomahawk/widgets/overlaywidget.cpp b/src/libtomahawk/widgets/overlaywidget.cpp index 077062e49..253569dce 100644 --- a/src/libtomahawk/widgets/overlaywidget.cpp +++ b/src/libtomahawk/widgets/overlaywidget.cpp @@ -18,10 +18,11 @@ #include "overlaywidget.h" -#include #include #include +#include "utils/logger.h" + #define CORNER_ROUNDNESS 8.0 #define FADING_DURATION 500 #define FONT_SIZE 16 diff --git a/src/libtomahawk/widgets/playlisttypeselectordlg.cpp b/src/libtomahawk/widgets/playlisttypeselectordlg.cpp index 4458bcd9f..8207edf34 100644 --- a/src/libtomahawk/widgets/playlisttypeselectordlg.cpp +++ b/src/libtomahawk/widgets/playlisttypeselectordlg.cpp @@ -16,13 +16,15 @@ * along with Tomahawk. If not, see . */ +#include "playlisttypeselectordlg.h" +#include "ui_playlisttypeselectordlg.h" + #include "widgets/newplaylistwidget.h" #include "viewmanager.h" #include "viewpage.h" #include "sourcelist.h" -#include "playlisttypeselectordlg.h" -#include "ui_playlisttypeselectordlg.h" +#include "utils/logger.h" PlaylistTypeSelectorDlg::PlaylistTypeSelectorDlg( QWidget* parent, Qt::WindowFlags f ) @@ -51,11 +53,13 @@ PlaylistTypeSelectorDlg::PlaylistTypeSelectorDlg( QWidget* parent, Qt::WindowFla this, SLOT( enableAutoPlaylistButton( const QString& ))); } + PlaylistTypeSelectorDlg::~PlaylistTypeSelectorDlg() { delete ui; } + void PlaylistTypeSelectorDlg::createNormalPlaylist() { @@ -63,23 +67,30 @@ PlaylistTypeSelectorDlg::createNormalPlaylist() done( QDialog::Accepted ); // return code is used to vaidate we did not exit out of the Dialog } -void PlaylistTypeSelectorDlg::createAutomaticPlaylist() { m_isAutoPlaylist = true; + +void +PlaylistTypeSelectorDlg::createAutomaticPlaylist() +{ + m_isAutoPlaylist = true; m_playlistName = ui->autoPlaylistNameLine->text(); done( QDialog::Accepted ); // return code is used to vaidate we did not exit out of the Dialog successfully } + QString PlaylistTypeSelectorDlg::playlistName() const { return m_playlistName; } + bool PlaylistTypeSelectorDlg::playlistTypeIsAuto() const { return m_isAutoPlaylist; } + void PlaylistTypeSelectorDlg::enableAutoPlaylistButton( const QString &text ) { diff --git a/src/libtomahawk/widgets/searchwidget.cpp b/src/libtomahawk/widgets/searchwidget.cpp index e4a734915..483920172 100644 --- a/src/libtomahawk/widgets/searchwidget.cpp +++ b/src/libtomahawk/widgets/searchwidget.cpp @@ -22,14 +22,13 @@ #include #include -#include "utils/tomahawkutils.h" - +#include "sourcelist.h" #include "viewmanager.h" #include "playlist/playlistmodel.h" - #include "widgets/overlaywidget.h" -#include "sourcelist.h" +#include "utils/tomahawkutils.h" +#include "utils/logger.h" SearchWidget::SearchWidget( const QString& search, QWidget* parent ) diff --git a/src/libtomahawk/widgets/welcomeplaylistmodel.cpp b/src/libtomahawk/widgets/welcomeplaylistmodel.cpp index 2345278fe..8c19b2e66 100644 --- a/src/libtomahawk/widgets/welcomeplaylistmodel.cpp +++ b/src/libtomahawk/widgets/welcomeplaylistmodel.cpp @@ -19,12 +19,15 @@ #include "welcomeplaylistmodel.h" + #include #include