author | brad <brad> | 2004-04-12 07:01:55 (UTC) |
---|---|---|
committer | brad <brad> | 2004-04-12 07:01:55 (UTC) |
commit | 2c087dc52d50eb9b13670254f70347d7b1147b20 (patch) (unidiff) | |
tree | 79814aa2618a6a512a0e669ba2b6829ca13b7bdd | |
parent | 66f497a5c7990d7e54cc1ae26995231ade55b86c (diff) | |
download | opie-2c087dc52d50eb9b13670254f70347d7b1147b20.zip opie-2c087dc52d50eb9b13670254f70347d7b1147b20.tar.gz opie-2c087dc52d50eb9b13670254f70347d7b1147b20.tar.bz2 |
Changed launcher to only add/remove icons/tabs that have changed when removable
media is mounted/unmounted. A card insert on my machine used to take 7500ms.
It now takes 548ms. Same with card removal.
Old code has been left as is an can be re-enabled with a simple comment.
-rw-r--r-- | core/launcher/documentlist.cpp | 92 | ||||
-rw-r--r-- | core/launcher/documentlist.h | 1 |
2 files changed, 91 insertions, 2 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp index 92b8c25..59dd721 100644 --- a/core/launcher/documentlist.cpp +++ b/core/launcher/documentlist.cpp | |||
@@ -330,10 +330,98 @@ void DocumentList::restoreDone() | |||
330 | } | 330 | } |
331 | 331 | ||
332 | void DocumentList::DiffAppLnks() | ||
333 | { | ||
334 | static AppLnkSet *appLnkSet2; | ||
335 | |||
336 | appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() ); | ||
337 | |||
338 | if ( d->sendAppLnks && d->serverGui ) { | ||
339 | static QStringList prevTypeList = appLnkSet->types(); | ||
340 | QStringList types = appLnkSet2->types(); | ||
341 | for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { | ||
342 | if ( !(*ittypes).isEmpty() ) { | ||
343 | if ( !prevTypeList.contains(*ittypes) ) { | ||
344 | QString name = appLnkSet2->typeName(*ittypes); | ||
345 | QPixmap pm = appLnkSet2->typePixmap(*ittypes); | ||
346 | QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes); | ||
347 | |||
348 | if (pm.isNull()) { | ||
349 | QImage img( Resource::loadImage( "UnknownDocument" ) ); | ||
350 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | ||
351 | bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); | ||
352 | } | ||
353 | |||
354 | odebug << "adding type " << (*ittypes) << "" << oendl; | ||
355 | |||
356 | // ### our current launcher expects docs tab to be last | ||
357 | d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); | ||
358 | } | ||
359 | prevTypeList.remove(*ittypes); | ||
360 | } | ||
361 | } | ||
362 | for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { | ||
363 | odebug << "removing type " << (*ittypes) << "" << oendl; | ||
364 | d->serverGui->typeRemoved(*ittypes); | ||
365 | } | ||
366 | prevTypeList = types; | ||
367 | } | ||
368 | |||
369 | |||
370 | QListIterator<AppLnk> it1( appLnkSet->children() ); | ||
371 | QListIterator<AppLnk> it2( appLnkSet2->children() ); | ||
372 | |||
373 | AppLnk *i; | ||
374 | AppLnk *j; | ||
375 | bool found; | ||
376 | |||
377 | while ( (j=it2.current()) ) { | ||
378 | it1 = appLnkSet->children(); | ||
379 | found = false; | ||
380 | while ( (i=it1.current()) ){ | ||
381 | if (strcmp(i->name().ascii(),j->name().ascii()) == 0) | ||
382 | found = true; | ||
383 | ++it1; | ||
384 | } | ||
385 | if (!found) { | ||
386 | qDebug("Item %s needs to be added",j->name().ascii() ); | ||
387 | d->serverGui->applicationAdded( j->type(), *j ); | ||
388 | } | ||
389 | ++it2; | ||
390 | } | ||
391 | |||
392 | it1 = appLnkSet->children(); | ||
393 | while ( (i=it1.current()) ) { | ||
394 | it2 = appLnkSet2->children(); | ||
395 | found = false; | ||
396 | while ( (j=it2.current()) ){ | ||
397 | if (strcmp(i->name().ascii(),j->name().ascii()) == 0) | ||
398 | found = true; | ||
399 | ++it2; | ||
400 | } | ||
401 | if (!found) { | ||
402 | qDebug("Item %s needs to be removed",i->name().ascii() ); | ||
403 | d->serverGui->applicationRemoved( i->type(), *i ); | ||
404 | } | ||
405 | |||
406 | ++it1; | ||
407 | } | ||
408 | |||
409 | delete appLnkSet; | ||
410 | appLnkSet = appLnkSet2; | ||
411 | |||
412 | } | ||
332 | void DocumentList::storageChanged() | 413 | void DocumentList::storageChanged() |
333 | { | 414 | { |
415 | QTime t; | ||
334 | // ### can implement better | 416 | // ### can implement better |
335 | reloadAppLnks(); | 417 | |
418 | t.start(); | ||
419 | DiffAppLnks(); | ||
420 | // reloadAppLnks(); | ||
421 | qDebug("Reload App links took %i ms",t.elapsed() ); | ||
336 | reloadDocLnks(); | 422 | reloadDocLnks(); |
337 | // ### Optimization opportunity | 423 | // odebug << "Reload links took " << t.elapsed() << " ms " << oendl; |
424 | qDebug("Reload All links took %i ms",t.elapsed() ); | ||
425 | // ### Optimization opportunity | ||
338 | // Could be a bit more intelligent and somehow work out which | 426 | // Could be a bit more intelligent and somehow work out which |
339 | // mtab entry has changed and then only scan that and add and remove | 427 | // mtab entry has changed and then only scan that and add and remove |
diff --git a/core/launcher/documentlist.h b/core/launcher/documentlist.h index bd5c031..232bb6a 100644 --- a/core/launcher/documentlist.h +++ b/core/launcher/documentlist.h | |||
@@ -43,4 +43,5 @@ public: | |||
43 | void reloadAppLnks(); | 43 | void reloadAppLnks(); |
44 | void reloadDocLnks(); | 44 | void reloadDocLnks(); |
45 | void DiffAppLnks(); | ||
45 | 46 | ||
46 | // Orig DocList stuff | 47 | // Orig DocList stuff |