49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
#ifndef SERVICELOADDB_H
|
|
#define SERVICELOADDB_H
|
|
|
|
#include <QObject>
|
|
#include <QSql>
|
|
#include <QSqlDatabase>
|
|
#include <QSqlRecord>
|
|
#include <QSqlQuery>
|
|
#include <QSqlError>
|
|
#include <QString>
|
|
#include <QDebug>
|
|
#include <QStringList>
|
|
#include <QMap>
|
|
#include <QList>
|
|
#include <QFile>
|
|
|
|
#include "models/types.h" // IWYU pragma: keep
|
|
|
|
class ServiceLoadDB : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ServiceLoadDB(QObject *parent = nullptr);
|
|
void start();
|
|
QMap<int, Location> loadLocations();
|
|
QMap<int, Department> loadDepartments();
|
|
QMap<int, Manufacturer> loadManufacturers();
|
|
QMap<int, DeviceType> loadDeviceTypes();
|
|
QMap<int, DeviceModel> loadDeviceModels();
|
|
QMap<int, Device> loadDevices();
|
|
bool updateDevice(const Device &device);
|
|
|
|
private:
|
|
QList<DeviceStructureElement> readStructureElements(int modelId);
|
|
|
|
template <typename T>
|
|
T getValueOrDefault(const QSqlQuery &query, const QSqlRecord &record, const QString &fieldName, const T &defaultValue);
|
|
|
|
private:
|
|
QSqlDatabase _db;
|
|
QString _dbInput;
|
|
QSqlQuery _query;
|
|
|
|
QMap<int, DeviceModel> _mapDeviceModels;
|
|
};
|
|
|
|
#endif // SERVICELOADDB_H
|