diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2010-12-04 09:54:09 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2010-12-04 09:54:09 +0000 |
| commit | 99de210652e05815c0bd9b15c9d64a51a3ff4d97 (patch) | |
| tree | 4269ac90ab6901806659a66266a2a5d56fbd9a39 /src/qmmpui/playstate.cpp | |
| parent | 03082b6a3b6190a14e17459a420a373f2fc1c3b5 (diff) | |
| download | qmmp-99de210652e05815c0bd9b15c9d64a51a3ff4d97.tar.gz qmmp-99de210652e05815c0bd9b15c9d64a51a3ff4d97.tar.bz2 qmmp-99de210652e05815c0bd9b15c9d64a51a3ff4d97.zip | |
fixed random playback (patch by Anton Petrusevich)
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1993 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/qmmpui/playstate.cpp')
| -rw-r--r-- | src/qmmpui/playstate.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/qmmpui/playstate.cpp b/src/qmmpui/playstate.cpp index d730e6fda..50db86459 100644 --- a/src/qmmpui/playstate.cpp +++ b/src/qmmpui/playstate.cpp @@ -38,9 +38,8 @@ bool ShufflePlayState::next() else prepare(); } - - if (m_shuffled_current < m_shuffled_indexes.count() - 1) - m_shuffled_current++; + else + m_shuffled_current = (m_shuffled_current + 1) % m_shuffled_indexes.count(); return m_model->setCurrent(m_shuffled_indexes.at(m_shuffled_current)); } @@ -61,7 +60,7 @@ int ShufflePlayState::nextIndex() else prepare(); } - return m_shuffled_indexes.at(m_shuffled_current + 1); + return m_shuffled_indexes.at((m_shuffled_current + 1) % m_shuffled_indexes.count()); } bool ShufflePlayState::previous() @@ -93,14 +92,14 @@ bool ShufflePlayState::previous() void ShufflePlayState::prepare() { resetState(); - for (int i = 0;i < m_model->items().count();i++) + for(int i = 0;i < m_model->items().count();i++) { if (i != m_model->currentRow()) m_shuffled_indexes << i; } - for (int i = 0;i < m_shuffled_indexes.count();i++) - m_shuffled_indexes.swap(qrand()%m_shuffled_indexes.size(),qrand()%m_shuffled_indexes.size()); + for (int i = 0; i < m_shuffled_indexes.count(); i++) + m_shuffled_indexes.swap(i, qrand()%m_shuffled_indexes.size()); m_shuffled_indexes.prepend(m_model->currentRow()); } |
