author | zecke <zecke> | 2002-03-24 19:30:27 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-03-24 19:30:27 (UTC) |
commit | 4802684dd785274be50b472c87e315da0e325449 (patch) (side-by-side diff) | |
tree | e15bb479f443d5ce410ccbd9368e663213210517 /core | |
parent | 6ce8bbff9eb16e0d731755010bda63e7fb43f70b (diff) | |
download | opie-4802684dd785274be50b472c87e315da0e325449.zip opie-4802684dd785274be50b472c87e315da0e325449.tar.gz opie-4802684dd785274be50b472c87e315da0e325449.tar.bz2 |
Hija this adds the "Do you want to scan this device?"
to launcher and should speed up some things.
Please test launcher and report bugs to me
-rw-r--r-- | core/launcher/launcher.cpp | 84 | ||||
-rw-r--r-- | core/launcher/mediummountgui.cpp | 10 |
2 files changed, 66 insertions, 28 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 1c38a05..cf1a3c8 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp @@ -78,2 +78,33 @@ // uidGen +namespace { + QStringList configToMime( Config *cfg ){ + QStringList mimes; + bool tmpMime; + cfg->setGroup("mimetypes" ); + tmpMime = cfg->readBoolEntry("all" ,false); + if( tmpMime ){ + mimes << QString::null; + return mimes; + }else{ + tmpMime = cfg->readBoolEntry("audio", true ); + if(tmpMime ) + mimes.append("audio//*" ); + + tmpMime = cfg->readBoolEntry("image", true ); + if(tmpMime ) + mimes.append("image//*" ); + + tmpMime = cfg->readBoolEntry("text", true ); + if(tmpMime ) + mimes.append("text//*"); + + tmpMime = cfg->readBoolEntry("video", true ); + if(tmpMime ) + mimes.append("video//*" ); + } + return mimes; + } + +} + @@ -428,4 +459,4 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) docsFolder = 0; - int stamp = uidgen.generate(); - uidgen.store( stamp ); + int stamp = uidgen.generate(); // this is our timestamp to see which devices we know + //uidgen.store( stamp ); m_timeStamp = QString::number( stamp ); @@ -513,2 +544,7 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global:: qWarning("new DocLnkSet" ); + DocLnkSet *tmp = 0; + QString home = QString(getenv("HOME")) + "/Documents"; + tmp = new DocLnkSet( home , QString::null); + docsFolder->appendFrom( *tmp ); + delete tmp; // find out wich filesystems are new in this round @@ -519,12 +555,7 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global:: - QString newStamp = QString::number( stamp ); - qWarning("new time stamp is: %s", newStamp.latin1() ); + QString newStamp = QString::number( stamp ); // generates newtime Stamp StorageInfo storage; const QList<FileSystem> &fileSystems = storage.fileSystems(); - qWarning("QList<FileSystem>" ); QListIterator<FileSystem> it ( fileSystems ); - qWarning("iterator initiliazed" ); for ( ; it.current(); ++it ) { - qWarning("inside for loop" ); - qWarning("checking device %s", (*it)->path().latin1() ); if ( (*it)->isRemovable() ) { // let's find out if we should search on it @@ -535,20 +566,28 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global:: if( stamp == m_timeStamp ){ // ok we know this card - qWarning("time stamp match" ); - cfg.writeEntry("timestamp", newStamp ); + cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp // we need to scan the list now. Hopefully the cache will be there - }else{ // come up with the gui - qWarning("time stamp doesn't match" ); + // read the mimetypes from the config and search for documents + QStringList mimetypes = configToMime( &cfg); + tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); + docsFolder->appendFrom( *tmp ); + delete tmp; + + }else{ // come up with the gui cause this a new card MediumMountGui medium((*it)->path() ); - qWarning("medium mount gui created" ); - if( medium.check() ){ - qWarning("need to check this device" ); - if( medium.exec() ){ //ok + if( medium.check() ){ // we did not ask before or ask again is off + if( medium.exec() ){ // he clicked yes so search it // speicher - qWarning("execed" ); - cfg.read(); + cfg.read(); // cause of a race we need to reread cfg.writeEntry("timestamp", newStamp ); - } - }else{ - qWarning("wrong :(" ); + }// no else + }else{ // we checked // do something different see what we need to do + // let's see if we should check the device + cfg.setGroup("main" ); + bool check = cfg.readBoolEntry("autocheck", true ); + if( check ){ // find the documents + tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); + docsFolder->appendFrom( *tmp ); + delete tmp; + } } @@ -557,5 +596,2 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global:: } - qWarning("findDocuments" ); - Global::findDocuments(docsFolder); // get rid of this call later - qWarning("done" ); m_timeStamp = newStamp; diff --git a/core/launcher/mediummountgui.cpp b/core/launcher/mediummountgui.cpp index e3fa5bd..f0de85b 100644 --- a/core/launcher/mediummountgui.cpp +++ b/core/launcher/mediummountgui.cpp @@ -82,5 +82,6 @@ void MediumMountGui::writeConfig(bool autocheck) { - // if all is checked then add only "null" to the list. + // if all is checked then add only "QString::null" to the list. if (checkmimeall) { - mimeTypeList += ("null"); + mimeTypeList.clear(); + mimeTypeList += QString::null; } else { @@ -99,6 +100,7 @@ void MediumMountGui::writeConfig(bool autocheck) { if (checkmimeall) { - mimeTypeList << ("null"); + mimeTypeList.clear(); + mimeTypeList << QString::null; } } - cfg.write(); + cfg.write(); // not really needed here but just to be sure } |