configguigpe.cpp
00001 /* 00002 This file is part of KitchenSync. 00003 00004 Copyright (c) 2007 Tobias Koenig <tokoe@kde.org> 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 "configguigpe.h" 00023 00024 #include <tqcheckbox.h> 00025 #include <tqdom.h> 00026 #include <tqlabel.h> 00027 #include <tqlayout.h> 00028 #include <tqspinbox.h> 00029 00030 #include <kcombobox.h> 00031 #include <kdialog.h> 00032 #include <klineedit.h> 00033 #include <klocale.h> 00034 00035 ConfigGuiGpe::ConfigGuiGpe( const QSync::Member &member, TQWidget *parent ) 00036 : ConfigGui( member, parent ) 00037 { 00038 initGUI(); 00039 00040 mConnectionMode->insertItem( i18n( "Local" ) ); 00041 mConnectionMode->insertItem( i18n( "Ssh" ) ); 00042 } 00043 00044 void ConfigGuiGpe::load( const TQString &xml ) 00045 { 00046 TQDomDocument doc; 00047 doc.setContent( xml ); 00048 TQDomElement docElement = doc.documentElement(); 00049 TQDomNode node; 00050 for( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) { 00051 TQDomElement element = node.toElement(); 00052 if ( element.tagName() == "use_local" ) { 00053 if ( element.text().toInt() == 1 ) 00054 mConnectionMode->setCurrentItem( 0 ); 00055 else 00056 mConnectionMode->setCurrentItem( 1 ); 00057 } else if ( element.tagName() == "handheld_ip" ) { 00058 mIP->setText( element.text() ); 00059 } else if ( element.tagName() == "handheld_port" ) { 00060 mPort->setValue( element.text().toInt() ); 00061 } else if ( element.tagName() == "handheld_user" ) { 00062 mUser->setText( element.text() ); 00063 } 00064 } 00065 } 00066 00067 TQString ConfigGuiGpe::save() const 00068 { 00069 TQString config = "<config>"; 00070 00071 config += TQString( "<use_local>%1</use_local>" ).arg( mConnectionMode->currentItem() == 0 ); 00072 config += TQString( "<use_ssh>%1</use_ssh>" ).arg( mConnectionMode->currentItem() == 1 ); 00073 config += TQString( "<handheld_ip>%1</handheld_ip>" ).arg( mIP->text() ); 00074 config += TQString( "<handheld_port>%1</handheld_port>" ).arg( mPort->value() ); 00075 config += TQString( "<handheld_user>%1</handheld_user>" ).arg( mUser->text() ); 00076 00077 config += "</config>"; 00078 00079 return config; 00080 } 00081 00082 void ConfigGuiGpe::initGUI() 00083 { 00084 TQGridLayout *layout = new TQGridLayout( topLayout(), 12, 4, KDialog::spacingHint() ); 00085 layout->setMargin( KDialog::marginHint() ); 00086 00087 layout->addWidget( new TQLabel( i18n( "Connection Mode:" ), this ), 0, 0 ); 00088 mConnectionMode = new KComboBox( this ); 00089 layout->addMultiCellWidget( mConnectionMode, 0, 0, 0, 3 ); 00090 00091 layout->addWidget( new TQLabel( i18n( "IP Address:" ), this ), 1, 0 ); 00092 mIP = new KLineEdit( this ); 00093 mIP->setInputMask( "000.000.000.000" ); 00094 layout->addWidget( mIP, 1, 1 ); 00095 00096 layout->addWidget( new TQLabel( i18n( "Port:" ), this ), 1, 2, TQt::AlignRight ); 00097 mPort = new TQSpinBox( 1, 65536, 1, this ); 00098 layout->addWidget( mPort, 1, 3 ); 00099 00100 layout->addWidget( new TQLabel( i18n( "User:" ), this ), 2, 0 ); 00101 mUser = new KLineEdit( this ); 00102 layout->addMultiCellWidget( mUser, 2, 2, 1, 3 ); 00103 }