kitchensync
configguibarry.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "configguibarry.h"
00025
00026 #include <klocale.h>
00027
00028 #include <qlayout.h>
00029 #include <qlabel.h>
00030 #include <qdom.h>
00031 #include <qlineedit.h>
00032
00033 ConfigGuiBarry::ConfigGuiBarry( const QSync::Member &member, QWidget *parent )
00034 : ConfigGui( member, parent )
00035 {
00036 QBoxLayout *userLayout = new QHBoxLayout( topLayout() );
00037
00038 QLabel *pinLbl= new QLabel( i18n("PIN:"), this );
00039 userLayout->addWidget(pinLbl);
00040
00041 mPin = new QLineEdit(this);
00042 userLayout->addWidget(mPin);
00043
00044 mCalendar = new QCheckBox( i18n("Sync calendar"), this );
00045 userLayout->addWidget( mCalendar );
00046
00047 mContacts = new QCheckBox( i18n("Sync contacts"), this );
00048 userLayout->addWidget( mContacts );
00049
00050 topLayout()->addStretch( 1 );
00051 }
00052
00053 void ConfigGuiBarry::load(const QString &cfg)
00054 {
00055 QStringList lines = QStringList::split( '\n', cfg);
00056 QString pin;
00057 uint cal = 0;
00058 uint con = 0;
00059 for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) {
00060 QStringList options = QStringList::split( ' ', *it);
00061 if (options.count() < 1)
00062
00063 continue;
00064
00065 if( options[0].lower() == "device" )
00066 {
00067 if (options.count() < 2)
00068
00069 continue;
00070
00071 pin = options[1];
00072 if (options.count() >= 3)
00073 cal = options[2].toUInt();
00074 if (options.count() >= 4)
00075 con = options[3].toUInt();
00076
00077 mPin->setText(pin);
00078 mCalendar->setChecked( cal != 0);
00079 mContacts->setChecked( con != 0);
00080 }
00081 }
00082 }
00083
00084 QString ConfigGuiBarry::save() const
00085 {
00086 QString cfg;
00087 cfg = "Device " + mPin->text();
00088 if ( mCalendar->isChecked() ) cfg += " 1";
00089 else cfg += " 0";
00090 if ( mContacts->isChecked() ) cfg += " 1";
00091 else cfg += " 0";
00092
00093 return cfg;
00094 }
|