Advertisement
Guest User

jgoday

a guest
Jun 13th, 2009
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 16.94 KB | None | 0 0
  1. Index: akonadi/kcm/serverconfigmodule.cpp
  2. ===================================================================
  3. --- akonadi/kcm/serverconfigmodule.cpp  (revision 981519)
  4. +++ akonadi/kcm/serverconfigmodule.cpp  (working copy)
  5. @@ -24,6 +24,8 @@
  6.  #include <kpluginfactory.h>
  7.  #include <kpluginloader.h>
  8.  
  9. +#include <QVBoxLayout>
  10. +#include <QComboBox>
  11.  #include <QSettings>
  12.  
  13.  #include <akonadi/control.h>
  14. @@ -41,22 +43,55 @@
  15.    KGlobal::locale()->insertCatalog( "kcm_akonadi" );
  16.    KGlobal::locale()->insertCatalog( "libakonadi" );
  17.  
  18. +  QVBoxLayout *layout = new QVBoxLayout( this );
  19. +  setLayout( layout );
  20. +
  21. +  QWidget *storage_driver = new QWidget( this );
  22. +  layout->addWidget( storage_driver );
  23. +  ui_driver.setupUi( storage_driver );
  24. +
  25. +  ui_driver.driverBox->addItem("Mysql", QVariant("QMYSQL"));
  26. +  ui_driver.driverBox->addItem("PostgreSQL", QVariant("QPSQL"));
  27. +
  28.    setButtons( KCModule::Default | KCModule::Apply );
  29. -  ui.setupUi( this );
  30. -  connect( ui.startServer, SIGNAL(toggled(bool)), SLOT(changed()) );
  31. -  connect( ui.serverPath, SIGNAL(textChanged(QString)), SLOT(changed()) );
  32. -  connect( ui.name, SIGNAL(textChanged(QString)), SLOT(changed()) );
  33. -  connect( ui.host, SIGNAL(textChanged(QString)), SLOT(changed()) );
  34. -  connect( ui.username, SIGNAL(textChanged(QString)), SLOT(changed()) );
  35. -  connect( ui.password, SIGNAL(textChanged(QString)), SLOT(changed()) );
  36. -  connect( ui.options, SIGNAL(textChanged(QString)), SLOT(changed()) );
  37.  
  38. +  // MySQL
  39. +  m_mysqlWidget = new QWidget( this );
  40. +  layout->addWidget( m_mysqlWidget );
  41. +  ui_mysql.setupUi( m_mysqlWidget );
  42. +
  43. +  // PSQL
  44. +  m_psqlWidget = new QWidget( this );
  45. +  layout->addWidget( m_psqlWidget );
  46. +  ui_psql.setupUi( m_psqlWidget );
  47. +
  48. +  QWidget *widget = new QWidget( this );
  49. +  layout->addWidget( widget );
  50. +  ui.setupUi( widget );
  51. +  
  52. +  connect( ui_mysql.startServer, SIGNAL(toggled(bool)), SLOT(changed()) );
  53. +  connect( ui_mysql.serverPath, SIGNAL(textChanged(QString)), SLOT(changed()) );
  54. +  connect( ui_mysql.name, SIGNAL(textChanged(QString)), SLOT(changed()) );
  55. +  connect( ui_mysql.host, SIGNAL(textChanged(QString)), SLOT(changed()) );
  56. +  connect( ui_mysql.username, SIGNAL(textChanged(QString)), SLOT(changed()) );
  57. +  connect( ui_mysql.password, SIGNAL(textChanged(QString)), SLOT(changed()) );
  58. +  connect( ui_mysql.options, SIGNAL(textChanged(QString)), SLOT(changed()) );
  59. +
  60. +  connect( ui_psql.name, SIGNAL(textChanged(QString)), SLOT(changed()) );
  61. +  connect( ui_psql.host, SIGNAL(textChanged(QString)), SLOT(changed()) );
  62. +  connect( ui_psql.username, SIGNAL(textChanged(QString)), SLOT(changed()) );
  63. +  connect( ui_psql.password, SIGNAL(textChanged(QString)), SLOT(changed()) );
  64. +  connect( ui_psql.port, SIGNAL(textChanged(QString)), SLOT(changed()) );
  65. +
  66.    connect( ui.startStopButton, SIGNAL(clicked()), SLOT(startStopClicked()) );
  67.    connect( ui.restartButton, SIGNAL(clicked()), SLOT(restartClicked()) );
  68.    connect( ui.selfTestButton, SIGNAL(clicked()), SLOT(selfTestClicked()) );
  69.  
  70.    connect( ServerManager::self(), SIGNAL(started()), SLOT(updateStatus()) );
  71.    connect( ServerManager::self(), SIGNAL(stopped()), SLOT(updateStatus()) );
  72. +
  73. +  connect( ui_driver.driverBox, SIGNAL(currentIndexChanged( int )), SLOT(driverChanged(int)) );
  74. +  connect( ui_driver.driverBox, SIGNAL(currentIndexChanged( int )), SLOT(changed()) );
  75.  }
  76.  
  77.  void ServerConfigModule::load()
  78. @@ -64,15 +99,30 @@
  79.    const QString serverConfigFile = XdgBaseDirs::akonadiServerConfigFile( XdgBaseDirs::ReadWrite );
  80.    QSettings settings( serverConfigFile, QSettings::IniFormat );
  81.    settings.beginGroup( "QMYSQL" );
  82. -  ui.startServer->setChecked( settings.value( "StartServer", true ).toBool() );
  83. -  ui.serverPath->setUrl( KUrl::fromPath( settings.value( "ServerPath", "" ).toString() ) );
  84. -  ui.name->setText( settings.value( "Name", "akonadi" ).toString() );
  85. -  ui.host->setText( settings.value( "Host", "" ).toString() );
  86. -  ui.username->setText( settings.value( "User", "" ).toString() );
  87. -  ui.password->setText( settings.value( "Password", "" ).toString() );
  88. -  ui.options->setText( settings.value( "Options", "" ).toString() );
  89. +  ui_mysql.startServer->setChecked( settings.value( "StartServer", true ).toBool() );
  90. +  ui_mysql.serverPath->setUrl( KUrl::fromPath( settings.value( "ServerPath", "" ).toString() ) );
  91. +  ui_mysql.name->setText( settings.value( "Name", "akonadi" ).toString() );
  92. +  ui_mysql.host->setText( settings.value( "Host", "" ).toString() );
  93. +  ui_mysql.username->setText( settings.value( "User", "" ).toString() );
  94. +  ui_mysql.password->setText( settings.value( "Password", "" ).toString() );
  95. +  ui_mysql.options->setText( settings.value( "Options", "" ).toString() );
  96.    settings.endGroup();
  97.  
  98. +  // postgresql group
  99. +  settings.beginGroup( "QPSQL" );
  100. +  ui_psql.name->setText( settings.value( "Name", "akonadi" ).toString() );
  101. +  ui_psql.host->setText( settings.value( "Host", "" ).toString() );
  102. +  ui_psql.username->setText( settings.value( "User", "" ).toString() );
  103. +  ui_psql.password->setText( settings.value( "Password", "" ).toString() );
  104. +  ui_psql.port->setText( settings.value( "Port", "5432" ).toString() );
  105. +  settings.endGroup();
  106. +
  107. +  // selected driver
  108. +  settings.beginGroup( "GENERAL" );
  109. +  ui_driver.driverBox->setCurrentIndex( ui_driver.driverBox->findData( settings.value ( "Driver", "QMYSQL" ) ) );
  110. +  driverChanged( ui_driver.driverBox->currentIndex() );
  111. +  settings.endGroup();
  112. +
  113.    updateStatus();
  114.  }
  115.  
  116. @@ -82,14 +132,28 @@
  117.    const QString serverConfigFile = XdgBaseDirs::akonadiServerConfigFile( XdgBaseDirs::ReadWrite );
  118.    QSettings settings( serverConfigFile, QSettings::IniFormat );
  119.    settings.beginGroup( "QMYSQL" );
  120. -  settings.setValue( "StartServer", ui.startServer->isChecked() );
  121. -  settings.setValue( "ServerPath", ui.serverPath->url().toLocalFile() );
  122. -  settings.setValue( "Name", ui.name->text() );
  123. -  settings.setValue( "Host", ui.host->text() );
  124. -  settings.setValue( "User", ui.username->text() );
  125. -  settings.setValue( "Password", ui.password->text() );
  126. -  settings.setValue( "Options", ui.options->text() );
  127. +  settings.setValue( "StartServer", ui_mysql.startServer->isChecked() );
  128. +  settings.setValue( "ServerPath", ui_mysql.serverPath->url().toLocalFile() );
  129. +  settings.setValue( "Name", ui_mysql.name->text() );
  130. +  settings.setValue( "Host", ui_mysql.host->text() );
  131. +  settings.setValue( "User", ui_mysql.username->text() );
  132. +  settings.setValue( "Password", ui_mysql.password->text() );
  133. +  settings.setValue( "Options", ui_mysql.options->text() );
  134.    settings.endGroup();
  135. +
  136. +  // postgresql group
  137. +  settings.beginGroup( "QPSQL" );
  138. +  settings.setValue( "Name", ui_psql.name->text() );
  139. +  settings.setValue( "Host", ui_psql.host->text() );
  140. +  settings.setValue( "User", ui_psql.username->text() );
  141. +  settings.setValue( "Password", ui_psql.password->text() );
  142. +  settings.setValue( "Port", ui_psql.port->text() );
  143. +  settings.endGroup();
  144. +
  145. +  // selected driver
  146. +  settings.beginGroup( "GENERAL" );
  147. +  settings.setValue( "Driver", ui_driver.driverBox->itemData( ui_driver.driverBox->currentIndex() ).toString() );
  148. +  settings.endGroup();
  149.    settings.sync();
  150.  
  151.    // TODO: restart server if needed
  152. @@ -97,9 +161,11 @@
  153.  
  154.  void ServerConfigModule::defaults()
  155.  {
  156. -  ui.startServer->setChecked( true );
  157. +  ui_mysql.startServer->setChecked( true );
  158.    // TODO: detect default server path
  159. -  ui.name->setText( "akonadi" );
  160. +  ui_mysql.name->setText( "akonadi" );
  161. +
  162. +  ui_driver.driverBox->setCurrentIndex( ui_driver.driverBox->findData ("QMYSQL") );
  163.  }
  164.  
  165.  void ServerConfigModule::updateStatus()
  166. @@ -133,4 +199,16 @@
  167.    ServerManager::showSelfTestDialog( this );
  168.  }
  169.  
  170. +void ServerConfigModule::driverChanged( int index )
  171. +{
  172. +  if( ui_driver.driverBox->itemData( index ).toString() == "QMYSQL" ) {
  173. +    m_psqlWidget->setVisible( false );
  174. +    m_mysqlWidget->setVisible( true );
  175. +  }
  176. +  else {
  177. +    m_psqlWidget->setVisible( true );
  178. +    m_mysqlWidget->setVisible( false );
  179. +  }
  180. +}
  181. +
  182.  #include "serverconfigmodule.moc"
  183. Index: akonadi/kcm/serverconfigmodule.h
  184. ===================================================================
  185. --- akonadi/kcm/serverconfigmodule.h    (revision 981519)
  186. +++ akonadi/kcm/serverconfigmodule.h    (working copy)
  187. @@ -21,9 +21,14 @@
  188.  #define SERVERCONFIGMODULE_H
  189.  
  190.  #include "ui_serverconfigmodule.h"
  191. +#include "ui_servermysqlstorage.h"
  192. +#include "ui_serverpsqlstorage.h"
  193. +#include "ui_serverstoragedriver.h"
  194.  
  195.  #include <KCModule>
  196.  
  197. +class QComboBox;
  198. +
  199.  class ServerConfigModule : public KCModule
  200.  {
  201.    Q_OBJECT
  202. @@ -39,9 +44,18 @@
  203.      void startStopClicked();
  204.      void restartClicked();
  205.      void selfTestClicked();
  206. +    void driverChanged(int);
  207.  
  208.    private:
  209.      Ui::ServerConfigModule ui;
  210. +    Ui::StorageDriver ui_driver;
  211. +    Ui::MySQLStorageObject ui_mysql;
  212. +    Ui::PSQLStorageObject  ui_psql;
  213. +
  214. +    QWidget *m_mysqlWidget;
  215. +    QWidget *m_psqlWidget;
  216. +
  217. +    QComboBox *m_driverBox;
  218.  };
  219.  
  220.  #endif
  221. Index: akonadi/kcm/CMakeLists.txt
  222. ===================================================================
  223. --- akonadi/kcm/CMakeLists.txt  (revision 981519)
  224. +++ akonadi/kcm/CMakeLists.txt  (working copy)
  225. @@ -7,7 +7,10 @@
  226.  
  227.  
  228.  set(akonadi_server_kcm_srcs serverconfigmodule.cpp)
  229. -kde4_add_ui_files(akonadi_server_kcm_srcs serverconfigmodule.ui )
  230. +kde4_add_ui_files(akonadi_server_kcm_srcs serverconfigmodule.ui
  231. +                                          servermysqlstorage.ui
  232. +                                          serverpsqlstorage.ui
  233. +                                          serverstoragedriver.ui)
  234.  kde4_add_plugin(kcm_akonadi_server ${akonadi_server_kcm_srcs})
  235.  target_link_libraries(kcm_akonadi_server  ${KDE4_KIO_LIBS} ${KDEPIMLIBS_AKONADI_LIBS} ${AKONADI_COMMON_LIBRARIES})
  236.  
  237. Index: akonadi/kcm/serverconfigmodule.ui
  238. ===================================================================
  239. --- akonadi/kcm/serverconfigmodule.ui   (revision 981519)
  240. +++ akonadi/kcm/serverconfigmodule.ui   (working copy)
  241. @@ -6,151 +6,12 @@
  242.     <rect>
  243.      <x>0</x>
  244.      <y>0</y>
  245. -    <width>444</width>
  246. -    <height>526</height>
  247. +    <width>493</width>
  248. +    <height>121</height>
  249.     </rect>
  250.    </property>
  251.    <layout class="QGridLayout" name="gridLayout_2">
  252.     <item row="0" column="0">
  253. -    <widget class="QCheckBox" name="startServer">
  254. -     <property name="whatsThis">
  255. -      <string>Choose whether Akonadi should use an internal or external MySQL server.</string>
  256. -     </property>
  257. -     <property name="text">
  258. -      <string>Use internal MySQL server</string>
  259. -     </property>
  260. -     <property name="checked">
  261. -      <bool>true</bool>
  262. -     </property>
  263. -    </widget>
  264. -   </item>
  265. -   <item row="1" column="0">
  266. -    <widget class="QGroupBox" name="groupBox_2">
  267. -     <property name="title">
  268. -      <string>Internal MySQL Server</string>
  269. -     </property>
  270. -     <layout class="QHBoxLayout" name="horizontalLayout">
  271. -      <item>
  272. -       <widget class="QLabel" name="label">
  273. -        <property name="text">
  274. -         <string>MySQL server executable:</string>
  275. -        </property>
  276. -        <property name="buddy">
  277. -         <cstring>serverPath</cstring>
  278. -        </property>
  279. -       </widget>
  280. -      </item>
  281. -      <item>
  282. -       <widget class="KUrlRequester" name="serverPath">
  283. -        <property name="whatsThis">
  284. -         <string>&lt;p&gt;&lt;b&gt;MySQL server location&lt;/b&gt;&lt;/p&gt;&lt;br&gt;Enter the location of your internal MySQL server or click on the Browse button.</string>
  285. -        </property>
  286. -       </widget>
  287. -      </item>
  288. -     </layout>
  289. -    </widget>
  290. -   </item>
  291. -   <item row="2" column="0">
  292. -    <widget class="QGroupBox" name="groupBox">
  293. -     <property name="enabled">
  294. -      <bool>false</bool>
  295. -     </property>
  296. -     <property name="title">
  297. -      <string>External MySQL Server</string>
  298. -     </property>
  299. -     <layout class="QFormLayout" name="formLayout">
  300. -      <item row="0" column="0">
  301. -       <widget class="QLabel" name="label_6">
  302. -        <property name="text">
  303. -         <string>Database name:</string>
  304. -        </property>
  305. -        <property name="buddy">
  306. -         <cstring>name</cstring>
  307. -        </property>
  308. -       </widget>
  309. -      </item>
  310. -      <item row="0" column="1">
  311. -       <widget class="KLineEdit" name="name">
  312. -        <property name="whatsThis">
  313. -         <string>&lt;p&gt;&lt;b&gt;Database Name&lt;/b&gt;&lt;/p&gt;&lt;br&gt;Enter the name of your Akonadi database on your external MySQL server.</string>
  314. -        </property>
  315. -       </widget>
  316. -      </item>
  317. -      <item row="1" column="0">
  318. -       <widget class="QLabel" name="label_2">
  319. -        <property name="text">
  320. -         <string>Host:</string>
  321. -        </property>
  322. -        <property name="buddy">
  323. -         <cstring>host</cstring>
  324. -        </property>
  325. -       </widget>
  326. -      </item>
  327. -      <item row="1" column="1">
  328. -       <widget class="KLineEdit" name="host">
  329. -        <property name="whatsThis">
  330. -         <string>&lt;p&gt;&lt;b&gt;Host&lt;/b&gt;&lt;/p&gt;&lt;br&gt;Enter the hostname or the IP address of the machine hosting your MySQL server.</string>
  331. -        </property>
  332. -       </widget>
  333. -      </item>
  334. -      <item row="2" column="0">
  335. -       <widget class="QLabel" name="label_3">
  336. -        <property name="text">
  337. -         <string>Username:</string>
  338. -        </property>
  339. -        <property name="buddy">
  340. -         <cstring>username</cstring>
  341. -        </property>
  342. -       </widget>
  343. -      </item>
  344. -      <item row="2" column="1">
  345. -       <widget class="KLineEdit" name="username">
  346. -        <property name="whatsThis">
  347. -         <string>Enter the username required to access your MySQL database.</string>
  348. -        </property>
  349. -       </widget>
  350. -      </item>
  351. -      <item row="3" column="0">
  352. -       <widget class="QLabel" name="label_4">
  353. -        <property name="text">
  354. -         <string>Password:</string>
  355. -        </property>
  356. -        <property name="buddy">
  357. -         <cstring>password</cstring>
  358. -        </property>
  359. -       </widget>
  360. -      </item>
  361. -      <item row="3" column="1">
  362. -       <widget class="KLineEdit" name="password">
  363. -        <property name="whatsThis">
  364. -         <string>Enter the password required to access your MySQL database.</string>
  365. -        </property>
  366. -        <property name="passwordMode">
  367. -         <bool>true</bool>
  368. -        </property>
  369. -       </widget>
  370. -      </item>
  371. -      <item row="4" column="0">
  372. -       <widget class="QLabel" name="label_5">
  373. -        <property name="text">
  374. -         <string>Options:</string>
  375. -        </property>
  376. -        <property name="buddy">
  377. -         <cstring>options</cstring>
  378. -        </property>
  379. -       </widget>
  380. -      </item>
  381. -      <item row="4" column="1">
  382. -       <widget class="KLineEdit" name="options">
  383. -        <property name="whatsThis">
  384. -         <string>&lt;p&gt;&lt;b&gt;External MySQL server options&lt;/b&gt;&lt;/p&gt;&lt;br&gt;If necessary, you may pass options to your MySQL server.</string>
  385. -        </property>
  386. -       </widget>
  387. -      </item>
  388. -     </layout>
  389. -    </widget>
  390. -   </item>
  391. -   <item row="3" column="0">
  392.      <widget class="QGroupBox" name="groupBox_3">
  393.       <property name="title">
  394.        <string>Status</string>
  395. @@ -219,80 +80,15 @@
  396.       </layout>
  397.      </widget>
  398.     </item>
  399. -   <item row="4" column="0">
  400. -    <spacer name="verticalSpacer">
  401. -     <property name="orientation">
  402. -      <enum>Qt::Vertical</enum>
  403. -     </property>
  404. -     <property name="sizeHint" stdset="0">
  405. -      <size>
  406. -       <width>20</width>
  407. -       <height>89</height>
  408. -      </size>
  409. -     </property>
  410. -    </spacer>
  411. -   </item>
  412.    </layout>
  413.   </widget>
  414.   <customwidgets>
  415.    <customwidget>
  416. -   <class>KLineEdit</class>
  417. -   <extends>QLineEdit</extends>
  418. -   <header>klineedit.h</header>
  419. -  </customwidget>
  420. -  <customwidget>
  421.     <class>KPushButton</class>
  422.     <extends>QPushButton</extends>
  423.     <header>kpushbutton.h</header>
  424.    </customwidget>
  425. -  <customwidget>
  426. -   <class>KUrlRequester</class>
  427. -   <extends>QFrame</extends>
  428. -   <header>kurlrequester.h</header>
  429. -  </customwidget>
  430.   </customwidgets>
  431. - <tabstops>
  432. -  <tabstop>startServer</tabstop>
  433. -  <tabstop>serverPath</tabstop>
  434. -  <tabstop>name</tabstop>
  435. -  <tabstop>host</tabstop>
  436. -  <tabstop>username</tabstop>
  437. -  <tabstop>password</tabstop>
  438. -  <tabstop>options</tabstop>
  439. - </tabstops>
  440.   <resources/>
  441. - <connections>
  442. -  <connection>
  443. -   <sender>startServer</sender>
  444. -   <signal>toggled(bool)</signal>
  445. -   <receiver>groupBox_2</receiver>
  446. -   <slot>setEnabled(bool)</slot>
  447. -   <hints>
  448. -    <hint type="sourcelabel">
  449. -     <x>53</x>
  450. -     <y>18</y>
  451. -    </hint>
  452. -    <hint type="destinationlabel">
  453. -     <x>56</x>
  454. -     <y>34</y>
  455. -    </hint>
  456. -   </hints>
  457. -  </connection>
  458. -  <connection>
  459. -   <sender>startServer</sender>
  460. -   <signal>toggled(bool)</signal>
  461. -   <receiver>groupBox</receiver>
  462. -   <slot>setDisabled(bool)</slot>
  463. -   <hints>
  464. -    <hint type="sourcelabel">
  465. -     <x>135</x>
  466. -     <y>20</y>
  467. -    </hint>
  468. -    <hint type="destinationlabel">
  469. -     <x>146</x>
  470. -     <y>110</y>
  471. -    </hint>
  472. -   </hints>
  473. -  </connection>
  474. - </connections>
  475. + <connections/>
  476.  </ui>
  477.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement