[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/multimedia/amarok/src/scriptengine
From:       Soren Harward <stharward () gmail ! com>
Date:       2009-04-26 18:29:36
Message-ID: 1240770576.426911.22495.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 959630 by stharward:

Replace the CountChanged signal in PlaylistScript

CountChanged was a relic of the old playlist code, which got rewritten
last year.  This connection in the scripting subsystem broke during the
rewrite, and hasn't been fixed until now.  The CountChanged has now been
replaced with the more useful "trackInserted" and "trackRemoved"
signals.  They aren't as fully featured as I think some script authors
would like, but at least they're correct.

BUG: 180128

 M  +19 -8     AmarokPlaylistScript.cpp  
 M  +4 -2      AmarokPlaylistScript.h  


--- trunk/extragear/multimedia/amarok/src/scriptengine/AmarokPlaylistScript.cpp \
#959629:959630 @@ -15,6 +15,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.      *
  ******************************************************************************/
 
+#define DEBUG_PREFIX "AmarokScript::Playlist"
+
 #include "AmarokPlaylistScript.h"
 
 #include "App.h"
@@ -37,8 +39,8 @@
         , m_scriptEngine( scriptEngine )
     {
         m_wrapperList = wrapperList;
-        connect( The::playlistModel(), SIGNAL( rowsInserted( const QModelIndex&, \
                int, int ) ), this, SLOT ( slotCountChanged() ) );
-        connect( The::playlistModel(), SIGNAL( rowsRemoved( const QModelIndex&, int, \
int ) ), this, SLOT ( slotCountChanged() ) ); +        connect( The::playlistModel(), \
SIGNAL( rowsInserted( const QModelIndex&, int, int ) ), this, SLOT ( \
slotTrackInserted( const QModelIndex&, int, int ) ) ); +        connect( \
The::playlistModel(), SIGNAL( rowsRemoved( const QModelIndex&, int, int ) ), this, \
                SLOT ( slotTrackRemoved( const QModelIndex&, int, int ) ) );
         connect( The::playlistModel(), SIGNAL( activeRowChanged( int ) ), this, \
SIGNAL( activeRowChanged( int ) ) );  }
 
@@ -135,11 +137,6 @@
         return QVariant::fromValue( track );;
     }
 
-    void AmarokPlaylistScript::slotCountChanged()
-    {
-        emit CountChanged( The::playlistModel()->rowCount() );
-    }
-	
     QList<int> AmarokPlaylistScript::selectedIndexes()
     {
         DEBUG_BLOCK
@@ -160,7 +157,21 @@
 
         return fileNames;
     }
+
+    // PlaylistModel inserts only one track at a time
+    void AmarokPlaylistScript::slotTrackInserted( const QModelIndex&, int row, int )
+    {
+        Meta::TrackPtr t = The::playlistModel()->trackAt( row );
+        debug() << "inserted" << t->prettyName() << "at" << row;
+        emit trackInserted( QVariant::fromValue( t ), row );
+    }
+
+    // PlaylistModel removes only one track at a time
+    void AmarokPlaylistScript::slotTrackRemoved( const QModelIndex&, int row, int )
+    {
+        debug() << "removed track at" << row;
+        emit trackRemoved( row );
+    }
 }
 
 #include "AmarokPlaylistScript.moc"
-
--- trunk/extragear/multimedia/amarok/src/scriptengine/AmarokPlaylistScript.h \
#959629:959630 @@ -57,11 +57,13 @@
             QStringList selectedFilenames();
 
         signals:
-            void CountChanged( int newCount );
             void activeRowChanged( int row );
+            void trackInserted( QVariant track, int row );
+            void trackRemoved( int row );
 
         private slots:
-            void slotCountChanged();
+            void slotTrackInserted( const QModelIndex&, int, int );
+            void slotTrackRemoved( const QModelIndex&, int, int );
 
         private:
             QList<QObject*>* m_wrapperList;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic