kitchensync
configguigcalendar.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "configguigcalendar.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 ConfigGuiGoogleCalendar::ConfigGuiGoogleCalendar( const QSync::Member &member, QWidget *parent )
00033 : ConfigGui( member, parent )
00034 {
00035 QBoxLayout *userLayout = new QHBoxLayout( topLayout() );
00036
00037 QLabel *userLbl= new QLabel( i18n("Username:"), this );
00038 userLayout->addWidget(userLbl);
00039
00040 mUsername = new QLineEdit(this);
00041 userLayout->addWidget(mUsername);
00042
00043
00044 QBoxLayout *passLayout = new QHBoxLayout( topLayout() );
00045
00046 QLabel *passLbl = new QLabel( i18n("Password:"), this );
00047 passLayout->addWidget(passLbl);
00048
00049 mPassword = new QLineEdit(this);
00050 mPassword->setEchoMode(QLineEdit::Password);
00051 passLayout->addWidget(mPassword);
00052
00053 topLayout()->addWidget(new QLabel( i18n("Please notice that currently the password is stored as plain text in the plugin configuration file"), this ));
00054
00055 QBoxLayout *urlLayout = new QHBoxLayout( topLayout() );
00056 QLabel *urlLbl = new QLabel( i18n("Calendar URL:"), this );
00057 urlLayout->addWidget(urlLbl);
00058
00059 mUrl = new QLineEdit(this);
00060 urlLayout->addWidget(mUrl);
00061
00062 topLayout()->addStretch( 1 );
00063 }
00064
00065 void ConfigGuiGoogleCalendar::load( const QString &xml )
00066 {
00067 QDomDocument doc;
00068 doc.setContent( xml );
00069 QDomElement docElement = doc.documentElement();
00070 QDomNode n;
00071 for( n = docElement.firstChild(); !n.isNull(); n = n.nextSibling() ) {
00072 QDomElement e = n.toElement();
00073 if ( e.tagName() == "username" ) {
00074 mUsername->setText(e.text());
00075 } else if ( e.tagName() == "password" ) {
00076 mPassword->setText(e.text());
00077 } else if ( e.tagName() == "url" ) {
00078 mUrl->setText(e.text());
00079 }
00080 }
00081 }
00082
00083 QString ConfigGuiGoogleCalendar::save()
00084 {
00085 QDomDocument doc;
00086 QDomElement root = doc.createElement("config");
00087 doc.appendChild(root);
00088
00089 QDomElement un = doc.createElement("username");
00090 root.appendChild(un);
00091 un.appendChild(doc.createTextNode(mUsername->text()));
00092
00093 QDomElement pass = doc.createElement("password");
00094 root.appendChild(pass);
00095 pass.appendChild(doc.createTextNode(mPassword->text()));
00096
00097 QDomElement url = doc.createElement("url");
00098 root.appendChild(url);
00099 url.appendChild(doc.createTextNode(mUrl->text()));
00100
00101
00102 return doc.toString();
00103 }
|