summaryrefslogtreecommitdiffabout
path: root/microkde/kresources/configpage.cpp
Unidiff
Diffstat (limited to 'microkde/kresources/configpage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/configpage.cpp75
1 files changed, 50 insertions, 25 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
@@ -22,4 +22,11 @@
22*/ 22*/
23 23
24/*
25Enhanced Version of the file for platform independent KDE tools.
26Copyright (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 @@
51using namespace KRES; 58using namespace KRES;
52 59
60const QString ConfigPage::syncfamily = "syncprofiles";
61
62
53class ConfigViewItem : public QCheckListItem 63class 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