- QStringList setupKeys = _backends[backend].toMap()["SetupKeys"].toStringList();
- if(!setupKeys.isEmpty()) {
- QVariantMap defaults = _backends[backend].toMap()["SetupDefaults"].toMap();
- QGroupBox *propertyBox = new QGroupBox(this);
- propertyBox->setTitle(tr("Connection Properties"));
- QFormLayout *formlayout = new QFormLayout;
-
- foreach(QString key, setupKeys) {
- QWidget *widget = 0;
- QVariant def;
- if(defaults.contains(key)) {
- def = defaults[key];
- }
- switch(def.type()) {
- case QVariant::Int:
- {
- QSpinBox *spinbox = new QSpinBox(propertyBox);
- spinbox->setMaximum(64000);
- spinbox->setValue(def.toInt());
- widget = spinbox;
- }
- break;
- default:
- {
- QLineEdit *lineEdit = new QLineEdit(def.toString(), propertyBox);
- if(key.toLower().contains("password")) {
- lineEdit->setEchoMode(QLineEdit::Password);
- }
- widget = lineEdit;
+ if (_connectionBox) {
+ layout()->removeWidget(_connectionBox);
+ _connectionBox->deleteLater();
+ _connectionBox = 0;
+ }
+
+ QStringList setupKeys = _backends[backend].toMap()["SetupKeys"].toStringList();
+ if (!setupKeys.isEmpty()) {
+ QVariantMap defaults = _backends[backend].toMap()["SetupDefaults"].toMap();
+ QGroupBox *propertyBox = new QGroupBox(this);
+ propertyBox->setTitle(tr("Connection Properties"));
+ QFormLayout *formlayout = new QFormLayout;
+
+ foreach(QString key, setupKeys) {
+ QWidget *widget = 0;
+ QVariant def;
+ if (defaults.contains(key)) {
+ def = defaults[key];
+ }
+ switch (def.type()) {
+ case QVariant::Int:
+ {
+ QSpinBox *spinbox = new QSpinBox(propertyBox);
+ spinbox->setMaximum(64000);
+ spinbox->setValue(def.toInt());
+ widget = spinbox;
+ }
+ break;
+ default:
+ {
+ QLineEdit *lineEdit = new QLineEdit(def.toString(), propertyBox);
+ if (key.toLower().contains("password")) {
+ lineEdit->setEchoMode(QLineEdit::Password);
+ }
+ widget = lineEdit;
+ }
+ }
+ widget->setObjectName(key);
+ formlayout->addRow(key + ":", widget);