2010-11-23 23:36:00 +01:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
|
|
|
|
|
|
|
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 ICECASTMODEL_H
|
|
|
|
#define ICECASTMODEL_H
|
|
|
|
|
|
|
|
#include "icecastitem.h"
|
|
|
|
#include "core/simpletreemodel.h"
|
2010-11-24 22:34:54 +01:00
|
|
|
#include "library/librarymodel.h"
|
2010-11-23 23:36:00 +01:00
|
|
|
|
|
|
|
#include <QIcon>
|
|
|
|
|
|
|
|
class IcecastBackend;
|
|
|
|
|
|
|
|
class IcecastModel : public SimpleTreeModel<IcecastItem> {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
IcecastModel(IcecastBackend* backend, QObject* parent = 0);
|
|
|
|
~IcecastModel();
|
|
|
|
|
|
|
|
// These values get saved in QSettings - don't change them
|
|
|
|
enum SortMode {
|
2010-11-24 00:05:42 +01:00
|
|
|
SortMode_GenreByPopularity = 0,
|
|
|
|
SortMode_GenreAlphabetical = 1,
|
2010-11-23 23:36:00 +01:00
|
|
|
SortMode_StationAlphabetical = 2,
|
|
|
|
};
|
|
|
|
|
2010-11-24 22:34:54 +01:00
|
|
|
enum Role {
|
|
|
|
Role_IsDivider = LibraryModel::Role_IsDivider,
|
|
|
|
};
|
|
|
|
|
2010-11-23 23:36:00 +01:00
|
|
|
IcecastBackend* backend() const { return backend_; }
|
|
|
|
|
2010-11-24 20:41:17 +01:00
|
|
|
Song GetSong(const QModelIndex& index) const;
|
|
|
|
|
2010-11-23 23:36:00 +01:00
|
|
|
// QAbstractItemModel
|
|
|
|
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
2010-11-24 20:25:41 +01:00
|
|
|
Qt::ItemFlags flags(const QModelIndex& index) const;
|
2010-11-23 23:36:00 +01:00
|
|
|
QStringList mimeTypes() const;
|
|
|
|
QMimeData* mimeData(const QModelIndexList& indexes) const;
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void Init();
|
|
|
|
void Reset();
|
|
|
|
|
2010-11-24 00:05:42 +01:00
|
|
|
void SetFilterText(const QString& filter);
|
|
|
|
void SetSortMode(SortMode mode);
|
|
|
|
|
2010-11-23 23:36:00 +01:00
|
|
|
protected:
|
|
|
|
void LazyPopulate(IcecastItem* parent);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QVariant data(const IcecastItem* item, int role) const;
|
2010-11-24 22:34:54 +01:00
|
|
|
void PopulateGenre(IcecastItem* parent, const QString& genre, bool create_dividers);
|
2010-11-25 22:20:06 +01:00
|
|
|
void AddGenres(const QStringList& genres, bool create_dividers);
|
2010-11-24 22:34:54 +01:00
|
|
|
|
|
|
|
static QChar DividerKey(const QString& text);
|
|
|
|
static QString DividerDisplayText(const QChar& key);
|
2010-11-23 23:36:00 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
IcecastBackend* backend_;
|
|
|
|
|
2010-11-24 00:05:42 +01:00
|
|
|
QString filter_;
|
2010-11-23 23:36:00 +01:00
|
|
|
SortMode sort_mode_;
|
|
|
|
|
|
|
|
QIcon genre_icon_;
|
|
|
|
QIcon station_icon_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ICECASTMODEL_H
|