From 254e23be48a8367603b9cdb9327096fb11d48bdf Mon Sep 17 00:00:00 2001 From: Mitternacht822 Date: Wed, 2 Jul 2025 12:18:33 +0400 Subject: [PATCH] refactored reload function in protolocolsModel --- client/ui/models/protocols_model.cpp | 16 +++++++++++++++- .../ui/qml/Pages2/PageSettingsServerProtocol.qml | 14 -------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/client/ui/models/protocols_model.cpp b/client/ui/models/protocols_model.cpp index 231a3fbf..9c29d336 100644 --- a/client/ui/models/protocols_model.cpp +++ b/client/ui/models/protocols_model.cpp @@ -71,10 +71,24 @@ QVariant ProtocolsModel::data(const QModelIndex &index, int role) const void ProtocolsModel::reload() { beginResetModel(); + + QJsonObject config = getConfig(); + + QStringList keys = m_content.keys(); + if (keys.size() == 1) { + QString protocolKey = keys.first(); + + if (config.contains(protocolKey)) { + QJsonObject protocolConfig = config.value(protocolKey).toObject(); + protocolConfig.remove(config_key::last_config); + config[protocolKey] = protocolConfig; + } + } + + updateModel(config); endResetModel(); } - void ProtocolsModel::updateModel(const QJsonObject &content) { m_container = ContainerProps::containerFromString(content.value(config_key::container).toString()); diff --git a/client/ui/qml/Pages2/PageSettingsServerProtocol.qml b/client/ui/qml/Pages2/PageSettingsServerProtocol.qml index 8e1792db..a5f6f7dc 100644 --- a/client/ui/qml/Pages2/PageSettingsServerProtocol.qml +++ b/client/ui/qml/Pages2/PageSettingsServerProtocol.qml @@ -24,20 +24,6 @@ PageType { ColumnLayout { id: header - /*Connections { - target: InstallController - function onCachedProfileCleared(message) { - console.log("СИГНАЛ cachedProfileCleared СРАБОТАЛ:", message) - //ProtocolsModel.updateModel(ProtocolsModel.getConfig()) - ProtocolsModel.clear() - console.log("isClientProtocolExists =", ProtocolsModel.get(0).isClientProtocolExists) - /*PageController.goToPage(PageEnum.PageMainSettings) - Qt.callLater(function() { - PageController.goToPage(PageEnum.PageSettingsServerProtocol) - }) - } - }*/ - anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right