summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/documentlist.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp
index 033dd10..7f9366e 100644
--- a/core/launcher/documentlist.cpp
+++ b/core/launcher/documentlist.cpp
@@ -6,37 +6,38 @@
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "documentlist.h" 20#include "documentlist.h"
21#include "serverinterface.h" 21#include "serverinterface.h"
22#include "launcherglobal.h"
22 23
23#include <qtopia/mimetype.h> 24#include <qtopia/mimetype.h>
24#include <qtopia/resource.h> 25#include <qtopia/resource.h>
25#include <qtopia/global.h> 26#include <qtopia/global.h>
26#include <qtopia/categories.h> 27#include <qtopia/private/categories.h>
27#include <qtopia/qpeapplication.h> 28#include <qtopia/qpeapplication.h>
28#include <qtopia/applnk.h> 29#include <qtopia/applnk.h>
29#include <qtopia/storage.h> 30#include <qtopia/storage.h>
30#ifdef Q_WS_QWS 31#ifdef Q_WS_QWS
31#include <qtopia/qcopenvelope_qws.h> 32#include <qtopia/qcopenvelope_qws.h>
32#endif 33#endif
33 34
34#include <qtimer.h> 35#include <qtimer.h>
35#include <qfileinfo.h> 36#include <qfileinfo.h>
36#include <qtextstream.h> 37#include <qtextstream.h>
37#include <qfile.h> 38#include <qfile.h>
38#include <qdir.h> 39#include <qdir.h>
39#include <qpainter.h> 40#include <qpainter.h>
40#include <qimage.h> 41#include <qimage.h>
41#include <qcopchannel_qws.h> 42#include <qcopchannel_qws.h>
42#include <qlistview.h> 43#include <qlistview.h>
@@ -229,63 +230,63 @@ void DocumentList::reloadAppLnks()
229 } 230 }
230 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { 231 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
231 //qDebug("removing type %s", (*ittypes).latin1()); 232 //qDebug("removing type %s", (*ittypes).latin1());
232 d->serverGui->typeRemoved(*ittypes); 233 d->serverGui->typeRemoved(*ittypes);
233 } 234 }
234 prevTypeList = types; 235 prevTypeList = types;
235 } 236 }
236 237
237 QListIterator<AppLnk> itapp( appLnkSet->children() ); 238 QListIterator<AppLnk> itapp( appLnkSet->children() );
238 AppLnk* l; 239 AppLnk* l;
239 while ( (l=itapp.current()) ) { 240 while ( (l=itapp.current()) ) {
240 ++itapp; 241 ++itapp;
241 if ( d->sendAppLnks && d->serverGui ) 242 if ( d->sendAppLnks && d->serverGui )
242 d->serverGui->applicationAdded( l->type(), *l ); 243 d->serverGui->applicationAdded( l->type(), *l );
243 } 244 }
244 245
245 if ( d->sendAppLnks && d->serverGui ) 246 if ( d->sendAppLnks && d->serverGui )
246 d->serverGui->applicationScanningProgress( 100 ); 247 d->serverGui->applicationScanningProgress( 100 );
247} 248}
248 249
249void DocumentList::reloadDocLnks() 250void DocumentList::reloadDocLnks()
250{ 251{
251 if ( !d->scanDocs ) 252 if ( !d->scanDocs )
252 return; 253 return;
253 254
254 if ( d->sendDocLnks && d->serverGui ) { 255 if ( d->sendDocLnks && d->serverGui ) {
255 d->serverGui->documentScanningProgress( 0 ); 256 d->serverGui->documentScanningProgress( 0 );
256 d->serverGui->allDocumentsRemoved(); 257 d->serverGui->allDocumentsRemoved();
257 } 258 }
258 259
259 rescan(); 260 rescan();
260} 261}
261 262
262void DocumentList::linkChanged( QString arg ) 263void DocumentList::linkChanged( QString arg )
263{ 264{
264 //qDebug( "linkchanged( %s )", arg.latin1() ); 265 //qDebug( "linkchanged( %s )", arg.latin1() );
265 266
266 if ( arg.isNull() || Global::isAppLnkFileName( arg ) ) { 267 if ( arg.isNull() || Opie::Global::isAppLnkFileName( arg ) ) {
267 reloadAppLnks(); 268 reloadAppLnks();
268 } else { 269 } else {
269 270
270 const QList<DocLnk> &list = d->dls.children(); 271 const QList<DocLnk> &list = d->dls.children();
271 QListIterator<DocLnk> it( list ); 272 QListIterator<DocLnk> it( list );
272 while ( it.current() ) { 273 while ( it.current() ) {
273 DocLnk *doc = it.current(); 274 DocLnk *doc = it.current();
274 ++it; 275 ++it;
275 if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) 276 if ( ( doc->linkFileKnown() && doc->linkFile() == arg )
276 || ( doc->fileKnown() && doc->file() == arg ) ) { 277 || ( doc->fileKnown() && doc->file() == arg ) ) {
277 //qDebug( "found old link" ); 278 //qDebug( "found old link" );
278 DocLnk* dl = new DocLnk( arg ); 279 DocLnk* dl = new DocLnk( arg );
279 // add new one if it exists and matches the mimetype 280 // add new one if it exists and matches the mimetype
280 if ( d->store( dl ) ) { 281 if ( d->store( dl ) ) {
281 // Existing link has been changed, send old link ref and a ref 282 // Existing link has been changed, send old link ref and a ref
282 // to the new link 283 // to the new link
283 //qDebug( "change case" ); 284 //qDebug( "change case" );
284 if ( d->serverGui ) 285 if ( d->serverGui )
285 d->serverGui->documentChanged( *doc, *dl ); 286 d->serverGui->documentChanged( *doc, *dl );
286 287
287 } else { 288 } else {
288 // Link has been removed or doesn't match the mimetypes any more 289 // Link has been removed or doesn't match the mimetypes any more
289 // so we aren't interested in it, so take it away from the list 290 // so we aren't interested in it, so take it away from the list
290 //qDebug( "removal case" ); 291 //qDebug( "removal case" );
291 if ( d->serverGui ) 292 if ( d->serverGui )
@@ -443,34 +444,34 @@ void DocumentListPrivate::initialize()
443 delete listDirs[i]; 444 delete listDirs[i];
444 listDirs[i] = 0; 445 listDirs[i] = 0;
445 } 446 }
446 lists[i] = 0; 447 lists[i] = 0;
447 listPositions[i] = 0; 448 listPositions[i] = 0;
448 } 449 }
449 450
450 docPathsSearched = 0; 451 docPathsSearched = 0;
451 searchDepth = -1; 452 searchDepth = -1;
452 state = Find; 453 state = Find;
453 dit = 0; 454 dit = 0;
454} 455}
455 456
456 457
457DocumentListPrivate::~DocumentListPrivate() 458DocumentListPrivate::~DocumentListPrivate()
458{ 459{
459 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) 460 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ )
460 if ( listDirs[i] ) 461 if ( listDirs[i] )
461 delete listDirs[i]; 462 delete listDirs[i];
462 delete dit; 463 delete dit;
463} 464}
464 465
465 466
466void DocumentListPrivate::estimatedPercentScanned() 467void DocumentListPrivate::estimatedPercentScanned()
467{ 468{
468 double overallProgress = 0.0; 469 double overallProgress = 0.0;
469 double levelWeight = 75.0; 470 double levelWeight = 75.0;
470 471
471 int topCount = docPaths.count(); 472 int topCount = docPaths.count();
472 if ( topCount > 1 ) { 473 if ( topCount > 1 ) {
473 levelWeight = levelWeight / topCount; 474 levelWeight = levelWeight / topCount;
474 overallProgress += (docPathsSearched - 1) * levelWeight; 475 overallProgress += (docPathsSearched - 1) * levelWeight;
475 } 476 }
476 477
@@ -609,33 +610,33 @@ const DocLnk *DocumentListPrivate::iterate()
609 610
610 iterationI = 0; 611 iterationI = 0;
611 iterationCount = dit->count(); 612 iterationCount = dit->count();
612 } 613 }
613 614
614 if ( state == MakeUnknownFiles ) { 615 if ( state == MakeUnknownFiles ) {
615 //qDebug("state MakeUnknownFiles"); 616 //qDebug("state MakeUnknownFiles");
616 for (void* c; (c=dit->current()); ++(*dit) ) { 617 for (void* c; (c=dit->current()); ++(*dit) ) {
617 if ( c == MAGIC_NUMBER ) { 618 if ( c == MAGIC_NUMBER ) {
618 DocLnk* dl = new DocLnk; 619 DocLnk* dl = new DocLnk;
619 QFileInfo fi( dit->currentKey() ); 620 QFileInfo fi( dit->currentKey() );
620 dl->setFile( fi.filePath() ); 621 dl->setFile( fi.filePath() );
621 dl->setName( fi.baseName() ); 622 dl->setName( fi.baseName() );
622 if ( store(dl) ) { 623 if ( store(dl) ) {
623 ++*dit; 624 ++*dit;
624 iterationI++; 625 iterationI++;
625 if ( serverGui ) 626 if ( serverGui )
626 serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount ); 627 serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount );
627 return dl; 628 return dl;
628 } 629 }
629 } 630 }
630 iterationI++; 631 iterationI++;
631 } 632 }
632 633
633 delete dit; 634 delete dit;
634 dit = 0; 635 dit = 0;
635 state = Done; 636 state = Done;
636 } 637 }
637 638
638 //qDebug("state Done"); 639 //qDebug("state Done");
639 return NULL; 640 return NULL;
640} 641}
641 642