2010-05-09 02:10:26 +02:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
|
|
|
|
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 PLAYLISTBACKEND_H
|
|
|
|
#define PLAYLISTBACKEND_H
|
|
|
|
|
2010-08-03 20:57:17 +02:00
|
|
|
#include <QFuture>
|
2010-05-09 02:10:26 +02:00
|
|
|
#include <QList>
|
2010-08-03 20:57:17 +02:00
|
|
|
#include <QObject>
|
2010-05-09 02:10:26 +02:00
|
|
|
|
|
|
|
#include "playlistitem.h"
|
|
|
|
|
2010-06-02 17:58:07 +02:00
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
2010-05-09 02:10:26 +02:00
|
|
|
class Database;
|
|
|
|
|
|
|
|
class PlaylistBackend : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2010-06-02 17:58:07 +02:00
|
|
|
Q_INVOKABLE PlaylistBackend(QObject* parent = 0);
|
|
|
|
void SetDatabase(boost::shared_ptr<Database> db) { db_ = db; }
|
2010-05-09 02:10:26 +02:00
|
|
|
|
|
|
|
struct Playlist {
|
|
|
|
int id;
|
|
|
|
QString name;
|
2010-05-21 00:30:55 +02:00
|
|
|
int last_played;
|
2010-05-09 02:10:26 +02:00
|
|
|
};
|
|
|
|
typedef QList<Playlist> PlaylistList;
|
2010-10-16 17:22:14 +02:00
|
|
|
typedef QFuture<PlaylistItemPtr> PlaylistItemFuture;
|
2010-05-09 02:10:26 +02:00
|
|
|
|
|
|
|
PlaylistList GetAllPlaylists();
|
2010-05-21 00:30:55 +02:00
|
|
|
Playlist GetPlaylist(int id);
|
2010-08-03 21:40:54 +02:00
|
|
|
PlaylistItemFuture GetPlaylistItems(int playlist);
|
2010-05-21 00:30:55 +02:00
|
|
|
void SavePlaylistAsync(int playlist, const PlaylistItemList& items,
|
|
|
|
int last_played);
|
2010-05-21 12:37:24 +02:00
|
|
|
void SetPlaylistOrder(const QList<int>& ids);
|
2010-05-09 02:10:26 +02:00
|
|
|
|
2010-05-20 23:21:55 +02:00
|
|
|
int CreatePlaylist(const QString& name);
|
|
|
|
void RemovePlaylist(int id);
|
|
|
|
void RenamePlaylist(int id, const QString& new_name);
|
|
|
|
|
2010-05-09 02:10:26 +02:00
|
|
|
public slots:
|
2010-05-21 00:30:55 +02:00
|
|
|
void SavePlaylist(int playlist, const PlaylistItemList& items, int last_played);
|
2010-05-09 02:10:26 +02:00
|
|
|
|
|
|
|
private:
|
2010-10-16 17:22:14 +02:00
|
|
|
static PlaylistItemPtr NewSongFromQuery(const SqlRow& row);
|
2010-08-03 20:57:17 +02:00
|
|
|
|
2010-06-02 17:58:07 +02:00
|
|
|
boost::shared_ptr<Database> db_;
|
2010-05-09 02:10:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PLAYLISTBACKEND_H
|