author | ulf69 <ulf69> | 2004-08-04 22:45:22 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-04 22:45:22 (UTC) |
commit | c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852 (patch) (unidiff) | |
tree | dc59744a6d59ba241e793ce051da485d0bf16d06 /microkde/kresources/configpage.cpp | |
parent | b83866e08ddcc5cb2734801977927f48b53a2e1c (diff) | |
download | kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.zip kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.tar.gz kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.tar.bz2 |
final changes for addressbook sync config dialog
Diffstat (limited to 'microkde/kresources/configpage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kresources/configpage.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
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 | |||
@@ -184,48 +184,50 @@ void ConfigPage::load() | |||
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 | ||
228 | void ConfigPage::save() | 230 | void ConfigPage::save() |
229 | { | 231 | { |
230 | saveResourceSettings(); | 232 | saveResourceSettings(); |
231 | 233 | ||
@@ -290,72 +292,79 @@ void ConfigPage::slotFamilyChanged( int pos ) | |||
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 | ||
300 | void ConfigPage::slotAdd() | 302 | void 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 ) |