author | ulf69 <ulf69> | 2004-08-02 18:15:04 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-02 18:15:04 (UTC) |
commit | e084a79b8aa0174e7587893f9b87d88670ed9f2c (patch) (unidiff) | |
tree | d3250447b9352effc8fb953866c772418c5e166c | |
parent | b4203356adb6008a4b4e6782afdae7dd34178697 (diff) | |
download | kdepimpi-e084a79b8aa0174e7587893f9b87d88670ed9f2c.zip kdepimpi-e084a79b8aa0174e7587893f9b87d88670ed9f2c.tar.gz kdepimpi-e084a79b8aa0174e7587893f9b87d88670ed9f2c.tar.bz2 |
added support for the syncing of resources
-rw-r--r-- | microkde/kresources/configdialog.cpp | 89 | ||||
-rw-r--r-- | microkde/kresources/configdialog.h | 4 | ||||
-rw-r--r-- | microkde/kresources/configpage.cpp | 75 | ||||
-rw-r--r-- | microkde/kresources/configpage.h | 1 | ||||
-rw-r--r-- | microkde/kresources/factory.cpp | 44 | ||||
-rw-r--r-- | microkde/kresources/factory.h | 26 | ||||
-rw-r--r-- | microkde/microkdeE.pro | 2 |
7 files changed, 179 insertions, 62 deletions
diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp index 0fc199c..90febca 100644 --- a/microkde/kresources/configdialog.cpp +++ b/microkde/kresources/configdialog.cpp | |||
@@ -40,12 +40,14 @@ | |||
40 | #include "configwidget.h" | 40 | #include "configwidget.h" |
41 | #include "configdialog.h" | 41 | #include "configdialog.h" |
42 | #include "syncwidget.h" | ||
42 | 43 | ||
43 | using namespace KRES; | 44 | using namespace KRES; |
44 | 45 | ||
45 | ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, | 46 | ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, |
46 | /*const QString& type,*/ Resource* resource, /*KConfig *config, */const char *name ) | 47 | Resource* resource, const char *name ) |
47 | : KDialogBase( parent, name, true, i18n( "Resource Configuration" ), | 48 | : KDialogBase( parent, name, true, resource->isSyncable()?i18n( "Sync Profile Configuration" ):i18n( "Resource Configuration" ), |
48 | Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false) | 49 | Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget(0), mResource( resource ), mPersistentReadOnly(false) |
49 | { | 50 | { |
51 | |||
50 | Factory *factory = Factory::self( resourceFamily ); | 52 | Factory *factory = Factory::self( resourceFamily ); |
51 | 53 | ||
@@ -62,12 +64,14 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, | |||
62 | generalGroupBox->setTitle( i18n( "General Settings" ) ); | 64 | generalGroupBox->setTitle( i18n( "General Settings" ) ); |
63 | 65 | ||
64 | new QLabel( i18n( "Name:" ), generalGroupBox ); | 66 | new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox ); |
65 | 67 | ||
66 | mName = new KLineEdit( generalGroupBox ); | 68 | mName = new KLineEdit( generalGroupBox ); |
67 | 69 | ||
68 | mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); | 70 | if (!mResource->isSyncable()) { |
71 | mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); | ||
72 | mReadOnly->setChecked( mResource->readOnly() ); | ||
73 | } | ||
69 | 74 | ||
70 | mName->setText( mResource->resourceName() ); | 75 | mName->setText( mResource->resourceName() ); |
71 | mReadOnly->setChecked( mResource->readOnly() ); | ||
72 | 76 | ||
73 | mainLayout->addWidget( generalGroupBox ); | 77 | mainLayout->addWidget( generalGroupBox ); |
@@ -83,19 +87,39 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, | |||
83 | mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); | 87 | mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); |
84 | if ( mConfigWidget ) { | 88 | if ( mConfigWidget ) { |
85 | connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), | 89 | connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), |
86 | SLOT( setReadOnly( bool ) ) ); | 90 | SLOT( setReadOnly( bool ) ) ); |
87 | connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), | 91 | connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), |
88 | SLOT( setPersistentReadOnly( bool ) ) ); | 92 | SLOT( setPersistentReadOnly( bool ) ) ); |
89 | mConfigWidget->setInEditMode( false ); | 93 | mConfigWidget->setInEditMode( false ); |
90 | mConfigWidget->loadSettings( mResource ); | 94 | mConfigWidget->loadSettings( mResource ); |
91 | mConfigWidget->show(); | 95 | mConfigWidget->show(); |
92 | 96 | ||
93 | } | 97 | } |
94 | 98 | ||
95 | connect( mName, SIGNAL( textChanged(const QString &)), | 99 | if (mResource->isSyncable()) |
100 | { | ||
101 | QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); | ||
102 | syncGroupBox->layout()->setSpacing( spacingHint()); | ||
103 | syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) ); | ||
104 | mainLayout->addWidget( syncGroupBox ); | ||
105 | |||
106 | mainLayout->addStretch(); | ||
107 | |||
108 | mSyncWidget = factory->syncWidget( resource->type(), syncGroupBox ); | ||
109 | if ( mSyncWidget ) { | ||
110 | mSyncWidget->setInEditMode( false ); | ||
111 | mSyncWidget->loadSettings( mResource ); | ||
112 | mSyncWidget->show(); | ||
113 | } | ||
114 | } | ||
115 | |||
116 | |||
117 | |||
118 | |||
119 | connect( mName, SIGNAL( textChanged(const QString &)), | ||
96 | SLOT( slotNameChanged(const QString &))); | 120 | SLOT( slotNameChanged(const QString &))); |
97 | 121 | ||
98 | slotNameChanged( mName->text() ); | 122 | slotNameChanged( mName->text() ); |
99 | 123 | ||
100 | //US setMinimumSize( 400, 250 ); | 124 | //US setMinimumSize( 400, 250 ); |
101 | setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); | 125 | setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); |
@@ -107,4 +131,8 @@ void ConfigDialog::setInEditMode( bool value ) | |||
107 | if ( mConfigWidget ) | 131 | if ( mConfigWidget ) |
108 | mConfigWidget->setInEditMode( value ); | 132 | mConfigWidget->setInEditMode( value ); |
133 | |||
134 | if ( mSyncWidget ) | ||
135 | mSyncWidget->setInEditMode( value ); | ||
136 | |||
109 | } | 137 | } |
110 | 138 | ||
@@ -116,19 +144,24 @@ void ConfigDialog::slotNameChanged( const QString &text) | |||
116 | void ConfigDialog::setReadOnly( bool value ) | 144 | void ConfigDialog::setReadOnly( bool value ) |
117 | { | 145 | { |
118 | if (mPersistentReadOnly == false) | 146 | if (!mResource->isSyncable()) { |
119 | mReadOnly->setChecked( value ); | 147 | |
120 | else | 148 | if (mPersistentReadOnly == false) |
121 | mReadOnly->setChecked( true ); | 149 | mReadOnly->setChecked( value ); |
150 | else | ||
151 | mReadOnly->setChecked( true ); | ||
152 | } | ||
122 | } | 153 | } |
123 | 154 | ||
124 | void ConfigDialog::setPersistentReadOnly( bool value ) | 155 | void ConfigDialog::setPersistentReadOnly( bool value ) |
125 | { | 156 | { |
126 | mPersistentReadOnly = value; | 157 | if (!mResource->isSyncable()) { |
127 | 158 | ||
128 | if (value == true) | 159 | mPersistentReadOnly = value; |
129 | setReadOnly( true ); | 160 | |
130 | 161 | if (value == true) | |
131 | mReadOnly->setEnabled( !value ); | 162 | setReadOnly( true ); |
132 | 163 | ||
164 | mReadOnly->setEnabled( !value ); | ||
165 | } | ||
133 | } | 166 | } |
134 | 167 | ||
@@ -136,10 +169,11 @@ void ConfigDialog::accept() | |||
136 | { | 169 | { |
137 | if ( mName->text().isEmpty() ) { | 170 | if ( mName->text().isEmpty() ) { |
138 | KMessageBox::sorry( this, i18n( "Please enter a resource name" ) ); | 171 | KMessageBox::sorry( this, mResource->isSyncable()?i18n( "Please enter a profile name" ):i18n( "Please enter a resource name" ) ); |
139 | return; | 172 | return; |
140 | } | 173 | } |
141 | 174 | ||
142 | mResource->setResourceName( mName->text() ); | 175 | mResource->setResourceName( mName->text() ); |
143 | mResource->setReadOnly( mReadOnly->isChecked() ); | 176 | if (!mResource->isSyncable()) |
177 | mResource->setReadOnly( mReadOnly->isChecked() ); | ||
144 | 178 | ||
145 | if ( mConfigWidget ) { | 179 | if ( mConfigWidget ) { |
@@ -149,4 +183,11 @@ void ConfigDialog::accept() | |||
149 | } | 183 | } |
150 | 184 | ||
185 | if ( mSyncWidget ) { | ||
186 | // First save generic information | ||
187 | // Also save setting of specific resource type | ||
188 | mSyncWidget->saveSettings( mResource ); | ||
189 | } | ||
190 | |||
191 | |||
151 | KDialog::accept(); | 192 | KDialog::accept(); |
152 | } | 193 | } |
diff --git a/microkde/kresources/configdialog.h b/microkde/kresources/configdialog.h index ba66f8e..b629347 100644 --- a/microkde/kresources/configdialog.h +++ b/microkde/kresources/configdialog.h | |||
@@ -32,4 +32,5 @@ namespace KRES { | |||
32 | class Resource; | 32 | class Resource; |
33 | class ConfigWidget; | 33 | class ConfigWidget; |
34 | class SyncWidget; | ||
34 | 35 | ||
35 | class ConfigDialog : public KDialogBase | 36 | class ConfigDialog : public KDialogBase |
@@ -51,4 +52,5 @@ class ConfigDialog : public KDialogBase | |||
51 | private: | 52 | private: |
52 | ConfigWidget *mConfigWidget; | 53 | ConfigWidget *mConfigWidget; |
54 | SyncWidget *mSyncWidget; | ||
53 | Resource* mResource; | 55 | Resource* mResource; |
54 | 56 | ||
@@ -56,5 +58,5 @@ class ConfigDialog : public KDialogBase | |||
56 | QCheckBox *mReadOnly; | 58 | QCheckBox *mReadOnly; |
57 | //US add a persistent readonly flag. We need that for opie and qtopia addressbooks. | 59 | //US add a persistent readonly flag. We need that for opie and qtopia addressbooks. |
58 | bool mPersistentReadOnly; | 60 | bool mPersistentReadOnly; |
59 | }; | 61 | }; |
60 | 62 | ||
diff --git a/microkde/kresources/configpage.cpp b/microkde/kresources/configpage.cpp index 8782ffd..912c62e 100644 --- a/microkde/kresources/configpage.cpp +++ b/microkde/kresources/configpage.cpp | |||
@@ -22,4 +22,11 @@ | |||
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | ||
25 | Enhanced Version of the file for platform independent KDE tools. | ||
26 | Copyright (c) 2004 Ulf Schenk | ||
27 | |||
28 | $Id$ | ||
29 | */ | ||
30 | |||
24 | #include <qgroupbox.h> | 31 | #include <qgroupbox.h> |
25 | #include <qinputdialog.h> | 32 | #include <qinputdialog.h> |
@@ -51,4 +58,7 @@ | |||
51 | using namespace KRES; | 58 | using namespace KRES; |
52 | 59 | ||
60 | const QString ConfigPage::syncfamily = "syncprofiles"; | ||
61 | |||
62 | |||
53 | class ConfigViewItem : public QCheckListItem | 63 | class ConfigViewItem : public QCheckListItem |
54 | { | 64 | { |
@@ -165,11 +175,13 @@ void ConfigPage::load() | |||
165 | //US QString family = tmp.toString(); | 175 | //US QString family = tmp.toString(); |
166 | QStringList families; | 176 | QStringList families; |
167 | families << "contact" << "sync-contacts"; | 177 | families << "contact" << syncfamily; |
178 | |||
179 | |||
168 | for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) | 180 | for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) |
169 | { | 181 | { |
170 | QString family = (*it); | 182 | QString family = (*it); |
171 | if ( !family.isEmpty() ) { | 183 | if ( !family.isEmpty() ) { |
172 | if ( !mFamilyMap.contains( family ) ) { | 184 | if ( !mFamilyMap.contains( family ) ) { |
173 | mCurrentManager = new Manager<Resource>( family ); | 185 | mCurrentManager = new Manager<Resource>( family, (family == syncfamily) ); |
174 | if ( mCurrentManager ) { | 186 | if ( mCurrentManager ) { |
175 | mFamilyMap.append( family ); | 187 | mFamilyMap.append( family ); |
@@ -229,5 +241,5 @@ void ConfigPage::slotFamilyChanged( int pos ) | |||
229 | 241 | ||
230 | //US qDebug("ConfigPage::slotFamilyChanged 4 family=%s", mFamily.latin1()); | 242 | //US qDebug("ConfigPage::slotFamilyChanged 4 family=%s", mFamily.latin1()); |
231 | 243 | ||
232 | mCurrentManager = mInfoMap[ pos ].mManager; | 244 | mCurrentManager = mInfoMap[ pos ].mManager; |
233 | mCurrentConfig = mInfoMap[ pos ].mConfig; | 245 | mCurrentConfig = mInfoMap[ pos ].mConfig; |
@@ -240,13 +252,13 @@ void ConfigPage::slotFamilyChanged( int pos ) | |||
240 | if ( mCurrentManager->isEmpty() ) { | 252 | if ( mCurrentManager->isEmpty() ) { |
241 | //US qDebug("ConfigPage::slotFamilyChanged 4.1 mCurrentManager=%ul", mCurrentManager ); | 253 | //US qDebug("ConfigPage::slotFamilyChanged 4.1 mCurrentManager=%ul", mCurrentManager ); |
242 | 254 | ||
243 | defaults(); | 255 | defaults(); |
244 | } | 256 | } |
245 | 257 | ||
246 | Resource *standardResource = mCurrentManager->standardResource(); | 258 | Resource *standardResource = mCurrentManager->standardResource(); |
247 | 259 | ||
248 | //US qDebug("ConfigPage::slotFamilyChanged 4.4 resourcename=%s", standardResource->resourceName().latin1()); | 260 | //US qDebug("ConfigPage::slotFamilyChanged 4.4 resourcename=%s", standardResource->resourceName().latin1()); |
249 | 261 | ||
250 | 262 | ||
251 | Manager<Resource>::Iterator it; | 263 | Manager<Resource>::Iterator it; |
252 | for ( it = mCurrentManager->begin(); it != mCurrentManager->end(); ++it ) { | 264 | for ( it = mCurrentManager->begin(); it != mCurrentManager->end(); ++it ) { |
@@ -255,5 +267,5 @@ void ConfigPage::slotFamilyChanged( int pos ) | |||
255 | item->setStandard( true ); | 267 | item->setStandard( true ); |
256 | } | 268 | } |
257 | 269 | ||
258 | if ( mListView->childCount() == 0 ) { | 270 | if ( mListView->childCount() == 0 ) { |
259 | //US qDebug("ConfigPage::slotFamilyChanged 4.5 "); | 271 | //US qDebug("ConfigPage::slotFamilyChanged 4.5 "); |
@@ -264,10 +276,10 @@ void ConfigPage::slotFamilyChanged( int pos ) | |||
264 | } else { | 276 | } else { |
265 | //US qDebug("ConfigPage::slotFamilyChanged 4.6 "); | 277 | //US qDebug("ConfigPage::slotFamilyChanged 4.6 "); |
266 | 278 | ||
267 | if ( !standardResource ) { | 279 | if ( !standardResource ) { |
268 | KMessageBox::sorry( this, i18n( "There is no standard resource! Please select one." ) ); | 280 | KMessageBox::sorry( this, i18n( "There is no standard resource!<br> Please select one." ) ); |
269 | 281 | ||
270 | //US qDebug("ConfigPage::slotFamilyChanged 4.7" ); | 282 | //US qDebug("ConfigPage::slotFamilyChanged 4.7" ); |
271 | 283 | ||
272 | } | 284 | } |
273 | 285 | ||
@@ -284,7 +296,20 @@ void ConfigPage::slotAdd() | |||
284 | QStringList descs = mCurrentManager->resourceTypeDescriptions(); | 296 | QStringList descs = mCurrentManager->resourceTypeDescriptions(); |
285 | bool ok = false; | 297 | bool ok = false; |
286 | QString desc = QInputDialog::getItem( i18n( "Resource Configuration" ), | 298 | |
287 | i18n( "Please select type of the new resource:" ), descs, 0, | 299 | QString desc; |
300 | |||
301 | if (mFamily == syncfamily) | ||
302 | { | ||
303 | desc = QInputDialog::getItem( i18n( "Sync Configuration" ), | ||
304 | i18n( "Please select resource type for new sync profile:" ), descs, 0, | ||
305 | false, &ok, this ); | ||
306 | } | ||
307 | else | ||
308 | { | ||
309 | desc = QInputDialog::getItem( i18n( "Resource Configuration" ), | ||
310 | i18n( "Please select type of the new resource:" ), descs, 0, | ||
288 | false, &ok, this ); | 311 | false, &ok, this ); |
312 | } | ||
313 | |||
289 | if ( !ok ) | 314 | if ( !ok ) |
290 | return; | 315 | return; |
@@ -381,5 +406,5 @@ void ConfigPage::slotEdit() | |||
381 | 406 | ||
382 | if ( configItem->standard() && configItem->readOnly() ) { | 407 | if ( configItem->standard() && configItem->readOnly() ) { |
383 | KMessageBox::sorry( this, i18n( "You cannot use a read-only resource as standard!" ) ); | 408 | KMessageBox::sorry( this, i18n( "You cannot use a read-only<br> resource as standard!" ) ); |
384 | configItem->setStandard( false ); | 409 | configItem->setStandard( false ); |
385 | } | 410 | } |
@@ -400,10 +425,10 @@ void ConfigPage::slotStandard() | |||
400 | 425 | ||
401 | if ( item->readOnly() ) { | 426 | if ( item->readOnly() ) { |
402 | KMessageBox::sorry( this, i18n( "You cannot use a read-only resource as standard!" ) ); | 427 | KMessageBox::sorry( this, i18n( "You cannot use a read-only<br>resource as standard!" ) ); |
403 | return; | 428 | return; |
404 | } | 429 | } |
405 | 430 | ||
406 | if ( !item->isOn() ) { | 431 | if ( !item->isOn() ) { |
407 | KMessageBox::sorry( this, i18n( "You cannot use an inactive resource as standard!" ) ); | 432 | KMessageBox::sorry( this, i18n( "You cannot use an inactive<br>resource as standard!" ) ); |
408 | return; | 433 | return; |
409 | } | 434 | } |
@@ -465,5 +490,5 @@ void ConfigPage::slotItemClicked( QListViewItem *item ) | |||
465 | 490 | ||
466 | if ( configItem->standard() && !configItem->isOn() ) { | 491 | if ( configItem->standard() && !configItem->isOn() ) { |
467 | KMessageBox::sorry( this, i18n( "You cannot deactivate the standard resource. Choose another standard resource first." ) ); | 492 | KMessageBox::sorry( this, i18n( "You cannot deactivate the<br>standard resource. Choose<br>another standard resource first." ) ); |
468 | configItem->setOn( true ); | 493 | configItem->setOn( true ); |
469 | return; | 494 | return; |
@@ -480,5 +505,5 @@ void ConfigPage::saveResourceSettings() | |||
480 | 505 | ||
481 | if ( mCurrentManager ) { | 506 | if ( mCurrentManager ) { |
482 | 507 | ||
483 | QListViewItem *item = mListView->firstChild(); | 508 | QListViewItem *item = mListView->firstChild(); |
484 | while ( item ) { | 509 | while ( item ) { |
@@ -488,8 +513,8 @@ void ConfigPage::saveResourceSettings() | |||
488 | if ( configItem->standard() && !configItem->readOnly() && | 513 | if ( configItem->standard() && !configItem->readOnly() && |
489 | configItem->isOn() ) { | 514 | configItem->isOn() ) { |
490 | 515 | ||
491 | mCurrentManager->setStandardResource( configItem->resource() ); | 516 | mCurrentManager->setStandardResource( configItem->resource() ); |
492 | } | 517 | } |
493 | 518 | ||
494 | // check if active or passive resource | 519 | // check if active or passive resource |
495 | configItem->resource()->setActive( configItem->isOn() ); | 520 | configItem->resource()->setActive( configItem->isOn() ); |
@@ -500,9 +525,9 @@ void ConfigPage::saveResourceSettings() | |||
500 | 525 | ||
501 | if ( !mCurrentManager->standardResource() ) | 526 | if ( !mCurrentManager->standardResource() ) |
502 | KMessageBox::sorry( this, i18n( "There is no valid standard resource! Please select one which is neither read-only nor inactive." ) ); | 527 | KMessageBox::sorry( this, i18n( "There is no valid standard resource!<br>Please select one which is neither read-only nor inactive." ) ); |
503 | } | 528 | } |
504 | 529 | ||
505 | qDebug("ConfigPage::saveResourceSettings() end"); | 530 | qDebug("ConfigPage::saveResourceSettings() end"); |
506 | 531 | ||
507 | } | 532 | } |
508 | 533 | ||
diff --git a/microkde/kresources/configpage.h b/microkde/kresources/configpage.h index 492ea54..be9239e 100644 --- a/microkde/kresources/configpage.h +++ b/microkde/kresources/configpage.h | |||
@@ -97,4 +97,5 @@ class ConfigPage : public QWidget, public ManagerListener<Resource> | |||
97 | 97 | ||
98 | QListViewItem* mLastItem; | 98 | QListViewItem* mLastItem; |
99 | static const QString syncfamily; | ||
99 | }; | 100 | }; |
100 | 101 | ||
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp index f82e94c..7a5c2f6 100644 --- a/microkde/kresources/factory.cpp +++ b/microkde/kresources/factory.cpp | |||
@@ -40,5 +40,5 @@ QDict<Factory> *Factory::mSelves = 0; | |||
40 | static KStaticDeleter< QDict<Factory> > staticDeleter; | 40 | static KStaticDeleter< QDict<Factory> > staticDeleter; |
41 | 41 | ||
42 | Factory *Factory::self( const QString& resourceFamily ) | 42 | Factory *Factory::self( const QString& resourceFamily) |
43 | { | 43 | { |
44 | 44 | ||
@@ -53,5 +53,5 @@ Factory *Factory::self( const QString& resourceFamily ) | |||
53 | 53 | ||
54 | if ( !factory ) { | 54 | if ( !factory ) { |
55 | factory = new Factory( resourceFamily ); | 55 | factory = new Factory( resourceFamily); |
56 | mSelves->insert( resourceFamily, factory ); | 56 | mSelves->insert( resourceFamily, factory ); |
57 | } | 57 | } |
@@ -60,5 +60,5 @@ Factory *Factory::self( const QString& resourceFamily ) | |||
60 | } | 60 | } |
61 | 61 | ||
62 | Factory::Factory( const QString& resourceFamily ) : | 62 | Factory::Factory( const QString& resourceFamily) : |
63 | mResourceFamily( resourceFamily ) | 63 | mResourceFamily( resourceFamily ) |
64 | { | 64 | { |
@@ -188,4 +188,38 @@ ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) | |||
188 | } | 188 | } |
189 | 189 | ||
190 | SyncWidget *Factory::syncWidget( const QString& type, QWidget *parent ) | ||
191 | { | ||
192 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | ||
193 | return 0; | ||
194 | |||
195 | //US KService::Ptr ptr = mTypeMap[ type ]; | ||
196 | //US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); | ||
197 | PluginInfo* pi = mTypeMap[ type ]; | ||
198 | KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); | ||
199 | if ( !factory ) { | ||
200 | qDebug("KRES::Factory::syncWidget(): Factory creation failed for library %s", pi->library.latin1()); | ||
201 | kdDebug() << "KRES::Factory::syncWidget(): Factory creation failed" << endl; | ||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); | ||
206 | |||
207 | if ( !pluginFactory ) { | ||
208 | qDebug("KRES::Factory::syncWidget(): no plugin factory for library %s", pi->library.latin1()); | ||
209 | kdDebug() << "KRES::Factory::syncWidget(): no plugin factory." << endl; | ||
210 | return 0; | ||
211 | } | ||
212 | |||
213 | SyncWidget *wdg = pluginFactory->syncWidget( parent ); | ||
214 | if ( !wdg ) { | ||
215 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; | ||
216 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); | ||
217 | return 0; | ||
218 | } | ||
219 | return wdg; | ||
220 | |||
221 | } | ||
222 | |||
223 | |||
190 | QString Factory::typeName( const QString &type ) const | 224 | QString Factory::typeName( const QString &type ) const |
191 | { | 225 | { |
@@ -212,5 +246,5 @@ QString Factory::typeDescription( const QString &type ) const | |||
212 | } | 246 | } |
213 | 247 | ||
214 | Resource *Factory::resource( const QString& type, const KConfig *config ) | 248 | Resource *Factory::resource( const QString& type, const KConfig *config, bool syncable ) |
215 | { | 249 | { |
216 | 250 | ||
@@ -243,5 +277,5 @@ Resource *Factory::resource( const QString& type, const KConfig *config ) | |||
243 | } | 277 | } |
244 | 278 | ||
245 | Resource *resource = pluginFactory->resource( config ); | 279 | Resource *resource = pluginFactory->resource( config, syncable ); |
246 | if ( !resource ) { | 280 | if ( !resource ) { |
247 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; | 281 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; |
diff --git a/microkde/kresources/factory.h b/microkde/kresources/factory.h index ad67ab3..a265bc8 100644 --- a/microkde/kresources/factory.h +++ b/microkde/kresources/factory.h | |||
@@ -35,5 +35,5 @@ | |||
35 | namespace KRES { | 35 | namespace KRES { |
36 | 36 | ||
37 | //US | 37 | //US |
38 | struct PluginInfo | 38 | struct PluginInfo |
39 | { | 39 | { |
@@ -66,5 +66,5 @@ class Factory | |||
66 | public: | 66 | public: |
67 | 67 | ||
68 | 68 | ||
69 | /** | 69 | /** |
70 | * Returns the global resource factory. | 70 | * Returns the global resource factory. |
@@ -79,5 +79,5 @@ class Factory | |||
79 | * | 79 | * |
80 | * @param type The type of the resource, returned by @ref resources() | 80 | * @param type The type of the resource, returned by @ref resources() |
81 | * @param resource The resource to be editted. | 81 | * @param resource The resource to be editted. |
82 | * @param parent The parent widget | 82 | * @param parent The parent widget |
83 | */ | 83 | */ |
@@ -85,4 +85,15 @@ class Factory | |||
85 | 85 | ||
86 | /** | 86 | /** |
87 | * Returns the sync widget for the given resource type, | ||
88 | * or a null pointer if resource type doesn't exist, | ||
89 | * or a null pointer if resource does not support syncing. | ||
90 | * | ||
91 | * @param type The type of the resource, returned by @ref resources() | ||
92 | * @param resource The resource to be editted. | ||
93 | * @param parent The parent widget | ||
94 | */ | ||
95 | SyncWidget *syncWidget( const QString& type, QWidget *parent = 0 ); | ||
96 | |||
97 | /** | ||
87 | * Returns a pointer to a resource object or a null pointer | 98 | * Returns a pointer to a resource object or a null pointer |
88 | * if resource type doesn't exist. | 99 | * if resource type doesn't exist. |
@@ -91,6 +102,7 @@ class Factory | |||
91 | * @param ab The address book, the resource should belong to | 102 | * @param ab The address book, the resource should belong to |
92 | * @param config The config object where the resource get it settings from, or 0 if a new resource should be created. | 103 | * @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. | ||
93 | */ | 105 | */ |
94 | Resource *resource( const QString& type, const KConfig *config ); | 106 | Resource *resource( const QString& type, const KConfig *config, bool syncable ); |
95 | 107 | ||
96 | /** | 108 | /** |
@@ -110,5 +122,5 @@ class Factory | |||
110 | 122 | ||
111 | protected: | 123 | protected: |
112 | Factory( const QString& resourceFamily ); | 124 | Factory( const QString& resourceFamily); |
113 | 125 | ||
114 | private: | 126 | private: |
@@ -117,6 +129,6 @@ class Factory | |||
117 | QString mResourceFamily; | 129 | QString mResourceFamily; |
118 | //US QMap<QString, KService::Ptr> mTypeMap; | 130 | //US QMap<QString, KService::Ptr> mTypeMap; |
119 | //US lets store the pluginfo struct as value instead of a KService | 131 | //US lets store the pluginfo struct as value instead of a KService |
120 | QMap<QString, PluginInfo*> mTypeMap; | 132 | QMap<QString, PluginInfo*> mTypeMap; |
121 | }; | 133 | }; |
122 | 134 | ||
diff --git a/microkde/microkdeE.pro b/microkde/microkdeE.pro index ec2b1f7..b664c9a 100644 --- a/microkde/microkdeE.pro +++ b/microkde/microkdeE.pro | |||
@@ -90,4 +90,5 @@ osmartpointer.h \ | |||
90 | kresources/configdialog.h \ | 90 | kresources/configdialog.h \ |
91 | kresources/kcmkresources.h \ | 91 | kresources/kcmkresources.h \ |
92 | kresources/syncwidget.h \ | ||
92 | kdecore/kmdcodec.h \ | 93 | kdecore/kmdcodec.h \ |
93 | kdecore/kconfigbase.h \ | 94 | kdecore/kconfigbase.h \ |
@@ -170,4 +171,5 @@ oprocess.cpp \ | |||
170 | kresources/resource.cpp \ | 171 | kresources/resource.cpp \ |
171 | kresources/selectdialog.cpp \ | 172 | kresources/selectdialog.cpp \ |
173 | kresources/syncwidget.cpp \ | ||
172 | kutils/kcmultidialog.cpp | 174 | kutils/kcmultidialog.cpp |
173 | 175 | ||