summaryrefslogtreecommitdiff
path: root/core/launcher/documentlist.cpp
Unidiff
Diffstat (limited to 'core/launcher/documentlist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/documentlist.cpp46
1 files changed, 24 insertions, 22 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp
index 3e0a96c..92b8c25 100644
--- a/core/launcher/documentlist.cpp
+++ b/core/launcher/documentlist.cpp
@@ -21,8 +21,9 @@
21#include "serverinterface.h" 21#include "serverinterface.h"
22#include "mediadlg.h" 22#include "mediadlg.h"
23 23
24/* OPIE */
24#include <opie2/oglobal.h> 25#include <opie2/oglobal.h>
25 26#include <opie2/odebug.h>
26#include <qtopia/config.h> 27#include <qtopia/config.h>
27#include <qtopia/mimetype.h> 28#include <qtopia/mimetype.h>
28#include <qtopia/resource.h> 29#include <qtopia/resource.h>
@@ -33,7 +34,9 @@
33#ifdef Q_WS_QWS 34#ifdef Q_WS_QWS
34#include <qtopia/qcopenvelope_qws.h> 35#include <qtopia/qcopenvelope_qws.h>
35#endif 36#endif
37using namespace Opie::Core;
36 38
39/* QT */
37#include <qtimer.h> 40#include <qtimer.h>
38#include <qfileinfo.h> 41#include <qfileinfo.h>
39#include <qtextstream.h> 42#include <qtextstream.h>
@@ -47,7 +50,6 @@
47#include <qpixmap.h> 50#include <qpixmap.h>
48 51
49 52
50using namespace Opie::Core;
51AppLnkSet *DocumentList::appLnkSet = 0; 53AppLnkSet *DocumentList::appLnkSet = 0;
52 54
53static const int MAX_SEARCH_DEPTH = 10; 55static const int MAX_SEARCH_DEPTH = 10;
@@ -108,7 +110,7 @@ DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/,
108 Config cfg( "Launcher" ); 110 Config cfg( "Launcher" );
109 cfg.setGroup( "DocTab" ); 111 cfg.setGroup( "DocTab" );
110 d->scanDocs = cfg.readBoolEntry( "Enable", true ); 112 d->scanDocs = cfg.readBoolEntry( "Enable", true );
111 qDebug( "DocumentList::DocumentList() : scanDocs = %d", d->scanDocs ); 113 odebug << "DocumentList::DocumentList() : scanDocs = " << d->scanDocs << "" << oendl;
112 114
113 QTimer::singleShot( 10, this, SLOT( startInitialScan() ) ); 115 QTimer::singleShot( 10, this, SLOT( startInitialScan() ) );
114} 116}
@@ -141,7 +143,7 @@ void DocumentList::start()
141 143
142void DocumentList::pause() 144void DocumentList::pause()
143{ 145{
144 //qDebug("pause %i", d->tid); 146 //odebug << "pause " << d->tid << "" << oendl;
145 killTimer( d->tid ); 147 killTimer( d->tid );
146 d->tid = 0; 148 d->tid = 0;
147} 149}
@@ -151,7 +153,7 @@ void DocumentList::resume()
151{ 153{
152 if ( d->tid == 0 ) { 154 if ( d->tid == 0 ) {
153 d->tid = startTimer( 20 ); 155 d->tid = startTimer( 20 );
154 //qDebug("resumed %i", d->tid); 156 //odebug << "resumed " << d->tid << "" << oendl;
155 } 157 }
156} 158}
157 159
@@ -177,7 +179,7 @@ void DocumentList::resendWorker()
177 179
178void DocumentList::rescan() 180void DocumentList::rescan()
179{ 181{
180 //qDebug("rescan"); 182 //odebug << "rescan" << oendl;
181 pause(); 183 pause();
182 d->initialize(); 184 d->initialize();
183 resume(); 185 resume();
@@ -232,7 +234,7 @@ void DocumentList::reloadAppLnks()
232 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); 234 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() );
233 } 235 }
234 236
235 //qDebug("adding type %s", (*ittypes).latin1()); 237 //odebug << "adding type " << (*ittypes) << "" << oendl;
236 238
237 // ### our current launcher expects docs tab to be last 239 // ### our current launcher expects docs tab to be last
238 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); 240 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
@@ -241,7 +243,7 @@ void DocumentList::reloadAppLnks()
241 } 243 }
242 } 244 }
243 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { 245 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
244 //qDebug("removing type %s", (*ittypes).latin1()); 246 //odebug << "removing type " << (*ittypes) << "" << oendl;
245 d->serverGui->typeRemoved(*ittypes); 247 d->serverGui->typeRemoved(*ittypes);
246 } 248 }
247 prevTypeList = types; 249 prevTypeList = types;
@@ -274,7 +276,7 @@ void DocumentList::reloadDocLnks()
274 276
275void DocumentList::linkChanged( QString arg ) 277void DocumentList::linkChanged( QString arg )
276{ 278{
277 //qDebug( "linkchanged( %s )", arg.latin1() ); 279 //odebug << "linkchanged( " << arg << " )" << oendl;
278 280
279 if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) { 281 if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) {
280 reloadAppLnks(); 282 reloadAppLnks();
@@ -287,20 +289,20 @@ void DocumentList::linkChanged( QString arg )
287 ++it; 289 ++it;
288 if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) 290 if ( ( doc->linkFileKnown() && doc->linkFile() == arg )
289 || ( doc->fileKnown() && doc->file() == arg ) ) { 291 || ( doc->fileKnown() && doc->file() == arg ) ) {
290 //qDebug( "found old link" ); 292 //odebug << "found old link" << oendl;
291 DocLnk* dl = new DocLnk( arg ); 293 DocLnk* dl = new DocLnk( arg );
292 // add new one if it exists and matches the mimetype 294 // add new one if it exists and matches the mimetype
293 if ( d->store( dl ) ) { 295 if ( d->store( dl ) ) {
294 // Existing link has been changed, send old link ref and a ref 296 // Existing link has been changed, send old link ref and a ref
295 // to the new link 297 // to the new link
296 //qDebug( "change case" ); 298 //odebug << "change case" << oendl;
297 if ( d->serverGui ) 299 if ( d->serverGui )
298 d->serverGui->documentChanged( *doc, *dl ); 300 d->serverGui->documentChanged( *doc, *dl );
299 301
300 } else { 302 } else {
301 // Link has been removed or doesn't match the mimetypes any more 303 // Link has been removed or doesn't match the mimetypes any more
302 // so we aren't interested in it, so take it away from the list 304 // so we aren't interested in it, so take it away from the list
303 //qDebug( "removal case" ); 305 //odebug << "removal case" << oendl;
304 if ( d->serverGui ) 306 if ( d->serverGui )
305 d->serverGui->documentRemoved( *doc ); 307 d->serverGui->documentRemoved( *doc );
306 308
@@ -314,7 +316,7 @@ void DocumentList::linkChanged( QString arg )
314 DocLnk* dl = new DocLnk( arg ); 316 DocLnk* dl = new DocLnk( arg );
315 if ( d->store( dl ) ) { 317 if ( d->store( dl ) ) {
316 // Add if it's a link we are interested in 318 // Add if it's a link we are interested in
317 //qDebug( "add case" ); 319 //odebug << "add case" << oendl;
318 add( *dl ); 320 add( *dl );
319 } 321 }
320 322
@@ -378,12 +380,12 @@ void DocumentList::sendAllDocLinks()
378 contents += QString("Size = %1\n").arg( fi.size() ); // No tr 380 contents += QString("Size = %1\n").arg( fi.size() ); // No tr
379 } 381 }
380 382
381 //qDebug( "sending length %d", contents.length() ); 383 //odebug << "sending length " << contents.length() << "" << oendl;
382#ifndef QT_NO_COP 384#ifndef QT_NO_COP
383 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); 385 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
384 e << contents; 386 e << contents;
385#endif 387#endif
386 //qDebug( "================ \n\n%s\n\n===============", contents.latin1() ); 388 //odebug << "================ \n\n" << contents << "\n\n===============" << oendl;
387 389
388 d->needToSendAllDocLinks = false; 390 d->needToSendAllDocLinks = false;
389} 391}
@@ -536,7 +538,7 @@ void DocumentListPrivate::estimatedPercentScanned()
536 } 538 }
537 } 539 }
538 540
539 // qDebug( "overallProgress: %f", overallProgress ); 541 // odebug << "overallProgress: " << overallProgress << "" << oendl;
540 542
541 if ( serverGui ) 543 if ( serverGui )
542 serverGui->documentScanningProgress( (int)overallProgress ); 544 serverGui->documentScanningProgress( (int)overallProgress );
@@ -553,7 +555,7 @@ const QString DocumentListPrivate::nextFile()
553 return QString::null; 555 return QString::null;
554 } else { 556 } else {
555 QDir dir( docPaths[docPathsSearched] ); 557 QDir dir( docPaths[docPathsSearched] );
556 // qDebug("now using base path: %s", docPaths[docPathsSearched].latin1() ); 558 // odebug << "now using base path: " << docPaths[docPathsSearched] << "" << oendl;
557 docPathsSearched++; 559 docPathsSearched++;
558 if ( !dir.exists( ".Qtopia-ignore" ) ) { 560 if ( !dir.exists( ".Qtopia-ignore" ) ) {
559 listDirs[0] = new QDir( dir ); 561 listDirs[0] = new QDir( dir );
@@ -587,7 +589,7 @@ const QString DocumentListPrivate::nextFile()
587 if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) { 589 if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) {
588 // go down a depth 590 // go down a depth
589 QDir dir( fi->filePath() ); 591 QDir dir( fi->filePath() );
590 // qDebug("now going in to path: %s", bn.latin1() ); 592 // odebug << "now going in to path: " << bn << "" << oendl;
591 if ( !dir.exists( ".Qtopia-ignore" ) ) { 593 if ( !dir.exists( ".Qtopia-ignore" ) ) {
592 if ( searchDepth < MAX_SEARCH_DEPTH - 1) { 594 if ( searchDepth < MAX_SEARCH_DEPTH - 1) {
593 searchDepth++; 595 searchDepth++;
@@ -628,7 +630,7 @@ bool DocumentListPrivate::store( DocLnk* dl )
628const DocLnk *DocumentListPrivate::iterate() 630const DocLnk *DocumentListPrivate::iterate()
629{ 631{
630 if ( state == Find ) { 632 if ( state == Find ) {
631 //qDebug("state Find"); 633 //odebug << "state Find" << oendl;
632 QString file = nextFile(); 634 QString file = nextFile();
633 while ( !file.isNull() ) { 635 while ( !file.isNull() ) {
634 if ( file.right(8) == ".desktop" ) { // No tr 636 if ( file.right(8) == ".desktop" ) { // No tr
@@ -650,7 +652,7 @@ const DocLnk *DocumentListPrivate::iterate()
650 static int iterationCount; 652 static int iterationCount;
651 653
652 if ( state == RemoveKnownFiles ) { 654 if ( state == RemoveKnownFiles ) {
653 //qDebug("state RemoveKnownFiles"); 655 //odebug << "state RemoveKnownFiles" << oendl;
654 const QList<DocLnk> &list = dls.children(); 656 const QList<DocLnk> &list = dls.children();
655 for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) { 657 for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) {
656 reference.remove( (*it)->file() ); 658 reference.remove( (*it)->file() );
@@ -664,7 +666,7 @@ const DocLnk *DocumentListPrivate::iterate()
664 } 666 }
665 667
666 if ( state == MakeUnknownFiles ) { 668 if ( state == MakeUnknownFiles ) {
667 //qDebug("state MakeUnknownFiles"); 669 //odebug << "state MakeUnknownFiles" << oendl;
668 for (void* c; (c=dit->current()); ++(*dit) ) { 670 for (void* c; (c=dit->current()); ++(*dit) ) {
669 if ( c == MAGIC_NUMBER ) { 671 if ( c == MAGIC_NUMBER ) {
670 DocLnk* dl = new DocLnk; 672 DocLnk* dl = new DocLnk;
@@ -687,7 +689,7 @@ const DocLnk *DocumentListPrivate::iterate()
687 state = Done; 689 state = Done;
688 } 690 }
689 691
690 //qDebug("state Done"); 692 //odebug << "state Done" << oendl;
691 return NULL; 693 return NULL;
692} 694}
693 695