configguievo2.cpp
00001 /* 00002 This file is part of KitchenSync. 00003 00004 Copyright (c) 2007 Anirudh Ramesh <abattoir@abattoir.in> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00019 USA. 00020 */ 00021 00022 #include "configguievo2.h" 00023 00024 #include <tqdom.h> 00025 #include <tqlabel.h> 00026 #include <tqlayout.h> 00027 #include <tqstring.h> 00028 00029 #include <kurlrequester.h> 00030 #include <kurl.h> 00031 #include <kfile.h> 00032 #include <kdialog.h> 00033 #include <klocale.h> 00034 00035 ConfigGuiEvo2::ConfigGuiEvo2( const QSync::Member &member, TQWidget *parent ) 00036 : ConfigGui( member, parent ) 00037 { 00038 initGUI(); 00039 } 00040 00041 void ConfigGuiEvo2::load( const TQString &xml ) 00042 { 00043 TQDomDocument doc; 00044 doc.setContent( xml ); 00045 TQDomElement docElement = doc.documentElement(); 00046 TQDomNode node; 00047 for( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) { 00048 TQDomElement element = node.toElement(); 00049 if ( element.tagName() == "address_path" ) { 00050 mAddressPath->setURL( element.text() ); 00051 } else if ( element.tagName() == "calendar_path" ) { 00052 mCalendarPath->setURL( element.text() ) ; 00053 } else if ( element.tagName() == "tasks_path" ) { 00054 mTasksPath->setURL( element.text() ); 00055 } 00056 } 00057 } 00058 00059 TQString ConfigGuiEvo2::save() const 00060 { 00061 TQString config = "<config>\n"; 00062 00063 config += TQString( "<address_path>%1</address_path>\n" ).arg( mAddressPath->url() ); 00064 config += TQString( "<calendar_path>%1</calendar_path>\n" ).arg( mCalendarPath->url() ); 00065 config += TQString( "<tasks_path>%1</tasks_path>\n" ).arg( mTasksPath->url() ); 00066 00067 config += "</config>"; 00068 00069 return config; 00070 } 00071 00072 void ConfigGuiEvo2::initGUI() 00073 { 00074 TQGridLayout *layout = new TQGridLayout( topLayout(), 12, 3, KDialog::spacingHint() ); 00075 layout->setMargin( KDialog::marginHint() ); 00076 00077 layout->addWidget( new TQLabel( i18n( "Address Book location:" ), this ), 0, 0 ); 00078 mAddressPath = new KURLRequester( this ); 00079 mAddressPath->setMode( KFile::Directory ); 00080 layout->addMultiCellWidget( mAddressPath, 0, 0, 1, 2 ); 00081 00082 layout->addWidget( new TQLabel( i18n( "Calendar location:" ), this ), 1, 0 ); 00083 mCalendarPath = new KURLRequester( this ); 00084 mCalendarPath->setMode( KFile::Directory ); 00085 layout->addMultiCellWidget( mCalendarPath, 1, 1, 1, 2 ); 00086 00087 layout->addWidget( new TQLabel( i18n( "Task list location:" ), this ), 2, 0 ); 00088 mTasksPath = new KURLRequester( this ); 00089 mTasksPath->setMode( KFile::Directory ); 00090 layout->addMultiCellWidget( mTasksPath, 2, 2, 1, 2 ); 00091 }