kitchensync
configguifile.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "configguifile.h"
00023
00024 #include <kurlrequester.h>
00025 #include <klocale.h>
00026 #include <kdialog.h>
00027
00028 #include <tqlayout.h>
00029 #include <tqcheckbox.h>
00030 #include <tqlabel.h>
00031 #include <tqdom.h>
00032
00033 ConfigGuiFile::ConfigGuiFile( const QSync::Member &member, TQWidget *parent )
00034 : ConfigGui( member, parent )
00035 {
00036 TQBoxLayout *filenameLayout = new TQHBoxLayout( topLayout() );
00037
00038 TQLabel *label = new TQLabel( i18n("Directory name:"), this );
00039 filenameLayout->addWidget( label );
00040
00041 mFilename = new KURLRequester( this );
00042 mFilename->setMode( KFile::Directory | KFile::LocalOnly );
00043 filenameLayout->addWidget( mFilename );
00044
00045 TQBoxLayout *recursiveLayout = new TQHBoxLayout( topLayout() );
00046
00047 mRecursive = new TQCheckBox( i18n("Sync all subdirectories"), this );
00048 recursiveLayout->addWidget( mRecursive );
00049
00050 topLayout()->addStretch( 1 );
00051 }
00052
00053 void ConfigGuiFile::load( const TQString &xml )
00054 {
00055 TQDomDocument doc;
00056 doc.setContent( xml );
00057 TQDomElement docElement = doc.documentElement();
00058 TQDomNode n;
00059 for( n = docElement.firstChild(); !n.isNull(); n = n.nextSibling() ) {
00060 TQDomElement e = n.toElement();
00061 if ( e.tagName() == "path" ) {
00062 mFilename->setURL( e.text() );
00063 } else if ( e.tagName() == "recursive" ) {
00064 mRecursive->setChecked( e.text() == "TRUE" );
00065 }
00066 }
00067 }
00068
00069 TQString ConfigGuiFile::save() const
00070 {
00071 TQString xml;
00072 xml = "<config>";
00073 xml += "<path>" + mFilename->url() + "</path>";
00074 xml += "<recursive>";
00075 if ( mRecursive->isChecked() ) xml += "TRUE";
00076 else xml += "FALSE";
00077 xml += "</recursive>";
00078 xml += "</config>";
00079
00080 return xml;
00081 }
|