From 9de221e9d0302bcba81b0ea3128b9c0ce35a8928 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sat, 19 Mar 2011 06:14:22 +0100 Subject: [PATCH] * Fixed broken signal / slot connection. Re-scanning now live-updates the CollectionFlatModel, again. --- README | 1 - src/libtomahawk/collection.cpp | 1 - src/libtomahawk/collection.h | 4 +++- src/libtomahawk/database/databasecollection.cpp | 5 ++--- src/libtomahawk/database/databasecollection.h | 3 --- .../database/databasecommand_addfiles.cpp | 6 +++--- src/libtomahawk/database/databasecommand_addfiles.h | 2 +- .../database/databasecommand_deletefiles.cpp | 12 ++++++++---- .../database/databasecommand_deletefiles.h | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README b/README index 8cfbf2f87..b5814e47a 100644 --- a/README +++ b/README @@ -105,7 +105,6 @@ Dependencies To build the app: ----------------- - $ mkdir build && cd build Pick one of the following two choices. If uncertain pick the second one, you probably want a GUI. diff --git a/src/libtomahawk/collection.cpp b/src/libtomahawk/collection.cpp index a89385fdf..47b42c014 100644 --- a/src/libtomahawk/collection.cpp +++ b/src/libtomahawk/collection.cpp @@ -176,7 +176,6 @@ Collection::setTracks( const QList& tracks ) { qDebug() << Q_FUNC_INFO << tracks.count() << name(); - m_isLoaded = true; m_tracks << tracks; emit tracksAdded( tracks ); } diff --git a/src/libtomahawk/collection.h b/src/libtomahawk/collection.h index 3ed499f84..ca2aa66fd 100644 --- a/src/libtomahawk/collection.h +++ b/src/libtomahawk/collection.h @@ -51,6 +51,7 @@ public: Collection( const source_ptr& source, const QString& name, QObject* parent = 0 ); virtual ~Collection(); + virtual void setLoaded() { m_isLoaded = true; } virtual bool isLoaded() const { return m_isLoaded; } virtual QString name() const; @@ -90,9 +91,10 @@ public slots: void setPlaylists( const QList& plists ); void setDynamicPlaylists( const QList< Tomahawk::dynplaylist_ptr >& dynplists ); - void setTracks( const QList& tracks ); + void setTracks( const QList& tracks ); void delTracks( const QStringList& files ); + void resetTrackCache() { m_tracks.clear(); m_isLoaded = false; } protected: QString m_name; diff --git a/src/libtomahawk/database/databasecollection.cpp b/src/libtomahawk/database/databasecollection.cpp index c90da627c..564180398 100644 --- a/src/libtomahawk/database/databasecollection.cpp +++ b/src/libtomahawk/database/databasecollection.cpp @@ -30,7 +30,6 @@ using namespace Tomahawk; DatabaseCollection::DatabaseCollection( const source_ptr& src, QObject* parent ) : Collection( src, QString( "dbcollection:%1" ).arg( src->userName() ), parent ) - , m_loadedTracks( false ) { } @@ -66,7 +65,7 @@ DatabaseCollection::loadTracks() { qDebug() << Q_FUNC_INFO << source()->userName(); - m_loadedTracks = true; + setLoaded(); DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( source()->collection() ); connect( cmd, SIGNAL( tracks( QList ) ), @@ -128,7 +127,7 @@ DatabaseCollection::tracks() { qDebug() << Q_FUNC_INFO; - if ( !m_loadedTracks ) + if ( !isLoaded() ) { loadTracks(); } diff --git a/src/libtomahawk/database/databasecollection.h b/src/libtomahawk/database/databasecollection.h index 74edcad77..5b15913c0 100644 --- a/src/libtomahawk/database/databasecollection.h +++ b/src/libtomahawk/database/databasecollection.h @@ -52,9 +52,6 @@ public slots: private slots: void dynamicPlaylistCreated( const Tomahawk::source_ptr& source, const QVariantList& data ); - -private: - bool m_loadedTracks; }; #endif // DATABASECOLLECTION_H diff --git a/src/libtomahawk/database/databasecommand_addfiles.cpp b/src/libtomahawk/database/databasecommand_addfiles.cpp index 64d96f079..e28164290 100644 --- a/src/libtomahawk/database/databasecommand_addfiles.cpp +++ b/src/libtomahawk/database/databasecommand_addfiles.cpp @@ -63,11 +63,11 @@ DatabaseCommand_AddFiles::postCommitHook() // collection browser will update/fade in etc. Collection* coll = source()->collection().data(); - connect( this, SIGNAL( notify( QList, Tomahawk::collection_ptr ) ), - coll, SLOT( setTracks( QList, Tomahawk::collection_ptr ) ), + connect( this, SIGNAL( notify( QList ) ), + coll, SLOT( setTracks( QList ) ), Qt::QueuedConnection ); - emit notify( m_queries, source()->collection() ); + emit notify( m_queries ); // also re-calc the collection stats, to updates the "X tracks" in the sidebar etc: DatabaseCommand_CollectionStats* cmd = new DatabaseCommand_CollectionStats( source() ); diff --git a/src/libtomahawk/database/databasecommand_addfiles.h b/src/libtomahawk/database/databasecommand_addfiles.h index bb09d72b5..5d82ec9ac 100644 --- a/src/libtomahawk/database/databasecommand_addfiles.h +++ b/src/libtomahawk/database/databasecommand_addfiles.h @@ -55,7 +55,7 @@ public: signals: void done( const QList&, const Tomahawk::collection_ptr& ); - void notify( const QList&, const Tomahawk::collection_ptr& ); + void notify( const QList& ); private: QVariantList m_files; diff --git a/src/libtomahawk/database/databasecommand_deletefiles.cpp b/src/libtomahawk/database/databasecommand_deletefiles.cpp index 03b4b1399..503d3887b 100644 --- a/src/libtomahawk/database/databasecommand_deletefiles.cpp +++ b/src/libtomahawk/database/databasecommand_deletefiles.cpp @@ -41,10 +41,10 @@ DatabaseCommand_DeleteFiles::postCommitHook() // collection browser will update/fade in etc. Collection* coll = source()->collection().data(); - connect( this, SIGNAL( notify( QStringList, Tomahawk::collection_ptr ) ), - coll, SLOT( delTracks( QStringList, Tomahawk::collection_ptr ) ), Qt::QueuedConnection ); + connect( this, SIGNAL( notify( QStringList ) ), + coll, SLOT( delTracks( QStringList ) ), Qt::QueuedConnection ); - emit notify( m_files, source()->collection() ); + emit notify( m_files ); // also re-calc the collection stats, to updates the "X tracks" in the sidebar etc: DatabaseCommand_CollectionStats* cmd = new DatabaseCommand_CollectionStats( source() ); @@ -66,6 +66,7 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi ) int deleted = 0; QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id(); TomahawkSqlQuery delquery = dbi->newquery(); + QString lastPath; if ( !m_dir.path().isEmpty() && source()->isLocal() ) { @@ -85,7 +86,10 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi ) QFileInfo fi( dirquery.value( 1 ).toString().mid( 7 ) ); // remove file:// if ( fi.absolutePath() != m_dir.absolutePath() ) { - qDebug() << "Skipping subdir:" << fi.absolutePath(); + if ( lastPath != fi.absolutePath() ) + qDebug() << "Skipping subdir:" << fi.absolutePath(); + + lastPath = fi.absolutePath(); continue; } diff --git a/src/libtomahawk/database/databasecommand_deletefiles.h b/src/libtomahawk/database/databasecommand_deletefiles.h index a51e0a34a..4668d0249 100644 --- a/src/libtomahawk/database/databasecommand_deletefiles.h +++ b/src/libtomahawk/database/databasecommand_deletefiles.h @@ -59,7 +59,7 @@ public: signals: void done( const QStringList&, const Tomahawk::collection_ptr& ); - void notify( const QStringList&, const Tomahawk::collection_ptr& ); + void notify( const QStringList& ); private: QDir m_dir;