-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSimpleDatabaseManager.h
More file actions
70 lines (64 loc) · 2.35 KB
/
SimpleDatabaseManager.h
File metadata and controls
70 lines (64 loc) · 2.35 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef SIMPLEDATABASEMANAGER_H
#define SIMPLEDATABASEMANAGER_H
// File modified by Deepak Samuel on 25 Sep 2019
#include <QtSql/QSqlError>
#include <QtSql/QSqlDatabase>
#include <QDebug>
#include <QtSql/QSqlQuery>
#include <QFormLayout>
#include <QLabel>
#include <QDoubleSpinBox>
#include <QSqlDatabase>
#include <QSqlTableModel>
class SimpleDatabaseManager
{
public:
SimpleDatabaseManager();
QSqlDatabase db;
QStringList Query(QString qry);
QStringList GetListOfShapes();
QStringList GetListOfMaterials();
QStringList GetListOfElements();
QStringList GetListOfElementSymbols();
QStringList GetListOfAtomicMass();
QStringList GetListOfZ();
QStringList GetListOfRefPhysics();
QStringList GetListOfRefPhysicsHints();
QStringList GetListOfSizeParameters(QString shapeName);
QList<float> GetListOfDefaultSizeParameters(QString shapeName);
QStringList GetListOfEnvVars();
QStringList GetListOfEnvVarValues();
void SetEnvVar(QString name, QString path);
QString GetEnvVar(QString name);
QSqlDatabase currentDatabase() const;
QStringList GetListOfPositionParameters();
QList<float> GetListOfDefaultPositionParameters();
QString activeDb;
QFormLayout* GetObjectSizeParametersForm(QString shapeName);
QFormLayout* GetObjectPositionParametersForm();
void InsertNewMaterial(QString name, QString formula);
QString GetMaterialFormula(QString custom_material); // used for custom materials
QStringList GetMaterialPropertyList();
QStringList GetMaterialConstPropertyList();
void InsertMaterialProperty(QString name, QString formula, QString property);
void UpdateMaterialProperty(QString name, QString property);
QString GetMaterialProperty(QString name);
QStringList GetRecentFileList();
void AddToRecentFiles(QString file);
//QStringList GetRecentFilePhysicsList();
};
// the following is required for database table editor
class DBTableModel: public QSqlTableModel
{
Q_OBJECT
public:
explicit DBTableModel(QObject *parent = nullptr, QSqlDatabase db = QSqlDatabase())
: QSqlTableModel(parent, db) {}
QVariant data(const QModelIndex &idx, int role) const override
{
if (role == Qt::BackgroundRole && isDirty(idx))
return QBrush(QColor(Qt::gray));
return QSqlTableModel::data(idx, role);
}
};
#endif // SIMPLEDATABASEMANAGER_H