summaryrefslogtreecommitdiffstats
path: root/kresources/carddav/config.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-05-31 07:49:08 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-05-31 07:49:08 +0000
commit7ef3b0e2a5e5bc9bf928e989e4f66932be096824 (patch)
treed1b924b843f78b9d9de26becb36bb8e12f7fef44 /kresources/carddav/config.cpp
parentf4a40d0495ff26b8767cf321fa8039e5ac633c12 (diff)
downloadtdepim-7ef3b0e2a5e5bc9bf928e989e4f66932be096824.tar.gz
tdepim-7ef3b0e2a5e5bc9bf928e989e4f66932be096824.zip
Added new carddav resource for kaddressbook
Lots of bugfixes for korganizer caldav resource git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1132701 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kresources/carddav/config.cpp')
-rw-r--r--kresources/carddav/config.cpp161
1 files changed, 161 insertions, 0 deletions
diff --git a/kresources/carddav/config.cpp b/kresources/carddav/config.cpp
new file mode 100644
index 000000000..8408184cc
--- /dev/null
+++ b/kresources/carddav/config.cpp
@@ -0,0 +1,161 @@
+/*=========================================================================
+| KCardDAV
+|--------------------------------------------------------------------------
+| (c) 2010 Timothy Pearson
+|
+| 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 KABC;
+
+/*=========================================================================
+| CONSTANTS
+ ========================================================================*/
+
+/*=========================================================================
+| STATIC METHODS
+ ========================================================================*/
+
+ResourceCardDav* ResourceCardDavConfig::getCardDavResource(KRES::Resource* resource) {
+ ResourceCardDav *res = dynamic_cast<ResourceCardDav *>( resource );
+ if (!res) {
+ kdDebug() << "invalid resource type";
+ }
+
+ return res;
+}
+
+CardDavPrefs* ResourceCardDavConfig::getPrefs(ResourceCardDav* res) {
+ CardDavPrefs* p = NULL;
+
+ if (res) {
+ p = res->prefs();
+ if (!p) {
+ kdDebug() << "CardDAV: res->prefs() returned NULL";
+ }
+ }
+
+ return p;
+}
+
+/*=========================================================================
+| CONSTRUCTOR / DESTRUCTOR
+ ========================================================================*/
+
+ResourceCardDavConfig::ResourceCardDavConfig( QWidget *parent )
+ : KRES::ConfigWidget( parent )
+{
+ setupUI();
+}
+
+/*=========================================================================
+| METHODS
+ ========================================================================*/
+
+void ResourceCardDavConfig::loadSettings( KRES::Resource *resource ) {
+ ResourceCardDav* res = getCardDavResource(resource);
+ CardDavPrefs* 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 ResourceCardDavConfig::saveSettings( KRES::Resource *resource ) {
+ ResourceCardDav* res = getCardDavResource(resource);
+ if (NULL != res) {
+ mReloadConfig->saveSettings(res);
+ mSaveConfig->saveSettings(res);
+
+ CardDavPrefs* p = getPrefs(res);
+ if (NULL != p) {
+ p->setUrl(mUrl->text());
+ p->setUsername(mUsername->text());
+ p->setRememberPassword(mRememberPassword->isChecked());
+ p->setPassword(mPassword->text());
+ }
+ }
+}
+
+void ResourceCardDavConfig::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 CardDavReloadConfig(this);
+ horizontal->addWidget(mReloadConfig);
+
+ // Save config
+ mSaveConfig = new CardDavSaveConfig(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 ========================================================================