X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fcoreconfigwizard.cpp;h=0d5c9778a1f96cf925f5e4684633fd8e5e7bf7b4;hp=030af57463eae0bb0503e7dad3f5c440fc40e10d;hb=8b7a532bed238cab3e675c78a16444d7a3f92865;hpb=029c6d402af7b00b320dd5ce48f230783a88957a diff --git a/src/qtui/coreconfigwizard.cpp b/src/qtui/coreconfigwizard.cpp index 030af574..0d5c9778 100644 --- a/src/qtui/coreconfigwizard.cpp +++ b/src/qtui/coreconfigwizard.cpp @@ -162,9 +162,12 @@ bool AdminUserPage::isComplete() const { /*** Storage Selection Page ***/ -StorageSelectionPage::StorageSelectionPage(const QHash &backends, QWidget *parent) : QWizardPage(parent) { +StorageSelectionPage::StorageSelectionPage(const QHash &backends, QWidget *parent) + : QWizardPage(parent), + _connectionBox(0), + _backends(backends) +{ ui.setupUi(this); - _backends = backends; setTitle(tr("Select Storage Backend")); setSubTitle(tr("Please select a database backend for the Quassel Core storage to store the backlog and other data in.")); @@ -189,29 +192,61 @@ QString StorageSelectionPage::selectedBackend() const { QVariantMap StorageSelectionPage::connectionProperties() const { QString backend = ui.backendList->itemData(ui.backendList->currentIndex()).toString(); - QVariantMap properties = _backends[backend].toMap()["ConnectionProperties"].toMap(); - if(!properties.isEmpty() && _connectionBox) { - QVariantMap::iterator propertyIter = properties.begin(); - while(propertyIter != properties.constEnd()) { - QWidget *widget = _connectionBox->findChild(propertyIter.key()); - switch(propertyIter.value().type()) { + + QVariantMap properties; + QStringList setupKeys = _backends[backend].toMap()["SetupKeys"].toStringList(); + if(!setupKeys.isEmpty()) { + QVariantMap defaults = _backends[backend].toMap()["SetupDefaults"].toMap(); + foreach(QString key, setupKeys) { + QWidget *widget = _connectionBox->findChild(key); + QVariant def; + if(defaults.contains(key)) { + def = defaults[key]; + } + switch(def.type()) { case QVariant::Int: { QSpinBox *spinbox = qobject_cast(widget); Q_ASSERT(spinbox); - propertyIter.value() = QVariant(spinbox->value()); + def = QVariant(spinbox->value()); } break; default: { QLineEdit *lineEdit = qobject_cast(widget); Q_ASSERT(lineEdit); - propertyIter.value() = QVariant(lineEdit->text()); + def = QVariant(lineEdit->text()); } } - propertyIter++; + properties[key] = def; } } + qDebug() << properties; + + +// QVariantMap properties = _backends[backend].toMap()["ConnectionProperties"].toMap(); +// if(!properties.isEmpty() && _connectionBox) { +// QVariantMap::iterator propertyIter = properties.begin(); +// while(propertyIter != properties.constEnd()) { +// QWidget *widget = _connectionBox->findChild(propertyIter.key()); +// switch(propertyIter.value().type()) { +// case QVariant::Int: +// { +// QSpinBox *spinbox = qobject_cast(widget); +// Q_ASSERT(spinbox); +// propertyIter.value() = QVariant(spinbox->value()); +// } +// break; +// default: +// { +// QLineEdit *lineEdit = qobject_cast(widget); +// Q_ASSERT(lineEdit); +// propertyIter.value() = QVariant(lineEdit->text()); +// } +// } +// propertyIter++; +// } +// } return properties; } @@ -225,30 +260,39 @@ void StorageSelectionPage::on_backendList_currentIndexChanged() { _connectionBox = 0; } - QVariantMap properties = _backends[backend].toMap()["ConnectionProperties"].toMap(); - if(!properties.isEmpty()) { + 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; - QVariantMap::const_iterator propertyIter = properties.constBegin(); - while(propertyIter != properties.constEnd()) { + foreach(QString key, setupKeys) { QWidget *widget = 0; - switch(propertyIter.value().type()) { + 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(propertyIter.value().toInt()); + spinbox->setValue(def.toInt()); widget = spinbox; } break; default: - widget = new QLineEdit(propertyIter.value().toString(), propertyBox); + { + QLineEdit *lineEdit = new QLineEdit(def.toString(), propertyBox); + if(key.toLower().contains("password")) { + lineEdit->setEchoMode(QLineEdit::Password); + } + widget = lineEdit; + } } - widget->setObjectName(propertyIter.key()); - formlayout->addRow(propertyIter.key() + ":", widget); - propertyIter++; + widget->setObjectName(key); + formlayout->addRow(key + ":", widget); } propertyBox->setLayout(formlayout); static_cast(layout())->insertWidget(layout()->indexOf(ui.descriptionBox) + 1, propertyBox);