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/typedefs.h"
34 #include "Utils/Playlist/PlaylistFwd.h"
35 #include "Utils/SetFwd.h"
36 #include "Utils/Pimpl.h"
37 
38 #include <QString>
39 
40 class MetaData;
41 class MetaDataList;
42 class CustomMimeData;
43 
46 {
47  Q_OBJECT
48  PIMPL(PlaylistItemModel)
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 PlaylistItemModel(PlaylistPtr pl, QObject* parent=nullptr);
66  virtual ~PlaylistItemModel();
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  const 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 
100 private:
101  void look_changed();
102 
103 private slots:
104  void playlist_changed(int pl_idx);
105 };
106 
107 #endif /* PLAYLISTITEMMODEL_H_ */
Definition: SearchableModel.h:52
The MetaData class.
Definition: MetaData.h:48
The MetaDataList class.
Definition: MetaDataList.h:38
Mimedata class for drag and dropping metadata.
Definition: CustomMimeData.h:33
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: AbstractPlaylist.h:38
Definition: Model.h:44
std::shared_ptr< Playlist::Base > PlaylistPtr
PlaylistPtr Playlist Pointer (only used internally)
Definition: PlaylistFwd.h:38
Definition: org_mpris_media_player2_adaptor.h:21