kitchensync

configguimoto.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 "configguimoto.h"
23 
24 #include <tqdom.h>
25 #include <tqlabel.h>
26 #include <tqlayout.h>
27 
28 #include <klineedit.h>
29 #include <kdialog.h>
30 #include <tdelocale.h>
31 
32 ConfigGuiMoto::ConfigGuiMoto( const QSync::Member &member, TQWidget *parent )
33  : ConfigGui( member, parent )
34 {
35  initGUI();
36 }
37 
38 void ConfigGuiMoto::load( const TQString &xml )
39 {
40  TQDomDocument doc;
41  doc.setContent( xml );
42  TQDomElement docElement = doc.documentElement();
43  TQDomNode node;
44  for( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
45  TQDomElement element = node.toElement();
46  if ( element.tagName() == "device" ) {
47  mDeviceString->setText( element.text() );
48  }
49  }
50 }
51 
52 TQString ConfigGuiMoto::save() const
53 {
54  TQString config = "<config>\n";
55 
56  config += TQString( "<device>%1</device>\n" ).arg( mDeviceString->text() );
57 
58  config += "</config>";
59 
60  return config;
61 }
62 
63 void ConfigGuiMoto::initGUI()
64 {
65  TQGridLayout *layout = new TQGridLayout( topLayout(), 12, 3, KDialog::spacingHint() );
66  layout->setMargin( KDialog::marginHint() );
67 
68  layout->addWidget( new TQLabel( i18n( "Device String:" ), this ), 0, 0 );
69  mDeviceString = new KLineEdit( this );
70  layout->addMultiCellWidget( mDeviceString, 0, 0, 1, 2 );
71 }