1 /* This file is part of Clementine. 2 Copyright 2010, David Sansome <me@davidsansome.com> 3 4 Clementine is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 3 of the License, or 7 (at your option) any later version. 8 9 Clementine is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with Clementine. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef QUEUE_H 19 #define QUEUE_H 20 21 #include "playlist.h" 22 23 #include <QAbstractProxyModel> 24 25 class Queue : public QAbstractProxyModel { 26 Q_OBJECT 27 28 public: 29 Queue(Playlist* parent); 30 31 static const char* kRowsMimetype; 32 33 // Query the queue 34 bool is_empty() const; 35 int PositionOf(const QModelIndex& source_index) const; 36 bool ContainsSourceRow(int source_row) const; 37 int PeekNext() const; 38 int ItemCount() const; 39 quint64 GetTotalLength() const; 40 41 // Modify the queue 42 int TakeNext(); 43 void ToggleTracks(const QModelIndexList& source_indexes); 44 void InsertFirst(const QModelIndexList& source_indexes); 45 void Clear(); 46 void Move(const QList<int>& proxy_rows, int pos); 47 void MoveUp(int row); 48 void MoveDown(int row); 49 void Remove(QList<int>& proxy_rows); 50 51 // QAbstractProxyModel 52 void setSourceModel(QAbstractItemModel* source_model); 53 QModelIndex mapFromSource(const QModelIndex& source_index) const; 54 QModelIndex mapToSource(const QModelIndex& proxy_index) const; 55 56 // QAbstractItemModel 57 QModelIndex index(int row, int column, 58 const QModelIndex& parent = QModelIndex()) const; 59 QModelIndex parent(const QModelIndex& child) const; 60 int rowCount(const QModelIndex& parent = QModelIndex()) const; 61 int columnCount(const QModelIndex& parent = QModelIndex()) const; 62 QVariant data(const QModelIndex& proxy_index, int role) const; 63 QVariant headerData(int section, Qt::Orientation orientation, int role) const; 64 QStringList mimeTypes() const; 65 Qt::DropActions supportedDropActions() const; 66 QMimeData* mimeData(const QModelIndexList& indexes) const; 67 bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, 68 int column, const QModelIndex& parent); 69 Qt::ItemFlags flags(const QModelIndex& index) const; 70 71 public slots: 72 void UpdateSummaryText(); 73 74 signals: 75 void TotalLengthChanged(const quint64 length); 76 void ItemCountChanged(const int count); 77 void SummaryTextChanged(const QString& message); 78 79 private slots: 80 void SourceDataChanged(const QModelIndex& top_left, 81 const QModelIndex& bottom_right); 82 void SourceLayoutChanged(); 83 void UpdateTotalLength(); 84 85 private: 86 QList<QPersistentModelIndex> source_indexes_; 87 const Playlist* playlist_; 88 quint64 total_length_ns_; 89 }; 90 91 #endif // QUEUE_H 92