Diffstat (limited to 'microkde/kresources/configpage.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | microkde/kresources/configpage.cpp | 43 |
1 files changed, 34 insertions, 9 deletions
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 | |||
@@ -18,12 +18,19 @@ | |||
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 | /* | ||
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> |
26 | #include <qlabel.h> | 33 | #include <qlabel.h> |
27 | #include <qlayout.h> | 34 | #include <qlayout.h> |
28 | 35 | ||
29 | #include <kapplication.h> | 36 | #include <kapplication.h> |
@@ -47,12 +54,15 @@ | |||
47 | #include <qpushbutton.h> | 54 | #include <qpushbutton.h> |
48 | #include <qfile.h> | 55 | #include <qfile.h> |
49 | #include <kglobal.h> | 56 | #include <kglobal.h> |
50 | 57 | ||
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 | { |
55 | public: | 65 | public: |
56 | ConfigViewItem( QListView *parent, Resource* resource ) : | 66 | ConfigViewItem( QListView *parent, Resource* resource ) : |
57 | QCheckListItem( parent, resource->resourceName(), CheckBox ), | 67 | QCheckListItem( parent, resource->resourceName(), CheckBox ), |
58 | mResource( resource ), | 68 | mResource( resource ), |
@@ -161,19 +171,21 @@ void ConfigPage::load() | |||
161 | //US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" ); | 171 | //US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" ); |
162 | //US KTrader::OfferList::ConstIterator it; | 172 | //US KTrader::OfferList::ConstIterator it; |
163 | //US for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 173 | //US for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
164 | //US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" ); | 174 | //US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" ); |
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 ); |
176 | mCurrentManager->addListener( this ); | 188 | mCurrentManager->addListener( this ); |
177 | 189 | ||
178 | ResourcePageInfo info; | 190 | ResourcePageInfo info; |
179 | info.mManager = mCurrentManager; | 191 | info.mManager = mCurrentManager; |
@@ -262,13 +274,13 @@ void ConfigPage::slotFamilyChanged( int pos ) | |||
262 | emit changed( true ); | 274 | emit changed( true ); |
263 | mCurrentManager->writeConfig( mCurrentConfig ); | 275 | mCurrentManager->writeConfig( mCurrentConfig ); |
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 | ||
274 | emit changed( false ); | 286 | emit changed( false ); |
@@ -280,15 +292,28 @@ void ConfigPage::slotAdd() | |||
280 | if ( !mCurrentManager ) | 292 | if ( !mCurrentManager ) |
281 | return; | 293 | return; |
282 | 294 | ||
283 | QStringList types = mCurrentManager->resourceTypeNames(); | 295 | QStringList types = mCurrentManager->resourceTypeNames(); |
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 | |
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" ), | ||
287 | i18n( "Please select type of the new resource:" ), descs, 0, | 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; |
291 | 316 | ||
292 | QString type = types[ descs.findIndex( desc ) ]; | 317 | QString type = types[ descs.findIndex( desc ) ]; |
293 | 318 | ||
294 | // Create new resource | 319 | // Create new resource |
@@ -377,13 +402,13 @@ void ConfigPage::slotEdit() | |||
377 | 402 | ||
378 | if ( dlg.exec() ) { | 403 | if ( dlg.exec() ) { |
379 | configItem->setText( 0, resource->resourceName() ); | 404 | configItem->setText( 0, resource->resourceName() ); |
380 | configItem->setText( 1, resource->type() ); | 405 | configItem->setText( 1, resource->type() ); |
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 | } |
386 | 411 | ||
387 | mCurrentManager->resourceChanged( resource ); | 412 | mCurrentManager->resourceChanged( resource ); |
388 | emit changed( true ); | 413 | emit changed( true ); |
389 | } | 414 | } |
@@ -396,18 +421,18 @@ void ConfigPage::slotStandard() | |||
396 | 421 | ||
397 | ConfigViewItem *item = static_cast<ConfigViewItem*>( mListView->currentItem() ); | 422 | ConfigViewItem *item = static_cast<ConfigViewItem*>( mListView->currentItem() ); |
398 | if ( !item ) | 423 | if ( !item ) |
399 | return; | 424 | return; |
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 | } |
410 | 435 | ||
411 | QListViewItem *it = mListView->firstChild(); | 436 | QListViewItem *it = mListView->firstChild(); |
412 | while ( it != 0 ) { | 437 | while ( it != 0 ) { |
413 | ConfigViewItem *configItem = static_cast<ConfigViewItem*>( it ); | 438 | ConfigViewItem *configItem = static_cast<ConfigViewItem*>( it ); |
@@ -461,13 +486,13 @@ void ConfigPage::resourceDeleted( Resource* resource ) | |||
461 | void ConfigPage::slotItemClicked( QListViewItem *item ) | 486 | void ConfigPage::slotItemClicked( QListViewItem *item ) |
462 | { | 487 | { |
463 | ConfigViewItem *configItem = static_cast<ConfigViewItem *>( item ); | 488 | ConfigViewItem *configItem = static_cast<ConfigViewItem *>( item ); |
464 | if ( !configItem ) return; | 489 | if ( !configItem ) return; |
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; |
470 | } | 495 | } |
471 | 496 | ||
472 | if ( configItem->isOn() != configItem->resource()->isActive() ) { | 497 | if ( configItem->isOn() != configItem->resource()->isActive() ) { |
473 | emit changed( true ); | 498 | emit changed( true ); |
@@ -496,13 +521,13 @@ void ConfigPage::saveResourceSettings() | |||
496 | 521 | ||
497 | item = item->nextSibling(); | 522 | item = item->nextSibling(); |
498 | } | 523 | } |
499 | mCurrentManager->writeConfig( mCurrentConfig ); | 524 | mCurrentManager->writeConfig( mCurrentConfig ); |
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 | ||