diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-08-05 13:37:05 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-08-05 13:37:05 +0000 |
| commit | d1d915ea7dbb89f0f5b15cdb27c18765102696ce (patch) | |
| tree | 19891def16c981b8f18de079f8ebb498aea38421 /src | |
| parent | 664d78f03b2ae95368c70ca8a45cc746a1612ccd (diff) | |
| download | qmmp-d1d915ea7dbb89f0f5b15cdb27c18765102696ce.tar.gz qmmp-d1d915ea7dbb89f0f5b15cdb27c18765102696ce.tar.bz2 qmmp-d1d915ea7dbb89f0f5b15cdb27c18765102696ce.zip | |
fixed shuffle playback
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3568 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
| -rw-r--r-- | src/qmmpui/playstate.cpp | 65 | ||||
| -rw-r--r-- | src/qmmpui/playstate_p.h | 2 |
2 files changed, 31 insertions, 36 deletions
diff --git a/src/qmmpui/playstate.cpp b/src/qmmpui/playstate.cpp index b06f1e659..1a108b3d5 100644 --- a/src/qmmpui/playstate.cpp +++ b/src/qmmpui/playstate.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Ilya Kotov * + * Copyright (C) 2006-2013 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -27,32 +27,28 @@ ShufflePlayState::ShufflePlayState(PlayListModel * model) : PlayState(model) bool ShufflePlayState::next() { - int itm_count = m_model->items().count(); + if(!m_model->count()) + return false; - 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; - else - prepare(); - } + if (!m_model->isRepeatableList()) + return false; else - m_shuffled_current = (m_shuffled_current + 1) % m_shuffled_indexes.count(); - - return m_model->setCurrent(m_shuffled_indexes.at(m_shuffled_current)); + prepare(); } - return false; + else + m_shuffled_current = (m_shuffled_current + 1) % m_shuffled_indexes.count(); + + return m_model->setCurrent(m_shuffled_indexes.at(m_shuffled_current)); + } int ShufflePlayState::nextIndex() { - int itm_count = m_model->items().count(); - if(!itm_count) + if(!m_model->count()) return -1; - if (m_shuffled_current >= m_shuffled_indexes.count() - 1) { if (!m_model->isRepeatableList()) @@ -65,36 +61,32 @@ int ShufflePlayState::nextIndex() bool ShufflePlayState::previous() { - int itm_count = m_model->items().count(); + if(!m_model->count()) + return false; - if (itm_count > 0) + if (m_shuffled_current <= 0) { - if (m_shuffled_current <= 0) + if (!m_model->isRepeatableList()) + return false; + else { - if (!m_model->isRepeatableList()) - return false; - else - { - prepare(); - m_shuffled_current = m_shuffled_indexes.count() - 1; - } + prepare(); + m_shuffled_current = m_shuffled_indexes.count() - 1; } + } - if (itm_count > 1) - m_shuffled_current --; + if (m_model->count() > 1) + m_shuffled_current--; - m_model->setCurrent(m_shuffled_indexes.at(m_shuffled_current)); - return true; - } - return false; + return m_model->setCurrent(m_shuffled_indexes.at(m_shuffled_current)); } void ShufflePlayState::prepare() { resetState(); - for(int i = 0;i < m_model->items().count();i++) + for(int i = 0; i < m_model->count(); i++) { - if (i != m_model->currentIndex()) + if (i != m_model->currentIndex() && m_model->isTrack(i)) m_shuffled_indexes << i; } @@ -102,6 +94,9 @@ void ShufflePlayState::prepare() m_shuffled_indexes.swap(i, qrand()%m_shuffled_indexes.size()); m_shuffled_indexes.prepend(m_model->currentIndex()); + + for (int i = 0; i < m_shuffled_indexes.count(); i++) + qDebug("++%d++", m_shuffled_indexes.at(i)); } void ShufflePlayState::resetState() diff --git a/src/qmmpui/playstate_p.h b/src/qmmpui/playstate_p.h index f9b259f54..e326b0943 100644 --- a/src/qmmpui/playstate_p.h +++ b/src/qmmpui/playstate_p.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2009 by Ilya Kotov * + * Copyright (C) 2007-2013 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * |
