mirror of
https://github.com/YACReader/yacreader
synced 2025-07-14 02:54:46 -04:00
Refactor YACReaderLibraries
It includes a new UUID per library (which isn't used yet) and a new class YACReaderLibrary that replaces the old `QMap<QString, QPair<int, QString>>`.
This commit is contained in:
@ -3,6 +3,8 @@
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
class YACReaderLibrary;
|
||||
|
||||
class YACReaderLibraries : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -22,15 +24,37 @@ public:
|
||||
void rename(const QString &oldName, const QString &newName);
|
||||
int getId(const QString &name);
|
||||
YACReaderLibraries &operator=(const YACReaderLibraries &source);
|
||||
QMap<QString, QPair<int, QString>> getLibraries();
|
||||
QList<YACReaderLibrary> getLibraries() const;
|
||||
public slots:
|
||||
void addLibrary(const QString &name, const QString &path);
|
||||
void load();
|
||||
bool save();
|
||||
|
||||
private:
|
||||
// name <id,path>
|
||||
QMap<QString, QPair<int, QString>> libraries;
|
||||
QList<YACReaderLibrary> libraries;
|
||||
};
|
||||
|
||||
class YACReaderLibrary
|
||||
{
|
||||
public:
|
||||
YACReaderLibrary();
|
||||
YACReaderLibrary(const QString &name, const QString &path, int legacyId, const QUuid &id);
|
||||
QString getName() const;
|
||||
QString getPath() const;
|
||||
QString getDBPath() const;
|
||||
int getLegacyId() const;
|
||||
QUuid getId() const;
|
||||
bool operator==(const YACReaderLibrary &other) const;
|
||||
bool operator!=(const YACReaderLibrary &other) const;
|
||||
friend QDataStream &operator<<(QDataStream &out, const YACReaderLibrary &library);
|
||||
friend QDataStream &operator>>(QDataStream &in, YACReaderLibrary &library);
|
||||
operator QString() const { return QString("%1 [%2, %3, %4]").arg(name).arg(legacyId).arg(id.toString(QUuid::WithoutBraces).arg(path)); }
|
||||
|
||||
private:
|
||||
QString name;
|
||||
QString path;
|
||||
int legacyId;
|
||||
QUuid id; // stored in `id` file in .yacreaderlibrary
|
||||
};
|
||||
|
||||
#endif // YACREADER_LIBRARIES_H
|
||||
|
Reference in New Issue
Block a user