Diffstat (limited to 'core/launcher/documentlist.cpp') (more/less context) (show 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 | |||
@@ -18,25 +18,28 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
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> |
30 | #include <qtopia/qpeapplication.h> | 31 | #include <qtopia/qpeapplication.h> |
31 | #include <qtopia/applnk.h> | 32 | #include <qtopia/applnk.h> |
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> |
41 | #include <qdir.h> | 44 | #include <qdir.h> |
42 | #include <qpainter.h> | 45 | #include <qpainter.h> |
@@ -44,13 +47,12 @@ | |||
44 | #include <qcopchannel_qws.h> | 47 | #include <qcopchannel_qws.h> |
45 | #include <qlistview.h> | 48 | #include <qlistview.h> |
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 | ||
55 | 57 | ||
56 | class DocumentListPrivate : public QObject { | 58 | class DocumentListPrivate : public QObject { |
@@ -105,13 +107,13 @@ DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/, | |||
105 | d = new DocumentListPrivate( serverGui ); | 107 | d = new DocumentListPrivate( serverGui ); |
106 | d->needToSendAllDocLinks = false; | 108 | d->needToSendAllDocLinks = false; |
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 | ||
116 | void DocumentList::startInitialScan() | 118 | void DocumentList::startInitialScan() |
117 | { | 119 | { |
@@ -138,23 +140,23 @@ void DocumentList::start() | |||
138 | resume(); | 140 | resume(); |
139 | } | 141 | } |
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 | ||
149 | 151 | ||
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 | /* |
159 | void DocumentList::resend() | 161 | void DocumentList::resend() |
160 | { | 162 | { |
@@ -174,13 +176,13 @@ void DocumentList::resendWorker() | |||
174 | resume(); | 176 | resume(); |
175 | } | 177 | } |
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 | } |
185 | 187 | ||
186 | 188 | ||
@@ -229,22 +231,22 @@ void DocumentList::reloadAppLnks() | |||
229 | if (pm.isNull()) { | 231 | if (pm.isNull()) { |
230 | QImage img( Resource::loadImage( "UnknownDocument" ) ); | 232 | QImage img( Resource::loadImage( "UnknownDocument" ) ); |
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 | } |
249 | 251 | ||
250 | QListIterator<AppLnk> itapp( appLnkSet->children() ); | 252 | QListIterator<AppLnk> itapp( appLnkSet->children() ); |
@@ -271,39 +273,39 @@ void DocumentList::reloadDocLnks() | |||
271 | 273 | ||
272 | rescan(); | 274 | rescan(); |
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 { |
282 | 284 | ||
283 | const QList<DocLnk> &list = d->dls.children(); | 285 | const QList<DocLnk> &list = d->dls.children(); |
284 | QListIterator<DocLnk> it( list ); | 286 | QListIterator<DocLnk> it( list ); |
285 | while ( it.current() ) { | 287 | while ( it.current() ) { |
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 | } |
308 | d->dls.remove( doc ); // remove old link from docLnkSet | 310 | d->dls.remove( doc ); // remove old link from docLnkSet |
309 | delete doc; | 311 | delete doc; |
@@ -311,13 +313,13 @@ void DocumentList::linkChanged( QString arg ) | |||
311 | } | 313 | } |
312 | } | 314 | } |
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 | } |
322 | } | 324 | } |
323 | 325 | ||
@@ -375,18 +377,18 @@ void DocumentList::sendAllDocLinks() | |||
375 | contents += "Type = "+doc->type()+"\n"; // No tr | 377 | contents += "Type = "+doc->type()+"\n"; // No tr |
376 | } | 378 | } |
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 | ||
391 | 393 | ||
392 | 394 | ||
@@ -533,13 +535,13 @@ void DocumentListPrivate::estimatedPercentScanned() | |||
533 | } | 535 | } |
534 | } else { | 536 | } else { |
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 | } |
544 | 546 | ||
545 | 547 | ||
@@ -550,13 +552,13 @@ const QString DocumentListPrivate::nextFile() | |||
550 | // go to next base path | 552 | // go to next base path |
551 | if ( docPathsSearched >= docPaths.count() ) { | 553 | if ( docPathsSearched >= docPaths.count() ) { |
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(); |
561 | listPositions[0] = 0; | 563 | listPositions[0] = 0; |
562 | searchDepth = 0; | 564 | searchDepth = 0; |
@@ -584,13 +586,13 @@ const QString DocumentListPrivate::nextFile() | |||
584 | QString bn = fi->fileName(); | 586 | QString bn = fi->fileName(); |
585 | if ( bn[0] != '.' ) { | 587 | if ( bn[0] != '.' ) { |
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 ); |
595 | lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); | 597 | lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); |
596 | listPositions[searchDepth] = 0; | 598 | listPositions[searchDepth] = 0; |
@@ -625,13 +627,13 @@ bool DocumentListPrivate::store( DocLnk* dl ) | |||
625 | 627 | ||
626 | #define MAGIC_NUMBER((void*)2) | 628 | #define MAGIC_NUMBER((void*)2) |
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 ); |
636 | if ( store(dl) ) | 638 | if ( store(dl) ) |
637 | return dl; | 639 | return dl; |
@@ -647,13 +649,13 @@ const DocLnk *DocumentListPrivate::iterate() | |||
647 | } | 649 | } |
648 | 650 | ||
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? |
658 | } | 660 | } |
659 | dit = new QDictIterator<void>(reference); | 661 | dit = new QDictIterator<void>(reference); |
@@ -661,13 +663,13 @@ const DocLnk *DocumentListPrivate::iterate() | |||
661 | 663 | ||
662 | iterationI = 0; | 664 | iterationI = 0; |
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() ); |
672 | dl->setFile( fi.filePath() ); | 674 | dl->setFile( fi.filePath() ); |
673 | dl->setName( fi.baseName() ); | 675 | dl->setName( fi.baseName() ); |
@@ -684,13 +686,13 @@ const DocLnk *DocumentListPrivate::iterate() | |||
684 | 686 | ||
685 | delete dit; | 687 | delete dit; |
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 | ||
695 | #include "documentlist.moc" | 697 | #include "documentlist.moc" |
696 | 698 | ||