/ desktop / datalake / structs.hpp
structs.hpp
  1  #pragma once
  2  #include <KFileMetaData/SimpleExtractionResult>
  3  #include <QFileInfo>
  4  #include <QList>
  5  #include <QSqlQuery>
  6  #include <QSqlRecord>
  7  #include <QString>
  8  #include <QUuid>
  9  
 10  class KotoArtist;
 11  class KotoAlbum;
 12  class KotoTrack;
 13  
 14  class KotoArtist {
 15    public:
 16      KotoArtist();
 17      static KotoArtist* fromDb(const QSqlQuery& query, const QSqlRecord& record);
 18      ~KotoArtist();
 19  
 20      QUuid uuid;
 21  
 22      void                      addAlbum(KotoAlbum* album);
 23      void                      addTrack(KotoTrack* track);
 24      void                      commit();
 25      QList<KotoAlbum*>         getAlbums();
 26      std::optional<KotoAlbum*> getAlbumByName(QString name);
 27      QString                   getName();
 28      QString                   getPath();
 29      QList<KotoTrack*>         getTracks();
 30      void                      removeAlbum(KotoAlbum* album);
 31      void                      removeTrack(KotoTrack* track);
 32      void                      setName(QString str);
 33      void                      setPath(QString str);
 34  
 35    private:
 36      QString path;
 37      QString name;
 38  
 39      QList<KotoAlbum*> albums;
 40      QList<KotoTrack*> tracks;
 41  };
 42  
 43  class KotoAlbum {
 44    public:
 45      KotoAlbum();
 46      static KotoAlbum* fromDb(const QSqlQuery& query, const QSqlRecord& record);
 47      ~KotoAlbum();
 48  
 49      QUuid uuid;
 50      QUuid artist_uuid;
 51  
 52      void               commit();
 53      QString            getAlbumArtPath();
 54      QString            getDescription();
 55      QList<QString>     getGenres();
 56      QString            getNarrator();
 57      QString            getPath();
 58      QString            getTitle();
 59      QList<KotoTrack*>  getTracks();
 60      std::optional<int> getYear();
 61  
 62      void addTrack(KotoTrack* track);
 63      void removeTrack(KotoTrack* track);
 64      void setAlbumArtPath(QString str);
 65      void setDescription(QString str);
 66      void setGenres(QList<QString> list);
 67      void setNarrator(QString str);
 68      void setPath(QString str);
 69      void setTitle(QString str);
 70      void setYear(int num);
 71  
 72    private:
 73      QString            title;
 74      QString            description;
 75      QString            narrator;
 76      std::optional<int> year;
 77  
 78      QList<QString>    genres;
 79      QList<KotoTrack*> tracks;
 80  
 81      QString path;
 82      QString album_art_path;
 83  };
 84  
 85  class KotoTrack {
 86    public:
 87      KotoTrack();  // No-op constructor
 88      static KotoTrack* fromDb(const QSqlQuery& query, const QSqlRecord& record);
 89      static KotoTrack* fromMetadata(const KFileMetaData::SimpleExtractionResult& metadata, const QFileInfo& info);
 90      ~KotoTrack();
 91  
 92      std::optional<QUuid> album_uuid;
 93      QUuid                artist_uuid;
 94      QUuid                uuid;
 95  
 96      void        commit();
 97      int         getDuration();
 98      QStringList getGenres();
 99      QString     getLyrics();
100      QString     getNarrator();
101      QString     getPath();
102      QString     getTitle();
103      int         getTrackNumber();
104      int         getYear();
105  
106      void setAlbum(KotoAlbum* album);
107      void setArtist(KotoArtist* artist);
108      void setDiscNumber(int num);
109      void setDuration(int num);
110      void setGenres(QList<QString> list);
111      void setLyrics(QString str);
112      void setNarrator(QString str);
113      void setPath(QString path);
114      void setTitle(QString str);
115      void setTrackNumber(int num);
116      void setYear(int num);
117  
118    private:
119      int         disc_number;
120      int         duration;
121      QStringList genres;
122      QString     lyrics;
123      QString     narrator;
124      QString     path;
125      QString     title;
126      int         track_number;
127      int         year;
128  };