Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: akonadi/kcm/serverconfigmodule.cpp
- ===================================================================
- --- akonadi/kcm/serverconfigmodule.cpp (revision 981519)
- +++ akonadi/kcm/serverconfigmodule.cpp (working copy)
- @@ -24,6 +24,8 @@
- #include <kpluginfactory.h>
- #include <kpluginloader.h>
- +#include <QVBoxLayout>
- +#include <QComboBox>
- #include <QSettings>
- #include <akonadi/control.h>
- @@ -41,22 +43,55 @@
- KGlobal::locale()->insertCatalog( "kcm_akonadi" );
- KGlobal::locale()->insertCatalog( "libakonadi" );
- + QVBoxLayout *layout = new QVBoxLayout( this );
- + setLayout( layout );
- +
- + QWidget *storage_driver = new QWidget( this );
- + layout->addWidget( storage_driver );
- + ui_driver.setupUi( storage_driver );
- +
- + ui_driver.driverBox->addItem("Mysql", QVariant("QMYSQL"));
- + ui_driver.driverBox->addItem("PostgreSQL", QVariant("QPSQL"));
- +
- setButtons( KCModule::Default | KCModule::Apply );
- - ui.setupUi( this );
- - connect( ui.startServer, SIGNAL(toggled(bool)), SLOT(changed()) );
- - connect( ui.serverPath, SIGNAL(textChanged(QString)), SLOT(changed()) );
- - connect( ui.name, SIGNAL(textChanged(QString)), SLOT(changed()) );
- - connect( ui.host, SIGNAL(textChanged(QString)), SLOT(changed()) );
- - connect( ui.username, SIGNAL(textChanged(QString)), SLOT(changed()) );
- - connect( ui.password, SIGNAL(textChanged(QString)), SLOT(changed()) );
- - connect( ui.options, SIGNAL(textChanged(QString)), SLOT(changed()) );
- + // MySQL
- + m_mysqlWidget = new QWidget( this );
- + layout->addWidget( m_mysqlWidget );
- + ui_mysql.setupUi( m_mysqlWidget );
- +
- + // PSQL
- + m_psqlWidget = new QWidget( this );
- + layout->addWidget( m_psqlWidget );
- + ui_psql.setupUi( m_psqlWidget );
- +
- + QWidget *widget = new QWidget( this );
- + layout->addWidget( widget );
- + ui.setupUi( widget );
- +
- + connect( ui_mysql.startServer, SIGNAL(toggled(bool)), SLOT(changed()) );
- + connect( ui_mysql.serverPath, SIGNAL(textChanged(QString)), SLOT(changed()) );
- + connect( ui_mysql.name, SIGNAL(textChanged(QString)), SLOT(changed()) );
- + connect( ui_mysql.host, SIGNAL(textChanged(QString)), SLOT(changed()) );
- + connect( ui_mysql.username, SIGNAL(textChanged(QString)), SLOT(changed()) );
- + connect( ui_mysql.password, SIGNAL(textChanged(QString)), SLOT(changed()) );
- + connect( ui_mysql.options, SIGNAL(textChanged(QString)), SLOT(changed()) );
- +
- + connect( ui_psql.name, SIGNAL(textChanged(QString)), SLOT(changed()) );
- + connect( ui_psql.host, SIGNAL(textChanged(QString)), SLOT(changed()) );
- + connect( ui_psql.username, SIGNAL(textChanged(QString)), SLOT(changed()) );
- + connect( ui_psql.password, SIGNAL(textChanged(QString)), SLOT(changed()) );
- + connect( ui_psql.port, SIGNAL(textChanged(QString)), SLOT(changed()) );
- +
- connect( ui.startStopButton, SIGNAL(clicked()), SLOT(startStopClicked()) );
- connect( ui.restartButton, SIGNAL(clicked()), SLOT(restartClicked()) );
- connect( ui.selfTestButton, SIGNAL(clicked()), SLOT(selfTestClicked()) );
- connect( ServerManager::self(), SIGNAL(started()), SLOT(updateStatus()) );
- connect( ServerManager::self(), SIGNAL(stopped()), SLOT(updateStatus()) );
- +
- + connect( ui_driver.driverBox, SIGNAL(currentIndexChanged( int )), SLOT(driverChanged(int)) );
- + connect( ui_driver.driverBox, SIGNAL(currentIndexChanged( int )), SLOT(changed()) );
- }
- void ServerConfigModule::load()
- @@ -64,15 +99,30 @@
- const QString serverConfigFile = XdgBaseDirs::akonadiServerConfigFile( XdgBaseDirs::ReadWrite );
- QSettings settings( serverConfigFile, QSettings::IniFormat );
- settings.beginGroup( "QMYSQL" );
- - ui.startServer->setChecked( settings.value( "StartServer", true ).toBool() );
- - ui.serverPath->setUrl( KUrl::fromPath( settings.value( "ServerPath", "" ).toString() ) );
- - ui.name->setText( settings.value( "Name", "akonadi" ).toString() );
- - ui.host->setText( settings.value( "Host", "" ).toString() );
- - ui.username->setText( settings.value( "User", "" ).toString() );
- - ui.password->setText( settings.value( "Password", "" ).toString() );
- - ui.options->setText( settings.value( "Options", "" ).toString() );
- + ui_mysql.startServer->setChecked( settings.value( "StartServer", true ).toBool() );
- + ui_mysql.serverPath->setUrl( KUrl::fromPath( settings.value( "ServerPath", "" ).toString() ) );
- + ui_mysql.name->setText( settings.value( "Name", "akonadi" ).toString() );
- + ui_mysql.host->setText( settings.value( "Host", "" ).toString() );
- + ui_mysql.username->setText( settings.value( "User", "" ).toString() );
- + ui_mysql.password->setText( settings.value( "Password", "" ).toString() );
- + ui_mysql.options->setText( settings.value( "Options", "" ).toString() );
- settings.endGroup();
- + // postgresql group
- + settings.beginGroup( "QPSQL" );
- + ui_psql.name->setText( settings.value( "Name", "akonadi" ).toString() );
- + ui_psql.host->setText( settings.value( "Host", "" ).toString() );
- + ui_psql.username->setText( settings.value( "User", "" ).toString() );
- + ui_psql.password->setText( settings.value( "Password", "" ).toString() );
- + ui_psql.port->setText( settings.value( "Port", "5432" ).toString() );
- + settings.endGroup();
- +
- + // selected driver
- + settings.beginGroup( "GENERAL" );
- + ui_driver.driverBox->setCurrentIndex( ui_driver.driverBox->findData( settings.value ( "Driver", "QMYSQL" ) ) );
- + driverChanged( ui_driver.driverBox->currentIndex() );
- + settings.endGroup();
- +
- updateStatus();
- }
- @@ -82,14 +132,28 @@
- const QString serverConfigFile = XdgBaseDirs::akonadiServerConfigFile( XdgBaseDirs::ReadWrite );
- QSettings settings( serverConfigFile, QSettings::IniFormat );
- settings.beginGroup( "QMYSQL" );
- - settings.setValue( "StartServer", ui.startServer->isChecked() );
- - settings.setValue( "ServerPath", ui.serverPath->url().toLocalFile() );
- - settings.setValue( "Name", ui.name->text() );
- - settings.setValue( "Host", ui.host->text() );
- - settings.setValue( "User", ui.username->text() );
- - settings.setValue( "Password", ui.password->text() );
- - settings.setValue( "Options", ui.options->text() );
- + settings.setValue( "StartServer", ui_mysql.startServer->isChecked() );
- + settings.setValue( "ServerPath", ui_mysql.serverPath->url().toLocalFile() );
- + settings.setValue( "Name", ui_mysql.name->text() );
- + settings.setValue( "Host", ui_mysql.host->text() );
- + settings.setValue( "User", ui_mysql.username->text() );
- + settings.setValue( "Password", ui_mysql.password->text() );
- + settings.setValue( "Options", ui_mysql.options->text() );
- settings.endGroup();
- +
- + // postgresql group
- + settings.beginGroup( "QPSQL" );
- + settings.setValue( "Name", ui_psql.name->text() );
- + settings.setValue( "Host", ui_psql.host->text() );
- + settings.setValue( "User", ui_psql.username->text() );
- + settings.setValue( "Password", ui_psql.password->text() );
- + settings.setValue( "Port", ui_psql.port->text() );
- + settings.endGroup();
- +
- + // selected driver
- + settings.beginGroup( "GENERAL" );
- + settings.setValue( "Driver", ui_driver.driverBox->itemData( ui_driver.driverBox->currentIndex() ).toString() );
- + settings.endGroup();
- settings.sync();
- // TODO: restart server if needed
- @@ -97,9 +161,11 @@
- void ServerConfigModule::defaults()
- {
- - ui.startServer->setChecked( true );
- + ui_mysql.startServer->setChecked( true );
- // TODO: detect default server path
- - ui.name->setText( "akonadi" );
- + ui_mysql.name->setText( "akonadi" );
- +
- + ui_driver.driverBox->setCurrentIndex( ui_driver.driverBox->findData ("QMYSQL") );
- }
- void ServerConfigModule::updateStatus()
- @@ -133,4 +199,16 @@
- ServerManager::showSelfTestDialog( this );
- }
- +void ServerConfigModule::driverChanged( int index )
- +{
- + if( ui_driver.driverBox->itemData( index ).toString() == "QMYSQL" ) {
- + m_psqlWidget->setVisible( false );
- + m_mysqlWidget->setVisible( true );
- + }
- + else {
- + m_psqlWidget->setVisible( true );
- + m_mysqlWidget->setVisible( false );
- + }
- +}
- +
- #include "serverconfigmodule.moc"
- Index: akonadi/kcm/serverconfigmodule.h
- ===================================================================
- --- akonadi/kcm/serverconfigmodule.h (revision 981519)
- +++ akonadi/kcm/serverconfigmodule.h (working copy)
- @@ -21,9 +21,14 @@
- #define SERVERCONFIGMODULE_H
- #include "ui_serverconfigmodule.h"
- +#include "ui_servermysqlstorage.h"
- +#include "ui_serverpsqlstorage.h"
- +#include "ui_serverstoragedriver.h"
- #include <KCModule>
- +class QComboBox;
- +
- class ServerConfigModule : public KCModule
- {
- Q_OBJECT
- @@ -39,9 +44,18 @@
- void startStopClicked();
- void restartClicked();
- void selfTestClicked();
- + void driverChanged(int);
- private:
- Ui::ServerConfigModule ui;
- + Ui::StorageDriver ui_driver;
- + Ui::MySQLStorageObject ui_mysql;
- + Ui::PSQLStorageObject ui_psql;
- +
- + QWidget *m_mysqlWidget;
- + QWidget *m_psqlWidget;
- +
- + QComboBox *m_driverBox;
- };
- #endif
- Index: akonadi/kcm/CMakeLists.txt
- ===================================================================
- --- akonadi/kcm/CMakeLists.txt (revision 981519)
- +++ akonadi/kcm/CMakeLists.txt (working copy)
- @@ -7,7 +7,10 @@
- set(akonadi_server_kcm_srcs serverconfigmodule.cpp)
- -kde4_add_ui_files(akonadi_server_kcm_srcs serverconfigmodule.ui )
- +kde4_add_ui_files(akonadi_server_kcm_srcs serverconfigmodule.ui
- + servermysqlstorage.ui
- + serverpsqlstorage.ui
- + serverstoragedriver.ui)
- kde4_add_plugin(kcm_akonadi_server ${akonadi_server_kcm_srcs})
- target_link_libraries(kcm_akonadi_server ${KDE4_KIO_LIBS} ${KDEPIMLIBS_AKONADI_LIBS} ${AKONADI_COMMON_LIBRARIES})
- Index: akonadi/kcm/serverconfigmodule.ui
- ===================================================================
- --- akonadi/kcm/serverconfigmodule.ui (revision 981519)
- +++ akonadi/kcm/serverconfigmodule.ui (working copy)
- @@ -6,151 +6,12 @@
- <rect>
- <x>0</x>
- <y>0</y>
- - <width>444</width>
- - <height>526</height>
- + <width>493</width>
- + <height>121</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- - <widget class="QCheckBox" name="startServer">
- - <property name="whatsThis">
- - <string>Choose whether Akonadi should use an internal or external MySQL server.</string>
- - </property>
- - <property name="text">
- - <string>Use internal MySQL server</string>
- - </property>
- - <property name="checked">
- - <bool>true</bool>
- - </property>
- - </widget>
- - </item>
- - <item row="1" column="0">
- - <widget class="QGroupBox" name="groupBox_2">
- - <property name="title">
- - <string>Internal MySQL Server</string>
- - </property>
- - <layout class="QHBoxLayout" name="horizontalLayout">
- - <item>
- - <widget class="QLabel" name="label">
- - <property name="text">
- - <string>MySQL server executable:</string>
- - </property>
- - <property name="buddy">
- - <cstring>serverPath</cstring>
- - </property>
- - </widget>
- - </item>
- - <item>
- - <widget class="KUrlRequester" name="serverPath">
- - <property name="whatsThis">
- - <string><p><b>MySQL server location</b></p><br>Enter the location of your internal MySQL server or click on the Browse button.</string>
- - </property>
- - </widget>
- - </item>
- - </layout>
- - </widget>
- - </item>
- - <item row="2" column="0">
- - <widget class="QGroupBox" name="groupBox">
- - <property name="enabled">
- - <bool>false</bool>
- - </property>
- - <property name="title">
- - <string>External MySQL Server</string>
- - </property>
- - <layout class="QFormLayout" name="formLayout">
- - <item row="0" column="0">
- - <widget class="QLabel" name="label_6">
- - <property name="text">
- - <string>Database name:</string>
- - </property>
- - <property name="buddy">
- - <cstring>name</cstring>
- - </property>
- - </widget>
- - </item>
- - <item row="0" column="1">
- - <widget class="KLineEdit" name="name">
- - <property name="whatsThis">
- - <string><p><b>Database Name</b></p><br>Enter the name of your Akonadi database on your external MySQL server.</string>
- - </property>
- - </widget>
- - </item>
- - <item row="1" column="0">
- - <widget class="QLabel" name="label_2">
- - <property name="text">
- - <string>Host:</string>
- - </property>
- - <property name="buddy">
- - <cstring>host</cstring>
- - </property>
- - </widget>
- - </item>
- - <item row="1" column="1">
- - <widget class="KLineEdit" name="host">
- - <property name="whatsThis">
- - <string><p><b>Host</b></p><br>Enter the hostname or the IP address of the machine hosting your MySQL server.</string>
- - </property>
- - </widget>
- - </item>
- - <item row="2" column="0">
- - <widget class="QLabel" name="label_3">
- - <property name="text">
- - <string>Username:</string>
- - </property>
- - <property name="buddy">
- - <cstring>username</cstring>
- - </property>
- - </widget>
- - </item>
- - <item row="2" column="1">
- - <widget class="KLineEdit" name="username">
- - <property name="whatsThis">
- - <string>Enter the username required to access your MySQL database.</string>
- - </property>
- - </widget>
- - </item>
- - <item row="3" column="0">
- - <widget class="QLabel" name="label_4">
- - <property name="text">
- - <string>Password:</string>
- - </property>
- - <property name="buddy">
- - <cstring>password</cstring>
- - </property>
- - </widget>
- - </item>
- - <item row="3" column="1">
- - <widget class="KLineEdit" name="password">
- - <property name="whatsThis">
- - <string>Enter the password required to access your MySQL database.</string>
- - </property>
- - <property name="passwordMode">
- - <bool>true</bool>
- - </property>
- - </widget>
- - </item>
- - <item row="4" column="0">
- - <widget class="QLabel" name="label_5">
- - <property name="text">
- - <string>Options:</string>
- - </property>
- - <property name="buddy">
- - <cstring>options</cstring>
- - </property>
- - </widget>
- - </item>
- - <item row="4" column="1">
- - <widget class="KLineEdit" name="options">
- - <property name="whatsThis">
- - <string><p><b>External MySQL server options</b></p><br>If necessary, you may pass options to your MySQL server.</string>
- - </property>
- - </widget>
- - </item>
- - </layout>
- - </widget>
- - </item>
- - <item row="3" column="0">
- <widget class="QGroupBox" name="groupBox_3">
- <property name="title">
- <string>Status</string>
- @@ -219,80 +80,15 @@
- </layout>
- </widget>
- </item>
- - <item row="4" column="0">
- - <spacer name="verticalSpacer">
- - <property name="orientation">
- - <enum>Qt::Vertical</enum>
- - </property>
- - <property name="sizeHint" stdset="0">
- - <size>
- - <width>20</width>
- - <height>89</height>
- - </size>
- - </property>
- - </spacer>
- - </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- - <class>KLineEdit</class>
- - <extends>QLineEdit</extends>
- - <header>klineedit.h</header>
- - </customwidget>
- - <customwidget>
- <class>KPushButton</class>
- <extends>QPushButton</extends>
- <header>kpushbutton.h</header>
- </customwidget>
- - <customwidget>
- - <class>KUrlRequester</class>
- - <extends>QFrame</extends>
- - <header>kurlrequester.h</header>
- - </customwidget>
- </customwidgets>
- - <tabstops>
- - <tabstop>startServer</tabstop>
- - <tabstop>serverPath</tabstop>
- - <tabstop>name</tabstop>
- - <tabstop>host</tabstop>
- - <tabstop>username</tabstop>
- - <tabstop>password</tabstop>
- - <tabstop>options</tabstop>
- - </tabstops>
- <resources/>
- - <connections>
- - <connection>
- - <sender>startServer</sender>
- - <signal>toggled(bool)</signal>
- - <receiver>groupBox_2</receiver>
- - <slot>setEnabled(bool)</slot>
- - <hints>
- - <hint type="sourcelabel">
- - <x>53</x>
- - <y>18</y>
- - </hint>
- - <hint type="destinationlabel">
- - <x>56</x>
- - <y>34</y>
- - </hint>
- - </hints>
- - </connection>
- - <connection>
- - <sender>startServer</sender>
- - <signal>toggled(bool)</signal>
- - <receiver>groupBox</receiver>
- - <slot>setDisabled(bool)</slot>
- - <hints>
- - <hint type="sourcelabel">
- - <x>135</x>
- - <y>20</y>
- - </hint>
- - <hint type="destinationlabel">
- - <x>146</x>
- - <y>110</y>
- - </hint>
- - </hints>
- - </connection>
- - </connections>
- + <connections/>
- </ui>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement