2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
2014-12-17 19:02:21 +01:00
|
|
|
Copyright 2010-2012, David Sansome <me@davidsansome.com>
|
|
|
|
Copyright 2011, Tyler Rhodes <tyler.s.rhodes@gmail.com>
|
|
|
|
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
|
|
|
|
Copyright 2014, John Maguire <john.maguire@gmail.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/>.
|
|
|
|
*/
|
|
|
|
|
2014-12-17 19:02:21 +01:00
|
|
|
#ifndef INTERNET_SAVEDRADIO_H_
|
|
|
|
#define INTERNET_SAVEDRADIO_H_
|
2010-02-24 23:26:01 +01:00
|
|
|
|
2014-02-06 14:48:00 +01:00
|
|
|
#include <memory>
|
2010-02-24 23:26:01 +01:00
|
|
|
|
2014-12-18 23:35:21 +01:00
|
|
|
#include "internet/core/internetservice.h"
|
2010-05-28 00:53:07 +02:00
|
|
|
|
2010-02-24 23:26:01 +01:00
|
|
|
class QMenu;
|
|
|
|
|
2010-05-28 00:53:07 +02:00
|
|
|
class AddStreamDialog;
|
|
|
|
|
2011-07-15 15:27:50 +02:00
|
|
|
class SavedRadio : public InternetService {
|
2010-02-24 23:26:01 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2012-02-12 14:41:50 +01:00
|
|
|
SavedRadio(Application* app, InternetModel* parent);
|
2010-02-24 23:26:01 +01:00
|
|
|
~SavedRadio();
|
|
|
|
|
2014-12-17 19:02:21 +01:00
|
|
|
enum ItemType {
|
|
|
|
Type_Stream = 2000,
|
|
|
|
};
|
2010-02-24 23:26:01 +01:00
|
|
|
|
2011-11-06 16:00:22 +01:00
|
|
|
struct Stream {
|
2014-12-17 19:02:21 +01:00
|
|
|
explicit Stream(const QUrl& url, const QString& name = QString())
|
|
|
|
: url_(url), name_(name) {}
|
2011-11-06 16:00:22 +01:00
|
|
|
|
|
|
|
// For QList::contains
|
2014-02-07 16:34:20 +01:00
|
|
|
bool operator==(const Stream& other) const { return url_ == other.url_; }
|
2011-11-06 16:00:22 +01:00
|
|
|
|
|
|
|
QUrl url_;
|
|
|
|
QString name_;
|
|
|
|
};
|
|
|
|
typedef QList<Stream> StreamList;
|
|
|
|
|
2010-02-24 23:26:01 +01:00
|
|
|
static const char* kServiceName;
|
|
|
|
static const char* kSettingsGroup;
|
|
|
|
|
2011-01-09 19:27:41 +01:00
|
|
|
QStandardItem* CreateRootItem();
|
|
|
|
void LazyPopulate(QStandardItem* item);
|
2010-02-24 23:26:01 +01:00
|
|
|
|
2012-03-11 15:44:43 +01:00
|
|
|
void ShowContextMenu(const QPoint& global_pos);
|
2010-02-24 23:26:01 +01:00
|
|
|
|
2010-05-28 00:53:07 +02:00
|
|
|
void Add(const QUrl& url, const QString& name = QString());
|
2010-02-24 23:26:01 +01:00
|
|
|
|
2011-11-06 16:00:22 +01:00
|
|
|
StreamList Streams() const { return streams_; }
|
|
|
|
|
2014-12-17 19:02:21 +01:00
|
|
|
signals:
|
2010-02-24 23:26:01 +01:00
|
|
|
void ShowAddStreamDialog();
|
2011-11-06 16:00:22 +01:00
|
|
|
void StreamsChanged();
|
2010-02-24 23:26:01 +01:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void Remove();
|
2010-05-28 00:53:07 +02:00
|
|
|
void Edit();
|
2010-02-24 23:26:01 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
void LoadStreams();
|
|
|
|
void SaveStreams();
|
2011-01-09 19:27:41 +01:00
|
|
|
void AddStreamToList(const Stream& stream, QStandardItem* parent);
|
2010-02-24 23:26:01 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
QMenu* context_menu_;
|
2011-01-09 19:27:41 +01:00
|
|
|
QStandardItem* root_;
|
2010-02-24 23:26:01 +01:00
|
|
|
|
|
|
|
QAction* remove_action_;
|
2010-05-28 00:53:07 +02:00
|
|
|
QAction* edit_action_;
|
|
|
|
|
2011-11-06 16:00:22 +01:00
|
|
|
StreamList streams_;
|
2010-02-24 23:26:01 +01:00
|
|
|
|
2014-02-06 14:48:00 +01:00
|
|
|
std::unique_ptr<AddStreamDialog> edit_dialog_;
|
2010-02-24 23:26:01 +01:00
|
|
|
};
|
|
|
|
|
2014-12-17 19:02:21 +01:00
|
|
|
#endif // INTERNET_SAVEDRADIO_H_
|