2024-10-02 17:51:51 +03:00
|
|
|
#pragma once
|
|
|
|
|
2024-10-27 19:16:30 +02:00
|
|
|
#include <QtQml/qqmlregistration.h>
|
|
|
|
|
2024-10-02 17:51:51 +03:00
|
|
|
#include <QHash>
|
2024-10-27 19:16:30 +02:00
|
|
|
#include <QQmlEngine>
|
|
|
|
#include <QQmlListProperty>
|
2024-10-02 17:51:51 +03:00
|
|
|
#include <QString>
|
|
|
|
#include <QUuid>
|
|
|
|
#include <optional>
|
|
|
|
|
|
|
|
#include "structs.hpp"
|
|
|
|
|
2024-10-27 19:16:30 +02:00
|
|
|
class Cartographer : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
QML_ELEMENT
|
|
|
|
QML_SINGLETON
|
|
|
|
// Q_PROPERTY(QQmlListProperty<KotoAlbum*> albums READ getAlbumsQml)
|
2024-10-28 19:20:35 +02:00
|
|
|
Q_PROPERTY(KotoArtistModel* artists READ getArtistsModel CONSTANT)
|
2024-10-27 19:16:30 +02:00
|
|
|
// Q_PROPERTY(QQmlListProperty<KotoTrack*> tracks READ getTracksQml)
|
|
|
|
|
2024-10-02 17:51:51 +03:00
|
|
|
public:
|
2024-10-28 19:20:35 +02:00
|
|
|
Cartographer(QObject* parent);
|
2024-10-02 17:51:51 +03:00
|
|
|
static Cartographer& instance();
|
2024-10-28 19:20:35 +02:00
|
|
|
static Cartographer* create(QQmlEngine*, QJSEngine*) {
|
|
|
|
QQmlEngine::setObjectOwnership(&instance(), QQmlEngine::CppOwnership);
|
|
|
|
return &instance();
|
|
|
|
}
|
2024-10-27 19:16:30 +02:00
|
|
|
|
|
|
|
void addAlbum(KotoAlbum* album);
|
|
|
|
void addArtist(KotoArtist* artist);
|
|
|
|
void addTrack(KotoTrack* track);
|
|
|
|
|
|
|
|
// QQmlListProperty<KotoAlbum*> getAlbumsQml();
|
|
|
|
KotoArtistModel* getArtistsModel();
|
|
|
|
// QQmlListProperty<KotoTrack*> getTracksQml();
|
2024-10-02 17:51:51 +03:00
|
|
|
|
2024-10-05 00:03:50 +03:00
|
|
|
std::optional<KotoAlbum*> getAlbum(QUuid uuid);
|
|
|
|
QList<KotoAlbum*> getAlbums();
|
2024-10-02 17:51:51 +03:00
|
|
|
std::optional<KotoArtist*> getArtist(QUuid uuid);
|
2024-10-05 00:03:50 +03:00
|
|
|
QList<KotoArtist*> getArtists();
|
2024-10-02 17:51:51 +03:00
|
|
|
std::optional<KotoArtist*> getArtist(QString name);
|
|
|
|
std::optional<KotoTrack*> getTrack(QUuid uuid);
|
2024-10-05 00:03:50 +03:00
|
|
|
QList<KotoTrack*> getTracks();
|
2024-10-02 17:51:51 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
QHash<QUuid, KotoAlbum*> i_albums;
|
2024-10-27 19:16:30 +02:00
|
|
|
KotoArtistModel* i_artists_model;
|
2024-10-02 17:51:51 +03:00
|
|
|
QHash<QString, KotoArtist*> i_artists_by_name;
|
|
|
|
QHash<QUuid, KotoTrack*> i_tracks;
|
|
|
|
};
|