summaryrefslogtreecommitdiff
path: root/core/launcher/documentlist.cpp
Unidiff
Diffstat (limited to 'core/launcher/documentlist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/documentlist.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp
index 19ceb0f..44ceb0c 100644
--- a/core/launcher/documentlist.cpp
+++ b/core/launcher/documentlist.cpp
@@ -294,231 +294,231 @@ void DocumentList::linkChanged( QString arg )
294 if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) 294 if ( ( doc->linkFileKnown() && doc->linkFile() == arg )
295 || ( doc->fileKnown() && doc->file() == arg ) ) { 295 || ( doc->fileKnown() && doc->file() == arg ) ) {
296 //odebug << "found old link" << oendl; 296 //odebug << "found old link" << oendl;
297 DocLnk* dl = new DocLnk( arg ); 297 DocLnk* dl = new DocLnk( arg );
298 // add new one if it exists and matches the mimetype 298 // add new one if it exists and matches the mimetype
299 if ( d->store( dl ) ) { 299 if ( d->store( dl ) ) {
300 // Existing link has been changed, send old link ref and a ref 300 // Existing link has been changed, send old link ref and a ref
301 // to the new link 301 // to the new link
302 //odebug << "change case" << oendl; 302 //odebug << "change case" << oendl;
303 if ( d->serverGui ) 303 if ( d->serverGui )
304 d->serverGui->documentChanged( *doc, *dl ); 304 d->serverGui->documentChanged( *doc, *dl );
305 305
306 } else { 306 } else {
307 // Link has been removed or doesn't match the mimetypes any more 307 // Link has been removed or doesn't match the mimetypes any more
308 // so we aren't interested in it, so take it away from the list 308 // so we aren't interested in it, so take it away from the list
309 //odebug << "removal case" << oendl; 309 //odebug << "removal case" << oendl;
310 if ( d->serverGui ) 310 if ( d->serverGui )
311 d->serverGui->documentRemoved( *doc ); 311 d->serverGui->documentRemoved( *doc );
312 312
313 } 313 }
314 d->dls.remove( doc ); // remove old link from docLnkSet 314 d->dls.remove( doc ); // remove old link from docLnkSet
315 delete doc; 315 delete doc;
316 return; 316 return;
317 } 317 }
318 } 318 }
319 // Didn't find existing link, must be new 319 // Didn't find existing link, must be new
320 DocLnk* dl = new DocLnk( arg ); 320 DocLnk* dl = new DocLnk( arg );
321 if ( d->store( dl ) ) { 321 if ( d->store( dl ) ) {
322 // Add if it's a link we are interested in 322 // Add if it's a link we are interested in
323 //odebug << "add case" << oendl; 323 //odebug << "add case" << oendl;
324 add( *dl ); 324 add( *dl );
325 } 325 }
326 326
327 } 327 }
328} 328}
329 329
330void DocumentList::restoreDone() 330void DocumentList::restoreDone()
331{ 331{
332 reloadAppLnks(); 332 reloadAppLnks();
333 reloadDocLnks(); 333 reloadDocLnks();
334} 334}
335 335
336void DocumentList::DiffAppLnks() 336void DocumentList::DiffAppLnks()
337{ 337{
338 static AppLnkSet *appLnkSet2; 338 static AppLnkSet *appLnkSet2;
339 339
340 appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() ); 340 appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() );
341 341
342 if ( d->sendAppLnks && d->serverGui ) { 342 if ( d->sendAppLnks && d->serverGui ) {
343 static QStringList prevTypeList = appLnkSet->types(); 343 static QStringList prevTypeList = appLnkSet->types();
344 QStringList types = appLnkSet2->types(); 344 QStringList types = appLnkSet2->types();
345 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { 345 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) {
346 if ( !(*ittypes).isEmpty() ) { 346 if ( !(*ittypes).isEmpty() ) {
347 if ( !prevTypeList.contains(*ittypes) ) { 347 if ( !prevTypeList.contains(*ittypes) ) {
348 QString name = appLnkSet2->typeName(*ittypes); 348 QString name = appLnkSet2->typeName(*ittypes);
349 QPixmap pm = appLnkSet2->typePixmap(*ittypes); 349 QPixmap pm = appLnkSet2->typePixmap(*ittypes);
350 QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes); 350 QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes);
351 351
352 if (pm.isNull()) { 352 if (pm.isNull()) {
353 QImage img( Resource::loadImage( "UnknownDocument" ) ); 353 QImage img( Resource::loadImage( "UnknownDocument" ) );
354 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 354 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
355 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); 355 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() );
356 } 356 }
357 357
358 odebug << "adding type " << (*ittypes) << "" << oendl; 358 odebug << "adding type " << (*ittypes) << "" << oendl;
359 359
360 // ### our current launcher expects docs tab to be last 360 // ### our current launcher expects docs tab to be last
361 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); 361 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
362 } 362 }
363 prevTypeList.remove(*ittypes); 363 prevTypeList.remove(*ittypes);
364 } 364 }
365 } 365 }
366 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { 366 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
367 odebug << "removing type " << (*ittypes) << "" << oendl; 367 odebug << "removing type " << (*ittypes) << "" << oendl;
368 d->serverGui->typeRemoved(*ittypes); 368 d->serverGui->typeRemoved(*ittypes);
369 } 369 }
370 prevTypeList = types; 370 prevTypeList = types;
371 } 371 }
372 372
373 373
374 QListIterator<AppLnk> it1( appLnkSet->children() ); 374 QListIterator<AppLnk> it1( appLnkSet->children() );
375 QListIterator<AppLnk> it2( appLnkSet2->children() ); 375 QListIterator<AppLnk> it2( appLnkSet2->children() );
376 376
377 AppLnk *i; 377 AppLnk *i;
378 AppLnk *j; 378 AppLnk *j;
379 bool found; 379 bool found;
380 380
381 while ( (j=it2.current()) ) { 381 while ( (j=it2.current()) ) {
382 it1 = appLnkSet->children(); 382 it1 = appLnkSet->children();
383 found = false; 383 found = false;
384 while ( (i=it1.current()) ){ 384 while ( (i=it1.current()) ){
385 if (strcmp(i->name().ascii(),j->name().ascii()) == 0) 385 if (strcmp(i->name().ascii(),j->name().ascii()) == 0)
386 found = true; 386 found = true;
387 ++it1; 387 ++it1;
388 } 388 }
389 if (!found) { 389 if (!found) {
390 qDebug("Item %s needs to be added",j->name().ascii() ); 390 odebug << "Item " << j->name().ascii() << " needs to be added" << oendl;
391 d->serverGui->applicationAdded( j->type(), *j ); 391 d->serverGui->applicationAdded( j->type(), *j );
392 } 392 }
393 ++it2; 393 ++it2;
394 } 394 }
395 395
396 it1 = appLnkSet->children(); 396 it1 = appLnkSet->children();
397 while ( (i=it1.current()) ) { 397 while ( (i=it1.current()) ) {
398 it2 = appLnkSet2->children(); 398 it2 = appLnkSet2->children();
399 found = false; 399 found = false;
400 while ( (j=it2.current()) ){ 400 while ( (j=it2.current()) ){
401 if (strcmp(i->name().ascii(),j->name().ascii()) == 0) 401 if (strcmp(i->name().ascii(),j->name().ascii()) == 0)
402 found = true; 402 found = true;
403 ++it2; 403 ++it2;
404 } 404 }
405 if (!found) { 405 if (!found) {
406 qDebug("Item %s needs to be removed",i->name().ascii() ); 406 odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl;
407 d->serverGui->applicationRemoved( i->type(), *i ); 407 d->serverGui->applicationRemoved( i->type(), *i );
408 } 408 }
409 409
410 ++it1; 410 ++it1;
411 } 411 }
412 412
413 delete appLnkSet; 413 delete appLnkSet;
414 appLnkSet = appLnkSet2; 414 appLnkSet = appLnkSet2;
415 415
416} 416}
417void DocumentList::storageChanged() 417void DocumentList::storageChanged()
418{ 418{
419 QTime t; 419 QTime t;
420 // ### can implement better 420 // ### can implement better
421 421
422 t.start(); 422 t.start();
423 DiffAppLnks(); 423 DiffAppLnks();
424// reloadAppLnks(); 424// reloadAppLnks();
425 qDebug("Reload App links took %i ms",t.elapsed() ); 425 odebug << "Reload App links took " << t.elapsed() << " ms" << oendl;
426 reloadDocLnks(); 426 reloadDocLnks();
427// odebug << "Reload links took " << t.elapsed() << " ms " << oendl; 427// odebug << "Reload links took " << t.elapsed() << " ms " << oendl;
428 qDebug("Reload All links took %i ms",t.elapsed() ); 428 odebug << "Reload All links took " << t.elapsed() << " ms" << oendl;
429// ### Optimization opportunity 429// ### Optimization opportunity
430 // Could be a bit more intelligent and somehow work out which 430 // Could be a bit more intelligent and somehow work out which
431 // mtab entry has changed and then only scan that and add and remove 431 // mtab entry has changed and then only scan that and add and remove
432 // links appropriately. 432 // links appropriately.
433// rescan(); 433// rescan();
434} 434}
435 435
436void DocumentList::sendAllDocLinks() 436void DocumentList::sendAllDocLinks()
437{ 437{
438 if ( d->tid != 0 ) { 438 if ( d->tid != 0 ) {
439 // We are in the middle of scanning, set a flag so 439 // We are in the middle of scanning, set a flag so
440 // we do this when we finish our scanning 440 // we do this when we finish our scanning
441 d->needToSendAllDocLinks = true; 441 d->needToSendAllDocLinks = true;
442 return; 442 return;
443 } 443 }
444 444
445 QString contents; 445 QString contents;
446 Categories cats; 446 Categories cats;
447 for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) { 447 for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) {
448 DocLnk *doc = it.current(); 448 DocLnk *doc = it.current();
449 QFileInfo fi( doc->file() ); 449 QFileInfo fi( doc->file() );
450 if ( !fi.exists() ) 450 if ( !fi.exists() )
451 continue; 451 continue;
452 452
453 bool fake = !doc->linkFileKnown(); 453 bool fake = !doc->linkFileKnown();
454 if ( !fake ) { 454 if ( !fake ) {
455 QFile f( doc->linkFile() ); 455 QFile f( doc->linkFile() );
456 if ( f.open( IO_ReadOnly ) ) { 456 if ( f.open( IO_ReadOnly ) ) {
457 QTextStream ts( &f ); 457 QTextStream ts( &f );
458 ts.setEncoding( QTextStream::UnicodeUTF8 ); 458 ts.setEncoding( QTextStream::UnicodeUTF8 );
459 contents += ts.read(); 459 contents += ts.read();
460 f.close(); 460 f.close();
461 } else 461 } else
462 fake = TRUE; 462 fake = TRUE;
463 } 463 }
464 if (fake) { 464 if (fake) {
465 contents += "[Desktop Entry]\n"; // No tr 465 contents += "[Desktop Entry]\n"; // No tr
466 contents += "Categories = " + // No tr 466 contents += "Categories = " + // No tr
467 cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr 467 cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr
468 contents += "Name = "+doc->name()+"\n"; // No tr 468 contents += "Name = "+doc->name()+"\n"; // No tr
469 contents += "Type = "+doc->type()+"\n"; // No tr 469 contents += "Type = "+doc->type()+"\n"; // No tr
470 } 470 }
471 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) 471 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path)
472 contents += QString("Size = %1\n").arg( fi.size() ); // No tr 472 contents += QString("Size = %1\n").arg( fi.size() ); // No tr
473 } 473 }
474 474
475 //odebug << "sending length " << contents.length() << "" << oendl; 475 //odebug << "sending length " << contents.length() << "" << oendl;
476#ifndef QT_NO_COP 476#ifndef QT_NO_COP
477 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); 477 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
478 e << contents; 478 e << contents;
479#endif 479#endif
480 //odebug << "================ \n\n" << contents << "\n\n===============" << oendl; 480 //odebug << "================ \n\n" << contents << "\n\n===============" << oendl;
481 481
482 d->needToSendAllDocLinks = false; 482 d->needToSendAllDocLinks = false;
483} 483}
484 484
485 485
486 486
487 487
488 488
489 489
490 490
491 491
492 492
493 493
494 494
495 495
496 496
497 497
498 498
499 499
500 500
501 501
502 502
503 503
504 504
505 505
506 506
507 507
508DocumentListPrivate::DocumentListPrivate( ServerInterface *gui ) 508DocumentListPrivate::DocumentListPrivate( ServerInterface *gui )
509{ 509{
510 storage = new StorageInfo( this ); 510 storage = new StorageInfo( this );
511 serverGui = gui; 511 serverGui = gui;
512 if ( serverGui ) { 512 if ( serverGui ) {
513 sendAppLnks = serverGui->requiresApplications(); 513 sendAppLnks = serverGui->requiresApplications();
514 sendDocLnks = serverGui->requiresDocuments(); 514 sendDocLnks = serverGui->requiresDocuments();
515 } else { 515 } else {
516 sendAppLnks = false; 516 sendAppLnks = false;
517 sendDocLnks = false; 517 sendDocLnks = false;
518 } 518 }
519 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { 519 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) {
520 listDirs[i] = 0; 520 listDirs[i] = 0;
521 lists[i] = 0; 521 lists[i] = 0;
522 listPositions[i] = 0; 522 listPositions[i] = 0;
523 } 523 }
524 initialize(); 524 initialize();