Diffstat (limited to 'core/launcher/documentlist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/launcher/documentlist.cpp | 610 |
1 files changed, 309 insertions, 301 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp index d8e7a83..9781a32 100644 --- a/core/launcher/documentlist.cpp +++ b/core/launcher/documentlist.cpp | |||
@@ -102,3 +102,3 @@ public: | |||
102 | DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/, | 102 | DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/, |
103 | QObject *parent, const char *name ) | 103 | QObject *parent, const char *name ) |
104 | : QObject( parent, name ) | 104 | : QObject( parent, name ) |
@@ -133,3 +133,3 @@ void DocumentList::add( const DocLnk& doc ) | |||
133 | if ( d->serverGui && QFile::exists( doc.file() ) ) | 133 | if ( d->serverGui && QFile::exists( doc.file() ) ) |
134 | d->serverGui->documentAdded( doc ); | 134 | d->serverGui->documentAdded( doc ); |
135 | } | 135 | } |
@@ -154,3 +154,3 @@ void DocumentList::resume() | |||
154 | if ( d->tid == 0 ) { | 154 | if ( d->tid == 0 ) { |
155 | d->tid = startTimer( 20 ); | 155 | d->tid = startTimer( 20 ); |
156 | //odebug << "resumed " << d->tid << "" << oendl; | 156 | //odebug << "resumed " << d->tid << "" << oendl; |
@@ -174,3 +174,3 @@ void DocumentList::resendWorker() | |||
174 | for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) | 174 | for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) |
175 | add( *(*it) ); | 175 | add( *(*it) ); |
176 | resume(); | 176 | resume(); |
@@ -191,18 +191,18 @@ void DocumentList::timerEvent( QTimerEvent *te ) | |||
191 | if ( te->timerId() == d->tid ) { | 191 | if ( te->timerId() == d->tid ) { |
192 | // Do 3 at a time | 192 | // Do 3 at a time |
193 | if ( d->serverGui ) | 193 | if ( d->serverGui ) |
194 | d->serverGui->aboutToAddBegin(); | 194 | d->serverGui->aboutToAddBegin(); |
195 | for (int i = 0; i < 3; i++ ) { | 195 | for (int i = 0; i < 3; i++ ) { |
196 | const DocLnk *lnk = d->iterate(); | 196 | const DocLnk *lnk = d->iterate(); |
197 | if ( lnk ) { | 197 | if ( lnk ) { |
198 | add( *lnk ); | 198 | add( *lnk ); |
199 | } else { | 199 | } else { |
200 | // stop when done | 200 | // stop when done |
201 | pause(); | 201 | pause(); |
202 | if ( d->serverGui ) | 202 | if ( d->serverGui ) |
203 | d->serverGui->documentScanningProgress( 100 ); | 203 | d->serverGui->documentScanningProgress( 100 ); |
204 | if ( d->needToSendAllDocLinks ) | 204 | if ( d->needToSendAllDocLinks ) |
205 | sendAllDocLinks(); | 205 | sendAllDocLinks(); |
206 | break; | 206 | break; |
207 | } | 207 | } |
208 | } | 208 | } |
@@ -217,4 +217,4 @@ void DocumentList::reloadAppLnks() | |||
217 | if ( d->sendAppLnks && d->serverGui ) { | 217 | if ( d->sendAppLnks && d->serverGui ) { |
218 | d->serverGui->applicationScanningProgress( 0 ); | 218 | d->serverGui->applicationScanningProgress( 0 ); |
219 | d->serverGui->allApplicationsRemoved(); | 219 | d->serverGui->allApplicationsRemoved(); |
220 | } | 220 | } |
@@ -225,16 +225,16 @@ void DocumentList::reloadAppLnks() | |||
225 | if ( d->sendAppLnks && d->serverGui ) { | 225 | if ( d->sendAppLnks && d->serverGui ) { |
226 | static QStringList prevTypeList; | 226 | static QStringList prevTypeList; |
227 | QStringList types = appLnkSet->types(); | 227 | QStringList types = appLnkSet->types(); |
228 | for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { | 228 | for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { |
229 | if ( !(*ittypes).isEmpty() ) { | 229 | if ( !(*ittypes).isEmpty() ) { |
230 | if ( !prevTypeList.contains(*ittypes) ) { | 230 | if ( !prevTypeList.contains(*ittypes) ) { |
231 | QString name = appLnkSet->typeName(*ittypes); | 231 | QString name = appLnkSet->typeName(*ittypes); |
232 | QPixmap pm = appLnkSet->typePixmap(*ittypes); | 232 | QPixmap pm = appLnkSet->typePixmap(*ittypes); |
233 | QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes); | 233 | QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes); |
234 | 234 | ||
235 | if (pm.isNull()) { | 235 | if (pm.isNull()) { |
236 | QImage img( Resource::loadImage( "UnknownDocument" ) ); | 236 | QImage img( Resource::loadImage( "UnknownDocument" ) ); |
237 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 237 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
238 | bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); | 238 | bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); |
239 | } | 239 | } |
240 | 240 | ||
@@ -242,13 +242,13 @@ void DocumentList::reloadAppLnks() | |||
242 | 242 | ||
243 | // ### our current launcher expects docs tab to be last | 243 | // ### our current launcher expects docs tab to be last |
244 | d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); | 244 | d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); |
245 | } | 245 | } |
246 | prevTypeList.remove(*ittypes); | 246 | prevTypeList.remove(*ittypes); |
247 | } | 247 | } |
248 | } | 248 | } |
249 | for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { | 249 | for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { |
250 | //odebug << "removing type " << (*ittypes) << "" << oendl; | 250 | //odebug << "removing type " << (*ittypes) << "" << oendl; |
251 | d->serverGui->typeRemoved(*ittypes); | 251 | d->serverGui->typeRemoved(*ittypes); |
252 | } | 252 | } |
253 | prevTypeList = types; | 253 | prevTypeList = types; |
254 | } | 254 | } |
@@ -258,5 +258,5 @@ void DocumentList::reloadAppLnks() | |||
258 | while ( (l=itapp.current()) ) { | 258 | while ( (l=itapp.current()) ) { |
259 | ++itapp; | 259 | ++itapp; |
260 | if ( d->sendAppLnks && d->serverGui ) | 260 | if ( d->sendAppLnks && d->serverGui ) |
261 | d->serverGui->applicationAdded( l->type(), *l ); | 261 | d->serverGui->applicationAdded( l->type(), *l ); |
262 | } | 262 | } |
@@ -264,3 +264,3 @@ void DocumentList::reloadAppLnks() | |||
264 | if ( d->sendAppLnks && d->serverGui ) | 264 | if ( d->sendAppLnks && d->serverGui ) |
265 | d->serverGui->applicationScanningProgress( 100 ); | 265 | d->serverGui->applicationScanningProgress( 100 ); |
266 | } | 266 | } |
@@ -270,7 +270,7 @@ void DocumentList::reloadDocLnks() | |||
270 | if ( !d->scanDocs ) | 270 | if ( !d->scanDocs ) |
271 | return; | 271 | return; |
272 | 272 | ||
273 | if ( d->sendDocLnks && d->serverGui ) { | 273 | if ( d->sendDocLnks && d->serverGui ) { |
274 | d->serverGui->documentScanningProgress( 0 ); | 274 | d->serverGui->documentScanningProgress( 0 ); |
275 | d->serverGui->allDocumentsRemoved(); | 275 | d->serverGui->allDocumentsRemoved(); |
276 | } | 276 | } |
@@ -280,47 +280,55 @@ void DocumentList::reloadDocLnks() | |||
280 | 280 | ||
281 | void DocumentList::reforceDocuments() | ||
282 | { | ||
283 | Config cfg( "Launcher" ); | ||
284 | cfg.setGroup( "DocTab" ); | ||
285 | d->scanDocs = cfg.readBoolEntry( "Enable", true ); | ||
286 | reloadDocLnks(); | ||
287 | } | ||
288 | |||
281 | void DocumentList::linkChanged( QString arg ) | 289 | void DocumentList::linkChanged( QString arg ) |
282 | { | 290 | { |
283 | //odebug << "linkchanged( " << arg << " )" << oendl; | 291 | odebug << "linkchanged( " << arg << " )" << oendl; |
284 | 292 | ||
285 | if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) { | 293 | if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) { |
286 | reloadAppLnks(); | 294 | reloadAppLnks(); |
287 | } else { | 295 | } else { |
288 | 296 | ||
289 | const QList<DocLnk> &list = d->dls.children(); | 297 | const QList<DocLnk> &list = d->dls.children(); |
290 | QListIterator<DocLnk> it( list ); | 298 | QListIterator<DocLnk> it( list ); |
291 | while ( it.current() ) { | 299 | while ( it.current() ) { |
292 | DocLnk *doc = it.current(); | 300 | DocLnk *doc = it.current(); |
293 | ++it; | 301 | ++it; |
294 | if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) | 302 | if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) |
295 | || ( doc->fileKnown() && doc->file() == arg ) ) { | 303 | || ( doc->fileKnown() && doc->file() == arg ) ) { |
296 | //odebug << "found old link" << oendl; | 304 | //odebug << "found old link" << oendl; |
297 | DocLnk* dl = new DocLnk( arg ); | 305 | DocLnk* dl = new DocLnk( arg ); |
298 | // add new one if it exists and matches the mimetype | 306 | // add new one if it exists and matches the mimetype |
299 | if ( d->store( dl ) ) { | 307 | if ( d->store( dl ) ) { |
300 | // Existing link has been changed, send old link ref and a ref | 308 | // Existing link has been changed, send old link ref and a ref |
301 | // to the new link | 309 | // to the new link |
302 | //odebug << "change case" << oendl; | 310 | //odebug << "change case" << oendl; |
303 | if ( d->serverGui ) | 311 | if ( d->serverGui ) |
304 | d->serverGui->documentChanged( *doc, *dl ); | 312 | d->serverGui->documentChanged( *doc, *dl ); |
305 | 313 | ||
306 | } else { | 314 | } else { |
307 | // Link has been removed or doesn't match the mimetypes any more | 315 | // Link has been removed or doesn't match the mimetypes any more |
308 | // so we aren't interested in it, so take it away from the list | 316 | // so we aren't interested in it, so take it away from the list |
309 | //odebug << "removal case" << oendl; | 317 | //odebug << "removal case" << oendl; |
310 | if ( d->serverGui ) | 318 | if ( d->serverGui ) |
311 | d->serverGui->documentRemoved( *doc ); | 319 | d->serverGui->documentRemoved( *doc ); |
312 | 320 | ||
313 | } | 321 | } |
314 | d->dls.remove( doc ); // remove old link from docLnkSet | 322 | d->dls.remove( doc ); // remove old link from docLnkSet |
315 | delete doc; | 323 | delete doc; |
316 | return; | 324 | return; |
317 | } | 325 | } |
318 | } | 326 | } |
319 | // Didn't find existing link, must be new | 327 | // Didn't find existing link, must be new |
320 | DocLnk* dl = new DocLnk( arg ); | 328 | DocLnk* dl = new DocLnk( arg ); |
321 | if ( d->store( dl ) ) { | 329 | if ( d->store( dl ) ) { |
322 | // Add if it's a link we are interested in | 330 | // Add if it's a link we are interested in |
323 | //odebug << "add case" << oendl; | 331 | //odebug << "add case" << oendl; |
324 | add( *dl ); | 332 | add( *dl ); |
325 | } | 333 | } |
326 | 334 | ||
@@ -342,16 +350,16 @@ void DocumentList::DiffAppLnks() | |||
342 | if ( d->sendAppLnks && d->serverGui ) { | 350 | if ( d->sendAppLnks && d->serverGui ) { |
343 | static QStringList prevTypeList = appLnkSet->types(); | 351 | static QStringList prevTypeList = appLnkSet->types(); |
344 | QStringList types = appLnkSet2->types(); | 352 | QStringList types = appLnkSet2->types(); |
345 | for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { | 353 | for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { |
346 | if ( !(*ittypes).isEmpty() ) { | 354 | if ( !(*ittypes).isEmpty() ) { |
347 | if ( !prevTypeList.contains(*ittypes) ) { | 355 | if ( !prevTypeList.contains(*ittypes) ) { |
348 | QString name = appLnkSet2->typeName(*ittypes); | 356 | QString name = appLnkSet2->typeName(*ittypes); |
349 | QPixmap pm = appLnkSet2->typePixmap(*ittypes); | 357 | QPixmap pm = appLnkSet2->typePixmap(*ittypes); |
350 | QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes); | 358 | QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes); |
351 | 359 | ||
352 | if (pm.isNull()) { | 360 | if (pm.isNull()) { |
353 | QImage img( Resource::loadImage( "UnknownDocument" ) ); | 361 | QImage img( Resource::loadImage( "UnknownDocument" ) ); |
354 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 362 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
355 | bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); | 363 | bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); |
356 | } | 364 | } |
357 | 365 | ||
@@ -359,13 +367,13 @@ void DocumentList::DiffAppLnks() | |||
359 | 367 | ||
360 | // ### our current launcher expects docs tab to be last | 368 | // ### our current launcher expects docs tab to be last |
361 | d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); | 369 | d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); |
362 | } | 370 | } |
363 | prevTypeList.remove(*ittypes); | 371 | prevTypeList.remove(*ittypes); |
364 | } | 372 | } |
365 | } | 373 | } |
366 | for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { | 374 | for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { |
367 | odebug << "removing type " << (*ittypes) << "" << oendl; | 375 | odebug << "removing type " << (*ittypes) << "" << oendl; |
368 | d->serverGui->typeRemoved(*ittypes); | 376 | d->serverGui->typeRemoved(*ittypes); |
369 | } | 377 | } |
370 | prevTypeList = types; | 378 | prevTypeList = types; |
371 | } | 379 | } |
@@ -381,14 +389,14 @@ void DocumentList::DiffAppLnks() | |||
381 | while ( (j=it2.current()) ) { | 389 | while ( (j=it2.current()) ) { |
382 | it1 = appLnkSet->children(); | 390 | it1 = appLnkSet->children(); |
383 | found = false; | 391 | found = false; |
384 | while ( (i=it1.current()) ){ | 392 | while ( (i=it1.current()) ){ |
385 | if (strcmp(i->name().ascii(),j->name().ascii()) == 0) | 393 | if (strcmp(i->name().ascii(),j->name().ascii()) == 0) |
386 | found = true; | 394 | found = true; |
387 | ++it1; | 395 | ++it1; |
388 | } | 396 | } |
389 | if (!found) { | 397 | if (!found) { |
390 | odebug << "Item " << j->name().ascii() << " needs to be added" << oendl; | 398 | odebug << "Item " << j->name().ascii() << " needs to be added" << oendl; |
391 | d->serverGui->applicationAdded( j->type(), *j ); | 399 | d->serverGui->applicationAdded( j->type(), *j ); |
392 | } | 400 | } |
393 | ++it2; | 401 | ++it2; |
394 | } | 402 | } |
@@ -397,15 +405,15 @@ void DocumentList::DiffAppLnks() | |||
397 | while ( (i=it1.current()) ) { | 405 | while ( (i=it1.current()) ) { |
398 | it2 = appLnkSet2->children(); | 406 | it2 = appLnkSet2->children(); |
399 | found = false; | 407 | found = false; |
400 | while ( (j=it2.current()) ){ | 408 | while ( (j=it2.current()) ){ |
401 | if (strcmp(i->name().ascii(),j->name().ascii()) == 0) | 409 | if (strcmp(i->name().ascii(),j->name().ascii()) == 0) |
402 | found = true; | 410 | found = true; |
403 | ++it2; | 411 | ++it2; |
404 | } | 412 | } |
405 | if (!found) { | 413 | if (!found) { |
406 | odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl; | 414 | odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl; |
407 | d->serverGui->applicationRemoved( i->type(), *i ); | 415 | d->serverGui->applicationRemoved( i->type(), *i ); |
408 | } | 416 | } |
409 | 417 | ||
410 | ++it1; | 418 | ++it1; |
411 | } | 419 | } |
@@ -438,6 +446,6 @@ void DocumentList::sendAllDocLinks() | |||
438 | if ( d->tid != 0 ) { | 446 | if ( d->tid != 0 ) { |
439 | // We are in the middle of scanning, set a flag so | 447 | // We are in the middle of scanning, set a flag so |
440 | // we do this when we finish our scanning | 448 | // we do this when we finish our scanning |
441 | d->needToSendAllDocLinks = true; | 449 | d->needToSendAllDocLinks = true; |
442 | return; | 450 | return; |
443 | } | 451 | } |
@@ -447,38 +455,38 @@ void DocumentList::sendAllDocLinks() | |||
447 | for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) { | 455 | for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) { |
448 | DocLnk *doc = it.current(); | 456 | DocLnk *doc = it.current(); |
449 | QFileInfo fi( doc->file() ); | 457 | QFileInfo fi( doc->file() ); |
450 | if ( !fi.exists() ) | 458 | if ( !fi.exists() ) |
451 | continue; | 459 | continue; |
452 | 460 | ||
453 | bool fake = !doc->linkFileKnown(); | 461 | bool fake = !doc->linkFileKnown(); |
454 | if ( !fake ) { | 462 | if ( !fake ) { |
455 | QFile f( doc->linkFile() ); | 463 | QFile f( doc->linkFile() ); |
456 | if ( f.open( IO_ReadOnly ) ) { | 464 | if ( f.open( IO_ReadOnly ) ) { |
457 | QTextStream ts( &f ); | 465 | QTextStream ts( &f ); |
458 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 466 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
459 | QString docLnk = ts.read(); | 467 | QString docLnk = ts.read(); |
460 | // Strip out the (stale) LinkFile entry | 468 | // Strip out the (stale) LinkFile entry |
461 | int start = docLnk.find( "\nLinkFile = " ) + 1; | 469 | int start = docLnk.find( "\nLinkFile = " ) + 1; |
462 | if ( start > 0 ) { | 470 | if ( start > 0 ) { |
463 | int end = docLnk.find( "\n", start + 1 ) + 1; | 471 | int end = docLnk.find( "\n", start + 1 ) + 1; |
464 | contents += docLnk.left(start); | 472 | contents += docLnk.left(start); |
465 | contents += docLnk.mid(end); | 473 | contents += docLnk.mid(end); |
466 | } else { | 474 | } else { |
467 | contents += docLnk; | 475 | contents += docLnk; |
468 | } | 476 | } |
469 | contents += "LinkFile = " + doc->linkFile() + "\n"; | 477 | contents += "LinkFile = " + doc->linkFile() + "\n"; |
470 | 478 | ||
471 | f.close(); | 479 | f.close(); |
472 | } else | 480 | } else |
473 | fake = TRUE; | 481 | fake = TRUE; |
474 | } | 482 | } |
475 | if (fake) { | 483 | if (fake) { |
476 | contents += "[Desktop Entry]\n"; // No tr | 484 | contents += "[Desktop Entry]\n"; // No tr |
477 | contents += "Categories = " + // No tr | 485 | contents += "Categories = " + // No tr |
478 | cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr | 486 | cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr |
479 | contents += "Name = "+doc->name()+"\n"; // No tr | 487 | contents += "Name = "+doc->name()+"\n"; // No tr |
480 | contents += "Type = "+doc->type()+"\n"; // No tr | 488 | contents += "Type = "+doc->type()+"\n"; // No tr |
481 | } | 489 | } |
482 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) | 490 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) |
483 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr | 491 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr |
484 | } | 492 | } |
@@ -523,12 +531,12 @@ DocumentListPrivate::DocumentListPrivate( ServerInterface *gui ) | |||
523 | if ( serverGui ) { | 531 | if ( serverGui ) { |
524 | sendAppLnks = serverGui->requiresApplications(); | 532 | sendAppLnks = serverGui->requiresApplications(); |
525 | sendDocLnks = serverGui->requiresDocuments(); | 533 | sendDocLnks = serverGui->requiresDocuments(); |
526 | } else { | 534 | } else { |
527 | sendAppLnks = false; | 535 | sendAppLnks = false; |
528 | sendDocLnks = false; | 536 | sendDocLnks = false; |
529 | } | 537 | } |
530 | for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { | 538 | for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { |
531 | listDirs[i] = 0; | 539 | listDirs[i] = 0; |
532 | lists[i] = 0; | 540 | lists[i] = 0; |
533 | listPositions[i] = 0; | 541 | listPositions[i] = 0; |
534 | } | 542 | } |
@@ -583,3 +591,3 @@ void DocumentListPrivate::initialize() | |||
583 | if ( docDir.exists() ) | 591 | if ( docDir.exists() ) |
584 | docPaths += QPEApplication::documentDir(); | 592 | docPaths += QPEApplication::documentDir(); |
585 | int i = 1; | 593 | int i = 1; |
@@ -595,8 +603,8 @@ void DocumentListPrivate::initialize() | |||
595 | for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) { | 603 | for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) { |
596 | if ( listDirs[i] ) { | 604 | if ( listDirs[i] ) { |
597 | delete listDirs[i]; | 605 | delete listDirs[i]; |
598 | listDirs[i] = 0; | 606 | listDirs[i] = 0; |
599 | } | 607 | } |
600 | lists[i] = 0; | 608 | lists[i] = 0; |
601 | listPositions[i] = 0; | 609 | listPositions[i] = 0; |
602 | } | 610 | } |
@@ -613,4 +621,4 @@ DocumentListPrivate::~DocumentListPrivate() | |||
613 | for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) | 621 | for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) |
614 | if ( listDirs[i] ) | 622 | if ( listDirs[i] ) |
615 | delete listDirs[i]; | 623 | delete listDirs[i]; |
616 | delete dit; | 624 | delete dit; |
@@ -626,4 +634,4 @@ void DocumentListPrivate::estimatedPercentScanned() | |||
626 | if ( topCount > 1 ) { | 634 | if ( topCount > 1 ) { |
627 | levelWeight = levelWeight / topCount; | 635 | levelWeight = levelWeight / topCount; |
628 | overallProgress += (docPathsSearched - 1) * levelWeight; | 636 | overallProgress += (docPathsSearched - 1) * levelWeight; |
629 | } | 637 | } |
@@ -631,12 +639,12 @@ void DocumentListPrivate::estimatedPercentScanned() | |||
631 | for ( int d = 0; d <= searchDepth; d++ ) { | 639 | for ( int d = 0; d <= searchDepth; d++ ) { |
632 | if ( listDirs[d] ) { | 640 | if ( listDirs[d] ) { |
633 | int items = lists[d]->count(); | 641 | int items = lists[d]->count(); |
634 | if ( items > 1 ) { | 642 | if ( items > 1 ) { |
635 | levelWeight = levelWeight / items; | 643 | levelWeight = levelWeight / items; |
636 | // Take in to account "." and ".." | 644 | // Take in to account "." and ".." |
637 | overallProgress += (listPositions[d] - 3) * levelWeight; | 645 | overallProgress += (listPositions[d] - 3) * levelWeight; |
638 | } | 646 | } |
639 | } else { | 647 | } else { |
640 | break; | 648 | break; |
641 | } | 649 | } |
642 | } | 650 | } |
@@ -646,3 +654,3 @@ void DocumentListPrivate::estimatedPercentScanned() | |||
646 | if ( serverGui ) | 654 | if ( serverGui ) |
647 | serverGui->documentScanningProgress( (int)overallProgress ); | 655 | serverGui->documentScanningProgress( (int)overallProgress ); |
648 | } | 656 | } |
@@ -653,21 +661,21 @@ const QString DocumentListPrivate::nextFile() | |||
653 | while ( TRUE ) { | 661 | while ( TRUE ) { |
654 | while ( searchDepth < 0 ) { | 662 | while ( searchDepth < 0 ) { |
655 | // go to next base path | 663 | // go to next base path |
656 | if ( docPathsSearched >= docPaths.count() ) { | 664 | if ( docPathsSearched >= docPaths.count() ) { |
657 | // end of base paths | 665 | // end of base paths |
658 | return QString::null; | 666 | return QString::null; |
659 | } else { | 667 | } else { |
660 | QDir dir( docPaths[docPathsSearched] ); | 668 | QDir dir( docPaths[docPathsSearched] ); |
661 | // odebug << "now using base path: " << docPaths[docPathsSearched] << "" << oendl; | 669 | // odebug << "now using base path: " << docPaths[docPathsSearched] << "" << oendl; |
662 | docPathsSearched++; | 670 | docPathsSearched++; |
663 | if ( !dir.exists( ".Qtopia-ignore" ) ) { | 671 | if ( !dir.exists( ".Qtopia-ignore" ) ) { |
664 | listDirs[0] = new QDir( dir ); | 672 | listDirs[0] = new QDir( dir ); |
665 | lists[0] = listDirs[0]->entryInfoList(); | 673 | lists[0] = listDirs[0]->entryInfoList(); |
666 | listPositions[0] = 0; | 674 | listPositions[0] = 0; |
667 | searchDepth = 0; | 675 | searchDepth = 0; |
668 | } | 676 | } |
669 | } | 677 | } |
670 | } | 678 | } |
671 | 679 | ||
672 | const QFileInfoList *fil = lists[searchDepth]; | 680 | const QFileInfoList *fil = lists[searchDepth]; |
673 | if (!fil) { | 681 | if (!fil) { |
@@ -675,37 +683,37 @@ const QString DocumentListPrivate::nextFile() | |||
675 | } | 683 | } |
676 | QFileInfoList *fl = (QFileInfoList *)fil; | 684 | QFileInfoList *fl = (QFileInfoList *)fil; |
677 | unsigned int pos = listPositions[searchDepth]; | 685 | unsigned int pos = listPositions[searchDepth]; |
678 | 686 | ||
679 | if ( pos >= fl->count() ) { | 687 | if ( pos >= fl->count() ) { |
680 | // go up a depth | 688 | // go up a depth |
681 | delete listDirs[searchDepth]; | 689 | delete listDirs[searchDepth]; |
682 | listDirs[searchDepth] = 0; | 690 | listDirs[searchDepth] = 0; |
683 | lists[searchDepth] = 0; | 691 | lists[searchDepth] = 0; |
684 | listPositions[searchDepth] = 0; | 692 | listPositions[searchDepth] = 0; |
685 | searchDepth--; | 693 | searchDepth--; |
686 | } else { | 694 | } else { |
687 | const QFileInfo *fi = fl->at(pos); | 695 | const QFileInfo *fi = fl->at(pos); |
688 | listPositions[searchDepth]++; | 696 | listPositions[searchDepth]++; |
689 | QString bn = fi->fileName(); | 697 | QString bn = fi->fileName(); |
690 | if ( bn[0] != '.' ) { | 698 | if ( bn[0] != '.' ) { |
691 | if ( fi->isDir() ) { | 699 | if ( fi->isDir() ) { |
692 | if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) { | 700 | if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) { |
693 | // go down a depth | 701 | // go down a depth |
694 | QDir dir( fi->filePath() ); | 702 | QDir dir( fi->filePath() ); |
695 | // odebug << "now going in to path: " << bn << "" << oendl; | 703 | // odebug << "now going in to path: " << bn << "" << oendl; |
696 | if ( !dir.exists( ".Qtopia-ignore" ) ) { | 704 | if ( !dir.exists( ".Qtopia-ignore" ) ) { |
697 | if ( searchDepth < MAX_SEARCH_DEPTH - 1) { | 705 | if ( searchDepth < MAX_SEARCH_DEPTH - 1) { |
698 | searchDepth++; | 706 | searchDepth++; |
699 | listDirs[searchDepth] = new QDir( dir ); | 707 | listDirs[searchDepth] = new QDir( dir ); |
700 | lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); | 708 | lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); |
701 | listPositions[searchDepth] = 0; | 709 | listPositions[searchDepth] = 0; |
702 | } | 710 | } |
703 | } | 711 | } |
704 | } | 712 | } |
705 | } else { | 713 | } else { |
706 | estimatedPercentScanned(); | 714 | estimatedPercentScanned(); |
707 | return fl->at(pos)->filePath(); | 715 | return fl->at(pos)->filePath(); |
708 | } | 716 | } |
709 | } | 717 | } |
710 | } | 718 | } |
711 | } | 719 | } |
@@ -720,4 +728,4 @@ bool DocumentListPrivate::store( DocLnk* dl ) | |||
720 | if ( dl && dl->fileKnown() ) { | 728 | if ( dl && dl->fileKnown() ) { |
721 | dls.add( dl ); // store | 729 | dls.add( dl ); // store |
722 | return TRUE; | 730 | return TRUE; |
723 | } | 731 | } |
@@ -730,3 +738,3 @@ bool DocumentListPrivate::store( DocLnk* dl ) | |||
730 | 738 | ||
731 | #define MAGIC_NUMBER((void*)2) | 739 | #define MAGIC_NUMBER ((void*)2) |
732 | 740 | ||
@@ -736,17 +744,17 @@ const DocLnk *DocumentListPrivate::iterate() | |||
736 | //odebug << "state Find" << oendl; | 744 | //odebug << "state Find" << oendl; |
737 | QString file = nextFile(); | 745 | QString file = nextFile(); |
738 | while ( !file.isNull() ) { | 746 | while ( !file.isNull() ) { |
739 | if ( file.right(8) == ".desktop" ) { // No tr | 747 | if ( file.right(8) == ".desktop" ) { // No tr |
740 | DocLnk* dl = new DocLnk( file ); | 748 | DocLnk* dl = new DocLnk( file ); |
741 | if ( store(dl) ) | 749 | if ( store(dl) ) |
742 | return dl; | 750 | return dl; |
743 | } else { | 751 | } else { |
744 | reference.insert( file, MAGIC_NUMBER ); | 752 | reference.insert( file, MAGIC_NUMBER ); |
745 | } | 753 | } |
746 | file = nextFile(); | 754 | file = nextFile(); |
747 | } | 755 | } |
748 | state = RemoveKnownFiles; | 756 | state = RemoveKnownFiles; |
749 | 757 | ||
750 | if ( serverGui ) | 758 | if ( serverGui ) |
751 | serverGui->documentScanningProgress( 75 ); | 759 | serverGui->documentScanningProgress( 75 ); |
752 | } | 760 | } |
@@ -758,12 +766,12 @@ const DocLnk *DocumentListPrivate::iterate() | |||
758 | //odebug << "state RemoveKnownFiles" << oendl; | 766 | //odebug << "state RemoveKnownFiles" << oendl; |
759 | const QList<DocLnk> &list = dls.children(); | 767 | const QList<DocLnk> &list = dls.children(); |
760 | for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) { | 768 | for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) { |
761 | reference.remove( (*it)->file() ); | 769 | reference.remove( (*it)->file() ); |
762 | // ### does this need to be deleted? | 770 | // ### does this need to be deleted? |
763 | } | 771 | } |
764 | dit = new QDictIterator<void>(reference); | 772 | dit = new QDictIterator<void>(reference); |
765 | state = MakeUnknownFiles; | 773 | state = MakeUnknownFiles; |
766 | 774 | ||
767 | iterationI = 0; | 775 | iterationI = 0; |
768 | iterationCount = dit->count(); | 776 | iterationCount = dit->count(); |
769 | } | 777 | } |
@@ -772,22 +780,22 @@ const DocLnk *DocumentListPrivate::iterate() | |||
772 | //odebug << "state MakeUnknownFiles" << oendl; | 780 | //odebug << "state MakeUnknownFiles" << oendl; |
773 | for (void* c; (c=dit->current()); ++(*dit) ) { | 781 | for (void* c; (c=dit->current()); ++(*dit) ) { |
774 | if ( c == MAGIC_NUMBER ) { | 782 | if ( c == MAGIC_NUMBER ) { |
775 | DocLnk* dl = new DocLnk; | 783 | DocLnk* dl = new DocLnk; |
776 | QFileInfo fi( dit->currentKey() ); | 784 | QFileInfo fi( dit->currentKey() ); |
777 | dl->setFile( fi.filePath() ); | 785 | dl->setFile( fi.filePath() ); |
778 | dl->setName( fi.baseName() ); | 786 | dl->setName( fi.baseName() ); |
779 | if ( store(dl) ) { | 787 | if ( store(dl) ) { |
780 | ++*dit; | 788 | ++*dit; |
781 | iterationI++; | 789 | iterationI++; |
782 | if ( serverGui ) | 790 | if ( serverGui ) |
783 | serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount ); | 791 | serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount ); |
784 | return dl; | 792 | return dl; |
785 | } | 793 | } |
786 | } | 794 | } |
787 | iterationI++; | 795 | iterationI++; |
788 | } | 796 | } |
789 | 797 | ||
790 | delete dit; | 798 | delete dit; |
791 | dit = 0; | 799 | dit = 0; |
792 | state = Done; | 800 | state = Done; |
793 | } | 801 | } |