Minor refactoring for API authentication.
This commit is contained in:
@ -39,7 +39,7 @@ GenericCore::GenericCore() {
|
|||||||
m_modelUndoStack = new QUndoStack(this);
|
m_modelUndoStack = new QUndoStack(this);
|
||||||
|
|
||||||
setupModels();
|
setupModels();
|
||||||
setupServerConfiguration();
|
setupServerCommunication();
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericCore::~GenericCore() { qDebug() << "Destroying core..."; }
|
GenericCore::~GenericCore() { qDebug() << "Destroying core..."; }
|
||||||
@ -129,7 +129,7 @@ void GenericCore::applySettings(QVariantMap settingMap, QString group) {
|
|||||||
SettingsHandler::saveSettings(settingMap, group);
|
SettingsHandler::saveSettings(settingMap, group);
|
||||||
|
|
||||||
if (group == "Server") {
|
if (group == "Server") {
|
||||||
setupServerConfiguration();
|
applyServerConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,6 +157,7 @@ void GenericCore::saveItems() {
|
|||||||
emit displayStatusMessage(QString("Error: Items couldn't be saved."));
|
emit displayStatusMessage(QString("Error: Items couldn't be saved."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericCore::onSendItemTriggered(const QByteArray& jsonData) {
|
void GenericCore::onSendItemTriggered(const QByteArray& jsonData) {
|
||||||
m_serverCommunicator->postItems(jsonData);
|
m_serverCommunicator->postItems(jsonData);
|
||||||
}
|
}
|
||||||
@ -246,7 +247,7 @@ QString GenericCore::getMaintenanceToolFilePath() const {
|
|||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericCore::setupServerConfiguration() {
|
void GenericCore::setupServerCommunication() {
|
||||||
m_serverCommunicator = make_unique<ServerCommunicator>(this);
|
m_serverCommunicator = make_unique<ServerCommunicator>(this);
|
||||||
/// request connections
|
/// request connections
|
||||||
connect(this, &GenericCore::fetchItemsFromServer, m_serverCommunicator.get(),
|
connect(this, &GenericCore::fetchItemsFromServer, m_serverCommunicator.get(),
|
||||||
@ -275,6 +276,7 @@ void GenericCore::setupServerConfiguration() {
|
|||||||
void GenericCore::applyServerConfiguration() {
|
void GenericCore::applyServerConfiguration() {
|
||||||
const QVariantMap serverSettings = SettingsHandler::getSettings("Server");
|
const QVariantMap serverSettings = SettingsHandler::getSettings("Server");
|
||||||
const QString urlValue = serverSettings.value("url").toString();
|
const QString urlValue = serverSettings.value("url").toString();
|
||||||
|
// NEXT if urlValue is empty -> remove authToken from settings?
|
||||||
if (!urlValue.isEmpty()) {
|
if (!urlValue.isEmpty()) {
|
||||||
const QString emailValue = serverSettings.value("email").toString();
|
const QString emailValue = serverSettings.value("email").toString();
|
||||||
const QString passwordValue = serverSettings.value("password").toString();
|
const QString passwordValue = serverSettings.value("password").toString();
|
||||||
|
|||||||
@ -67,7 +67,7 @@ class GenericCore : public QObject {
|
|||||||
|
|
||||||
/// Network communication
|
/// Network communication
|
||||||
std::unique_ptr<ServerCommunicator> m_serverCommunicator;
|
std::unique_ptr<ServerCommunicator> m_serverCommunicator;
|
||||||
void setupServerConfiguration();
|
void setupServerCommunication();
|
||||||
void applyServerConfiguration();
|
void applyServerConfiguration();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,7 @@ QString GeneralSortFilterModel::getUuid(const QModelIndex& itemIndex) const {
|
|||||||
return data(itemIndex, IdRole).toString();
|
return data(itemIndex, IdRole).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NEXT remove when deprecated
|
||||||
QByteArray GeneralSortFilterModel::jsonDataForServer(const QModelIndex& proxyIndex) {
|
QByteArray GeneralSortFilterModel::jsonDataForServer(const QModelIndex& proxyIndex) {
|
||||||
const QModelIndex sourceIndex = mapToSource(proxyIndex);
|
const QModelIndex sourceIndex = mapToSource(proxyIndex);
|
||||||
return m_tableModel->jsonDataForServer(sourceIndex);
|
return m_tableModel->jsonDataForServer(sourceIndex);
|
||||||
|
|||||||
Reference in New Issue
Block a user