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
34#include "Utils/Playlist/PlaylistFwd.h"
35#include "Utils/Pimpl.h"
36
37class CustomMimeData;
38class PlaylistCreator;
39class QPixmap;
40
41namespace Playlist
42{
47 class Model :
49 {
50 Q_OBJECT
51 PIMPL(Model)
52
54
55 signals:
56 void sigDataReady();
57 void sigCurrentTrackChanged(int index);
58 void sigCurrentScannedFileChanged(const QString& filename);
59 void sigBusyChanged(bool b);
60
61 public:
62 enum StyleElement
63 {
64 Italic=0x2110,
65 Bold=0x212C
66 };
67
68 enum ColumnName
69 {
70 TrackNumber=0,
71 Cover,
72 Description,
73 Time,
74 NumColumns
75 };
76
77 enum Roles
78 {
79 RatingRole=Qt::UserRole + 1,
80 DragIndexRole=Qt::UserRole + 2,
81 EntryLookRole=Qt::UserRole + 3,
82 CurrentPlayingRole=Qt::UserRole + 4
83 };
84
85 explicit Model(PlaylistCreator* playlistCreator, PlaylistPtr playlist, QObject* parent);
86 ~Model() override;
87
88 int playlistIndex() const;
89
90 void clear();
91 void removeTracks(const IndexSet& rows);
92 void deleteTracks(const IndexSet& rows);
93
94 void findTrack(int index);
95
96 IndexSet moveTracks(const IndexSet& rows, int target_index);
97 IndexSet moveTracksUp(const IndexSet& rows);
98 IndexSet moveTracksDown(const IndexSet& rows);
99 IndexSet copyTracks(const IndexSet& rows, int target_index);
100 void insertTracks(const MetaDataList& tracks, int row);
101 void insertTracks(const QStringList& files, int row);
102
103 int currentTrack() const;
104
105 const MetaData& metadata(int row) const;
106 MetaDataList metadata(const IndexSet& rows) const;
107
108 bool hasLocalMedia(const IndexSet& rows) const;
109 void setDragIndex(int dragIndex);
110 void changeRating(const IndexSet& rows, Rating rating);
111 void changeTrack(int trackIndex, Seconds seconds=0);
112
113 void setBusy(bool b);
114
115 Qt::ItemFlags flags(const QModelIndex& index=QModelIndex()) const override;
116 QVariant data(const QModelIndex& index, int role=Qt::DisplayRole) const override;
117 bool setData(const QModelIndex& index, const QVariant &value, int role) override;
118 int rowCount(const QModelIndex& parent=QModelIndex()) const override;
119 int columnCount(const QModelIndex& parent=QModelIndex()) const override;
120
121 SearchableModelInterface::ExtraTriggerMap getExtraTriggers() override;
122 QMimeData* mimeData(const QModelIndexList& indexes) const override;
123 QModelIndexList searchResults(const QString& searchString) override;
124
125 public slots:
126 void refreshData();
127 void reverseTracks();
128
129 private slots:
130 void playlistChanged(int playlistIndex);
131 void currentTrackChanged(int oldIndex, int newIndex);
132
133 void coversChanged();
134 void coverFound(const QPixmap& pixmap);
135 void coverLookupFinished(bool success);
136
137 private:
138 void startCoverLookup(const MetaData& track) const;
139 void lookChanged();
140 void refreshPlaylist(int rowCount, int columnCount);
141 };
142}
143
144#endif /* PLAYLISTITEMMODEL_H */
The MetaDataList class.
Definition: MetaDataList.h:37
The MetaData class.
Definition: MetaData.h:47
Definition: PlaylistInterface.h:56
The PlaylistItemModel class.
Definition: PlaylistModel.h:49
Definition: LanguageUtils.h:31
Definition: SearchableModel.h:58
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:37