Sayonara Player
PlaylistModel.h
1 /* PlaylistItemModel.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (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: Michael Lugmair (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 sigDataReady();
54 
55  public:
56  enum StyleElement
57  {
58  Italic=0x2110,
59  Bold=0x212C
60  };
61 
62  enum ColumnName
63  {
64  TrackNumber=0,
65  Cover,
66  Description,
67  Time,
68  NumColumns
69  };
70 
71  enum Roles
72  {
73  RatingRole=Qt::UserRole + 1,
74  RadioModeRole=Qt::UserRole + 2,
75  DragIndexRole=Qt::UserRole + 3,
76  EntryLookRole=Qt::UserRole + 4
77  };
78 
79  explicit Model(PlaylistPtr pl, QObject* parent=nullptr);
80  ~Model() override;
81 
82  void clear();
83  void removeTracks(const IndexSet& rows);
84  IndexSet moveTracks(const IndexSet& rows, int target_index);
85  IndexSet moveTracksUp(const IndexSet& rows);
86  IndexSet moveTracksDown(const IndexSet& rows);
87  IndexSet copyTracks(const IndexSet& rows, int target_index);
88  void insertTracks(const MetaDataList& tracks, int row);
89  void insertTracks(const QStringList& files, int row);
90 
91  int currentTrack() const;
92  void setCurrentTrack(int row);
93 
94  MetaData metadata(int row) const;
95  MetaDataList metadata(const IndexSet& rows) const;
96 
97  bool hasLocalMedia(const IndexSet& rows) const;
98  void setDragIndex(int dragIndex);
99  void setRowHeight(int rowHeight);
100  void changeRating(const IndexSet& rows, Rating rating);
101 
102  QModelIndex getRowIndexOf(const QString& substr, int row, bool is_forward);
103 
104  Qt::ItemFlags flags(const QModelIndex& index=QModelIndex()) const override;
105  QVariant data(const QModelIndex& index, int role=Qt::DisplayRole) const override;
106  bool setData(const QModelIndex& index, const QVariant &value, int role) override;
107  int rowCount(const QModelIndex& parent=QModelIndex()) const override;
108  int columnCount(const QModelIndex& parent=QModelIndex()) const override;
109 
110  SearchableModelInterface::ExtraTriggerMap getExtraTriggers() override;
111  QMimeData* mimeData(const QModelIndexList& indexes) const override;
112  QModelIndexList searchResults(const QString& substr) override;
113 
114  public slots:
115  void refreshData();
116 
117  private slots:
118  void playlistChanged(int playlistIndex);
119 
120  private:
121  void lookChanged();
122  };
123 }
124 
125 #endif /* PLAYLISTITEMMODEL_H_ */
MetaDataList
The MetaDataList class.
Definition: MetaDataList.h:37
Util::Set
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:37
SearchableModel
Definition: SearchableModel.h:58
QMap
Definition: org_mpris_media_player2_adaptor.h:21
MetaData
The MetaData class.
Definition: MetaData.h:47
Playlist::Model
The PlaylistItemModel class.
Definition: PlaylistModel.h:46