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