kitchensync
configguisynce.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "configguisynce.h"
00023
00024 #include <tqdom.h>
00025 #include <tqlabel.h>
00026 #include <tqlayout.h>
00027 #include <tqcheckbox.h>
00028
00029 #include <klineedit.h>
00030 #include <kdialog.h>
00031 #include <tdelocale.h>
00032
00033 ConfigGuiSynce::ConfigGuiSynce( const QSync::Member &member, TQWidget *parent )
00034 : ConfigGui( member, parent )
00035 {
00036 initGUI();
00037 }
00038
00039 void ConfigGuiSynce::load( const TQString &xml )
00040 {
00041 TQDomDocument doc;
00042 doc.setContent( xml );
00043 TQDomElement docElement = doc.documentElement();
00044 TQDomNode node;
00045 for( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
00046 TQDomElement element = node.toElement();
00047 if ( element.tagName() == "contact" ) {
00048 mContacts->setChecked( element.text().toInt() == 1 );
00049 } else if ( element.tagName() == "todos" ) {
00050 mTodos->setChecked( element.text().toInt() == 1 );
00051 } else if ( element.tagName() == "calendar" ) {
00052 mCalendar->setChecked( element.text().toInt() == 1 );
00053 } else if ( element.tagName() == "file" ) {
00054 mFile->setText( element.text() );
00055 }
00056 }
00057 }
00058
00059 TQString ConfigGuiSynce::save() const
00060 {
00061 TQString config = "<config>\n";
00062
00063 config += TQString( "<contact>%1</contact>\n" ).arg( mContacts->isChecked() ? "1" : "0" );
00064 config += TQString( "<todos>%1</todos>\n" ).arg( mTodos->isChecked() ? "1" : "0" );
00065 config += TQString( "<calendar>%1</calendar>\n" ).arg( mCalendar->isChecked() ? "1" : "0" );
00066 config += TQString( "<file>%1</file>\n" ).arg( mFile->text() );
00067
00068 config += "</config>";
00069
00070 return config;
00071 }
00072
00073 void ConfigGuiSynce::initGUI()
00074 {
00075 TQGridLayout *layout = new TQGridLayout( topLayout(), 12, 2, KDialog::spacingHint() );
00076 layout->setMargin( KDialog::marginHint() );
00077
00078 mContacts = new TQCheckBox( this );
00079 mContacts->setText( "Sync Contacts" );
00080 layout->addMultiCellWidget( mContacts, 0, 0, 0, 1 );
00081
00082 mTodos = new TQCheckBox( this );
00083 mTodos->setText( "Sync \'Todo\' items" );
00084 layout->addMultiCellWidget( mTodos, 1, 1, 0, 1 );
00085
00086 mCalendar = new TQCheckBox( this );
00087 mCalendar->setText( "Sync Calendar" );
00088 layout->addMultiCellWidget( mCalendar, 2, 2, 0, 1 );
00089
00090 layout->addWidget( new TQLabel( i18n( "File:" ), this ), 3, 0 );
00091 mFile = new KLineEdit( this );
00092 layout->addWidget( mFile, 3, 1 );
00093 }
|