94
src/smartplaylists/smartplaylistsmodel.h
Normal file
94
src/smartplaylists/smartplaylistsmodel.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This code was part of Clementine.
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2019, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry 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.
|
||||
*
|
||||
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SMARTPLAYLISTSMODEL_H
|
||||
#define SMARTPLAYLISTSMODEL_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
#include <QStringList>
|
||||
#include <QSettings>
|
||||
#include <QIcon>
|
||||
|
||||
#include "core/simpletreemodel.h"
|
||||
#include "smartplaylistsitem.h"
|
||||
#include "playlistgenerator_fwd.h"
|
||||
|
||||
class Application;
|
||||
class CollectionBackend;
|
||||
|
||||
class QModelIndex;
|
||||
class QMimeData;
|
||||
|
||||
class SmartPlaylistsModel : public SimpleTreeModel<SmartPlaylistsItem> {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SmartPlaylistsModel(CollectionBackend *backend, QObject *parent = nullptr);
|
||||
~SmartPlaylistsModel();
|
||||
|
||||
void Init();
|
||||
|
||||
enum Role {
|
||||
Role_Type = Qt::UserRole + 1,
|
||||
Role_SortText,
|
||||
Role_DisplayText,
|
||||
Role_Smartplaylist,
|
||||
LastRole
|
||||
};
|
||||
|
||||
typedef QList<PlaylistGeneratorPtr> GeneratorList;
|
||||
typedef QList<GeneratorList> DefaultGenerators;
|
||||
|
||||
PlaylistGeneratorPtr CreateGenerator(const QModelIndex &idx) const;
|
||||
void AddGenerator(PlaylistGeneratorPtr gen);
|
||||
void UpdateGenerator(const QModelIndex &idx, PlaylistGeneratorPtr gen);
|
||||
void DeleteGenerator(const QModelIndex &idx);
|
||||
|
||||
private:
|
||||
QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override;
|
||||
QStringList mimeTypes() const override;
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
|
||||
protected:
|
||||
void LazyPopulate(SmartPlaylistsItem *item) override { LazyPopulate(item, true); }
|
||||
void LazyPopulate(SmartPlaylistsItem *item, bool signal);
|
||||
|
||||
private:
|
||||
static const char *kSettingsGroup;
|
||||
static const char *kSmartPlaylistsMimeType;
|
||||
static const int kSmartPlaylistsVersion;
|
||||
|
||||
void SaveGenerator(QSettings *s, const int i, PlaylistGeneratorPtr generator) const;
|
||||
void ItemFromSmartPlaylist(const QSettings &s, const bool notify);
|
||||
|
||||
private:
|
||||
CollectionBackend *backend_;
|
||||
QIcon icon_;
|
||||
DefaultGenerators default_smart_playlists_;
|
||||
QList<SmartPlaylistsItem*> items_;
|
||||
|
||||
};
|
||||
|
||||
#endif // SMARTPLAYLISTSMODEL_H
|
||||
Reference in New Issue
Block a user