kitchensync
configguievo2.cpp00001 #include "configguievo2.h"
00002
00003 #include <qdom.h>
00004 #include <qlabel.h>
00005 #include <qlayout.h>
00006 #include <qstring.h>
00007
00008 #include <kurlrequester.h>
00009 #include <kurl.h>
00010 #include <kfile.h>
00011 #include <kdialog.h>
00012 #include <klocale.h>
00013
00014 ConfigGuiEvo2::ConfigGuiEvo2( const QSync::Member &member, QWidget *parent )
00015 : ConfigGui( member, parent )
00016 {
00017 initGUI();
00018 }
00019
00020 void ConfigGuiEvo2::load( const QString &xml )
00021 {
00022 QDomDocument doc;
00023 doc.setContent( xml );
00024 QDomElement docElement = doc.documentElement();
00025 QDomNode node;
00026 for( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
00027 QDomElement element = node.toElement();
00028 if ( element.tagName() == "address_path" ) {
00029 mAddressPath->setURL( element.text() );
00030 } else if ( element.tagName() == "calendar_path" ) {
00031 mCalendarPath->setURL( element.text() ) ;
00032 } else if ( element.tagName() == "tasks_path" ) {
00033 mTasksPath->setURL( element.text() );
00034 }
00035 }
00036 }
00037
00038 QString ConfigGuiEvo2::save() const
00039 {
00040 QString config = "<config>\n";
00041
00042 config += QString( "<address_path>%1</address_path>\n" ).arg( mAddressPath->url() );
00043 config += QString( "<calendar_path>%1</calendar_path>\n" ).arg( mCalendarPath->url() );
00044 config += QString( "<tasks_path>%1</tasks_path>\n" ).arg( mTasksPath->url() );
00045
00046 config += "</config>";
00047
00048 return config;
00049 }
00050
00051 void ConfigGuiEvo2::initGUI()
00052 {
00053 QGridLayout *layout = new QGridLayout( topLayout(), 12, 3, KDialog::spacingHint() );
00054 layout->setMargin( KDialog::marginHint() );
00055
00056 layout->addWidget( new QLabel( i18n( "Address Book location:" ), this ), 0, 0 );
00057 mAddressPath = new KURLRequester( this );
00058 mAddressPath->setMode( KFile::Directory );
00059 layout->addMultiCellWidget( mAddressPath, 0, 0, 1, 2 );
00060
00061 layout->addWidget( new QLabel( i18n( "Calendar location:" ), this ), 1, 0 );
00062 mCalendarPath = new KURLRequester( this );
00063 mCalendarPath->setMode( KFile::Directory );
00064 layout->addMultiCellWidget( mCalendarPath, 1, 1, 1, 2 );
00065
00066 layout->addWidget( new QLabel( i18n( "Task list location:" ), this ), 2, 0 );
00067 mTasksPath = new KURLRequester( this );
00068 mTasksPath->setMode( KFile::Directory );
00069 layout->addMultiCellWidget( mTasksPath, 2, 2, 1, 2 );
00070 }
|