! Shows the MQTT connection manager where the connections are created and edited. The selected connection is selected in the connection combo box in this widget. */
| 2914 | The selected connection is selected in the connection combo box in this widget. |
| 2915 | */ |
| 2916 | void ImportFileWidget::showMQTTConnectionManager() { |
| 2917 | bool previousConnectionChanged = false; |
| 2918 | auto* dlg = new MQTTConnectionManagerDialog(this, ui.cbConnection->currentText(), previousConnectionChanged); |
| 2919 | |
| 2920 | if (dlg->exec() == QDialog::Accepted) { |
| 2921 | // re-read the available connections to be in sync with the changes in MQTTConnectionManager |
| 2922 | m_initialisingMQTT = true; |
| 2923 | const QString& prevConn = ui.cbConnection->currentText(); |
| 2924 | ui.cbConnection->clear(); |
| 2925 | readMQTTConnections(); |
| 2926 | m_initialisingMQTT = false; |
| 2927 | |
| 2928 | // select the connection the user has selected in MQTTConnectionManager |
| 2929 | const QString& conn = dlg->connection(); |
| 2930 | |
| 2931 | int index = ui.cbConnection->findText(conn); |
| 2932 | if (conn != prevConn) { // Current connection isn't the previous one |
| 2933 | if (ui.cbConnection->currentIndex() != index) |
| 2934 | ui.cbConnection->setCurrentIndex(index); |
| 2935 | else |
| 2936 | mqttConnectionChanged(); |
| 2937 | } else if (dlg->initialConnectionChanged()) { // Current connection is the same with previous one but it changed |
| 2938 | if (ui.cbConnection->currentIndex() == index) |
| 2939 | mqttConnectionChanged(); |
| 2940 | else |
| 2941 | ui.cbConnection->setCurrentIndex(index); |
| 2942 | } else { // Previous connection wasn't changed |
| 2943 | m_initialisingMQTT = true; |
| 2944 | ui.cbConnection->setCurrentIndex(index); |
| 2945 | m_initialisingMQTT = false; |
| 2946 | } |
| 2947 | } |
| 2948 | delete dlg; |
| 2949 | } |
| 2950 | |
| 2951 | /*! |
| 2952 | loads all available saved MQTT nconnections |
nothing calls this directly
no test coverage detected