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