1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-23 01:09:42 +01:00

* Moved more debug output to LOGVERBOSE level.

This commit is contained in:
Christian Muehlhaeuser 2011-09-12 07:58:15 +02:00
parent f48c2c9b5c
commit 5121d060db
6 changed files with 123 additions and 109 deletions

View File

@ -213,7 +213,7 @@ AudioEngine::next()
bool
AudioEngine::canGoNext()
{
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
if ( m_queue && m_queue->trackCount() )
return true;
@ -267,13 +267,13 @@ AudioEngine::canSeek()
void
AudioEngine::seek( qint64 ms )
{
if( !canSeek() )
if ( !canSeek() )
{
qDebug() << "Could not seek!";
tDebug( LOGEXTRA ) << "Could not seek!";
return;
}
if( isPlaying() || isPaused() )
if ( isPlaying() || isPaused() )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << ms;
m_mediaObject->seek( ms );

View File

@ -540,7 +540,6 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
else
{
// Q_ASSERT( false );
tDebug() << "We don't support non-servent / non-file result-hints yet.";
/* res = Tomahawk::result_ptr( new Tomahawk::Result() );
s = SourceList::instance()->webSource();
res->setUrl( url );

View File

@ -100,38 +100,31 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
{
m_port = port;
int defPort = TomahawkSettings::instance()->defaultPort();
// Listen on both the selected port and, if not the same, the default port -- the latter sometimes necessary for zeroconf
// TODO: only listen on both when zeroconf sip is enabled
// TODO: use a real zeroconf system instead of a simple UDP broadcast?
if( !listen( ha, m_port ) )
if ( !listen( ha, m_port ) )
{
bool defPortAlso = false;
if( m_port != defPort )
defPortAlso = listen( ha, defPort );
if( !defPortAlso )
if ( m_port != defPort )
{
tLog() << "Failed to listen on both port" << m_port << "and port" << defPort;
tLog() << "Error string is" << errorString();
return false;
if ( !listen( ha, defPort ) )
{
tLog() << "Failed to listen on both port" << m_port << "and port" << defPort;
tLog() << "Error string is:" << errorString();
return false;
}
else
m_port = defPort;
}
else
tLog() << "Servent listening on port" << defPort << "servent thread:" << thread();
}
else
{
bool defPortAlso = listen( ha, defPort );
tLog() << "Servent listening on port" << m_port << "servent thread:" << thread();
if( defPortAlso )
tLog() << "Servent also listening on port" << defPort << "servent thread:" << thread();
}
// --lanhack means to advertise your LAN IP over jabber as if it were externallyVisible
tLog() << "Address mode =" << (int)(TomahawkSettings::instance()->externalAddressMode());
tLog() << "Static host/port preferred =" << ( TomahawkSettings::instance()->preferStaticHostPort() ? "true" : "false" );
tLog() << "Servent listening on port" << m_port << "- servent thread:" << thread()
<< "- address mode:" << (int)( TomahawkSettings::instance()->externalAddressMode() );
if( TomahawkSettings::instance()->preferStaticHostPort() )
// --lanhack means to advertise your LAN IP as if it were externally visible
if ( TomahawkSettings::instance()->preferStaticHostPort() )
{
tLog() << "Forcing static preferred host and port";
m_externalHostname = TomahawkSettings::instance()->externalHostname();
m_externalPort = TomahawkSettings::instance()->externalPort();
m_ready = true;
@ -141,7 +134,7 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
TomahawkSettings::ExternalAddressMode mode = TomahawkSettings::instance()->externalAddressMode();
if ( mode == TomahawkSettings::Upnp && !upnp )
mode = TomahawkSettings::Lan;
mode = TomahawkSettings::Lan;
switch( mode )
{
@ -181,7 +174,6 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
QString
Servent::createConnectionKey( const QString& name, const QString &nodeid, const QString &key, bool onceOnly )
{
// qDebug() << Q_FUNC_INFO;
Q_ASSERT( this->thread() == QThread::currentThread() );
QString _key = ( key.isEmpty() ? uuid() : key );
@ -191,7 +183,7 @@ Servent::createConnectionKey( const QString& name, const QString &nodeid, const
cc->setId( nodeid );
cc->setOnceOnly( onceOnly );
qDebug() << "Creating connection key with name of" << cc->name() << "and id of" << cc->id() << "and key of" << _key << "; key is once only? :" << (onceOnly ? "true" : "false");
tDebug( LOGVERBOSE ) << "Creating connection key with name of" << cc->name() << "and id of" << cc->id() << "and key of" << _key << "; key is once only? :" << (onceOnly ? "true" : "false");
registerOffer( _key, cc );
return _key;
}
@ -205,7 +197,7 @@ Servent::setExternalAddress( QHostAddress ha, unsigned int port )
{
if ( ip.startsWith( "10." ) || ip.startsWith( "172.16." ) || ip.startsWith( "192.168." ) )
{
qDebug() << Q_FUNC_INFO << "Tried to set an invalid ip as external address!";
tDebug() << Q_FUNC_INFO << "Tried to set an invalid ip as external address!";
return;
}
@ -223,10 +215,9 @@ Servent::setExternalAddress( QHostAddress ha, unsigned int port )
if ( !TomahawkSettings::instance()->externalHostname().isEmpty() &&
!TomahawkSettings::instance()->externalPort() == 0 )
{
qDebug() << "UPnP failed, have external address/port -- falling back";
m_externalHostname = TomahawkSettings::instance()->externalHostname();
m_externalPort = TomahawkSettings::instance()->externalPort();
qDebug() << m_externalHostname << m_externalPort;
tDebug() << "UPnP failed, have external address/port - falling back" << m_externalHostname << m_externalPort << m_externalAddress;
}
else
tLog() << "No external access, LAN and outbound connections only!";
@ -247,7 +238,6 @@ Servent::registerOffer( const QString& key, Connection* conn )
void
Servent::registerControlConnection( ControlConnection* conn )
{
// qDebug() << Q_FUNC_INFO << conn->id();
m_controlconnections.append( conn );
}
@ -281,21 +271,19 @@ Servent::incomingConnection( int sd )
Q_ASSERT( this->thread() == QThread::currentThread() );
QTcpSocketExtra* sock = new QTcpSocketExtra;
qDebug() << Q_FUNC_INFO << "Accepting connection, sock" << sock;
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Accepting connection, sock" << sock;
sock->moveToThread( thread() );
sock->_disowned = false;
sock->_outbound = false;
if( !sock->setSocketDescriptor( sd ) )
{
qDebug() << "Out of system resources for new ports?";
Q_ASSERT( false );
return;
}
connect( sock, SIGNAL( readyRead() ), SLOT( readyRead() ) );
connect( sock, SIGNAL( disconnected() ), sock, SLOT( deleteLater() ) );
// qDebug() << "connection accepted.";
}
@ -304,12 +292,10 @@ Servent::readyRead()
{
Q_ASSERT( this->thread() == QThread::currentThread() );
QTcpSocketExtra* sock = (QTcpSocketExtra*)sender();
//qDebug() << Q_FUNC_INFO << thread() << sock;
if( sock->_disowned )
{
//qDebug() << "Socket already disowned";
return ;
return;
}
if( sock->_msg.isNull() )
@ -336,7 +322,7 @@ Servent::readyRead()
QVariantMap m = parser.parse( sock->_msg->payload(), &ok ).toMap();
if( !ok )
{
qDebug() << "Invalid JSON on new conection, aborting";
tDebug() << "Invalid JSON on new connection, aborting";
goto closeconnection;
}
conntype = m.value( "conntype" ).toString();
@ -345,13 +331,12 @@ Servent::readyRead()
nodeid = m.value( "nodeid" ).toString();
controlid = m.value( "controlid" ).toString();
qDebug() << "Incoming connection details:" << m;
tDebug( LOGVERBOSE ) << "Incoming connection details:" << m;
if( !nodeid.isEmpty() ) // only control connections send nodeid
{
foreach( ControlConnection* con, m_controlconnections )
{
// qDebug() << con->socket() << sock;
if( con->id() == nodeid )
{
tLog() << "Duplicate control connection detected, dropping:" << nodeid << conntype;
@ -362,8 +347,6 @@ Servent::readyRead()
foreach( ControlConnection* con, m_controlconnections )
{
// qDebug() << "conid:" << con->id();
if ( con->id() == controlid )
{
cc = con;
@ -381,7 +364,7 @@ Servent::readyRead()
tLog() << "claimOffer FAILED, key:" << key;
goto closeconnection;
}
qDebug() << "claimOffer OK:" << key;
tDebug( LOGVERBOSE ) << "claimOffer OK:" << key;
if( !nodeid.isEmpty() )
conn->setId( nodeid );
@ -391,7 +374,7 @@ Servent::readyRead()
}
else
{
qDebug() << "Invalid or unhandled conntype";
tLog() << "Invalid or unhandled conntype";
}
// fallthru to cleanup:
@ -407,11 +390,10 @@ closeconnection:
void
Servent::createParallelConnection( Connection* orig_conn, Connection* new_conn, const QString& key )
{
qDebug() << "Servent::createParallelConnection, key:" << key << thread() << orig_conn;
tDebug( LOGVERBOSE ) << "Servent::createParallelConnection, key:" << key << thread() << orig_conn;
// if we can connect to them directly:
if( orig_conn && orig_conn->outbound() )
{
tLog() << "Connecting directly";
connectToPeer( orig_conn->socket()->peerAddress().toString(),
orig_conn->peerPort(),
key,
@ -441,7 +423,7 @@ Servent::socketConnected()
{
QTcpSocketExtra* sock = (QTcpSocketExtra*)sender();
tDebug() << "Servent::SocketConnected" << thread() << "socket:" << sock;
tDebug( LOGVERBOSE ) << "Servent::SocketConnected" << thread() << "socket:" << sock;
Connection* conn = sock->_conn.data();
handoverSocket( conn, sock );
@ -503,7 +485,6 @@ Servent::socketError( QAbstractSocket::SocketError e )
void
Servent::connectToPeer( const QString& ha, int port, const QString &key, const QString& name, const QString& id )
{
qDebug() << Q_FUNC_INFO << ha << port << key << name << id;
Q_ASSERT( this->thread() == QThread::currentThread() );
ControlConnection* conn = new ControlConnection( this );
@ -526,12 +507,11 @@ Servent::connectToPeer( const QString& ha, int port, const QString &key, const Q
void
Servent::connectToPeer( const QString& ha, int port, const QString &key, Connection* conn )
{
qDebug() << "Servent::connectToPeer:" << ha << ":" << port
<< thread() << QThread::currentThread();
tDebug( LOGVERBOSE ) << "Servent::connectToPeer:" << ha << ":" << port
<< thread() << QThread::currentThread();
Q_ASSERT( port > 0 );
Q_ASSERT( conn );
// Q_ASSERT( this->thread() == QThread::currentThread() );
if ( ( ha == m_externalAddress.toString() || ha == m_externalHostname ) &&
( port == m_externalPort ) )
@ -554,16 +534,13 @@ Servent::connectToPeer( const QString& ha, int port, const QString &key, Connect
sock->_disowned = false;
sock->_conn = conn;
sock->_outbound = true;
//qDebug() << "connectToPeer, sock:" << sock->thread();
connect( sock, SIGNAL( connected() ), SLOT( socketConnected() ) );
connect( sock, SIGNAL( error( QAbstractSocket::SocketError ) ),
SLOT( socketError( QAbstractSocket::SocketError ) ) );
//qDebug() << "About to connectToHost...";
sock->connectToHost( ha, port, QTcpSocket::ReadWrite );
sock->moveToThread( thread() );
//qDebug() << "tried to connectToHost (waiting on a connected signal)";
}
@ -572,11 +549,11 @@ Servent::reverseOfferRequest( ControlConnection* orig_conn, const QString& their
{
Q_ASSERT( this->thread() == QThread::currentThread() );
qDebug() << "Servent::reverseOfferRequest received for" << key;
tDebug( LOGVERBOSE ) << "Servent::reverseOfferRequest received for" << key;
Connection* new_conn = claimOffer( orig_conn, theirdbid, key );
if ( !new_conn )
{
qDebug() << "claimOffer failed, killing requesting connection out of spite";
tDebug() << "claimOffer failed, killing requesting connection out of spite";
orig_conn->shutdown();
return;
}
@ -595,8 +572,6 @@ Servent::reverseOfferRequest( ControlConnection* orig_conn, const QString& their
Connection*
Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString &key, const QHostAddress peer )
{
// qDebug() << Q_FUNC_INFO;
bool noauth = qApp->arguments().contains( "--noauth" );
// magic key for stream connections:
@ -630,14 +605,14 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
{
if( isIPWhitelisted( peer ) )
{
qDebug() << "Connection is from whitelisted IP range (LAN)";
tDebug() << "Connection is from whitelisted IP range (LAN)";
Connection* conn = new ControlConnection( this );
conn->setName( peer.toString() );
return conn;
}
else
{
qDebug() << "Connection claimed to be whitelisted, but wasn't.";
tDebug() << "Connection claimed to be whitelisted, but wasn't.";
return NULL;
}
}
@ -664,8 +639,6 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
}
}
tLog() << "ACL has allowed the connection";
if( conn->onceOnly() )
{
m_offers.remove( key );
@ -694,7 +667,7 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
bool
Servent::checkACL( const Connection* conn, const QString &nodeid, bool showDialog ) const
{
qDebug() << "Checking ACLs";
tDebug( LOGVERBOSE ) << "Checking ACLs";
ACLSystem* aclSystem = ACLSystem::instance();
ACLSystem::ACL peerStatus = aclSystem->isAuthorizedUser( nodeid );
@ -709,7 +682,6 @@ Servent::checkACL( const Connection* conn, const QString &nodeid, bool showDialo
if( !showDialog )
return false;
qDebug() << "ACL for this node not found";
QMessageBox msgBox;
msgBox.setIcon( QMessageBox::Question );
msgBox.setText( tr( "Incoming Connection Attempt" ) );
@ -740,7 +712,7 @@ Servent::checkACL( const Connection* conn, const QString &nodeid, bool showDialo
return true;
//How could we get here?
qDebug() << "Somehow no button matched";
Q_ASSERT( false );
return false;
}
#endif
@ -752,7 +724,6 @@ Servent::checkACL( const Connection* conn, const QString &nodeid, bool showDialo
QSharedPointer<QIODevice>
Servent::remoteIODeviceFactory( const result_ptr& result )
{
// qDebug() << Q_FUNC_INFO << thread();
QSharedPointer<QIODevice> sp;
QStringList parts = result->url().mid( QString( "servent://" ).length() ).split( "\t" );
@ -773,7 +744,7 @@ void
Servent::registerStreamConnection( StreamConnection* sc )
{
Q_ASSERT( !m_scsessions.contains( sc ) );
qDebug() << "Registering Stream" << m_scsessions.length() + 1;
tDebug( LOGVERBOSE ) << "Registering Stream" << m_scsessions.length() + 1;
QMutexLocker lock( &m_ftsession_mut );
m_scsessions.append( sc );
@ -787,7 +758,7 @@ void
Servent::onStreamFinished( StreamConnection* sc )
{
Q_ASSERT( sc );
qDebug() << "Stream Finished, unregistering" << sc->id();
tDebug( LOGVERBOSE ) << "Stream Finished, unregistering" << sc->id();
QMutexLocker lock( &m_ftsession_mut );
m_scsessions.removeAll( sc );
@ -824,7 +795,7 @@ Servent::isIPWhitelisted( QHostAddress ip )
<< range( QHostAddress( "169.254.0.0" ), 16 )
<< range( QHostAddress( "127.0.0.0" ), 24 );
// qDebug() << "Loaded whitelist IP range:" << whitelist;
// tDebug( LOGVERBOSE ) << "Loaded whitelist IP range:" << whitelist;
}
foreach( const range& r, whitelist )
@ -838,10 +809,8 @@ Servent::isIPWhitelisted( QHostAddress ip )
bool
Servent::connectedToSession( const QString& session )
{
// qDebug() << "Checking against" << session;
foreach( ControlConnection* cc, m_controlconnections )
{
// qDebug() << "Checking session" << cc->id();
if( cc->id() == session )
return true;
}
@ -871,7 +840,6 @@ void
Servent::registerIODeviceFactory( const QString &proto, boost::function<QSharedPointer<QIODevice>(Tomahawk::result_ptr)> fac )
{
m_iofactories.insert( proto, fac );
qDebug() << "Registered IODevice Factory for" << proto;
}
@ -885,10 +853,9 @@ Servent::getIODeviceForUrl( const Tomahawk::result_ptr& result )
return sp;
const QString proto = rx.cap( 1 );
//const QString urlpart = rx.cap( 2 );
// qDebug() << "Getting IODevice for URL:" << proto << m_iofactories.contains( proto );
if ( !m_iofactories.contains( proto ) )
return sp;
return m_iofactories.value( proto )( result );
}

View File

@ -337,7 +337,7 @@ Pipeline::shunt( const query_ptr& q )
if ( r )
{
tLog( LOGEXTRA ) << "Dispatching to resolver" << r->name() << q->toString() << q->solved() << q->id();
tLog( LOGVERBOSE ) << "Dispatching to resolver" << r->name() << q->toString() << q->solved() << q->id();
q->setCurrentResolver( r );
r->resolve( q );

View File

@ -31,6 +31,7 @@
#include "utils/logger.h"
BreadcrumbBar::BreadcrumbBar(BreadcrumbButtonFactory *buttonFactory, QWidget *parent)
: QWidget(parent)
, m_model(0)
@ -53,6 +54,7 @@ BreadcrumbBar::BreadcrumbBar(BreadcrumbButtonFactory *buttonFactory, QWidget *pa
show();
}
BreadcrumbBar::BreadcrumbBar(QWidget *parent)
: QWidget(parent)
, m_model(0)
@ -75,20 +77,25 @@ BreadcrumbBar::BreadcrumbBar(QWidget *parent)
show();
}
BreadcrumbBar::~BreadcrumbBar()
{
}
void BreadcrumbBar::setButtonFactory(BreadcrumbButtonFactory *buttonFactory)
{
tDebug() << "Breadcrumbbar:: got me some button factory!";
tDebug( LOGVERBOSE ) << "Breadcrumbbar:: got me some button factory!";
m_buttonFactory = buttonFactory;
}
BreadcrumbButtonFactory* BreadcrumbBar::buttonFactory() const
{
return m_buttonFactory;
}
void BreadcrumbBar::appendButton(BreadcrumbButtonBase *widget, int stretch)
{
m_layout->insertWidget(m_layout->count(), widget, stretch);
@ -110,6 +117,7 @@ void BreadcrumbBar::appendButton(BreadcrumbButtonBase *widget, int stretch)
}
}
void BreadcrumbBar::deleteAnimationFinished()
{
QPropertyAnimation *anim = qobject_cast<QPropertyAnimation*>(sender());
@ -121,6 +129,7 @@ void BreadcrumbBar::deleteAnimationFinished()
anim->deleteLater();
}
void BreadcrumbBar::deleteButton(BreadcrumbButtonBase *widget)
{
if( !m_useAnimation ) {
@ -144,13 +153,16 @@ void BreadcrumbBar::deleteButton(BreadcrumbButtonBase *widget)
widget->deleteLater();
}
}
void BreadcrumbBar::updateButtons()
{
tDebug() << "Breadcrumbbar:: updateButtons" << m_buttonFactory << m_selectionModel ;
if(m_selectionModel )
tDebug() <<"Breadcrumbbar:: update buttoms current index"<< m_selectionModel->currentIndex().isValid();
if (!m_buttonFactory || !m_selectionModel || !m_selectionModel->currentIndex().isValid()) {
tDebug() << "Breadcrumb:: updatebuttons failed!";
tDebug( LOGVERBOSE ) << "Breadcrumbbar:: updateButtons" << m_buttonFactory << m_selectionModel ;
if ( m_selectionModel )
tDebug( LOGVERBOSE ) <<"Breadcrumbbar:: update buttoms current index"<< m_selectionModel->currentIndex().isValid();
if ( !m_buttonFactory || !m_selectionModel || !m_selectionModel->currentIndex().isValid() )
{
tDebug( LOGVERBOSE ) << "Breadcrumb:: updatebuttons failed!";
return;
}
@ -165,7 +177,7 @@ void BreadcrumbBar::updateButtons()
indexes.prepend(index);
index = index.parent();
}
tDebug() << "BreadcrumbBar::updateButtons:: " << index.data().toString();
tDebug( LOGVERBOSE ) << "BreadcrumbBar::updateButtons:: " << index.data().toString();
indexes.prepend(index);
int count = indexes.size(), i = 0;
@ -205,6 +217,7 @@ void BreadcrumbBar::updateButtons()
adjustSize();
}
void BreadcrumbBar::collapseButtons()
{
foreach (BreadcrumbButtonBase *button, m_navButtons) {
@ -224,6 +237,7 @@ void BreadcrumbBar::collapseButtons()
}
}
void BreadcrumbBar::clearButtons()
{
foreach (BreadcrumbButtonBase *button, m_navButtons)
@ -234,11 +248,13 @@ void BreadcrumbBar::clearButtons()
m_navButtons.clear();
}
void BreadcrumbBar::currentIndexChanged()
{
updateButtons();
}
void BreadcrumbBar::setRootIcon(const QIcon &icon)
{
@ -252,6 +268,7 @@ void BreadcrumbBar::setRootIcon(const QIcon &icon)
connect(button, SIGNAL(clicked()), this, SIGNAL(rootClicked()));
}
void BreadcrumbBar::setRootText(const QString &text)
{
//TODO: implement this
@ -263,27 +280,32 @@ void BreadcrumbBar::setRootText(const QString &text)
m_layout->insertSpacing(2,5);*/
}
void BreadcrumbBar::setUseAnimation(bool use)
{
m_useAnimation = use;
}
bool BreadcrumbBar::useAnimation() const
{
return m_useAnimation;
}
void BreadcrumbBar::setModel(QAbstractItemModel *model)
{
m_model = model;
updateButtons();
}
QAbstractItemModel* BreadcrumbBar::model()
{
return m_model;
}
void BreadcrumbBar::setSelectionModel(QItemSelectionModel *selectionModel)
{
m_selectionModel = selectionModel;
@ -294,16 +316,19 @@ void BreadcrumbBar::setSelectionModel(QItemSelectionModel *selectionModel)
updateButtons();
}
QItemSelectionModel* BreadcrumbBar::selectionModel()
{
return m_selectionModel;
}
QModelIndex BreadcrumbBar::currentIndex()
{
return m_selectionModel->currentIndex();
}
void BreadcrumbBar::currentChangedTriggered(QModelIndex const& index)
{
Q_ASSERT(m_selectionModel);
@ -311,6 +336,7 @@ void BreadcrumbBar::currentChangedTriggered(QModelIndex const& index)
emit currentIndexChanged(index);
}
void BreadcrumbBar::resizeEvent ( QResizeEvent * event )
{
collapseButtons();

View File

@ -46,6 +46,7 @@ using namespace Tomahawk;
static QString s_whatsHotIdentifier = QString( "WhatsHotWidget" );
WhatsHotWidget::WhatsHotWidget( QWidget* parent )
: QWidget( parent )
, ui( new Ui::WhatsHotWidget )
@ -127,6 +128,7 @@ WhatsHotWidget::~WhatsHotWidget()
delete ui;
}
void
WhatsHotWidget::fetchData()
{
@ -140,7 +142,7 @@ WhatsHotWidget::fetchData()
requestData.type = Tomahawk::InfoSystem::InfoChartCapabilities;
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
tDebug() << "WhatsHot: requested InfoChartCapabilities";
tDebug( LOGVERBOSE ) << "WhatsHot: requested InfoChartCapabilities";
}
@ -160,20 +162,21 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
return;
}
tDebug() << "WhatsHot: got something...";
tDebug( LOGVERBOSE ) << "WhatsHot: got something...";
QVariantMap returnedData = output.toMap();
switch ( requestData.type )
{
case InfoSystem::InfoChartCapabilities:
{
tDebug() << "WhatsHot:: info chart capabilities";
tDebug( LOGVERBOSE ) << "WhatsHot:: info chart capabilities";
QStandardItem *rootItem= m_crumbModelLeft->invisibleRootItem();
tDebug() << "WhatsHot:: " << returnedData.keys();
tDebug( LOGVERBOSE ) << "WhatsHot:: " << returnedData.keys();
foreach(const QString label, returnedData.keys()) {
tDebug() << "WhatsHot:: parsing " << label;
foreach( const QString label, returnedData.keys() )
{
tDebug( LOGVERBOSE ) << "WhatsHot:: parsing " << label;
QStandardItem *childItem = parseNode( rootItem, label, returnedData[label] );
tDebug() << "WhatsHot:: appending" << childItem->text();
tDebug( LOGVERBOSE ) << "WhatsHot:: appending" << childItem->text();
rootItem->appendRow(childItem);
}
KBreadcrumbSelectionModel *selectionModelLeft = new KBreadcrumbSelectionModel(new QItemSelectionModel(m_crumbModelLeft, this), this);
@ -192,28 +195,36 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
if( !returnedData.contains(type) )
break;
const QString side = requestData.customData["whatshot_side"].toString();
tDebug() << "WhatsHot: got chart! " << type << " on " << side;
if( type == "artists" ) {
tDebug( LOGVERBOSE ) << "WhatsHot: got chart! " << type << " on " << side;
if( type == "artists" )
{
setLeftViewArtists();
const QStringList artists = returnedData["artists"].toStringList();
tDebug() << "WhatsHot: got artists! " << artists.size();
tDebug( LOGVERBOSE ) << "WhatsHot: got artists! " << artists.size();
m_artistsModel->clear();
foreach ( const QString& artist, artists )
m_artistsModel->addArtists( Artist::get( artist ) );
} else if( type == "tracks" ) {
}
else if( type == "tracks" )
{
setLeftViewTracks();
const QList<Tomahawk::InfoSystem::ArtistTrackPair> tracks = returnedData["tracks"].value<QList<Tomahawk::InfoSystem::ArtistTrackPair> >();
tDebug() << "WhatsHot: got tracks! " << tracks.size();
tDebug( LOGVERBOSE ) << "WhatsHot: got tracks! " << tracks.size();
m_tracksModel->clear();
foreach ( const Tomahawk::InfoSystem::ArtistTrackPair& track, tracks ) {
foreach ( const Tomahawk::InfoSystem::ArtistTrackPair& track, tracks )
{
query_ptr query = Query::get( track.artist, track.track, QString(), uuid() );
m_tracksModel->append( query );
}
} else {
tDebug() << "WhatsHot: got unknown chart type" << type;
}
else
{
tDebug( LOGVERBOSE ) << "WhatsHot: got unknown chart type" << type;
}
break;
}
default:
return;
}
@ -230,7 +241,7 @@ WhatsHotWidget::infoSystemFinished( QString target )
void
WhatsHotWidget::leftCrumbIndexChanged( QModelIndex index )
{
qDebug() << "WhatsHot:: left crumb changed" << index.data();
tDebug( LOGVERBOSE ) << "WhatsHot:: left crumb changed" << index.data();
QStandardItem* item = m_crumbModelLeft->itemFromIndex(index);
if( !item )
return;
@ -254,6 +265,7 @@ WhatsHotWidget::leftCrumbIndexChanged( QModelIndex index )
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
}
void
WhatsHotWidget::changeEvent( QEvent* e )
{
@ -273,42 +285,52 @@ WhatsHotWidget::changeEvent( QEvent* e )
QStandardItem*
WhatsHotWidget::parseNode(QStandardItem* parentItem, const QString &label, const QVariant &data)
{
tDebug() << "WhatsHot:: parsing " << label;
tDebug( LOGVERBOSE ) << "WhatsHot:: parsing " << label;
QStandardItem *sourceItem = new QStandardItem(label);
if( data.canConvert<QList<Tomahawk::InfoSystem::Chart> >() ) {
if( data.canConvert<QList<Tomahawk::InfoSystem::Chart> >() )
{
QList<Tomahawk::InfoSystem::Chart> charts = data.value<QList<Tomahawk::InfoSystem::Chart> >();
foreach( Tomahawk::InfoSystem::Chart chart, charts) {
foreach( Tomahawk::InfoSystem::Chart chart, charts)
{
QStandardItem *childItem= new QStandardItem(chart.label);
childItem->setData(chart.id);
sourceItem->appendRow(childItem);
}
} else if( data.canConvert<QVariantMap>() ) {
} else if( data.canConvert<QVariantMap>() )
{
QVariantMap dataMap = data.toMap();
foreach(const QString childLabel,dataMap.keys()) {
foreach(const QString childLabel,dataMap.keys())
{
QStandardItem *childItem = parseNode( sourceItem, childLabel, dataMap[childLabel] );
sourceItem->appendRow(childItem);
}
} else if ( data.canConvert<QVariantList>() ) {
} else if ( data.canConvert<QVariantList>() )
{
QVariantList dataList = data.toList();
foreach(const QVariant value, dataList) {
foreach(const QVariant value, dataList)
{
QStandardItem *childItem= new QStandardItem(value.toString());
sourceItem->appendRow(childItem);
}
} else {
}
else
{
QStandardItem *childItem= new QStandardItem(data.toString());
sourceItem->appendRow(childItem);
}
return sourceItem;
}
void
WhatsHotWidget::setLeftViewArtists()
{
ui->stackLeft->setCurrentIndex(1);
}
void
WhatsHotWidget::setLeftViewTracks()
{