~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to kresources/lib/kcal_resourcegroupwarebaseconfig.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    This file is part of kdepim.
3
 
 
4
 
    Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
5
 
    Copyright (c) 2004 Till Adam <adam@kde.org>
6
 
    Copyright (c) 2005 Reinhold Kainhofer <reinhold@kainhofer.com>
7
 
 
8
 
    This program is free software; you can redistribute it and/or modify
9
 
    it under the terms of the GNU General Public License as published by
10
 
    the Free Software Foundation; either version 2 of the License, or
11
 
    (at your option) any later version.
12
 
 
13
 
    This program is distributed in the hope that it will be useful,
14
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 
    GNU General Public License for more details.
17
 
 
18
 
    You should have received a copy of the GNU General Public License
19
 
    along with this program; if not, write to the Free Software
20
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
 
*/
22
 
 
23
 
#include "kcal_resourcegroupwarebaseconfig.h"
24
 
 
25
 
#include "kcal_cachesettingsdlg.h"
26
 
#include "kcal_resourcegroupwarebase.h"
27
 
#include "kresources_groupwareprefs.h"
28
 
#include "folderconfig.h"
29
 
 
30
 
#include <kcal/resourcecachedconfig.h>
31
 
 
32
 
#include <klocale.h>
33
 
#include <kdebug.h>
34
 
#include <klineedit.h>
35
 
#include <kdialog.h>
36
 
#include <kpushbutton.h>
37
 
 
38
 
#include <QLabel>
39
 
#include <QLayout>
40
 
#include <khbox.h>
41
 
//Added by qt3to4:
42
 
#include <QGridLayout>
43
 
 
44
 
 
45
 
using namespace KCal;
46
 
 
47
 
ResourceGroupwareBaseConfig::ResourceGroupwareBaseConfig( QWidget* parent,
48
 
                                                          const char* name )
49
 
    : KRES::ConfigWidget( parent)
50
 
{
51
 
  setObjectName(name);
52
 
  resize( 245, 115 );
53
 
 
54
 
  QGridLayout *mainLayout = new QGridLayout( this );
55
 
  mainLayout->setSpacing( KDialog::spacingHint() );
56
 
 
57
 
  QLabel *label = new QLabel( i18n("URL:"), this );
58
 
  mainLayout->addWidget( label, 1, 0 );
59
 
  mUrl = new KLineEdit( this );
60
 
  mainLayout->addWidget( mUrl, 1, 1 );
61
 
 
62
 
  label = new QLabel( i18n("User:"), this );
63
 
  mainLayout->addWidget( label, 2, 0 );
64
 
  mUserEdit = new KLineEdit( this );
65
 
  mainLayout->addWidget( mUserEdit, 2, 1 );
66
 
 
67
 
  label = new QLabel( i18n("Password:"), this );
68
 
  mainLayout->addWidget( label, 3, 0 );
69
 
  mPasswordEdit = new KLineEdit( this );
70
 
  mainLayout->addWidget( mPasswordEdit, 3, 1 );
71
 
  mPasswordEdit->setEchoMode( KLineEdit::Password );
72
 
 
73
 
  mFolderConfig = new KPIM::FolderConfig( this );
74
 
  connect( mFolderConfig, SIGNAL( updateFoldersClicked() ),
75
 
    SLOT( updateFolders() ) );
76
 
  mainLayout->addWidget( mFolderConfig, 4, 0, 1, 2 );
77
 
 
78
 
  KHBox *hBox = new KHBox( this );
79
 
  mCacheSettingsButton = new KPushButton( i18n("Configure Cache Settings..."), hBox );
80
 
  mainLayout->addWidget( hBox, 5, 0, 1, 2 );
81
 
  connect( mCacheSettingsButton, SIGNAL( clicked() ),
82
 
           SLOT( showCacheSettings() ) );
83
 
 
84
 
  mCacheDialog = new CacheSettingsDialog( this );
85
 
}
86
 
 
87
 
void ResourceGroupwareBaseConfig::loadSettings( KRES::Resource *resource )
88
 
{
89
 
  kDebug(7000) <<"KCal::ResourceGroupwareBaseConfig::loadSettings()";
90
 
 
91
 
  ResourceGroupwareBase *res = static_cast<ResourceGroupwareBase *>( resource );
92
 
  if ( res ) {
93
 
    if ( !res->prefs() ) {
94
 
      kError() <<"No PREF";
95
 
      return;
96
 
    }
97
 
 
98
 
    mUrl->setText( res->prefs()->url() );
99
 
    mUserEdit->setText( res->prefs()->user() );
100
 
    mPasswordEdit->setText( res->prefs()->password() );
101
 
    if ( mCacheDialog ) mCacheDialog->loadSettings( res );
102
 
 
103
 
    mFolderConfig->setFolderLister( res->folderLister() );
104
 
    mFolderConfig->updateFolderList();
105
 
  } else {
106
 
    kError(5700) <<"KCalResourceGroupwareBaseConfig::loadSettings():"
107
 
                     "no KCalOpenGroupware, cast failed";
108
 
  }
109
 
}
110
 
 
111
 
void ResourceGroupwareBaseConfig::saveSettings( KRES::Resource *resource )
112
 
{
113
 
  ResourceGroupwareBase *res = static_cast<ResourceGroupwareBase*>( resource );
114
 
  if ( res ) {
115
 
    res->prefs()->setUrl( mUrl->text() );
116
 
    res->prefs()->setUser( mUserEdit->text() );
117
 
    res->prefs()->setPassword( mPasswordEdit->text() );
118
 
    if ( mCacheDialog ) mCacheDialog->saveSettings( res );
119
 
    mFolderConfig->saveSettings();
120
 
  } else {
121
 
    kError(5700) <<"KCalResourceGroupwareBaseConfig::saveSettings():"
122
 
                     "no KCalOpenGroupware, cast failed";
123
 
  }
124
 
}
125
 
 
126
 
void ResourceGroupwareBaseConfig::updateFolders()
127
 
{
128
 
  KUrl url = mUrl->text();
129
 
  url.setUser( mUserEdit->text() );
130
 
  url.setPass( mPasswordEdit->text() );
131
 
 
132
 
  mFolderConfig->retrieveFolderList( url );
133
 
}
134
 
 
135
 
void ResourceGroupwareBaseConfig::showCacheSettings()
136
 
{
137
 
  if ( mCacheDialog ) mCacheDialog->exec();
138
 
}
139
 
 
140
 
#include "kcal_resourcegroupwarebaseconfig.moc"