Changeset View
Changeset View
Standalone View
Standalone View
src/databaseinterface.h
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 49 | enum ColumnsRoles { | |||
---|---|---|---|---|---|
82 | HasEmbeddedCover, | 82 | HasEmbeddedCover, | ||
83 | FileModificationTime, | 83 | FileModificationTime, | ||
84 | FirstPlayDate, | 84 | FirstPlayDate, | ||
85 | LastPlayDate, | 85 | LastPlayDate, | ||
86 | PlayCounter, | 86 | PlayCounter, | ||
87 | PlayFrequency, | 87 | PlayFrequency, | ||
88 | ElementTypeRole, | 88 | ElementTypeRole, | ||
89 | LyricsRole, | 89 | LyricsRole, | ||
90 | }; | 90 | }; | ||
astippich: I think this is unneeded, the resource role QUrl should be able to handle http adresses just… | |||||
91 | 91 | | |||
92 | Q_ENUM(ColumnsRoles) | 92 | Q_ENUM(ColumnsRoles) | ||
93 | 93 | | |||
94 | private: | 94 | private: | ||
95 | 95 | | |||
96 | using DataType = QMap<ColumnsRoles, QVariant>; | 96 | using DataType = QMap<ColumnsRoles, QVariant>; | ||
97 | 97 | | |||
98 | public: | 98 | public: | ||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Line(s) | 102 | public: | |||
241 | QDateTime fileModificationTime() const | 241 | QDateTime fileModificationTime() const | ||
242 | { | 242 | { | ||
243 | return operator[](key_type::FileModificationTime).toDateTime(); | 243 | return operator[](key_type::FileModificationTime).toDateTime(); | ||
244 | } | 244 | } | ||
245 | }; | 245 | }; | ||
246 | 246 | | |||
247 | using ListTrackDataType = QList<TrackDataType>; | 247 | using ListTrackDataType = QList<TrackDataType>; | ||
248 | 248 | | |||
249 | using ListRadioDataType = QList<TrackDataType>; | ||||
250 | | ||||
249 | class AlbumDataType : public DataType | 251 | class AlbumDataType : public DataType | ||
250 | { | 252 | { | ||
251 | public: | 253 | public: | ||
252 | 254 | | |||
253 | using DataType::DataType; | 255 | using DataType::DataType; | ||
254 | 256 | | |||
255 | qulonglong databaseId() const | 257 | qulonglong databaseId() const | ||
256 | { | 258 | { | ||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Line(s) | |||||
352 | ~DatabaseInterface() override; | 354 | ~DatabaseInterface() override; | ||
353 | 355 | | |||
354 | Q_INVOKABLE void init(const QString &dbName, const QString &databaseFileName = {}); | 356 | Q_INVOKABLE void init(const QString &dbName, const QString &databaseFileName = {}); | ||
355 | 357 | | |||
356 | qulonglong albumIdFromTitleAndArtist(const QString &title, const QString &artist, const QString &albumPath); | 358 | qulonglong albumIdFromTitleAndArtist(const QString &title, const QString &artist, const QString &albumPath); | ||
357 | 359 | | |||
358 | ListTrackDataType allTracksData(); | 360 | ListTrackDataType allTracksData(); | ||
359 | 361 | | |||
362 | ListRadioDataType allRadiosData(); | ||||
363 | | ||||
360 | ListTrackDataType recentlyPlayedTracksData(int count); | 364 | ListTrackDataType recentlyPlayedTracksData(int count); | ||
361 | 365 | | |||
362 | ListTrackDataType frequentlyPlayedTracksData(int count); | 366 | ListTrackDataType frequentlyPlayedTracksData(int count); | ||
363 | 367 | | |||
364 | ListAlbumDataType allAlbumsData(); | 368 | ListAlbumDataType allAlbumsData(); | ||
365 | 369 | | |||
366 | ListAlbumDataType allAlbumsDataByGenreAndArtist(const QString &genre, const QString &artist); | 370 | ListAlbumDataType allAlbumsDataByGenreAndArtist(const QString &genre, const QString &artist); | ||
367 | 371 | | |||
Show All 10 Lines | |||||
378 | ListGenreDataType allGenresData(); | 382 | ListGenreDataType allGenresData(); | ||
379 | 383 | | |||
380 | bool internalArtistMatchGenre(qulonglong databaseId, const QString &genre); | 384 | bool internalArtistMatchGenre(qulonglong databaseId, const QString &genre); | ||
381 | 385 | | |||
382 | ListTrackDataType tracksDataFromAuthor(const QString &artistName); | 386 | ListTrackDataType tracksDataFromAuthor(const QString &artistName); | ||
383 | 387 | | |||
384 | TrackDataType trackDataFromDatabaseId(qulonglong id); | 388 | TrackDataType trackDataFromDatabaseId(qulonglong id); | ||
385 | 389 | | |||
386 | qulonglong trackIdFromTitleAlbumTrackDiscNumber(const QString &title, const QString &artist, const std::optional<QString> &album, | 390 | TrackDataType radioDataFromDatabaseId(qulonglong id); | ||
387 | std::optional<int> trackNumber, std::optional<int> discNumber); | 391 | | ||
392 | qulonglong trackIdFromTitleAlbumTrackDiscNumber(const QString &title, const QString &artist, const std::optional<QString> &album, std::optional<int> trackNumber, std::optional<int> discNumber); | ||||
mgallien: Please remove this unrelated change. | |||||
388 | 393 | | |||
389 | qulonglong trackIdFromFileName(const QUrl &fileName); | 394 | qulonglong trackIdFromFileName(const QUrl &fileName); | ||
390 | 395 | | |||
391 | void applicationAboutToQuit(); | 396 | void applicationAboutToQuit(); | ||
392 | 397 | | |||
393 | Q_SIGNALS: | 398 | Q_SIGNALS: | ||
394 | 399 | | |||
395 | void artistsAdded(const DatabaseInterface::ListArtistDataType &newArtists); | 400 | void artistsAdded(const DatabaseInterface::ListArtistDataType &newArtists); | ||
Show All 25 Lines | |||||
421 | void restoredTracks(QHash<QUrl, QDateTime> allFiles); | 426 | void restoredTracks(QHash<QUrl, QDateTime> allFiles); | ||
422 | 427 | | |||
423 | void cleanedDatabase(); | 428 | void cleanedDatabase(); | ||
424 | 429 | | |||
425 | void finishInsertingTracksList(); | 430 | void finishInsertingTracksList(); | ||
426 | 431 | | |||
427 | void finishRemovingTracksList(); | 432 | void finishRemovingTracksList(); | ||
428 | 433 | | |||
434 | void radioAdded(const DatabaseInterface::TrackDataType radio); | ||||
435 | | ||||
436 | void radioModified(const DatabaseInterface::TrackDataType radio); | ||||
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. | |||||
437 | | ||||
438 | void radioRemoved(qulonglong radioId); | ||||
439 | | ||||
429 | public Q_SLOTS: | 440 | public Q_SLOTS: | ||
430 | 441 | | |||
431 | void insertTracksList(const QList<MusicAudioTrack> &tracks, const QHash<QString, QUrl> &covers); | 442 | void insertTracksList(const QList<MusicAudioTrack> &tracks, const QHash<QString, QUrl> &covers); | ||
432 | 443 | | |||
433 | void removeTracksList(const QList<QUrl> &removedTracks); | 444 | void removeTracksList(const QList<QUrl> &removedTracks); | ||
434 | 445 | | |||
435 | void askRestoredTracks(); | 446 | void askRestoredTracks(); | ||
436 | 447 | | |||
437 | void trackHasStartedPlaying(const QUrl &fileName, const QDateTime &time); | 448 | void trackHasStartedPlaying(const QUrl &fileName, const QDateTime &time); | ||
438 | 449 | | |||
439 | void clearData(); | 450 | void clearData(); | ||
440 | 451 | | |||
452 | void insertRadio(const TrackDataType &oneTrack); | ||||
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… | |||||
453 | | ||||
454 | void removeRadio(qulonglong radioId); | ||||
455 | | ||||
441 | private: | 456 | private: | ||
442 | 457 | | |||
443 | enum class TrackFileInsertType { | 458 | enum class TrackFileInsertType { | ||
444 | NewTrackFileInsert, | 459 | NewTrackFileInsert, | ||
445 | ModifiedTrackFileInsert, | 460 | ModifiedTrackFileInsert, | ||
446 | }; | 461 | }; | ||
447 | 462 | | |||
448 | void initChangesTrackers(); | 463 | void initChangesTrackers(); | ||
Show All 18 Lines | 481 | qulonglong internalTrackIdFromTitleAlbumTracDiscNumber(const QString &title, const QString &artist, const std::optional<QString> &album, | |||
467 | std::optional<int> trackNumber, std::optional<int> discNumber); | 482 | std::optional<int> trackNumber, std::optional<int> discNumber); | ||
468 | 483 | | |||
469 | qulonglong getDuplicateTrackIdFromTitleAlbumTrackDiscNumber(const QString &title, const QString &trackArtist, const QString &album, | 484 | qulonglong getDuplicateTrackIdFromTitleAlbumTrackDiscNumber(const QString &title, const QString &trackArtist, const QString &album, | ||
470 | const QString &albumArtist, const QString &trackPath, int trackNumber, | 485 | const QString &albumArtist, const QString &trackPath, int trackNumber, | ||
471 | int discNumber, int priority); | 486 | int discNumber, int priority); | ||
472 | 487 | | |||
473 | qulonglong internalTrackIdFromFileName(const QUrl &fileName); | 488 | qulonglong internalTrackIdFromFileName(const QUrl &fileName); | ||
474 | 489 | | |||
490 | qulonglong internalRadioIdFromHttpAddress(const QString &httpAddress); | ||||
491 | | ||||
475 | ListTrackDataType internalTracksFromAuthor(const QString &artistName); | 492 | ListTrackDataType internalTracksFromAuthor(const QString &artistName); | ||
476 | 493 | | |||
477 | QList<qulonglong> internalAlbumIdsFromAuthor(const QString &artistName); | 494 | QList<qulonglong> internalAlbumIdsFromAuthor(const QString &artistName); | ||
478 | 495 | | |||
479 | void initDatabase(); | 496 | void initDatabase(); | ||
480 | 497 | | |||
481 | void initRequest(); | 498 | void initRequest(); | ||
482 | 499 | | |||
Show All 27 Lines | |||||
510 | 527 | | |||
511 | qulonglong internalInsertTrack(const MusicAudioTrack &oneModifiedTrack, | 528 | qulonglong internalInsertTrack(const MusicAudioTrack &oneModifiedTrack, | ||
512 | const QHash<QString, QUrl> &covers, bool &isInserted); | 529 | const QHash<QString, QUrl> &covers, bool &isInserted); | ||
513 | 530 | | |||
514 | MusicAudioTrack buildTrackFromDatabaseRecord(const QSqlRecord &trackRecord) const; | 531 | MusicAudioTrack buildTrackFromDatabaseRecord(const QSqlRecord &trackRecord) const; | ||
515 | 532 | | |||
516 | TrackDataType buildTrackDataFromDatabaseRecord(const QSqlRecord &trackRecord) const; | 533 | TrackDataType buildTrackDataFromDatabaseRecord(const QSqlRecord &trackRecord) const; | ||
517 | 534 | | |||
535 | TrackDataType buildRadioDataFromDatabaseRecord(const QSqlRecord &trackRecord) const; | ||||
536 | | ||||
518 | void internalRemoveTracksList(const QList<QUrl> &removedTracks); | 537 | void internalRemoveTracksList(const QList<QUrl> &removedTracks); | ||
519 | 538 | | |||
520 | void internalRemoveTracksList(const QHash<QUrl, QDateTime> &removedTracks, qulonglong sourceId); | 539 | void internalRemoveTracksList(const QHash<QUrl, QDateTime> &removedTracks, qulonglong sourceId); | ||
521 | 540 | | |||
522 | QUrl internalAlbumArtUriFromAlbumId(qulonglong albumId); | 541 | QUrl internalAlbumArtUriFromAlbumId(qulonglong albumId); | ||
523 | 542 | | |||
524 | bool isValidArtist(qulonglong albumId); | 543 | bool isValidArtist(qulonglong albumId); | ||
525 | 544 | | |||
526 | qulonglong insertComposer(const QString &name); | 545 | qulonglong insertComposer(const QString &name); | ||
527 | 546 | | |||
528 | qulonglong insertLyricist(const QString &name); | 547 | qulonglong insertLyricist(const QString &name); | ||
529 | 548 | | |||
530 | QHash<QUrl, QDateTime> internalAllFileName(); | 549 | QHash<QUrl, QDateTime> internalAllFileName(); | ||
531 | 550 | | |||
532 | bool internalGenericPartialData(QSqlQuery &query); | 551 | bool internalGenericPartialData(QSqlQuery &query); | ||
533 | 552 | | |||
534 | ListArtistDataType internalAllArtistsPartialData(QSqlQuery &artistsQuery); | 553 | ListArtistDataType internalAllArtistsPartialData(QSqlQuery &artistsQuery); | ||
535 | 554 | | |||
536 | ListAlbumDataType internalAllAlbumsPartialData(QSqlQuery &query); | 555 | ListAlbumDataType internalAllAlbumsPartialData(QSqlQuery &query); | ||
537 | 556 | | |||
538 | AlbumDataType internalOneAlbumPartialData(qulonglong databaseId); | 557 | AlbumDataType internalOneAlbumPartialData(qulonglong databaseId); | ||
539 | 558 | | |||
540 | ListTrackDataType internalAllTracksPartialData(); | 559 | ListTrackDataType internalAllTracksPartialData(); | ||
541 | 560 | | |||
561 | ListRadioDataType internalAllRadiosPartialData(); | ||||
562 | | ||||
542 | ListTrackDataType internalRecentlyPlayedTracksData(int count); | 563 | ListTrackDataType internalRecentlyPlayedTracksData(int count); | ||
543 | 564 | | |||
544 | ListTrackDataType internalFrequentlyPlayedTracksData(int count); | 565 | ListTrackDataType internalFrequentlyPlayedTracksData(int count); | ||
545 | 566 | | |||
546 | TrackDataType internalOneTrackPartialData(qulonglong databaseId); | 567 | TrackDataType internalOneTrackPartialData(qulonglong databaseId); | ||
547 | 568 | | |||
569 | TrackDataType internalOneRadioPartialData(qulonglong databaseId); | ||||
570 | | ||||
548 | ListGenreDataType internalAllGenresPartialData(); | 571 | ListGenreDataType internalAllGenresPartialData(); | ||
549 | 572 | | |||
550 | ListArtistDataType internalAllComposersPartialData(); | 573 | ListArtistDataType internalAllComposersPartialData(); | ||
551 | 574 | | |||
552 | ListArtistDataType internalAllLyricistsPartialData(); | 575 | ListArtistDataType internalAllLyricistsPartialData(); | ||
553 | 576 | | |||
554 | bool prepareQuery(QSqlQuery &query, const QString &queryText) const; | 577 | bool prepareQuery(QSqlQuery &query, const QString &queryText) const; | ||
555 | 578 | | |||
Show All 9 Lines | |||||
565 | void upgradeDatabaseV9(); | 588 | void upgradeDatabaseV9(); | ||
566 | 589 | | |||
567 | void upgradeDatabaseV11(); | 590 | void upgradeDatabaseV11(); | ||
568 | 591 | | |||
569 | void upgradeDatabaseV12(); | 592 | void upgradeDatabaseV12(); | ||
570 | 593 | | |||
571 | void upgradeDatabaseV13(); | 594 | void upgradeDatabaseV13(); | ||
572 | 595 | | |||
596 | void upgradeDatabaseV14(); | ||||
597 | | ||||
573 | void checkDatabaseSchema(); | 598 | void checkDatabaseSchema(); | ||
574 | 599 | | |||
575 | void checkAlbumsTableSchema(); | 600 | void checkAlbumsTableSchema(); | ||
576 | 601 | | |||
577 | void checkArtistsTableSchema(); | 602 | void checkArtistsTableSchema(); | ||
578 | 603 | | |||
579 | void checkComposerTableSchema(); | 604 | void checkComposerTableSchema(); | ||
580 | 605 | | |||
Show All 27 Lines |
I think this is unneeded, the resource role QUrl should be able to handle http adresses just fine.