-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabasemanager.h
52 lines (42 loc) · 1.44 KB
/
databasemanager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* This file is part of the PrismaticOutpost project.
* Copyright 2024. Isaac Raway. All rights reserved.
* This file is licensed under the terms of the AGPL-3.0,
* which you can find a copy of in the LICENSE.md file
* https://www.gnu.org/licenses/agpl-3.0.md.
* IMPORTANT: This license ALSO applies to all scripts
* and databases packaged with this distribution of
* PrismaticOutpost. If you wish to distribute proprietary
* scripts or databases, then they MUST NOT be packaged
* with this distribution or any binary distribution built
* from this distribution or any derivative of this
* distribution.
*/
// databasemanager.h
#ifndef DATABASEMANAGER_H
#define DATABASEMANAGER_H
#include <QObject>
#include <QSqlDatabase>
#include <QVariant>
#include <QFileInfo>
#include <QDir>
class DatabaseManager : public QObject
{
Q_OBJECT
public:
explicit DatabaseManager(QObject *parent = nullptr);
~DatabaseManager();
bool openDatabase(const QString &path);
void closeDatabase();
QVariant getValue(const QString &key);
bool setValue(const QString &key, const QVariant &value);
bool removeValue(const QString &key);
QStringList getChildKeys(const QString &parentKey);
QString getDatabaseDirectory() const {
return QFileInfo(db.databaseName()).dir().absolutePath();
}
private:
QSqlDatabase db;
bool initTables();
};
#endif // DATABASEMANAGER_H