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