Sayonara Player
PlaylistItemModel.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/Helper/SearchableWidget/AbstractSearchModel.h"
33 #include "Helper/typedefs.h"
34 #include "Helper/Playlist/PlaylistFwd.h"
35 
36 #include <QString>
37 
38 class MetaData;
39 class MetaDataList;
40 class CustomMimeData;
41 namespace SP
42 {
43  template<typename T>
44  class Set;
45 }
46 
48 {
49  Q_OBJECT
50 
51 public:
52  explicit PlaylistItemModel(PlaylistPtr pl, QObject* parent=nullptr);
53  virtual ~PlaylistItemModel();
54 
55  int rowCount(const QModelIndex &parent=QModelIndex()) const override;
56  QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override;
57  const MetaData& get_md(int row) const;
58 
59  Qt::ItemFlags flags(const QModelIndex &index) const override;
60 
61  bool setData(const QModelIndex &index, const QVariant& var, int role=Qt::DisplayRole) override;
62 
63  void clear();
64 
65  void remove_rows(const SP::Set<int>& rows);
66  void move_rows(const SP::Set<int>& rows, int target_index);
67  void copy_rows(const SP::Set<int>& rows, int target_index);
68 
69  void set_current_track(int row);
70  int get_current_track() const;
71 
72  QModelIndex getFirstRowIndexOf(const QString& substr) override;
73  QModelIndex getPrevRowIndexOf(const QString& substr, int row, const QModelIndex &parent=QModelIndex()) override;
74  QModelIndex getNextRowIndexOf(const QString& substr, int row, const QModelIndex &parent=QModelIndex()) override;
75  QMap<QChar, QString> getExtraTriggers() override;
76 
77 
78  void get_metadata(const IdxList& rows, MetaDataList& v_md);
79  CustomMimeData* get_custom_mimedata(const QModelIndexList& indexes) const;
80  QMimeData* mimeData(const QModelIndexList& indexes) const override;
81 
82  bool has_local_media(const IdxList& idxs) const;
83 
84 
85 protected:
86  PlaylistPtr _pl=nullptr;
87 
88 private slots:
89  void playlist_changed(int pl_idx);
90 };
91 
92 #endif /* PLAYLISTITEMMODEL_H_ */
Definition: AbstractSearchModel.h:55
The MetaDataList class.
Definition: AbstractPlaylist.h:34
The MetaData class MetaDataHelper.
Definition: MetaData.h:55
Definition: MetaDataList.h:39
Set namespace defines the setting: Which key and which type.
Definition: SettingKey.h:200
Mimedata class for drag and dropping metadata.
Definition: CustomMimeData.h:33
std::shared_ptr< AbstractPlaylist > PlaylistPtr
PlaylistPtr Playlist Pointer (only used internally)
Definition: PlaylistFwd.h:27
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: AbstractPlaylist.h:37
Definition: PlaylistItemModel.h:47
Definition: org_mpris_media_player2_adaptor.h:21