kitchensync
configguisynce.cpp00001 #include "configguisynce.h"
00002
00003 #include <qdom.h>
00004 #include <qlabel.h>
00005 #include <qlayout.h>
00006
00007 #include <klineedit.h>
00008 #include <kdialog.h>
00009 #include <klocale.h>
00010
00011 ConfigGuiSynce::ConfigGuiSynce( const QSync::Member &member, QWidget *parent )
00012 : ConfigGui( member, parent )
00013 {
00014 initGUI();
00015 }
00016
00017 void ConfigGuiSynce::load( const QString &xml )
00018 {
00019 QDomDocument doc;
00020 doc.setContent( xml );
00021 QDomElement docElement = doc.documentElement();
00022 QDomNode node;
00023 for( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
00024 QDomElement element = node.toElement();
00025 if ( element.tagName() == "contact" ) {
00026 mContacts->setText( element.text() );
00027 } else if ( element.tagName() == "todos" ) {
00028 mTodos->setText( element.text() );
00029 } else if ( element.tagName() == "calendar" ) {
00030 mCalendar->setText( element.text() );
00031 } else if ( element.tagName() == "file" ) {
00032 mFile->setText( element.text() );
00033 }
00034 }
00035 }
00036
00037 QString ConfigGuiSynce::save()
00038 {
00039 QString config = "<config>\n";
00040
00041 config += QString( "<contact>%1</contact>\n" ).arg( mContacts->text() );
00042 config += QString( "<todos>%1</todos>\n" ).arg( mTodos->text() );
00043 config += QString( "<calendar>%1</calendar>\n" ).arg( mCalendar->text() );
00044 config += QString( "<file>%1</file>\n" ).arg( mFile->text() );
00045
00046 config += "</config>";
00047
00048 return config;
00049 }
00050
00051 void ConfigGuiSynce::initGUI()
00052 {
00053 QGridLayout *layout = new QGridLayout( topLayout(), 12, 4, KDialog::spacingHint() );
00054 layout->setMargin( KDialog::marginHint() );
00055
00056 layout->addWidget( new QLabel( i18n( "Contacts:" ), this ), 0, 0 );
00057 mContacts = new KLineEdit( this );
00058 layout->addMultiCellWidget( mContacts, 0, 0, 1, 2 );
00059
00060 layout->addWidget( new QLabel( i18n( "Todo List:" ), this ), 1, 0 );
00061 mTodos = new KLineEdit( this );
00062 layout->addMultiCellWidget( mTodos, 1, 1, 1, 2 );
00063
00064 layout->addWidget( new QLabel( i18n( "Calendar:" ), this ), 2, 0 );
00065 mCalendar = new KLineEdit( this );
00066 layout->addMultiCellWidget( mCalendar, 2, 2, 1, 2 );
00067
00068 layout->addWidget( new QLabel( i18n( "File:" ), this ), 3, 0 );
00069 mFile = new KLineEdit( this );
00070 layout->addMultiCellWidget( mFile, 3, 3, 1, 2 );
00071 }
|