diff options
Diffstat (limited to 'src/qmmpui')
| -rw-r--r-- | src/qmmpui/mediaplayer.cpp | 22 | ||||
| -rw-r--r-- | src/qmmpui/mediaplayer.h | 6 | ||||
| -rw-r--r-- | src/qmmpui/playlistmodel.cpp | 35 | ||||
| -rw-r--r-- | src/qmmpui/playlistmodel.h | 4 |
4 files changed, 64 insertions, 3 deletions
diff --git a/src/qmmpui/mediaplayer.cpp b/src/qmmpui/mediaplayer.cpp index 311b195b9..f0e7c54ae 100644 --- a/src/qmmpui/mediaplayer.cpp +++ b/src/qmmpui/mediaplayer.cpp @@ -35,6 +35,7 @@ MediaPlayer::MediaPlayer(QObject *parent) m_instance = this; m_model = 0; m_core = 0; + m_repeat = FALSE; } @@ -53,6 +54,7 @@ void MediaPlayer::initialize(SoundCore *core, PlayListModel *model) Q_CHECK_PTR(model); m_core = core; m_model = model; + m_repeat = FALSE; connect(m_core, SIGNAL(finished()), SLOT(next())); } @@ -61,6 +63,11 @@ PlayListModel *MediaPlayer::playListModel() return m_model; } +bool MediaPlayer::isRepeatable() const +{ + return m_repeat; +} + void MediaPlayer::play() { m_model->doCurrentVisibleRequest(); @@ -155,3 +162,18 @@ void MediaPlayer::previous() display->hideTimeDisplay();*/ } +void MediaPlayer::setRepeatable(bool r) +{ + if (r != m_repeat && !r) + { + disconnect(m_core, SIGNAL(finished()), this, SLOT(play())); + connect(m_core, SIGNAL(finished()), SLOT(next())); + } + else if (r != m_repeat && r) + { + disconnect(m_core, SIGNAL(finished()), this, SLOT(next())); + connect(m_core, SIGNAL(finished()), SLOT(play())); + } + m_repeat = r; + emit repeatableChanged(r); +} diff --git a/src/qmmpui/mediaplayer.h b/src/qmmpui/mediaplayer.h index fefc42978..920ef6908 100644 --- a/src/qmmpui/mediaplayer.h +++ b/src/qmmpui/mediaplayer.h @@ -40,17 +40,23 @@ public: void initialize(SoundCore *core, PlayListModel *model); PlayListModel *playListModel(); + bool isRepeatable() const; public slots: void play(); void stop(); void next(); void previous(); + void setRepeatable(bool); + +signals: + void repeatableChanged(bool); private: PlayListModel *m_model; SoundCore *m_core; static MediaPlayer* m_instance; + bool m_repeat; }; diff --git a/src/qmmpui/playlistmodel.cpp b/src/qmmpui/playlistmodel.cpp index 812ae51b2..2f00568f9 100644 --- a/src/qmmpui/playlistmodel.cpp +++ b/src/qmmpui/playlistmodel.cpp @@ -72,6 +72,7 @@ PlayListModel::PlayListModel(QObject *parent) : QObject(parent) , m_selection() { qsrand(time(0)); + m_shuffle = 0; m_total_length = 0; m_current = 0; m_block_update_signals = false; @@ -240,6 +241,34 @@ void PlayListModel::removeUnselected() removeSelection(true); } +void PlayListModel::removeAt (int i) +{ + if ((i < count()) && (i >= 0)) + { + PlayListItem* f = m_items.takeAt(i); + m_total_length -= f->length(); + if (m_total_length < 0) + m_total_length = qMin(0, m_total_length); + + if (f->flag() == PlayListItem::FREE) + { + delete f; + f = NULL; + } + else if (f->flag() == PlayListItem::EDITING) + f->setFlag(PlayListItem::SCHEDULED_FOR_DELETION); + + if (m_current >= i && m_current != 0) + m_current--; + + if (!m_items.isEmpty()) + m_currentItem = m_items.at(m_current); + + m_play_state->prepare(); + emit listChanged(); + } +} + void PlayListModel::removeSelection(bool inverted) { int i = 0; @@ -826,7 +855,9 @@ void PlayListModel::prepareForShufflePlaying(bool val) else m_play_state = new NormalPlayState(this); - emit shuffleChanged(val); + m_shuffle = val; + + emit shuffleChanged(val); } void PlayListModel::prepareForRepeatablePlaying(bool val) @@ -904,7 +935,7 @@ bool PlayListModel::isRepeatableList() const bool PlayListModel::isShuffle() const { - return FALSE; //TODO fix this + return m_shuffle; } bool PlayListModel::isFileLoaderRunning() const diff --git a/src/qmmpui/playlistmodel.h b/src/qmmpui/playlistmodel.h index c0a4e1168..3c2ca50f7 100644 --- a/src/qmmpui/playlistmodel.h +++ b/src/qmmpui/playlistmodel.h @@ -129,7 +129,7 @@ public: /*! * Returns index of \b f file in queue.e */ - int queuedIndex(PlayListItem* item)const + int queuedIndex(PlayListItem* item) const { return m_queued_songs.indexOf(item); } @@ -206,6 +206,7 @@ public slots: void clearSelection(); void removeSelected(); void removeUnselected(); + void removeAt (int i); void invertSelection(); void selectAll(); void showDetails(); @@ -346,6 +347,7 @@ private: * when finished. */ QVector<GuardedFileLoader> m_running_loaders; + bool m_shuffle; }; |
