2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-03-24 00:11:46 +01:00
|
|
|
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
|
2009-12-26 16:13:38 +01:00
|
|
|
#ifndef RADIOMODEL_H
|
|
|
|
#define RADIOMODEL_H
|
|
|
|
|
|
|
|
#include "radioitem.h"
|
2010-06-02 17:58:07 +02:00
|
|
|
#include "core/backgroundthread.h"
|
2010-05-10 23:50:31 +02:00
|
|
|
#include "core/simpletreemodel.h"
|
|
|
|
#include "core/song.h"
|
|
|
|
#include "playlist/playlistitem.h"
|
2010-08-27 17:42:58 +02:00
|
|
|
#include "ui/settingsdialog.h"
|
2010-05-10 23:50:31 +02:00
|
|
|
#include "widgets/multiloadingindicator.h"
|
2009-12-26 16:13:38 +01:00
|
|
|
|
2010-06-23 15:21:30 +02:00
|
|
|
class Database;
|
2010-05-09 17:51:04 +02:00
|
|
|
class MergedProxyModel;
|
2010-06-23 15:21:30 +02:00
|
|
|
class RadioService;
|
2010-06-09 00:56:31 +02:00
|
|
|
class SettingsDialog;
|
2010-06-23 15:21:30 +02:00
|
|
|
class TaskManager;
|
2009-12-26 16:13:38 +01:00
|
|
|
|
2010-12-18 18:28:02 +01:00
|
|
|
#ifdef HAVE_LIBLASTFM
|
|
|
|
class LastFMService;
|
|
|
|
#endif
|
|
|
|
|
2009-12-26 16:13:38 +01:00
|
|
|
class RadioModel : public SimpleTreeModel<RadioItem> {
|
2009-12-26 22:35:45 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
2011-01-02 15:49:55 +01:00
|
|
|
public:
|
2010-10-16 19:20:54 +02:00
|
|
|
RadioModel(BackgroundThread<Database>* db_thread, TaskManager* task_manager,
|
2010-06-23 15:21:30 +02:00
|
|
|
QObject* parent = 0);
|
2009-12-26 16:13:38 +01:00
|
|
|
|
|
|
|
enum {
|
|
|
|
Role_Type = Qt::UserRole + 1,
|
|
|
|
Role_SortText,
|
|
|
|
Role_Key,
|
|
|
|
};
|
|
|
|
|
2009-12-26 22:35:45 +01:00
|
|
|
// Needs to be static for RadioPlaylistItem::restore
|
|
|
|
static RadioService* ServiceByName(const QString& name);
|
|
|
|
|
2010-05-28 01:34:05 +02:00
|
|
|
template<typename T>
|
|
|
|
static T* Service() {
|
2011-01-02 15:49:55 +01:00
|
|
|
return static_cast<T*>(ServiceByName(T::kServiceName));
|
2010-05-28 01:34:05 +02:00
|
|
|
}
|
|
|
|
|
2009-12-29 20:22:02 +01:00
|
|
|
// This is special because Player needs it for scrobbling
|
2010-12-18 18:28:02 +01:00
|
|
|
#ifdef HAVE_LIBLASTFM
|
2009-12-29 20:22:02 +01:00
|
|
|
LastFMService* GetLastFMService() const;
|
2010-12-18 18:28:02 +01:00
|
|
|
#endif
|
2009-12-29 20:22:02 +01:00
|
|
|
|
2009-12-26 16:13:38 +01:00
|
|
|
// QAbstractItemModel
|
|
|
|
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
2009-12-26 22:35:45 +01:00
|
|
|
Qt::ItemFlags flags(const QModelIndex& index) const;
|
|
|
|
QStringList mimeTypes() const;
|
|
|
|
QMimeData* mimeData(const QModelIndexList& indexes) const;
|
|
|
|
|
2010-05-09 19:53:27 +02:00
|
|
|
void ShowContextMenu(RadioItem* item, const QModelIndex& index,
|
|
|
|
const QPoint& global_pos);
|
2010-02-03 19:32:48 +01:00
|
|
|
void ReloadSettings();
|
2009-12-30 00:01:07 +01:00
|
|
|
|
2010-06-02 17:58:07 +02:00
|
|
|
BackgroundThread<Database>* db_thread() const { return db_thread_; }
|
2010-05-09 17:51:04 +02:00
|
|
|
MergedProxyModel* merged_model() const { return merged_model_; }
|
2010-06-23 15:21:30 +02:00
|
|
|
TaskManager* task_manager() const { return task_manager_; }
|
2010-05-09 17:51:04 +02:00
|
|
|
|
2011-01-02 15:49:55 +01:00
|
|
|
signals:
|
2010-05-18 22:43:10 +02:00
|
|
|
void AsyncLoadFinished(const PlaylistItem::SpecialLoadResult& result);
|
2009-12-26 22:35:45 +01:00
|
|
|
void StreamError(const QString& message);
|
2009-12-26 23:15:57 +01:00
|
|
|
void StreamMetadataFound(const QUrl& original_url, const Song& song);
|
2010-08-27 17:42:58 +02:00
|
|
|
void OpenSettingsAtPage(SettingsDialog::Page);
|
2009-12-26 16:13:38 +01:00
|
|
|
|
2010-12-04 16:49:43 +01:00
|
|
|
void AddItemToPlaylist(RadioItem* item, bool clear_first);
|
|
|
|
void AddItemsToPlaylist(const PlaylistItemList& items, bool clear_first);
|
2009-12-30 02:41:37 +01:00
|
|
|
|
2011-01-02 15:49:55 +01:00
|
|
|
protected:
|
2009-12-26 16:13:38 +01:00
|
|
|
void LazyPopulate(RadioItem* parent);
|
|
|
|
|
2011-01-02 15:49:55 +01:00
|
|
|
private:
|
2009-12-26 16:13:38 +01:00
|
|
|
QVariant data(const RadioItem* item, int role) const;
|
2009-12-26 22:35:45 +01:00
|
|
|
void AddService(RadioService* service);
|
2009-12-26 16:13:38 +01:00
|
|
|
|
2011-01-02 15:49:55 +01:00
|
|
|
private:
|
|
|
|
static QMap<QString, RadioService*>* sServices;
|
2010-06-02 17:58:07 +02:00
|
|
|
BackgroundThread<Database>* db_thread_;
|
2010-05-09 17:51:04 +02:00
|
|
|
MergedProxyModel* merged_model_;
|
2010-06-23 15:21:30 +02:00
|
|
|
TaskManager* task_manager_;
|
2009-12-26 16:13:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // RADIOMODEL_H
|