Sayonara Player
SomaFMStationModel.h
1 /* SomaFMStationModel.h */
2 
3 /* Copyright (C) 2011-2016 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 
23 /* SomaFMStationModel.h */
24 
25 #ifndef SomaFMStationModel_H
26 #define SomaFMStationModel_H
27 
28 #include "GUI/Helper/SearchableWidget/AbstractSearchModel.h"
29 #include "3rdParty/SomaFM/SomaFMStation.h"
30 #include <QMap>
31 #include <QList>
32 class QMimeData;
34 {
35  Q_OBJECT
36 public:
37  explicit SomaFMStationModel(QObject *parent = 0);
38 
39 private:
40  QList<SomaFMStation> _stations;
41 
42  enum class Status {
43  Waiting,
44  Error,
45  OK
46  };
47 
48  Status _status;
49 
50  // QAbstractItemModel interface
51 public:
52  int rowCount(const QModelIndex& parent=QModelIndex()) const override;
53  int columnCount(const QModelIndex& parent=QModelIndex()) const override;
54  QVariant data(const QModelIndex& index, int role=Qt::DisplayRole) const override;
55  QMimeData* mimeData(const QModelIndexList &indexes) const override;
56  Qt::ItemFlags flags(const QModelIndex &index) const override;
57 
58 
59  // AbstractSearchModelInterface interface
60 public:
61  QModelIndex getFirstRowIndexOf(QString substr) override;
62  QModelIndex getNextRowIndexOf(QString substr, int cur_row, const QModelIndex& parent) override;
63  QModelIndex getPrevRowIndexOf(QString substr, int cur_row, const QModelIndex& parent) override;
64  QMap<QChar, QString> getExtraTriggers() override;
65 
66  void set_stations(const QList<SomaFMStation>& stations);
67  void replace_station(const SomaFMStation& station);
68  bool has_stations() const;
69  void set_waiting();
70 };
71 
72 
73 #endif // SomaFMStationModel_H
Definition: SomaFMStation.h:31
Definition: AbstractSearchModel.h:48
Definition: SomaFMStationModel.h:33