author | zecke <zecke> | 2002-03-24 19:30:27 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-03-24 19:30:27 (UTC) |
commit | 4802684dd785274be50b472c87e315da0e325449 (patch) (unidiff) | |
tree | e15bb479f443d5ce410ccbd9368e663213210517 /core/launcher | |
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 | |||
@@ -76,6 +76,37 @@ | |||
76 | // uidGen | 76 | // uidGen |
77 | 77 | ||
78 | // uidGen | 78 | // uidGen |
79 | namespace { | ||
80 | QStringList configToMime( Config *cfg ){ | ||
81 | QStringList mimes; | ||
82 | bool tmpMime; | ||
83 | cfg->setGroup("mimetypes" ); | ||
84 | tmpMime = cfg->readBoolEntry("all" ,false); | ||
85 | if( tmpMime ){ | ||
86 | mimes << QString::null; | ||
87 | return mimes; | ||
88 | }else{ | ||
89 | tmpMime = cfg->readBoolEntry("audio", true ); | ||
90 | if(tmpMime ) | ||
91 | mimes.append("audio//*" ); | ||
92 | |||
93 | tmpMime = cfg->readBoolEntry("image", true ); | ||
94 | if(tmpMime ) | ||
95 | mimes.append("image//*" ); | ||
96 | |||
97 | tmpMime = cfg->readBoolEntry("text", true ); | ||
98 | if(tmpMime ) | ||
99 | mimes.append("text//*"); | ||
100 | |||
101 | tmpMime = cfg->readBoolEntry("video", true ); | ||
102 | if(tmpMime ) | ||
103 | mimes.append("video//*" ); | ||
104 | } | ||
105 | return mimes; | ||
106 | } | ||
107 | |||
108 | } | ||
109 | |||
79 | 110 | ||
80 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : | 111 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : |
81 | QVBox( parent ) | 112 | QVBox( parent ) |
@@ -426,8 +457,8 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) | |||
426 | tabs = 0; | 457 | tabs = 0; |
427 | rootFolder = 0; | 458 | rootFolder = 0; |
428 | docsFolder = 0; | 459 | docsFolder = 0; |
429 | int stamp = uidgen.generate(); | 460 | int stamp = uidgen.generate(); // this is our timestamp to see which devices we know |
430 | uidgen.store( stamp ); | 461 | //uidgen.store( stamp ); |
431 | m_timeStamp = QString::number( stamp ); | 462 | m_timeStamp = QString::number( stamp ); |
432 | 463 | ||
433 | tabs = new CategoryTabWidget( this ); | 464 | tabs = new CategoryTabWidget( this ); |
@@ -511,53 +542,58 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global:: | |||
511 | delete docsFolder; | 542 | delete docsFolder; |
512 | docsFolder = new DocLnkSet; | 543 | docsFolder = new DocLnkSet; |
513 | qWarning("new DocLnkSet" ); | 544 | qWarning("new DocLnkSet" ); |
545 | DocLnkSet *tmp = 0; | ||
546 | QString home = QString(getenv("HOME")) + "/Documents"; | ||
547 | tmp = new DocLnkSet( home , QString::null); | ||
548 | docsFolder->appendFrom( *tmp ); | ||
549 | delete tmp; | ||
514 | // find out wich filesystems are new in this round | 550 | // find out wich filesystems are new in this round |
515 | // We will do this by having a timestamp inside each mountpoint | 551 | // We will do this by having a timestamp inside each mountpoint |
516 | // if the current timestamp doesn't match this is a new file system and | 552 | // if the current timestamp doesn't match this is a new file system and |
517 | // come up with our MediumMountGui :) let the hacking begin | 553 | // come up with our MediumMountGui :) let the hacking begin |
518 | int stamp = uidgen.generate(); | 554 | int stamp = uidgen.generate(); |
519 | 555 | ||
520 | QString newStamp = QString::number( stamp ); | 556 | QString newStamp = QString::number( stamp ); // generates newtime Stamp |
521 | qWarning("new time stamp is: %s", newStamp.latin1() ); | ||
522 | StorageInfo storage; | 557 | StorageInfo storage; |
523 | const QList<FileSystem> &fileSystems = storage.fileSystems(); | 558 | const QList<FileSystem> &fileSystems = storage.fileSystems(); |
524 | qWarning("QList<FileSystem>" ); | ||
525 | QListIterator<FileSystem> it ( fileSystems ); | 559 | QListIterator<FileSystem> it ( fileSystems ); |
526 | qWarning("iterator initiliazed" ); | ||
527 | for ( ; it.current(); ++it ) { | 560 | for ( ; it.current(); ++it ) { |
528 | qWarning("inside for loop" ); | ||
529 | qWarning("checking device %s", (*it)->path().latin1() ); | ||
530 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 561 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
531 | qWarning("%s is removeable", (*it)->path().latin1() ); | 562 | qWarning("%s is removeable", (*it)->path().latin1() ); |
532 | OConfig cfg( (*it)->path() + "/.opiestorage.cf"); | 563 | OConfig cfg( (*it)->path() + "/.opiestorage.cf"); |
533 | cfg.setGroup("main"); | 564 | cfg.setGroup("main"); |
534 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); | 565 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); |
535 | if( stamp == m_timeStamp ){ // ok we know this card | 566 | if( stamp == m_timeStamp ){ // ok we know this card |
536 | qWarning("time stamp match" ); | 567 | cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp |
537 | cfg.writeEntry("timestamp", newStamp ); | ||
538 | // we need to scan the list now. Hopefully the cache will be there | 568 | // we need to scan the list now. Hopefully the cache will be there |
539 | }else{ // come up with the gui | 569 | // read the mimetypes from the config and search for documents |
540 | qWarning("time stamp doesn't match" ); | 570 | QStringList mimetypes = configToMime( &cfg); |
571 | tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); | ||
572 | docsFolder->appendFrom( *tmp ); | ||
573 | delete tmp; | ||
574 | |||
575 | }else{ // come up with the gui cause this a new card | ||
541 | MediumMountGui medium((*it)->path() ); | 576 | MediumMountGui medium((*it)->path() ); |
542 | qWarning("medium mount gui created" ); | 577 | if( medium.check() ){ // we did not ask before or ask again is off |
543 | if( medium.check() ){ | 578 | if( medium.exec() ){ // he clicked yes so search it |
544 | qWarning("need to check this device" ); | ||
545 | if( medium.exec() ){ //ok | ||
546 | // speicher | 579 | // speicher |
547 | qWarning("execed" ); | 580 | cfg.read(); // cause of a race we need to reread |
548 | cfg.read(); | ||
549 | cfg.writeEntry("timestamp", newStamp ); | 581 | cfg.writeEntry("timestamp", newStamp ); |
550 | } | 582 | }// no else |
551 | }else{ | 583 | }else{ // we checked |
552 | qWarning("wrong :(" ); | ||
553 | // do something different see what we need to do | 584 | // do something different see what we need to do |
585 | // let's see if we should check the device | ||
586 | cfg.setGroup("main" ); | ||
587 | bool check = cfg.readBoolEntry("autocheck", true ); | ||
588 | if( check ){ // find the documents | ||
589 | tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); | ||
590 | docsFolder->appendFrom( *tmp ); | ||
591 | delete tmp; | ||
592 | } | ||
554 | } | 593 | } |
555 | } | 594 | } |
556 | } | 595 | } |
557 | } | 596 | } |
558 | qWarning("findDocuments" ); | ||
559 | Global::findDocuments(docsFolder); // get rid of this call later | ||
560 | qWarning("done" ); | ||
561 | m_timeStamp = newStamp; | 597 | m_timeStamp = newStamp; |
562 | } | 598 | } |
563 | 599 | ||
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 | |||
@@ -80,9 +80,10 @@ void MediumMountGui::writeConfig(bool autocheck) { | |||
80 | cfg.writeEntry("dirs", ""); | 80 | cfg.writeEntry("dirs", ""); |
81 | 81 | ||
82 | 82 | ||
83 | // if all is checked then add only "null" to the list. | 83 | // if all is checked then add only "QString::null" to the list. |
84 | if (checkmimeall) { | 84 | if (checkmimeall) { |
85 | mimeTypeList += ("null"); | 85 | mimeTypeList.clear(); |
86 | mimeTypeList += QString::null; | ||
86 | } else { | 87 | } else { |
87 | if (checkmimeaudio) { | 88 | if (checkmimeaudio) { |
88 | mimeTypeList += ("audio//*"); | 89 | mimeTypeList += ("audio//*"); |
@@ -97,10 +98,11 @@ void MediumMountGui::writeConfig(bool autocheck) { | |||
97 | mimeTypeList += ("image//*"); | 98 | mimeTypeList += ("image//*"); |
98 | } | 99 | } |
99 | if (checkmimeall) { | 100 | if (checkmimeall) { |
100 | mimeTypeList << ("null"); | 101 | mimeTypeList.clear(); |
102 | mimeTypeList << QString::null; | ||
101 | } | 103 | } |
102 | } | 104 | } |
103 | cfg.write(); | 105 | cfg.write(); // not really needed here but just to be sure |
104 | } | 106 | } |
105 | 107 | ||
106 | void MediumMountGui::startGui() { | 108 | void MediumMountGui::startGui() { |