kitchensync

configguimoto.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 "configguimoto.h"
00023 
00024 #include <tqdom.h>
00025 #include <tqlabel.h>
00026 #include <tqlayout.h>
00027 
00028 #include <klineedit.h>
00029 #include <kdialog.h>
00030 #include <tdelocale.h>
00031 
00032 ConfigGuiMoto::ConfigGuiMoto( const QSync::Member &member, TQWidget *parent )
00033   : ConfigGui( member, parent )
00034 {
00035   initGUI();
00036 }
00037 
00038 void ConfigGuiMoto::load( const TQString &xml )
00039 {
00040   TQDomDocument doc;
00041   doc.setContent( xml );
00042   TQDomElement docElement = doc.documentElement();
00043   TQDomNode node;
00044   for( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
00045     TQDomElement element = node.toElement();
00046     if ( element.tagName() == "device" ) {
00047       mDeviceString->setText( element.text() );
00048     }
00049   }
00050 }
00051 
00052 TQString ConfigGuiMoto::save() const
00053 {
00054   TQString config = "<config>\n";
00055 
00056   config += TQString( "<device>%1</device>\n" ).arg( mDeviceString->text() );
00057 
00058   config += "</config>";
00059 
00060   return config;
00061 }
00062 
00063 void ConfigGuiMoto::initGUI()
00064 {
00065   TQGridLayout *layout = new TQGridLayout( topLayout(), 12, 3, KDialog::spacingHint() );
00066   layout->setMargin( KDialog::marginHint() );
00067 
00068   layout->addWidget( new TQLabel( i18n( "Device String:" ), this ), 0, 0 );
00069   mDeviceString = new KLineEdit( this );
00070   layout->addMultiCellWidget( mDeviceString, 0, 0, 1, 2 );
00071 }