summaryrefslogtreecommitdiff
authoralwin <alwin>2004-02-21 21:43:40 (UTC)
committer alwin <alwin>2004-02-21 21:43:40 (UTC)
commit1a89ecd8e2d11d48a8e80b2fd8b1e95b738a286c (patch) (side-by-side diff)
tree2c0aaf8487c87c23855dd06599b51c22fa8d6478
parentc7e563cbb26c20807e66dd4284d1ce9cbf8e1419 (diff)
downloadopie-1a89ecd8e2d11d48a8e80b2fd8b1e95b738a286c.zip
opie-1a89ecd8e2d11d48a8e80b2fd8b1e95b738a286c.tar.gz
opie-1a89ecd8e2d11d48a8e80b2fd8b1e95b738a286c.tar.bz2
on removable medias take a look into .opiestorage.cf and read the list
of subdirs of the media where to search for documents. If this value isn't set, it will reduce search to FS+"/Documents" so not the whole media is searched. ToDo: Work on mediummount that users can set this values. Implement same stuff in global.cpp of libqpe.
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
@@ -18,96 +18,98 @@
**
**********************************************************************/
#include "documentlist.h"
#include "serverinterface.h"
#include <opie2/oglobal.h>
#include <qtopia/config.h>
#include <qtopia/mimetype.h>
#include <qtopia/resource.h>
#include <qtopia/private/categories.h>
#include <qtopia/qpeapplication.h>
#include <qtopia/applnk.h>
#include <qtopia/storage.h>
#ifdef Q_WS_QWS
#include <qtopia/qcopenvelope_qws.h>
#endif
#include <qtimer.h>
#include <qfileinfo.h>
#include <qtextstream.h>
#include <qfile.h>
#include <qdir.h>
#include <qpainter.h>
#include <qimage.h>
#include <qcopchannel_qws.h>
#include <qlistview.h>
#include <qlist.h>
#include <qpixmap.h>
AppLnkSet *DocumentList::appLnkSet = 0;
static const int MAX_SEARCH_DEPTH = 10;
class DocumentListPrivate : public QObject {
Q_OBJECT
public:
DocumentListPrivate( ServerInterface *gui );
~DocumentListPrivate();
void initialize();
const QString nextFile();
const DocLnk *iterate();
bool store( DocLnk* dl );
void estimatedPercentScanned();
+ void appendDocpath(FileSystem*);
+
DocLnkSet dls;
QDict<void> reference;
QDictIterator<void> *dit;
enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state;
QStringList docPaths;
unsigned int docPathsSearched;
int searchDepth;
QDir *listDirs[MAX_SEARCH_DEPTH];
const QFileInfoList *lists[MAX_SEARCH_DEPTH];
unsigned int listPositions[MAX_SEARCH_DEPTH];
StorageInfo *storage;
int tid;
ServerInterface *serverGui;
bool needToSendAllDocLinks;
bool sendAppLnks;
bool sendDocLnks;
bool scanDocs;
};
/*
* scandocs will be read from Config
*/
DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/,
QObject *parent, const char *name )
: QObject( parent, name )
{
appLnkSet = new AppLnkSet( MimeType::appsFolderName() );
d = new DocumentListPrivate( serverGui );
d->needToSendAllDocLinks = false;
Config cfg( "Launcher" );
cfg.setGroup( "DocTab" );
d->scanDocs = cfg.readBoolEntry( "Enable", true );
qDebug( "DocumentList::DocumentList() : scanDocs = %d", d->scanDocs );
QTimer::singleShot( 10, this, SLOT( startInitialScan() ) );
}
void DocumentList::startInitialScan()
{
@@ -382,117 +384,144 @@ void DocumentList::sendAllDocLinks()
//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()) {
+ if (defPath.exists()) {
+ docPaths+=defPath.path();
+ }
+ return;
+ }
+ Config conf(f.filePath(), Config::File );
+ conf.setGroup("subdirs");
+ 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() ) {
- docPaths += (*it)->path();
- i++;
- }
+ for ( ; it.current(); ++it ) {
+ if ( (*it)->isRemovable() ) {
+ appendDocpath((*it));
+ ++i;
+ }
+ }
- for ( int i = 0; i < MAX_SEARCH_DEPTH; 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;
}
}