Changeset View
Changeset View
Standalone View
Standalone View
src/databaseinterface.h
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | 49 | enum ColumnsRoles { | |||
---|---|---|---|---|---|
81 | HasEmbeddedCover, | 81 | HasEmbeddedCover, | ||
82 | FileModificationTime, | 82 | FileModificationTime, | ||
83 | FirstPlayDate, | 83 | FirstPlayDate, | ||
84 | LastPlayDate, | 84 | LastPlayDate, | ||
85 | PlayCounter, | 85 | PlayCounter, | ||
86 | PlayFrequency, | 86 | PlayFrequency, | ||
87 | ElementTypeRole, | 87 | ElementTypeRole, | ||
88 | LyricsRole, | 88 | LyricsRole, | ||
89 | HttpAddressRole, | ||||
astippich: I think this is unneeded, the resource role QUrl should be able to handle http adresses just… | |||||
89 | }; | 90 | }; | ||
90 | 91 | | |||
91 | Q_ENUM(ColumnsRoles) | 92 | Q_ENUM(ColumnsRoles) | ||
92 | 93 | | |||
93 | private: | 94 | private: | ||
94 | 95 | | |||
95 | using DataType = QMap<ColumnsRoles, QVariant>; | 96 | using DataType = QMap<ColumnsRoles, QVariant>; | ||
96 | 97 | | |||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Line(s) | 102 | public: | |||
221 | { | 222 | { | ||
222 | return operator[](key_type::HasEmbeddedCover).toBool(); | 223 | return operator[](key_type::HasEmbeddedCover).toBool(); | ||
223 | } | 224 | } | ||
224 | 225 | | |||
225 | QDateTime fileModificationTime() const | 226 | QDateTime fileModificationTime() const | ||
226 | { | 227 | { | ||
227 | return operator[](key_type::FileModificationTime).toDateTime(); | 228 | return operator[](key_type::FileModificationTime).toDateTime(); | ||
228 | } | 229 | } | ||
230 | | ||||
231 | QString httpAddress() const | ||||
232 | { | ||||
233 | return operator[](key_type::HttpAddressRole).toString(); | ||||
234 | } | ||||
229 | }; | 235 | }; | ||
230 | 236 | | |||
231 | using ListTrackDataType = QList<TrackDataType>; | 237 | using ListTrackDataType = QList<TrackDataType>; | ||
232 | 238 | | |||
233 | class AlbumDataType : public DataType | 239 | class AlbumDataType : public DataType | ||
234 | { | 240 | { | ||
235 | public: | 241 | public: | ||
236 | 242 | | |||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | |||||
336 | ~DatabaseInterface() override; | 342 | ~DatabaseInterface() override; | ||
337 | 343 | | |||
338 | Q_INVOKABLE void init(const QString &dbName, const QString &databaseFileName = {}); | 344 | Q_INVOKABLE void init(const QString &dbName, const QString &databaseFileName = {}); | ||
339 | 345 | | |||
340 | qulonglong albumIdFromTitleAndArtist(const QString &title, const QString &artist); | 346 | qulonglong albumIdFromTitleAndArtist(const QString &title, const QString &artist); | ||
341 | 347 | | |||
342 | ListTrackDataType allTracksData(); | 348 | ListTrackDataType allTracksData(); | ||
343 | 349 | | |||
350 | ListTrackDataType allRadiosData(); | ||||
351 | | ||||
344 | ListTrackDataType recentlyPlayedTracksData(int count); | 352 | ListTrackDataType recentlyPlayedTracksData(int count); | ||
345 | 353 | | |||
346 | ListTrackDataType frequentlyPlayedTracksData(int count); | 354 | ListTrackDataType frequentlyPlayedTracksData(int count); | ||
347 | 355 | | |||
348 | ListAlbumDataType allAlbumsData(); | 356 | ListAlbumDataType allAlbumsData(); | ||
349 | 357 | | |||
350 | ListAlbumDataType allAlbumsDataByGenreAndArtist(const QString &genre, const QString &artist); | 358 | ListAlbumDataType allAlbumsDataByGenreAndArtist(const QString &genre, const QString &artist); | ||
351 | 359 | | |||
Show All 10 Lines | |||||
362 | ListGenreDataType allGenresData(); | 370 | ListGenreDataType allGenresData(); | ||
363 | 371 | | |||
364 | bool internalArtistMatchGenre(qulonglong databaseId, const QString &genre); | 372 | bool internalArtistMatchGenre(qulonglong databaseId, const QString &genre); | ||
365 | 373 | | |||
366 | ListTrackDataType tracksDataFromAuthor(const QString &artistName); | 374 | ListTrackDataType tracksDataFromAuthor(const QString &artistName); | ||
367 | 375 | | |||
368 | TrackDataType trackDataFromDatabaseId(qulonglong id); | 376 | TrackDataType trackDataFromDatabaseId(qulonglong id); | ||
369 | 377 | | |||
378 | TrackDataType radioDataFromDatabaseId(qulonglong id); | ||||
379 | | ||||
370 | qulonglong trackIdFromTitleAlbumTrackDiscNumber(const QString &title, const QString &artist, const QString &album, | 380 | qulonglong trackIdFromTitleAlbumTrackDiscNumber(const QString &title, const QString &artist, const QString &album, | ||
371 | int trackNumber, int discNumber); | 381 | int trackNumber, int discNumber); | ||
372 | 382 | | |||
mgallien: Please remove this unrelated change. | |||||
373 | qulonglong trackIdFromFileName(const QUrl &fileName); | 383 | qulonglong trackIdFromFileName(const QUrl &fileName); | ||
374 | 384 | | |||
375 | void applicationAboutToQuit(); | 385 | void applicationAboutToQuit(); | ||
376 | 386 | | |||
377 | Q_SIGNALS: | 387 | Q_SIGNALS: | ||
378 | 388 | | |||
379 | void artistsAdded(const DatabaseInterface::ListArtistDataType &newArtists); | 389 | void artistsAdded(const DatabaseInterface::ListArtistDataType &newArtists); | ||
380 | 390 | | |||
Show All 24 Lines | |||||
405 | void restoredTracks(QHash<QUrl, QDateTime> allFiles); | 415 | void restoredTracks(QHash<QUrl, QDateTime> allFiles); | ||
406 | 416 | | |||
407 | void cleanedDatabase(); | 417 | void cleanedDatabase(); | ||
408 | 418 | | |||
409 | void finishInsertingTracksList(); | 419 | void finishInsertingTracksList(); | ||
410 | 420 | | |||
411 | void finishRemovingTracksList(); | 421 | void finishRemovingTracksList(); | ||
412 | 422 | | |||
413 | public Q_SLOTS: | 423 | public Q_SLOTS: | ||
414 | 424 | | |||
415 | void insertTracksList(const QList<MusicAudioTrack> &tracks, const QHash<QString, QUrl> &covers); | 425 | void insertTracksList(const QList<MusicAudioTrack> &tracks, const QHash<QString, QUrl> &covers); | ||
can you make them consistently with the other, e.g. radioRemoved(), radiosAdded()? astippich: can you make them consistently with the other, e.g. radioRemoved(), radiosAdded()? | |||||
Why are they needed ? mgallien: Why are they needed ?
The database should just signal that a radio has been modified or removed… | |||||
updateUIAfterRadioDeleted has the same role as trackRemoved for tracks. I think I should name them radioRemoved and radioModified. jguidon: updateUIAfterRadioDeleted has the same role as trackRemoved for tracks. | |||||
416 | 426 | | |||
417 | void removeTracksList(const QList<QUrl> &removedTracks); | 427 | void removeTracksList(const QList<QUrl> &removedTracks); | ||
418 | 428 | | |||
419 | void askRestoredTracks(); | 429 | void askRestoredTracks(); | ||
420 | 430 | | |||
421 | void trackHasStartedPlaying(const QUrl &fileName, const QDateTime &time); | 431 | void trackHasStartedPlaying(const QUrl &fileName, const QDateTime &time); | ||
422 | 432 | | |||
423 | void clearData(); | 433 | void clearData(); | ||
424 | 434 | | |||
425 | private: | 435 | private: | ||
Is update also dealing with insert ? If it is the case, please follow the existing convention of using insert for insert or modify. You can always change all of them in a later diff. mgallien: Is update also dealing with insert ? If it is the case, please follow the existing convention… | |||||
426 | 436 | | |||
427 | enum class TrackFileInsertType { | 437 | enum class TrackFileInsertType { | ||
428 | NewTrackFileInsert, | 438 | NewTrackFileInsert, | ||
429 | ModifiedTrackFileInsert, | 439 | ModifiedTrackFileInsert, | ||
430 | }; | 440 | }; | ||
431 | 441 | | |||
432 | void initChangesTrackers(); | 442 | void initChangesTrackers(); | ||
433 | 443 | | |||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | |||||
495 | 505 | | |||
496 | qulonglong internalInsertTrack(const MusicAudioTrack &oneModifiedTrack, | 506 | qulonglong internalInsertTrack(const MusicAudioTrack &oneModifiedTrack, | ||
497 | const QHash<QString, QUrl> &covers, bool &isInserted); | 507 | const QHash<QString, QUrl> &covers, bool &isInserted); | ||
498 | 508 | | |||
499 | MusicAudioTrack buildTrackFromDatabaseRecord(const QSqlRecord &trackRecord) const; | 509 | MusicAudioTrack buildTrackFromDatabaseRecord(const QSqlRecord &trackRecord) const; | ||
500 | 510 | | |||
501 | TrackDataType buildTrackDataFromDatabaseRecord(const QSqlRecord &trackRecord) const; | 511 | TrackDataType buildTrackDataFromDatabaseRecord(const QSqlRecord &trackRecord) const; | ||
502 | 512 | | |||
513 | TrackDataType buildRadioDataFromDatabaseRecord(const QSqlRecord &trackRecord) const; | ||||
514 | | ||||
503 | void internalRemoveTracksList(const QList<QUrl> &removedTracks); | 515 | void internalRemoveTracksList(const QList<QUrl> &removedTracks); | ||
504 | 516 | | |||
505 | void internalRemoveTracksList(const QHash<QUrl, QDateTime> &removedTracks, qulonglong sourceId); | 517 | void internalRemoveTracksList(const QHash<QUrl, QDateTime> &removedTracks, qulonglong sourceId); | ||
506 | 518 | | |||
507 | QUrl internalAlbumArtUriFromAlbumId(qulonglong albumId); | 519 | QUrl internalAlbumArtUriFromAlbumId(qulonglong albumId); | ||
508 | 520 | | |||
509 | bool isValidArtist(qulonglong albumId); | 521 | bool isValidArtist(qulonglong albumId); | ||
510 | 522 | | |||
511 | qulonglong insertComposer(const QString &name); | 523 | qulonglong insertComposer(const QString &name); | ||
512 | 524 | | |||
513 | qulonglong insertLyricist(const QString &name); | 525 | qulonglong insertLyricist(const QString &name); | ||
514 | 526 | | |||
515 | QHash<QUrl, QDateTime> internalAllFileName(); | 527 | QHash<QUrl, QDateTime> internalAllFileName(); | ||
516 | 528 | | |||
517 | bool internalGenericPartialData(QSqlQuery &query); | 529 | bool internalGenericPartialData(QSqlQuery &query); | ||
518 | 530 | | |||
519 | ListArtistDataType internalAllArtistsPartialData(QSqlQuery &artistsQuery); | 531 | ListArtistDataType internalAllArtistsPartialData(QSqlQuery &artistsQuery); | ||
520 | 532 | | |||
521 | ListAlbumDataType internalAllAlbumsPartialData(QSqlQuery &query); | 533 | ListAlbumDataType internalAllAlbumsPartialData(QSqlQuery &query); | ||
522 | 534 | | |||
523 | AlbumDataType internalOneAlbumPartialData(qulonglong databaseId); | 535 | AlbumDataType internalOneAlbumPartialData(qulonglong databaseId); | ||
524 | 536 | | |||
525 | ListTrackDataType internalAllTracksPartialData(); | 537 | ListTrackDataType internalAllTracksPartialData(); | ||
526 | 538 | | |||
539 | ListTrackDataType internalAllRadiosPartialData(); | ||||
540 | | ||||
527 | ListTrackDataType internalRecentlyPlayedTracksData(int count); | 541 | ListTrackDataType internalRecentlyPlayedTracksData(int count); | ||
528 | 542 | | |||
529 | ListTrackDataType internalFrequentlyPlayedTracksData(int count); | 543 | ListTrackDataType internalFrequentlyPlayedTracksData(int count); | ||
530 | 544 | | |||
531 | TrackDataType internalOneTrackPartialData(qulonglong databaseId); | 545 | TrackDataType internalOneTrackPartialData(qulonglong databaseId); | ||
532 | 546 | | |||
547 | TrackDataType internalOneRadioPartialData(qulonglong databaseId); | ||||
548 | | ||||
533 | ListGenreDataType internalAllGenresPartialData(); | 549 | ListGenreDataType internalAllGenresPartialData(); | ||
534 | 550 | | |||
535 | ListArtistDataType internalAllComposersPartialData(); | 551 | ListArtistDataType internalAllComposersPartialData(); | ||
536 | 552 | | |||
537 | ListArtistDataType internalAllLyricistsPartialData(); | 553 | ListArtistDataType internalAllLyricistsPartialData(); | ||
538 | 554 | | |||
539 | bool prepareQuery(QSqlQuery &query, const QString &queryText) const; | 555 | bool prepareQuery(QSqlQuery &query, const QString &queryText) const; | ||
540 | 556 | | |||
541 | bool execQuery(QSqlQuery &query); | 557 | bool execQuery(QSqlQuery &query); | ||
542 | 558 | | |||
543 | void updateAlbumArtist(qulonglong albumId, const QString &title, const QString &albumPath, | 559 | void updateAlbumArtist(qulonglong albumId, const QString &title, const QString &albumPath, | ||
544 | const QString &artistName); | 560 | const QString &artistName); | ||
545 | 561 | | |||
546 | void updateTrackStatistics(const QUrl &fileName, const QDateTime &time); | 562 | void updateTrackStatistics(const QUrl &fileName, const QDateTime &time); | ||
547 | 563 | | |||
548 | void createDatabaseV9(); | 564 | void createDatabaseV9(); | ||
549 | 565 | | |||
550 | void upgradeDatabaseV9(); | 566 | void upgradeDatabaseV9(); | ||
551 | 567 | | |||
552 | void upgradeDatabaseV11(); | 568 | void upgradeDatabaseV11(); | ||
553 | 569 | | |||
554 | void upgradeDatabaseV12(); | 570 | void upgradeDatabaseV12(); | ||
555 | 571 | | |||
572 | void upgradeDatabaseV13(); | ||||
573 | | ||||
556 | void checkDatabaseSchema(); | 574 | void checkDatabaseSchema(); | ||
557 | 575 | | |||
558 | void checkAlbumsTableSchema(); | 576 | void checkAlbumsTableSchema(); | ||
559 | 577 | | |||
560 | void checkArtistsTableSchema(); | 578 | void checkArtistsTableSchema(); | ||
561 | 579 | | |||
562 | void checkComposerTableSchema(); | 580 | void checkComposerTableSchema(); | ||
563 | 581 | | |||
Show All 27 Lines |
I think this is unneeded, the resource role QUrl should be able to handle http adresses just fine.