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

List:       kde-commits
Subject:    kdemultimedia/juk
From:       Scott Wheeler <wheeler () kde ! org>
Date:       2004-06-27 18:57:21
Message-ID: 20040627185721.4E2039992 () office ! kde ! org
[Download RAW message or body]

CVS commit by wheeler: 

Stop after we hit the end files matched by the search bar.


  M +24 -24    playlist.cpp   1.220
  M +2 -0      playlist.h   1.123


--- kdemultimedia/juk/playlist.cpp  #1.219:1.220
@@ -390,7 +390,5 @@ int Playlist::time() const
 void Playlist::playFirst()
 {
-    m_playNextItem = static_cast<PlaylistItem*>(QListViewItemIterator(
-        this, QListViewItemIterator::Visible).current());
-
+    m_playNextItem = nextItem();
     action("forward")->activate();
 }
@@ -421,22 +419,8 @@ void Playlist::playNext()
     }
     else {
-        // If there's a current item then we want to play the item after it.  If
-        // not we want to either play the first selected item or failing that the
-        // first visible item.
+        next = nextItem(m_playingItem);
 
-        if(m_playingItem) {
-            next = static_cast<PlaylistItem *>(m_playingItem->itemBelow());
-            if(!next && loop) {
-                QListViewItemIterator it(list, QListViewItemIterator::Visible);
-                next = static_cast<PlaylistItem *>(it.current());
-            }
-        }
-        else {
-            QListViewItemIterator it(list, QListViewItemIterator::Selected |
-                                     QListViewItemIterator::Visible);
-            if(!it.current())
-                it = QListViewItemIterator(list, QListViewItemIterator::Visible);
-            next = static_cast<PlaylistItem *>(it.current());
-        }
+        if(!next && loop)
+            next = nextItem();
     }
 
@@ -1221,4 +1205,23 @@ void Playlist::setup()
 }
 
+PlaylistItem *Playlist::nextItem(PlaylistItem *current) const
+{
+    if(current) {
+        QListViewItemIterator it(current, QListViewItemIterator::Visible);
+        ++it;
+        return static_cast<PlaylistItem *>(it.current());
+    }
+    else {
+        QListViewItemIterator it(const_cast<Playlist *>(this),
+                                 QListViewItemIterator::Selected |
+                                 QListViewItemIterator::Visible);
+        if(!it.current()) {
+            it = QListViewItemIterator(const_cast<Playlist *>(this),
+                                       QListViewItemIterator::Selected);
+        }
+        return static_cast<PlaylistItem *>(it.current());
+    }
+}
+
 void Playlist::loadFile(const QString &fileName, const QFileInfo &fileInfo)
 {
@@ -1753,8 +1756,5 @@ void Playlist::slotInlineCompletionModeC
 void Playlist::slotPlayCurrent()
 {
-    QListViewItemIterator it(this, QListViewItemIterator::Selected |
-                             QListViewItemIterator::Visible);
-    m_playNextItem = static_cast<PlaylistItem *>(it.current());
-
+    m_playNextItem = nextItem();
     action("forward")->activate();
 }

--- kdemultimedia/juk/playlist.h  #1.122:1.123
@@ -428,4 +428,6 @@ private:
     void setup();
 
+    PlaylistItem *nextItem(PlaylistItem *current = 0) const;
+
     /**
      * Load the playlist from a file.  \a fileName should be the absolute path.


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

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