1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-15 10:33:59 +02:00

* Work in progress: New sidebar with "Super Collection".

* Click the track title in the AudioControls to jump to the current track in the playlist.
* Moved networky stuff to a separate subdir.
* Don't crash on jabber error.
* Try to reconnect to jabber server after an error occurred.
This commit is contained in:
Christian Muehlhaeuser
2010-11-11 05:22:58 +01:00
parent 3872477446
commit eed67d9b89
39 changed files with 328 additions and 192 deletions

View File

@@ -36,24 +36,21 @@ public:
virtual QString name() const; virtual QString name() const;
virtual void loadPlaylists() = 0; virtual void loadPlaylists() { qDebug() << Q_FUNC_INFO; }
virtual void loadAllTracks() = 0; virtual void loadTracks() { qDebug() << Q_FUNC_INFO; }
virtual Tomahawk::playlist_ptr playlist( const QString& guid ); virtual Tomahawk::playlist_ptr playlist( const QString& guid );
virtual void addPlaylist( const Tomahawk::playlist_ptr& p ); virtual void addPlaylist( const Tomahawk::playlist_ptr& p );
virtual void deletePlaylist( const Tomahawk::playlist_ptr& p ); virtual void deletePlaylist( const Tomahawk::playlist_ptr& p );
virtual const QList< Tomahawk::playlist_ptr >& playlists() const { return m_playlists; } virtual QList< Tomahawk::playlist_ptr > playlists() { return m_playlists; }
virtual QList< Tomahawk::query_ptr > tracks() { return m_tracks; }
bool isLoaded() const { return m_loaded; }
const source_ptr& source() const { return m_source; } const source_ptr& source() const { return m_source; }
unsigned int lastmodified() const { return m_lastmodified; } unsigned int lastmodified() const { return m_lastmodified; }
static bool trackSorter( const QVariant& left, const QVariant &right );
signals: signals:
void tracksAdded( const QList<QVariant>&, const Tomahawk::collection_ptr& ); void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& );
void tracksRemoved( const QList<QVariant>&, const Tomahawk::collection_ptr& ); void tracksRemoved( const QList<QVariant>&, const Tomahawk::collection_ptr& );
void tracksFinished( const Tomahawk::collection_ptr& ); void tracksFinished( const Tomahawk::collection_ptr& );
@@ -64,25 +61,17 @@ public slots:
virtual void addTracks( const QList<QVariant> &newitems ) = 0; virtual void addTracks( const QList<QVariant> &newitems ) = 0;
virtual void removeTracks( const QList<QVariant> &olditems ) = 0; virtual void removeTracks( const QList<QVariant> &olditems ) = 0;
void setPlaylists( const QList<Tomahawk::playlist_ptr>& plists ) void setPlaylists( const QList<Tomahawk::playlist_ptr>& plists );
{ void setTracks( const QList<QVariant>& tracks, Tomahawk::collection_ptr collection );
qDebug() << Q_FUNC_INFO << plists.length();
m_playlists.append( plists );
if( !m_loaded )
{
m_loaded = true;
emit playlistsAdded( plists );
}
}
protected: protected:
QString m_name; QString m_name;
bool m_loaded;
unsigned int m_lastmodified; // unix time of last change to collection unsigned int m_lastmodified; // unix time of last change to collection
private: private:
source_ptr m_source; source_ptr m_source;
QList< Tomahawk::playlist_ptr > m_playlists; QList< Tomahawk::playlist_ptr > m_playlists;
QList< Tomahawk::query_ptr > m_tracks;
}; };
}; // ns }; // ns

View File

@@ -43,17 +43,18 @@ SET( tomahawkSources ${tomahawkSources}
infosystem/infoplugins/musixmatchplugin.cpp infosystem/infoplugins/musixmatchplugin.cpp
bufferiodevice.cpp bufferiodevice.cpp
connection.cpp
msgprocessor.cpp msgprocessor.cpp
controlconnection.cpp
collection.cpp collection.cpp
filetransferconnection.cpp
dbsyncconnection.cpp
musicscanner.cpp musicscanner.cpp
remotecollection.cpp
servent.cpp
scriptresolver.cpp scriptresolver.cpp
network/connection.cpp
network/controlconnection.cpp
network/filetransferconnection.cpp
network/dbsyncconnection.cpp
network/remotecollection.cpp
network/servent.cpp
database/fuzzyindex.cpp database/fuzzyindex.cpp
database/database.cpp database/database.cpp
database/databaseworker.cpp database/databaseworker.cpp
@@ -94,6 +95,8 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
utils/imagebutton.cpp utils/imagebutton.cpp
utils/progresstreeview.cpp utils/progresstreeview.cpp
utils/proxystyle.cpp
utils/widgetdragfilter.cpp
audio/madtranscode.cpp audio/madtranscode.cpp
audio/audioengine.cpp audio/audioengine.cpp
@@ -126,9 +129,6 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
tomahawkwindow.cpp tomahawkwindow.cpp
audiocontrols.cpp audiocontrols.cpp
settingsdialog.cpp settingsdialog.cpp
proxystyle.cpp
widgetdragfilter.cpp
) )
SET( tomahawkHeaders ${tomahawkHeaders} SET( tomahawkHeaders ${tomahawkHeaders}
@@ -186,17 +186,18 @@ SET( tomahawkHeaders ${tomahawkHeaders}
infosystem/infoplugins/musixmatchplugin.h infosystem/infoplugins/musixmatchplugin.h
bufferiodevice.h bufferiodevice.h
connection.h
msgprocessor.h msgprocessor.h
controlconnection.h
filetransferconnection.h
dbsyncconnection.h
musicscanner.h musicscanner.h
tomahawkzeroconf.h
remotecollection.h
servent.h
scriptresolver.h scriptresolver.h
tomahawksettings.h tomahawksettings.h
tomahawkzeroconf.h
network/remotecollection.h
network/servent.h
network/connection.h
network/controlconnection.h
network/filetransferconnection.h
network/dbsyncconnection.h
xmppbot/xmppbot.h xmppbot/xmppbot.h
@@ -209,6 +210,7 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
utils/animatedcounterlabel.h utils/animatedcounterlabel.h
utils/imagebutton.h utils/imagebutton.h
utils/progresstreeview.h utils/progresstreeview.h
utils/widgetdragfilter.h
audio/transcodeinterface.h audio/transcodeinterface.h
audio/madtranscode.h audio/madtranscode.h
@@ -243,8 +245,6 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
tomahawkwindow.h tomahawkwindow.h
audiocontrols.h audiocontrols.h
settingsdialog.h settingsdialog.h
widgetdragfilter.h
) )
SET( tomahawkUI ${tomahawkUI} SET( tomahawkUI ${tomahawkUI}
@@ -265,6 +265,7 @@ INCLUDE_DIRECTORIES(
audio audio
database database
playlist playlist
network
sourcetree sourcetree
topbar topbar
utils utils

View File

@@ -119,6 +119,8 @@ AudioControls::AudioControls( QWidget* parent )
connect( ui->repeatButton, SIGNAL( clicked() ), SLOT( onRepeatClicked() ) ); connect( ui->repeatButton, SIGNAL( clicked() ), SLOT( onRepeatClicked() ) );
connect( ui->shuffleButton, SIGNAL( clicked() ), SLOT( onShuffleClicked() ) ); connect( ui->shuffleButton, SIGNAL( clicked() ), SLOT( onShuffleClicked() ) );
connect( ui->artistTrackLabel, SIGNAL( linkActivated( QString ) ), SLOT( onTrackClicked( QString ) ) );
// <From AudioEngine> // <From AudioEngine>
connect( (QObject*)TomahawkApp::instance()->audioEngine(), SIGNAL( loading( const Tomahawk::result_ptr& ) ), SLOT( onPlaybackLoading( const Tomahawk::result_ptr& ) ) ); connect( (QObject*)TomahawkApp::instance()->audioEngine(), SIGNAL( loading( const Tomahawk::result_ptr& ) ), SLOT( onPlaybackLoading( const Tomahawk::result_ptr& ) ) );
connect( (QObject*)TomahawkApp::instance()->audioEngine(), SIGNAL( started( const Tomahawk::result_ptr& ) ), SLOT( onPlaybackStarted( const Tomahawk::result_ptr& ) ) ); connect( (QObject*)TomahawkApp::instance()->audioEngine(), SIGNAL( started( const Tomahawk::result_ptr& ) ), SLOT( onPlaybackStarted( const Tomahawk::result_ptr& ) ) );
@@ -221,7 +223,7 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
m_currentTrack = result; m_currentTrack = result;
ui->artistTrackLabel->setText( QString( "%1 - %2" ).arg( result->artist() ).arg( result->track() ) ); ui->artistTrackLabel->setText( "<a style='color:black; text-decoration:none;' href='#'>" + QString( "%1 - %2" ).arg( result->artist() ).arg( result->track() ) + "</a>" );
ui->albumLabel->setText( result->album() ); ui->albumLabel->setText( result->album() );
ui->ownerLabel->setText( result->collection()->source()->friendlyName() ); ui->ownerLabel->setText( result->collection()->source()->friendlyName() );
ui->coverImage->setPixmap( m_defaultCover ); ui->coverImage->setPixmap( m_defaultCover );
@@ -402,3 +404,10 @@ AudioControls::onShuffleClicked()
{ {
APP->playlistManager()->setShuffled( m_shuffled ^ true ); APP->playlistManager()->setShuffled( m_shuffled ^ true );
} }
void
AudioControls::onTrackClicked( const QString& /* link */ )
{
APP->playlistManager()->showCurrentTrack();
}

View File

@@ -38,6 +38,8 @@ private slots:
void onRepeatClicked(); void onRepeatClicked();
void onShuffleClicked(); void onShuffleClicked();
void onTrackClicked( const QString& link );
void onCoverArtDownloaded(); void onCoverArtDownloaded();
private: private:

View File

@@ -11,7 +11,6 @@ using namespace Tomahawk;
Collection::Collection( const source_ptr& source, const QString& name, QObject* parent ) Collection::Collection( const source_ptr& source, const QString& name, QObject* parent )
: QObject( parent ) : QObject( parent )
, m_name( name ) , m_name( name )
, m_loaded( false )
, m_lastmodified( 0 ) , m_lastmodified( 0 )
, m_source( source ) , m_source( source )
{ {
@@ -75,20 +74,37 @@ Collection::playlist( const QString& guid )
} }
bool void
Collection::trackSorter( const QVariant& left, const QVariant& right ) Collection::setPlaylists( const QList<Tomahawk::playlist_ptr>& plists )
{ {
int art = left.toMap().value( "artist" ).toString() qDebug() << Q_FUNC_INFO << plists.count();
.localeAwareCompare( right.toMap().value( "artist" ).toString() );
if ( art == 0 ) m_playlists.append( plists );
{ emit playlistsAdded( plists );
int trk = left.toMap().value( "track" ).toString() }
.localeAwareCompare( right.toMap().value( "track" ).toString() );
return trk < 0;
} void
else Collection::setTracks( const QList<QVariant>& tracks, Tomahawk::collection_ptr collection )
{ {
return art < 0; qDebug() << Q_FUNC_INFO << tracks.count() << collection->name();
}
QList<query_ptr> qs;
foreach( const QVariant& v, tracks )
{
query_ptr query = query_ptr( new Query( v ) );
QVariantMap t = query->toVariant().toMap();
t["score"] = 1.0;
QList<result_ptr> results;
result_ptr result = result_ptr( new Result( t, collection ) );
results << result;
query->addResults( results );
qs << query;
}
m_tracks << qs;
emit tracksAdded( qs, collection );
} }

View File

@@ -31,14 +31,14 @@ DatabaseCollection::loadPlaylists()
void void
DatabaseCollection::loadAllTracks() DatabaseCollection::loadTracks()
{ {
qDebug() << Q_FUNC_INFO << source()->userName(); qDebug() << Q_FUNC_INFO << source()->userName();
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( source()->collection() ); DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( source()->collection() );
connect( cmd, SIGNAL( tracks( QList<QVariant>, Tomahawk::collection_ptr ) ), connect( cmd, SIGNAL( tracks( QList<QVariant>, Tomahawk::collection_ptr ) ),
SIGNAL( tracksAdded( QList<QVariant>, Tomahawk::collection_ptr ) ) ); SLOT( setTracks( QList<QVariant>, Tomahawk::collection_ptr ) ) );
connect( cmd, SIGNAL( done( Tomahawk::collection_ptr ) ), /* connect( cmd, SIGNAL( done( Tomahawk::collection_ptr ) ),
SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ) ); SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ) );*/
TomahawkApp::instance()->database()->enqueue( TomahawkApp::instance()->database()->enqueue(
QSharedPointer<DatabaseCommand>( cmd ) QSharedPointer<DatabaseCommand>( cmd )
@@ -66,3 +66,31 @@ DatabaseCollection::removeTracks( const QList<QVariant> &olditems )
// TODO RemoveTracks cmd, probably builds a temp table of all the URLs in // TODO RemoveTracks cmd, probably builds a temp table of all the URLs in
// olditems, then joins on that to batch-delete. // olditems, then joins on that to batch-delete.
} }
QList< Tomahawk::playlist_ptr >
DatabaseCollection::playlists()
{
qDebug() << Q_FUNC_INFO;
if ( Collection::playlists().isEmpty() )
{
loadPlaylists();
}
return Collection::playlists();
}
QList< Tomahawk::query_ptr >
DatabaseCollection::tracks()
{
qDebug() << Q_FUNC_INFO;
if ( Collection::tracks().isEmpty() )
{
loadTracks();
}
return Collection::tracks();
}

View File

@@ -15,9 +15,12 @@ public:
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
} }
virtual void loadAllTracks(); virtual void loadTracks();
virtual void loadPlaylists(); virtual void loadPlaylists();
virtual QList< Tomahawk::playlist_ptr > playlists();
virtual QList< Tomahawk::query_ptr > tracks();
public slots: public slots:
virtual void addTracks( const QList<QVariant> &newitems ); virtual void addTracks( const QList<QVariant> &newitems );
virtual void removeTracks( const QList<QVariant> &olditems ); virtual void removeTracks( const QList<QVariant> &olditems );

View File

@@ -40,7 +40,7 @@ DatabaseCommand_AddFiles::postCommitHook()
Collection* coll = source()->collection().data(); Collection* coll = source()->collection().data();
connect( this, SIGNAL( notify( const QList<QVariant>&, Tomahawk::collection_ptr ) ), connect( this, SIGNAL( notify( const QList<QVariant>&, Tomahawk::collection_ptr ) ),
coll, SIGNAL( tracksAdded( const QList<QVariant>&, Tomahawk::collection_ptr ) ), coll, SIGNAL( setTracks( const QList<QVariant>&, Tomahawk::collection_ptr ) ),
Qt::QueuedConnection ); Qt::QueuedConnection );
// do it like this so it gets called in the right thread: // do it like this so it gets called in the right thread:
emit notify( m_files, source()->collection() ); emit notify( m_files, source()->collection() );

View File

@@ -2,6 +2,7 @@
#include <QDebug> #include <QDebug>
#include <QTime> #include <QTime>
#include <QTimer>
#include <QString> #include <QString>
#include <QRegExp> #include <QRegExp>
@@ -56,7 +57,7 @@ Jabber_p::Jabber_p( const QString& jid, const QString& password, const QString&
Jabber_p::~Jabber_p() Jabber_p::~Jabber_p()
{ {
// qDebug() << Q_FUNC_INFO; // qDebug() << Q_FUNC_INFO;
if( m_client ) if ( !m_client.isNull() )
{ {
// m_client->disco()->removeDiscoHandler( this ); // m_client->disco()->removeDiscoHandler( this );
m_client->rosterManager()->removeRosterListener(); m_client->rosterManager()->removeRosterListener();
@@ -70,16 +71,16 @@ Jabber_p::setProxy( QNetworkProxy* proxy )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
if( !m_client || !proxy ) if( !m_client.isNull() || !proxy )
{ {
qDebug() << "No client or no proxy"; qDebug() << "No client or no proxy";
return; return;
} }
QNetworkProxy appProx = QNetworkProxy::applicationProxy(); QNetworkProxy appProx = QNetworkProxy::applicationProxy();
QNetworkProxy* prox = proxy->type() == QNetworkProxy::DefaultProxy ? &appProx : proxy; QNetworkProxy* p = proxy->type() == QNetworkProxy::DefaultProxy ? &appProx : proxy;
if( prox->type() == QNetworkProxy::NoProxy ) if( p->type() == QNetworkProxy::NoProxy )
{ {
qDebug() << "Setting proxy to none"; qDebug() << "Setting proxy to none";
m_client->setConnectionImpl( new gloox::ConnectionTCPClient( m_client.data(), m_client->logInstance(), m_client->server(), m_client->port() ) ); m_client->setConnectionImpl( new gloox::ConnectionTCPClient( m_client.data(), m_client->logInstance(), m_client->server(), m_client->port() ) );
@@ -120,10 +121,10 @@ Jabber_p::go()
// Handle proxy // Handle proxy
if( m_client->connect( false ) ) if ( m_client->connect( false ) )
{ {
emit connected(); emit connected();
m_timer.singleShot(0, this, SLOT(doJabberRecv())); QTimer::singleShot( 0, this, SLOT( doJabberRecv() ) );
} }
} }
@@ -131,14 +132,17 @@ Jabber_p::go()
void void
Jabber_p::doJabberRecv() Jabber_p::doJabberRecv()
{ {
ConnectionError ce = m_client->recv(100); if ( m_client.isNull() )
if( ce != ConnNoError ) return;
ConnectionError ce = m_client->recv( 100 );
if ( ce != ConnNoError )
{ {
qDebug() << "Jabber_p::Recv failed, disconnected"; qDebug() << "Jabber_p::Recv failed, disconnected";
} }
else else
{ {
m_timer.singleShot(100, this, SLOT(doJabberRecv())); QTimer::singleShot( 100, this, SLOT( doJabberRecv() ) );
} }
} }
@@ -146,7 +150,7 @@ Jabber_p::doJabberRecv()
void void
Jabber_p::disconnect() Jabber_p::disconnect()
{ {
if ( m_client ) if ( !m_client.isNull() )
{ {
m_client->disconnect(); m_client->disconnect();
} }
@@ -156,7 +160,7 @@ Jabber_p::disconnect()
void void
Jabber_p::sendMsg( const QString& to, const QString& msg ) Jabber_p::sendMsg( const QString& to, const QString& msg )
{ {
if( QThread::currentThread() != thread() ) if ( QThread::currentThread() != thread() )
{ {
qDebug() << Q_FUNC_INFO << "invoking in correct thread, not" qDebug() << Q_FUNC_INFO << "invoking in correct thread, not"
<< QThread::currentThread(); << QThread::currentThread();
@@ -169,8 +173,12 @@ Jabber_p::sendMsg( const QString& to, const QString& msg )
return; return;
} }
if ( m_client.isNull() )
return;
qDebug() << Q_FUNC_INFO << to << msg; qDebug() << Q_FUNC_INFO << to << msg;
Message m( Message::Chat, JID(to.toStdString()), msg.toStdString(), "" ); Message m( Message::Chat, JID(to.toStdString()), msg.toStdString(), "" );
m_client->send( m ); // assuming this is threadsafe m_client->send( m ); // assuming this is threadsafe
} }
@@ -178,7 +186,7 @@ Jabber_p::sendMsg( const QString& to, const QString& msg )
void void
Jabber_p::broadcastMsg( const QString &msg ) Jabber_p::broadcastMsg( const QString &msg )
{ {
if( QThread::currentThread() != thread() ) if ( QThread::currentThread() != thread() )
{ {
QMetaObject::invokeMethod( this, "broadcastMsg", QMetaObject::invokeMethod( this, "broadcastMsg",
Qt::QueuedConnection, Qt::QueuedConnection,
@@ -186,6 +194,10 @@ Jabber_p::broadcastMsg( const QString &msg )
); );
return; return;
} }
if ( m_client.isNull() )
return;
std::string msg_s = msg.toStdString(); std::string msg_s = msg.toStdString();
foreach( const QString& jidstr, m_peers.keys() ) foreach( const QString& jidstr, m_peers.keys() )
{ {
@@ -202,7 +214,7 @@ Jabber_p::onConnect()
{ {
// update jid resource, servers like gtalk use resource binding and may // update jid resource, servers like gtalk use resource binding and may
// have changed our requested /resource // have changed our requested /resource
if( m_client->resource() != m_jid.resource() ) if ( m_client->resource() != m_jid.resource() )
{ {
m_jid.setResource( m_client->resource() ); m_jid.setResource( m_client->resource() );
QString jidstr( m_jid.full().c_str() ); QString jidstr( m_jid.full().c_str() );
@@ -218,15 +230,18 @@ Jabber_p::onDisconnect( ConnectionError e )
{ {
qDebug() << "Jabber Disconnected"; qDebug() << "Jabber Disconnected";
QString error; QString error;
switch(e)
switch( e )
{ {
case AuthErrorUndefined: case AuthErrorUndefined:
error = " No error occurred, or error condition is unknown"; error = " No error occurred, or error condition is unknown";
break; break;
case SaslAborted: case SaslAborted:
error = "The receiving entity acknowledges an &lt;abort/&gt; element sent " error = "The receiving entity acknowledges an &lt;abort/&gt; element sent "
"by the initiating entity; sent in reply to the &lt;abort/&gt; element."; "by the initiating entity; sent in reply to the &lt;abort/&gt; element.";
break; break;
case SaslIncorrectEncoding: case SaslIncorrectEncoding:
error = "The data provided by the initiating entity could not be processed " error = "The data provided by the initiating entity could not be processed "
"because the [BASE64] encoding is incorrect (e.g., because the encoding " "because the [BASE64] encoding is incorrect (e.g., because the encoding "
@@ -234,6 +249,7 @@ Jabber_p::onDisconnect( ConnectionError e )
"reply to a &lt;response/&gt; element or an &lt;auth/&gt; element with " "reply to a &lt;response/&gt; element or an &lt;auth/&gt; element with "
"initial response data."; "initial response data.";
break; break;
case SaslInvalidAuthzid: case SaslInvalidAuthzid:
error = "The authzid provided by the initiating entity is invalid, either " error = "The authzid provided by the initiating entity is invalid, either "
"because it is incorrectly formatted or because the initiating entity " "because it is incorrectly formatted or because the initiating entity "
@@ -241,58 +257,70 @@ Jabber_p::onDisconnect( ConnectionError e )
"&lt;response/&gt; element or an &lt;auth/&gt; element with initial " "&lt;response/&gt; element or an &lt;auth/&gt; element with initial "
"response data."; "response data.";
break; break;
case SaslInvalidMechanism: case SaslInvalidMechanism:
error = "The initiating entity did not provide a mechanism or requested a " error = "The initiating entity did not provide a mechanism or requested a "
"mechanism that is not supported by the receiving entity; sent in reply " "mechanism that is not supported by the receiving entity; sent in reply "
"to an &lt;auth/&gt; element."; "to an &lt;auth/&gt; element.";
break; break;
case SaslMalformedRequest: case SaslMalformedRequest:
error = "The request is malformed (e.g., the &lt;auth/&gt; element includes " error = "The request is malformed (e.g., the &lt;auth/&gt; element includes "
"an initial response but the mechanism does not allow that); sent in " "an initial response but the mechanism does not allow that); sent in "
"reply to an &lt;abort/&gt;, &lt;auth/&gt;, &lt;challenge/&gt;, or " "reply to an &lt;abort/&gt;, &lt;auth/&gt;, &lt;challenge/&gt;, or "
"&lt;response/&gt; element."; "&lt;response/&gt; element.";
break; break;
case SaslMechanismTooWeak: case SaslMechanismTooWeak:
error = "The mechanism requested by the initiating entity is weaker than " error = "The mechanism requested by the initiating entity is weaker than "
"server policy permits for that initiating entity; sent in reply to a " "server policy permits for that initiating entity; sent in reply to a "
"&lt;response/&gt; element or an &lt;auth/&gt; element with initial " "&lt;response/&gt; element or an &lt;auth/&gt; element with initial "
"response data."; "response data.";
break; break;
case SaslNotAuthorized: case SaslNotAuthorized:
error = "The authentication failed because the initiating entity did not " error = "The authentication failed because the initiating entity did not "
"provide valid credentials (this includes but is not limited to the " "provide valid credentials (this includes but is not limited to the "
"case of an unknown username); sent in reply to a &lt;response/&gt; " "case of an unknown username); sent in reply to a &lt;response/&gt; "
"element or an &lt;auth/&gt; element with initial response data. "; "element or an &lt;auth/&gt; element with initial response data. ";
break; break;
case SaslTemporaryAuthFailure: case SaslTemporaryAuthFailure:
error = "The authentication failed because of a temporary error condition " error = "The authentication failed because of a temporary error condition "
"within the receiving entity; sent in reply to an &lt;auth/&gt; element " "within the receiving entity; sent in reply to an &lt;auth/&gt; element "
"or &lt;response/&gt; element."; "or &lt;response/&gt; element.";
break; break;
case NonSaslConflict: case NonSaslConflict:
error = "XEP-0078: Resource Conflict"; error = "XEP-0078: Resource Conflict";
break; break;
case NonSaslNotAcceptable: case NonSaslNotAcceptable:
error = "XEP-0078: Required Information Not Provided"; error = "XEP-0078: Required Information Not Provided";
break; break;
case NonSaslNotAuthorized: case NonSaslNotAuthorized:
error = "XEP-0078: Incorrect Credentials"; error = "XEP-0078: Incorrect Credentials";
break; break;
case ConnAuthenticationFailed: case ConnAuthenticationFailed:
error = "Authentication failed"; error = "Authentication failed";
break; break;
case ConnNoSupportedAuth: case ConnNoSupportedAuth:
error = "No supported auth mechanism"; error = "No supported auth mechanism";
break; break;
default :
error ="UNKNOWN ERROR";
}
qDebug() << "Connection error msg:" << error;
emit authError(e, error);
default :
error = "UNKNOWN ERROR";
}
qDebug() << "Connection error msg:" << error;
emit authError( e, error );
emit disconnected(); emit disconnected();
// Q_ASSERT(0); //this->exit(1); // trigger reconnect
} }
@@ -322,7 +350,8 @@ Jabber_p::handleMessage( const Message& m, MessageSession * /*session*/ )
QString from = QString::fromStdString( m.from().full() ); QString from = QString::fromStdString( m.from().full() );
QString msg = QString::fromStdString( m.body() ); QString msg = QString::fromStdString( m.body() );
if( msg.length() == 0 ) return; if ( !msg.length() )
return;
qDebug() << "Jabber_p::handleMessage" << from << msg; qDebug() << "Jabber_p::handleMessage" << from << msg;
@@ -340,9 +369,9 @@ void
Jabber_p::handleLog( LogLevel level, LogArea area, const std::string& message ) Jabber_p::handleLog( LogLevel level, LogArea area, const std::string& message )
{ {
qDebug() << Q_FUNC_INFO qDebug() << Q_FUNC_INFO
<< "level:" << level << "level:" << level
<< "area:" << area << "area:" << area
<< "msg:" << message.c_str(); << "msg:" << message.c_str();
} }
@@ -460,7 +489,7 @@ Jabber_p::handleRosterPresence( const RosterItem& item, const std::string& resou
// "going offline" event // "going offline" event
if ( !presenceMeansOnline( presence ) && if ( !presenceMeansOnline( presence ) &&
( !m_peers.contains( fulljid ) || ( !m_peers.contains( fulljid ) ||
presenceMeansOnline( m_peers.value(fulljid) ) presenceMeansOnline( m_peers.value( fulljid ) )
) )
) )
{ {
@@ -571,7 +600,8 @@ Jabber_p::handleDiscoError( const JID& j, const Error* e, int /*context*/ )
/// END DISCO STUFF /// END DISCO STUFF
bool Jabber_p::presenceMeansOnline( Presence::PresenceType p ) bool
Jabber_p::presenceMeansOnline( Presence::PresenceType p )
{ {
switch(p) switch(p)
{ {

View File

@@ -11,7 +11,6 @@
#include <QMap> #include <QMap>
#include <QNetworkProxy> #include <QNetworkProxy>
#include <QThread> #include <QThread>
#include <QTimer>
#include <string> #include <string>
@@ -135,7 +134,6 @@ private:
QMap<gloox::Presence::PresenceType, QString> m_presences; QMap<gloox::Presence::PresenceType, QString> m_presences;
QMap<QString, gloox::Presence::PresenceType> m_peers; QMap<QString, gloox::Presence::PresenceType> m_peers;
QSharedPointer<gloox::VCardManager> m_vcardManager; QSharedPointer<gloox::VCardManager> m_vcardManager;
QTimer m_timer; // for recv()
}; };
#endif // JABBER_H #endif // JABBER_H

View File

@@ -52,8 +52,10 @@ CollectionFlatModel::addCollection( const collection_ptr& collection )
emit loadingStarts(); emit loadingStarts();
connect( collection.data(), SIGNAL( tracksAdded( QList<QVariant>, Tomahawk::collection_ptr ) ), onTracksAdded( collection->tracks(), collection );
SLOT( onTracksAdded( QList<QVariant>, Tomahawk::collection_ptr ) ) );
connect( collection.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
connect( collection.data(), SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ), connect( collection.data(), SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ),
SLOT( onTracksAddingFinished( Tomahawk::collection_ptr ) ) ); SLOT( onTracksAddingFinished( Tomahawk::collection_ptr ) ) );
} }
@@ -62,8 +64,8 @@ CollectionFlatModel::addCollection( const collection_ptr& collection )
void void
CollectionFlatModel::removeCollection( const collection_ptr& collection ) CollectionFlatModel::removeCollection( const collection_ptr& collection )
{ {
disconnect( collection.data(), SIGNAL( tracksAdded( QList<QVariant>, Tomahawk::collection_ptr ) ), disconnect( collection.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
this, SLOT( onTracksAdded( QList<QVariant>, Tomahawk::collection_ptr ) ) ); this, SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
disconnect( collection.data(), SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ), disconnect( collection.data(), SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ),
this, SLOT( onTracksAddingFinished( Tomahawk::collection_ptr ) ) ); this, SLOT( onTracksAddingFinished( Tomahawk::collection_ptr ) ) );
@@ -126,7 +128,7 @@ CollectionFlatModel::removeCollection( const collection_ptr& collection )
void void
CollectionFlatModel::onTracksAdded( const QList<QVariant>& tracks, const collection_ptr& collection ) CollectionFlatModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection )
{ {
int c = rowCount( QModelIndex() ); int c = rowCount( QModelIndex() );
QPair< int, int > crows; QPair< int, int > crows;
@@ -136,25 +138,12 @@ CollectionFlatModel::onTracksAdded( const QList<QVariant>& tracks, const collect
emit beginInsertRows( QModelIndex(), crows.first, crows.second ); emit beginInsertRows( QModelIndex(), crows.first, crows.second );
PlItem* plitem; PlItem* plitem;
foreach( const QVariant& v, tracks ) foreach( const query_ptr& query, tracks )
{ {
Tomahawk::query_ptr query = query_ptr( new Query( v ) );
// FIXME: needs merging
// Manually add a result, since it's coming from the local collection
QVariantMap t = query->toVariant().toMap();
t["score"] = 1.0;
QList<result_ptr> results;
result_ptr result = result_ptr( new Result( t, collection ) );
results << result;
query->addResults( results );
plitem = new PlItem( query, m_rootItem ); plitem = new PlItem( query, m_rootItem );
plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem ); plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) ); connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
// m_collectionIndex.insertMulti( collection, plitem );
} }
m_collectionRows.insertMulti( collection, crows ); m_collectionRows.insertMulti( collection, crows );
@@ -166,9 +155,10 @@ CollectionFlatModel::onTracksAdded( const QList<QVariant>& tracks, const collect
void void
CollectionFlatModel::onTracksAddingFinished( const Tomahawk::collection_ptr& /* collection */ ) CollectionFlatModel::onTracksAddingFinished( const Tomahawk::collection_ptr& collection )
{ {
qDebug() << "Finished loading tracks"; qDebug() << "Finished loading tracks" << collection->source()->friendlyName();
emit loadingFinished(); emit loadingFinished();
} }

View File

@@ -44,7 +44,7 @@ signals:
private slots: private slots:
void onDataChanged(); void onDataChanged();
void onTracksAdded( const QList<QVariant>& tracks, const Tomahawk::collection_ptr& collection ); void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection );
void onTracksAddingFinished( const Tomahawk::collection_ptr& collection ); void onTracksAddingFinished( const Tomahawk::collection_ptr& collection );
void onSourceOffline( const Tomahawk::source_ptr& src ); void onSourceOffline( const Tomahawk::source_ptr& src );

View File

@@ -239,9 +239,15 @@ CollectionModel::onTracksAdded( const QList<QVariant>& tracks, const collection_
void void
CollectionModel::onTracksAddingFinished( const Tomahawk::collection_ptr& /* collection */ ) CollectionModel::onTracksAddingFinished( const Tomahawk::collection_ptr& collection )
{ {
qDebug() << "Finished loading tracks"; qDebug() << "Finished loading tracks" << collection->source()->friendlyName();
disconnect( collection.data(), SIGNAL( tracksAdded( QList<QVariant>, Tomahawk::collection_ptr ) ),
this, SLOT( onTracksAdded( QList<QVariant>, Tomahawk::collection_ptr ) ) );
disconnect( collection.data(), SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ),
this, SLOT( onTracksAddingFinished( Tomahawk::collection_ptr ) ) );
emit loadingFinished(); emit loadingFinished();
} }

View File

@@ -53,7 +53,7 @@ PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& opti
else else
painter->setOpacity( 0.3 ); painter->setOpacity( 0.3 );
if ( item->isPlaying() ) if ( item->isPlaying() )
{ {
painter->save(); painter->save();
painter->setRenderHint( QPainter::Antialiasing ); painter->setRenderHint( QPainter::Antialiasing );
@@ -67,7 +67,7 @@ PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& opti
} }
painter->setPen( option.palette.text().color() ); painter->setPen( option.palette.text().color() );
painter->drawText( r, index.data().toString() ); painter->drawText( r.adjusted( 0, 2, 0, 0 ), index.data().toString() );
} }
if ( index.column() == index.model()->columnCount() - 1 ) if ( index.column() == index.model()->columnCount() - 1 )

View File

@@ -14,18 +14,20 @@
PlaylistManager::PlaylistManager( QObject* parent ) PlaylistManager::PlaylistManager( QObject* parent )
: QObject( parent ) : QObject( parent )
, m_widget( new QStackedWidget() ) , m_widget( new QStackedWidget() )
, m_superCollectionModel( new CollectionModel() )
, m_superCollectionFlatModel( new CollectionFlatModel() )
, m_currentProxyModel( 0 ) , m_currentProxyModel( 0 )
, m_currentModel( 0 ) , m_currentModel( 0 )
, m_currentView( 0 )
, m_currentMode( 0 ) , m_currentMode( 0 )
, m_superCollectionVisible( true ) , m_superCollectionVisible( true )
{ {
m_widget->setMinimumWidth( 620 ); m_widget->setMinimumWidth( 620 );
m_superCollectionViews << new CollectionView(); m_superCollectionView = new CollectionView();
m_superCollectionViews.first()->setModel( m_superCollectionFlatModel ); m_superCollectionFlatModel = new CollectionFlatModel( m_superCollectionView );
m_widget->addWidget( m_superCollectionViews.first() ); m_superCollectionView->setModel( m_superCollectionFlatModel );
m_widget->addWidget( m_superCollectionView );
m_currentView = m_superCollectionView;
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) ); connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
} }
@@ -61,6 +63,7 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
m_views.insert( playlist, views ); m_views.insert( playlist, views );
m_widget->addWidget( views.first() ); m_widget->addWidget( views.first() );
m_widget->setCurrentWidget( views.first() ); m_widget->setCurrentWidget( views.first() );
m_currentView = views.first();
} }
else else
{ {
@@ -68,13 +71,13 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
m_widget->setCurrentWidget( views.first() ); m_widget->setCurrentWidget( views.first() );
m_currentProxyModel = views.first()->proxyModel(); m_currentProxyModel = views.first()->proxyModel();
m_currentModel = views.first()->model(); m_currentModel = views.first()->model();
m_currentView = views.first();
} }
m_superCollectionVisible = false; m_superCollectionVisible = false;
linkPlaylist(); linkPlaylist();
emit numSourcesChanged( APP->sourcelist().count() ); emit numSourcesChanged( APP->sourcelist().count() );
return true; return true;
} }
@@ -82,42 +85,68 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
bool bool
PlaylistManager::show( const Tomahawk::collection_ptr& collection ) PlaylistManager::show( const Tomahawk::collection_ptr& collection )
{ {
if ( m_superCollectionVisible )
{
if ( !m_superCollections.contains( collection ) )
{
m_superCollections.append( collection );
m_superCollectionFlatModel->addCollection( collection );
collection->loadAllTracks();
}
else
{
m_superCollectionFlatModel->removeCollection( collection );
m_superCollections.removeAll( collection );
}
}
unlinkPlaylist(); unlinkPlaylist();
if ( m_currentMode == 0 ) if ( !m_collectionViews.contains( collection ) )
{ {
m_widget->setCurrentWidget( m_superCollectionViews.first() ); QList<CollectionView*> views;
m_currentProxyModel = m_superCollectionViews.first()->proxyModel(); {
m_currentModel = m_superCollectionViews.first()->model(); CollectionView* view = new CollectionView();
CollectionFlatModel* model = new CollectionFlatModel();
view->setModel( model );
views << view;
m_currentProxyModel = view->proxyModel();
m_currentModel = view->model();
model->addCollection( collection );
// collection->loadAllTracks();
}
m_collectionViews.insert( collection, views );
m_widget->addWidget( views.first() );
m_widget->setCurrentWidget( views.first() );
m_currentView = views.first();
} }
else else
{ {
m_widget->setCurrentWidget( m_superCollectionViews.at( 1 ) ); QList<CollectionView*> views = m_collectionViews.value( collection );
m_currentProxyModel = m_superCollectionViews.at( 1 )->proxyModel(); m_widget->setCurrentWidget( views.first() );
m_currentModel = m_superCollectionViews.at( 1 )->model(); m_currentProxyModel = views.first()->proxyModel();
m_currentModel = views.first()->model();
m_currentView = views.first();
} }
m_superCollectionVisible = false;
linkPlaylist();
emit numSourcesChanged( 1 );
return true;
}
bool
PlaylistManager::showSuperCollection()
{
foreach( const Tomahawk::source_ptr& source, APP->sourcelist().sources() )
{
if ( !m_superCollections.contains( source->collection() ) )
{
m_superCollections.append( source->collection() );
m_superCollectionFlatModel->addCollection( source->collection() );
// source->collection()->loadAllTracks();
}
}
m_widget->setCurrentWidget( m_superCollectionView );
m_currentProxyModel = m_superCollectionView->proxyModel();
m_currentModel = m_superCollectionView->model();
m_currentView = m_superCollectionView;
m_superCollectionVisible = true; m_superCollectionVisible = true;
linkPlaylist(); linkPlaylist();
emit numSourcesChanged( m_superCollections.count() ); emit numSourcesChanged( m_superCollections.count() );
return true; return true;
} }
@@ -130,7 +159,7 @@ PlaylistManager::setTreeMode()
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
m_currentMode = 1; m_currentMode = 1;
m_widget->setCurrentWidget( m_superCollectionViews.at( 1 ) ); m_widget->setCurrentWidget( m_superCollectionView );
} }
@@ -140,7 +169,7 @@ PlaylistManager::setTableMode()
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
m_currentMode = 0; m_currentMode = 0;
m_widget->setCurrentWidget( m_superCollectionViews.first() ); m_widget->setCurrentWidget( m_superCollectionView );
} }
@@ -235,3 +264,11 @@ PlaylistManager::setShuffled( bool enabled )
if ( m_currentProxyModel ) if ( m_currentProxyModel )
m_currentProxyModel->setShuffled( enabled ); m_currentProxyModel->setShuffled( enabled );
} }
void
PlaylistManager::showCurrentTrack()
{
if ( m_currentView && m_currentProxyModel )
m_currentView->scrollTo( m_currentProxyModel->currentItem(), QAbstractItemView::PositionAtCenter );
}

View File

@@ -14,6 +14,7 @@ class CollectionView;
class PlaylistView; class PlaylistView;
class TrackProxyModel; class TrackProxyModel;
class TrackModel; class TrackModel;
class TrackView;
class PlaylistManager : public QObject class PlaylistManager : public QObject
{ {
@@ -26,12 +27,14 @@ public:
QWidget* widget() const { return m_widget; } QWidget* widget() const { return m_widget; }
bool isSuperCollectionVisible() const { return true; } bool isSuperCollectionVisible() const { return true; }
QList< Tomahawk::collection_ptr > superCollections() const { return m_superCollections; }
QList<PlaylistView*> views( const Tomahawk::playlist_ptr& playlist ) { return m_views.value( playlist ); } QList<PlaylistView*> views( const Tomahawk::playlist_ptr& playlist ) { return m_views.value( playlist ); }
bool show( const Tomahawk::playlist_ptr& playlist ); bool show( const Tomahawk::playlist_ptr& playlist );
bool show( const Tomahawk::collection_ptr& collection ); bool show( const Tomahawk::collection_ptr& collection );
bool showSuperCollection();
void showCurrentTrack();
signals: signals:
void numSourcesChanged( unsigned int sources ); void numSourcesChanged( unsigned int sources );
@@ -61,14 +64,17 @@ private:
QStackedWidget* m_widget; QStackedWidget* m_widget;
CollectionModel* m_superCollectionModel;
CollectionFlatModel* m_superCollectionFlatModel; CollectionFlatModel* m_superCollectionFlatModel;
QList<CollectionView*> m_superCollectionViews; CollectionView* m_superCollectionView;
QList< Tomahawk::collection_ptr > m_superCollections; QList< Tomahawk::collection_ptr > m_superCollections;
QHash< Tomahawk::collection_ptr, QList<CollectionView*> > m_collectionViews;
QHash< Tomahawk::playlist_ptr, QList<PlaylistView*> > m_views; QHash< Tomahawk::playlist_ptr, QList<PlaylistView*> > m_views;
TrackProxyModel* m_currentProxyModel; TrackProxyModel* m_currentProxyModel;
TrackModel* m_currentModel; TrackModel* m_currentModel;
TrackView* m_currentView;
int m_currentMode; int m_currentMode;
bool m_superCollectionVisible; bool m_superCollectionVisible;

View File

@@ -45,9 +45,12 @@ Source::~Source()
} }
collection_ptr Source::collection() const collection_ptr
Source::collection() const
{ {
if( m_collections.length() ) return m_collections.first(); if( m_collections.length() )
return m_collections.first();
collection_ptr tmp; collection_ptr tmp;
return tmp; return tmp;
} }

View File

@@ -38,8 +38,8 @@ SourceList::add( const Tomahawk::source_ptr& s )
m_local = s; m_local = s;
} }
} }
emit sourceAdded( s ); emit sourceAdded( s );
s->collection()->loadPlaylists();
} }
@@ -65,6 +65,7 @@ SourceList::remove( Tomahawk::Source* s )
m_sources.remove( s->userName() ); m_sources.remove( s->userName() );
qDebug() << "SourceList::remove(" << s->userName() << "), total sources now:" << m_sources.size(); qDebug() << "SourceList::remove(" << s->userName() << "), total sources now:" << m_sources.size();
} }
emit sourceRemoved( src ); emit sourceRemoved( src );
} }

View File

@@ -24,9 +24,6 @@ SourcesModel::SourcesModel( QObject* parent )
connect( parent, SIGNAL( onOnline( QModelIndex ) ), SLOT( onItemOnline( QModelIndex ) ) ); connect( parent, SIGNAL( onOnline( QModelIndex ) ), SLOT( onItemOnline( QModelIndex ) ) );
connect( parent, SIGNAL( onOffline( QModelIndex ) ), SLOT( onItemOffline( QModelIndex ) ) ); connect( parent, SIGNAL( onOffline( QModelIndex ) ), SLOT( onItemOffline( QModelIndex ) ) );
// load sources after the view initialised completely
// QTimer::singleShot( 0, this, SLOT( loadSources() ) );
} }

View File

@@ -16,15 +16,20 @@ SourceTreeItem::SourceTreeItem( const source_ptr& source, QObject* parent )
{ {
QStandardItem* item = new QStandardItem( "" ); QStandardItem* item = new QStandardItem( "" );
item->setEditable( false ); item->setEditable( false );
item->setData( (qlonglong)this, Qt::UserRole + 2 );
item->setData( 0, Qt::UserRole + 1 ); item->setData( 0, Qt::UserRole + 1 );
item->setData( (qlonglong)this, Qt::UserRole + 2 );
m_columns << item; m_columns << item;
connect( source.data()->collection().data(), SIGNAL( playlistsAdded( QList<Tomahawk::playlist_ptr> ) ), if ( !source.isNull() )
SLOT( onPlaylistsAdded( QList<Tomahawk::playlist_ptr> ) ) ); {
onPlaylistsAdded( source->collection()->playlists() );
connect( source.data()->collection().data(), SIGNAL( playlistsDeleted( QList<Tomahawk::playlist_ptr> ) ), connect( source->collection().data(), SIGNAL( playlistsAdded( QList<Tomahawk::playlist_ptr> ) ),
SLOT( onPlaylistsDeleted( QList<Tomahawk::playlist_ptr> ) ) ); SLOT( onPlaylistsAdded( QList<Tomahawk::playlist_ptr> ) ) );
connect( source->collection().data(), SIGNAL( playlistsDeleted( QList<Tomahawk::playlist_ptr> ) ),
SLOT( onPlaylistsDeleted( QList<Tomahawk::playlist_ptr> ) ) );
}
m_widget = new SourceTreeItemWidget( source, (QWidget*)parent->parent() ); m_widget = new SourceTreeItemWidget( source, (QWidget*)parent->parent() );
connect( m_widget, SIGNAL( clicked() ), SLOT( onClicked() ) ); connect( m_widget, SIGNAL( clicked() ), SLOT( onClicked() ) );
@@ -55,8 +60,6 @@ SourceTreeItem::onOffline()
void void
SourceTreeItem::onPlaylistsAdded( const QList<playlist_ptr>& playlists ) SourceTreeItem::onPlaylistsAdded( const QList<playlist_ptr>& playlists )
{ {
// qDebug() << playlists;
// const-ness is important for getting the right pointer! // const-ness is important for getting the right pointer!
foreach( const playlist_ptr& p, playlists ) foreach( const playlist_ptr& p, playlists )
{ {

View File

@@ -16,23 +16,36 @@ SourceTreeItemWidget::SourceTreeItemWidget( const source_ptr& source, QWidget* p
ui( new Ui::SourceTreeItemWidget ) ui( new Ui::SourceTreeItemWidget )
{ {
// qDebug() << Q_FUNC_INFO; // qDebug() << Q_FUNC_INFO;
ui->setupUi( this ); ui->setupUi( this );
ui->verticalLayout->setSpacing( 3 ); ui->verticalLayout->setSpacing( 3 );
connect( source.data(), SIGNAL( loadingStateChanged( DBSyncConnection::State, DBSyncConnection::State, QString ) ), QString displayname;
SLOT( onLoadingStateChanged( DBSyncConnection::State, DBSyncConnection::State, QString ) ) ); if ( source.isNull() )
{
ui->avatarImage->setPixmap( QPixmap( RESPATH "images/user-avatar.png" ) );
connect( source.data(), SIGNAL( stats( const QVariantMap& ) ), SLOT( gotStats( const QVariantMap& ) ) ); displayname = tr( "Super Collection" );
ui->infoLabel->setText( tr( "All available tracks" ) );
}
else
{
connect( source.data(), SIGNAL( loadingStateChanged( DBSyncConnection::State, DBSyncConnection::State, QString ) ),
SLOT( onLoadingStateChanged( DBSyncConnection::State, DBSyncConnection::State, QString ) ) );
ui->avatarImage->setPixmap( QPixmap( RESPATH "images/user-avatar.png" ) ); connect( source.data(), SIGNAL( stats( QVariantMap ) ), SLOT( gotStats( QVariantMap ) ) );
QString displayname = source->friendlyName(); ui->avatarImage->setPixmap( QPixmap( RESPATH "images/user-avatar.png" ) );
if( displayname.isEmpty() )
displayname = source->userName(); displayname = source->friendlyName();
if( displayname.isEmpty() )
displayname = source->userName();
ui->infoLabel->setText( "???" );
}
ui->nameLabel->setText( displayname ); ui->nameLabel->setText( displayname );
ui->infoLabel->setForegroundRole( QPalette::Dark ); ui->infoLabel->setForegroundRole( QPalette::Dark );
ui->infoLabel->setText( "???" );
connect( ui->onOffButton, SIGNAL( clicked() ), SIGNAL( clicked() ) ); connect( ui->onOffButton, SIGNAL( clicked() ), SIGNAL( clicked() ) );
@@ -106,12 +119,14 @@ SourceTreeItemWidget::onLoadingStateChanged( DBSyncConnection::State newstate, D
void void
SourceTreeItemWidget::onOnline() SourceTreeItemWidget::onOnline()
{ {
ui->onOffButton->setPixmap( RESPATH "images/source-on-rest.png" ); if ( !m_source.isNull() )
ui->onOffButton->setPixmap( RESPATH "images/source-on-rest.png" );
} }
void void
SourceTreeItemWidget::onOffline() SourceTreeItemWidget::onOffline()
{ {
ui->onOffButton->setPixmap( RESPATH "images/source-off-rest.png" ); if ( !m_source.isNull() )
ui->onOffButton->setPixmap( RESPATH "images/source-off-rest.png" );
} }

View File

@@ -53,6 +53,7 @@ SourceTreeView::SourceTreeView( QWidget* parent )
setAllColumnsShowFocus( true ); setAllColumnsShowFocus( true );
setUniformRowHeights( false ); setUniformRowHeights( false );
setIndentation( 0 ); setIndentation( 0 );
setAnimated( false );
setItemDelegate( new SourceDelegate( this ) ); setItemDelegate( new SourceDelegate( this ) );
@@ -70,6 +71,8 @@ SourceTreeView::SourceTreeView( QWidget* parent )
connect( selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), SLOT( onSelectionChanged() ) ); connect( selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), SLOT( onSelectionChanged() ) );
connect( &APP->sourcelist(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ), SLOT( onSourceOffline( Tomahawk::source_ptr ) ) ); connect( &APP->sourcelist(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ), SLOT( onSourceOffline( Tomahawk::source_ptr ) ) );
m_model->appendItem( source_ptr() );
} }
@@ -123,19 +126,23 @@ SourceTreeView::onItemActivated( const QModelIndex& index )
SourceTreeItem* item = SourcesModel::indexToTreeItem( index ); SourceTreeItem* item = SourcesModel::indexToTreeItem( index );
if ( item ) if ( item )
{ {
if ( APP->playlistManager()->isSuperCollectionVisible() ) if ( item->source().isNull() )
{
APP->playlistManager()->showSuperCollection();
}
else
{ {
qDebug() << "SourceTreeItem toggled:" << item->source()->userName(); qDebug() << "SourceTreeItem toggled:" << item->source()->userName();
APP->playlistManager()->show( item->source()->collection() ); APP->playlistManager()->show( item->source()->collection() );
if ( APP->playlistManager()->superCollections().contains( item->source()->collection() ) ) /*if ( APP->playlistManager()->superCollections().contains( item->source()->collection() ) )
{ {
emit onOnline( index ); emit onOnline( index );
} }
else else
{ {
emit onOffline( index ); emit onOffline( index );
} }*/
} }
} }
} }
@@ -155,14 +162,14 @@ SourceTreeView::onItemActivated( const QModelIndex& index )
void void
SourceTreeView::onSelectionChanged() SourceTreeView::onSelectionChanged()
{ {
QModelIndexList si = selectedIndexes(); /* QModelIndexList si = selectedIndexes();
foreach( const QModelIndex& idx, si ) foreach( const QModelIndex& idx, si )
{ {
int type = SourcesModel::indexType( idx ); int type = SourcesModel::indexType( idx );
if ( type == 0 ) if ( type == 0 )
selectionModel()->select( idx, QItemSelectionModel::Deselect ); selectionModel()->select( idx, QItemSelectionModel::Deselect );
} }*/
} }

View File

@@ -428,12 +428,11 @@ TomahawkApp::loadPlugins()
void void
TomahawkApp::setupJabber() //const QString& jid, const QString& pass, const QString server TomahawkApp::setupJabber()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
if( !m_jabber.isNull() ) if ( !m_jabber.isNull() )
return; return;
if ( !m_settings->value( "jabber/autoconnect", true ).toBool() ) if ( !m_settings->value( "jabber/autoconnect", true ).toBool() )
return; return;
@@ -443,9 +442,7 @@ TomahawkApp::setupJabber() //const QString& jid, const QString& pass, const QStr
unsigned int port = m_settings->value( "jabber/port", 5222 ).toUInt(); unsigned int port = m_settings->value( "jabber/port", 5222 ).toUInt();
// gtalk check // gtalk check
if( server.isEmpty() && ( if( server.isEmpty() && ( jid.contains("@gmail.com") || jid.contains("@googlemail.com") ) )
jid.contains("@gmail.com") ||
jid.contains("@googlemail.com") ) )
{ {
qDebug() << "Setting jabber server to talk.google.com"; qDebug() << "Setting jabber server to talk.google.com";
server = "talk.google.com"; server = "talk.google.com";
@@ -459,17 +456,13 @@ TomahawkApp::setupJabber() //const QString& jid, const QString& pass, const QStr
m_jabber = QSharedPointer<Jabber>( new Jabber( jid, password, server, port ) ); m_jabber = QSharedPointer<Jabber>( new Jabber( jid, password, server, port ) );
connect( m_jabber.data(), SIGNAL( peerOnline( const QString& ) ), connect( m_jabber.data(), SIGNAL( peerOnline( QString ) ), SLOT( jabberPeerOnline( QString ) ) );
SLOT( jabberPeerOnline( const QString& ) ) ); connect( m_jabber.data(), SIGNAL( peerOffline( QString ) ), SLOT( jabberPeerOffline( QString ) ) );
connect( m_jabber.data(), SIGNAL( peerOffline( const QString& ) ), connect( m_jabber.data(), SIGNAL( msgReceived( QString, QString ) ), SLOT( jabberMessage( QString, QString ) ) );
SLOT( jabberPeerOffline( const QString& ) ) );
connect( m_jabber.data(), SIGNAL( msgReceived( const QString&, const QString& ) ),
SLOT( jabberMessage( const QString&, const QString& ) ) );
connect( m_jabber.data(), SIGNAL( disconnected() ), SLOT( jabberDisconnected() ) );
//connect( m_jabber.data(), SIGNAL( finished() ), SLOT( jabberDisconnected() ) );
connect( m_jabber.data(), SIGNAL( connected() ), SLOT( jabberConnected() ) ); connect( m_jabber.data(), SIGNAL( connected() ), SLOT( jabberConnected() ) );
connect( m_jabber.data(), SIGNAL( authError(int, const QString&) ), SLOT( jabberAuthError(int,const QString&) ) ); connect( m_jabber.data(), SIGNAL( disconnected() ), SLOT( jabberDisconnected() ) );
connect( m_jabber.data(), SIGNAL( authError( int, QString ) ), SLOT( jabberAuthError( int, QString ) ) );
m_jabber->setProxy( m_proxy ); m_jabber->setProxy( m_proxy );
m_jabber->start(); m_jabber->start();
@@ -502,6 +495,9 @@ TomahawkApp::jabberAuthError( int code, const QString& msg )
QMessageBox::Ok ); QMessageBox::Ok );
} }
#endif #endif
if ( code != gloox::ConnAuthenticationFailed )
QTimer::singleShot( 10000, this, SLOT( reconnectJabber() ) );
} }
@@ -534,7 +530,6 @@ TomahawkApp::jabberDisconnected()
.arg( (servent().externalPort() > 0) ? QString( "YES:%1" ).arg(servent().externalPort()):"NO" ) ); .arg( (servent().externalPort() > 0) ? QString( "YES:%1" ).arg(servent().externalPort()):"NO" ) );
} }
#endif #endif
m_jabber.clear();
} }