1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-05-01 22:00:04 +02:00

* Merged and fixed master into phonon.

This commit is contained in:
Christian Muehlhaeuser 2011-01-22 07:58:20 +01:00
commit f82f98785f
125 changed files with 1095 additions and 648 deletions

View File

@ -1 +1 @@
58
61

View File

@ -13,7 +13,7 @@ SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
#ADD_DEFINITIONS(-Wall -O2 -DNDEBUG)
#ADD_DEFINITIONS(-fPIC)
ADD_DEFINITIONS(-fPIC)
SET(AUDIO_LIBS "")

View File

@ -3,14 +3,11 @@
#define APP TomahawkApp::instance()
#define RESPATH ":/data/"
#include "headlesscheck.h"
#include <QRegExp>
#include <QFile>
#include <QSettings>
#include <QNetworkAccessManager>
#include <QDir>
#include "QxtHttpServerConnector"
@ -61,16 +58,12 @@ public:
static TomahawkApp* instance();
AudioEngine* audioEngine() { return m_audioEngine; }
SipHandler* sipHandler() { return m_sipHandler; }
QNetworkAccessManager* nam() { return m_nam; }
QNetworkProxy* proxy() { return m_proxy; }
Tomahawk::InfoSystem::InfoSystem* infoSystem() { return m_infoSystem; }
XMPPBot* xmppBot() { return m_xmppBot; }
#ifndef TOMAHAWK_HEADLESS
AudioControls* audioControls();
PlaylistManager* playlistManager();
TomahawkWindow* mainWindow() const { return m_mainwindow; }
#endif
@ -107,9 +100,6 @@ private:
bool m_headless;
QNetworkAccessManager* m_nam;
QNetworkProxy* m_proxy;
Tomahawk::InfoSystem::InfoSystem* m_infoSystem;
QxtHttpServerConnector m_connector;

View File

@ -1,14 +1,7 @@
SET( tomahawkSourcesGui ${tomahawkSourcesGui} audio/rtaudiooutput.cpp )
SET( tomahawkHeadersGui ${tomahawkHeadersGui} audio/rtaudiooutput.h )
FIND_LIBRARY( COREAUDIO_LIBRARY CoreAudio )
FIND_LIBRARY( COREFOUNDATION_LIBRARY CoreFoundation )
MARK_AS_ADVANCED( COREAUDIO_LIBRARY COREFOUNDATION_LIBRARY )
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
${COREAUDIO_LIBRARY}
${COREFOUNDATION_LIBRARY}
rtaudio
tomahawklib
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
${COREAUDIO_LIBRARY}
${COREFOUNDATION_LIBRARY}
rtaudio
tomahawklib
)

View File

@ -10,7 +10,6 @@ SET( QT_USE_QTXML TRUE )
SET( QT_USE_PHONON TRUE )
INCLUDE( ${QT_USE_FILE} )
INCLUDE( ${CMAKE_MODULE_PATH}/AddAppIconMacro.cmake )
#SET( CMAKE_BUILD_TYPE "Release" )
@ -29,60 +28,24 @@ SET( TOMAHAWK_INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../include/" )
#ENDFOREACH( moddir )
SET( tomahawkSources ${tomahawkSources}
audio/audioengine.cpp
utils/tomahawkutils.cpp
sip/SipHandler.cpp
infosystem/infosystem.cpp
infosystem/infoplugins/echonestplugin.cpp
infosystem/infoplugins/musixmatchplugin.cpp
musicscanner.cpp
scriptresolver.cpp
scrobbler.cpp
xmppbot/xmppbot.cpp
web/api_v1.cpp
musicscanner.cpp
scriptresolver.cpp
scrobbler.cpp
tomahawkapp.cpp
main.cpp
)
SET( tomahawkSourcesGui ${tomahawkSourcesGui}
xspfloader.cpp
utils/querylabel.cpp
utils/elidedlabel.cpp
utils/imagebutton.cpp
utils/progresstreeview.cpp
utils/proxystyle.cpp
utils/widgetdragfilter.cpp
utils/animatedsplitter.cpp
playlist/collectionmodel.cpp
playlist/collectionproxymodel.cpp
playlist/collectionflatmodel.cpp
playlist/collectionview.cpp
playlist/playlistmanager.cpp
playlist/plitem.cpp
playlist/playlistmodel.cpp
playlist/playlistproxymodel.cpp
playlist/playlistview.cpp
playlist/playlistitemdelegate.cpp
playlist/queueproxymodel.cpp
playlist/queueview.cpp
playlist/trackmodel.cpp
playlist/trackproxymodel.cpp
playlist/trackview.cpp
playlist/trackheader.cpp
playlist/albumitem.cpp
playlist/albummodel.cpp
playlist/albumproxymodel.cpp
playlist/albumitemdelegate.cpp
playlist/albumview.cpp
sourcetree/sourcesmodel.cpp
sourcetree/sourcetreeitem.cpp
sourcetree/sourcetreeitemwidget.cpp
@ -94,72 +57,31 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
topbar/lineedit.cpp
topbar/searchbutton.cpp
infowidgets/sourceinfowidget.cpp
widgets/newplaylistwidget.cpp
widgets/welcomewidget.cpp
transferview.cpp
tomahawkwindow.cpp
tomahawktrayicon.cpp
audiocontrols.cpp
settingsdialog.cpp
tomahawkwindow.cpp
)
SET( tomahawkHeaders ${tomahawkHeaders}
"${TOMAHAWK_INC_DIR}/tomahawk/tomahawkapp.h"
"${TOMAHAWK_INC_DIR}/tomahawk/infosystem.h"
audio/transcodeinterface.h
audio/audioengine.h
sip/SipHandler.h
infosystem/infoplugins/echonestplugin.h
infosystem/infoplugins/musixmatchplugin.h
musicscanner.h
scriptresolver.h
scrobbler.h
xmppbot/xmppbot.h
web/api_v1.h
musicscanner.h
scriptresolver.h
scrobbler.h
)
SET( tomahawkHeadersGui ${tomahawkHeadersGui}
xspfloader.h
utils/querylabel.h
utils/elidedlabel.h
utils/animatedcounterlabel.h
utils/imagebutton.h
utils/progresstreeview.h
utils/widgetdragfilter.h
utils/animatedsplitter.h
playlist/collectionmodel.h
playlist/collectionproxymodel.h
playlist/collectionflatmodel.h
playlist/collectionview.h
playlist/playlistmanager.h
playlist/plitem.h
playlist/playlistmodel.h
playlist/playlistproxymodel.h
playlist/playlistview.h
playlist/playlistitemdelegate.h
playlist/queueproxymodel.h
playlist/queueview.h
playlist/trackmodel.h
playlist/trackproxymodel.h
playlist/trackview.h
playlist/trackheader.h
playlist/albumitem.h
playlist/albummodel.h
playlist/albumproxymodel.h
playlist/albumitemdelegate.h
playlist/albumview.h
sourcetree/sourcesmodel.h
sourcetree/sourcetreeitem.h
sourcetree/sourcetreeitemwidget.h
@ -172,16 +94,11 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
topbar/lineedit_p.h
topbar/searchbutton.h
infowidgets/sourceinfowidget.h
widgets/newplaylistwidget.h
widgets/welcomewidget.h
transferview.h
tomahawkwindow.h
tomahawktrayicon.h
audiocontrols.h
settingsdialog.h
tomahawkwindow.h
)
SET( tomahawkUI ${tomahawkUI}
@ -192,9 +109,6 @@ SET( tomahawkUI ${tomahawkUI}
audiocontrols.ui
sourcetree/sourcetreeitemwidget.ui
topbar/topbar.ui
infowidgets/sourceinfowidget.ui
widgets/newplaylistwidget.ui
widgets/welcomewidget.ui
)
INCLUDE_DIRECTORIES(
@ -212,6 +126,7 @@ INCLUDE_DIRECTORIES(
libtomahawk
../alsa-playback
../rtaudio
../qxt/qxtweb-standalone/qxtweb
/usr/include/taglib
@ -242,9 +157,9 @@ SET( final_src ${final_src} ${tomahawkMoc} ${tomahawkSources} ${tomahawkHeaders}
IF( "${gui}" STREQUAL "no" )
ELSE()
qt4_wrap_ui( tomahawkUI_H ${tomahawkUI} )
qt4_wrap_cpp( tomahawkMocGui ${tomahawkHeadersGui} )
SET( final_src ${final_src} ${tomahawkUI_H} ${tomahawkMocGui} ${tomahawkSourcesGui} ${RC_SRCS} )
qt4_wrap_ui( tomahawkUI_H ${tomahawkUI} )
qt4_wrap_cpp( tomahawkMocGui ${tomahawkHeadersGui} )
SET( final_src ${final_src} ${tomahawkUI_H} ${tomahawkMocGui} ${tomahawkSourcesGui} ${RC_SRCS} )
ENDIF()
IF( UNIX AND NOT APPLE )

View File

@ -13,16 +13,17 @@ SET( OS_SPECIFIC_LINK_LIBRARIES
)
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
mad
vorbisfile
ogg
FLAC++
${OS_SPECIFIC_LINK_LIBRARIES}
mad
vorbisfile
ogg
FLAC++
)
IF( APPLE )
INCLUDE( "CMakeLists.osx.txt" )
INCLUDE( "CMakeLists.osx.txt" )
ENDIF( APPLE )
IF( UNIX AND NOT APPLE )
INCLUDE( "CMakeLists.linux.txt" )
INCLUDE( "CMakeLists.linux.txt" )
ENDIF( UNIX AND NOT APPLE )

View File

@ -9,47 +9,38 @@ ADD_DEFINITIONS( -static-libgcc )
# Add manual locations to stuff:
INCLUDE_DIRECTORIES(
../../libmad-0.15.1b
../../boost_1_43_0
../../gloox-1.0
../../qjson
../../liblastfm/_include
../../taglib-1.6.3/
../../taglib-1.6.3/build
../../taglib-1.6.3/taglib
../../taglib-1.6.3/taglib/toolkit
../../libmad-0.15.1b
../../boost_1_43_0
../../gloox-1.0
../../qjson
../../liblastfm/_include
../../taglib-1.6.3/
../../taglib-1.6.3/build
../../taglib-1.6.3/taglib
../../taglib-1.6.3/taglib/toolkit
)
SET( GLOOX_LIBS
${GLOOX_LIBS}
gloox
${GLOOX_LIBS}
gloox
)
SET( OS_SPECIFIC_LINK_LIBRARIES
${LIBLASTFM_LIBRARY}
${GLOOX_LIBS}
${LIBLASTFM_LIBRARY}
${GLOOX_LIBS}
)
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
"secur32.dll"
"crypt32.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/../qxt/qxtweb-standalone/libqxtweb-standalone.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/../build/src/libtomahawk/libtomahawklib.dll"
${OS_SPECIFIC_LINK_LIBRARIES}
"secur32.dll"
"crypt32.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/../qxt/qxtweb-standalone/libqxtweb-standalone.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/../build/src/libtomahawk/libtomahawklib.dll"
)
SET( tomahawkSourcesGui ${tomahawkSourcesGui} audio/rtaudiooutput.cpp )
SET( tomahawkHeadersGui ${tomahawkHeadersGui} audio/rtaudiooutput.h )
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
"dsound.dll"
"winmm.dll"
"iphlpapi.a"
"mad"
"vorbisfile"
"ogg"
"FLAC++"
"${CMAKE_CURRENT_SOURCE_DIR}/../rtaudio/librtaudio.dll"
${OS_SPECIFIC_LINK_LIBRARIES}
"iphlpapi.a"
)

View File

@ -4,12 +4,12 @@
#include <QNetworkReply>
#include "tomahawk/tomahawkapp.h"
#include "album.h"
#include "audio/audioengine.h"
#include "playlist/playlistmanager.h"
#include "utils/imagebutton.h"
#include "utils/tomahawkutils.h"
#include "audioengine.h"
#include "imagebutton.h"
#include "playlist/playlistmanager.h"
#include "album.h"
#define LASTFM_DEFAULT_COVER "http://cdn.last.fm/flatness/catalogue/noimage"
@ -83,7 +83,7 @@ AudioControls::AudioControls( QWidget* parent )
ui->volumeSlider->setFixedHeight( 20 );
ui->volumeSlider->setRange( 0, 100 );
ui->volumeSlider->setValue( APP->audioEngine()->volume() );
ui->volumeSlider->setValue( AudioEngine::instance()->volume() );
ui->volumeSlider->setStyleSheet( "QSlider::groove::horizontal {"
"margin: 5px; border-width: 3px;"
"border-image: url(" RESPATH "images/volume-slider-bkg.png) 3 3 3 3 stretch stretch;"
@ -113,28 +113,29 @@ AudioControls::AudioControls( QWidget* parent )
connect( m_prevAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( previous() ) );
connect( m_nextAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( next() ) ); */
connect( ui->volumeSlider, SIGNAL( valueChanged( int ) ), (QObject*)APP->audioEngine(), SLOT( setVolume( int ) ) );
connect( ui->prevButton, SIGNAL( clicked() ), (QObject*)APP->audioEngine(), SLOT( previous() ) );
connect( ui->playPauseButton, SIGNAL( clicked() ), (QObject*)APP->audioEngine(), SLOT( play() ) );
connect( ui->pauseButton, SIGNAL( clicked() ), (QObject*)APP->audioEngine(), SLOT( pause() ) );
connect( ui->nextButton, SIGNAL( clicked() ), (QObject*)APP->audioEngine(), SLOT( next() ) );
connect( ui->volumeLowButton, SIGNAL( clicked() ), (QObject*)APP->audioEngine(), SLOT( lowerVolume() ) );
connect( ui->volumeHighButton, SIGNAL( clicked() ), (QObject*)APP->audioEngine(), SLOT( raiseVolume() ) );
connect( ui->volumeSlider, SIGNAL( valueChanged( int ) ), AudioEngine::instance(), SLOT( setVolume( int ) ) );
connect( ui->prevButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( previous() ) );
connect( ui->playPauseButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( play() ) );
connect( ui->pauseButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( pause() ) );
connect( ui->nextButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( next() ) );
connect( ui->volumeLowButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( lowerVolume() ) );
connect( ui->volumeHighButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( raiseVolume() ) );
connect( ui->repeatButton, SIGNAL( clicked() ), SLOT( onRepeatClicked() ) );
connect( ui->shuffleButton, SIGNAL( clicked() ), SLOT( onShuffleClicked() ) );
connect( ui->artistTrackLabel, SIGNAL( clicked() ), SLOT( onTrackClicked() ) );
connect( ui->albumLabel, SIGNAL( clicked() ), SLOT( onAlbumClicked() ) );
connect( ui->artistTrackLabel, SIGNAL( clickedArtist() ), SLOT( onArtistClicked() ) );
connect( ui->artistTrackLabel, SIGNAL( clickedTrack() ), SLOT( onTrackClicked() ) );
connect( ui->albumLabel, SIGNAL( clickedAlbum() ), SLOT( onAlbumClicked() ) );
// <From AudioEngine>
connect( (QObject*)APP->audioEngine(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( onPlaybackLoading( Tomahawk::result_ptr ) ) );
connect( (QObject*)APP->audioEngine(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlaybackStarted( Tomahawk::result_ptr ) ) );
connect( (QObject*)APP->audioEngine(), SIGNAL( paused() ), SLOT( onPlaybackPaused() ) );
connect( (QObject*)APP->audioEngine(), SIGNAL( resumed() ), SLOT( onPlaybackResumed() ) );
connect( (QObject*)APP->audioEngine(), SIGNAL( stopped() ), SLOT( onPlaybackStopped() ) );
connect( (QObject*)APP->audioEngine(), SIGNAL( timerMilliSeconds( qint64 ) ), SLOT( onPlaybackTimer( qint64 ) ) );
connect( (QObject*)APP->audioEngine(), SIGNAL( volumeChanged( int ) ), SLOT( onVolumeChanged( int ) ) );
connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( onPlaybackLoading( Tomahawk::result_ptr ) ) );
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlaybackStarted( Tomahawk::result_ptr ) ) );
connect( AudioEngine::instance(), SIGNAL( paused() ), SLOT( onPlaybackPaused() ) );
connect( AudioEngine::instance(), SIGNAL( resumed() ), SLOT( onPlaybackResumed() ) );
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( onPlaybackStopped() ) );
connect( AudioEngine::instance(), SIGNAL( timerSeconds( unsigned int ) ), SLOT( onPlaybackTimer( unsigned int ) ) );
connect( AudioEngine::instance(), SIGNAL( volumeChanged( int ) ), SLOT( onVolumeChanged( int ) ) );
m_defaultCover = QPixmap( RESPATH "images/no-album-art-placeholder.png" )
.scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
@ -200,7 +201,7 @@ AudioControls::onCoverArtDownloaded()
{
// Follow HTTP redirect
QNetworkRequest req( redir );
QNetworkReply* reply = APP->nam()->get( req );
QNetworkReply* reply = TomahawkUtils::nam()->get( req );
connect( reply, SIGNAL( finished() ), SLOT( onCoverArtDownloaded() ) );
}
@ -217,7 +218,7 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
QString imgurl = "http://ws.audioscrobbler.com/2.0/?method=album.imageredirect&artist=%1&album=%2&size=medium&api_key=7a90f6672a04b809ee309af169f34b8b";
QNetworkRequest req( imgurl.arg( result->artist()->name() ).arg( result->album()->name() ) );
QNetworkReply* reply = APP->nam()->get( req );
QNetworkReply* reply = TomahawkUtils::nam()->get( req );
connect( reply, SIGNAL( finished() ), SLOT( onCoverArtDownloaded() ) );
}
@ -360,21 +361,21 @@ AudioControls::onRepeatClicked()
case PlaylistInterface::NoRepeat:
{
// switch to RepeatOne
APP->playlistManager()->setRepeatMode( PlaylistInterface::RepeatOne );
PlaylistManager::instance()->setRepeatMode( PlaylistInterface::RepeatOne );
}
break;
case PlaylistInterface::RepeatOne:
{
// switch to RepeatAll
APP->playlistManager()->setRepeatMode( PlaylistInterface::RepeatAll );
PlaylistManager::instance()->setRepeatMode( PlaylistInterface::RepeatAll );
}
break;
case PlaylistInterface::RepeatAll:
{
// switch to NoRepeat
APP->playlistManager()->setRepeatMode( PlaylistInterface::NoRepeat );
PlaylistManager::instance()->setRepeatMode( PlaylistInterface::NoRepeat );
}
break;
@ -409,19 +410,26 @@ AudioControls::onShuffleModeChanged( bool enabled )
void
AudioControls::onShuffleClicked()
{
APP->playlistManager()->setShuffled( m_shuffled ^ true );
PlaylistManager::instance()->setShuffled( m_shuffled ^ true );
}
void
AudioControls::onTrackClicked()
AudioControls::onArtistClicked()
{
APP->playlistManager()->showCurrentTrack();
PlaylistManager::instance()->show( m_currentTrack->artist() );
}
void
AudioControls::onAlbumClicked()
{
APP->playlistManager()->show( m_currentTrack->album() );
PlaylistManager::instance()->show( m_currentTrack->album() );
}
void
AudioControls::onTrackClicked()
{
PlaylistManager::instance()->showCurrentTrack();
}

View File

@ -38,8 +38,10 @@ private slots:
void onRepeatClicked();
void onShuffleClicked();
void onTrackClicked();
void onArtistClicked();
void onAlbumClicked();
void onTrackClicked();
void onCoverArtDownloaded();

View File

@ -492,12 +492,12 @@
<customwidget>
<class>ImageButton</class>
<extends>QPushButton</extends>
<header>imagebutton.h</header>
<header>utils/imagebutton.h</header>
</customwidget>
<customwidget>
<class>QueryLabel</class>
<extends>QLabel</extends>
<header>querylabel.h</header>
<header>utils/querylabel.h</header>
</customwidget>
</customwidgets>
<resources/>

View File

@ -44,7 +44,7 @@ void MusixMatchPlugin::getInfo(const QString &caller, const InfoType type, const
url.addQueryItem("apikey", m_apiKey);
url.addQueryItem("q_artist", artist);
url.addQueryItem("q_track", track);
QNetworkReply* reply = TomahawkApp::instance()->nam()->get(QNetworkRequest(url));
QNetworkReply* reply = TomahawkUtils::nam()->get(QNetworkRequest(url));
reply->setProperty("customData", QVariant::fromValue<Tomahawk::InfoSystem::InfoCustomDataHash>(customData));
reply->setProperty("origData", data);
reply->setProperty("caller", caller);
@ -104,7 +104,7 @@ void MusixMatchPlugin::trackSearchSlot()
QUrl url(requestString);
url.addQueryItem("apikey", m_apiKey);
url.addQueryItem("track_id", track_id);
QNetworkReply* newReply = TomahawkApp::instance()->nam()->get(QNetworkRequest(url));
QNetworkReply* newReply = TomahawkUtils::nam()->get(QNetworkRequest(url));
newReply->setProperty("origData", oldReply->property("origData"));
newReply->setProperty("customData", oldReply->property("customData"));
newReply->setProperty("caller", oldReply->property("caller"));
@ -133,4 +133,4 @@ void MusixMatchPlugin::trackLyricsSlot()
qDebug() << "Emitting lyrics: " << lyrics;
emit info(reply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics, reply->property("origData"), QVariant(lyrics), reply->property("customData").value<Tomahawk::InfoSystem::InfoCustomDataHash>());
emit finished(reply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics);
}
}

View File

@ -1,129 +1,216 @@
project( tomahawklib )
SET( QT_USE_QTGUI TRUE )
SET( QT_USE_QTSQL TRUE )
SET( QT_USE_QTNETWORK TRUE )
SET( QT_USE_QTXML TRUE )
SET( QT_USE_PHONON TRUE )
include( ${QT_USE_FILE} )
add_definitions( ${QT_DEFINITIONS} )
add_definitions( -DQT_SHARED )
add_definitions( -DDLLEXPORT_PRO )
set( libSources
tomahawksettings.cpp
sourcelist.cpp
pipeline.cpp
tomahawksettings.cpp
sourcelist.cpp
pipeline.cpp
artist.cpp
album.cpp
collection.cpp
playlist.cpp
pluginapi.cpp
query.cpp
result.cpp
source.cpp
artist.cpp
album.cpp
collection.cpp
playlist.cpp
pluginapi.cpp
query.cpp
result.cpp
source.cpp
sip/SipPlugin.cpp
sip/SipPlugin.cpp
audio/madtranscode.cpp
audio/vorbistranscode.cpp
audio/flactranscode.cpp
audio/audioengine.cpp
network/bufferiodevice.cpp
network/msgprocessor.cpp
network/filetransferconnection.cpp
network/dbsyncconnection.cpp
network/remotecollection.cpp
network/portfwdthread.cpp
database/database.cpp
database/databasecollection.cpp
database/databaseworker.cpp
database/databaseimpl.cpp
database/databaseresolver.cpp
database/databasecommand.cpp
database/databasecommandloggable.cpp
database/databasecommand_resolve.cpp
database/databasecommand_allalbums.cpp
database/databasecommand_alltracks.cpp
database/databasecommand_addfiles.cpp
database/databasecommand_dirmtimes.cpp
database/databasecommand_loadfile.cpp
database/databasecommand_logplayback.cpp
database/databasecommand_addsource.cpp
database/databasecommand_sourceoffline.cpp
database/databasecommand_collectionstats.cpp
database/databasecommand_loadplaylistentries.cpp
database/databasecommand_modifyplaylist.cpp
database/databasecommand_playbackhistory.cpp
database/databasecommand_setplaylistrevision.cpp
database/databasecommand_loadallplaylists.cpp
database/databasecommand_createplaylist.cpp
database/databasecommand_deleteplaylist.cpp
database/databasecommand_renameplaylist.cpp
database/databasecommand_loadops.cpp
database/databasecommand_updatesearchindex.cpp
database/fuzzyindex.cpp
database/fuzzyindex.cpp
database/databaseworker.cpp
database/databaseimpl.cpp
database/databaseresolver.cpp
database/databasecommand.cpp
database/databasecommandloggable.cpp
database/databasecommand_resolve.cpp
database/databasecommand_allalbums.cpp
database/databasecommand_alltracks.cpp
database/databasecommand_addfiles.cpp
database/databasecommand_dirmtimes.cpp
database/databasecommand_loadfile.cpp
database/databasecommand_logplayback.cpp
database/databasecommand_addsource.cpp
database/databasecommand_sourceoffline.cpp
database/databasecommand_collectionstats.cpp
database/databasecommand_loadplaylistentries.cpp
database/databasecommand_modifyplaylist.cpp
database/databasecommand_playbackhistory.cpp
database/databasecommand_setplaylistrevision.cpp
database/databasecommand_loadallplaylists.cpp
database/databasecommand_createplaylist.cpp
database/databasecommand_deleteplaylist.cpp
database/databasecommand_renameplaylist.cpp
database/databasecommand_loadops.cpp
database/databasecommand_updatesearchindex.cpp
database/databasecollection.cpp
playlist/collectionmodel.cpp
playlist/collectionproxymodel.cpp
playlist/collectionflatmodel.cpp
playlist/collectionview.cpp
playlist/playlistmanager.cpp
playlist/plitem.cpp
playlist/playlistmodel.cpp
playlist/playlistproxymodel.cpp
playlist/playlistview.cpp
playlist/playlistitemdelegate.cpp
playlist/queueproxymodel.cpp
playlist/queueview.cpp
playlist/trackmodel.cpp
playlist/trackproxymodel.cpp
playlist/trackview.cpp
playlist/trackheader.cpp
playlist/albumitem.cpp
playlist/albummodel.cpp
playlist/albumproxymodel.cpp
playlist/albumitemdelegate.cpp
playlist/albumview.cpp
database/database.cpp
network/bufferiodevice.cpp
network/msgprocessor.cpp
network/filetransferconnection.cpp
network/dbsyncconnection.cpp
network/remotecollection.cpp
network/portfwdthread.cpp
network/servent.cpp
network/connection.cpp
network/controlconnection.cpp
network/servent.cpp
network/connection.cpp
network/controlconnection.cpp
utils/tomahawkutils.cpp
utils/querylabel.cpp
utils/elidedlabel.cpp
utils/imagebutton.cpp
utils/progresstreeview.cpp
utils/proxystyle.cpp
utils/widgetdragfilter.cpp
utils/animatedsplitter.cpp
utils/xspfloader.cpp
widgets/newplaylistwidget.cpp
widgets/welcomewidget.cpp
widgets/infowidgets/sourceinfowidget.cpp
)
set( libHeaders
tomahawksettings.h
sourcelist.h
pipeline.h
functimeout.h
tomahawksettings.h
sourcelist.h
pipeline.h
functimeout.h
collection.h
pluginapi.h
query.h
resolver.h
result.h
source.h
artist.h
album.h
track.h
playlist.h
collection.h
pluginapi.h
query.h
resolver.h
result.h
source.h
sip/SipPlugin.h
artist.h
album.h
track.h
playlist.h
audio/transcodeinterface.h
audio/madtranscode.h
audio/vorbistranscode.h
audio/flactranscode.h
audio/audioengine.h
sip/SipPlugin.h
database/database.h
database/databasecollection.h
database/databaseworker.h
database/databaseimpl.h
database/databaseresolver.h
database/databasecommand.h
database/databasecommandloggable.h
database/databasecommand_resolve.h
database/databasecommand_allalbums.h
database/databasecommand_alltracks.h
database/databasecommand_addfiles.h
database/databasecommand_dirmtimes.h
database/databasecommand_loadfile.h
database/databasecommand_logplayback.h
database/databasecommand_addsource.h
database/databasecommand_sourceoffline.h
database/databasecommand_collectionstats.h
database/databasecommand_loadplaylistentries.h
database/databasecommand_modifyplaylist.h
database/databasecommand_playbackhistory.h
database/databasecommand_setplaylistrevision.h
database/databasecommand_loadallplaylists.h
database/databasecommand_createplaylist.h
database/databasecommand_deleteplaylist.h
database/databasecommand_renameplaylist.h
database/databasecommand_loadops.h
database/databasecommand_updatesearchindex.h
database/fuzzyindex.h
database/database.h
database/fuzzyindex.h
database/databaseworker.h
database/databaseimpl.h
database/databaseresolver.h
database/databasecommand.h
database/databasecommandloggable.h
database/databasecommand_resolve.h
database/databasecommand_allalbums.h
database/databasecommand_alltracks.h
database/databasecommand_addfiles.h
database/databasecommand_dirmtimes.h
database/databasecommand_loadfile.h
database/databasecommand_logplayback.h
database/databasecommand_addsource.h
database/databasecommand_sourceoffline.h
database/databasecommand_collectionstats.h
database/databasecommand_loadplaylistentries.h
database/databasecommand_modifyplaylist.h
database/databasecommand_playbackhistory.h
database/databasecommand_setplaylistrevision.h
database/databasecommand_loadallplaylists.h
database/databasecommand_createplaylist.h
database/databasecommand_deleteplaylist.h
database/databasecommand_renameplaylist.h
database/databasecommand_loadops.h
database/databasecommand_updatesearchindex.h
database/databasecollection.h
network/bufferiodevice.h
network/msgprocessor.h
network/remotecollection.h
network/filetransferconnection.h
network/dbsyncconnection.h
network/servent.h
network/connection.h
network/controlconnection.h
network/portfwdthread.h
network/bufferiodevice.h
network/msgprocessor.h
network/remotecollection.h
network/filetransferconnection.h
network/dbsyncconnection.h
network/servent.h
network/connection.h
network/controlconnection.h
network/portfwdthread.h
playlist/collectionmodel.h
playlist/collectionproxymodel.h
playlist/collectionflatmodel.h
playlist/collectionview.h
playlist/playlistmanager.h
playlist/plitem.h
playlist/playlistmodel.h
playlist/playlistproxymodel.h
playlist/playlistview.h
playlist/playlistitemdelegate.h
playlist/queueproxymodel.h
playlist/queueview.h
playlist/trackmodel.h
playlist/trackproxymodel.h
playlist/trackview.h
playlist/trackheader.h
playlist/albumitem.h
playlist/albummodel.h
playlist/albumproxymodel.h
playlist/albumitemdelegate.h
playlist/albumview.h
utils/querylabel.h
utils/elidedlabel.h
utils/animatedcounterlabel.h
utils/imagebutton.h
utils/progresstreeview.h
utils/widgetdragfilter.h
utils/animatedsplitter.h
utils/xspfloader.h
widgets/newplaylistwidget.h
widgets/welcomewidget.h
widgets/infowidgets/sourceinfowidget.h
)
set( libUI ${libUI}
widgets/newplaylistwidget.ui
widgets/welcomewidget.ui
widgets/infowidgets/sourceinfowidget.ui
)
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
@ -132,25 +219,68 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
../../include
../network
../../qxt/qxtweb-standalone/qxtweb
../../rtaudio
../../alsa-playback
)
qt4_wrap_cpp( libMoc ${libHeaders} )
add_library( tomahawklib SHARED ${libSources} ${libMoc} )
IF( WIN32 )
SET( libSources ${libSources} audio/rtaudiooutput.cpp )
SET( libHeaders ${libHeaders} audio/rtaudiooutput.h )
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
"iphlpapi.a"
"ws2_32.dll"
"dnsapi.dll"
${OS_SPECIFIC_LINK_LIBRARIES}
"iphlpapi.a"
"ws2_32.dll"
"dnsapi.dll"
"dsound.dll"
"winmm.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/../../rtaudio/librtaudio.dll"
)
ENDIF( WIN32 )
IF( APPLE )
FIND_LIBRARY( COREAUDIO_LIBRARY CoreAudio )
FIND_LIBRARY( COREFOUNDATION_LIBRARY CoreFoundation )
MARK_AS_ADVANCED( COREAUDIO_LIBRARY COREFOUNDATION_LIBRARY )
SET( libSources ${libSources} audio/rtaudiooutput.cpp )
SET( libHeaders ${libHeaders} audio/rtaudiooutput.h )
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
${COREAUDIO_LIBRARY}
${COREFOUNDATION_LIBRARY}
rtaudio
)
ENDIF( APPLE )
IF( UNIX AND NOT APPLE )
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
alsaplayback
)
ENDIF( UNIX AND NOT APPLE )
qt4_wrap_ui( libUI_H ${libUI} )
qt4_wrap_cpp( libMoc ${libHeaders} )
SET( libSources ${libSources} ${libUI_H} )
add_library( tomahawklib SHARED ${libSources} ${libMoc} )
target_link_libraries( tomahawklib
${QT_LIBRARIES}
${OS_SPECIFIC_LINK_LIBRARIES}
portfwd
qjson
${QT_LIBRARIES}
${OS_SPECIFIC_LINK_LIBRARIES}
portfwd
qjson
mad
vorbisfile
ogg
FLAC++
)
install( TARGETS tomahawklib DESTINATION lib )

View File

@ -31,8 +31,9 @@ public:
Tomahawk::collection_ptr collection() const { return m_collection; }
QList<Tomahawk::query_ptr> tracks();
virtual int unfilteredTrackCount() const { return m_queries.count(); }
virtual int trackCount() const { return m_queries.count(); }
virtual int unfilteredTrackCount() const { return m_queries.count(); }
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }

View File

@ -27,8 +27,56 @@ Artist::get( unsigned int id, const QString& name, const Tomahawk::collection_pt
Artist::Artist( unsigned int id, const QString& name, const Tomahawk::collection_ptr& collection )
: m_id( id )
: PlaylistInterface( this )
, m_id( id )
, m_name( name )
, m_collection( collection )
, m_currentTrack( 0 )
{
}
void
Artist::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection )
{
qDebug() << Q_FUNC_INFO;
m_queries << tracks;
emit tracksAdded( tracks, collection );
}
Tomahawk::result_ptr
Artist::siblingItem( int itemsAway )
{
int p = m_currentTrack;
p += itemsAway;
if ( p < 0 )
return Tomahawk::result_ptr();
if ( p >= m_queries.count() )
return Tomahawk::result_ptr();
m_currentTrack = p;
return m_queries.at( p )->results().first();
}
QList<Tomahawk::query_ptr>
Artist::tracks()
{
if ( m_queries.isEmpty() )
{
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( m_collection );
cmd->setArtist( this );
cmd->setSortOrder( DatabaseCommand_AllTracks::Album );
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
return m_queries;
}

View File

@ -7,12 +7,14 @@
#include "typedefs.h"
#include "collection.h"
#include "playlistinterface.h"
#include "dllmacro.h"
namespace Tomahawk
{
class DLLEXPORT Artist : public QObject
class DLLEXPORT Artist : public QObject, public PlaylistInterface
{
Q_OBJECT
@ -26,13 +28,38 @@ public:
Tomahawk::collection_ptr collection() const { return m_collection; }
// QList<Tomahawk::query_ptr> tracks();
// virtual int trackCount() const { return 0; }
QList<Tomahawk::query_ptr> tracks();
virtual int trackCount() const { return 0; }
virtual int unfilteredTrackCount() const { return m_queries.count(); }
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
virtual bool shuffled() const { return false; }
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
virtual void setShuffled( bool ) {}
virtual void setFilter( const QString& pattern ) {}
signals:
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
void shuffleModeChanged( bool enabled );
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& );
void trackCountChanged( unsigned int tracks );
void sourceTrackCountChanged( unsigned int tracks );
private slots:
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection );
private:
unsigned int m_id;
QString m_name;
QList<Tomahawk::query_ptr> m_queries;
unsigned int m_currentTrack;
Tomahawk::collection_ptr m_collection;
};

View File

@ -8,6 +8,15 @@
#include "database/databasecommand_logplayback.h"
#include "network/servent.h"
AudioEngine* AudioEngine::s_instance = 0;
AudioEngine*
AudioEngine::instance()
{
return s_instance;
}
AudioEngine::AudioEngine()
: QObject()
@ -17,6 +26,7 @@ AudioEngine::AudioEngine()
, m_timeElapsed( 0 )
, m_expectStop( false )
{
s_instance = this;
qDebug() << "Init AudioEngine";
qRegisterMetaType< AudioErrorCode >("AudioErrorCode");

View File

@ -11,17 +11,21 @@
#include "transcodeinterface.h"
#include "dllmacro.h"
#define AUDIO_VOLUME_STEP 5
class PlaylistInterface;
class AudioEngine : public QObject
class DLLEXPORT AudioEngine : public QObject
{
Q_OBJECT
public:
enum AudioErrorCode { StreamReadError, AudioDeviceError, DecodeError };
static AudioEngine* instance();
explicit AudioEngine();
~AudioEngine();
@ -94,6 +98,8 @@ private:
unsigned int m_timeElapsed;
bool m_expectStop;
static AudioEngine* s_instance;
};
#endif // AUDIOENGINE_H

View File

@ -15,10 +15,12 @@
#include <QMutex>
#include <QDebug>
#include "dllmacro.h"
#define FLAC_BUFFER 32768 * 36
#define FLAC_BUFFER_PREFERRED 32768
class FLACTranscode : public TranscodeInterface , protected FLAC::Decoder::Stream
class DLLEXPORT FLACTranscode : public TranscodeInterface , protected FLAC::Decoder::Stream
{
Q_OBJECT

View File

@ -14,10 +14,12 @@
#include <QObject>
#include <QMutex>
#include "dllmacro.h"
#define MP3_BUFFER 32768
#define MP3_BUFFER_PREFERRED 32768
class MADTranscode : public TranscodeInterface
class DLLEXPORT MADTranscode : public TranscodeInterface
{
Q_OBJECT

View File

@ -6,7 +6,9 @@
#include <QObject>
#include <QMutex>
class TranscodeInterface : public QObject
#include "dllmacro.h"
class DLLEXPORT TranscodeInterface : public QObject
{
Q_OBJECT

View File

@ -15,11 +15,13 @@
#include <QDebug>
#include <QStringList>
#include "dllmacro.h"
// Must not be smaller than 8500 bytes!
#define OGG_BUFFER 8500
#define OGG_BUFFER_PREFERRED 32768
class VorbisTranscode : public TranscodeInterface
class DLLEXPORT VorbisTranscode : public TranscodeInterface
{
Q_OBJECT

View File

@ -1,5 +1,7 @@
#include "database.h"
#define WORKER_THREADS 5
Database* Database::s_instance = 0;
@ -13,12 +15,18 @@ Database::instance()
Database::Database( const QString& dbname, QObject* parent )
: QObject( parent )
, m_impl( new DatabaseImpl( dbname, this ) )
, m_workerRO( new DatabaseWorker( m_impl, this, false ) )
, m_workerRW( new DatabaseWorker( m_impl, this, true ) )
{
s_instance = this;
m_workerRO->start();
for ( int i = 0; i < WORKER_THREADS; i++ )
{
DatabaseWorker* worker = new DatabaseWorker( m_impl, this, false );
worker->start();
m_workersRO << worker;
}
m_workerRW->start();
}
@ -27,8 +35,8 @@ Database::~Database()
{
qDebug() << Q_FUNC_INFO;
qDeleteAll( m_workersRO );
delete m_workerRW;
delete m_workerRO;
delete m_impl;
}
@ -46,12 +54,31 @@ Database::enqueue( QSharedPointer<DatabaseCommand> lc )
if( lc->doesMutates() )
{
//qDebug() << Q_FUNC_INFO << "RW" << lc->commandname();
emit newJobRO( lc );
m_workerRW->enqueue( lc );
}
else
{
//qDebug() << Q_FUNC_INFO << "RO" << lc->commandname();
emit newJobRW( lc );
// qDebug() << Q_FUNC_INFO << "RO" << lc->commandname();
int busyThreads = 0;
DatabaseWorker* happyThread = 0;
for ( int i = 0; i < m_workersRO.count(); i++ )
{
DatabaseWorker* worker = m_workersRO.at( i );
if ( !worker->busy() )
{
happyThread = worker;
break;
}
busyThreads++;
if ( !happyThread || worker->outstandingJobs() < happyThread->outstandingJobs() )
happyThread = worker;
}
qDebug() << "Enqueueing command to thread:" << happyThread << busyThreads << lc->commandname();
happyThread->enqueue( lc );
}
}

View File

@ -45,7 +45,8 @@ public slots:
private:
DatabaseImpl* m_impl;
DatabaseWorker *m_workerRO, *m_workerRW;
DatabaseWorker* m_workerRW;
QList<DatabaseWorker*> m_workersRO;
bool m_indexReady;
static Database* s_instance;

View File

@ -18,6 +18,10 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
case 0:
break;
case Album:
m_orderToken = "album.name, file_join.albumpos";
break;
case ModificationTime:
m_orderToken = "file.mtime";
break;
@ -37,9 +41,10 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
"AND file_join.artist = artist.id "
"AND file_join.track = track.id "
"AND file.source %1 "
"%2 "
"%3 %4 %5"
"%2 %3 "
"%4 %5 %6"
).arg( m_collection->source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( m_collection->source()->id() ) )
.arg( !m_artist ? QString() : QString( "AND artist.id = %1" ).arg( m_artist->id() ) )
.arg( !m_album ? QString() : QString( "AND album.id = %1" ).arg( m_album->id() ) )
.arg( m_sortOrder > 0 ? QString( "ORDER BY %1" ).arg( m_orderToken ) : QString() )
.arg( m_sortDescending ? "DESC" : QString() )

View File

@ -17,13 +17,15 @@ Q_OBJECT
public:
enum SortOrder {
None = 0,
ModificationTime = 1,
AlbumPosition = 2
Album = 1,
ModificationTime = 2,
AlbumPosition = 3
};
explicit DatabaseCommand_AllTracks( const Tomahawk::collection_ptr& collection, QObject* parent = 0 )
: DatabaseCommand( parent )
, m_collection( collection )
, m_artist( 0 )
, m_album( 0 )
, m_amount( 0 )
, m_sortOrder( DatabaseCommand_AllTracks::None )
@ -35,7 +37,9 @@ public:
virtual bool doesMutates() const { return false; }
virtual QString commandname() const { return "alltracks"; }
void setArtist( Tomahawk::Artist* artist ) { m_artist = artist; }
void setAlbum( Tomahawk::Album* album ) { m_album = album; }
void setLimit( unsigned int amount ) { m_amount = amount; }
void setSortOrder( DatabaseCommand_AllTracks::SortOrder order ) { m_sortOrder = order; }
void setSortDescending( bool descending ) { m_sortDescending = descending; }
@ -46,7 +50,10 @@ signals:
private:
Tomahawk::collection_ptr m_collection;
Tomahawk::Artist* m_artist;
Tomahawk::Album* m_album;
unsigned int m_amount;
DatabaseCommand_AllTracks::SortOrder m_sortOrder;
bool m_sortDescending;

View File

@ -69,8 +69,6 @@ DatabaseCommand_Resolve::exec( DatabaseImpl* lib )
QList< int > tracks = lib->searchTable( "track", trackname, 10 );
QList< int > albums = lib->searchTable( "album", albumname, 10 );
//qDebug() << "searchTable calls duration:" << timer.elapsed() << "ms";
if( artists.length() == 0 || tracks.length() == 0 )
{
//qDebug() << "No candidates found in first pass, aborting resolve" << artistname << trackname;
@ -145,7 +143,7 @@ DatabaseCommand_Resolve::exec( DatabaseImpl* lib )
{
//qDebug() << "Skipping result for offline sourceid:" << files_query.value( 13 ).toUInt();
// will happen for valid sources which are offline (and thus not in the sourcelist)
return;
continue;
}
m.insert( "url", QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url_str ) );

View File

@ -15,18 +15,6 @@ DatabaseWorker::DatabaseWorker( DatabaseImpl* lib, Database* db, bool mutates )
, m_outstanding( 0 )
{
moveToThread( this );
if( mutates )
{
connect( db, SIGNAL( newJobRW(QSharedPointer<DatabaseCommand>) ),
SLOT( doWork(QSharedPointer<DatabaseCommand>) ),
Qt::QueuedConnection );
}
else
{
connect( db, SIGNAL( newJobRO(QSharedPointer<DatabaseCommand>) ),
SLOT( doWork(QSharedPointer<DatabaseCommand>) ),
Qt::QueuedConnection );
}
qDebug() << "CTOR DatabaseWorker" << this->thread();
}
@ -50,7 +38,19 @@ DatabaseWorker::run()
void
DatabaseWorker::doWork( QSharedPointer<DatabaseCommand> cmd )
DatabaseWorker::enqueue( const QSharedPointer<DatabaseCommand>& cmd )
{
QMutexLocker lock( &m_mut );
m_commands << cmd;
m_outstanding++;
if ( m_outstanding == 1 )
QTimer::singleShot( 0, this, SLOT( doWork() ) );
}
void
DatabaseWorker::doWork()
{
/*
Run the dbcmd. Only inside a transaction if the cmd does mutates.
@ -59,12 +59,20 @@ DatabaseWorker::doWork( QSharedPointer<DatabaseCommand> cmd )
log to the database oplog for replication to peers.
*/
QTime timer;
timer.start();
QSharedPointer<DatabaseCommand> cmd;
{
QMutexLocker lock( &m_mut );
cmd = m_commands.takeFirst();
}
if( cmd->doesMutates() )
{
bool transok = m_dbimpl->database().transaction();
Q_ASSERT( transok );
// Q_ASSERT( transok );
Q_UNUSED( transok );
}
try
@ -141,7 +149,7 @@ DatabaseWorker::doWork( QSharedPointer<DatabaseCommand> cmd )
if( cmd->doesMutates() )
m_dbimpl->database().rollback();
Q_ASSERT( false );
// Q_ASSERT( false );
}
catch(...)
{
@ -154,6 +162,14 @@ DatabaseWorker::doWork( QSharedPointer<DatabaseCommand> cmd )
}
cmd->emitFinished();
{
QMutexLocker lock( &m_mut );
m_outstanding--;
}
if ( m_outstanding > 0 )
doWork();
}

View File

@ -24,13 +24,17 @@ Q_OBJECT
public:
DatabaseWorker( DatabaseImpl*, Database*, bool mutates );
~DatabaseWorker();
//void enqueue( QSharedPointer<DatabaseCommand> );
void enqueue( const QSharedPointer<DatabaseCommand>& );
bool busy() const { return m_outstanding > 0; }
unsigned int outstandingJobs() const { return m_outstanding; }
protected:
void run();
public slots:
void doWork( QSharedPointer<DatabaseCommand> );
private slots:
void doWork();
private:
void logOp( DatabaseCommandLoggable* command );
@ -38,8 +42,10 @@ private:
QMutex m_mut;
DatabaseImpl* m_dbimpl;
QList< QSharedPointer<DatabaseCommand> > m_commands;
bool m_abort;
int m_outstanding;
QJson::Serializer m_serializer;
};

View File

@ -18,6 +18,7 @@
#include "sourcelist.h"
#include "portfwdthread.h"
#include "tomahawksettings.h"
using namespace Tomahawk;
@ -82,30 +83,38 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
}
// --lanhack means to advertise your LAN IP over jabber as if it were externallyVisible
if( qApp->arguments().contains( "--lanhack" ) )
switch( TomahawkSettings::instance()->externalAddressMode() )
{
QList<QHostAddress> ifs = QNetworkInterface::allAddresses();
foreach( QHostAddress ha, ifs )
{
if( ha.toString() == "127.0.0.1" ) continue;
if( ha.toString().contains( ":" ) ) continue; //ipv6
case TomahawkSettings::Lan:
foreach( QHostAddress ha, QNetworkInterface::allAddresses() )
{
if( ha.toString() == "127.0.0.1" ) continue;
if( ha.toString().contains( ":" ) ) continue; //ipv6
m_externalAddress = ha;
m_externalPort = m_port;
qDebug() << "LANHACK: set external address to lan address" << ha.toString();
m_externalAddress = ha;
m_externalPort = m_port;
qDebug() << "LANHACK: set external address to lan address" << ha.toString();
break;
}
break;
}
}
else if( upnp )
{
// TODO check if we have a public/internet IP on this machine directly
m_portfwd = new PortFwdThread( m_port );
connect( m_portfwd, SIGNAL( externalAddressDetected( QHostAddress, unsigned int ) ),
SLOT( setExternalAddress( QHostAddress, unsigned int ) ) );
}
else
{
emit ready();
case TomahawkSettings::DynDns:
qDebug() << "External address mode set to dyndns...";
m_externalHostname = TomahawkSettings::instance()->externalHostname();
m_externalPort = TomahawkSettings::instance()->externalPort();
qDebug() << m_externalHostname << m_externalPort;
break;
case TomahawkSettings::Upnp:
// TODO check if we have a public/internet IP on this machine directly
qDebug() << "External address mode set to upnp....";
m_portfwd = new PortFwdThread( m_port );
connect( m_portfwd, SIGNAL( externalAddressDetected( QHostAddress, unsigned int ) ),
SLOT( setExternalAddress( QHostAddress, unsigned int ) ) );
break;
default:
emit ready();
}
return true;

View File

@ -90,8 +90,8 @@ public:
void connectToPeer( const QString& ha, int port, const QString &key, Connection* conn );
void reverseOfferRequest( ControlConnection* orig_conn, const QString& key, const QString& theirkey );
bool visibleExternally() const { return m_externalPort > 0 && !m_externalAddress.isNull(); }
QHostAddress externalAddress() const { return m_externalAddress; }
bool visibleExternally() const { return !m_externalHostname.isNull() || (m_externalPort > 0 && !m_externalAddress.isNull()); }
QString externalAddress() const { return !m_externalHostname.isNull() ? m_externalHostname : m_externalAddress.toString(); }
int externalPort() const { return m_externalPort; }
QSharedPointer<QIODevice> remoteIODeviceFactory( const Tomahawk::result_ptr& );
@ -142,6 +142,7 @@ private:
QMap< QString, QPointer<Connection> > m_offers;
int m_port, m_externalPort;
QHostAddress m_externalAddress;
QString m_externalHostname;
// currently active file transfers:
QList< FileTransferConnection* > m_ftsessions;

View File

@ -8,7 +8,9 @@
#include "album.h"
class AlbumItem : public QObject
#include "dllmacro.h"
class DLLEXPORT AlbumItem : public QObject
{
Q_OBJECT

View File

@ -1,12 +1,14 @@
#include "albumitemdelegate.h"
#include <QApplication>
#include <QDebug>
#include <QPainter>
#include <QAbstractItemView>
#include "query.h"
#include "result.h"
#include "tomahawk/tomahawkapp.h"
#include "utils/tomahawkutils.h"
#include "playlist/albumitem.h"
#include "playlist/albumproxymodel.h"
@ -37,7 +39,7 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
QStyleOptionViewItemV4 opt = option;
initStyleOption( &opt, QModelIndex() );
APP->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
if ( option.state & QStyle::State_Selected )
{

View File

@ -3,9 +3,11 @@
#include <QStyledItemDelegate>
#include "dllmacro.h"
class AlbumProxyModel;
class AlbumItemDelegate : public QStyledItemDelegate
class DLLEXPORT AlbumItemDelegate : public QStyledItemDelegate
{
Q_OBJECT

View File

@ -5,9 +5,10 @@
#include <QMimeData>
#include <QNetworkReply>
#include "tomahawk/tomahawkapp.h"
#include "database/database.h"
#include "utils/tomahawkutils.h"
#define LASTFM_DEFAULT_COVER "http://cdn.last.fm/flatness/catalogue/noimage"
using namespace Tomahawk;
@ -270,7 +271,7 @@ AlbumModel::onAlbumsAdded( const QList<Tomahawk::album_ptr>& albums, const Tomah
QString imgurl = "http://ws.audioscrobbler.com/2.0/?method=album.imageredirect&artist=%1&album=%2&size=large&api_key=7a90f6672a04b809ee309af169f34b8b";
QNetworkRequest req( imgurl.arg( album->artist()->name() ).arg( album->name() ) );
req.setAttribute( QNetworkRequest::User, (qlonglong)albumitem );
QNetworkReply* reply = APP->nam()->get( req );
QNetworkReply* reply = TomahawkUtils::nam()->get( req );
connect( reply, SIGNAL( finished() ), SLOT( onCoverArtDownloaded() ) );
connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
@ -313,7 +314,7 @@ AlbumModel::onCoverArtDownloaded()
// Follow HTTP redirect
QNetworkRequest req( redir );
req.setAttribute( QNetworkRequest::User, reply->request().attribute( QNetworkRequest::User ) );
QNetworkReply* reply = APP->nam()->get( req );
QNetworkReply* reply = TomahawkUtils::nam()->get( req );
connect( reply, SIGNAL( finished() ), SLOT( onCoverArtDownloaded() ) );
}

View File

@ -11,9 +11,11 @@
#include "albumitem.h"
#include "dllmacro.h"
class QMetaData;
class AlbumModel : public QAbstractItemModel
class DLLEXPORT AlbumModel : public QAbstractItemModel
{
Q_OBJECT

View File

@ -6,7 +6,9 @@
#include "playlistinterface.h"
#include "playlist/albummodel.h"
class AlbumProxyModel : public QSortFilterProxyModel, public PlaylistInterface
#include "dllmacro.h"
class DLLEXPORT AlbumProxyModel : public QSortFilterProxyModel, public PlaylistInterface
{
Q_OBJECT

View File

@ -6,10 +6,9 @@
#include <QPainter>
#include <QScrollBar>
#include "tomahawk/tomahawkapp.h"
#include "audioengine.h"
#include "tomahawksettings.h"
#include "audio/audioengine.h"
#include "tomahawksettings.h"
#include "albumitemdelegate.h"
#include "albummodel.h"
#include "albumproxymodel.h"
@ -82,7 +81,7 @@ AlbumView::onItemActivated( const QModelIndex& index )
// qDebug() << "Result activated:" << item->album()->tracks().first()->toString() << item->album()->tracks().first()->results().first()->url();
// APP->audioEngine()->playItem( item->album().data(), item->album()->tracks().first()->results().first() );
APP->playlistManager()->show( item->album() );
PlaylistManager::instance()->show( item->album() );
}
}

View File

@ -4,10 +4,12 @@
#include <QListView>
#include <QSortFilterProxyModel>
#include "dllmacro.h"
class AlbumModel;
class AlbumProxyModel;
class AlbumView : public QListView
class DLLEXPORT AlbumView : public QListView
{
Q_OBJECT

View File

@ -15,9 +15,11 @@
#include "database/databasecommand_alltracks.h"
#include "dllmacro.h"
class QMetaData;
class CollectionFlatModel : public TrackModel
class DLLEXPORT CollectionFlatModel : public TrackModel
{
Q_OBJECT
@ -35,7 +37,7 @@ public:
void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllTracks::SortOrder order );
virtual void appendTrack( const Tomahawk::query_ptr& query ) {}
virtual void append( const Tomahawk::query_ptr& query ) {}
signals:
void repeatModeChanged( PlaylistInterface::RepeatMode mode );

View File

@ -12,9 +12,11 @@
#include "playlist.h"
#include "playlistinterface.h"
#include "dllmacro.h"
class QMetaData;
class CollectionModel : public QAbstractItemModel
class DLLEXPORT CollectionModel : public QAbstractItemModel
{
Q_OBJECT

View File

@ -3,7 +3,9 @@
#include "trackproxymodel.h"
class CollectionProxyModel : public TrackProxyModel
#include "dllmacro.h"
class DLLEXPORT CollectionProxyModel : public TrackProxyModel
{
Q_OBJECT

View File

@ -3,10 +3,11 @@
#include <QMenu>
#include "tomahawk/tomahawkapp.h"
#include "trackview.h"
class CollectionView : public TrackView
#include "dllmacro.h"
class DLLEXPORT CollectionView : public TrackView
{
Q_OBJECT

View File

@ -6,7 +6,6 @@
#include "query.h"
#include "result.h"
#include "tomahawk/tomahawkapp.h"
#include "playlist/plitem.h"
#include "playlist/trackproxymodel.h"

View File

@ -3,9 +3,11 @@
#include <QStyledItemDelegate>
#include "dllmacro.h"
class TrackProxyModel;
class PlaylistItemDelegate : public QStyledItemDelegate
class DLLEXPORT PlaylistItemDelegate : public QStyledItemDelegate
{
Q_OBJECT

View File

@ -19,12 +19,19 @@
#include "sourcelist.h"
#include "tomahawksettings.h"
#include "infowidgets/sourceinfowidget.h"
#include "widgets/welcomewidget.h"
#include "widgets/infowidgets/sourceinfowidget.h"
#define FILTER_TIMEOUT 280
PlaylistManager* PlaylistManager::s_instance = 0;
PlaylistManager*
PlaylistManager::instance()
{
return s_instance;
}
PlaylistManager::PlaylistManager( QObject* parent )
: QObject( parent )
@ -35,6 +42,7 @@ PlaylistManager::PlaylistManager( QObject* parent )
, m_statsAvailable( false )
, m_modesAvailable( false )
{
s_instance = this;
m_stack = new QStackedWidget();
m_widget->setLayout( new QVBoxLayout() );
@ -48,7 +56,7 @@ PlaylistManager::PlaylistManager( QObject* parent )
m_queueView = new QueueView( m_splitter );
m_queueModel = new PlaylistModel( m_queueView );
m_queueView->queue()->setModel( m_queueModel );
APP->audioEngine()->setQueue( m_queueView->queue()->proxyModel() );
AudioEngine::instance()->setQueue( m_queueView->queue()->proxyModel() );
m_splitter->addWidget( m_queueView );
m_splitter->hide( 1, false );
@ -67,7 +75,10 @@ PlaylistManager::PlaylistManager( QObject* parent )
m_stack->addWidget( m_superCollectionView );
m_stack->addWidget( m_superAlbumView );
show( new WelcomeWidget() );
m_stack->setContentsMargins( 0, 0, 0, 0 );
m_widget->setContentsMargins( 0, 0, 0, 0 );
m_widget->layout()->setContentsMargins( 0, 0, 0, 0 );
m_widget->layout()->setMargin( 0 );
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
}
@ -125,6 +136,42 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
}
bool
PlaylistManager::show( const Tomahawk::artist_ptr& artist )
{
qDebug() << Q_FUNC_INFO << &artist << artist.data();
unlinkPlaylist();
if ( !m_artistViews.contains( artist ) )
{
PlaylistView* view = new PlaylistView();
PlaylistModel* model = new PlaylistModel();
view->setModel( model );
model->append( artist );
m_currentInterface = view->proxyModel();
m_artistViews.insert( artist, view );
m_stack->addWidget( view );
m_stack->setCurrentWidget( view );
}
else
{
PlaylistView* view = m_artistViews.value( artist );
m_stack->setCurrentWidget( view );
m_currentInterface = view->proxyModel();
}
m_superCollectionVisible = false;
m_statsAvailable = false;
m_modesAvailable = false;
linkPlaylist();
emit numSourcesChanged( 1 );
return true;
}
bool
PlaylistManager::show( const Tomahawk::album_ptr& album )
{
@ -136,7 +183,7 @@ PlaylistManager::show( const Tomahawk::album_ptr& album )
PlaylistView* view = new PlaylistView();
PlaylistModel* model = new PlaylistModel();
view->setModel( model );
model->loadAlbum( album );
model->append( album );
m_currentInterface = view->proxyModel();
m_albumViews.insert( album, view );
@ -447,7 +494,7 @@ PlaylistManager::linkPlaylist()
}
applyFilter();
APP->audioEngine()->setPlaylist( m_currentInterface );
AudioEngine::instance()->setPlaylist( m_currentInterface );
if ( m_currentInterface && m_statsAvailable )
{
@ -507,7 +554,7 @@ PlaylistManager::showCurrentTrack()
{
unlinkPlaylist();
m_currentInterface = APP->audioEngine()->currentTrackPlaylist();
m_currentInterface = AudioEngine::instance()->currentTrackPlaylist();
if ( m_currentInterface->widget() )
m_stack->setCurrentWidget( m_currentInterface->widget() );

View File

@ -8,6 +8,8 @@
#include "collection.h"
#include "playlistinterface.h"
#include "dllmacro.h"
class AnimatedSplitter;
class AlbumModel;
class AlbumView;
@ -22,11 +24,13 @@ class TrackModel;
class TrackView;
class SourceInfoWidget;
class PlaylistManager : public QObject
class DLLEXPORT PlaylistManager : public QObject
{
Q_OBJECT
public:
static PlaylistManager* instance();
explicit PlaylistManager( QObject* parent = 0 );
~PlaylistManager();
@ -36,6 +40,7 @@ public:
bool isSuperCollectionVisible() const { return true; }
bool show( const Tomahawk::playlist_ptr& playlist );
bool show( const Tomahawk::artist_ptr& artist );
bool show( const Tomahawk::album_ptr& album );
bool show( const Tomahawk::collection_ptr& collection );
bool show( const Tomahawk::source_ptr& source );
@ -97,6 +102,7 @@ private:
QHash< Tomahawk::collection_ptr, AlbumView* > m_collectionAlbumViews;
QHash< Tomahawk::playlist_ptr, PlaylistView* > m_playlistViews;
QHash< Tomahawk::artist_ptr, PlaylistView* > m_artistViews;
QHash< Tomahawk::album_ptr, PlaylistView* > m_albumViews;
QHash< Tomahawk::source_ptr, SourceInfoWidget* > m_sourceViews;
@ -114,6 +120,8 @@ private:
QTimer m_filterTimer;
QString m_filter;
static PlaylistManager* s_instance;
};
#endif // PLAYLISTMANAGER_H

View File

@ -94,30 +94,6 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist )
}
void
PlaylistModel::loadAlbum( const Tomahawk::album_ptr& album )
{
if ( album.isNull() )
return;
if ( rowCount( QModelIndex() ) )
{
emit beginRemoveRows( QModelIndex(), 0, rowCount( QModelIndex() ) - 1 );
delete m_rootItem;
emit endRemoveRows();
m_rootItem = new PlItem( 0, this );
}
m_playlist.clear();
setReadOnly( false );
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
onTracksAdded( album->tracks(), album->collection() );
}
void
PlaylistModel::loadHistory( const Tomahawk::source_ptr& source, unsigned int amount )
{
@ -143,7 +119,7 @@ PlaylistModel::loadHistory( const Tomahawk::source_ptr& source, unsigned int amo
void
PlaylistModel::appendTrack( const Tomahawk::query_ptr& query )
PlaylistModel::append( const Tomahawk::query_ptr& query )
{
if ( query.isNull() )
return;
@ -156,7 +132,33 @@ PlaylistModel::appendTrack( const Tomahawk::query_ptr& query )
void
PlaylistModel::insertTrack( unsigned int row, const Tomahawk::query_ptr& query )
PlaylistModel::append( const Tomahawk::album_ptr& album )
{
if ( album.isNull() )
return;
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
onTracksAdded( album->tracks(), album->collection() );
}
void
PlaylistModel::append( const Tomahawk::artist_ptr& artist )
{
if ( artist.isNull() )
return;
connect( artist.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
onTracksAdded( artist->tracks(), artist->collection() );
}
void
PlaylistModel::insert( unsigned int row, const Tomahawk::query_ptr& query )
{
if ( query.isNull() )
return;

View File

@ -6,16 +6,17 @@
#include "plitem.h"
#include "trackmodel.h"
#include "tomahawk/tomahawkapp.h"
#include "collection.h"
#include "query.h"
#include "typedefs.h"
#include "playlist.h"
#include "playlistinterface.h"
#include "dllmacro.h"
class QMetaData;
class PlaylistModel : public TrackModel
class DLLEXPORT PlaylistModel : public TrackModel
{
Q_OBJECT
@ -31,11 +32,13 @@ public:
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent );
void loadPlaylist( const Tomahawk::playlist_ptr& playlist );
void loadAlbum( const Tomahawk::album_ptr& album );
void loadHistory( const Tomahawk::source_ptr& source, unsigned int amount = 100 );
void appendTrack( const Tomahawk::query_ptr& query );
void insertTrack( unsigned int row, const Tomahawk::query_ptr& query );
void append( const Tomahawk::query_ptr& query );
void append( const Tomahawk::album_ptr& album );
void append( const Tomahawk::artist_ptr& artist );
void insert( unsigned int row, const Tomahawk::query_ptr& query );
virtual void removeIndex( const QModelIndex& index, bool moreToCome = false );

View File

@ -3,7 +3,9 @@
#include "trackproxymodel.h"
class PlaylistProxyModel : public TrackProxyModel
#include "dllmacro.h"
class DLLEXPORT PlaylistProxyModel : public TrackProxyModel
{
Q_OBJECT

View File

@ -3,10 +3,11 @@
#include <QMenu>
#include "tomahawk/tomahawkapp.h"
#include "trackview.h"
class PlaylistView : public TrackView
#include "dllmacro.h"
class DLLEXPORT PlaylistView : public TrackView
{
Q_OBJECT

View File

@ -8,7 +8,9 @@
#include "query.h"
#include "typedefs.h"
class PlItem : public QObject
#include "dllmacro.h"
class DLLEXPORT PlItem : public QObject
{
Q_OBJECT

View File

@ -2,7 +2,6 @@
#include <QDebug>
#include "tomahawk/tomahawkapp.h"
#include "playlist/playlistmanager.h"
using namespace Tomahawk;
@ -30,7 +29,7 @@ QueueProxyModel::siblingItem( int itemsAway )
qDebug() << "new rowcount:" << rowCount( QModelIndex() );
if ( rowCount( QModelIndex() ) == 1 )
APP->playlistManager()->hideQueue();
PlaylistManager::instance()->hideQueue();
removeIndex( currentItem() );

View File

@ -3,9 +3,11 @@
#include "playlistproxymodel.h"
#include "dllmacro.h"
class QMetaData;
class QueueProxyModel : public PlaylistProxyModel
class DLLEXPORT QueueProxyModel : public PlaylistProxyModel
{
Q_OBJECT

View File

@ -6,7 +6,9 @@
#include "utils/animatedsplitter.h"
#include "playlistview.h"
class QueueView : public AnimatedWidget
#include "dllmacro.h"
class DLLEXPORT QueueView : public AnimatedWidget
{
Q_OBJECT

View File

@ -4,7 +4,6 @@
#include <QDebug>
#include <QMenu>
#include "tomahawk/tomahawkapp.h"
#include "tomahawksettings.h"
#include "playlist/trackmodel.h"
#include "playlist/trackview.h"

View File

@ -4,9 +4,11 @@
#include <QHeaderView>
#include <QSignalMapper>
#include "dllmacro.h"
class TrackView;
class TrackHeader : public QHeaderView
class DLLEXPORT TrackHeader : public QHeaderView
{
Q_OBJECT

View File

@ -4,7 +4,9 @@
#include <QMimeData>
#include <QTreeView>
#include "tomahawk/tomahawkapp.h"
#include "audio/audioengine.h"
#include "utils/tomahawkutils.h"
#include "album.h"
using namespace Tomahawk;
@ -17,8 +19,8 @@ TrackModel::TrackModel( QObject* parent )
{
qDebug() << Q_FUNC_INFO;
connect( (QObject*)APP->audioEngine(), SIGNAL( finished( Tomahawk::result_ptr ) ), SLOT( onPlaybackFinished( Tomahawk::result_ptr ) ), Qt::DirectConnection );
connect( (QObject*)APP->audioEngine(), SIGNAL( stopped() ), SLOT( onPlaybackStopped() ), Qt::DirectConnection );
connect( AudioEngine::instance(), SIGNAL( finished( Tomahawk::result_ptr ) ), SLOT( onPlaybackFinished( Tomahawk::result_ptr ) ), Qt::DirectConnection );
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( onPlaybackStopped() ), Qt::DirectConnection );
}

View File

@ -6,9 +6,11 @@
#include "playlistinterface.h"
#include "playlist/plitem.h"
#include "dllmacro.h"
class QMetaData;
class TrackModel : public QAbstractItemModel
class DLLEXPORT TrackModel : public QAbstractItemModel
{
Q_OBJECT
@ -51,7 +53,7 @@ public:
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
virtual bool shuffled() const { return false; }
virtual void appendTrack( const Tomahawk::query_ptr& query ) = 0;
virtual void append( const Tomahawk::query_ptr& query ) = 0;
PlItem* itemFromIndex( const QModelIndex& index ) const;

View File

@ -6,7 +6,9 @@
#include "playlistinterface.h"
#include "playlist/trackmodel.h"
class TrackProxyModel : public QSortFilterProxyModel, public PlaylistInterface
#include "dllmacro.h"
class DLLEXPORT TrackProxyModel : public QSortFilterProxyModel, public PlaylistInterface
{
Q_OBJECT

View File

@ -5,11 +5,12 @@
#include <QPainter>
#include <QScrollBar>
#include "tomahawk/tomahawkapp.h"
#include "playlist/trackheader.h"
#include "playlist/playlistmanager.h"
#include "playlist/queueview.h"
#include "audioengine.h"
#include "audio/audioengine.h"
#include "utils/tomahawkutils.h"
#include "trackheader.h"
#include "playlistmanager.h"
#include "queueview.h"
#include "trackmodel.h"
#include "trackproxymodel.h"
@ -94,7 +95,7 @@ TrackView::onItemActivated( const QModelIndex& index )
{
qDebug() << "Result activated:" << item->query()->toString() << item->query()->results().first()->url();
m_proxyModel->setCurrentItem( index );
APP->audioEngine()->playItem( m_proxyModel, item->query()->results().first() );
AudioEngine::instance()->playItem( m_proxyModel, item->query()->results().first() );
}
}
@ -141,8 +142,8 @@ TrackView::addItemsToQueue()
PlItem* item = model()->itemFromIndex( proxyModel()->mapToSource( idx ) );
if ( item && item->query()->numResults() )
{
APP->playlistManager()->queue()->model()->appendTrack( item->query() );
APP->playlistManager()->showQueue();
PlaylistManager::instance()->queue()->model()->append( item->query() );
PlaylistManager::instance()->showQueue();
}
}
}

View File

@ -6,12 +6,14 @@
#include "playlistitemdelegate.h"
#include "dllmacro.h"
class PlaylistInterface;
class TrackHeader;
class TrackModel;
class TrackProxyModel;
class TrackView : public QTreeView
class DLLEXPORT TrackView : public QTreeView
{
Q_OBJECT

View File

@ -297,17 +297,41 @@ TomahawkSettings::setJabberPassword( const QString& pw )
}
bool
TomahawkSettings::upnpEnabled() const
TomahawkSettings::ExternalAddressMode
TomahawkSettings::externalAddressMode() const
{
return value( "network/upnp", true ).toBool();
return (TomahawkSettings::ExternalAddressMode) value( "network/external-address-mode", TomahawkSettings::Upnp ).toInt();
}
void
TomahawkSettings::setUPnPEnabled( bool enable )
TomahawkSettings::setExternalAddressMode( ExternalAddressMode externalAddressMode )
{
setValue( "network/upnp", enable );
setValue( "network/external-address-mode", externalAddressMode );
}
QString
TomahawkSettings::externalHostname() const
{
return value( "network/external-hostname" ).toString();
}
void
TomahawkSettings::setExternalHostname(const QString& externalHostname)
{
setValue( "network/external-hostname", externalHostname );
}
int
TomahawkSettings::externalPort() const
{
return value( "network/external-port" ).toInt();
}
void
TomahawkSettings::setExternalPort(int externalPort)
{
setValue( "network/external-port", externalPort);
}
@ -328,14 +352,14 @@ TomahawkSettings::setLastFmPassword( const QString& password )
QByteArray
TomahawkSettings::lastFmSessionKey() const
{
return value( "lastfm/sessionkey" ).toByteArray();
return value( "lastfm/session" ).toByteArray();
}
void
TomahawkSettings::setLastFmSessionKey( const QByteArray& key )
{
setValue( "lastfm/sessionkey", key );
setValue( "lastfm/session", key );
}

View File

@ -55,11 +55,18 @@ public:
void setJabberPort( int port );
/// Network settings
enum ExternalAddressMode { Lan, DynDns, Upnp };
ExternalAddressMode externalAddressMode() const;
void setExternalAddressMode(ExternalAddressMode externalAddressMode);
bool httpEnabled() const; /// true by default
void setHttpEnabled( bool enable );
bool upnpEnabled() const; /// true by default
void setUPnPEnabled( bool enable );
QString externalHostname() const;
void setExternalHostname( const QString& externalHostname );
int externalPort() const;
void setExternalPort( int externalPort );
QString proxyHost() const;
void setProxyHost( const QString &host );

View File

@ -8,7 +8,9 @@
#include <QEasingCurve>
#include <cmath>
class AnimatedCounterLabel : public QLabel
#include "dllmacro.h"
class DLLEXPORT AnimatedCounterLabel : public QLabel
{
Q_OBJECT

View File

@ -5,9 +5,11 @@
#include <QSplitter>
#include <QTimeLine>
#include "dllmacro.h"
class AnimatedWidget;
class AnimatedSplitter : public QSplitter
class DLLEXPORT AnimatedSplitter : public QSplitter
{
Q_OBJECT
@ -44,7 +46,7 @@ private:
QTimeLine* m_timeLine;
};
class AnimatedWidget : public QWidget
class DLLEXPORT AnimatedWidget : public QWidget
{
Q_OBJECT
public:

View File

@ -4,7 +4,9 @@
#include <QFrame>
#include <QTime>
class ElidedLabel : public QFrame
#include "dllmacro.h"
class DLLEXPORT ElidedLabel : public QFrame
{
Q_OBJECT
Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged )

View File

@ -5,8 +5,9 @@
#include <QIcon>
#include <QMap>
#include "dllmacro.h"
class ImageButton : public QAbstractButton
class DLLEXPORT ImageButton : public QAbstractButton
{
Q_OBJECT

View File

@ -4,7 +4,9 @@
#include <QTreeView>
#include <QProgressBar>
class ProgressTreeView : public QTreeView
#include "dllmacro.h"
class DLLEXPORT ProgressTreeView : public QTreeView
{
Q_OBJECT

View File

@ -4,7 +4,9 @@
#include <QtGlobal>
#include <QProxyStyle>
class ProxyStyle : public QProxyStyle
#include "dllmacro.h"
class DLLEXPORT ProxyStyle : public QProxyStyle
{
public:
ProxyStyle() {}

View File

@ -53,6 +53,7 @@ QueryLabel::~QueryLabel()
void
QueryLabel::init()
{
m_hoverType = None;
setContentsMargins( 0, 0, 0, 0 );
setMouseTracking( true );
@ -247,6 +248,7 @@ void
QueryLabel::updateLabel()
{
m_hoverArea = QRect();
m_hoverType = None;
updateGeometry();
update();
@ -292,8 +294,15 @@ QueryLabel::paintEvent( QPaintEvent* event )
p.save();
p.setRenderHint( QPainter::Antialiasing );
if ( elidedText == s && m_hoverArea.width() )
if ( m_hoverArea.width() )
{
if ( elidedText != s )
{
m_hoverArea.setLeft( 0 );
m_hoverArea.setRight( fontMetrics().width( elidedText ) + contentsMargins().left() * 2 );
m_hoverType = Track;
}
p.setPen( palette().mid().color() );
p.setBrush( palette().highlight() );
p.drawRoundedRect( m_hoverArea, 4.0, 4.0 );
@ -301,8 +310,16 @@ QueryLabel::paintEvent( QPaintEvent* event )
if ( elidedText != s || ( m_result.isNull() && m_query.isNull() ) )
{
p.setBrush( palette().window() );
p.setPen( palette().color( foregroundRole() ) );
if ( m_hoverArea.width() )
{
p.setPen( palette().highlightedText().color() );
p.setBrush( palette().highlight() );
}
else
{
p.setBrush( palette().window() );
p.setPen( palette().color( foregroundRole() ) );
}
p.drawText( r, align, elidedText );
}
else
@ -318,7 +335,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
p.setBrush( palette().window() );
p.setPen( palette().color( foregroundRole() ) );
if ( m_hoverArea.width() && m_hoverArea.left() + contentsMargins().left() == r.left() )
if ( m_hoverType == Artist )
{
p.setPen( palette().highlightedText().color() );
p.setBrush( palette().highlight() );
@ -337,7 +354,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
p.drawText( r, align, DASH );
r.adjust( dashX, 0, 0, 0 );
}
if ( m_hoverArea.width() && m_hoverArea.left() + contentsMargins().left() == r.left() )
if ( m_hoverType == Album )
{
p.setPen( palette().highlightedText().color() );
p.setBrush( palette().highlight() );
@ -356,7 +373,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
p.drawText( r, align, DASH );
r.adjust( dashX, 0, 0, 0 );
}
if ( m_hoverArea.width() && m_hoverArea.left() + contentsMargins().left() == r.left() )
if ( m_hoverType == Track )
{
p.setPen( palette().highlightedText().color() );
p.setBrush( palette().highlight() );
@ -403,7 +420,23 @@ QueryLabel::mouseReleaseEvent( QMouseEvent* event )
m_dragPos = QPoint();
if ( time.elapsed() < qApp->doubleClickInterval() )
emit clicked();
{
switch( m_hoverType )
{
case Artist:
emit clickedArtist();
break;
case Album:
emit clickedAlbum();
break;
case Track:
emit clickedTrack();
break;
default:
emit clicked();
}
}
}
@ -424,6 +457,7 @@ QueryLabel::mouseMoveEvent( QMouseEvent* event )
if ( m_query.isNull() && m_result.isNull() )
{
m_hoverArea = QRect();
m_hoverType = None;
return;
}
@ -450,19 +484,23 @@ QueryLabel::mouseMoveEvent( QMouseEvent* event )
}
QRect hoverArea;
m_hoverType = None;
if ( m_type & Artist && x < artistX )
{
m_hoverType = Artist;
hoverArea.setLeft( 0 );
hoverArea.setRight( artistX + contentsMargins().left() );
}
else if ( m_type & Album && x < albumX && x > artistX )
{
m_hoverType = Album;
int spacing = ( m_type & Artist ) ? dashX : 0;
hoverArea.setLeft( artistX + spacing );
hoverArea.setRight( albumX + spacing + contentsMargins().left() );
}
else if ( m_type & Track && x < trackX && x > albumX )
{
m_hoverType = Track;
int spacing = ( m_type & Album ) ? dashX : 0;
hoverArea.setLeft( albumX + spacing );
hoverArea.setRight( trackX + contentsMargins().left() );
@ -485,6 +523,7 @@ void
QueryLabel::leaveEvent( QEvent* event )
{
m_hoverArea = QRect();
m_hoverType = None;
repaint();
}

View File

@ -6,13 +6,16 @@
#include "result.h"
class QueryLabel : public QFrame
#include "dllmacro.h"
class DLLEXPORT QueryLabel : public QFrame
{
Q_OBJECT
public:
enum DisplayType
{
None = 0,
Artist = 1,
Album = 2,
Track = 4,
@ -58,6 +61,9 @@ public slots:
signals:
void clicked();
void clickedArtist();
void clickedAlbum();
void clickedTrack();
void textChanged( const QString& text );
void resultChanged( const Tomahawk::result_ptr& result );
@ -86,6 +92,7 @@ private:
Qt::Alignment align;
Qt::TextElideMode mode;
DisplayType m_hoverType;
QRect m_hoverArea;
QPoint m_dragPos;
QMargins m_textMargins;

View File

@ -6,6 +6,7 @@
#include <QDir>
#include <QPainter>
#include <QPixmap>
#include <QNetworkAccessManager>
#ifdef WIN32
#include <windows.h>
@ -273,4 +274,35 @@ createDragPixmap( int itemCount )
return dragPixmap;
}
QNetworkAccessManager* s_nam = 0;
QNetworkProxy* s_proxy = 0;
QNetworkAccessManager*
nam()
{
return s_nam;
}
QNetworkProxy*
proxy()
{
return s_proxy;
}
void
setNam( QNetworkAccessManager* nam )
{
s_nam = nam;
}
void
setProxy( QNetworkProxy* proxy )
{
s_proxy = proxy;
}
} // ns

View File

@ -0,0 +1,33 @@
#ifndef TOMAHAWKUTILS_H
#define TOMAHAWKUTILS_H
#include "dllmacro.h"
#define RESPATH ":/data/"
class QDir;
class QDateTime;
class QString;
class QPixmap;
class QNetworkAccessManager;
class QNetworkProxy;
namespace TomahawkUtils
{
DLLEXPORT QDir appConfigDir();
DLLEXPORT QDir appDataDir();
DLLEXPORT QString timeToString( int seconds );
DLLEXPORT QString ageToString( const QDateTime& time );
DLLEXPORT QString filesizeToString( unsigned int size );
DLLEXPORT QPixmap createDragPixmap( int itemCount = 1 );
DLLEXPORT QNetworkAccessManager* nam();
DLLEXPORT QNetworkProxy* proxy();
DLLEXPORT void setNam( QNetworkAccessManager* nam );
DLLEXPORT void setProxy( QNetworkProxy* proxy );
}
#endif // TOMAHAWKUTILS_H

View File

@ -5,6 +5,8 @@
#include <QPoint>
#include <QWidget>
#include "dllmacro.h"
class QMouseEvent;
class QEvent;
@ -12,7 +14,7 @@ class QEvent;
* This class encapsulates an event filter on a widget that lets any drag events over the widget
* translate into move events for the whole application.
*/
class WidgetDragFilter : public QObject
class DLLEXPORT WidgetDragFilter : public QObject
{
Q_OBJECT
public:

View File

@ -1,9 +1,11 @@
#include "xspfloader.h"
#include <QApplication>
#include <QDomDocument>
#include <QMessageBox>
#include "tomahawk/tomahawkapp.h"
#include "utils/tomahawkutils.h"
#include "sourcelist.h"
#include "playlist.h"
@ -14,7 +16,7 @@ void
XSPFLoader::load( const QUrl& url )
{
QNetworkRequest request( url );
QNetworkReply* reply = APP->nam()->get( request );
QNetworkReply* reply = TomahawkUtils::nam()->get( request );
// isn't there a race condition here? something could happen before we connect()
connect( reply, SIGNAL( finished() ),
@ -111,7 +113,7 @@ XSPFLoader::gotBody()
{
if ( m_autoCreate )
{
QMessageBox::critical( APP->mainWindow(), tr( "XSPF Error" ), tr( "This is not a valid XSPF playlist." ) );
QMessageBox::critical( 0, tr( "XSPF Error" ), tr( "This is not a valid XSPF playlist." ) );
deleteLater();
return;
}

View File

@ -15,7 +15,9 @@
#include "playlist.h"
#include "typedefs.h"
class XSPFLoader : public QObject
#include "dllmacro.h"
class DLLEXPORT XSPFLoader : public QObject
{
Q_OBJECT

Some files were not shown because too many files have changed in this diff Show More