Sayonara Player
Model.h
1 /* PlaylistItemModel.h */
2 
3 /* Copyright (C) 2011-2017 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  * PlaylistItemModel.h
24  *
25  * Created on: Apr 8, 2011
26  * Author: Lucio Carreras
27  */
28 
29 #ifndef PLAYLISTITEMMODEL_H_
30 #define PLAYLISTITEMMODEL_H_
31 
32 #include "GUI/Utils/SearchableWidget/SearchableModel.h"
33 #include "Utils/Playlist/PlaylistFwd.h"
34 #include "Utils/Pimpl.h"
35 
36 class CustomMimeData;
37 
40 {
41  Q_OBJECT
42  PIMPL(PlaylistItemModel)
43 
45 
46 signals:
47  void sig_data_ready();
48 
49 public:
50  enum ColumnName
51  {
52  TrackNumber=0,
53  Cover,
54  Description,
55  Time,
56  NumColumns
57  };
58 
59  explicit PlaylistItemModel(PlaylistPtr pl, QObject* parent=nullptr);
60  virtual ~PlaylistItemModel();
61 
62  int rowCount(const QModelIndex& parent=QModelIndex()) const override;
63  int columnCount(const QModelIndex& parent=QModelIndex()) const override;
64 
65  Qt::ItemFlags flags(const QModelIndex& index=QModelIndex()) const override;
66  QVariant data(const QModelIndex& index, int role=Qt::DisplayRole) const override;
67  bool setData(const QModelIndex &index, const QVariant &value, int role) override;
68 
69 
70  SearchableModelInterface::ExtraTriggerMap getExtraTriggers() override;
71  QModelIndex getRowIndexOf(const QString& substr, int row, bool is_forward);
72  QModelIndexList search_results(const QString& substr) override;
73 
74  void clear();
75  void remove_rows(const IndexSet& rows);
76  IndexSet move_rows(const IndexSet& rows, int target_index);
77  IndexSet move_rows_up(const IndexSet& rows);
78  IndexSet move_rows_down(const IndexSet& rows);
79  IndexSet copy_rows(const IndexSet& rows, int target_index);
80  void change_rating(const IndexSet& rows, Rating rating);
81  void insert_tracks(const MetaDataList& v_md, int row);
82 
83  void set_current_track(int row);
84  int current_track() const;
85 
86  const MetaData& metadata(int row) const;
87  MetaDataList metadata(const IndexSet& rows) const;
88 
89  QMimeData* mimeData(const QModelIndexList& indexes) const override;
90 
91  bool has_local_media(const IndexSet& rows) const;
92  void set_drag_index(int drag_index);
93 
94 public slots:
95  void refresh_data();
96 
97 private:
98  void look_changed();
99 
100 private slots:
101  void playlist_changed(int pl_idx);
102 };
103 
104 #endif /* PLAYLISTITEMMODEL_H_ */
Definition: SearchableModel.h:52
The MetaData class.
Definition: MetaData.h:44
The MetaDataList class.
Definition: MetaDataList.h:37
Mimedata class for drag and dropping metadata.
Definition: CustomMimeData.h:32
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:35
Definition: SomaFMStation.h:33
Definition: Model.h:38
std::shared_ptr< Playlist::Base > PlaylistPtr
PlaylistPtr Playlist Pointer (only used internally)
Definition: PlaylistFwd.h:38
Definition: org_mpris_media_player2_adaptor.h:21