summaryrefslogtreecommitdiff
authorbrad <brad>2004-04-12 07:01:55 (UTC)
committer brad <brad>2004-04-12 07:01:55 (UTC)
commit2c087dc52d50eb9b13670254f70347d7b1147b20 (patch) (unidiff)
tree79814aa2618a6a512a0e669ba2b6829ca13b7bdd
parent66f497a5c7990d7e54cc1ae26995231ade55b86c (diff)
downloadopie-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.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/documentlist.cpp92
-rw-r--r--core/launcher/documentlist.h1
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
@@ -320,30 +320,118 @@ void DocumentList::linkChanged( QString arg )
320 add( *dl ); 320 add( *dl );
321 } 321 }
322 322
323 } 323 }
324} 324}
325 325
326void DocumentList::restoreDone() 326void DocumentList::restoreDone()
327{ 327{
328 reloadAppLnks(); 328 reloadAppLnks();
329 reloadDocLnks(); 329 reloadDocLnks();
330} 330}
331 331
332void 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}
332void DocumentList::storageChanged() 413void 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
340 // links appropriately. 428 // links appropriately.
341// rescan(); 429// rescan();
342} 430}
343 431
344void DocumentList::sendAllDocLinks() 432void DocumentList::sendAllDocLinks()
345{ 433{
346 if ( d->tid != 0 ) { 434 if ( d->tid != 0 ) {
347 // We are in the middle of scanning, set a flag so 435 // We are in the middle of scanning, set a flag so
348 // we do this when we finish our scanning 436 // we do this when we finish our scanning
349 d->needToSendAllDocLinks = true; 437 d->needToSendAllDocLinks = true;
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
@@ -33,24 +33,25 @@ class DocumentList : public QObject {
33public: 33public:
34 DocumentList( ServerInterface *serverGui, bool scanDocs = TRUE, 34 DocumentList( ServerInterface *serverGui, bool scanDocs = TRUE,
35 QObject *parent = 0, const char *name = 0 ); 35 QObject *parent = 0, const char *name = 0 );
36 ~DocumentList(); 36 ~DocumentList();
37 37
38 void linkChanged( QString link ); 38 void linkChanged( QString link );
39 void restoreDone(); 39 void restoreDone();
40 void storageChanged(); 40 void storageChanged();
41 void sendAllDocLinks(); 41 void sendAllDocLinks();
42 42
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
47 void start(); 48 void start();
48 void pause(); 49 void pause();
49 void resume(); 50 void resume();
50 void rescan(); 51 void rescan();
51 52
52 static AppLnkSet *appLnkSet; 53 static AppLnkSet *appLnkSet;
53 54
54/* 55/*
55 void resend(); 56 void resend();
56signals: 57signals: