kitchensync

configguievo2.cpp
1 /*
2  This file is part of KitchenSync.
3 
4  Copyright (c) 2007 Anirudh Ramesh <abattoir@abattoir.in>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19  USA.
20 */
21 
22 #include "configguievo2.h"
23 
24 #include <tqdom.h>
25 #include <tqlabel.h>
26 #include <tqlayout.h>
27 #include <tqstring.h>
28 
29 #include <kurlrequester.h>
30 #include <kurl.h>
31 #include <tdefile.h>
32 #include <kdialog.h>
33 #include <tdelocale.h>
34 
35 ConfigGuiEvo2::ConfigGuiEvo2( const QSync::Member &member, TQWidget *parent )
36  : ConfigGui( member, parent )
37 {
38  initGUI();
39 }
40 
41 void ConfigGuiEvo2::load( const TQString &xml )
42 {
43  TQDomDocument doc;
44  doc.setContent( xml );
45  TQDomElement docElement = doc.documentElement();
46  TQDomNode node;
47  for( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
48  TQDomElement element = node.toElement();
49  if ( element.tagName() == "address_path" ) {
50  mAddressPath->setURL( element.text() );
51  } else if ( element.tagName() == "calendar_path" ) {
52  mCalendarPath->setURL( element.text() ) ;
53  } else if ( element.tagName() == "tasks_path" ) {
54  mTasksPath->setURL( element.text() );
55  }
56  }
57 }
58 
59 TQString ConfigGuiEvo2::save() const
60 {
61  TQString config = "<config>\n";
62 
63  config += TQString( "<address_path>%1</address_path>\n" ).arg( mAddressPath->url() );
64  config += TQString( "<calendar_path>%1</calendar_path>\n" ).arg( mCalendarPath->url() );
65  config += TQString( "<tasks_path>%1</tasks_path>\n" ).arg( mTasksPath->url() );
66 
67  config += "</config>";
68 
69  return config;
70 }
71 
72 void ConfigGuiEvo2::initGUI()
73 {
74  TQGridLayout *layout = new TQGridLayout( topLayout(), 12, 3, KDialog::spacingHint() );
75  layout->setMargin( KDialog::marginHint() );
76 
77  layout->addWidget( new TQLabel( i18n( "Address Book location:" ), this ), 0, 0 );
78  mAddressPath = new KURLRequester( this );
79  mAddressPath->setMode( KFile::Directory );
80  layout->addMultiCellWidget( mAddressPath, 0, 0, 1, 2 );
81 
82  layout->addWidget( new TQLabel( i18n( "Calendar location:" ), this ), 1, 0 );
83  mCalendarPath = new KURLRequester( this );
84  mCalendarPath->setMode( KFile::Directory );
85  layout->addMultiCellWidget( mCalendarPath, 1, 1, 1, 2 );
86 
87  layout->addWidget( new TQLabel( i18n( "Task list location:" ), this ), 2, 0 );
88  mTasksPath = new KURLRequester( this );
89  mTasksPath->setMode( KFile::Directory );
90  layout->addMultiCellWidget( mTasksPath, 2, 2, 1, 2 );
91 }