diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2010-09-15 18:29:45 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2010-09-15 18:29:45 +0000 |
| commit | e2bc4908a3397ded862d9e8494544131e4448158 (patch) | |
| tree | a72cb3ed23c4df927739df3a57a387b80c12ffed /src/qmmpui | |
| parent | 4b02064e9f260443c38ba6e145d64715b9031e27 (diff) | |
| download | qmmp-e2bc4908a3397ded862d9e8494544131e4448158.tar.gz qmmp-e2bc4908a3397ded862d9e8494544131e4448158.tar.bz2 qmmp-e2bc4908a3397ded862d9e8494544131e4448158.zip | |
fixed problem with shuffle and crossfade
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1888 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/qmmpui')
| -rw-r--r-- | src/qmmpui/playlistmodel.cpp | 9 | ||||
| -rw-r--r-- | src/qmmpui/playstate.cpp | 41 | ||||
| -rw-r--r-- | src/qmmpui/playstate.h | 7 |
3 files changed, 49 insertions, 8 deletions
diff --git a/src/qmmpui/playlistmodel.cpp b/src/qmmpui/playlistmodel.cpp index 17bfc7fd9..58cac7770 100644 --- a/src/qmmpui/playlistmodel.cpp +++ b/src/qmmpui/playlistmodel.cpp @@ -147,11 +147,12 @@ PlayListItem* PlayListModel::currentItem() PlayListItem* PlayListModel::nextItem() { - if(isShuffle() || m_items.isEmpty() || !isEmptyQueue()) + if(m_items.isEmpty() || !isEmptyQueue() || !m_play_state) return 0; - if(m_current < m_items.size() - 1) - return m_items.at(m_current + 1); - return 0; + int index = m_play_state->nextIndex(); + if(index < 0 || (index + 1 > m_items.count())) + return 0; + return m_items.at(index); } PlayListItem* PlayListModel::item(int row) const diff --git a/src/qmmpui/playstate.cpp b/src/qmmpui/playstate.cpp index ad2bbf9fb..d730e6fda 100644 --- a/src/qmmpui/playstate.cpp +++ b/src/qmmpui/playstate.cpp @@ -31,7 +31,7 @@ bool ShufflePlayState::next() if (itm_count > 0) { - if (m_shuffled_current >= m_shuffled_indexes.count() -1 ) + if (m_shuffled_current >= m_shuffled_indexes.count() - 1) { if (!m_model->isRepeatableList()) return false; @@ -39,13 +39,31 @@ bool ShufflePlayState::next() prepare(); } - if (m_shuffled_current < m_shuffled_indexes.count() - 1)m_shuffled_current++; + if (m_shuffled_current < m_shuffled_indexes.count() - 1) + m_shuffled_current++; return m_model->setCurrent(m_shuffled_indexes.at(m_shuffled_current)); } return false; } +int ShufflePlayState::nextIndex() +{ + int itm_count = m_model->items().count(); + if(!itm_count) + return -1; + + + if (m_shuffled_current >= m_shuffled_indexes.count() - 1) + { + if (!m_model->isRepeatableList()) + return -1; + else + prepare(); + } + return m_shuffled_indexes.at(m_shuffled_current + 1); +} + bool ShufflePlayState::previous() { int itm_count = m_model->items().count(); @@ -63,7 +81,8 @@ bool ShufflePlayState::previous() } } - if (itm_count > 1) m_shuffled_current --; + if (itm_count > 1) + m_shuffled_current --; m_model->setCurrent(m_shuffled_indexes.at(m_shuffled_current)); return true; @@ -132,3 +151,19 @@ bool NormalPlayState::previous() return false; } +int NormalPlayState::nextIndex() +{ + int itm_count = m_model->items().count(); + if(!itm_count) + return -1; + + if (m_model->currentRow() == itm_count - 1) + { + if (m_model->isRepeatableList()) + return 0; + else + return -1; + } + return m_model->currentRow() + 1; +} + diff --git a/src/qmmpui/playstate.h b/src/qmmpui/playstate.h index c03ac268e..011a02848 100644 --- a/src/qmmpui/playstate.h +++ b/src/qmmpui/playstate.h @@ -39,7 +39,10 @@ public: * If the step has done returns \b true, otherwise returns \b false */ virtual bool previous() = 0; - + /*! + * Returns next item index. + */ + virtual int nextIndex() = 0; /*! * Service method, resets state to it's defaults. */ @@ -77,6 +80,7 @@ class NormalPlayState : public PlayState public: virtual bool next(); virtual bool previous(); + virtual int nextIndex(); NormalPlayState(PlayListModel* model); }; @@ -89,6 +93,7 @@ class ShufflePlayState : public PlayState public: virtual bool next(); virtual bool previous(); + virtual int nextIndex(); virtual void prepare(); ShufflePlayState(PlayListModel* model); virtual void resetState(); |
