From e084a79b8aa0174e7587893f9b87d88670ed9f2c Mon Sep 17 00:00:00 2001 From: ulf69 Date: Mon, 02 Aug 2004 18:15:04 +0000 Subject: added support for the syncing of resources --- (limited to 'microkde/kresources/configpage.cpp') 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 @@ -21,6 +21,13 @@ Boston, MA 02111-1307, USA. */ +/* +Enhanced Version of the file for platform independent KDE tools. +Copyright (c) 2004 Ulf Schenk + +$Id$ +*/ + #include #include #include @@ -50,6 +57,9 @@ using namespace KRES; +const QString ConfigPage::syncfamily = "syncprofiles"; + + class ConfigViewItem : public QCheckListItem { public: @@ -164,13 +174,15 @@ void ConfigPage::load() //US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" ); //US QString family = tmp.toString(); QStringList families; - families << "contact" << "sync-contacts"; + families << "contact" << syncfamily; + + for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) - { + { QString family = (*it); if ( !family.isEmpty() ) { if ( !mFamilyMap.contains( family ) ) { - mCurrentManager = new Manager( family ); + mCurrentManager = new Manager( family, (family == syncfamily) ); if ( mCurrentManager ) { mFamilyMap.append( family ); mCurrentManager->addListener( this ); @@ -228,7 +240,7 @@ void ConfigPage::slotFamilyChanged( int pos ) mFamily = mFamilyMap[ pos ]; //US qDebug("ConfigPage::slotFamilyChanged 4 family=%s", mFamily.latin1()); - + mCurrentManager = mInfoMap[ pos ].mManager; mCurrentConfig = mInfoMap[ pos ].mConfig; @@ -239,22 +251,22 @@ void ConfigPage::slotFamilyChanged( int pos ) if ( mCurrentManager->isEmpty() ) { //US qDebug("ConfigPage::slotFamilyChanged 4.1 mCurrentManager=%ul", mCurrentManager ); - + defaults(); } - + Resource *standardResource = mCurrentManager->standardResource(); - + //US qDebug("ConfigPage::slotFamilyChanged 4.4 resourcename=%s", standardResource->resourceName().latin1()); - + Manager::Iterator it; for ( it = mCurrentManager->begin(); it != mCurrentManager->end(); ++it ) { ConfigViewItem *item = new ConfigViewItem( mListView, *it ); if ( *it == standardResource ) item->setStandard( true ); } - + if ( mListView->childCount() == 0 ) { //US qDebug("ConfigPage::slotFamilyChanged 4.5 "); @@ -263,12 +275,12 @@ void ConfigPage::slotFamilyChanged( int pos ) mCurrentManager->writeConfig( mCurrentConfig ); } else { //US qDebug("ConfigPage::slotFamilyChanged 4.6 "); - + if ( !standardResource ) { - KMessageBox::sorry( this, i18n( "There is no standard resource! Please select one." ) ); - + KMessageBox::sorry( this, i18n( "There is no standard resource!
Please select one." ) ); + //US qDebug("ConfigPage::slotFamilyChanged 4.7" ); - + } emit changed( false ); @@ -283,9 +295,22 @@ void ConfigPage::slotAdd() QStringList types = mCurrentManager->resourceTypeNames(); QStringList descs = mCurrentManager->resourceTypeDescriptions(); bool ok = false; - QString desc = QInputDialog::getItem( i18n( "Resource Configuration" ), - i18n( "Please select type of the new resource:" ), descs, 0, + + QString desc; + + if (mFamily == syncfamily) + { + desc = QInputDialog::getItem( i18n( "Sync Configuration" ), + i18n( "Please select resource type for new sync profile:" ), descs, 0, + false, &ok, this ); + } + else + { + desc = QInputDialog::getItem( i18n( "Resource Configuration" ), + i18n( "Please select type of the new resource:" ), descs, 0, false, &ok, this ); + } + if ( !ok ) return; @@ -380,7 +405,7 @@ void ConfigPage::slotEdit() configItem->setText( 1, resource->type() ); if ( configItem->standard() && configItem->readOnly() ) { - KMessageBox::sorry( this, i18n( "You cannot use a read-only resource as standard!" ) ); + KMessageBox::sorry( this, i18n( "You cannot use a read-only
resource as standard!" ) ); configItem->setStandard( false ); } @@ -399,12 +424,12 @@ void ConfigPage::slotStandard() return; if ( item->readOnly() ) { - KMessageBox::sorry( this, i18n( "You cannot use a read-only resource as standard!" ) ); + KMessageBox::sorry( this, i18n( "You cannot use a read-only
resource as standard!" ) ); return; } if ( !item->isOn() ) { - KMessageBox::sorry( this, i18n( "You cannot use an inactive resource as standard!" ) ); + KMessageBox::sorry( this, i18n( "You cannot use an inactive
resource as standard!" ) ); return; } @@ -464,7 +489,7 @@ void ConfigPage::slotItemClicked( QListViewItem *item ) if ( !configItem ) return; if ( configItem->standard() && !configItem->isOn() ) { - KMessageBox::sorry( this, i18n( "You cannot deactivate the standard resource. Choose another standard resource first." ) ); + KMessageBox::sorry( this, i18n( "You cannot deactivate the
standard resource. Choose
another standard resource first." ) ); configItem->setOn( true ); return; } @@ -479,7 +504,7 @@ void ConfigPage::saveResourceSettings() qDebug("ConfigPage::saveResourceSettings() begin"); if ( mCurrentManager ) { - + QListViewItem *item = mListView->firstChild(); while ( item ) { ConfigViewItem *configItem = static_cast( item ); @@ -487,10 +512,10 @@ void ConfigPage::saveResourceSettings() // check if standard resource if ( configItem->standard() && !configItem->readOnly() && configItem->isOn() ) { - + mCurrentManager->setStandardResource( configItem->resource() ); } - + // check if active or passive resource configItem->resource()->setActive( configItem->isOn() ); @@ -499,11 +524,11 @@ void ConfigPage::saveResourceSettings() mCurrentManager->writeConfig( mCurrentConfig ); if ( !mCurrentManager->standardResource() ) - KMessageBox::sorry( this, i18n( "There is no valid standard resource! Please select one which is neither read-only nor inactive." ) ); + KMessageBox::sorry( this, i18n( "There is no valid standard resource!
Please select one which is neither read-only nor inactive." ) ); } - + qDebug("ConfigPage::saveResourceSettings() end"); - + } //US #include "configpage.moc" -- cgit v0.9.0.2