2010-07-11 17:37:40 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-07-11 17:37:40 +02:00
|
|
|
|
|
|
|
Clementine 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QUEUE_H
|
|
|
|
#define QUEUE_H
|
|
|
|
|
|
|
|
#include "playlist.h"
|
|
|
|
|
|
|
|
#include <QAbstractProxyModel>
|
|
|
|
|
|
|
|
class Queue : public QAbstractProxyModel {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2014-02-10 16:03:54 +01:00
|
|
|
Queue(QObject* parent = nullptr);
|
2010-07-11 17:37:40 +02:00
|
|
|
|
2010-07-11 20:04:35 +02:00
|
|
|
static const char* kRowsMimetype;
|
|
|
|
|
2010-07-11 18:58:22 +02:00
|
|
|
// Query the queue
|
2010-07-11 17:37:40 +02:00
|
|
|
bool is_empty() const;
|
2010-07-11 18:17:38 +02:00
|
|
|
int PositionOf(const QModelIndex& source_index) const;
|
2010-11-21 18:48:58 +01:00
|
|
|
bool ContainsSourceRow(int source_row) const;
|
2010-07-11 21:02:31 +02:00
|
|
|
int PeekNext() const;
|
2010-07-11 17:37:40 +02:00
|
|
|
|
2010-07-11 18:58:22 +02:00
|
|
|
// Modify the queue
|
2010-07-11 21:02:31 +02:00
|
|
|
int TakeNext();
|
2010-07-11 17:37:40 +02:00
|
|
|
void ToggleTracks(const QModelIndexList& source_indexes);
|
2010-07-11 18:58:22 +02:00
|
|
|
void Clear();
|
2010-07-11 19:39:11 +02:00
|
|
|
void Move(const QList<int>& proxy_rows, int pos);
|
|
|
|
void MoveUp(int row);
|
|
|
|
void MoveDown(int row);
|
2011-03-30 20:41:34 +02:00
|
|
|
void Remove(QList<int>& proxy_rows);
|
2010-07-11 17:37:40 +02:00
|
|
|
|
|
|
|
// QAbstractProxyModel
|
|
|
|
void setSourceModel(QAbstractItemModel* source_model);
|
|
|
|
QModelIndex mapFromSource(const QModelIndex& source_index) const;
|
|
|
|
QModelIndex mapToSource(const QModelIndex& proxy_index) const;
|
|
|
|
|
|
|
|
// QAbstractItemModel
|
2014-02-07 16:34:20 +01:00
|
|
|
QModelIndex index(int row, int column,
|
|
|
|
const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
QModelIndex parent(const QModelIndex& child) const;
|
|
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
2010-07-11 17:37:40 +02:00
|
|
|
QVariant data(const QModelIndex& proxy_index, int role) const;
|
2010-07-11 23:27:36 +02:00
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
2010-07-11 20:04:35 +02:00
|
|
|
QStringList mimeTypes() const;
|
|
|
|
Qt::DropActions supportedDropActions() const;
|
|
|
|
QMimeData* mimeData(const QModelIndexList& indexes) const;
|
2014-02-07 16:34:20 +01:00
|
|
|
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row,
|
|
|
|
int column, const QModelIndex& parent);
|
|
|
|
Qt::ItemFlags flags(const QModelIndex& index) const;
|
2010-07-11 17:37:40 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private slots:
|
|
|
|
void SourceDataChanged(const QModelIndex& top_left,
|
|
|
|
const QModelIndex& bottom_right);
|
2010-07-11 17:37:40 +02:00
|
|
|
void SourceLayoutChanged();
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2010-07-11 17:37:40 +02:00
|
|
|
QList<QPersistentModelIndex> source_indexes_;
|
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // QUEUE_H
|