-
Notifications
You must be signed in to change notification settings - Fork 1
/
playlistmodel.h
64 lines (47 loc) · 1.71 KB
/
playlistmodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef PLAYLISTMODEL_H
#define PLAYLISTMODEL_H
#include <QAbstractTableModel>
#include <QList>
#include <QUrl>
class PlayListItem;
class PlayListModel : public QAbstractTableModel
{
friend class PlayListView;
Q_OBJECT
public:
explicit PlayListModel(QObject *parent = 0);
protected:
// model base
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
bool removeRows(int row, int count, const QModelIndex &parent);
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
// drag'n'drop
Qt::ItemFlags flags(const QModelIndex &index) const;
virtual Qt::DropActions supportedDropActions() const;
QStringList mimeTypes() const;
// QMimeData *mimeData(const QModelIndexList &indexes) const;
// bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
// extra
void clickedItem(const QModelIndex &index = QModelIndex());
signals:
void itemUpdated(PlayListItem*);
public slots:
void nextItem();
void prevItem();
void save(QString filename);
void gather(QString path);
void removeCurrent();
void appendUrl(QUrl url);
void appendUrls(QList<QUrl> urls);
void appendItems(QList<PlayListItem *> new_items);
private:
QList<PlayListItem *> items;
int current;
QList<PlayListItem *> urlToItems(QUrl url);
QList<PlayListItem *> urlsToItems(QList<QUrl> urls);
QList<QUrl> m3uToUrls(QUrl url);
};
#endif // PLAYLISTMODEL_H