summaryrefslogtreecommitdiffstats
path: root/kresources/caldav/config.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-05-24 17:21:58 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-05-24 17:21:58 +0000
commita71c4476a79950040c9007f84af25cef4e28b351 (patch)
tree20d54bfeb827604e6b1c4ca01e9702346ddcc068 /kresources/caldav/config.cpp
parent45c9a75f1220817f57304df51e018f8cc66aaea4 (diff)
downloadtdepim-a71c4476a79950040c9007f84af25cef4e28b351.tar.gz
tdepim-a71c4476a79950040c9007f84af25cef4e28b351.zip
Initial CalDAV support
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1130194 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kresources/caldav/config.cpp')
-rw-r--r--kresources/caldav/config.cpp162
1 files changed, 162 insertions, 0 deletions
diff --git a/kresources/caldav/config.cpp b/kresources/caldav/config.cpp
new file mode 100644
index 000000000..681faa1c7
--- /dev/null
+++ b/kresources/caldav/config.cpp
@@ -0,0 +1,162 @@
+/*=========================================================================
+| KCalDAV
+|--------------------------------------------------------------------------
+| (c) 2010 Timothy Pearson
+| (c) 2009 Kumaran Santhanam (initial KDE4 version)
+|
+| This project is released under the GNU General Public License.
+| Please see the file COPYING for more details.
+|--------------------------------------------------------------------------
+| Configuration and properties dialog
+ ========================================================================*/
+
+/*=========================================================================
+| INCLUDES
+ ========================================================================*/
+
+#include "resource.h"
+#include "config.h"
+#include "configwidgets.h"
+
+#include <kcombobox.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <klocale.h>
+#include <klineedit.h>
+#include <klistview.h>
+#include <kurlrequester.h>
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qcheckbox.h>
+
+/*=========================================================================
+| NAMESPACE
+ ========================================================================*/
+
+using namespace KCal;
+
+/*=========================================================================
+| CONSTANTS
+ ========================================================================*/
+
+/*=========================================================================
+| STATIC METHODS
+ ========================================================================*/
+
+ResourceCalDav* ResourceCalDavConfig::getCalDavResource(KRES::Resource* resource) {
+ ResourceCalDav *res = dynamic_cast<ResourceCalDav *>( resource );
+ if (!res) {
+ kdDebug() << "invalid resource type";
+ }
+
+ return res;
+}
+
+CalDavPrefs* ResourceCalDavConfig::getPrefs(ResourceCalDav* res) {
+ CalDavPrefs* p = NULL;
+
+ if (res) {
+ p = res->prefs();
+ if (!p) {
+ kdDebug() << "CalDAV: res->prefs() returned NULL";
+ }
+ }
+
+ return p;
+}
+
+/*=========================================================================
+| CONSTRUCTOR / DESTRUCTOR
+ ========================================================================*/
+
+ResourceCalDavConfig::ResourceCalDavConfig( QWidget *parent )
+ : KRES::ConfigWidget( parent )
+{
+ setupUI();
+}
+
+/*=========================================================================
+| METHODS
+ ========================================================================*/
+
+void ResourceCalDavConfig::loadSettings( KRES::Resource *resource ) {
+ ResourceCalDav* res = getCalDavResource(resource);
+ CalDavPrefs* p = getPrefs(res);
+ if (NULL != p) {
+ mUrl->setText(p->url());
+ mUsername->setText(p->username());
+ mRememberPassword->setChecked(p->rememberPassword());
+ mPassword->setText(p->password());
+
+ mReloadConfig->loadSettings(res);
+ mSaveConfig->loadSettings(res);
+ }
+}
+
+void ResourceCalDavConfig::saveSettings( KRES::Resource *resource ) {
+ ResourceCalDav* res = getCalDavResource(resource);
+ if (NULL != res) {
+ mReloadConfig->saveSettings(res);
+ mSaveConfig->saveSettings(res);
+
+ CalDavPrefs* p = getPrefs(res);
+ if (NULL != p) {
+ p->setUrl(mUrl->text());
+ p->setUsername(mUsername->text());
+ p->setRememberPassword(mRememberPassword->isChecked());
+ p->setPassword(mPassword->text());
+ }
+ }
+}
+
+void ResourceCalDavConfig::setupUI() {
+ QVBoxLayout *vertical = new QVBoxLayout(this);
+
+ QGridLayout *mainLayout = new QGridLayout( this );
+
+ // URL
+ QLabel *label = new QLabel( i18n( "URL:" ), this );
+ mUrl = new QLineEdit( this );
+ mainLayout->addWidget( label, 1, 0 );
+ mainLayout->addWidget( mUrl, 1, 1 );
+
+ // Username
+ label = new QLabel( i18n( "Username:" ), this );
+ mUsername = new QLineEdit( this );
+ mainLayout->addWidget( label, 2, 0 );
+ mainLayout->addWidget( mUsername, 2, 1 );
+
+ // Password
+ label = new QLabel( i18n( "Password:" ), this );
+ mPassword = new QLineEdit( this );
+ mPassword->setEchoMode( QLineEdit::Password );
+ mainLayout->addWidget( label, 3, 0 );
+ mainLayout->addWidget( mPassword, 3, 1 );
+
+ // Remember password checkbox
+ mRememberPassword = new QCheckBox( i18n("Remember password"), this );
+ mainLayout->addWidget(mRememberPassword, 4, 1);
+
+ // configs
+ QHBoxLayout* horizontal = new QHBoxLayout(this);
+
+ // Reload config
+ mReloadConfig = new CalDavReloadConfig(this);
+ horizontal->addWidget(mReloadConfig);
+
+ // Save config
+ mSaveConfig = new CalDavSaveConfig(this);
+ horizontal->addWidget(mSaveConfig);
+
+ // FIXME: This feature does not work; hide the UI elements for later use
+ mRememberPassword->hide();
+ label->hide();
+ mPassword->hide();
+
+ // combining layouts
+ vertical->addLayout(mainLayout);
+ vertical->addLayout(horizontal);
+}
+
+// EOF ========================================================================