Sayonara Player
PlaylistItemModel.h
1 /* PlaylistItemModel.h */
2 
3 /* Copyright (C) 2011-2016 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 "Components/Playlist/Playlist.h"
33 #include "GUI/Helper/SearchableWidget/AbstractSearchModel.h"
34 
35 #include "Helper/MetaData/MetaData.h"
36 
37 #include <QUrl>
38 #include <QLabel>
39 #include <QAbstractListModel>
40 #include <QStringList>
41 
42 class CustomMimeData;
44  Q_OBJECT
45 
46 public:
47  PlaylistItemModel(PlaylistPtr pl, QObject* parent=nullptr);
48 
49  virtual ~PlaylistItemModel();
50 
51  int rowCount(const QModelIndex &parent=QModelIndex()) const override;
52  QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override;
53  const MetaData& get_md(int row) const;
54 
55  Qt::ItemFlags flags(const QModelIndex &index) const override;
56 
57  bool setData(const QModelIndex &index, const QVariant& var, int role=Qt::DisplayRole) override;
58 
59  void clear();
60 
61  void remove_rows(const SP::Set<int>& rows);
62  void move_rows(const SP::Set<int>& rows, int target_index);
63  void copy_rows(const SP::Set<int>& rows, int target_index);
64  void insert_metadata(const MetaDataList& v_md, int target_index);
65 
66  void set_current_track(int row);
67  int get_current_track() const;
68 
69  QModelIndex getFirstRowIndexOf(QString substr) override;
70  QModelIndex getPrevRowIndexOf(QString substr, int row, const QModelIndex &parent=QModelIndex()) override;
71  QModelIndex getNextRowIndexOf(QString substr, int row, const QModelIndex &parent=QModelIndex()) override;
72  QMap<QChar, QString> getExtraTriggers() override;
73 
74 
75  void get_metadata(const IdxList& rows, MetaDataList& v_md);
76  CustomMimeData* get_custom_mimedata(const QModelIndexList& indexes) const;
77  QMimeData* mimeData(const QModelIndexList& indexes) const override;
78 
79  bool has_local_media(const IdxList& idxs) const;
80 
81 
82 protected:
83  PlaylistPtr _pl=nullptr;
84 
85 private slots:
86  void playlist_changed(int pl_idx);
87 
88 };
89 
90 #endif /* PLAYLISTITEMMODEL_H_ */
Definition: MetaData.h:49
Definition: MetaDataList.h:44
Mimedata class for drag and dropping metadata.
Definition: CustomMimeData.h:34
Definition: AbstractSearchModel.h:56
Definition: PlaylistItemModel.h:43