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 
45  public SearchableListModel
46 {
47  Q_OBJECT
48  PIMPL(PlaylistItemModel)
49 
50 public:
51  explicit PlaylistItemModel(PlaylistPtr pl, QObject* parent=nullptr);
52  virtual ~PlaylistItemModel();
53 
54  int rowCount(const QModelIndex &parent=QModelIndex()) const override;
55  QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override;
56 
57  Qt::ItemFlags flags(const QModelIndex &index) const override;
58 
59  void clear();
60 
61  void remove_rows(const IndexSet& rows);
62  void move_rows(const IndexSet& rows, int target_index);
63  IndexSet move_rows_up(const IndexSet& rows);
64  IndexSet move_rows_down(const IndexSet& rows);
65  void copy_rows(const IndexSet& rows, int target_index);
66 
67  void set_current_track(int row);
68  int current_track() const;
69 
70  QModelIndex getPrevRowIndexOf(const QString& substr, int row, const QModelIndex &parent=QModelIndex()) override;
71  QModelIndex getNextRowIndexOf(const QString& substr, int row, const QModelIndex &parent=QModelIndex()) override;
72  QMap<QChar, QString> getExtraTriggers() override;
73 
74  const MetaData& metadata(int row) const;
75  MetaDataList metadata(const IndexSet& rows) const;
76 
77  QMimeData* mimeData(const QModelIndexList& indexes) const override;
78 
79  bool has_local_media(const IndexSet& rows) const;
80 
81 
82 private slots:
83  void playlist_changed(int pl_idx);
84 };
85 
86 #endif /* PLAYLISTITEMMODEL_H_ */
Definition: SearchableModel.h:55
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:36
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