kitchensync

configguijescs.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 "configguijescs.h"
23
24#include <tqcheckbox.h>
25#include <tqdom.h>
26#include <tqlabel.h>
27#include <tqlayout.h>
28
29#include <klineedit.h>
30#include <kdialog.h>
31#include <tdelocale.h>
32
33ConfigGuiJescs::ConfigGuiJescs( const QSync::Member &member, TQWidget *parent )
34 : ConfigGui( member, parent )
35{
36 initGUI();
37}
38
39void ConfigGuiJescs::load( const TQString &xml )
40{
41 TQDomDocument doc;
42 doc.setContent( xml );
43 TQDomElement docElement = doc.documentElement();
44 TQDomNode node;
45 for( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
46 TQDomElement element = node.toElement();
47 if ( element.tagName() == "url" ) {
48 mUrl->setText( element.text() );
49 } else if ( element.tagName() == "username" ) {
50 mUsername->setText( element.text() );
51 } else if ( element.tagName() == "password" ) {
52 mPassword->setText( element.text() );
53 } else if ( element.tagName() == "del_notify" ) {
54 mDelNotify->setChecked( element.text() == "1" );
55 }
56 }
57}
58
59TQString ConfigGuiJescs::save() const
60{
61 int delNotifyState;
62 TQString config = "<config>\n";
63
64 config += TQString( "<url>%1</url>\n" ).arg( mUrl->text() );
65 config += TQString( "<username>%1</username>\n" ).arg( mUsername->text() );
66 config += TQString( "<password>%1</password>\n" ).arg( mPassword->text() );
67 if ( mDelNotify->isChecked() ) { delNotifyState = 1;
68 } else { delNotifyState = 0;
69 }
70 config += TQString( "<del_notify>%1</del_notify>\n" ).arg( delNotifyState );
71
72 config += "</config>";
73
74 return config;
75}
76
77void ConfigGuiJescs::initGUI()
78{
79 TQGridLayout *layout = new TQGridLayout( topLayout(), 12, 3, KDialog::spacingHint() );
80 layout->setMargin( KDialog::marginHint() );
81
82 layout->addWidget( new TQLabel( i18n( "URL:" ), this ), 0, 0 );
83 mUrl = new KLineEdit( this );
84 layout->addMultiCellWidget( mUrl, 0, 0, 1, 2 );
85
86 layout->addWidget( new TQLabel( i18n( "Username:" ), this ), 1, 0 );
87 mUsername = new KLineEdit( this );
88 layout->addMultiCellWidget( mUsername, 1, 1, 1, 2 );
89
90 layout->addWidget( new TQLabel( i18n( "Password:" ), this ), 2, 0 );
91 mPassword = new KLineEdit( this );
92 mPassword->setEchoMode( KLineEdit::Password );
93 layout->addMultiCellWidget( mPassword, 2, 2, 1, 2 );
94
95 mDelNotify = new TQCheckBox( this );
96 mDelNotify->setText( "Notify attendees about event/task deletion" );
97 layout->addMultiCellWidget( mDelNotify, 3, 3, 0, 2 );
98}