-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 | |||
@@ -316,38 +316,126 @@ void DocumentList::linkChanged( QString arg ) | |||
316 | DocLnk* dl = new DocLnk( arg ); | 316 | DocLnk* dl = new DocLnk( arg ); |
317 | if ( d->store( dl ) ) { | 317 | if ( d->store( dl ) ) { |
318 | // Add if it's a link we are interested in | 318 | // Add if it's a link we are interested in |
319 | //odebug << "add case" << oendl; | 319 | //odebug << "add case" << oendl; |
320 | add( *dl ); | 320 | add( *dl ); |
321 | } | 321 | } |
322 | 322 | ||
323 | } | 323 | } |
324 | } | 324 | } |
325 | 325 | ||
326 | void DocumentList::restoreDone() | 326 | void DocumentList::restoreDone() |
327 | { | 327 | { |
328 | reloadAppLnks(); | 328 | reloadAppLnks(); |
329 | reloadDocLnks(); | 329 | reloadDocLnks(); |
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 |
340 | // links appropriately. | 428 | // links appropriately. |
341 | // rescan(); | 429 | // rescan(); |
342 | } | 430 | } |
343 | 431 | ||
344 | void DocumentList::sendAllDocLinks() | 432 | void 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; |
350 | return; | 438 | return; |
351 | } | 439 | } |
352 | 440 | ||
353 | QString contents; | 441 | QString contents; |
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 | |||
@@ -29,32 +29,33 @@ class DocumentListPrivate; | |||
29 | class ServerInterface; | 29 | class ServerInterface; |
30 | 30 | ||
31 | class DocumentList : public QObject { | 31 | class DocumentList : public QObject { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | public: | 33 | public: |
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(); |
56 | signals: | 57 | signals: |
57 | void added( const DocLnk& doc ); | 58 | void added( const DocLnk& doc ); |
58 | void removed( const DocLnk& doc ); | 59 | void removed( const DocLnk& doc ); |
59 | void changed( const DocLnk& oldDoc, const DocLnk& newDoc ); | 60 | void changed( const DocLnk& oldDoc, const DocLnk& newDoc ); |
60 | void allRemoved(); | 61 | void allRemoved(); |