-rw-r--r-- | core/launcher/documentlist.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp index 39dc7c9..63f853e 100644 --- a/core/launcher/documentlist.cpp +++ b/core/launcher/documentlist.cpp @@ -380,247 +380,254 @@ void DocumentList::sendAllDocLinks() //qDebug( "sending length %d", contents.length() ); #ifndef QT_NO_COP QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); e << contents; #endif //qDebug( "================ \n\n%s\n\n===============", contents.latin1() ); d->needToSendAllDocLinks = false; } DocumentListPrivate::DocumentListPrivate( ServerInterface *gui ) { storage = new StorageInfo( this ); serverGui = gui; if ( serverGui ) { sendAppLnks = serverGui->requiresApplications(); sendDocLnks = serverGui->requiresDocuments(); } else { sendAppLnks = false; sendDocLnks = false; } for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { listDirs[i] = 0; lists[i] = 0; listPositions[i] = 0; } initialize(); tid = 0; } void DocumentListPrivate::appendDocpath(FileSystem*fs) { QDir defPath(fs->path()+"/Documents"); QFileInfo f(fs->path()+"/.opiestorage.cf"); if (!f.exists()) { Mediadlg dlg(fs); if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) { return; } } Config conf(f.filePath(), Config::File ); + conf.setGroup("main"); + if (!conf.readBoolEntry("check",false)) { + return; + } conf.setGroup("subdirs"); bool read_all = conf.readBoolEntry("wholemedia",true); if (read_all) { docPaths+=fs->path(); return; } QStringList subDirs = conf.readListEntry("subdirs",':'); if (subDirs.isEmpty()) { if (defPath.exists()) { docPaths+=defPath.path(); } return; } for (unsigned c = 0; c < subDirs.count();++c) { QDir docDir(QString(fs->path()+"/"+subDirs[c])); if (docDir.exists()) { docPaths+=docDir.path(); } } } void DocumentListPrivate::initialize() { // Reset dls.clear(); docPaths.clear(); reference.clear(); QDir docDir( QPEApplication::documentDir() ); if ( docDir.exists() ) docPaths += QPEApplication::documentDir(); int i = 1; const QList<FileSystem> &fs = storage->fileSystems(); QListIterator<FileSystem> it( fs ); for ( ; it.current(); ++it ) { if ( (*it)->isRemovable() ) { appendDocpath((*it)); ++i; } } for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) { if ( listDirs[i] ) { delete listDirs[i]; listDirs[i] = 0; } lists[i] = 0; listPositions[i] = 0; } docPathsSearched = 0; searchDepth = -1; state = Find; dit = 0; } DocumentListPrivate::~DocumentListPrivate() { for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) if ( listDirs[i] ) delete listDirs[i]; delete dit; } void DocumentListPrivate::estimatedPercentScanned() { double overallProgress = 0.0; double levelWeight = 75.0; int topCount = docPaths.count(); if ( topCount > 1 ) { levelWeight = levelWeight / topCount; overallProgress += (docPathsSearched - 1) * levelWeight; } for ( int d = 0; d <= searchDepth; d++ ) { if ( listDirs[d] ) { int items = lists[d]->count(); if ( items > 1 ) { levelWeight = levelWeight / items; // Take in to account "." and ".." overallProgress += (listPositions[d] - 3) * levelWeight; } } else { break; } } // qDebug( "overallProgress: %f", overallProgress ); if ( serverGui ) serverGui->documentScanningProgress( (int)overallProgress ); } const QString DocumentListPrivate::nextFile() { while ( TRUE ) { while ( searchDepth < 0 ) { // go to next base path if ( docPathsSearched >= docPaths.count() ) { // end of base paths return QString::null; } else { QDir dir( docPaths[docPathsSearched] ); // qDebug("now using base path: %s", docPaths[docPathsSearched].latin1() ); docPathsSearched++; if ( !dir.exists( ".Qtopia-ignore" ) ) { listDirs[0] = new QDir( dir ); lists[0] = listDirs[0]->entryInfoList(); listPositions[0] = 0; searchDepth = 0; } } } const QFileInfoList *fil = lists[searchDepth]; + if (!fil) { + return QString::null; + } QFileInfoList *fl = (QFileInfoList *)fil; unsigned int pos = listPositions[searchDepth]; if ( pos >= fl->count() ) { // go up a depth delete listDirs[searchDepth]; listDirs[searchDepth] = 0; lists[searchDepth] = 0; listPositions[searchDepth] = 0; searchDepth--; } else { const QFileInfo *fi = fl->at(pos); listPositions[searchDepth]++; QString bn = fi->fileName(); if ( bn[0] != '.' ) { if ( fi->isDir() ) { if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) { // go down a depth QDir dir( fi->filePath() ); // qDebug("now going in to path: %s", bn.latin1() ); if ( !dir.exists( ".Qtopia-ignore" ) ) { if ( searchDepth < MAX_SEARCH_DEPTH - 1) { searchDepth++; listDirs[searchDepth] = new QDir( dir ); lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); listPositions[searchDepth] = 0; } } } } else { estimatedPercentScanned(); return fl->at(pos)->filePath(); } } } } return QString::null; } bool DocumentListPrivate::store( DocLnk* dl ) { // if ( dl->fileKnown() && !dl->file().isEmpty() ) { if ( dl && dl->fileKnown() ) { dls.add( dl ); // store return TRUE; } // don't store - delete delete dl; return FALSE; } #define MAGIC_NUMBER ((void*)2) const DocLnk *DocumentListPrivate::iterate() { if ( state == Find ) { //qDebug("state Find"); QString file = nextFile(); while ( !file.isNull() ) { if ( file.right(8) == ".desktop" ) { // No tr |