2022-11-25 15:41:50 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QFileSystemWatcher>
|
|
|
|
#include <QUrl>
|
|
|
|
|
|
|
|
class FigmaLinks;
|
|
|
|
|
|
|
|
class FigmaLinksSource : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QUrl filePath READ getFilePath WRITE setFilePath NOTIFY filePathChanged)
|
|
|
|
Q_PROPERTY(FigmaLinks* figmaLinks READ getFigmaLinks NOTIFY figmaLinksChanged)
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit FigmaLinksSource(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
const QUrl& getFilePath() const;
|
|
|
|
void setFilePath(const QUrl& path);
|
|
|
|
FigmaLinks* getFigmaLinks() const;
|
|
|
|
|
2022-11-29 10:51:19 +00:00
|
|
|
Q_INVOKABLE void remove(const QString &key, const QList<int> &indexes);
|
|
|
|
Q_INVOKABLE void append(const QString &key, const QList<QString> &links);
|
|
|
|
|
2022-11-25 15:41:50 +00:00
|
|
|
signals:
|
|
|
|
void filePathChanged();
|
|
|
|
void figmaLinksChanged();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void updateFigmaLinks(const QMap<QString, QStringList>& map);
|
|
|
|
void readFile();
|
|
|
|
void setupWatcher();
|
|
|
|
|
|
|
|
FigmaLinks *m_figmaLinks = nullptr;
|
|
|
|
QUrl m_filePath;
|
|
|
|
QFileSystemWatcher m_watcher;
|
|
|
|
};
|