summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/documentlist.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp
index d2b9afa..b8bf4e0 100644
--- a/core/launcher/documentlist.cpp
+++ b/core/launcher/documentlist.cpp
@@ -329,145 +329,145 @@ void DocumentList::linkChanged( QString arg )
329 if ( d->store( dl ) ) { 329 if ( d->store( dl ) ) {
330 // Add if it's a link we are interested in 330 // Add if it's a link we are interested in
331 //odebug << "add case" << oendl; 331 //odebug << "add case" << oendl;
332 add( *dl ); 332 add( *dl );
333 } 333 }
334 334
335 } 335 }
336} 336}
337 337
338void DocumentList::restoreDone() 338void DocumentList::restoreDone()
339{ 339{
340 reloadAppLnks(); 340 reloadAppLnks();
341 reloadDocLnks(); 341 reloadDocLnks();
342} 342}
343 343
344void DocumentList::DiffAppLnks() 344void DocumentList::DiffAppLnks()
345{ 345{
346 static AppLnkSet *appLnkSet2; 346 static AppLnkSet *appLnkSet2;
347 347
348 appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() ); 348 appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() );
349 349
350 if ( d->sendAppLnks && d->serverGui ) { 350 if ( d->sendAppLnks && d->serverGui ) {
351 static QStringList prevTypeList = appLnkSet->types(); 351 static QStringList prevTypeList = appLnkSet->types();
352 QStringList types = appLnkSet2->types(); 352 QStringList types = appLnkSet2->types();
353 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { 353 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) {
354 if ( !(*ittypes).isEmpty() ) { 354 if ( !(*ittypes).isEmpty() ) {
355 if ( !prevTypeList.contains(*ittypes) ) { 355 if ( !prevTypeList.contains(*ittypes) ) {
356 QString name = appLnkSet2->typeName(*ittypes); 356 QString name = appLnkSet2->typeName(*ittypes);
357 QPixmap pm = appLnkSet2->typePixmap(*ittypes); 357 QPixmap pm = appLnkSet2->typePixmap(*ittypes);
358 QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes); 358 QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes);
359 359
360 if (pm.isNull()) { 360 if (pm.isNull()) {
361 QImage img( Resource::loadImage( "UnknownDocument" ) ); 361 QImage img( Resource::loadImage( "UnknownDocument" ) );
362 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 362 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
363 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); 363 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() );
364 } 364 }
365 365
366 odebug << "adding type " << (*ittypes) << "" << oendl; 366 odebug << "adding type " << (*ittypes) << "" << oendl;
367 367
368 // ### our current launcher expects docs tab to be last 368 // ### our current launcher expects docs tab to be last
369 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); 369 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
370 } 370 }
371 prevTypeList.remove(*ittypes); 371 prevTypeList.remove(*ittypes);
372 } 372 }
373 } 373 }
374 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { 374 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
375 odebug << "removing type " << (*ittypes) << "" << oendl; 375 odebug << "removing type " << (*ittypes) << "" << oendl;
376 d->serverGui->typeRemoved(*ittypes); 376 d->serverGui->typeRemoved(*ittypes);
377 } 377 }
378 prevTypeList = types; 378 prevTypeList = types;
379 } 379 }
380 380
381 381
382 QListIterator<AppLnk> it1( appLnkSet->children() ); 382 QListIterator<AppLnk> it1( appLnkSet->children() );
383 QListIterator<AppLnk> it2( appLnkSet2->children() ); 383 QListIterator<AppLnk> it2( appLnkSet2->children() );
384 384
385 AppLnk *i; 385 AppLnk *i;
386 AppLnk *j; 386 AppLnk *j;
387 bool found; 387 bool found;
388 388
389 while ( (j=it2.current()) ) { 389 while ( (j=it2.current()) ) {
390 it1 = appLnkSet->children(); 390 it1 = appLnkSet->children();
391 found = false; 391 found = false;
392 while ( (i=it1.current()) ){ 392 while ( (i=it1.current()) ){
393 if (strcmp(i->name().ascii(),j->name().ascii()) == 0) 393 if (j->name().ascii() && i->name().ascii() && strcmp(i->name().ascii(),j->name().ascii()) == 0)
394 found = true; 394 found = true;
395 ++it1; 395 ++it1;
396 } 396 }
397 if (!found) { 397 if (!found) {
398 odebug << "Item " << j->name().ascii() << " needs to be added" << oendl; 398 odebug << "Item " << j->name().ascii() << " needs to be added" << oendl;
399 d->serverGui->applicationAdded( j->type(), *j ); 399 d->serverGui->applicationAdded( j->type(), *j );
400 } 400 }
401 ++it2; 401 ++it2;
402 } 402 }
403 403
404 it1 = appLnkSet->children(); 404 it1 = appLnkSet->children();
405 while ( (i=it1.current()) ) { 405 while ( (i=it1.current()) ) {
406 it2 = appLnkSet2->children(); 406 it2 = appLnkSet2->children();
407 found = false; 407 found = false;
408 while ( (j=it2.current()) ){ 408 while ( (j=it2.current()) ){
409 if (strcmp(i->name().ascii(),j->name().ascii()) == 0) 409 if (j->name().ascii() && i->name().ascii() && strcmp(i->name().ascii(),j->name().ascii()) == 0)
410 found = true; 410 found = true;
411 ++it2; 411 ++it2;
412 } 412 }
413 if (!found) { 413 if (!found) {
414 odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl; 414 odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl;
415 d->serverGui->applicationRemoved( i->type(), *i ); 415 d->serverGui->applicationRemoved( i->type(), *i );
416 } 416 }
417 417
418 ++it1; 418 ++it1;
419 } 419 }
420 420
421 delete appLnkSet; 421 delete appLnkSet;
422 appLnkSet = appLnkSet2; 422 appLnkSet = appLnkSet2;
423 423
424} 424}
425void DocumentList::storageChanged() 425void DocumentList::storageChanged()
426{ 426{
427 QTime t; 427 QTime t;
428 // ### can implement better 428 // ### can implement better
429 429
430 t.start(); 430 t.start();
431 DiffAppLnks(); 431 DiffAppLnks();
432// reloadAppLnks(); 432// reloadAppLnks();
433 odebug << "Reload App links took " << t.elapsed() << " ms" << oendl; 433 odebug << "Reload App links took " << t.elapsed() << " ms" << oendl;
434 reloadDocLnks(); 434 reloadDocLnks();
435// odebug << "Reload links took " << t.elapsed() << " ms " << oendl; 435// odebug << "Reload links took " << t.elapsed() << " ms " << oendl;
436 odebug << "Reload All links took " << t.elapsed() << " ms" << oendl; 436 odebug << "Reload All links took " << t.elapsed() << " ms" << oendl;
437// ### Optimization opportunity 437// ### Optimization opportunity
438 // Could be a bit more intelligent and somehow work out which 438 // Could be a bit more intelligent and somehow work out which
439 // mtab entry has changed and then only scan that and add and remove 439 // mtab entry has changed and then only scan that and add and remove
440 // links appropriately. 440 // links appropriately.
441// rescan(); 441// rescan();
442} 442}
443 443
444void DocumentList::sendAllDocLinks() 444void DocumentList::sendAllDocLinks()
445{ 445{
446 if ( d->tid != 0 ) { 446 if ( d->tid != 0 ) {
447 // We are in the middle of scanning, set a flag so 447 // We are in the middle of scanning, set a flag so
448 // we do this when we finish our scanning 448 // we do this when we finish our scanning
449 d->needToSendAllDocLinks = true; 449 d->needToSendAllDocLinks = true;
450 return; 450 return;
451 } 451 }
452 452
453 QString contents; 453 QString contents;
454 Categories cats; 454 Categories cats;
455 for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) { 455 for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) {
456 DocLnk *doc = it.current(); 456 DocLnk *doc = it.current();
457 QFileInfo fi( doc->file() ); 457 QFileInfo fi( doc->file() );
458 if ( !fi.exists() ) 458 if ( !fi.exists() )
459 continue; 459 continue;
460 460
461 bool fake = !doc->linkFileKnown(); 461 bool fake = !doc->linkFileKnown();
462 if ( !fake ) { 462 if ( !fake ) {
463 QFile f( doc->linkFile() ); 463 QFile f( doc->linkFile() );
464 if ( f.open( IO_ReadOnly ) ) { 464 if ( f.open( IO_ReadOnly ) ) {
465 QTextStream ts( &f ); 465 QTextStream ts( &f );
466 ts.setEncoding( QTextStream::UnicodeUTF8 ); 466 ts.setEncoding( QTextStream::UnicodeUTF8 );
467 QString docLnk = ts.read(); 467 QString docLnk = ts.read();
468 // Strip out the (stale) LinkFile entry 468 // Strip out the (stale) LinkFile entry
469 int start = docLnk.find( "\nLinkFile = " ) + 1; 469 int start = docLnk.find( "\nLinkFile = " ) + 1;
470 if ( start > 0 ) { 470 if ( start > 0 ) {
471 int end = docLnk.find( "\n", start + 1 ) + 1; 471 int end = docLnk.find( "\n", start + 1 ) + 1;
472 contents += docLnk.left(start); 472 contents += docLnk.left(start);
473 contents += docLnk.mid(end); 473 contents += docLnk.mid(end);