1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 22:26:32 +02:00

* Moved InfoSystem into libTomahawk.

* Made InfoSystem a singleton.
* Don't access InfoSystem via TomahawkApp any longer.
* Progress on ArtistView & TreeModel.
This commit is contained in:
Christian Muehlhaeuser
2011-04-14 00:32:16 +02:00
parent 43a08b7957
commit 9f4c3bb461
35 changed files with 352 additions and 273 deletions

View File

@@ -52,10 +52,6 @@ class XMPPBot;
namespace Tomahawk
{
class ShortcutHandler;
namespace InfoSystem
{
class InfoSystem;
}
}
#ifdef LIBLASTFM_FOUND
@@ -83,7 +79,6 @@ public:
static TomahawkApp* instance();
SipHandler* sipHandler() { return m_sipHandler; }
Tomahawk::InfoSystem::InfoSystem* infoSystem() { return m_infoSystem; }
XMPPBot* xmppBot() { return m_xmppBot; }
#ifndef TOMAHAWK_HEADLESS
@@ -138,8 +133,6 @@ private:
bool m_headless;
Tomahawk::InfoSystem::InfoSystem* m_infoSystem;
QxtHttpServerConnector m_connector;
QxtHttpSessionManager m_session;
};

View File

@@ -34,12 +34,6 @@ ENDIF()
SET( tomahawkSources ${tomahawkSources}
sip/SipHandler.cpp
infosystem/infosystemcache.cpp
infosystem/infosystem.cpp
infosystem/infoplugins/echonestplugin.cpp
infosystem/infoplugins/lastfmplugin.cpp
infosystem/infoplugins/musixmatchplugin.cpp
web/api_v1.cpp
resolvers/scriptresolver.cpp
@@ -74,15 +68,9 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
SET( tomahawkHeaders ${tomahawkHeaders}
"${TOMAHAWK_INC_DIR}/tomahawk/tomahawkapp.h"
"${TOMAHAWK_INC_DIR}/tomahawk/infosystem.h"
sip/SipHandler.h
infosystem/infosystemcache.h
infosystem/infoplugins/echonestplugin.h
infosystem/infoplugins/lastfmplugin.h
infosystem/infoplugins/musixmatchplugin.h
web/api_v1.h
resolvers/scriptresolver.h
@@ -137,8 +125,6 @@ INCLUDE_DIRECTORIES(
topbar
utils
libtomahawk
libtomahawk/utils
infosystem
mac
${THIRDPARTY_DIR}/alsa-playback

View File

@@ -21,7 +21,6 @@
#include <QNetworkReply>
#include "tomahawk/tomahawkapp.h"
#include "audio/audioengine.h"
#include "playlist/playlistmanager.h"
#include "utils/imagebutton.h"
@@ -31,7 +30,7 @@
#define LASTFM_DEFAULT_COVER "http://cdn.last.fm/flatness/catalogue/noimage"
static QString s_infoIdentifier = QString( "AUDIOCONTROLS" );
static QString s_acInfoIdentifier = QString( "AUDIOCONTROLS" );
AudioControls::AudioControls( QWidget* parent )
@@ -168,11 +167,11 @@ AudioControls::AudioControls( QWidget* parent )
m_defaultCover = QPixmap( RESPATH "images/no-album-art-placeholder.png" )
.scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
connect( TomahawkApp::instance()->infoSystem(),
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
SLOT( infoSystemInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ) );
connect( TomahawkApp::instance()->infoSystem(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
onPlaybackStopped(); // initial state
}
@@ -220,8 +219,8 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
trackInfo["artist"] = QVariant::fromValue< QString >( result->artist()->name() );
trackInfo["album"] = QVariant::fromValue< QString >( result->album()->name() );
TomahawkApp::instance()->infoSystem()->getInfo(
s_infoIdentifier, Tomahawk::InfoSystem::InfoAlbumCoverArt,
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo(
s_acInfoIdentifier, Tomahawk::InfoSystem::InfoAlbumCoverArt,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCustomData >( trackInfo ), Tomahawk::InfoSystem::InfoCustomData() );
}
@@ -232,8 +231,8 @@ AudioControls::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType ty
Q_UNUSED( input );
Q_UNUSED( customData );
qDebug() << Q_FUNC_INFO;
if ( caller != s_infoIdentifier || type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
qDebug() << Q_FUNC_INFO << caller << type << s_acInfoIdentifier << Tomahawk::InfoSystem::InfoAlbumCoverArt;
if ( caller != s_acInfoIdentifier || type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
{
qDebug() << "Info of wrong type or not with our identifier";
return;

View File

@@ -23,7 +23,7 @@
#include "result.h"
#include "playlistinterface.h"
#include "tomahawk/infosystem.h"
#include "infosystem/infosystem.h"
namespace Ui
{

View File

@@ -75,6 +75,12 @@ set( libSources
database/databasecommand_clientauthvalid.cpp
database/database.cpp
infosystem/infosystemcache.cpp
infosystem/infosystem.cpp
infosystem/infoplugins/echonestplugin.cpp
infosystem/infoplugins/lastfmplugin.cpp
infosystem/infoplugins/musixmatchplugin.cpp
playlist/treemodel.cpp
playlist/treeproxymodel.cpp
playlist/treeheader.cpp
@@ -226,6 +232,12 @@ set( libHeaders
database/databasecommand_addclientauth.h
database/databasecommand_clientauthvalid.h
infosystem/infosystem.h
infosystem/infosystemcache.h
infosystem/infoplugins/echonestplugin.h
infosystem/infoplugins/lastfmplugin.h
infosystem/infoplugins/musixmatchplugin.h
network/bufferiodevice.h
network/msgprocessor.h
network/remotecollection.h
@@ -330,9 +342,9 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.
${LIBECHONEST_INCLUDE_DIR}/..
${CLUCENE_INCLUDE_DIR}
${CLUCENE_LIBRARY_DIR}
${CMAKE_BINARY_DIR}/thirdparty/liblastfm2/src
../../include
../network
playlist
${THIRDPARTY_DIR}/libportfwd/include
@@ -394,6 +406,10 @@ IF( UNIX AND NOT APPLE )
)
ENDIF( UNIX AND NOT APPLE )
IF(LIBLASTFM_FOUND)
SET(LINK_LIBRARIES ${LINK_LIBRARIES} tomahawk_lastfm2 )
ENDIF(LIBLASTFM_FOUND)
qt4_wrap_ui( libUI_H ${libUI} )
qt4_wrap_cpp( libMoc ${libHeaders} )
@@ -422,6 +438,7 @@ target_link_libraries( tomahawklib
${QT_LIBRARIES}
${OS_SPECIFIC_LINK_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${LINK_LIBRARIES}
)
INSTALL( TARGETS tomahawklib DESTINATION lib${LIB_SUFFIX} )

View File

@@ -93,7 +93,7 @@ Album::tracks()
cmd->setAlbum( this );
cmd->setSortOrder( DatabaseCommand_AllTracks::AlbumPosition );
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ),
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );

View File

@@ -95,7 +95,7 @@ Artist::tracks()
cmd->setArtist( this );
cmd->setSortOrder( DatabaseCommand_AllTracks::Album );
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ),
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );

View File

@@ -68,7 +68,7 @@ DatabaseCollection::loadTracks()
setLoaded();
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( source()->collection() );
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ),
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
SLOT( setTracks( QList<Tomahawk::query_ptr> ) ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );

View File

@@ -16,8 +16,6 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tomahawk/infosystem.h"
#include "tomahawk/tomahawkapp.h"
#include "echonestplugin.h"
#include <echonest/Artist.h>
#include <echonest/ArtistTypes.h>

View File

@@ -19,7 +19,7 @@
#ifndef ECHONESTPLUGIN_H
#define ECHONESTPLUGIN_H
#include "tomahawk/infosystem.h"
#include "infosystem/infosystem.h"
#include <QObject>

View File

@@ -26,7 +26,7 @@
#include "typedefs.h"
#include "audio/audioengine.h"
#include "tomahawksettings.h"
#include "tomahawk/tomahawkapp.h"
#include "utils/tomahawkutils.h"
#include <lastfm/ws.h>
#include <lastfm/XmlQuery>
@@ -232,7 +232,7 @@ LastFmPlugin::coverArtReturned()
Tomahawk::InfoSystem::InfoCacheCriteria criteria;
criteria["artist"] = origData["artist"].toString();
criteria["album"] = origData["album"].toString();
emit updateCache( criteria, type, returnedData );
emit updateCache( criteria, 2419200000, type, returnedData );
}
else
{

View File

@@ -18,7 +18,7 @@
#ifndef LASTFMPLUGIN_H
#define LASTFMPLUGIN_H
#include "tomahawk/infosystem.h"
#include "infosystem/infosystem.h"
#include "result.h"
#include <lastfm/Track>

View File

@@ -16,10 +16,10 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tomahawk/infosystem.h"
#include "tomahawk/tomahawkapp.h"
#include "musixmatchplugin.h"
#include "utils/tomahawkutils.h"
#include <QNetworkReply>
#include <QDomDocument>

View File

@@ -18,7 +18,8 @@
#ifndef MUSIXMATCHPLUGIN_H
#define MUSIXMATCHPLUGIN_H
#include "tomahawk/infosystem.h"
#include "infosystem/infosystem.h"
class QNetworkReply;

View File

@@ -18,8 +18,8 @@
#include <QCoreApplication>
#include "tomahawk/infosystem.h"
#include "tomahawkutils.h"
#include "infosystem.h"
#include "utils/tomahawkutils.h"
#include "infosystemcache.h"
#include "infoplugins/echonestplugin.h"
#include "infoplugins/musixmatchplugin.h"
@@ -40,9 +40,9 @@ InfoPlugin::InfoPlugin(QObject *parent)
{
QObject::connect(
this,
SIGNAL( getCachedInfo( Tomahawk::InfoSystem::InfoCacheCriteria, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
SIGNAL( getCachedInfo( Tomahawk::InfoSystem::InfoCacheCriteria, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
system->getCache(),
SLOT( getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) )
SLOT( getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) )
);
QObject::connect(
system->getCache(),
@@ -52,17 +52,27 @@ InfoPlugin::InfoPlugin(QObject *parent)
);
QObject::connect(
this,
SIGNAL( updateCache( Tomahawk::InfoSystem::InfoCacheCriteria, Tomahawk::InfoSystem::InfoType, QVariant ) ),
SIGNAL( updateCache( Tomahawk::InfoSystem::InfoCacheCriteria, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ),
system->getCache(),
SLOT( updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria, Tomahawk::InfoSystem::InfoType, QVariant ) )
SLOT( updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) )
);
}
}
InfoSystem* InfoSystem::s_instance = 0;
InfoSystem*
InfoSystem::instance()
{
return s_instance;
}
InfoSystem::InfoSystem(QObject *parent)
: QObject(parent)
{
s_instance = this;
qDebug() << Q_FUNC_INFO;
qRegisterMetaType< QMap< QString, QMap< QString, QString > > >( "Tomahawk::InfoSystem::InfoGenericMap" );
qRegisterMetaType< QHash< QString, QVariant > >( "Tomahawk::InfoSystem::InfoCustomData" );

View File

@@ -113,7 +113,7 @@ public:
signals:
void getCachedInfo( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
void updateCache( Tomahawk::InfoSystem::InfoCacheCriteria criteria, Tomahawk::InfoSystem::InfoType type, QVariant output );
void updateCache( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64, Tomahawk::InfoSystem::InfoType type, QVariant output );
void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
void finished( QString, Tomahawk::InfoSystem::InfoType );
@@ -139,6 +139,7 @@ class InfoSystem : public QObject
Q_OBJECT
public:
static InfoSystem* instance();
InfoSystem( QObject *parent );
~InfoSystem();
@@ -169,6 +170,8 @@ private:
InfoSystemCache* m_cache;
QThread* m_infoSystemCacheThreadController;
static InfoSystem* s_instance;
};
}

View File

@@ -23,7 +23,7 @@
#include <QObject>
#include <QtDebug>
#include "tomahawk/infosystem.h"
#include "infosystem.h"
namespace Tomahawk
{

View File

@@ -26,6 +26,7 @@
#include <QNetworkProxy>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QPushButton>
#include <QMessageBox>
#include "result.h"
@@ -41,7 +42,6 @@
#include "tomahawksettings.h"
#include "utils/tomahawkutils.h"
#include <aclsystem.h>
#include <tomahawk/tomahawkapp.h>
using namespace Tomahawk;

View File

@@ -240,8 +240,8 @@ AlbumModel::addCollection( const collection_ptr& collection )
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( collection );
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, Tomahawk::collection_ptr ) ),
SLOT( onAlbumsAdded( QList<Tomahawk::album_ptr>, Tomahawk::collection_ptr ) ) );
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
SLOT( onAlbumsAdded( QList<Tomahawk::album_ptr> ) ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
@@ -262,7 +262,7 @@ AlbumModel::addFilteredCollection( const collection_ptr& collection, unsigned in
cmd->setSortOrder( order );
cmd->setSortDescending( true );
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr> ) ),
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
SLOT( onAlbumsAdded( QList<Tomahawk::album_ptr> ) ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );

View File

@@ -27,6 +27,7 @@
#include "audio/audioengine.h"
#include "tomahawksettings.h"
#include "treeheader.h"
#include "treeitemdelegate.h"
#include "playlistmanager.h"
@@ -37,17 +38,35 @@ ArtistView::ArtistView( QWidget* parent )
: QTreeView( parent )
, m_model( 0 )
, m_proxyModel( 0 )
, m_header( new TreeHeader( this ) )
// , m_delegate( 0 )
{
setAlternatingRowColors( true );
setDragEnabled( true );
setDropIndicatorShown( false );
setDragDropOverwriteMode( false );
setUniformRowHeights( false );
setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
setRootIsDecorated( true );
setAnimated( false );
setAllColumnsShowFocus( true );
setSelectionMode( QAbstractItemView::ExtendedSelection );
setSelectionBehavior( QAbstractItemView::SelectRows );
setHeader( m_header );
setProxyModel( new TreeProxyModel( this ) );
#ifndef Q_WS_WIN
QFont f = font();
f.setPointSize( f.pointSize() - 1 );
setFont( f );
#endif
#ifdef Q_WS_MAC
f.setPointSize( f.pointSize() - 2 );
setFont( f );
#endif
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
}

View File

@@ -28,6 +28,8 @@
#include "dllmacro.h"
class TreeHeader;
class DLLEXPORT ArtistView : public QTreeView, public Tomahawk::ViewPage
{
Q_OBJECT
@@ -71,6 +73,7 @@ private slots:
private:
QPixmap createDragPixmap( int itemCount ) const;
TreeHeader* m_header;
TreeModel* m_model;
TreeProxyModel* m_proxyModel;
// PlaylistItemDelegate* m_delegate;

View File

@@ -102,8 +102,8 @@ CollectionFlatModel::addFilteredCollection( const collection_ptr& collection, un
cmd->setSortOrder( order );
cmd->setSortDescending( true );
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ), Qt::QueuedConnection );
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ), Qt::QueuedConnection );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}

View File

@@ -390,6 +390,10 @@ PlaylistManager::showSuperCollection()
{
setPage( m_superCollectionView );
}
else if ( m_currentMode == 1 )
{
setPage( m_superCollectionView );
}
else if ( m_currentMode == 2 )
{
setPage( m_superAlbumView );

View File

@@ -78,6 +78,9 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
opt.palette.setColor( QPalette::Text, opt.palette.color( QPalette::HighlightedText ) );
}
if ( index.column() > 0 )
return;
painter->save();
painter->setRenderHint( QPainter::Antialiasing );
painter->setPen( opt.palette.color( QPalette::Text ) );
@@ -92,7 +95,8 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
QFont boldFont = opt.font;
boldFont.setBold( true );
r = option.rect.adjusted( option.rect.height(), 6, 0, -option.rect.height() + 22 );
r = option.rect.adjusted( option.rect.height(), 6, -4, -option.rect.height() + 22 );
text = painter->fontMetrics().elidedText( text, Qt::ElideRight, r.width() );
painter->drawText( r, text, to );
painter->setFont( boldFont );

View File

@@ -30,7 +30,7 @@
#define LASTFM_DEFAULT_COVER "http://cdn.last.fm/flatness/catalogue/noimage"
static QString s_infoIdentifier = QString( "TREEMODEL" );
static QString s_tmInfoIdentifier = QString( "TREEMODEL" );
using namespace Tomahawk;
@@ -44,11 +44,11 @@ TreeModel::TreeModel( QObject* parent )
m_defaultCover = QPixmap( RESPATH "images/no-album-art-placeholder.png" )
.scaled( QSize( 120, 120 ), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
/* connect( TomahawkApp::instance()->infoSystem(),
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
SLOT( infoSystemInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ) );
connect( TomahawkApp::instance()->infoSystem(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );*/
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
}
@@ -142,7 +142,7 @@ int
TreeModel::columnCount( const QModelIndex& parent ) const
{
Q_UNUSED( parent );
return 4;
return 7;
}
@@ -190,22 +190,47 @@ TreeModel::data( const QModelIndex& index, int role ) const
if ( role != Qt::DisplayRole ) // && role != Qt::ToolTipRole )
return QVariant();
switch( index.column() )
{
case 0:
if ( !entry->artist().isNull() )
if ( !entry->artist().isNull() && index.column() == Name )
{
return entry->artist()->name();
}
else if ( !entry->artist().isNull() )
else if ( !entry->album().isNull() && index.column() == Name )
{
return entry->album()->name();
}
else if ( !entry->result().isNull() )
else
{
return entry->result()->track();
const result_ptr& result = entry->result();
switch( index.column() )
{
case Name:
return QString( "%1%2" ).arg( result->albumpos() > 0 ? QString( "%1. ").arg( result->albumpos() ) : QString() )
.arg( result->track() );
case Duration:
return TomahawkUtils::timeToString( result->duration() );
case Bitrate:
return result->bitrate();
case Age:
return TomahawkUtils::ageToString( QDateTime::fromTime_t( result->modificationTime() ) );
case Year:
return result->year();
case Filesize:
return TomahawkUtils::filesizeToString( result->size() );
case Origin:
return result->friendlySource();
case AlbumPosition:
return result->albumpos();
default:
return QVariant();
}
break;
}
return QVariant();
@@ -216,7 +241,7 @@ QVariant
TreeModel::headerData( int section, Qt::Orientation orientation, int role ) const
{
QStringList headers;
headers << tr( "Artist" );
headers << tr( "Name" ) << tr( "Duration" ) << tr( "Bitrate" ) << tr( "Age" ) << tr( "Year" ) << tr( "Size" ) << tr( "Origin" );
if ( orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 )
{
return headers.at( section );
@@ -453,14 +478,14 @@ TreeModel::onAlbumsAdded( const QList<Tomahawk::album_ptr>& albums, const QVaria
albumitem->index = createIndex( parentItem->children.count() - 1, 0, albumitem );
connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
/* Tomahawk::InfoSystem::InfoCustomData trackInfo;
Tomahawk::InfoSystem::InfoCustomData trackInfo;
trackInfo["artist"] = QVariant::fromValue< QString >( album->artist()->name() );
trackInfo["album"] = QVariant::fromValue< QString >( album->name() );
trackInfo["pptr"] = (qlonglong)albumitem;
trackInfo["pptr"] = QVariant::fromValue< qlonglong >( (qlonglong)albumitem );
TomahawkApp::instance()->infoSystem()->getInfo(
s_infoIdentifier, Tomahawk::InfoSystem::InfoAlbumCoverArt,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCustomData >( trackInfo ), Tomahawk::InfoSystem::InfoCustomData() );*/
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo(
s_tmInfoIdentifier, Tomahawk::InfoSystem::InfoAlbumCoverArt,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCustomData >( trackInfo ), Tomahawk::InfoSystem::InfoCustomData() );
}
if ( crows.second > 0 )
@@ -517,7 +542,7 @@ void
TreeModel::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData )
{
qDebug() << Q_FUNC_INFO;
if ( caller != s_infoIdentifier || type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
if ( caller != s_tmInfoIdentifier || type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
{
qDebug() << "Info of wrong type or not with our identifier";
return;
@@ -529,6 +554,7 @@ TreeModel::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type,
return;
}
Tomahawk::InfoSystem::InfoCustomData pptr = input.value< Tomahawk::InfoSystem::InfoCustomData >();
Tomahawk::InfoSystem::InfoCustomData returnedData = output.value< Tomahawk::InfoSystem::InfoCustomData >();
const QByteArray ba = returnedData["imgbytes"].toByteArray();
if ( ba.length() )
@@ -536,13 +562,15 @@ TreeModel::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type,
QPixmap pm;
pm.loadFromData( ba );
qlonglong pptr = input.toLongLong();
TreeModelItem* ai = reinterpret_cast<TreeModelItem*>(pptr);
qlonglong p = pptr["pptr"].toLongLong();
TreeModelItem* ai = reinterpret_cast<TreeModelItem*>(p);
if ( pm.isNull() || returnedData["url"].toString().startsWith( LASTFM_DEFAULT_COVER ) )
ai->cover = m_defaultCover;
else
ai->cover = pm;
emit dataChanged( ai->index, ai->index.sibling( ai->index.row(), columnCount( QModelIndex() ) - 1 ) );
}
}

View File

@@ -28,7 +28,7 @@
#include "database/databasecommand_allartists.h"
#include "treemodelitem.h"
#include "tomahawk/infosystem.h"
#include "infosystem/infosystem.h"
#include "dllmacro.h"
@@ -39,6 +39,17 @@ class DLLEXPORT TreeModel : public QAbstractItemModel
Q_OBJECT
public:
enum Columns {
Name = 0,
Duration,
Bitrate,
Age,
Year,
Filesize,
Origin,
AlbumPosition
};
explicit TreeModel( QObject* parent = 0 );
virtual ~TreeModel();

View File

@@ -99,6 +99,12 @@ TreeProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) co
if ( !p2 )
return false;
if ( !p1->result().isNull() )
{
if ( p1->result()->albumpos() != p2->result()->albumpos() )
return p1->result()->albumpos() < p2->result()->albumpos();
}
return QString::localeAwareCompare( textForItem( p1 ), textForItem( p2 ) ) < 0;
}

View File

@@ -26,7 +26,7 @@
#include "musicscanner.h"
#include "tomahawksettings.h"
#include "tomahawkutils.h"
#include "utils/tomahawkutils.h"
#include "database/database.h"
#include "database/databasecommand_dirmtimes.h"

View File

@@ -26,10 +26,9 @@
#include "typedefs.h"
#include "audio/audioengine.h"
#include "tomahawksettings.h"
#include "tomahawk/tomahawkapp.h"
#include "tomahawk/infosystem.h"
#include "infosystem/infosystem.h"
static QString s_infoIdentifier = QString("SCROBBLER");
static QString s_scInfoIdentifier = QString( "SCROBBLER" );
Scrobbler::Scrobbler( QObject* parent )
: QObject( parent )
@@ -38,12 +37,10 @@ Scrobbler::Scrobbler( QObject* parent )
connect( AudioEngine::instance(), SIGNAL( timerSeconds( unsigned int ) ),
SLOT( engineTick( unsigned int ) ), Qt::QueuedConnection );
connect( TomahawkApp::instance()->infoSystem(),
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
SLOT( infoSystemInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ) );
connect( TomahawkApp::instance()->infoSystem(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
connect( AudioEngine::instance(), SIGNAL( started( const Tomahawk::result_ptr& ) ),
SLOT( trackStarted( const Tomahawk::result_ptr& ) ), Qt::QueuedConnection );
@@ -55,6 +52,8 @@ Scrobbler::Scrobbler( QObject* parent )
connect( AudioEngine::instance(), SIGNAL( stopped() ),
SLOT( trackStopped() ), Qt::QueuedConnection );
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
}
@@ -81,8 +80,8 @@ Scrobbler::trackStarted( const Tomahawk::result_ptr& track )
trackInfo["artist"] = QVariant::fromValue< QString >( track->artist()->name() );
trackInfo["album"] = QVariant::fromValue< QString >( track->album()->name() );
trackInfo["duration"] = QVariant::fromValue< uint >( track->duration() );
TomahawkApp::instance()->infoSystem()->getInfo(
s_infoIdentifier, Tomahawk::InfoSystem::InfoMiscSubmitNowPlaying,
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo(
s_scInfoIdentifier, Tomahawk::InfoSystem::InfoMiscSubmitNowPlaying,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCustomData >( trackInfo ), Tomahawk::InfoSystem::InfoCustomData() );
m_scrobblePoint = ScrobblePoint( track->duration() / 2 );
@@ -129,18 +128,19 @@ Scrobbler::scrobble()
{
Q_ASSERT( QThread::currentThread() == thread() );
TomahawkApp::instance()->infoSystem()->getInfo(
s_infoIdentifier, Tomahawk::InfoSystem::InfoMiscSubmitScrobble,
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo(
s_scInfoIdentifier, Tomahawk::InfoSystem::InfoMiscSubmitScrobble,
QVariant(), Tomahawk::InfoSystem::InfoCustomData() );
}
void
Scrobbler::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData )
{
Q_UNUSED( input );
Q_UNUSED( output );
Q_UNUSED( customData );
if ( caller == s_infoIdentifier )
if ( caller == s_scInfoIdentifier )
{
qDebug() << Q_FUNC_INFO;
if ( type == Tomahawk::InfoSystem::InfoMiscSubmitNowPlaying )
@@ -150,10 +150,11 @@ Scrobbler::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type,
}
}
void
Scrobbler::infoSystemFinished( QString target )
{
if ( target == s_infoIdentifier )
if ( target == s_scInfoIdentifier )
{
qDebug() << Q_FUNC_INFO;
qDebug() << "Scrobbler received done signal from InfoSystem";

View File

@@ -23,7 +23,7 @@
#include "lastfm/ScrobblePoint"
#include "tomahawk/infosystem.h"
#include "infosystem/infosystem.h"
#include <QObject>

View File

@@ -32,7 +32,7 @@
#include "artist.h"
#include "album.h"
#include "collection.h"
#include "tomahawk/infosystem.h"
#include "infosystem/infosystem.h"
#include "database/database.h"
#include "database/databasecollection.h"
#include "database/databasecommand_collectionstats.h"
@@ -152,7 +152,6 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
, m_shortcutHandler( 0 )
, m_scrubFriendlyName( false )
, m_mainwindow( 0 )
, m_infoSystem( 0 )
{
qDebug() << "TomahawkApp thread:" << this->thread();
setOrganizationName( QLatin1String( ORGANIZATION_NAME ) );
@@ -176,7 +175,6 @@ TomahawkApp::init()
#endif
registerMetaTypes();
setupLogfile();
Echonest::Config::instance()->setAPIKey( "JRIHWEP6GPOER2QQ6" );
@@ -217,7 +215,7 @@ TomahawkApp::init()
}
qDebug() << "Init InfoSystem.";
m_infoSystem = new Tomahawk::InfoSystem::InfoSystem( this );
new Tomahawk::InfoSystem::InfoSystem( this );
#ifdef LIBLASTFM_FOUND
qDebug() << "Init Scrobbler.";
@@ -304,7 +302,7 @@ TomahawkApp::~TomahawkApp()
delete m_mainwindow;
delete m_audioEngine;
#endif
delete m_infoSystem;
// delete m_infoSystem;
delete m_database;
}

View File

@@ -38,8 +38,7 @@
#include <QStringList>
#include "network/servent.h"
#include "tomahawkutils.h"
#include "tomahawk/tomahawkapp.h"
#include "utils/tomahawkutils.h"
#include <database/databasecommand_addclientauth.h>
#include <qxtwebcontent.h>
#include <database/database.h>

View File

@@ -18,8 +18,7 @@
#include "xmppbot.h"
#include "tomahawk/tomahawkapp.h"
#include "tomahawk/infosystem.h"
#include "infosystem/infosystem.h"
#include "album.h"
#include "typedefs.h"
#include "tomahawksettings.h"
@@ -36,7 +35,7 @@
using namespace gloox;
using namespace Tomahawk::InfoSystem;
static QString s_infoIdentifier = QString("XMPPBot");
static QString s_botInfoIdentifier = QString( "XMPPBot" );
XMPPBot::XMPPBot(QObject *parent)
: QObject(parent)
@@ -66,11 +65,11 @@ XMPPBot::XMPPBot(QObject *parent)
connect(AudioEngine::instance(), SIGNAL(started(const Tomahawk::result_ptr &)),
SLOT(newTrackSlot(const Tomahawk::result_ptr &)));
connect(TomahawkApp::instance()->infoSystem(),
connect(InfoSystem::instance(),
SIGNAL(info(QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData)),
SLOT(infoReturnedSlot(QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData)));
connect(TomahawkApp::instance()->infoSystem(), SIGNAL(finished(QString)), SLOT(infoFinishedSlot(QString)));
connect(InfoSystem::instance(), SIGNAL(finished(QString)), SLOT(infoFinishedSlot(QString)));
bool success = m_client.data()->gloox::Client::connect(false);
if (success)
@@ -237,14 +236,14 @@ void XMPPBot::handleMessage(const Message& msg, MessageSession* session)
m_client.data()->send(retMsg);
Tomahawk::InfoSystem::InfoCustomData hash;
hash["XMPPBotSendToJID"] = originatingJid;
TomahawkApp::instance()->infoSystem()->getInfo(s_infoIdentifier, infoMap, hash);
InfoSystem::instance()->getInfo(s_botInfoIdentifier, infoMap, hash);
}
void XMPPBot::infoReturnedSlot(QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData)
{
qDebug() << Q_FUNC_INFO;
if (caller != s_infoIdentifier ||
if (caller != s_botInfoIdentifier ||
input.isNull() || !input.isValid() ||
!customData.contains("XMPPBotSendToJID")
)
@@ -398,8 +397,8 @@ void XMPPBot::infoFinishedSlot(QString caller)
{
qDebug() << Q_FUNC_INFO;
qDebug() << "current return message is" << m_currReturnMessage;
qDebug() << "id is" << caller << "and our id is" << s_infoIdentifier;
if (m_currReturnMessage.isEmpty() || caller != s_infoIdentifier)
qDebug() << "id is" << caller << "and our id is" << s_botInfoIdentifier;
if (m_currReturnMessage.isEmpty() || caller != s_botInfoIdentifier)
return;
qDebug() << "Sending message to JID" << m_currReturnJid;

View File

@@ -20,7 +20,7 @@
#define XMPPBOT_H
#include <result.h>
#include <tomahawk/infosystem.h>
#include <infosystem/infosystem.h>
#include <QtCore/QObject>
#include <QtCore/qsharedpointer.h>