Diffstat (limited to 'core/launcher/documentlist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/launcher/documentlist.cpp | 46 |
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 | |||
@@ -20,10 +20,11 @@ | |||
20 | #include "documentlist.h" | 20 | #include "documentlist.h" |
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> |
29 | #include <qtopia/private/categories.h> | 30 | #include <qtopia/private/categories.h> |
@@ -32,9 +33,11 @@ | |||
32 | #include <qtopia/storage.h> | 33 | #include <qtopia/storage.h> |
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 |
37 | using 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> |
40 | #include <qfile.h> | 43 | #include <qfile.h> |
@@ -46,9 +49,8 @@ | |||
46 | #include <qlist.h> | 49 | #include <qlist.h> |
47 | #include <qpixmap.h> | 50 | #include <qpixmap.h> |
48 | 51 | ||
49 | 52 | ||
50 | using namespace Opie::Core; | ||
51 | AppLnkSet *DocumentList::appLnkSet = 0; | 53 | AppLnkSet *DocumentList::appLnkSet = 0; |
52 | 54 | ||
53 | static const int MAX_SEARCH_DEPTH = 10; | 55 | static const int MAX_SEARCH_DEPTH = 10; |
54 | 56 | ||
@@ -107,9 +109,9 @@ DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/, | |||
107 | 109 | ||
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 | } |
115 | 117 | ||
@@ -140,9 +142,9 @@ void DocumentList::start() | |||
140 | 142 | ||
141 | 143 | ||
142 | void DocumentList::pause() | 144 | void 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 | } |
148 | 150 | ||
@@ -150,9 +152,9 @@ void DocumentList::pause() | |||
150 | void DocumentList::resume() | 152 | 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 | ||
158 | /* | 160 | /* |
@@ -176,9 +178,9 @@ void DocumentList::resendWorker() | |||
176 | */ | 178 | */ |
177 | 179 | ||
178 | void DocumentList::rescan() | 180 | void 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(); |
184 | } | 186 | } |
@@ -231,18 +233,18 @@ void DocumentList::reloadAppLnks() | |||
231 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 233 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
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 ); |
239 | } | 241 | } |
240 | prevTypeList.remove(*ittypes); | 242 | prevTypeList.remove(*ittypes); |
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; |
248 | } | 250 | } |
@@ -273,9 +275,9 @@ void DocumentList::reloadDocLnks() | |||
273 | } | 275 | } |
274 | 276 | ||
275 | void DocumentList::linkChanged( QString arg ) | 277 | void 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(); |
281 | } else { | 283 | } else { |
@@ -286,22 +288,22 @@ void DocumentList::linkChanged( QString arg ) | |||
286 | DocLnk *doc = it.current(); | 288 | DocLnk *doc = it.current(); |
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 | ||
307 | } | 309 | } |
@@ -313,9 +315,9 @@ void DocumentList::linkChanged( QString arg ) | |||
313 | // Didn't find existing link, must be new | 315 | // Didn't find existing link, must be new |
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 | ||
321 | } | 323 | } |
@@ -377,14 +379,14 @@ void DocumentList::sendAllDocLinks() | |||
377 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) | 379 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) |
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 | } |
390 | 392 | ||
@@ -535,9 +537,9 @@ void DocumentListPrivate::estimatedPercentScanned() | |||
535 | break; | 537 | break; |
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 ); |
543 | } | 545 | } |
@@ -552,9 +554,9 @@ const QString DocumentListPrivate::nextFile() | |||
552 | // end of base paths | 554 | // end of base paths |
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 ); |
560 | lists[0] = listDirs[0]->entryInfoList(); | 562 | lists[0] = listDirs[0]->entryInfoList(); |
@@ -586,9 +588,9 @@ const QString DocumentListPrivate::nextFile() | |||
586 | if ( fi->isDir() ) { | 588 | if ( fi->isDir() ) { |
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++; |
594 | listDirs[searchDepth] = new QDir( dir ); | 596 | listDirs[searchDepth] = new QDir( dir ); |
@@ -627,9 +629,9 @@ bool DocumentListPrivate::store( DocLnk* dl ) | |||
627 | 629 | ||
628 | const DocLnk *DocumentListPrivate::iterate() | 630 | const 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 |
635 | DocLnk* dl = new DocLnk( file ); | 637 | DocLnk* dl = new DocLnk( file ); |
@@ -649,9 +651,9 @@ const DocLnk *DocumentListPrivate::iterate() | |||
649 | static int iterationI; | 651 | static int iterationI; |
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() ); |
657 | // ### does this need to be deleted? | 659 | // ### does this need to be deleted? |
@@ -663,9 +665,9 @@ const DocLnk *DocumentListPrivate::iterate() | |||
663 | iterationCount = dit->count(); | 665 | iterationCount = dit->count(); |
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; |
671 | QFileInfo fi( dit->currentKey() ); | 673 | QFileInfo fi( dit->currentKey() ); |
@@ -686,9 +688,9 @@ const DocLnk *DocumentListPrivate::iterate() | |||
686 | dit = 0; | 688 | dit = 0; |
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 | ||
694 | 696 | ||