-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 @@ -67,24 +67,55 @@ #include <stdio.h> #include <sys/vfs.h> #include <mntent.h> #endif #include <qpe/storage.h> #include "mediummountgui.h" //#define SHOW_ALL // uidGen // 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; + } + +} + CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : QVBox( parent ) { categoryBar = 0; stack = 0; } void CategoryTabWidget::prevTab() { if ( categoryBar ) { int n = categoryBar->count(); @@ -417,26 +448,26 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { setCaption( tr("Launcher") ); syncDialog = 0; // we have a pretty good idea how big we'll be setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); tabs = 0; rootFolder = 0; 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 ); tabs = new CategoryTabWidget( this ); tabs->setMaximumWidth( qApp->desktop()->width() ); setCentralWidget( tabs ); connect( tabs, SIGNAL(selected(const QString&)), this, SLOT(viewSelected(const QString&)) ); connect( tabs, SIGNAL(clicked(const AppLnk*)), this, SLOT(select(const AppLnk*))); connect( tabs, SIGNAL(rightPressed(AppLnk*)), this, SLOT(properties(AppLnk*))); @@ -502,71 +533,76 @@ void Launcher::updateMimeTypes(AppLnkSet* folder) MimeType::registerApp(*app); } } } void Launcher::loadDocs() // ok here comes a hack belonging to Global:: { qWarning("loading Documents" ); qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() ); delete docsFolder; docsFolder = new DocLnkSet; 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 // We will do this by having a timestamp inside each mountpoint // if the current timestamp doesn't match this is a new file system and // come up with our MediumMountGui :) let the hacking begin int stamp = uidgen.generate(); - 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 qWarning("%s is removeable", (*it)->path().latin1() ); OConfig cfg( (*it)->path() + "/.opiestorage.cf"); cfg.setGroup("main"); QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); 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; + } } } } } - qWarning("findDocuments" ); - Global::findDocuments(docsFolder); // get rid of this call later - qWarning("done" ); m_timeStamp = newStamp; } void Launcher::updateTabs() { MimeType::updateApplications(); // ### reads all applnks twice delete rootFolder; rootFolder = new AppLnkSet( MimeType::appsFolderName() ); loadDocs(); 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 @@ -71,45 +71,47 @@ void MediumMountGui::writeConfig(bool autocheck) { cfg.setGroup("mimetypes"); cfg.writeEntry("audio", CheckBoxAudio->isChecked() ); cfg.writeEntry("image",CheckBoxImage->isChecked() ); cfg.writeEntry("text",CheckBoxImage->isChecked() ); cfg.writeEntry("video",CheckBoxVideo->isChecked() ); cfg.writeEntry("all",CheckBoxAll->isChecked() ); cfg.setGroup("dirs"); cfg.writeEntry("dirs", ""); - // 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 { if (checkmimeaudio) { mimeTypeList += ("audio//*"); } if (checkmimetext) { mimeTypeList += ("text//*"); } if (checkmimevideo) { mimeTypeList += ("video//*"); } if (checkmimeimage) { mimeTypeList += ("image//*"); } if (checkmimeall) { - mimeTypeList << ("null"); + mimeTypeList.clear(); + mimeTypeList << QString::null; } } - cfg.write(); + cfg.write(); // not really needed here but just to be sure } void MediumMountGui::startGui() { QPixmap image = Resource::loadPixmap( "HelpBrowser"); Text_2 = new QLabel( this ); Text_2->setGeometry( QRect( 10, 15, 40, 40 ) ); Text_2->setPixmap( image ); Text = new QLabel( this, "Text" ); Text->setGeometry( QRect( 55, 11, this->width()-50, 50 ) ); |