00001 /*************************************************************************** 00002 * Copyright (C) 2009-2011 by Ilya Kotov * 00003 * forkotov02@hotmail.ru * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 #ifndef PLAYLISTMANAGER_H 00021 #define PLAYLISTMANAGER_H 00022 00023 #include <QObject> 00024 #include "playlistmodel.h" 00025 00029 class PlayListManager : public QObject 00030 { 00031 Q_OBJECT 00032 public: 00037 PlayListManager(QObject *parent); 00041 ~PlayListManager(); 00045 static PlayListManager* instance(); 00049 QList <PlayListModel *> playLists() const; 00053 QStringList playListNames() const; 00057 PlayListModel *selectedPlayList() const; 00061 PlayListModel *currentPlayList() const; 00065 int selectedPlayListIndex() const; 00069 int currentPlayListIndex() const; 00073 int count() const; 00077 int indexOf(PlayListModel *model) const; 00082 PlayListModel *playListAt(int i) const; 00086 bool convertUnderscore() const; 00090 bool convertTwenty() const; 00094 bool useMetadata() const; 00098 const QString format() const; 00103 void setConvertUnderscore(bool enabled); 00108 void setConvertTwenty(bool enabled); 00113 void setUseMetadata(bool enabled); 00118 void setFormat(const QString &format); 00122 bool isRepeatableList() const; 00126 bool isShuffle() const; 00127 00128 signals: 00134 void currentPlayListChanged (PlayListModel *current, PlayListModel *previous); 00140 void selectedPlayListChanged (PlayListModel *selected, PlayListModel *previous); 00144 void playListAdded(int index); 00148 void playListRemoved(int index); 00152 void playListMoved(int i, int j); 00156 void playListsChanged(); 00161 void repeatableListChanged(bool state); 00166 void shuffleChanged(bool state); 00170 void settingsChanged(); 00171 00172 public slots: 00176 void selectPlayList(PlayListModel *model); 00180 void selectPlayList(int index); 00184 void selectNextPlayList(); 00188 void selectPreviousPlayList(); 00192 void activatePlayList(PlayListModel *model); 00196 void activatePlayList(int index); 00200 PlayListModel *createPlayList(const QString &name = QString()); 00204 void removePlayList(PlayListModel *model); 00208 void removePlayList(int index); 00212 void move(int i, int j); 00217 void setRepeatableList(bool r); 00222 void setShuffle(bool s); 00226 void clear(); 00230 void clearSelection(); 00234 void removeSelected(); 00238 void removeUnselected(); 00242 void removeAt (int i); 00246 void removeItem (PlayListItem *item); 00250 void invertSelection(); 00254 void selectAll(); 00258 void showDetails(); 00262 void add(const QStringList &paths); 00266 void randomizeList(); 00270 void reverseList(); 00274 void sortSelection(int mode); 00278 void sort(int mode); 00282 void addToQueue(); 00286 void removeInvalidItems(); 00290 void removeDuplicates(); 00294 void clearQueue(); 00298 void stopAfterSelected(); 00299 00300 00301 private: 00302 void readPlayLists(); 00303 void writePlayLists(); 00304 static PlayListManager* m_instance; 00305 QList <PlayListModel *> m_models; 00306 PlayListModel *m_current; 00307 PlayListModel *m_selected; 00308 bool m_repeatable, m_shuffle; 00309 }; 00310 00311 #endif // PLAYLISTMANAGER_H