summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/documentlist.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp
index 440bf1e..fdba687 100644
--- a/core/launcher/documentlist.cpp
+++ b/core/launcher/documentlist.cpp
@@ -54,24 +54,26 @@ static const int MAX_SEARCH_DEPTH = 10;
54class DocumentListPrivate : public QObject { 54class DocumentListPrivate : public QObject {
55 Q_OBJECT 55 Q_OBJECT
56public: 56public:
57 DocumentListPrivate( ServerInterface *gui ); 57 DocumentListPrivate( ServerInterface *gui );
58 ~DocumentListPrivate(); 58 ~DocumentListPrivate();
59 59
60 void initialize(); 60 void initialize();
61 61
62 const QString nextFile(); 62 const QString nextFile();
63 const DocLnk *iterate(); 63 const DocLnk *iterate();
64 bool store( DocLnk* dl ); 64 bool store( DocLnk* dl );
65 void estimatedPercentScanned(); 65 void estimatedPercentScanned();
66 void appendDocpath(FileSystem*);
67
66 68
67 DocLnkSet dls; 69 DocLnkSet dls;
68 QDict<void> reference; 70 QDict<void> reference;
69 QDictIterator<void> *dit; 71 QDictIterator<void> *dit;
70 enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state; 72 enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state;
71 73
72 QStringList docPaths; 74 QStringList docPaths;
73 unsigned int docPathsSearched; 75 unsigned int docPathsSearched;
74 76
75 int searchDepth; 77 int searchDepth;
76 QDir *listDirs[MAX_SEARCH_DEPTH]; 78 QDir *listDirs[MAX_SEARCH_DEPTH];
77 const QFileInfoList *lists[MAX_SEARCH_DEPTH]; 79 const QFileInfoList *lists[MAX_SEARCH_DEPTH];
@@ -418,45 +420,72 @@ DocumentListPrivate::DocumentListPrivate( ServerInterface *gui )
418 sendAppLnks = false; 420 sendAppLnks = false;
419 sendDocLnks = false; 421 sendDocLnks = false;
420 } 422 }
421 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { 423 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) {
422 listDirs[i] = 0; 424 listDirs[i] = 0;
423 lists[i] = 0; 425 lists[i] = 0;
424 listPositions[i] = 0; 426 listPositions[i] = 0;
425 } 427 }
426 initialize(); 428 initialize();
427 tid = 0; 429 tid = 0;
428} 430}
429 431
432void DocumentListPrivate::appendDocpath(FileSystem*fs)
433{
434 QDir defPath(fs->path()+"/Documents");
435 QFileInfo f(fs->path()+"/.opiestorage.cf");
436 if (!f.exists()) {
437 if (defPath.exists()) {
438 docPaths+=defPath.path();
439 }
440 return;
441 }
442 Config conf(f.filePath(), Config::File );
443 conf.setGroup("subdirs");
444 QStringList subDirs = conf.readListEntry("subdirs",':');
445 if (subDirs.isEmpty()) {
446 if (defPath.exists()) {
447 docPaths+=defPath.path();
448 }
449 return;
450 }
451 for (unsigned c = 0; c < subDirs.count();++c) {
452 QDir docDir(QString(fs->path()+"/"+subDirs[c]));
453 if (docDir.exists()) {
454 docPaths+=docDir.path();
455 }
456 }
457}
430 458
431void DocumentListPrivate::initialize() 459void DocumentListPrivate::initialize()
432{ 460{
433 // Reset 461 // Reset
434 dls.clear(); 462 dls.clear();
435 docPaths.clear(); 463 docPaths.clear();
436 reference.clear(); 464 reference.clear();
437 465
438 QDir docDir( QPEApplication::documentDir() ); 466 QDir docDir( QPEApplication::documentDir() );
439 if ( docDir.exists() ) 467 if ( docDir.exists() )
440 docPaths += QPEApplication::documentDir(); 468 docPaths += QPEApplication::documentDir();
441 int i = 1; 469 int i = 1;
442 const QList<FileSystem> &fs = storage->fileSystems(); 470 const QList<FileSystem> &fs = storage->fileSystems();
443 QListIterator<FileSystem> it( fs ); 471 QListIterator<FileSystem> it( fs );
444 for ( ; it.current(); ++it ) 472 for ( ; it.current(); ++it ) {
445 if ( (*it)->isRemovable() ) { 473 if ( (*it)->isRemovable() ) {
446 docPaths += (*it)->path(); 474 appendDocpath((*it));
447 i++; 475 ++i;
448 } 476 }
477 }
449 478
450 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { 479 for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) {
451 if ( listDirs[i] ) { 480 if ( listDirs[i] ) {
452 delete listDirs[i]; 481 delete listDirs[i];
453 listDirs[i] = 0; 482 listDirs[i] = 0;
454 } 483 }
455 lists[i] = 0; 484 lists[i] = 0;
456 listPositions[i] = 0; 485 listPositions[i] = 0;
457 } 486 }
458 487
459 docPathsSearched = 0; 488 docPathsSearched = 0;
460 searchDepth = -1; 489 searchDepth = -1;
461 state = Find; 490 state = Find;
462 dit = 0; 491 dit = 0;