75 lines
2.0 KiB
C++
75 lines
2.0 KiB
C++
#ifndef GENERICCORE_H
|
|
#define GENERICCORE_H
|
|
|
|
#include <QObject>
|
|
|
|
class QUndoStack;
|
|
class QAbstractItemModel;
|
|
class QAbstractItemModelTester;
|
|
class QString;
|
|
|
|
class TableModel;
|
|
class GeneralSortFilterModel;
|
|
class ServerCommunicator;
|
|
|
|
class GenericCore : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
GenericCore();
|
|
~GenericCore();
|
|
|
|
QString toString() const;
|
|
void sayHello() const;
|
|
|
|
bool isApplicationUpdateAvailable();
|
|
void triggerApplicationUpdate(const bool saveChanges);
|
|
|
|
QUndoStack* getModelUndoStack() const;
|
|
std::shared_ptr<TableModel> getModel() const;
|
|
std::shared_ptr<GeneralSortFilterModel> getSortFilterModel() const;
|
|
|
|
void importCSVFile(const QString& filePath);
|
|
bool exportCSVFile(const QString& filePath);
|
|
|
|
QVariantMap getSettings(QString group = "") const;
|
|
void applySettings(QVariantMap settingMap, QString group = "");
|
|
bool isSyncServerSetup() const;
|
|
|
|
public slots:
|
|
void saveItems();
|
|
|
|
void onSendItemTriggered(const QByteArray& jsonData);
|
|
void onItemsFetched(const QByteArray jsonData);
|
|
void onItemsFetchFailure(const QString errorString);
|
|
void onPostRequestSuccessful(const QByteArray responseData);
|
|
void onPostRequestFailure(const QString errorString);
|
|
void onDeleteRequestSuccessful(const QByteArray responseData);
|
|
void onDeleteRequestFailure(const QString errorString);
|
|
|
|
signals:
|
|
void displayStatusMessage(QString message);
|
|
void fetchItemsFromServer();
|
|
void postItemToServer(const QByteArray& jsonData);
|
|
void deleteItemFromServer(const QString& id);
|
|
|
|
private:
|
|
QUndoStack* m_modelUndoStack;
|
|
std::shared_ptr<TableModel> m_mainModel;
|
|
std::shared_ptr<GeneralSortFilterModel> m_sortFilterModel;
|
|
std::unique_ptr<QAbstractItemModelTester> m_mainModelTester;
|
|
std::unique_ptr<QAbstractItemModelTester> m_proxyModelTester;
|
|
|
|
void setupModels();
|
|
void initModelData();
|
|
|
|
QString getMaintenanceToolFilePath() const;
|
|
|
|
/// Network communication
|
|
std::unique_ptr<ServerCommunicator> m_serverCommunicator;
|
|
void setupServerConfiguration();
|
|
void applyServerConfiguration();
|
|
};
|
|
|
|
#endif // GENERICCORE_H
|