Merge branch 'master' of http://git.fredemmott.co.uk/repo/yanihp
[jkt-jerboa.git] / src / core / PlaylistModel.h
blob7027cfe790763638d02782cf2236eb535d2bd76c
1 /* LICENSE NOTICE
2 This file is part of Jerboa.
3 Jerboa is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation, either version 2 of the License, or
6 (at your option), version 3 of the license.
8 Jerboa is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with Jerboa. If not, see <http://www.gnu.org/licenses/>.
16 #ifndef _JERBOA_PLAYLIST_MODEL_H
17 #define _JERBOA_PLAYLIST_MODEL_H
19 #include "Playlist.h"
20 #include "TrackData.h"
21 #include "Types.h"
23 #include <QAbstractItemModel>
24 #include <QList>
25 #include <QMimeData>
26 #include <QModelIndex>
27 #include <QPair>
28 #include <QSqlDatabase>
29 #include <QString>
30 #include <QStringList>
31 #include <QVariant>
33 namespace Jerboa
35 class TrackDataLoader;
36 class PlaylistModel : public QAbstractItemModel
38 Q_OBJECT;
39 public:
40 PlaylistModel(const QString& dbConnectionName, QObject* parent = 0);
42 QVariant data(const QModelIndex &index, int role) const;
43 Qt::ItemFlags flags(const QModelIndex& index) const;
44 QVariant headerData(int section, Qt::Orientation orientation,
45 int role = Qt::DisplayRole) const;
46 QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
47 QModelIndex parent(const QModelIndex& index) const;
48 int rowCount(const QModelIndex &parent = QModelIndex()) const;
49 int columnCount(const QModelIndex &parent = QModelIndex()) const;
50 virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
52 QStringList mimeTypes() const;
53 virtual QMimeData* mimeData(const QModelIndexList& indexes) const;
54 bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
55 Qt::DropActions supportedDropActions() const;
57 void setCurrentItem(const QModelIndex&);
58 QModelIndex currentItem() const;
59 QModelIndex peekNext() const;
60 QModelIndex moveNext();
61 QModelIndex peekPrevious() const;
62 QModelIndex movePrevious();
64 TrackData trackData(const QModelIndex& index) const;
66 LoopMode loopMode() const;
67 void setLoopMode(LoopMode);
69 ShuffleMode shuffleMode() const;
70 void setShuffleMode(ShuffleMode);
71 private:
72 static bool skipFile(const QString& file);
73 public slots:
74 void clear();
75 protected slots:
76 void gotTrackData(const QUrl& file, const TrackData& data);
77 void trackAppended();
78 protected:
79 void setNextTrack();
80 void loadNextUrl();
81 QSqlDatabase mDB;
82 Playlist mTracks;
83 int mPosition;
84 int mNextPosition;
85 LoopMode mLoopMode;
86 ShuffleMode mShuffleMode;
87 TrackDataLoader* mTrackLoader;
88 QList<QPair<QUrl, quint32> > mUrlsToAdd;
91 #endif