31 #include <QSqlDatabase> 32 #include "ui_backendselector.h" 33 #include "../xmlsettingsdialog/basesettingsmanager.h" 42 Ui_ =
new Ui::BackendSelector;
48 if (!QSqlDatabase::isDriverAvailable (
"QMYSQL"))
50 Ui_->MySQLSettings_->setEnabled (
false);
51 Ui_->StorageType_->removeItem (2);
53 if (!QSqlDatabase::isDriverAvailable (
"QPSQL"))
55 Ui_->PostgreSQLSettings_->setEnabled (
false);
56 Ui_->StorageType_->removeItem (1);
60 void BackendSelector::FillUI ()
62 int index = Ui_->StorageType_->
64 Property (
"StorageType",
"SQLite").
toString ());
65 Ui_->StorageType_->setCurrentIndex (index);
66 Ui_->Settings_->setCurrentIndex (index);
68 Ui_->SQLiteVacuum_->setCheckState (Manager_->
69 Property (
"SQLiteVacuum",
false).toBool () ?
72 Ui_->SQLiteJournalMode_->setCurrentIndex (Ui_->SQLiteJournalMode_->
74 Property (
"SQLiteJournalMode",
"TRUNCATE").
toString ()));
75 Ui_->SQLiteTempStore_->setCurrentIndex (Ui_->SQLiteTempStore_->
77 Property (
"SQLiteTempStore",
"MEMORY").
toString ()));
78 Ui_->SQLiteSynchronous_->setCurrentIndex (Ui_->SQLiteSynchronous_->
80 Property (
"SQLiteSynchronous",
"OFF").
toString ()));
82 Ui_->PostgresHostname_->setText (Manager_->
83 Property (
"PostgresHostname",
"localhost").
toString ());
84 Ui_->PostgresPort_->setValue (Manager_->
85 Property (
"PostgresPort", 5432).toInt ());
86 Ui_->PostgresDBName_->setText (Manager_->
87 Property (
"PostgresDBName",
"").
toString ());
88 Ui_->PostgresUsername_->setText (Manager_->
89 Property (
"PostgresUsername",
"").
toString ());
90 Ui_->PostgresPassword_->setText (Manager_->
91 Property (
"PostgresPassword",
"").
toString ());
93 Ui_->MysqlHostname_->setText (Manager_->
94 Property (
"MysqlHostname",
"localhost").
toString ());
95 Ui_->MysqlPort_->setValue (Manager_->
96 Property (
"MysqlPort", 5432).toInt ());
97 Ui_->MysqlDBName_->setText (Manager_->
98 Property (
"MysqlDBName",
"").
toString ());
99 Ui_->MysqlUsername_->setText (Manager_->
100 Property (
"MysqlUsername",
"").
toString ());
101 Ui_->MysqlPassword_->setText (Manager_->
102 Property (
"MysqlPassword",
"").
toString ());
107 Manager_->setProperty (
"StorageType",
108 Ui_->StorageType_->currentText ());
110 Manager_->setProperty (
"SQLiteVacuum",
111 Ui_->SQLiteVacuum_->checkState () == Qt::Checked);
112 Manager_->setProperty (
"SQLiteJournalMode",
113 Ui_->SQLiteJournalMode_->currentText ());
114 Manager_->setProperty (
"SQLiteTempStore",
115 Ui_->SQLiteTempStore_->currentText ());
116 Manager_->setProperty (
"SQLiteSynchronous",
117 Ui_->SQLiteSynchronous_->currentText ());
119 Manager_->setProperty (
"PostgresHostname",
120 Ui_->PostgresHostname_->text ());
121 Manager_->setProperty (
"PostgresPort",
122 Ui_->PostgresPort_->value ());
123 Manager_->setProperty (
"PostgresDBName",
124 Ui_->PostgresDBName_->text ());
125 Manager_->setProperty (
"PostgresUsername",
126 Ui_->PostgresUsername_->text ());
127 Manager_->setProperty (
"PostgresPassword",
128 Ui_->PostgresPassword_->text ());
130 Manager_->setProperty (
"MysqlHostname",
131 Ui_->MysqlHostname_->text ());
132 Manager_->setProperty (
"MysqlPort",
133 Ui_->MysqlPort_->value ());
134 Manager_->setProperty (
"MysqlDBName",
135 Ui_->MysqlDBName_->text ());
136 Manager_->setProperty (
"MysqlUsername",
137 Ui_->MysqlUsername_->text ());
138 Manager_->setProperty (
"MysqlPassword",
139 Ui_->MysqlPassword_->text ());
BackendSelector(BaseSettingsManager *manager, QWidget *parent=0)
Constructs the BackendSelector.
void accept()
Updates the settings manager.
void reject()
Restores the settings in UI.
char * toString(const char *name, const T &t)