diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-08-16 15:03:18 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-08-16 15:03:18 +0000 |
| commit | a5a2707ad816bb423b5ea1086bc1286d0b97e2a2 (patch) | |
| tree | 957ea76b5571dbf4210bbc7a7c969236293b32ca /src/qmmpui | |
| parent | 955dc7e3a6318bda8868ea7d442d833e04b14650 (diff) | |
| download | qmmp-a5a2707ad816bb423b5ea1086bc1286d0b97e2a2.tar.gz qmmp-a5a2707ad816bb423b5ea1086bc1286d0b97e2a2.tar.bz2 qmmp-a5a2707ad816bb423b5ea1086bc1286d0b97e2a2.zip | |
added possibility to disable groups (not working yet)
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3612 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/qmmpui')
| -rw-r--r-- | src/qmmpui/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/qmmpui/groupedcontainer.cpp | 11 | ||||
| -rw-r--r-- | src/qmmpui/groupedcontainer_p.h | 1 | ||||
| -rw-r--r-- | src/qmmpui/normalcontainer.cpp | 8 | ||||
| -rw-r--r-- | src/qmmpui/normalcontainer_p.h | 1 | ||||
| -rw-r--r-- | src/qmmpui/playlistcontainer.cpp | 29 | ||||
| -rw-r--r-- | src/qmmpui/playlistcontainer_p.h | 4 | ||||
| -rw-r--r-- | src/qmmpui/playlistgroup.cpp | 7 | ||||
| -rw-r--r-- | src/qmmpui/playlistgroup.h | 9 | ||||
| -rw-r--r-- | src/qmmpui/playlistmanager.cpp | 11 | ||||
| -rw-r--r-- | src/qmmpui/playlistmanager.h | 6 | ||||
| -rw-r--r-- | src/qmmpui/playlistmodel.cpp | 18 | ||||
| -rw-r--r-- | src/qmmpui/playlistmodel.h | 5 | ||||
| -rw-r--r-- | src/qmmpui/qmmpui.pro | 3 |
14 files changed, 103 insertions, 11 deletions
diff --git a/src/qmmpui/CMakeLists.txt b/src/qmmpui/CMakeLists.txt index 74bac0f2e..14525d47e 100644 --- a/src/qmmpui/CMakeLists.txt +++ b/src/qmmpui/CMakeLists.txt @@ -39,6 +39,7 @@ SET(libqmmpui_SRCS playlistitem.cpp playlistgroup.cpp playlisttrack.cpp + playlistcontainer.cpp normalcontainer.cpp groupedcontainer.cpp mediaplayer.cpp diff --git a/src/qmmpui/groupedcontainer.cpp b/src/qmmpui/groupedcontainer.cpp index 400490b53..1fd30dc04 100644 --- a/src/qmmpui/groupedcontainer.cpp +++ b/src/qmmpui/groupedcontainer.cpp @@ -255,6 +255,17 @@ bool GroupedContainer::move(QList<int> indexes, int from, int to) return true; } +QList<PlayListTrack *> GroupedContainer::takeAllTracks() +{ + QList<PlayListTrack *> tracks; + foreach (PlayListGroup *g, m_groups) + { + tracks.append(g->takeAll()); + } + clear(); + return tracks; +} + void GroupedContainer::clear() { while(!m_groups.isEmpty()) diff --git a/src/qmmpui/groupedcontainer_p.h b/src/qmmpui/groupedcontainer_p.h index 31a9ab76d..64b8a069a 100644 --- a/src/qmmpui/groupedcontainer_p.h +++ b/src/qmmpui/groupedcontainer_p.h @@ -49,6 +49,7 @@ public: void removeTrack(PlayListTrack *track); void removeTracks(QList<PlayListTrack *> tracks); bool move(QList<int> indexes, int from, int to); + QList<PlayListTrack *> takeAllTracks(); void clear(); private: diff --git a/src/qmmpui/normalcontainer.cpp b/src/qmmpui/normalcontainer.cpp index 35a99ce3b..3b2f23185 100644 --- a/src/qmmpui/normalcontainer.cpp +++ b/src/qmmpui/normalcontainer.cpp @@ -170,6 +170,14 @@ bool NormalContainer::move(QList<int> indexes, int from, int to) return true; } +QList<PlayListTrack *> NormalContainer::takeAllTracks() +{ + QList<PlayListTrack *> tracks; + while(!m_items.isEmpty()) + tracks.append(dynamic_cast<PlayListTrack *>(m_items.takeFirst())); + return tracks; +} + void NormalContainer::clear() { qDeleteAll(m_items); diff --git a/src/qmmpui/normalcontainer_p.h b/src/qmmpui/normalcontainer_p.h index 23286d9eb..05c257245 100644 --- a/src/qmmpui/normalcontainer_p.h +++ b/src/qmmpui/normalcontainer_p.h @@ -48,6 +48,7 @@ public: void removeTrack(PlayListTrack *track); void removeTracks(QList<PlayListTrack *> tracks); bool move(QList<int> indexes, int from, int to); + QList<PlayListTrack *> takeAllTracks(); void clear(); private: diff --git a/src/qmmpui/playlistcontainer.cpp b/src/qmmpui/playlistcontainer.cpp new file mode 100644 index 000000000..a845a7204 --- /dev/null +++ b/src/qmmpui/playlistcontainer.cpp @@ -0,0 +1,29 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include "playlistcontainer_p.h" + +void PlayListContainer::addTracks(QList<PlayListTrack *> tracks) +{ + foreach(PlayListTrack *t, tracks) + addTrack(t); +} + + diff --git a/src/qmmpui/playlistcontainer_p.h b/src/qmmpui/playlistcontainer_p.h index b4ea6a765..caa7cb23e 100644 --- a/src/qmmpui/playlistcontainer_p.h +++ b/src/qmmpui/playlistcontainer_p.h @@ -32,7 +32,8 @@ public: PlayListContainer(){} virtual ~PlayListContainer(){} - virtual void addTrack(PlayListTrack *item) = 0; + virtual void addTrack(PlayListTrack *track) = 0; + void addTracks(QList<PlayListTrack *> tracks); virtual QList<PlayListGroup *> groups() = 0; virtual QList<PlayListItem *> items() const = 0; virtual int count() const = 0; @@ -51,6 +52,7 @@ public: virtual void removeTrack(PlayListTrack *track) = 0; virtual void removeTracks(QList<PlayListTrack *> tracks) = 0; virtual bool move(QList<int> indexes, int from, int to) = 0; + virtual QList<PlayListTrack *> takeAllTracks() = 0; virtual void clear() = 0; }; diff --git a/src/qmmpui/playlistgroup.cpp b/src/qmmpui/playlistgroup.cpp index f0ddf8470..a23dc0efc 100644 --- a/src/qmmpui/playlistgroup.cpp +++ b/src/qmmpui/playlistgroup.cpp @@ -83,3 +83,10 @@ void PlayListGroup::move(int from, int to) { m_tracks.move(from, to); } + +QList<PlayListTrack *> PlayListGroup::takeAll() +{ + QList<PlayListTrack *> t = m_tracks; + m_tracks.clear(); + return t; +} diff --git a/src/qmmpui/playlistgroup.h b/src/qmmpui/playlistgroup.h index 4f37fd381..bd63b4cc7 100644 --- a/src/qmmpui/playlistgroup.h +++ b/src/qmmpui/playlistgroup.h @@ -39,22 +39,17 @@ public: bool contains(PlayListTrack *track) const; bool isEmpty() const; void remove(PlayListTrack *track); - QList<PlayListTrack *> *tracks(); - int count() const; - - - /*! * Returns formatted length of the item. */ const QString formattedLength() { return QString(); } - virtual bool isGroup() const { return true; } - void move(int from, int to); + QList<PlayListTrack *> takeAll(); + private: QList<PlayListTrack *> m_tracks; QString m_name; diff --git a/src/qmmpui/playlistmanager.cpp b/src/qmmpui/playlistmanager.cpp index 9249dcbf9..c0f580555 100644 --- a/src/qmmpui/playlistmanager.cpp +++ b/src/qmmpui/playlistmanager.cpp @@ -41,6 +41,7 @@ PlayListManager::PlayListManager(QObject *parent) : QObject(parent) m_repeatable = false; m_shuffle = false; m_autosave_playlist = false; + m_groups_enabled = false; m_timer = new QTimer(this); m_timer->setInterval(5000); m_timer->setSingleShot(true); @@ -483,6 +484,16 @@ void PlayListManager::stopAfterSelected() m_selected->stopAfterSelected(); } +void PlayListManager::setGroupsEnabled(bool enabled) +{ + if(m_groups_enabled == enabled) + return; + + m_groups_enabled = enabled; + foreach(PlayListModel *model, m_models) + model->prepareGroups(enabled); +} + void PlayListManager::readSettings() { QSettings settings(Qmmp::configFile(), QSettings::IniFormat); diff --git a/src/qmmpui/playlistmanager.h b/src/qmmpui/playlistmanager.h index d543e14fa..4f8447778 100644 --- a/src/qmmpui/playlistmanager.h +++ b/src/qmmpui/playlistmanager.h @@ -263,6 +263,11 @@ public slots: */ void stopAfterSelected(); /*! + * Enables or disables playlist groups + * * @param enabled State of the groups (\b true - enabled, \b false - disabled) + */ + void setGroupsEnabled(bool enabled); + /*! * Read the relevant settings. */ void readSettings(); @@ -277,6 +282,7 @@ private: PlayListModel *m_current; PlayListModel *m_selected; bool m_repeatable, m_shuffle, m_autosave_playlist; + bool m_groups_enabled; QTimer *m_timer; }; diff --git a/src/qmmpui/playlistmodel.cpp b/src/qmmpui/playlistmodel.cpp index e325484f1..4cddd236e 100644 --- a/src/qmmpui/playlistmodel.cpp +++ b/src/qmmpui/playlistmodel.cpp @@ -56,8 +56,7 @@ PlayListModel::PlayListModel(const QString &name, QObject *parent) m_stop_track = 0; m_play_state = new NormalPlayState(this); m_loader = new FileLoader(this); - m_container = new GroupedContainer; - //m_container = new NormalContainer; + m_container = new NormalContainer; connect(m_loader, SIGNAL(newPlayListTrack(PlayListTrack*)), SLOT(add(PlayListTrack*)), Qt::QueuedConnection); connect(m_loader, SIGNAL(finished()), SLOT(preparePlayState())); @@ -869,6 +868,21 @@ void PlayListModel::prepareForRepeatablePlaying(bool val) m_is_repeatable_list = val; } +void PlayListModel::prepareGroups(bool enabled) +{ + PlayListContainer *container = 0; + if(enabled) + container = new GroupedContainer; + else + container = new NormalContainer; + container->addTracks(m_container->takeAllTracks()); + delete m_container; + m_container = container; + if(!m_container->isEmpty()) + m_current = m_container->indexOf(m_current_track); + emit listChanged(); +} + void PlayListModel::doCurrentVisibleRequest() { emit currentChanged(); diff --git a/src/qmmpui/playlistmodel.h b/src/qmmpui/playlistmodel.h index e7804e31e..0eb6ab09f 100644 --- a/src/qmmpui/playlistmodel.h +++ b/src/qmmpui/playlistmodel.h @@ -379,6 +379,11 @@ public slots: */ void prepareForRepeatablePlaying(bool); /*! + * Enabled/Disabled groped mode + * @param enabled State of the groups (\b true - enabled, \b false - disabled) + */ + void prepareGroups(bool enabled); + /*! * Sorts selected items in \b mode sort mode. */ void sortSelection(int mode); diff --git a/src/qmmpui/qmmpui.pro b/src/qmmpui/qmmpui.pro index 7bb64cf74..05273bd7e 100644 --- a/src/qmmpui/qmmpui.pro +++ b/src/qmmpui/qmmpui.pro @@ -86,7 +86,8 @@ SOURCES += general.cpp \ playlistgroup.cpp \ playlisttrack.cpp \ groupedcontainer.cpp \ - normalcontainer.cpp + normalcontainer.cpp \ + playlistcontainer.cpp FORMS += forms/detailsdialog.ui \ forms/tageditor.ui \ forms/templateeditor.ui \ |
