summaryrefslogtreecommitdiffabout
path: root/microkde/kresources
authorulf69 <ulf69>2004-08-04 22:45:22 (UTC)
committer ulf69 <ulf69>2004-08-04 22:45:22 (UTC)
commitc3a704f5acda9cf9fee66e5c0b1b864f3b7dd852 (patch) (unidiff)
treedc59744a6d59ba241e793ce051da485d0bf16d06 /microkde/kresources
parentb83866e08ddcc5cb2734801977927f48b53a2e1c (diff)
downloadkdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.zip
kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.tar.gz
kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.tar.bz2
final changes for addressbook sync config dialog
Diffstat (limited to 'microkde/kresources') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/configdialog.cpp78
-rw-r--r--microkde/kresources/configdialog.h4
-rw-r--r--microkde/kresources/configpage.cpp15
-rw-r--r--microkde/kresources/factory.cpp4
-rw-r--r--microkde/kresources/factory.h5
-rw-r--r--microkde/kresources/resource.h8
-rw-r--r--microkde/kresources/syncwidget.h10
7 files changed, 97 insertions, 27 deletions
diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp
index 90febca..f8240f9 100644
--- a/microkde/kresources/configdialog.cpp
+++ b/microkde/kresources/configdialog.cpp
@@ -1,195 +1,241 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#include <klocale.h> 24#include <klocale.h>
25#include <kglobal.h> 25#include <kglobal.h>
26#include <kmessagebox.h> 26#include <kmessagebox.h>
27 27
28#include <qgroupbox.h> 28#include <qgroupbox.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qlayout.h> 30#include <qlayout.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qvbox.h>
32 33
33#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qscrollview.h>
34 36
35#include <kbuttonbox.h> 37#include <kbuttonbox.h>
36#include <kdialog.h> 38#include <kdialog.h>
37#include <klineedit.h> 39#include <klineedit.h>
38 40
39#include "factory.h" 41#include "factory.h"
40#include "configwidget.h" 42#include "configwidget.h"
41#include "configdialog.h" 43#include "configdialog.h"
42#include "syncwidget.h" 44#include "syncwidget.h"
43 45
44using namespace KRES; 46using namespace KRES;
45 47
46ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, 48ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
47 Resource* resource, const char *name ) 49 Resource* resource, const char *name )
48 : KDialogBase( parent, name, true, resource->isSyncable()?i18n( "Sync Profile Configuration" ):i18n( "Resource Configuration" ), 50 : KDialogBase( parent, name, true, resource->isSyncable()?i18n( "Sync Profile Configuration" ):i18n( "Resource Configuration" ),
49 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget(0), mResource( resource ), mPersistentReadOnly(false) 51 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget_Settings(0), mSyncWidget_Conflicts(0),mSyncWidget_Remote(0), mResource( resource ), mPersistentReadOnly(false)
50{ 52{
51 53
52 Factory *factory = Factory::self( resourceFamily ); 54 Factory *factory = Factory::self( resourceFamily );
53 55
54//US resize( 250, 240 ); 56//US resize( 250, 240 );
55 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); 57 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240));
56 58
57//US QFrame *main = makeMainWidget(); 59 QFrame *main;
58 QFrame *main = plainPage(); 60
61 if (!mResource->isSyncable())
62 main = plainPage();
63 else
64 main = addPage("Profile");
59 65
60 QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); 66 QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() );
61 67
68
62 QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 69 QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
63 generalGroupBox->layout()->setSpacing( spacingHint() ); 70 generalGroupBox->layout()->setSpacing( spacingHint() );
64 generalGroupBox->setTitle( i18n( "General Settings" ) ); 71 generalGroupBox->setTitle( i18n( "General Settings" ) );
65 72
66 new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox ); 73 new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox );
67 74
68 mName = new KLineEdit( generalGroupBox ); 75 mName = new KLineEdit( generalGroupBox );
69 76
70 if (!mResource->isSyncable()) { 77 if (!mResource->isSyncable()) {
71 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); 78 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox );
72 mReadOnly->setChecked( mResource->readOnly() ); 79 mReadOnly->setChecked( mResource->readOnly() );
73 } 80 }
74 81
75 mName->setText( mResource->resourceName() ); 82 mName->setText( mResource->resourceName() );
76 83
77 mainLayout->addWidget( generalGroupBox ); 84 mainLayout->addWidget( generalGroupBox );
78 85
79 QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 86 QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
80 resourceGroupBox->layout()->setSpacing( spacingHint()); 87 resourceGroupBox->layout()->setSpacing( spacingHint());
81 resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) 88 resourceGroupBox->setTitle( i18n( "%1 Resource Settings" )
82 .arg( factory->typeName( resource->type() ) ) ); 89 .arg( factory->typeName( resource->type() ) ) );
83 mainLayout->addWidget( resourceGroupBox ); 90 mainLayout->addWidget( resourceGroupBox );
84 91
85 mainLayout->addStretch(); 92 mainLayout->addStretch();
86 93
87 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); 94 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox );
88 if ( mConfigWidget ) { 95 if ( mConfigWidget ) {
89 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), 96 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ),
90 SLOT( setReadOnly( bool ) ) ); 97 SLOT( setReadOnly( bool ) ) );
91 connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), 98 connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ),
92 SLOT( setPersistentReadOnly( bool ) ) ); 99 SLOT( setPersistentReadOnly( bool ) ) );
93 mConfigWidget->setInEditMode( false ); 100 mConfigWidget->setInEditMode( false );
94 mConfigWidget->loadSettings( mResource ); 101 mConfigWidget->loadSettings( mResource );
95 mConfigWidget->show(); 102 mConfigWidget->show();
96 103
97 } 104 }
98 105
99 if (mResource->isSyncable()) 106 if (mResource->isSyncable())
100 { 107 {
101 QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 108 SyncWidgetContainer* c = factory->syncWidgetContainer( resource->type() );
102 syncGroupBox->layout()->setSpacing( spacingHint()); 109
103 syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) ); 110 QFrame* syncPage = addPage("Settings");
104 mainLayout->addWidget( syncGroupBox ); 111 QVBoxLayout *syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() );
112 mSyncWidget_Settings = c->generateSettingsTab(syncPage);
113 syncLayout->addWidget( mSyncWidget_Settings );
114
115 syncPage = addPage("Conflicts");
116 syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() );
117 mSyncWidget_Conflicts = c->generateConflictsTab(syncPage);
118 syncLayout->addWidget( mSyncWidget_Conflicts );
119
120 syncPage = addPage("Remote");
121 syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() );
122 mSyncWidget_Remote = c->generateRemoteTab(syncPage);
123 syncLayout->addWidget( mSyncWidget_Remote );
124
105 125
106 mainLayout->addStretch(); 126 mSyncWidget_Settings->setInEditMode( false );
127 mSyncWidget_Settings->loadSettings( mResource );
128 mSyncWidget_Settings->show();
107 129
108 mSyncWidget = factory->syncWidget( resource->type(), syncGroupBox ); 130 mSyncWidget_Conflicts->setInEditMode( false );
131 mSyncWidget_Conflicts->loadSettings( mResource );
132 mSyncWidget_Conflicts->show();
133
134 mSyncWidget_Remote->setInEditMode( false );
135 mSyncWidget_Remote->loadSettings( mResource );
136 mSyncWidget_Remote->show();
137
138 delete c;
139
140// QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, syncPage );
141// syncGroupBox->layout()->setSpacing( spacingHint());
142// syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) );
143// syncLayout->addWidget( syncGroupBox );
144
145// syncLayout->addStretch();
146/*US
147 mSyncWidget = factory->syncWidget( resource->type(), syncPage );
148 syncLayout->addWidget( mSyncWidget );
109 if ( mSyncWidget ) { 149 if ( mSyncWidget ) {
110 mSyncWidget->setInEditMode( false ); 150 mSyncWidget->setInEditMode( false );
111 mSyncWidget->loadSettings( mResource ); 151 mSyncWidget->loadSettings( mResource );
112 mSyncWidget->show(); 152 mSyncWidget->show();
113 } 153 }
154 */
114 } 155 }
115 156
116 157
117 158
118 159
119 connect( mName, SIGNAL( textChanged(const QString &)), 160 connect( mName, SIGNAL( textChanged(const QString &)),
120 SLOT( slotNameChanged(const QString &))); 161 SLOT( slotNameChanged(const QString &)));
121 162
122 slotNameChanged( mName->text() ); 163 slotNameChanged( mName->text() );
123 164
124//US setMinimumSize( 400, 250 ); 165//US setMinimumSize( 400, 250 );
125 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); 166 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250));
126 167
127} 168}
128 169
129void ConfigDialog::setInEditMode( bool value ) 170void ConfigDialog::setInEditMode( bool value )
130{ 171{
131 if ( mConfigWidget ) 172 if ( mConfigWidget )
132 mConfigWidget->setInEditMode( value ); 173 mConfigWidget->setInEditMode( value );
133 174
134 if ( mSyncWidget ) 175 if ( mSyncWidget_Settings )
135 mSyncWidget->setInEditMode( value ); 176 mSyncWidget_Settings->setInEditMode( value );
177 if ( mSyncWidget_Conflicts )
178 mSyncWidget_Conflicts->setInEditMode( value );
179 if ( mSyncWidget_Remote )
180 mSyncWidget_Remote->setInEditMode( value );
136 181
137} 182}
138 183
139void ConfigDialog::slotNameChanged( const QString &text) 184void ConfigDialog::slotNameChanged( const QString &text)
140{ 185{
141 enableButtonOK( !text.isEmpty() ); 186 enableButtonOK( !text.isEmpty() );
142} 187}
143 188
144void ConfigDialog::setReadOnly( bool value ) 189void ConfigDialog::setReadOnly( bool value )
145{ 190{
146 if (!mResource->isSyncable()) { 191 if (!mResource->isSyncable()) {
147 192
148 if (mPersistentReadOnly == false) 193 if (mPersistentReadOnly == false)
149 mReadOnly->setChecked( value ); 194 mReadOnly->setChecked( value );
150 else 195 else
151 mReadOnly->setChecked( true ); 196 mReadOnly->setChecked( true );
152 } 197 }
153} 198}
154 199
155void ConfigDialog::setPersistentReadOnly( bool value ) 200void ConfigDialog::setPersistentReadOnly( bool value )
156{ 201{
157 if (!mResource->isSyncable()) { 202 if (!mResource->isSyncable()) {
158 203
159 mPersistentReadOnly = value; 204 mPersistentReadOnly = value;
160 205
161 if (value == true) 206 if (value == true)
162 setReadOnly( true ); 207 setReadOnly( true );
163 208
164 mReadOnly->setEnabled( !value ); 209 mReadOnly->setEnabled( !value );
165 } 210 }
166} 211}
167 212
168void ConfigDialog::accept() 213void ConfigDialog::accept()
169{ 214{
170 if ( mName->text().isEmpty() ) { 215 if ( mName->text().isEmpty() ) {
171 KMessageBox::sorry( this, mResource->isSyncable()?i18n( "Please enter a profile name" ):i18n( "Please enter a resource name" ) ); 216 KMessageBox::sorry( this, mResource->isSyncable()?i18n( "Please enter a profile name" ):i18n( "Please enter a resource name" ) );
172 return; 217 return;
173 } 218 }
174 219
175 mResource->setResourceName( mName->text() ); 220 mResource->setResourceName( mName->text() );
176 if (!mResource->isSyncable()) 221 if (!mResource->isSyncable())
177 mResource->setReadOnly( mReadOnly->isChecked() ); 222 mResource->setReadOnly( mReadOnly->isChecked() );
178 223
179 if ( mConfigWidget ) { 224 if ( mConfigWidget ) {
180 // First save generic information 225 // First save generic information
181 // Also save setting of specific resource type 226 // Also save setting of specific resource type
182 mConfigWidget->saveSettings( mResource ); 227 mConfigWidget->saveSettings( mResource );
183 } 228 }
184 229
185 if ( mSyncWidget ) { 230 if ( mSyncWidget_Settings )
186 // First save generic information 231 mSyncWidget_Settings->saveSettings( mResource );
187 // Also save setting of specific resource type 232 if ( mSyncWidget_Conflicts )
188 mSyncWidget->saveSettings( mResource ); 233 mSyncWidget_Conflicts->saveSettings( mResource );
189 } 234 if ( mSyncWidget_Remote )
235 mSyncWidget_Remote->saveSettings( mResource );
190 236
191 237
192 KDialog::accept(); 238 KDialog::accept();
193} 239}
194 240
195//US #include "configdialog.moc" 241//US #include "configdialog.moc"
diff --git a/microkde/kresources/configdialog.h b/microkde/kresources/configdialog.h
index b629347..63cd4e9 100644
--- a/microkde/kresources/configdialog.h
+++ b/microkde/kresources/configdialog.h
@@ -1,65 +1,67 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 4 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef KRESOURCES_CONFIGDIALOG_H 22#ifndef KRESOURCES_CONFIGDIALOG_H
23#define KRESOURCES_CONFIGDIALOG_H 23#define KRESOURCES_CONFIGDIALOG_H
24 24
25#include <kdialogbase.h> 25#include <kdialogbase.h>
26 26
27class KLineEdit; 27class KLineEdit;
28class QCheckBox; 28class QCheckBox;
29class KButtonBox; 29class KButtonBox;
30 30
31namespace KRES { 31namespace KRES {
32 class Resource; 32 class Resource;
33 class ConfigWidget; 33 class ConfigWidget;
34 class SyncWidget; 34 class SyncWidget;
35 35
36class ConfigDialog : public KDialogBase 36class ConfigDialog : public KDialogBase
37{ 37{
38 Q_OBJECT 38 Q_OBJECT
39 public: 39 public:
40 // Resource=0: create new resource 40 // Resource=0: create new resource
41 ConfigDialog( QWidget *parent, const QString& resourceFamily, 41 ConfigDialog( QWidget *parent, const QString& resourceFamily,
42 Resource* resource, const char *name = 0); 42 Resource* resource, const char *name = 0);
43 43
44 void setInEditMode( bool value ); 44 void setInEditMode( bool value );
45 45
46 protected slots: 46 protected slots:
47 void accept(); 47 void accept();
48 void setReadOnly( bool value ); 48 void setReadOnly( bool value );
49 void setPersistentReadOnly( bool value ); 49 void setPersistentReadOnly( bool value );
50 void slotNameChanged( const QString &text); 50 void slotNameChanged( const QString &text);
51 51
52 private: 52 private:
53 ConfigWidget *mConfigWidget; 53 ConfigWidget *mConfigWidget;
54 SyncWidget *mSyncWidget; 54 SyncWidget *mSyncWidget_Settings;
55 SyncWidget *mSyncWidget_Conflicts;
56 SyncWidget *mSyncWidget_Remote;
55 Resource* mResource; 57 Resource* mResource;
56 58
57 KLineEdit *mName; 59 KLineEdit *mName;
58 QCheckBox *mReadOnly; 60 QCheckBox *mReadOnly;
59//US add a persistent readonly flag. We need that for opie and qtopia addressbooks. 61//US add a persistent readonly flag. We need that for opie and qtopia addressbooks.
60 bool mPersistentReadOnly; 62 bool mPersistentReadOnly;
61}; 63};
62 64
63} 65}
64 66
65#endif 67#endif
diff --git a/microkde/kresources/configpage.cpp b/microkde/kresources/configpage.cpp
index 2fe021d..1a3a22c 100644
--- a/microkde/kresources/configpage.cpp
+++ b/microkde/kresources/configpage.cpp
@@ -112,322 +112,331 @@ ConfigPage::ConfigPage( QWidget *parent, const char *name )
112 mListView->setAllColumnsShowFocus( true ); 112 mListView->setAllColumnsShowFocus( true );
113 mListView->addColumn( i18n( "Name" ) ); 113 mListView->addColumn( i18n( "Name" ) );
114 mListView->addColumn( i18n( "Type" ) ); 114 mListView->addColumn( i18n( "Type" ) );
115 mListView->addColumn( i18n( "Standard" ) ); 115 mListView->addColumn( i18n( "Standard" ) );
116 116
117//US groupBoxLayout->addWidget( mListView, 1, 0 ); 117//US groupBoxLayout->addWidget( mListView, 1, 0 );
118 groupBoxLayout->addMultiCellWidget( mListView, 1, 1, 0, 1 ); 118 groupBoxLayout->addMultiCellWidget( mListView, 1, 1, 0, 1 );
119 119
120 120
121 mAddButton = new QPushButton( i18n( "&Add..." ), this ); 121 mAddButton = new QPushButton( i18n( "&Add..." ), this );
122 groupBoxLayout->addWidget( mAddButton, 2, 0 ); 122 groupBoxLayout->addWidget( mAddButton, 2, 0 );
123 mRemoveButton = new QPushButton( i18n( "&Remove" ), this ); 123 mRemoveButton = new QPushButton( i18n( "&Remove" ), this );
124 groupBoxLayout->addWidget( mRemoveButton, 2, 1 ); 124 groupBoxLayout->addWidget( mRemoveButton, 2, 1 );
125 mEditButton = new QPushButton( i18n( "&Edit..." ), this ); 125 mEditButton = new QPushButton( i18n( "&Edit..." ), this );
126 groupBoxLayout->addWidget( mEditButton, 3, 0 ); 126 groupBoxLayout->addWidget( mEditButton, 3, 0 );
127 mStandardButton = new QPushButton( i18n( "&Use as Standard" ), this ); 127 mStandardButton = new QPushButton( i18n( "&Use as Standard" ), this );
128 groupBoxLayout->addWidget( mStandardButton, 3, 1 ); 128 groupBoxLayout->addWidget( mStandardButton, 3, 1 );
129 129
130 mRemoveButton->setEnabled( false ); 130 mRemoveButton->setEnabled( false );
131 mEditButton->setEnabled( false ); 131 mEditButton->setEnabled( false );
132 mStandardButton->setEnabled( false ); 132 mStandardButton->setEnabled( false );
133 133
134 134
135 connect( mAddButton, SIGNAL( clicked() ), SLOT(slotAdd()) ); 135 connect( mAddButton, SIGNAL( clicked() ), SLOT(slotAdd()) );
136 connect( mRemoveButton, SIGNAL( clicked() ), SLOT(slotRemove()) ); 136 connect( mRemoveButton, SIGNAL( clicked() ), SLOT(slotRemove()) );
137 connect( mEditButton, SIGNAL( clicked() ), SLOT(slotEdit()) ); 137 connect( mEditButton, SIGNAL( clicked() ), SLOT(slotEdit()) );
138 connect( mStandardButton, SIGNAL( clicked() ), SLOT(slotStandard()) ); 138 connect( mStandardButton, SIGNAL( clicked() ), SLOT(slotStandard()) );
139 139
140 140
141 mainLayout->addWidget( groupBox ); 141 mainLayout->addWidget( groupBox );
142 142
143 connect( mFamilyCombo, SIGNAL( activated( int ) ), 143 connect( mFamilyCombo, SIGNAL( activated( int ) ),
144 SLOT( slotFamilyChanged( int ) ) ); 144 SLOT( slotFamilyChanged( int ) ) );
145 connect( mListView, SIGNAL( selectionChanged() ), 145 connect( mListView, SIGNAL( selectionChanged() ),
146 SLOT( slotSelectionChanged() ) ); 146 SLOT( slotSelectionChanged() ) );
147 connect( mListView, SIGNAL( clicked( QListViewItem * ) ), 147 connect( mListView, SIGNAL( clicked( QListViewItem * ) ),
148 SLOT( slotItemClicked( QListViewItem * ) ) ); 148 SLOT( slotItemClicked( QListViewItem * ) ) );
149 149
150 mLastItem = 0; 150 mLastItem = 0;
151 151
152//US mConfig = new KConfig( "kcmkresourcesrc" ); 152//US mConfig = new KConfig( "kcmkresourcesrc" );
153 mConfig = new KConfig( locateLocal( "config", "kcmkresourcesrc") ); 153 mConfig = new KConfig( locateLocal( "config", "kcmkresourcesrc") );
154 mConfig->setGroup( "General" ); 154 mConfig->setGroup( "General" );
155 155
156 load(); 156 load();
157} 157}
158 158
159ConfigPage::~ConfigPage() 159ConfigPage::~ConfigPage()
160{ 160{
161 QValueList<ResourcePageInfo>::Iterator it; 161 QValueList<ResourcePageInfo>::Iterator it;
162 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) { 162 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) {
163 (*it).mManager->removeListener( this ); 163 (*it).mManager->removeListener( this );
164 delete (*it).mManager; 164 delete (*it).mManager;
165 delete (*it).mConfig; 165 delete (*it).mConfig;
166 } 166 }
167 167
168 mConfig->writeEntry( "CurrentFamily", mFamilyCombo->currentItem() ); 168 mConfig->writeEntry( "CurrentFamily", mFamilyCombo->currentItem() );
169 delete mConfig; 169 delete mConfig;
170 mConfig = 0; 170 mConfig = 0;
171} 171}
172 172
173void ConfigPage::load() 173void ConfigPage::load()
174{ 174{
175 kdDebug(5650) << "ConfigPage::load()" << endl; 175 kdDebug(5650) << "ConfigPage::load()" << endl;
176 176
177 mListView->clear(); 177 mListView->clear();
178 178
179//US we remove the dynamic pluginloader, and set the one family we need (contact) manually. 179//US we remove the dynamic pluginloader, and set the one family we need (contact) manually.
180 180
181//US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" ); 181//US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" );
182//US KTrader::OfferList::ConstIterator it; 182//US KTrader::OfferList::ConstIterator it;
183//US for ( it = plugins.begin(); it != plugins.end(); ++it ) { 183//US for ( it = plugins.begin(); it != plugins.end(); ++it ) {
184//US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" ); 184//US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" );
185//US QString family = tmp.toString(); 185//US QString family = tmp.toString();
186 QStringList families; 186 QStringList families;
187 families << "contact" << syncfamily; 187 families << "contact" << syncfamily;
188 188
189 189
190 for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) 190 for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it )
191 { 191 {
192 QString family = (*it); 192 QString family = (*it);
193 if ( !family.isEmpty() ) { 193 if ( !family.isEmpty() ) {
194 if ( !mFamilyMap.contains( family ) ) { 194 if ( !mFamilyMap.contains( family ) ) {
195 mCurrentManager = new Manager<Resource>( family, (family == syncfamily) ); 195 mCurrentManager = new Manager<Resource>( family, (family == syncfamily) );
196 if ( mCurrentManager ) { 196 if ( mCurrentManager ) {
197 mFamilyMap.append( family ); 197 mFamilyMap.append( family );
198 mCurrentManager->addListener( this ); 198 mCurrentManager->addListener( this );
199 199
200 ResourcePageInfo info; 200 ResourcePageInfo info;
201 info.mManager = mCurrentManager; 201 info.mManager = mCurrentManager;
202 QString configDir = KGlobal::dirs()->saveLocation( "config" ); 202 QString configDir = KGlobal::dirs()->saveLocation( "config" );
203 //QString configDir = KStandardDirs::appDir() + "/config"; 203 //QString configDir = KStandardDirs::appDir() + "/config";
204 if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) { 204 if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) {
205 info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) ); 205 info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) );
206 } else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) { 206 } else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) {
207 info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) ); 207 info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) );
208 } else if ( family == syncfamily && QFile::exists( configDir + "/kabcsyncrc" ) ) {
209 info.mConfig = new KConfig( locateLocal( "config", "kabcsyncrc" ) );
208 } else { 210 } else {
209 QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) ); 211 QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) );
210 info.mConfig = new KConfig( configFile ); 212 info.mConfig = new KConfig( configFile );
211 } 213 }
212 info.mManager->readConfig( info.mConfig ); 214 info.mManager->readConfig( info.mConfig );
213 215
214 mInfoMap.append( info ); 216 mInfoMap.append( info );
215 } 217 }
216 } 218 }
217 } 219 }
218 } 220 }
219 mCurrentManager = 0; 221 mCurrentManager = 0;
220 222
221 mFamilyCombo->insertStringList( mFamilyMap ); 223 mFamilyCombo->insertStringList( mFamilyMap );
222 224
223 int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 ); 225 int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 );
224 mFamilyCombo->setCurrentItem( currentFamily ); 226 mFamilyCombo->setCurrentItem( currentFamily );
225 slotFamilyChanged( currentFamily ); 227 slotFamilyChanged( currentFamily );
226} 228}
227 229
228void ConfigPage::save() 230void ConfigPage::save()
229{ 231{
230 saveResourceSettings(); 232 saveResourceSettings();
231 233
232 QValueList<ResourcePageInfo>::Iterator it; 234 QValueList<ResourcePageInfo>::Iterator it;
233 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) 235 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it )
234 (*it).mManager->writeConfig( (*it).mConfig ); 236 (*it).mManager->writeConfig( (*it).mConfig );
235 237
236 emit changed( false ); 238 emit changed( false );
237} 239}
238 240
239void ConfigPage::defaults() 241void ConfigPage::defaults()
240{ 242{
241} 243}
242 244
243void ConfigPage::slotFamilyChanged( int pos ) 245void ConfigPage::slotFamilyChanged( int pos )
244{ 246{
245 if ( pos < 0 || pos >= (int)mFamilyMap.count() ) 247 if ( pos < 0 || pos >= (int)mFamilyMap.count() )
246 return; 248 return;
247 249
248 saveResourceSettings(); 250 saveResourceSettings();
249 251
250 mFamily = mFamilyMap[ pos ]; 252 mFamily = mFamilyMap[ pos ];
251 253
252//US qDebug("ConfigPage::slotFamilyChanged 4 family=%s", mFamily.latin1()); 254//US qDebug("ConfigPage::slotFamilyChanged 4 family=%s", mFamily.latin1());
253 255
254 mCurrentManager = mInfoMap[ pos ].mManager; 256 mCurrentManager = mInfoMap[ pos ].mManager;
255 mCurrentConfig = mInfoMap[ pos ].mConfig; 257 mCurrentConfig = mInfoMap[ pos ].mConfig;
256 258
257 if ( !mCurrentManager ) 259 if ( !mCurrentManager )
258 kdDebug(5650) << "ERROR: cannot create ResourceManager<Resource>( mFamily )" << endl; 260 kdDebug(5650) << "ERROR: cannot create ResourceManager<Resource>( mFamily )" << endl;
259 261
260 mListView->clear(); 262 mListView->clear();
261 263
262 if ( mCurrentManager->isEmpty() ) { 264 if ( mCurrentManager->isEmpty() ) {
263//US qDebug("ConfigPage::slotFamilyChanged 4.1 mCurrentManager=%ul", mCurrentManager ); 265//US qDebug("ConfigPage::slotFamilyChanged 4.1 mCurrentManager=%ul", mCurrentManager );
264 266
265 defaults(); 267 defaults();
266 } 268 }
267 269
268 Resource *standardResource = mCurrentManager->standardResource(); 270 Resource *standardResource = mCurrentManager->standardResource();
269 271
270//US qDebug("ConfigPage::slotFamilyChanged 4.4 resourcename=%s", standardResource->resourceName().latin1()); 272//US qDebug("ConfigPage::slotFamilyChanged 4.4 resourcename=%s", standardResource->resourceName().latin1());
271 273
272 274
273 Manager<Resource>::Iterator it; 275 Manager<Resource>::Iterator it;
274 for ( it = mCurrentManager->begin(); it != mCurrentManager->end(); ++it ) { 276 for ( it = mCurrentManager->begin(); it != mCurrentManager->end(); ++it ) {
275 ConfigViewItem *item = new ConfigViewItem( mListView, *it ); 277 ConfigViewItem *item = new ConfigViewItem( mListView, *it );
276 if ( *it == standardResource ) 278 if ( *it == standardResource )
277 item->setStandard( true ); 279 item->setStandard( true );
278 } 280 }
279 281
280 if ( mListView->childCount() == 0 ) { 282 if ( mListView->childCount() == 0 ) {
281//US qDebug("ConfigPage::slotFamilyChanged 4.5 "); 283//US qDebug("ConfigPage::slotFamilyChanged 4.5 ");
282 284
283 defaults(); 285 defaults();
284 emit changed( true ); 286 emit changed( true );
285 mCurrentManager->writeConfig( mCurrentConfig ); 287 mCurrentManager->writeConfig( mCurrentConfig );
286 } else { 288 } else {
287//US qDebug("ConfigPage::slotFamilyChanged 4.6 "); 289//US qDebug("ConfigPage::slotFamilyChanged 4.6 ");
288 290
289 if ( !standardResource ) { 291 if ( !standardResource ) {
290 KMessageBox::sorry( this, i18n( "There is no standard resource!<br> Please select one." ) ); 292 KMessageBox::sorry( this, i18n( "There is no standard resource!<br> Please select one." ) );
291 293
292//US qDebug("ConfigPage::slotFamilyChanged 4.7" ); 294//US qDebug("ConfigPage::slotFamilyChanged 4.7" );
293 295
294 } 296 }
295 297
296 emit changed( false ); 298 emit changed( false );
297 } 299 }
298} 300}
299 301
300void ConfigPage::slotAdd() 302void ConfigPage::slotAdd()
301{ 303{
302 if ( !mCurrentManager ) 304 if ( !mCurrentManager )
303 return; 305 return;
304 306
305 QStringList types = mCurrentManager->resourceTypeNames(); 307 QStringList types = mCurrentManager->resourceTypeNames();
306 QStringList descs = mCurrentManager->resourceTypeDescriptions(); 308 QStringList descs = mCurrentManager->resourceTypeDescriptions();
307 bool ok = false; 309 bool ok = false;
308 310
309 QString desc; 311 QString desc;
310 312
311 if (mFamily == syncfamily) 313 if (mFamily == syncfamily)
312 { 314 {
313 desc = QInputDialog::getItem( i18n( "Sync Configuration" ), 315 desc = QInputDialog::getItem( i18n( "Sync Configuration" ),
314 i18n( "Please select resource type for new sync profile:" ), descs, 0, 316 i18n( "Select resource type for the new sync profile:" ), descs, 0,
315 false, &ok, this ); 317 false, &ok, this );
316 } 318 }
317 else 319 else
318 { 320 {
319 desc = QInputDialog::getItem( i18n( "Resource Configuration" ), 321 desc = QInputDialog::getItem( i18n( "Resource Configuration" ),
320 i18n( "Please select type of the new resource:" ), descs, 0, 322 i18n( "Select type of the new resource:" ), descs, 0,
321 false, &ok, this ); 323 false, &ok, this );
322 } 324 }
323 325
324 if ( !ok ) 326 if ( !ok )
325 return; 327 return;
326 328
327 QString type = types[ descs.findIndex( desc ) ]; 329 QString type = types[ descs.findIndex( desc ) ];
328 330
329 // Create new resource 331 // Create new resource
330 Resource *resource = mCurrentManager->createResource( type ); 332 Resource *resource = mCurrentManager->createResource( type );
331 if ( !resource ) { 333 if ( !resource ) {
332 KMessageBox::error( this, i18n("Unable to create resource of type '%1'.") 334 KMessageBox::error( this, i18n("Unable to create resource of type '%1'.")
333 .arg( type ) ); 335 .arg( type ) );
334 return; 336 return;
335 } 337 }
336 338
337 resource->setResourceName( type + "-resource" ); 339 if (mFamily == syncfamily)
340 {
341 resource->setResourceName( type + "-syncprofile" );
342 }
343 else
344 {
345 resource->setResourceName( type + "-resource" );
346 }
338 347
339 ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" ); 348 ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" );
340 349
341 if ( dlg.exec() ) { 350 if ( dlg.exec() ) {
342 mCurrentManager->add( resource ); 351 mCurrentManager->add( resource );
343 352
344 ConfigViewItem *item = new ConfigViewItem( mListView, resource ); 353 ConfigViewItem *item = new ConfigViewItem( mListView, resource );
345 354
346 mLastItem = item; 355 mLastItem = item;
347 356
348 // if there are only read-only resources we'll set this resource 357 // if there are only read-only resources we'll set this resource
349 // as standard resource 358 // as standard resource
350 if ( !resource->readOnly() ) { 359 if ( !resource->readOnly() ) {
351 bool onlyReadOnly = true; 360 bool onlyReadOnly = true;
352 QListViewItem *it = mListView->firstChild(); 361 QListViewItem *it = mListView->firstChild();
353 while ( it != 0 ) { 362 while ( it != 0 ) {
354 ConfigViewItem *confIt = static_cast<ConfigViewItem*>( it ); 363 ConfigViewItem *confIt = static_cast<ConfigViewItem*>( it );
355 if ( !confIt->readOnly() && confIt != item ) 364 if ( !confIt->readOnly() && confIt != item )
356 onlyReadOnly = false; 365 onlyReadOnly = false;
357 366
358 it = it->itemBelow(); 367 it = it->itemBelow();
359 } 368 }
360 369
361 if ( onlyReadOnly ) 370 if ( onlyReadOnly )
362 item->setStandard( true ); 371 item->setStandard( true );
363 } 372 }
364 373
365 emit changed( true ); 374 emit changed( true );
366 } else { 375 } else {
367 delete resource; 376 delete resource;
368 resource = 0; 377 resource = 0;
369 } 378 }
370} 379}
371 380
372void ConfigPage::slotRemove() 381void ConfigPage::slotRemove()
373{ 382{
374 if ( !mCurrentManager ) 383 if ( !mCurrentManager )
375 return; 384 return;
376 385
377 QListViewItem *item = mListView->currentItem(); 386 QListViewItem *item = mListView->currentItem();
378 ConfigViewItem *confItem = static_cast<ConfigViewItem*>( item ); 387 ConfigViewItem *confItem = static_cast<ConfigViewItem*>( item );
379 388
380 if ( !confItem ) 389 if ( !confItem )
381 return; 390 return;
382 391
383 if ( confItem->standard() ) { 392 if ( confItem->standard() ) {
384 KMessageBox::sorry( this, i18n( "You cannot remove your standard resource!\n Please select a new standard resource first." ) ); 393 KMessageBox::sorry( this, i18n( "You cannot remove your standard resource!\n Please select a new standard resource first." ) );
385 return; 394 return;
386 } 395 }
387 396
388 mCurrentManager->remove( confItem->resource() ); 397 mCurrentManager->remove( confItem->resource() );
389 398
390 if ( item == mLastItem ) 399 if ( item == mLastItem )
391 mLastItem = 0; 400 mLastItem = 0;
392 401
393 mListView->takeItem( item ); 402 mListView->takeItem( item );
394 delete item; 403 delete item;
395 404
396 emit changed( true ); 405 emit changed( true );
397} 406}
398 407
399void ConfigPage::slotEdit() 408void ConfigPage::slotEdit()
400{ 409{
401 if ( !mCurrentManager ) 410 if ( !mCurrentManager )
402 return; 411 return;
403 412
404 QListViewItem *item = mListView->currentItem(); 413 QListViewItem *item = mListView->currentItem();
405 ConfigViewItem *configItem = static_cast<ConfigViewItem*>( item ); 414 ConfigViewItem *configItem = static_cast<ConfigViewItem*>( item );
406 if ( !configItem ) 415 if ( !configItem )
407 return; 416 return;
408 417
409 Resource *resource = configItem->resource(); 418 Resource *resource = configItem->resource();
410 419
411 ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" ); 420 ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" );
412 421
413 if ( dlg.exec() ) { 422 if ( dlg.exec() ) {
414 configItem->setText( 0, resource->resourceName() ); 423 configItem->setText( 0, resource->resourceName() );
415 configItem->setText( 1, resource->type() ); 424 configItem->setText( 1, resource->type() );
416 425
417 if ( configItem->standard() && configItem->readOnly() ) { 426 if ( configItem->standard() && configItem->readOnly() ) {
418 KMessageBox::sorry( this, i18n( "You cannot use a read-only<br> resource as standard!" ) ); 427 KMessageBox::sorry( this, i18n( "You cannot use a read-only<br> resource as standard!" ) );
419 configItem->setStandard( false ); 428 configItem->setStandard( false );
420 } 429 }
421 430
422 mCurrentManager->resourceChanged( resource ); 431 mCurrentManager->resourceChanged( resource );
423 emit changed( true ); 432 emit changed( true );
424 } 433 }
425} 434}
426 435
427void ConfigPage::slotStandard() 436void ConfigPage::slotStandard()
428{ 437{
429 if ( !mCurrentManager ) 438 if ( !mCurrentManager )
430 return; 439 return;
431 440
432 ConfigViewItem *item = static_cast<ConfigViewItem*>( mListView->currentItem() ); 441 ConfigViewItem *item = static_cast<ConfigViewItem*>( mListView->currentItem() );
433 if ( !item ) 442 if ( !item )
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp
index 7a5c2f6..e44fce3 100644
--- a/microkde/kresources/factory.cpp
+++ b/microkde/kresources/factory.cpp
@@ -94,196 +94,196 @@ Factory::Factory( const QString& resourceFamily) :
94 info->nameLabel = i18n( "ldap" ); 94 info->nameLabel = i18n( "ldap" );
95 info->descriptionLabel = i18n( "No description available" ); 95 info->descriptionLabel = i18n( "No description available" );
96 mTypeMap.insert( "ldap", info ); 96 mTypeMap.insert( "ldap", info );
97 97
98 //US add opie plugin only, if the library exists. 98 //US add opie plugin only, if the library exists.
99 QString libname = "microkabc_opie"; 99 QString libname = "microkabc_opie";
100 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 100 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
101 if ( !path.isEmpty() ) 101 if ( !path.isEmpty() )
102 { 102 {
103 info = new PluginInfo; 103 info = new PluginInfo;
104 info->library = libname; 104 info->library = libname;
105 info->nameLabel = i18n( "opie" ); 105 info->nameLabel = i18n( "opie" );
106 info->descriptionLabel = i18n( "Opie PIM Addressbook." ); 106 info->descriptionLabel = i18n( "Opie PIM Addressbook." );
107 mTypeMap.insert( "opie", info ); 107 mTypeMap.insert( "opie", info );
108 } 108 }
109 109
110 //US add qtopia plugin only, if the library exists. 110 //US add qtopia plugin only, if the library exists.
111 libname = "microkabc_qtopia"; 111 libname = "microkabc_qtopia";
112 path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 112 path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
113 if ( !path.isEmpty() ) 113 if ( !path.isEmpty() )
114 { 114 {
115 info = new PluginInfo; 115 info = new PluginInfo;
116 info->library = libname; 116 info->library = libname;
117 info->nameLabel = i18n( "qtopia" ); 117 info->nameLabel = i18n( "qtopia" );
118 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." ); 118 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." );
119 mTypeMap.insert( "qtopia", info ); 119 mTypeMap.insert( "qtopia", info );
120 } 120 }
121 121
122 //US add sharp plugin only, if the library exists. 122 //US add sharp plugin only, if the library exists.
123 libname = "microkabc_sharpdtm"; 123 libname = "microkabc_sharpdtm";
124 path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 124 path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
125 if ( !path.isEmpty() ) 125 if ( !path.isEmpty() )
126 { 126 {
127 info = new PluginInfo; 127 info = new PluginInfo;
128 info->library = libname; 128 info->library = libname;
129 info->nameLabel = i18n( "sharp" ); 129 info->nameLabel = i18n( "sharp" );
130 info->descriptionLabel = i18n( "Sharp DTM Addressbook." ); 130 info->descriptionLabel = i18n( "Sharp DTM Addressbook." );
131 mTypeMap.insert( "sharp", info ); 131 mTypeMap.insert( "sharp", info );
132 } 132 }
133 133
134 134
135} 135}
136 136
137Factory::~Factory() 137Factory::~Factory()
138{ 138{
139} 139}
140 140
141QStringList Factory::typeNames() const 141QStringList Factory::typeNames() const
142{ 142{
143//US method QMap::keys() not available yet. SO collect the data manually 143//US method QMap::keys() not available yet. SO collect the data manually
144//US return mTypeMap.keys(); 144//US return mTypeMap.keys();
145 145
146 QStringList result; 146 QStringList result;
147 147
148 QMap<QString, PluginInfo*>::ConstIterator it; 148 QMap<QString, PluginInfo*>::ConstIterator it;
149 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) { 149 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) {
150 result << it.key().latin1(); 150 result << it.key().latin1();
151// qDebug("Factory::typeNames() : %s ", it.key().latin1()); 151// qDebug("Factory::typeNames() : %s ", it.key().latin1());
152 152
153 } 153 }
154 return result; 154 return result;
155} 155}
156 156
157ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) 157ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
158{ 158{
159 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 159 if ( type.isEmpty() || !mTypeMap.contains( type ) )
160 return 0; 160 return 0;
161 161
162//US KService::Ptr ptr = mTypeMap[ type ]; 162//US KService::Ptr ptr = mTypeMap[ type ];
163//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 163//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
164 PluginInfo* pi = mTypeMap[ type ]; 164 PluginInfo* pi = mTypeMap[ type ];
165 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 165 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
166 if ( !factory ) { 166 if ( !factory ) {
167 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1()); 167 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1());
168 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl; 168 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl;
169 return 0; 169 return 0;
170 } 170 }
171 171
172 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 172 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
173 173
174 if ( !pluginFactory ) { 174 if ( !pluginFactory ) {
175 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1()); 175 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1());
176 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl; 176 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl;
177 return 0; 177 return 0;
178 } 178 }
179 179
180 ConfigWidget *wdg = pluginFactory->configWidget( parent ); 180 ConfigWidget *wdg = pluginFactory->configWidget( parent );
181 if ( !wdg ) { 181 if ( !wdg ) {
182//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 182//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
183 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 183 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
184 return 0; 184 return 0;
185 } 185 }
186 return wdg; 186 return wdg;
187 187
188} 188}
189 189
190SyncWidget *Factory::syncWidget( const QString& type, QWidget *parent ) 190SyncWidgetContainer *Factory::syncWidgetContainer( const QString& type )
191{ 191{
192 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 192 if ( type.isEmpty() || !mTypeMap.contains( type ) )
193 return 0; 193 return 0;
194 194
195//US KService::Ptr ptr = mTypeMap[ type ]; 195//US KService::Ptr ptr = mTypeMap[ type ];
196//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 196//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
197 PluginInfo* pi = mTypeMap[ type ]; 197 PluginInfo* pi = mTypeMap[ type ];
198 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 198 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
199 if ( !factory ) { 199 if ( !factory ) {
200 qDebug("KRES::Factory::syncWidget(): Factory creation failed for library %s", pi->library.latin1()); 200 qDebug("KRES::Factory::syncWidget(): Factory creation failed for library %s", pi->library.latin1());
201 kdDebug() << "KRES::Factory::syncWidget(): Factory creation failed" << endl; 201 kdDebug() << "KRES::Factory::syncWidget(): Factory creation failed" << endl;
202 return 0; 202 return 0;
203 } 203 }
204 204
205 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 205 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
206 206
207 if ( !pluginFactory ) { 207 if ( !pluginFactory ) {
208 qDebug("KRES::Factory::syncWidget(): no plugin factory for library %s", pi->library.latin1()); 208 qDebug("KRES::Factory::syncWidget(): no plugin factory for library %s", pi->library.latin1());
209 kdDebug() << "KRES::Factory::syncWidget(): no plugin factory." << endl; 209 kdDebug() << "KRES::Factory::syncWidget(): no plugin factory." << endl;
210 return 0; 210 return 0;
211 } 211 }
212 212
213 SyncWidget *wdg = pluginFactory->syncWidget( parent ); 213 SyncWidgetContainer *wdg = pluginFactory->syncWidgetContainer( );
214 if ( !wdg ) { 214 if ( !wdg ) {
215//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 215//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
216 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 216 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
217 return 0; 217 return 0;
218 } 218 }
219 return wdg; 219 return wdg;
220 220
221} 221}
222 222
223 223
224QString Factory::typeName( const QString &type ) const 224QString Factory::typeName( const QString &type ) const
225{ 225{
226 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 226 if ( type.isEmpty() || !mTypeMap.contains( type ) )
227 return QString(); 227 return QString();
228 228
229 229
230//US KService::Ptr ptr = mTypeMap[ type ]; 230//US KService::Ptr ptr = mTypeMap[ type ];
231//US return ptr->name(); 231//US return ptr->name();
232 PluginInfo* pi = mTypeMap[ type ]; 232 PluginInfo* pi = mTypeMap[ type ];
233 return pi->nameLabel; 233 return pi->nameLabel;
234 234
235} 235}
236 236
237QString Factory::typeDescription( const QString &type ) const 237QString Factory::typeDescription( const QString &type ) const
238{ 238{
239 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 239 if ( type.isEmpty() || !mTypeMap.contains( type ) )
240 return QString(); 240 return QString();
241 241
242//US KService::Ptr ptr = mTypeMap[ type ]; 242//US KService::Ptr ptr = mTypeMap[ type ];
243//US return ptr->comment(); 243//US return ptr->comment();
244 PluginInfo* pi = mTypeMap[ type ]; 244 PluginInfo* pi = mTypeMap[ type ];
245 return pi->descriptionLabel; 245 return pi->descriptionLabel;
246} 246}
247 247
248Resource *Factory::resource( const QString& type, const KConfig *config, bool syncable ) 248Resource *Factory::resource( const QString& type, const KConfig *config, bool syncable )
249{ 249{
250 250
251 251
252 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 252 if ( type.isEmpty() || !mTypeMap.contains( type ) )
253 return 0; 253 return 0;
254 254
255/*US load the lib not dynamicly. !! 255/*US load the lib not dynamicly. !!
256 KService::Ptr ptr = mTypeMap[ type ]; 256 KService::Ptr ptr = mTypeMap[ type ];
257 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 257 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
258 if ( !factory ) { 258 if ( !factory ) {
259 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 259 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
260 return 0; 260 return 0;
261 } 261 }
262*/ 262*/
263 PluginInfo* pi = mTypeMap[ type ]; 263 PluginInfo* pi = mTypeMap[ type ];
264 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 264 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
265 if ( !factory ) { 265 if ( !factory ) {
266 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1()); 266 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1());
267 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 267 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
268 return 0; 268 return 0;
269 } 269 }
270 270
271 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 271 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
272 272
273 if ( !pluginFactory ) { 273 if ( !pluginFactory ) {
274 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1()); 274 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1());
275 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl; 275 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl;
276 return 0; 276 return 0;
277 } 277 }
278 278
279 Resource *resource = pluginFactory->resource( config, syncable ); 279 Resource *resource = pluginFactory->resource( config, syncable );
280 if ( !resource ) { 280 if ( !resource ) {
281//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 281//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
282 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 282 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
283 return 0; 283 return 0;
284 } 284 }
285 285
286 resource->setType( type ); 286 resource->setType( type );
287 287
288 return resource; 288 return resource;
289} 289}
diff --git a/microkde/kresources/factory.h b/microkde/kresources/factory.h
index a265bc8..0e4231b 100644
--- a/microkde/kresources/factory.h
+++ b/microkde/kresources/factory.h
@@ -1,136 +1,139 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#ifndef KRESOURCES_FACTORY_H 24#ifndef KRESOURCES_FACTORY_H
25#define KRESOURCES_FACTORY_H 25#define KRESOURCES_FACTORY_H
26 26
27#include <qdict.h> 27#include <qdict.h>
28#include <qstring.h> 28#include <qstring.h>
29 29
30#include <kconfig.h> 30#include <kconfig.h>
31 31
32 32
33#include "resource.h" 33#include "resource.h"
34 34
35namespace KRES { 35namespace KRES {
36 36
37class SyncWidgetContainer;
38class ConfigWidget;
39
37//US 40//US
38struct PluginInfo 41struct PluginInfo
39{ 42{
40 QString library; 43 QString library;
41 QString nameLabel; 44 QString nameLabel;
42 QString descriptionLabel; 45 QString descriptionLabel;
43}; 46};
44 47
45 48
46/** 49/**
47 * Class for loading resource plugins. 50 * Class for loading resource plugins.
48 * Do not use this class directly. Use ResourceManager instead 51 * Do not use this class directly. Use ResourceManager instead
49 * 52 *
50 * Example: 53 * Example:
51 * 54 *
52 * <pre> 55 * <pre>
53 * KABC::Factory<Calendar> *factory = KABC::Factory<Calendar>::self(); 56 * KABC::Factory<Calendar> *factory = KABC::Factory<Calendar>::self();
54 * 57 *
55 * QStringList list = factory->resources(); 58 * QStringList list = factory->resources();
56 * QStringList::Iterator it; 59 * QStringList::Iterator it;
57 * for ( it = list.begin(); it != list.end(); ++it ) { 60 * for ( it = list.begin(); it != list.end(); ++it ) {
58 * Resource<Calendar> *resource = factory->resource( (*it), 61 * Resource<Calendar> *resource = factory->resource( (*it),
59 * KABC::StdAddressBook::self(), 0 ); 62 * KABC::StdAddressBook::self(), 0 );
60 * // do something with resource 63 * // do something with resource
61 * } 64 * }
62 * </pre> 65 * </pre>
63 */ 66 */
64class Factory 67class Factory
65{ 68{
66 public: 69 public:
67 70
68 71
69 /** 72 /**
70 * Returns the global resource factory. 73 * Returns the global resource factory.
71 */ 74 */
72 static Factory *self( const QString& resourceFamily ); 75 static Factory *self( const QString& resourceFamily );
73 76
74 ~Factory(); 77 ~Factory();
75 78
76 /** 79 /**
77 * Returns the config widget for the given resource type, 80 * Returns the config widget for the given resource type,
78 * or a null pointer if resource type doesn't exist. 81 * or a null pointer if resource type doesn't exist.
79 * 82 *
80 * @param type The type of the resource, returned by @ref resources() 83 * @param type The type of the resource, returned by @ref resources()
81 * @param resource The resource to be editted. 84 * @param resource The resource to be editted.
82 * @param parent The parent widget 85 * @param parent The parent widget
83 */ 86 */
84 ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 ); 87 ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 );
85 88
86 /** 89 /**
87 * Returns the sync widget for the given resource type, 90 * Returns the sync widget for the given resource type,
88 * or a null pointer if resource type doesn't exist, 91 * or a null pointer if resource type doesn't exist,
89 * or a null pointer if resource does not support syncing. 92 * or a null pointer if resource does not support syncing.
90 * 93 *
91 * @param type The type of the resource, returned by @ref resources() 94 * @param type The type of the resource, returned by @ref resources()
92 * @param resource The resource to be editted. 95 * @param resource The resource to be editted.
93 * @param parent The parent widget 96 * @param parent The parent widget
94 */ 97 */
95 SyncWidget *syncWidget( const QString& type, QWidget *parent = 0 ); 98 SyncWidgetContainer *syncWidgetContainer( const QString& type );
96 99
97 /** 100 /**
98 * Returns a pointer to a resource object or a null pointer 101 * Returns a pointer to a resource object or a null pointer
99 * if resource type doesn't exist. 102 * if resource type doesn't exist.
100 * 103 *
101 * @param type The type of the resource, returned by @ref resources() 104 * @param type The type of the resource, returned by @ref resources()
102 * @param ab The address book, the resource should belong to 105 * @param ab The address book, the resource should belong to
103 * @param config The config object where the resource get it settings from, or 0 if a new resource should be created. 106 * @param config The config object where the resource get it settings from, or 0 if a new resource should be created.
104 * @param syncable If the resource should support syncing capabilities. 107 * @param syncable If the resource should support syncing capabilities.
105 */ 108 */
106 Resource *resource( const QString& type, const KConfig *config, bool syncable ); 109 Resource *resource( const QString& type, const KConfig *config, bool syncable );
107 110
108 /** 111 /**
109 * Returns a list of all available resource types. 112 * Returns a list of all available resource types.
110 */ 113 */
111 QStringList typeNames() const; 114 QStringList typeNames() const;
112 115
113 /** 116 /**
114 * Returns the name for a special type. 117 * Returns the name for a special type.
115 */ 118 */
116 QString typeName( const QString &type ) const; 119 QString typeName( const QString &type ) const;
117 120
118 /** 121 /**
119 * Returns the description for a special type. 122 * Returns the description for a special type.
120 */ 123 */
121 QString typeDescription( const QString &type ) const; 124 QString typeDescription( const QString &type ) const;
122 125
123 protected: 126 protected:
124 Factory( const QString& resourceFamily); 127 Factory( const QString& resourceFamily);
125 128
126 private: 129 private:
127 static QDict<Factory> *mSelves; 130 static QDict<Factory> *mSelves;
128 131
129 QString mResourceFamily; 132 QString mResourceFamily;
130//US QMap<QString, KService::Ptr> mTypeMap; 133//US QMap<QString, KService::Ptr> mTypeMap;
131//US lets store the pluginfo struct as value instead of a KService 134//US lets store the pluginfo struct as value instead of a KService
132 QMap<QString, PluginInfo*> mTypeMap; 135 QMap<QString, PluginInfo*> mTypeMap;
133}; 136};
134 137
135} 138}
136#endif 139#endif
diff --git a/microkde/kresources/resource.h b/microkde/kresources/resource.h
index c9202c9..580b5d1 100644
--- a/microkde/kresources/resource.h
+++ b/microkde/kresources/resource.h
@@ -1,139 +1,139 @@
1/* 1/*
2 This file is part of libkresources 2 This file is part of libkresources
3 3
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#ifndef KRESOURCES_RESOURCE_H 23#ifndef KRESOURCES_RESOURCE_H
24#define KRESOURCES_RESOURCE_H 24#define KRESOURCES_RESOURCE_H
25 25
26//US 26//US
27#ifdef QT_THREAD_SUPPORT 27#ifdef QT_THREAD_SUPPORT
28#include <qmutex.h> 28#include <qmutex.h>
29#endif //QT_THREAD_SUPPORT 29#endif //QT_THREAD_SUPPORT
30 30
31#include <qvaluelist.h> 31#include <qvaluelist.h>
32#include <qwidget.h> 32#include <qwidget.h>
33 33
34#include <qobject.h> 34#include <qobject.h>
35 35
36#include <klibloader.h> 36#include <klibloader.h>
37 37
38class KConfig; 38class KConfig;
39 39
40namespace KRES { 40namespace KRES {
41 41
42class ConfigWidget; 42class ConfigWidget;
43class SyncWidget; 43class SyncWidgetContainer;
44 44
45/** 45/**
46 * @internal 46 * @internal
47 * @libdoc The KDE Resource library 47 * @libdoc The KDE Resource library
48 * 48 *
49 * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this 49 * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this
50 * interface, it is in constant flux. 50 * interface, it is in constant flux.
51 * 51 *
52 * The KDE Resource framework can be used to manage resources of 52 * The KDE Resource framework can be used to manage resources of
53 * different types, organized in families. The Resource framework 53 * different types, organized in families. The Resource framework
54 * is currently used for addressbook resources in libkabc and for 54 * is currently used for addressbook resources in libkabc and for
55 * calendar resources in libkcal. 55 * calendar resources in libkcal.
56 * 56 *
57 * When you want to use the framework for a new family, you need to 57 * When you want to use the framework for a new family, you need to
58 * <ul><li>Define a name for your resource family</li> 58 * <ul><li>Define a name for your resource family</li>
59 * <li>subclass Resource and add the fields and method that are needed 59 * <li>subclass Resource and add the fields and method that are needed
60 * in your application</li> 60 * in your application</li>
61 * <li>If needed, override the doOpen() and doClose() methods. 61 * <li>If needed, override the doOpen() and doClose() methods.
62 * <li> Provide a configuration possibility for resources in your 62 * <li> Provide a configuration possibility for resources in your
63 * new family. You can use @ref ResourcesConfigPage to easily create a 63 * new family. You can use @ref ResourcesConfigPage to easily create a
64 * KControl applet</li> 64 * KControl applet</li>
65 * <li>In your application, you can use @ref ResourceManager to keep track 65 * <li>In your application, you can use @ref ResourceManager to keep track
66 * of the resources in your family, and you can use @ref ResourceSelectDialog 66 * of the resources in your family, and you can use @ref ResourceSelectDialog
67 * to let the user select a single resource.</li> 67 * to let the user select a single resource.</li>
68 * </ul> 68 * </ul>
69 * 69 *
70 * When you want to add a new resource type to an existing resource family, 70 * When you want to add a new resource type to an existing resource family,
71 * you need to 71 * you need to
72 * <ul><li>Further subclass the family-specific Resource to implement 72 * <ul><li>Further subclass the family-specific Resource to implement
73 * resource type-specific operation</li> 73 * resource type-specific operation</li>
74 * <li>Subclass ResourceConfigWidget to provide a configuration widget 74 * <li>Subclass ResourceConfigWidget to provide a configuration widget
75 * for your new resource type</li> 75 * for your new resource type</li>
76 * <li>Provide a .desktop file so that the new resource type can be found 76 * <li>Provide a .desktop file so that the new resource type can be found
77 * automatically by the ResourceManager</li> 77 * automatically by the ResourceManager</li>
78 * </ul> 78 * </ul>
79 * 79 *
80 * Example: 80 * Example:
81 * 81 *
82<B>resourceexample.h</B>: 82<B>resourceexample.h</B>:
83<pre> 83<pre>
84#include <kconfig.h> 84#include <kconfig.h>
85#include <kresources/resource.h> 85#include <kresources/resource.h>
86 86
87class ResourceExample : public KRES::ResourceExample 87class ResourceExample : public KRES::ResourceExample
88{ 88{
89public: 89public:
90 ResourceExample( const KConfig * ); 90 ResourceExample( const KConfig * );
91 ~ResourceCalendarExchange(); 91 ~ResourceCalendarExchange();
92 void writeConfig( KConfig *config ); 92 void writeConfig( KConfig *config );
93private: 93private:
94 QString mLocation; 94 QString mLocation;
95 QString mPassword; 95 QString mPassword;
96} 96}
97</pre> 97</pre>
98<B>resourceexample.cpp</B>: 98<B>resourceexample.cpp</B>:
99<pre> 99<pre>
100#include <kconfig.h> 100#include <kconfig.h>
101 101
102#include "resourceexample.h" 102#include "resourceexample.h"
103 103
104ResourceExample::ResourceExample( const KConfig *config ) 104ResourceExample::ResourceExample( const KConfig *config )
105 : Resource( config ) 105 : Resource( config )
106{ 106{
107 if ( config ) { 107 if ( config ) {
108 mLocation = config->readEntry( "Location" ); 108 mLocation = config->readEntry( "Location" );
109 mPassword = KStringHandler::obscure( config->readEntry( "Password" ) ); 109 mPassword = KStringHandler::obscure( config->readEntry( "Password" ) );
110 } else { 110 } else {
111 mLocation = ""; // Or some sensible default 111 mLocation = ""; // Or some sensible default
112 mPassword = ""; 112 mPassword = "";
113 } 113 }
114} 114}
115 115
116void ResourceExample::writeConfig( KConfig *config ) 116void ResourceExample::writeConfig( KConfig *config )
117{ 117{
118 KRES::Resource::writeConfig( config ); 118 KRES::Resource::writeConfig( config );
119 config->writeEntry( "Location", mLocation ); 119 config->writeEntry( "Location", mLocation );
120 config->writeEntry( "Password", KStringHandler::obscure( mPassword ) ); 120 config->writeEntry( "Password", KStringHandler::obscure( mPassword ) );
121} 121}
122 122
123extern "C" 123extern "C"
124{ 124{
125 KRES::ResourceExample *config_widget( QWidget *parent ) { 125 KRES::ResourceExample *config_widget( QWidget *parent ) {
126 return new ResourceExampleConfig( parent, "Configure Example Resource" ); 126 return new ResourceExampleConfig( parent, "Configure Example Resource" );
127 } 127 }
128 128
129 KRES::Resource *resource( const KConfig *config ) { 129 KRES::Resource *resource( const KConfig *config ) {
130 return new ResourceExample( config ); 130 return new ResourceExample( config );
131 } 131 }
132} 132}
133</pre> 133</pre>
134* <B>resourceexampleconfig.h</B>: 134* <B>resourceexampleconfig.h</B>:
135<pre> 135<pre>
136#include <klineedit.h> 136#include <klineedit.h>
137#include <kresources/resourceconfigwidget.h> 137#include <kresources/resourceconfigwidget.h>
138 138
139#include "resourceexample.h" 139#include "resourceexample.h"
@@ -285,132 +285,132 @@ class Resource : public QObject
285 * Returns whether the resource is open or not. 285 * Returns whether the resource is open or not.
286 */ 286 */
287 bool isOpen() const; 287 bool isOpen() const;
288 288
289 /** 289 /**
290 * Returns a unique identifier. The identifier is unique for this resource. 290 * Returns a unique identifier. The identifier is unique for this resource.
291 * It is created when the resource is first created, and it is retained 291 * It is created when the resource is first created, and it is retained
292 * in the resource family configuration file for this resource. 292 * in the resource family configuration file for this resource.
293 * @return This resource's identifier 293 * @return This resource's identifier
294 */ 294 */
295 QString identifier() const; 295 QString identifier() const;
296 296
297 /** 297 /**
298 * Returns the type of this resource. 298 * Returns the type of this resource.
299 */ 299 */
300 QString type() const; 300 QString type() const;
301 301
302 /** 302 /**
303 * Mark the resource as read-only. You can override this method, 303 * Mark the resource as read-only. You can override this method,
304 * but also remember to call Resource::setReadOnly(). 304 * but also remember to call Resource::setReadOnly().
305 */ 305 */
306 virtual void setReadOnly( bool value ); 306 virtual void setReadOnly( bool value );
307 307
308 /** 308 /**
309 * Returns, if the resource is read-only. 309 * Returns, if the resource is read-only.
310 */ 310 */
311 virtual bool readOnly() const; 311 virtual bool readOnly() const;
312 312
313 /** 313 /**
314 * Set the name of resource.You can override this method, 314 * Set the name of resource.You can override this method,
315 * but also remember to call Resource::setResourceName(). 315 * but also remember to call Resource::setResourceName().
316 */ 316 */
317 virtual void setResourceName( const QString &name ); 317 virtual void setResourceName( const QString &name );
318 318
319 /** 319 /**
320 * Returns the name of resource. 320 * Returns the name of resource.
321 */ 321 */
322 virtual QString resourceName() const; 322 virtual QString resourceName() const;
323 323
324 324
325 325
326 virtual bool isSyncable() const = 0; 326 virtual bool isSyncable() const = 0;
327 327
328 328
329 /** 329 /**
330 Sets, if the resource is active. 330 Sets, if the resource is active.
331 */ 331 */
332 void setActive( bool active ); 332 void setActive( bool active );
333 333
334 /** 334 /**
335 Return true, if the resource is active. 335 Return true, if the resource is active.
336 */ 336 */
337 bool isActive() const; 337 bool isActive() const;
338 338
339 friend class Factory; 339 friend class Factory;
340 friend class ManagerImpl; 340 friend class ManagerImpl;
341 341
342 /** 342 /**
343 Print resource information as debug output. 343 Print resource information as debug output.
344 */ 344 */
345 virtual void dump() const; 345 virtual void dump() const;
346 346
347 347
348 protected: 348 protected:
349 /** 349 /**
350 * Open this resource. When called, the resource must be in 350 * Open this resource. When called, the resource must be in
351 * a closed state. 351 * a closed state.
352 * 352 *
353 * Returns true if the resource was opened successfully; 353 * Returns true if the resource was opened successfully;
354 * returns false if the resource was not opened successfully. 354 * returns false if the resource was not opened successfully.
355 * 355 *
356 * The result of this call can be accessed later by @ref isOpen() 356 * The result of this call can be accessed later by @ref isOpen()
357 */ 357 */
358 virtual bool doOpen() { return true; } 358 virtual bool doOpen() { return true; }
359 359
360 /** 360 /**
361 * Close this resource. Pre-condition: resource is open. 361 * Close this resource. Pre-condition: resource is open.
362 * Post-condition: resource is closed. 362 * Post-condition: resource is closed.
363 */ 363 */
364 virtual void doClose() {} 364 virtual void doClose() {}
365 365
366 void setIdentifier( const QString& identifier ); 366 void setIdentifier( const QString& identifier );
367 void setType( const QString& type ); 367 void setType( const QString& type );
368 368
369 private: 369 private:
370 class ResourcePrivate; 370 class ResourcePrivate;
371 ResourcePrivate *d; 371 ResourcePrivate *d;
372}; 372};
373 373
374class PluginFactoryBase : public KLibFactory 374class PluginFactoryBase : public KLibFactory
375{ 375{
376 public: 376 public:
377 virtual Resource *resource( const KConfig *config, bool syncable ) = 0; 377 virtual Resource *resource( const KConfig *config, bool syncable ) = 0;
378 378
379 virtual ConfigWidget *configWidget( QWidget *parent ) = 0; 379 virtual ConfigWidget *configWidget( QWidget *parent ) = 0;
380 380
381 virtual SyncWidget *syncWidget( QWidget *parent ) = 0; 381 virtual SyncWidgetContainer *syncWidgetContainer() = 0;
382 382
383 protected: 383 protected:
384 virtual QObject* createObject( QObject*, const char*, const char*, 384 virtual QObject* createObject( QObject*, const char*, const char*,
385 const QStringList & ) 385 const QStringList & )
386 { 386 {
387 return 0; 387 return 0;
388 } 388 }
389}; 389};
390 390
391template<class TR,class TC, class TS> 391template<class TR,class TC, class TS>
392class PluginFactory : public PluginFactoryBase 392class PluginFactory : public PluginFactoryBase
393{ 393{
394 public: 394 public:
395 Resource *resource( const KConfig *config, bool syncable ) 395 Resource *resource( const KConfig *config, bool syncable )
396 { 396 {
397 return new TR( config, syncable ); 397 return new TR( config, syncable );
398 } 398 }
399 399
400 ConfigWidget *configWidget( QWidget *parent ) 400 ConfigWidget *configWidget( QWidget *parent )
401 { 401 {
402 return new TC( parent ); 402 return new TC( parent );
403 } 403 }
404 404
405 virtual SyncWidget *syncWidget( QWidget *parent ) 405 SyncWidgetContainer *syncWidgetContainer()
406 { 406 {
407 return new TS( parent ); 407 return new TS();
408 } 408 }
409 409
410}; 410};
411 411
412 412
413 413
414} 414}
415 415
416#endif 416#endif
diff --git a/microkde/kresources/syncwidget.h b/microkde/kresources/syncwidget.h
index e94252c..6632b69 100644
--- a/microkde/kresources/syncwidget.h
+++ b/microkde/kresources/syncwidget.h
@@ -1,62 +1,72 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#ifndef KRESOURCES_SYNCWIDGET_H 23#ifndef KRESOURCES_SYNCWIDGET_H
24#define KRESOURCES_SYNCWIDGET_H 24#define KRESOURCES_SYNCWIDGET_H
25 25
26#include <qwidget.h> 26#include <qwidget.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29 29
30#include "resource.h" 30#include "resource.h"
31 31
32namespace KRES { 32namespace KRES {
33 33
34class SyncWidget : public QWidget 34class SyncWidget : public QWidget
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 37
38public: 38public:
39 SyncWidget( QWidget *parent = 0, const char *name = 0 ); 39 SyncWidget( QWidget *parent = 0, const char *name = 0 );
40 40
41 /** 41 /**
42 Sets the widget to 'edit' mode. Reimplement this method if you are 42 Sets the widget to 'edit' mode. Reimplement this method if you are
43 interested in the mode change (to disable some GUI element for 43 interested in the mode change (to disable some GUI element for
44 example). By default the widget is in 'create new' mode. 44 example). By default the widget is in 'create new' mode.
45 */ 45 */
46 virtual void setInEditMode( bool value ); 46 virtual void setInEditMode( bool value );
47 47
48public slots: 48public slots:
49 virtual void loadSettings( Resource *resource ); 49 virtual void loadSettings( Resource *resource );
50 virtual void saveSettings( Resource *resource ); 50 virtual void saveSettings( Resource *resource );
51 51
52signals: 52signals:
53//US void setReadOnly( bool value ); 53//US void setReadOnly( bool value );
54//US void setPersistentReadOnly( bool value ); 54//US void setPersistentReadOnly( bool value );
55 55
56 56
57protected: 57protected:
58//US Resource* mResource; 58//US Resource* mResource;
59}; 59};
60 60
61class SyncWidgetContainer : public QObject
62{
63 Q_OBJECT
64
65public:
66 virtual SyncWidget* generateSettingsTab(QWidget *parent = 0, const char *name = 0) = 0;
67 virtual SyncWidget* generateConflictsTab(QWidget *parent = 0, const char *name = 0) = 0;
68 virtual SyncWidget* generateRemoteTab(QWidget *parent = 0, const char *name = 0) = 0;
69};
70
61} 71}
62#endif 72#endif