From b1f7fbff8b5c106dfac36869c80f9f07c1c741af Mon Sep 17 00:00:00 2001 From: Bent Witthold Date: Sat, 2 May 2026 11:34:22 +0200 Subject: [PATCH] Minor refactoring for API authentication. --- genericcore.cpp | 8 +++++--- genericcore.h | 2 +- model/generalsortfiltermodel.cpp | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/genericcore.cpp b/genericcore.cpp index 7824d17..c21c655 100644 --- a/genericcore.cpp +++ b/genericcore.cpp @@ -39,7 +39,7 @@ GenericCore::GenericCore() { m_modelUndoStack = new QUndoStack(this); setupModels(); - setupServerConfiguration(); + setupServerCommunication(); } GenericCore::~GenericCore() { qDebug() << "Destroying core..."; } @@ -129,7 +129,7 @@ void GenericCore::applySettings(QVariantMap settingMap, QString group) { SettingsHandler::saveSettings(settingMap, group); if (group == "Server") { - setupServerConfiguration(); + applyServerConfiguration(); } } @@ -157,6 +157,7 @@ void GenericCore::saveItems() { emit displayStatusMessage(QString("Error: Items couldn't be saved.")); } } + void GenericCore::onSendItemTriggered(const QByteArray& jsonData) { m_serverCommunicator->postItems(jsonData); } @@ -246,7 +247,7 @@ QString GenericCore::getMaintenanceToolFilePath() const { return filePath; } -void GenericCore::setupServerConfiguration() { +void GenericCore::setupServerCommunication() { m_serverCommunicator = make_unique(this); /// request connections connect(this, &GenericCore::fetchItemsFromServer, m_serverCommunicator.get(), @@ -275,6 +276,7 @@ void GenericCore::setupServerConfiguration() { void GenericCore::applyServerConfiguration() { const QVariantMap serverSettings = SettingsHandler::getSettings("Server"); const QString urlValue = serverSettings.value("url").toString(); + // NEXT if urlValue is empty -> remove authToken from settings? if (!urlValue.isEmpty()) { const QString emailValue = serverSettings.value("email").toString(); const QString passwordValue = serverSettings.value("password").toString(); diff --git a/genericcore.h b/genericcore.h index 4fce2eb..722b5cd 100644 --- a/genericcore.h +++ b/genericcore.h @@ -67,7 +67,7 @@ class GenericCore : public QObject { /// Network communication std::unique_ptr m_serverCommunicator; - void setupServerConfiguration(); + void setupServerCommunication(); void applyServerConfiguration(); }; diff --git a/model/generalsortfiltermodel.cpp b/model/generalsortfiltermodel.cpp index 7f4d7a4..2d79880 100644 --- a/model/generalsortfiltermodel.cpp +++ b/model/generalsortfiltermodel.cpp @@ -27,6 +27,7 @@ QString GeneralSortFilterModel::getUuid(const QModelIndex& itemIndex) const { return data(itemIndex, IdRole).toString(); } +// NEXT remove when deprecated QByteArray GeneralSortFilterModel::jsonDataForServer(const QModelIndex& proxyIndex) { const QModelIndex sourceIndex = mapToSource(proxyIndex); return m_tableModel->jsonDataForServer(sourceIndex);