Sayonara Player
Model.h
1 /* PlaylistItemModel.h */
2 
3 /* Copyright (C) 2011-2019 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 
44 {
45  Q_OBJECT
46  PIMPL(PlaylistItemModel)
47 
49 
50 signals:
51  void sig_data_ready();
52 
53 public:
54  enum ColumnName
55  {
56  TrackNumber=0,
57  Cover,
58  Description,
59  Time,
60  NumColumns
61  };
62 
63  explicit PlaylistItemModel(PlaylistPtr pl, QObject* parent=nullptr);
64  virtual ~PlaylistItemModel();
65 
66  int rowCount(const QModelIndex& parent=QModelIndex()) const override;
67  int columnCount(const QModelIndex& parent=QModelIndex()) const override;
68 
69  Qt::ItemFlags flags(const QModelIndex& index=QModelIndex()) const override;
70  QVariant data(const QModelIndex& index, int role=Qt::DisplayRole) const override;
71  bool setData(const QModelIndex &index, const QVariant &value, int role) override;
72 
73 
74  SearchableModelInterface::ExtraTriggerMap getExtraTriggers() override;
75  QModelIndex getRowIndexOf(const QString& substr, int row, bool is_forward);
76  QModelIndexList search_results(const QString& substr) override;
77 
78  void clear();
79  void remove_rows(const IndexSet& rows);
80  IndexSet move_rows(const IndexSet& rows, int target_index);
81  IndexSet move_rows_up(const IndexSet& rows);
82  IndexSet move_rows_down(const IndexSet& rows);
83  IndexSet copy_rows(const IndexSet& rows, int target_index);
84  void change_rating(const IndexSet& rows, Rating rating);
85  void insert_tracks(const MetaDataList& v_md, int row);
86 
87  void set_current_track(int row);
88  int current_track() const;
89 
90  MetaData metadata(int row) const;
91  MetaDataList metadata(const IndexSet& rows) const;
92 
93  QMimeData* mimeData(const QModelIndexList& indexes) const override;
94 
95  bool has_local_media(const IndexSet& rows) const;
96  void set_drag_index(int drag_index);
97  void set_row_height(int row_height);
98 
99 public slots:
100  void refresh_data();
101 
102 private:
103  void look_changed();
104 
105 private slots:
106  void playlist_changed(int pl_idx);
107 };
108 
109 #endif /* PLAYLISTITEMMODEL_H_ */
Definition: SearchableModel.h:56
The MetaData class.
Definition: MetaData.h:44
The MetaDataList class.
Definition: MetaDataList.h:37
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:35
The PlaylistItemModel class.
Definition: Model.h:42
Definition: org_mpris_media_player2_adaptor.h:21