30
32
setPage(AdminUserPage, new CoreConfigWizardPages::AdminUserPage(this));
31
33
setPage(StorageSelectionPage, new CoreConfigWizardPages::StorageSelectionPage(_backends, this));
32
34
syncPage = new CoreConfigWizardPages::SyncPage(this);
33
connect(syncPage, SIGNAL(setupCore(const QString &)), this, SLOT(prepareCoreSetup(const QString &)));
35
connect(syncPage, SIGNAL(setupCore(const QString &, const QVariantMap &)), this, SLOT(prepareCoreSetup(const QString &, const QVariantMap &)));
34
36
setPage(SyncPage, syncPage);
35
37
syncRelayPage = new CoreConfigWizardPages::SyncRelayPage(this);
36
38
connect(syncRelayPage, SIGNAL(startOver()), this, SLOT(startOver()));
66
void CoreConfigWizard::prepareCoreSetup(const QString &backend) {
68
void CoreConfigWizard::prepareCoreSetup(const QString &backend, const QVariantMap &properties) {
67
69
// Prevent the user from changing any settings he already specified...
68
foreach(int idx, visitedPages()) page(idx)->setEnabled(false);
70
foreach(int idx, visitedPages())
71
page(idx)->setEnabled(false);
70
74
foo["AdminUser"] = field("adminUser.user").toString();
71
75
foo["AdminPasswd"] = field("adminUser.password").toString();
72
76
foo["Backend"] = backend;
77
foo["ConnectionProperties"] = properties;
73
78
emit setupCore(foo);
159
163
/*** Storage Selection Page ***/
161
StorageSelectionPage::StorageSelectionPage(const QHash<QString, QVariant> &backends, QWidget *parent) : QWizardPage(parent) {
165
StorageSelectionPage::StorageSelectionPage(const QHash<QString, QVariant> &backends, QWidget *parent)
166
: QWizardPage(parent),
162
170
ui.setupUi(this);
163
_backends = backends;
165
172
setTitle(tr("Select Storage Backend"));
166
173
setSubTitle(tr("Please select a database backend for the Quassel Core storage to store the backlog and other data in."));
183
190
return ui.backendList->currentText();
193
QVariantMap StorageSelectionPage::connectionProperties() const {
194
QString backend = ui.backendList->itemData(ui.backendList->currentIndex()).toString();
196
QVariantMap properties;
197
QStringList setupKeys = _backends[backend].toMap()["SetupKeys"].toStringList();
198
if(!setupKeys.isEmpty()) {
199
QVariantMap defaults = _backends[backend].toMap()["SetupDefaults"].toMap();
200
foreach(QString key, setupKeys) {
201
QWidget *widget = _connectionBox->findChild<QWidget *>(key);
203
if(defaults.contains(key)) {
209
QSpinBox *spinbox = qobject_cast<QSpinBox *>(widget);
211
def = QVariant(spinbox->value());
216
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(widget);
218
def = QVariant(lineEdit->text());
221
properties[key] = def;
224
qDebug() << properties;
227
// QVariantMap properties = _backends[backend].toMap()["ConnectionProperties"].toMap();
228
// if(!properties.isEmpty() && _connectionBox) {
229
// QVariantMap::iterator propertyIter = properties.begin();
230
// while(propertyIter != properties.constEnd()) {
231
// QWidget *widget = _connectionBox->findChild<QWidget *>(propertyIter.key());
232
// switch(propertyIter.value().type()) {
233
// case QVariant::Int:
235
// QSpinBox *spinbox = qobject_cast<QSpinBox *>(widget);
236
// Q_ASSERT(spinbox);
237
// propertyIter.value() = QVariant(spinbox->value());
242
// QLineEdit *lineEdit = qobject_cast<QLineEdit *>(widget);
243
// Q_ASSERT(lineEdit);
244
// propertyIter.value() = QVariant(lineEdit->text());
186
253
void StorageSelectionPage::on_backendList_currentIndexChanged() {
187
254
QString backend = ui.backendList->itemData(ui.backendList->currentIndex()).toString();
188
255
ui.description->setText(_backends[backend].toMap()["Description"].toString());
258
layout()->removeWidget(_connectionBox);
259
_connectionBox->deleteLater();
263
QStringList setupKeys = _backends[backend].toMap()["SetupKeys"].toStringList();
264
if(!setupKeys.isEmpty()) {
265
QVariantMap defaults = _backends[backend].toMap()["SetupDefaults"].toMap();
266
QGroupBox *propertyBox = new QGroupBox(this);
267
propertyBox->setTitle(tr("Connection Properties"));
268
QFormLayout *formlayout = new QFormLayout;
270
foreach(QString key, setupKeys) {
273
if(defaults.contains(key)) {
279
QSpinBox *spinbox = new QSpinBox(propertyBox);
280
spinbox->setMaximum(64000);
281
spinbox->setValue(def.toInt());
287
QLineEdit *lineEdit = new QLineEdit(def.toString(), propertyBox);
288
if(key.toLower().contains("password")) {
289
lineEdit->setEchoMode(QLineEdit::Password);
294
widget->setObjectName(key);
295
formlayout->addRow(key + ":", widget);
297
propertyBox->setLayout(formlayout);
298
static_cast<QVBoxLayout *>(layout())->insertWidget(layout()->indexOf(ui.descriptionBox) + 1, propertyBox);
299
_connectionBox = propertyBox;
191
303
/*** Sync Page ***/
199
311
void SyncPage::initializePage() {
200
312
complete = false;
201
313
hasError = false;
202
QString backend = qobject_cast<StorageSelectionPage *>(wizard()->page(CoreConfigWizard::StorageSelectionPage))->selectedBackend();
315
StorageSelectionPage *storagePage = qobject_cast<StorageSelectionPage *>(wizard()->page(CoreConfigWizard::StorageSelectionPage));
316
QString backend = storagePage->selectedBackend();
317
QVariantMap properties = storagePage->connectionProperties();
203
318
Q_ASSERT(!backend.isEmpty());
204
319
ui.user->setText(wizard()->field("adminUser.user").toString());
205
320
ui.backend->setText(backend);
206
emit setupCore(backend);
321
emit setupCore(backend, properties);
209
324
int SyncPage::nextId() const {