kitchensync
configguijescs.cpp00001 #include "configguijescs.h"
00002
00003 #include <qcheckbox.h>
00004 #include <qdom.h>
00005 #include <qlabel.h>
00006 #include <qlayout.h>
00007
00008 #include <klineedit.h>
00009 #include <kdialog.h>
00010 #include <klocale.h>
00011
00012 ConfigGuiJescs::ConfigGuiJescs( const QSync::Member &member, QWidget *parent )
00013 : ConfigGui( member, parent )
00014 {
00015 initGUI();
00016 }
00017
00018 void ConfigGuiJescs::load( const QString &xml )
00019 {
00020 QDomDocument doc;
00021 doc.setContent( xml );
00022 QDomElement docElement = doc.documentElement();
00023 QDomNode node;
00024 for( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
00025 QDomElement element = node.toElement();
00026 if ( element.tagName() == "url" ) {
00027 mUrl->setText( element.text() );
00028 } else if ( element.tagName() == "username" ) {
00029 mUsername->setText( element.text() );
00030 } else if ( element.tagName() == "password" ) {
00031 mPassword->setText( element.text() );
00032 } else if ( element.tagName() == "del_notify" ) {
00033 mDelNotify->setChecked( element.text() == "1" );
00034 }
00035 }
00036 }
00037
00038 QString ConfigGuiJescs::save() const
00039 {
00040 int delNotifyState;
00041 QString config = "<config>\n";
00042
00043 config += QString( "<url>%1</url>\n" ).arg( mUrl->text() );
00044 config += QString( "<username>%1</username>\n" ).arg( mUsername->text() );
00045 config += QString( "<password>%1</password>\n" ).arg( mPassword->text() );
00046 if ( mDelNotify->isChecked() ) { delNotifyState = 1;
00047 } else { delNotifyState = 0;
00048 }
00049 config += QString( "<del_notify>%1</del_notify>\n" ).arg( delNotifyState );
00050
00051 config += "</config>";
00052
00053 return config;
00054 }
00055
00056 void ConfigGuiJescs::initGUI()
00057 {
00058 QGridLayout *layout = new QGridLayout( topLayout(), 12, 3, KDialog::spacingHint() );
00059 layout->setMargin( KDialog::marginHint() );
00060
00061 layout->addWidget( new QLabel( i18n( "URL:" ), this ), 0, 0 );
00062 mUrl = new KLineEdit( this );
00063 layout->addMultiCellWidget( mUrl, 0, 0, 1, 2 );
00064
00065 layout->addWidget( new QLabel( i18n( "Username:" ), this ), 1, 0 );
00066 mUsername = new KLineEdit( this );
00067 layout->addMultiCellWidget( mUsername, 1, 1, 1, 2 );
00068
00069 layout->addWidget( new QLabel( i18n( "Password:" ), this ), 2, 0 );
00070 mPassword = new KLineEdit( this );
00071 mPassword->setEchoMode( KLineEdit::Password );
00072 layout->addMultiCellWidget( mPassword, 2, 2, 1, 2 );
00073
00074 mDelNotify = new QCheckBox( this );
00075 mDelNotify->setText( "Notify attendees about event/task deletion" );
00076 layout->addMultiCellWidget( mDelNotify, 3, 3, 0, 2 );
00077 }
|