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 EnabledRole = Qt::UserRole + 5
88 };
89
90 Model(const PlaylistPtr& playlist, Library::InfoAccessor* libraryInfoAccessor, QObject* parent);
91 ~Model() override;
92
93 [[nodiscard]] int playlistIndex() const;
94
95 void clear();
96 void removeTracks(const IndexSet& rows);
97 void deleteTracks(const IndexSet& rows);
98
99 void findTrack(int index);
100
101 IndexSet moveTracks(const IndexSet& rows, int targetIndex);
102 IndexSet moveTracksUp(const IndexSet& rows);
103 IndexSet moveTracksDown(const IndexSet& rows);
104 IndexSet copyTracks(const IndexSet& rows, int targetIndex);
105 void insertTracks(const MetaDataList& tracks, int row);
106 void insertTracks(const QStringList& files, int row);
107
108 [[nodiscard]] int currentTrack() const;
109
110 [[nodiscard]] MetaDataList metadata(const IndexSet& rows) const;
111 [[nodiscard]] bool isEnabled(const int row) const;
112
113 [[nodiscard]] bool hasLocalMedia(const IndexSet& rows) const;
114 [[nodiscard]] bool isLocked() const;
115 void setLocked(bool b);
116 void setDragIndex(int dragIndex);
117 void changeRating(const IndexSet& rows, Rating rating);
118 void changeTrack(int trackIndex, Seconds seconds = 0);
119
120 void setBusy(bool b);
121
122 [[nodiscard]] Qt::ItemFlags flags(const QModelIndex& index = QModelIndex()) const override;
123 [[nodiscard]] QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
124 bool setData(const QModelIndex& index, const QVariant& value, int role) override;
125 [[nodiscard]] int rowCount(const QModelIndex& parent = QModelIndex()) const override;
126 [[nodiscard]] int columnCount(const QModelIndex& parent = QModelIndex()) const override;
127
128 SearchableModelInterface::ExtraTriggerMap getExtraTriggers() override;
129 [[nodiscard]] QMimeData* mimeData(const QModelIndexList& indexes) const override;
130 QModelIndexList searchResults(const QString& searchString) override;
131
132 public slots: // NOLINT(readability-redundant-access-specifiers)
133 void refreshData();
134 void reverseTracks();
135 void randomizeTracks();
136 void sortTracks(Library::TrackSortorder sortorder);
137 void jumpToNextAlbum();
138
139 private slots:
140 void playlistChanged(int playlistIndex);
141 void currentTrackChanged(int oldIndex, int newIndex);
142
143 void coversChanged();
144 void coverFound(const QPixmap& pixmap);
145 void coverLookupFinished(bool success);
146
147 private: // NOLINT(readability-redundant-access-specifiers)
148 void startCoverLookup(const MetaData& track) const;
149 void lookChanged();
150 void refreshPlaylist(int rowCount, int columnCount);
151 };
152
153 Util::Set<int> removeDisabledRows(const Util::Set<int>& selectedRows, Model* model);
154}
155
156#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 LanguageUtils.h:31
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