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