Changeset View
Changeset View
Standalone View
Standalone View
src/databaseinterface.h
Show All 15 Lines | |||||
16 | */ | 16 | */ | ||
17 | 17 | | |||
18 | #ifndef DATABASEINTERFACE_H | 18 | #ifndef DATABASEINTERFACE_H | ||
19 | #define DATABASEINTERFACE_H | 19 | #define DATABASEINTERFACE_H | ||
20 | 20 | | |||
21 | #include "elisaLib_export.h" | 21 | #include "elisaLib_export.h" | ||
22 | 22 | | |||
23 | #include "elisautils.h" | 23 | #include "elisautils.h" | ||
24 | #include "datatypes.h" | ||||
24 | 25 | | |||
25 | #include <QObject> | 26 | #include <QObject> | ||
26 | #include <QString> | 27 | #include <QString> | ||
27 | #include <QHash> | 28 | #include <QHash> | ||
28 | #include <QList> | 29 | #include <QList> | ||
29 | #include <QVariant> | 30 | #include <QVariant> | ||
30 | #include <QUrl> | 31 | #include <QUrl> | ||
31 | #include <QDateTime> | 32 | #include <QDateTime> | ||
Show All 9 Lines | |||||
41 | class MusicAudioTrack; | 42 | class MusicAudioTrack; | ||
42 | 43 | | |||
43 | class ELISALIB_EXPORT DatabaseInterface : public QObject | 44 | class ELISALIB_EXPORT DatabaseInterface : public QObject | ||
44 | { | 45 | { | ||
45 | Q_OBJECT | 46 | Q_OBJECT | ||
46 | 47 | | |||
47 | public: | 48 | public: | ||
48 | 49 | | |||
49 | enum ColumnsRoles { | | |||
50 | TitleRole = Qt::UserRole + 1, | | |||
51 | SecondaryTextRole, | | |||
52 | ImageUrlRole, | | |||
53 | ShadowForImageRole, | | |||
54 | ChildModelRole, | | |||
55 | DurationRole, | | |||
56 | StringDurationRole, | | |||
57 | MilliSecondsDurationRole, | | |||
58 | ArtistRole, | | |||
59 | AllArtistsRole, | | |||
60 | HighestTrackRating, | | |||
61 | AlbumRole, | | |||
62 | AlbumArtistRole, | | |||
63 | IsValidAlbumArtistRole, | | |||
64 | TrackNumberRole, | | |||
65 | DiscNumberRole, | | |||
66 | RatingRole, | | |||
67 | GenreRole, | | |||
68 | LyricistRole, | | |||
69 | ComposerRole, | | |||
70 | CommentRole, | | |||
71 | YearRole, | | |||
72 | ChannelsRole, | | |||
73 | BitRateRole, | | |||
74 | SampleRateRole, | | |||
75 | ResourceRole, | | |||
76 | IdRole, | | |||
77 | DatabaseIdRole, | | |||
78 | IsSingleDiscAlbumRole, | | |||
79 | ContainerDataRole, | | |||
80 | IsPartialDataRole, | | |||
81 | AlbumIdRole, | | |||
82 | HasEmbeddedCover, | | |||
83 | FileModificationTime, | | |||
84 | FirstPlayDate, | | |||
85 | LastPlayDate, | | |||
86 | PlayCounter, | | |||
87 | PlayFrequency, | | |||
88 | ElementTypeRole, | | |||
89 | LyricsRole, | | |||
90 | }; | | |||
91 | | ||||
92 | Q_ENUM(ColumnsRoles) | | |||
93 | | ||||
94 | private: | | |||
95 | | ||||
96 | using DataType = QMap<ColumnsRoles, QVariant>; | | |||
97 | | ||||
98 | public: | | |||
99 | | ||||
100 | class TrackDataType : public DataType | | |||
101 | { | | |||
102 | public: | | |||
103 | | ||||
104 | using DataType::DataType; | | |||
105 | | ||||
106 | bool isValid() const | | |||
107 | { | | |||
108 | return !isEmpty(); | | |||
109 | } | | |||
110 | | ||||
111 | qulonglong databaseId() const | | |||
112 | { | | |||
113 | return operator[](key_type::DatabaseIdRole).toULongLong(); | | |||
114 | } | | |||
115 | | ||||
116 | QString title() const | | |||
117 | { | | |||
118 | return operator[](key_type::TitleRole).toString(); | | |||
119 | } | | |||
120 | | ||||
121 | QString artist() const | | |||
122 | { | | |||
123 | return operator[](key_type::ArtistRole).toString(); | | |||
124 | } | | |||
125 | | ||||
126 | qulonglong albumId() const | | |||
127 | { | | |||
128 | return operator[](key_type::AlbumIdRole).toULongLong(); | | |||
129 | } | | |||
130 | | ||||
131 | bool hasAlbum() const | | |||
132 | { | | |||
133 | return find(key_type::AlbumRole) != end(); | | |||
134 | } | | |||
135 | | ||||
136 | QString album() const | | |||
137 | { | | |||
138 | return operator[](key_type::AlbumRole).toString(); | | |||
139 | } | | |||
140 | | ||||
141 | QString albumArtist() const | | |||
142 | { | | |||
143 | return operator[](key_type::AlbumArtistRole).toString(); | | |||
144 | } | | |||
145 | | ||||
146 | bool hasTrackNumber() const | | |||
147 | { | | |||
148 | return find(key_type::TrackNumberRole) != end(); | | |||
149 | } | | |||
150 | | ||||
151 | int trackNumber() const | | |||
152 | { | | |||
153 | return operator[](key_type::TrackNumberRole).toInt(); | | |||
154 | } | | |||
155 | | ||||
156 | bool hasDiscNumber() const | | |||
157 | { | | |||
158 | return find(key_type::DiscNumberRole) != end(); | | |||
159 | } | | |||
160 | | ||||
161 | int discNumber() const | | |||
162 | { | | |||
163 | return operator[](key_type::DiscNumberRole).toInt(); | | |||
164 | } | | |||
165 | | ||||
166 | QTime duration() const | | |||
167 | { | | |||
168 | return operator[](key_type::DurationRole).toTime(); | | |||
169 | } | | |||
170 | | ||||
171 | QUrl resourceURI() const | | |||
172 | { | | |||
173 | return operator[](key_type::ResourceRole).toUrl(); | | |||
174 | } | | |||
175 | | ||||
176 | QUrl albumCover() const | | |||
177 | { | | |||
178 | return operator[](key_type::ImageUrlRole).toUrl(); | | |||
179 | } | | |||
180 | | ||||
181 | bool isSingleDiscAlbum() const | | |||
182 | { | | |||
183 | return operator[](key_type::IsSingleDiscAlbumRole).toBool(); | | |||
184 | } | | |||
185 | | ||||
186 | int rating() const | | |||
187 | { | | |||
188 | return operator[](key_type::RatingRole).toInt(); | | |||
189 | } | | |||
190 | | ||||
191 | QString genre() const | | |||
192 | { | | |||
193 | return operator[](key_type::GenreRole).toString(); | | |||
194 | } | | |||
195 | | ||||
196 | QString composer() const | | |||
197 | { | | |||
198 | return operator[](key_type::ComposerRole).toString(); | | |||
199 | } | | |||
200 | | ||||
201 | QString lyricist() const | | |||
202 | { | | |||
203 | return operator[](key_type::LyricistRole).toString(); | | |||
204 | } | | |||
205 | | ||||
206 | QString lyrics() const | | |||
207 | { | | |||
208 | return operator[](key_type::LyricsRole).toString(); | | |||
209 | } | | |||
210 | | ||||
211 | QString comment() const | | |||
212 | { | | |||
213 | return operator[](key_type::CommentRole).toString(); | | |||
214 | } | | |||
215 | | ||||
216 | int year() const | | |||
217 | { | | |||
218 | return operator[](key_type::YearRole).toInt(); | | |||
219 | } | | |||
220 | | ||||
221 | int channels() const | | |||
222 | { | | |||
223 | return operator[](key_type::ChannelsRole).toInt(); | | |||
224 | } | | |||
225 | | ||||
226 | int bitRate() const | | |||
227 | { | | |||
228 | return operator[](key_type::BitRateRole).toInt(); | | |||
229 | } | | |||
230 | | ||||
231 | int sampleRate() const | | |||
232 | { | | |||
233 | return operator[](key_type::SampleRateRole).toInt(); | | |||
234 | } | | |||
235 | | ||||
236 | bool hasEmbeddedCover() const | | |||
237 | { | | |||
238 | return operator[](key_type::HasEmbeddedCover).toBool(); | | |||
239 | } | | |||
240 | | ||||
241 | QDateTime fileModificationTime() const | | |||
242 | { | | |||
243 | return operator[](key_type::FileModificationTime).toDateTime(); | | |||
244 | } | | |||
245 | }; | | |||
246 | | ||||
247 | using ListTrackDataType = QList<TrackDataType>; | | |||
248 | | ||||
249 | using ListRadioDataType = QList<TrackDataType>; | | |||
250 | | ||||
251 | class AlbumDataType : public DataType | | |||
252 | { | | |||
253 | public: | | |||
254 | | ||||
255 | using DataType::DataType; | | |||
256 | | ||||
257 | qulonglong databaseId() const | | |||
258 | { | | |||
259 | return operator[](key_type::DatabaseIdRole).toULongLong(); | | |||
260 | } | | |||
261 | | ||||
262 | QString title() const | | |||
263 | { | | |||
264 | return operator[](key_type::TitleRole).toString(); | | |||
265 | } | | |||
266 | | ||||
267 | QString artist() const | | |||
268 | { | | |||
269 | return operator[](key_type::ArtistRole).toString(); | | |||
270 | } | | |||
271 | | ||||
272 | bool isValidArtist() const | | |||
273 | { | | |||
274 | const auto &artistData = operator[](key_type::ArtistRole); | | |||
275 | return artistData.isValid() && !artistData.toString().isEmpty(); | | |||
276 | } | | |||
277 | | ||||
278 | QStringList genres() const | | |||
279 | { | | |||
280 | return operator[](key_type::GenreRole).toStringList(); | | |||
281 | } | | |||
282 | | ||||
283 | QUrl albumArtURI() const | | |||
284 | { | | |||
285 | return operator[](key_type::ImageUrlRole).toUrl(); | | |||
286 | } | | |||
287 | | ||||
288 | bool isSingleDiscAlbum() const | | |||
289 | { | | |||
290 | return operator[](key_type::IsSingleDiscAlbumRole).toBool(); | | |||
291 | } | | |||
292 | | ||||
293 | bool isValid() const | | |||
294 | { | | |||
295 | return !isEmpty(); | | |||
296 | } | | |||
297 | | ||||
298 | }; | | |||
299 | | ||||
300 | using ListAlbumDataType = QList<AlbumDataType>; | | |||
301 | | ||||
302 | class ArtistDataType : public DataType | | |||
303 | { | | |||
304 | public: | | |||
305 | | ||||
306 | using DataType::DataType; | | |||
307 | | ||||
308 | qulonglong databaseId() const | | |||
309 | { | | |||
310 | return operator[](key_type::DatabaseIdRole).toULongLong(); | | |||
311 | } | | |||
312 | | ||||
313 | }; | | |||
314 | | ||||
315 | using ListArtistDataType = QList<ArtistDataType>; | | |||
316 | | ||||
317 | class GenreDataType : public DataType | | |||
318 | { | | |||
319 | public: | | |||
320 | | ||||
321 | using DataType::DataType; | | |||
322 | | ||||
323 | qulonglong databaseId() const | | |||
324 | { | | |||
325 | return operator[](key_type::DatabaseIdRole).toULongLong(); | | |||
326 | } | | |||
327 | | ||||
328 | QString title() const | | |||
329 | { | | |||
330 | return operator[](key_type::TitleRole).toString(); | | |||
331 | } | | |||
332 | | ||||
333 | }; | | |||
334 | | ||||
335 | using ListGenreDataType = QList<GenreDataType>; | | |||
336 | | ||||
337 | enum PropertyType { | | |||
338 | DatabaseId, | | |||
339 | DisplayRole, | | |||
340 | SecondaryRole, | | |||
341 | }; | | |||
342 | | ||||
343 | Q_ENUM(PropertyType) | | |||
344 | | ||||
345 | enum AlbumDiscsCount { | | |||
346 | SingleDiscAlbum, | | |||
347 | MultipleDiscsAlbum, | | |||
348 | }; | | |||
349 | | ||||
350 | Q_ENUM(AlbumDiscsCount) | | |||
351 | | ||||
352 | explicit DatabaseInterface(QObject *parent = nullptr); | 50 | explicit DatabaseInterface(QObject *parent = nullptr); | ||
353 | 51 | | |||
354 | ~DatabaseInterface() override; | 52 | ~DatabaseInterface() override; | ||
355 | 53 | | |||
356 | Q_INVOKABLE void init(const QString &dbName, const QString &databaseFileName = {}); | 54 | Q_INVOKABLE void init(const QString &dbName, const QString &databaseFileName = {}); | ||
357 | 55 | | |||
358 | qulonglong albumIdFromTitleAndArtist(const QString &title, const QString &artist, const QString &albumPath); | 56 | qulonglong albumIdFromTitleAndArtist(const QString &title, const QString &artist, const QString &albumPath); | ||
359 | 57 | | |||
360 | ListTrackDataType allTracksData(); | 58 | DataTypes::ListTrackDataType allTracksData(); | ||
361 | 59 | | |||
362 | ListRadioDataType allRadiosData(); | 60 | DataTypes::ListRadioDataType allRadiosData(); | ||
363 | 61 | | |||
364 | ListTrackDataType recentlyPlayedTracksData(int count); | 62 | DataTypes::ListTrackDataType recentlyPlayedTracksData(int count); | ||
365 | 63 | | |||
366 | ListTrackDataType frequentlyPlayedTracksData(int count); | 64 | DataTypes::ListTrackDataType frequentlyPlayedTracksData(int count); | ||
367 | 65 | | |||
368 | ListAlbumDataType allAlbumsData(); | 66 | DataTypes::ListAlbumDataType allAlbumsData(); | ||
369 | 67 | | |||
370 | ListAlbumDataType allAlbumsDataByGenreAndArtist(const QString &genre, const QString &artist); | 68 | DataTypes::ListAlbumDataType allAlbumsDataByGenreAndArtist(const QString &genre, const QString &artist); | ||
371 | 69 | | |||
372 | ListAlbumDataType allAlbumsDataByArtist(const QString &artist); | 70 | DataTypes::ListAlbumDataType allAlbumsDataByArtist(const QString &artist); | ||
373 | 71 | | |||
374 | AlbumDataType albumDataFromDatabaseId(qulonglong id); | 72 | DataTypes::AlbumDataType albumDataFromDatabaseId(qulonglong id); | ||
375 | 73 | | |||
376 | ListTrackDataType albumData(qulonglong databaseId); | 74 | DataTypes::ListTrackDataType albumData(qulonglong databaseId); | ||
377 | 75 | | |||
378 | ListArtistDataType allArtistsData(); | 76 | DataTypes::ListArtistDataType allArtistsData(); | ||
379 | 77 | | |||
380 | ListArtistDataType allArtistsDataByGenre(const QString &genre); | 78 | DataTypes::ListArtistDataType allArtistsDataByGenre(const QString &genre); | ||
381 | 79 | | |||
382 | ListGenreDataType allGenresData(); | 80 | DataTypes::ListGenreDataType allGenresData(); | ||
383 | 81 | | |||
384 | bool internalArtistMatchGenre(qulonglong databaseId, const QString &genre); | 82 | bool internalArtistMatchGenre(qulonglong databaseId, const QString &genre); | ||
385 | 83 | | |||
386 | ListTrackDataType tracksDataFromAuthor(const QString &artistName); | 84 | DataTypes::ListTrackDataType tracksDataFromAuthor(const QString &artistName); | ||
387 | 85 | | |||
388 | TrackDataType trackDataFromDatabaseId(qulonglong id); | 86 | DataTypes::TrackDataType trackDataFromDatabaseId(qulonglong id); | ||
389 | 87 | | |||
390 | TrackDataType radioDataFromDatabaseId(qulonglong id); | 88 | DataTypes::TrackDataType radioDataFromDatabaseId(qulonglong id); | ||
391 | 89 | | |||
392 | qulonglong trackIdFromTitleAlbumTrackDiscNumber(const QString &title, const QString &artist, const std::optional<QString> &album, std::optional<int> trackNumber, std::optional<int> discNumber); | 90 | qulonglong trackIdFromTitleAlbumTrackDiscNumber(const QString &title, const QString &artist, const std::optional<QString> &album, std::optional<int> trackNumber, std::optional<int> discNumber); | ||
393 | 91 | | |||
394 | qulonglong trackIdFromFileName(const QUrl &fileName); | 92 | qulonglong trackIdFromFileName(const QUrl &fileName); | ||
395 | 93 | | |||
396 | void applicationAboutToQuit(); | 94 | void applicationAboutToQuit(); | ||
397 | 95 | | |||
398 | Q_SIGNALS: | 96 | Q_SIGNALS: | ||
399 | 97 | | |||
400 | void artistsAdded(const DatabaseInterface::ListArtistDataType &newArtists); | 98 | void artistsAdded(const DataTypes::ListArtistDataType &newArtists); | ||
401 | 99 | | |||
402 | void composersAdded(const DatabaseInterface::ListArtistDataType &newComposers); | 100 | void composersAdded(const DataTypes::ListArtistDataType &newComposers); | ||
403 | 101 | | |||
404 | void lyricistsAdded(const DatabaseInterface::ListArtistDataType &newLyricists); | 102 | void lyricistsAdded(const DataTypes::ListArtistDataType &newLyricists); | ||
405 | 103 | | |||
406 | void albumsAdded(const DatabaseInterface::ListAlbumDataType &newAlbums); | 104 | void albumsAdded(const DataTypes::ListAlbumDataType &newAlbums); | ||
407 | 105 | | |||
408 | void tracksAdded(const DatabaseInterface::ListTrackDataType &allTracks); | 106 | void tracksAdded(const DataTypes::ListTrackDataType &allTracks); | ||
409 | 107 | | |||
410 | void genresAdded(const DatabaseInterface::ListGenreDataType &allGenres); | 108 | void genresAdded(const DataTypes::ListGenreDataType &allGenres); | ||
411 | 109 | | |||
412 | void artistRemoved(qulonglong removedArtistId); | 110 | void artistRemoved(qulonglong removedArtistId); | ||
413 | 111 | | |||
414 | void albumRemoved(qulonglong removedAlbumId); | 112 | void albumRemoved(qulonglong removedAlbumId); | ||
415 | 113 | | |||
416 | void trackRemoved(qulonglong id); | 114 | void trackRemoved(qulonglong id); | ||
417 | 115 | | |||
418 | void albumModified(const DatabaseInterface::AlbumDataType &modifiedAlbum, qulonglong modifiedAlbumId); | 116 | void albumModified(const DataTypes::AlbumDataType &modifiedAlbum, qulonglong modifiedAlbumId); | ||
419 | 117 | | |||
420 | void trackModified(const DatabaseInterface::TrackDataType &modifiedTrack); | 118 | void trackModified(const DataTypes::TrackDataType &modifiedTrack); | ||
421 | 119 | | |||
422 | void requestsInitDone(); | 120 | void requestsInitDone(); | ||
423 | 121 | | |||
424 | void databaseError(); | 122 | void databaseError(); | ||
425 | 123 | | |||
426 | void restoredTracks(const QHash<QUrl, QDateTime> &allFiles); | 124 | void restoredTracks(const QHash<QUrl, QDateTime> &allFiles); | ||
427 | 125 | | |||
428 | void cleanedDatabase(); | 126 | void cleanedDatabase(); | ||
429 | 127 | | |||
430 | void finishInsertingTracksList(); | 128 | void finishInsertingTracksList(); | ||
431 | 129 | | |||
432 | void finishRemovingTracksList(); | 130 | void finishRemovingTracksList(); | ||
433 | 131 | | |||
434 | void radioAdded(const DatabaseInterface::TrackDataType &radio); | 132 | void radioAdded(const DataTypes::TrackDataType &radio); | ||
435 | 133 | | |||
436 | void radioModified(const DatabaseInterface::TrackDataType &radio); | 134 | void radioModified(const DataTypes::TrackDataType &radio); | ||
437 | 135 | | |||
438 | void radioRemoved(qulonglong radioId); | 136 | void radioRemoved(qulonglong radioId); | ||
439 | 137 | | |||
440 | public Q_SLOTS: | 138 | public Q_SLOTS: | ||
441 | 139 | | |||
442 | void insertTracksList(const QList<MusicAudioTrack> &tracks, const QHash<QString, QUrl> &covers); | 140 | void insertTracksList(const QList<MusicAudioTrack> &tracks, const QHash<QString, QUrl> &covers); | ||
443 | 141 | | |||
444 | void removeTracksList(const QList<QUrl> &removedTracks); | 142 | void removeTracksList(const QList<QUrl> &removedTracks); | ||
445 | 143 | | |||
446 | void askRestoredTracks(); | 144 | void askRestoredTracks(); | ||
447 | 145 | | |||
448 | void trackHasStartedPlaying(const QUrl &fileName, const QDateTime &time); | 146 | void trackHasStartedPlaying(const QUrl &fileName, const QDateTime &time); | ||
449 | 147 | | |||
450 | void clearData(); | 148 | void clearData(); | ||
451 | 149 | | |||
452 | void insertRadio(const DatabaseInterface::TrackDataType &oneTrack); | 150 | void insertRadio(const DataTypes::TrackDataType &oneTrack); | ||
453 | 151 | | |||
454 | void removeRadio(qulonglong radioId); | 152 | void removeRadio(qulonglong radioId); | ||
455 | 153 | | |||
456 | private: | 154 | private: | ||
457 | 155 | | |||
458 | enum class TrackFileInsertType { | 156 | enum class TrackFileInsertType { | ||
459 | NewTrackFileInsert, | 157 | NewTrackFileInsert, | ||
460 | ModifiedTrackFileInsert, | 158 | ModifiedTrackFileInsert, | ||
Show All 23 Lines | |||||
484 | qulonglong getDuplicateTrackIdFromTitleAlbumTrackDiscNumber(const QString &title, const QString &trackArtist, const QString &album, | 182 | qulonglong getDuplicateTrackIdFromTitleAlbumTrackDiscNumber(const QString &title, const QString &trackArtist, const QString &album, | ||
485 | const QString &albumArtist, const QString &trackPath, int trackNumber, | 183 | const QString &albumArtist, const QString &trackPath, int trackNumber, | ||
486 | int discNumber, int priority); | 184 | int discNumber, int priority); | ||
487 | 185 | | |||
488 | qulonglong internalTrackIdFromFileName(const QUrl &fileName); | 186 | qulonglong internalTrackIdFromFileName(const QUrl &fileName); | ||
489 | 187 | | |||
490 | qulonglong internalRadioIdFromHttpAddress(const QString &httpAddress); | 188 | qulonglong internalRadioIdFromHttpAddress(const QString &httpAddress); | ||
491 | 189 | | |||
492 | ListTrackDataType internalTracksFromAuthor(const QString &artistName); | 190 | DataTypes::ListTrackDataType internalTracksFromAuthor(const QString &artistName); | ||
493 | 191 | | |||
494 | QList<qulonglong> internalAlbumIdsFromAuthor(const QString &artistName); | 192 | QList<qulonglong> internalAlbumIdsFromAuthor(const QString &artistName); | ||
495 | 193 | | |||
496 | void initDatabase(); | 194 | void initDatabase(); | ||
497 | 195 | | |||
498 | void initRequest(); | 196 | void initRequest(); | ||
499 | 197 | | |||
500 | qulonglong insertAlbum(const QString &title, const QString &albumArtist, | 198 | qulonglong insertAlbum(const QString &title, const QString &albumArtist, | ||
Show All 24 Lines | |||||
525 | 223 | | |||
526 | void updateTrackOrigin(const QUrl &fileName, const QDateTime &fileModifiedTime); | 224 | void updateTrackOrigin(const QUrl &fileName, const QDateTime &fileModifiedTime); | ||
527 | 225 | | |||
528 | qulonglong internalInsertTrack(const MusicAudioTrack &oneModifiedTrack, | 226 | qulonglong internalInsertTrack(const MusicAudioTrack &oneModifiedTrack, | ||
529 | const QHash<QString, QUrl> &covers, bool &isInserted); | 227 | const QHash<QString, QUrl> &covers, bool &isInserted); | ||
530 | 228 | | |||
531 | MusicAudioTrack buildTrackFromDatabaseRecord(const QSqlRecord &trackRecord) const; | 229 | MusicAudioTrack buildTrackFromDatabaseRecord(const QSqlRecord &trackRecord) const; | ||
532 | 230 | | |||
533 | TrackDataType buildTrackDataFromDatabaseRecord(const QSqlRecord &trackRecord) const; | 231 | DataTypes::TrackDataType buildTrackDataFromDatabaseRecord(const QSqlRecord &trackRecord) const; | ||
534 | 232 | | |||
535 | TrackDataType buildRadioDataFromDatabaseRecord(const QSqlRecord &trackRecord) const; | 233 | DataTypes::TrackDataType buildRadioDataFromDatabaseRecord(const QSqlRecord &trackRecord) const; | ||
536 | 234 | | |||
537 | void internalRemoveTracksList(const QList<QUrl> &removedTracks); | 235 | void internalRemoveTracksList(const QList<QUrl> &removedTracks); | ||
538 | 236 | | |||
539 | void internalRemoveTracksList(const QHash<QUrl, QDateTime> &removedTracks, qulonglong sourceId); | 237 | void internalRemoveTracksList(const QHash<QUrl, QDateTime> &removedTracks, qulonglong sourceId); | ||
540 | 238 | | |||
541 | QUrl internalAlbumArtUriFromAlbumId(qulonglong albumId); | 239 | QUrl internalAlbumArtUriFromAlbumId(qulonglong albumId); | ||
542 | 240 | | |||
543 | bool isValidArtist(qulonglong albumId); | 241 | bool isValidArtist(qulonglong albumId); | ||
544 | 242 | | |||
545 | qulonglong insertComposer(const QString &name); | 243 | qulonglong insertComposer(const QString &name); | ||
546 | 244 | | |||
547 | qulonglong insertLyricist(const QString &name); | 245 | qulonglong insertLyricist(const QString &name); | ||
548 | 246 | | |||
549 | QHash<QUrl, QDateTime> internalAllFileName(); | 247 | QHash<QUrl, QDateTime> internalAllFileName(); | ||
550 | 248 | | |||
551 | bool internalGenericPartialData(QSqlQuery &query); | 249 | bool internalGenericPartialData(QSqlQuery &query); | ||
552 | 250 | | |||
553 | ListArtistDataType internalAllArtistsPartialData(QSqlQuery &artistsQuery); | 251 | DataTypes::ListArtistDataType internalAllArtistsPartialData(QSqlQuery &artistsQuery); | ||
554 | 252 | | |||
555 | ListAlbumDataType internalAllAlbumsPartialData(QSqlQuery &query); | 253 | DataTypes::ListAlbumDataType internalAllAlbumsPartialData(QSqlQuery &query); | ||
556 | 254 | | |||
557 | AlbumDataType internalOneAlbumPartialData(qulonglong databaseId); | 255 | DataTypes::AlbumDataType internalOneAlbumPartialData(qulonglong databaseId); | ||
558 | 256 | | |||
559 | ListTrackDataType internalAllTracksPartialData(); | 257 | DataTypes::ListTrackDataType internalAllTracksPartialData(); | ||
560 | 258 | | |||
561 | ListRadioDataType internalAllRadiosPartialData(); | 259 | DataTypes::ListRadioDataType internalAllRadiosPartialData(); | ||
562 | 260 | | |||
563 | ListTrackDataType internalRecentlyPlayedTracksData(int count); | 261 | DataTypes::ListTrackDataType internalRecentlyPlayedTracksData(int count); | ||
564 | 262 | | |||
565 | ListTrackDataType internalFrequentlyPlayedTracksData(int count); | 263 | DataTypes::ListTrackDataType internalFrequentlyPlayedTracksData(int count); | ||
566 | 264 | | |||
567 | TrackDataType internalOneTrackPartialData(qulonglong databaseId); | 265 | DataTypes::TrackDataType internalOneTrackPartialData(qulonglong databaseId); | ||
568 | 266 | | |||
569 | TrackDataType internalOneRadioPartialData(qulonglong databaseId); | 267 | DataTypes::TrackDataType internalOneRadioPartialData(qulonglong databaseId); | ||
570 | 268 | | |||
571 | ListGenreDataType internalAllGenresPartialData(); | 269 | DataTypes::ListGenreDataType internalAllGenresPartialData(); | ||
572 | 270 | | |||
573 | ListArtistDataType internalAllComposersPartialData(); | 271 | DataTypes::ListArtistDataType internalAllComposersPartialData(); | ||
574 | 272 | | |||
575 | ListArtistDataType internalAllLyricistsPartialData(); | 273 | DataTypes::ListArtistDataType internalAllLyricistsPartialData(); | ||
576 | 274 | | |||
577 | bool prepareQuery(QSqlQuery &query, const QString &queryText) const; | 275 | bool prepareQuery(QSqlQuery &query, const QString &queryText) const; | ||
578 | 276 | | |||
579 | bool execQuery(QSqlQuery &query); | 277 | bool execQuery(QSqlQuery &query); | ||
580 | 278 | | |||
581 | void updateAlbumArtist(qulonglong albumId, const QString &title, const QString &albumPath, | 279 | void updateAlbumArtist(qulonglong albumId, const QString &title, const QString &albumPath, | ||
582 | const QString &artistName); | 280 | const QString &artistName); | ||
583 | 281 | | |||
Show All 30 Lines | |||||
614 | void genericCheckTable(const QString &tableName, const QStringList &expectedColumns); | 312 | void genericCheckTable(const QString &tableName, const QStringList &expectedColumns); | ||
615 | 313 | | |||
616 | void resetDatabase(); | 314 | void resetDatabase(); | ||
617 | 315 | | |||
618 | std::unique_ptr<DatabaseInterfacePrivate> d; | 316 | std::unique_ptr<DatabaseInterfacePrivate> d; | ||
619 | 317 | | |||
620 | }; | 318 | }; | ||
621 | 319 | | |||
622 | Q_DECLARE_METATYPE(DatabaseInterface::TrackDataType) | | |||
623 | Q_DECLARE_METATYPE(DatabaseInterface::AlbumDataType) | | |||
624 | Q_DECLARE_METATYPE(DatabaseInterface::ArtistDataType) | | |||
625 | Q_DECLARE_METATYPE(DatabaseInterface::GenreDataType) | | |||
626 | | ||||
627 | Q_DECLARE_METATYPE(DatabaseInterface::ListTrackDataType) | | |||
628 | Q_DECLARE_METATYPE(DatabaseInterface::ListAlbumDataType) | | |||
629 | Q_DECLARE_METATYPE(DatabaseInterface::ListArtistDataType) | | |||
630 | Q_DECLARE_METATYPE(DatabaseInterface::ListGenreDataType) | | |||
631 | | ||||
632 | #endif // DATABASEINTERFACE_H | 320 | #endif // DATABASEINTERFACE_H |