defuze.me
Client
|
00001 /************************************************************************** 00002 ** defuze.me Epitech Innovative Project 00003 ** 00004 ** Copyright 2010 00005 ** Athena Calmettes - Jocelyn De La Rosa - Francois Gaillard 00006 ** Adrien Jarthon - Alexandre Moore - Luc Peres - Arnaud Sellier 00007 ** 00008 ** All rights reserved. 00009 **************************************************************************/ 00010 00011 namespace Queue { 00012 class PlayQueue; 00013 } 00014 00015 #ifndef PLAYQUEUE_HPP 00016 #define PLAYQUEUE_HPP 00017 00018 #include <QWidget> 00019 #include <QAbstractListModel> 00020 #include <QItemSelectionModel> 00021 #include <deque> 00022 #include "queueable.hpp" 00023 #include "container.hpp" 00024 #include "playqueuewidget.hpp" 00025 #include "staticplugin.hpp" 00026 #include "audiotrack.hpp" 00027 #include "eventmodel.hpp" 00028 00029 namespace Queue 00030 { 00050 class PlayQueue : public QAbstractListModel, public StaticPlugin 00051 { 00052 Q_OBJECT 00053 friend class PlayQueueDelegate; 00054 00055 public: 00056 explicit PlayQueue(QObject *parent = 0); 00057 ~PlayQueue(); 00058 void aboutToQuit(); 00059 void init(); 00060 void add(Queueable*, int position = -1); 00061 void add(Container*, int position = -1); 00062 void remove(int position); 00063 void remove(QList<int> positions); 00064 void bulkMove(QList<int> positions, int destination); 00065 QWidget* getWidget(); 00066 Queueable* head() const; 00067 Queueable* next() const; 00068 Queueable* nextNext() const; 00069 void pop(); 00070 const QueueableDeque& getQueue() const; 00071 void updatePositions(); 00072 QList<int> findByEvent(Scheduler::EventModel *event); 00073 Scheduler::SchedulerPlugin* getSchedulerPlugin() const; 00074 // Subclassing of QAbstractListModel needs reimplementing this methods: 00075 int rowCount(const QModelIndex &parent = QModelIndex()) const; 00076 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 00077 Qt::ItemFlags flags(const QModelIndex &index) const; 00078 bool isBeingAlteredALot() const; 00079 void emitAltered(); 00080 // Drag 00081 QStringList mimeTypes() const; 00082 QMimeData* mimeData(const QModelIndexList &indexes) const; 00083 // Drop 00084 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); 00085 00086 signals: 00087 void popQueue(); 00088 void initialized(); 00089 void altered(); 00090 void removeQueueElem(Queue::Queueable*); 00091 void addQueueElem(Queue::Queueable*); 00092 00093 public slots: 00094 void updateTimes(int shift = 0); 00095 void removeAll(Library::AudioTrack*); 00096 void removeSelected(); 00097 void updateFocus(const QModelIndex ¤t, const QModelIndex &previous); 00098 void closeControls(); 00099 void removeOne(Queueable *elem); 00100 // Scheduler related events 00101 void newEvent(Scheduler::EventModel* event); 00102 void updateEvent(Scheduler::EventModel* event); 00103 void removeEvent(Scheduler::EventModel* event); 00104 00105 00106 private: 00107 void populateFromDB(); 00108 void shiftDBPositions(int pos, int shift = 1); 00109 void startAlteringALot(); 00110 void finishAlteringALot(); 00111 00112 QueueableDeque queue; 00113 PlayQueueWidget *widget; 00114 QItemSelectionModel *selection; 00115 Gui::Module *uiModule; 00116 bool altering; 00117 Scheduler::SchedulerPlugin *scheduler; 00118 }; 00119 } 00120 00121 00122 #endif // PLAYQUEUE_HPP