Bibletime – a bible study tool
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmoduleindexdialog.cpp 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //
  2. // C++ Implementation: cmoduleindexdialog
  3. //
  4. // Description:
  5. //
  6. //
  7. // Author: The BibleTime team <info@bibletime.info>, (C) 2006
  8. //
  9. // Copyright: See COPYING file that comes with this distribution
  10. //
  11. //
  12. #include "cmoduleindexdialog.h"
  13. #include "util/scoped_resource.h"
  14. //TQt includes
  15. #include <tqstring.h>
  16. //KDE includes
  17. #include <tdeapplication.h>
  18. #include <kprogress.h>
  19. #include <tdelocale.h>
  20. CModuleIndexDialog* CModuleIndexDialog::getInstance() {
  21. static CModuleIndexDialog* instance = 0;
  22. if (instance == 0) {
  23. instance = new CModuleIndexDialog();
  24. }
  25. return instance;
  26. }
  27. void CModuleIndexDialog::indexAllModules( const ListCSwordModuleInfo& modules ) {
  28. tqDebug("indexAllModules");
  29. if (modules.count() == 0) {
  30. return;
  31. }
  32. m_currentModuleIndex = 0;
  33. progress = new KProgressDialog(0, "progressDialog", i18n("Preparing instant search"), TQString(), true);
  34. progress->setAllowCancel(false);
  35. progress->progressBar()->setTotalSteps( modules.count() * 100 );
  36. progress->setMinimumDuration(0);
  37. // progress->show();
  38. // progress->raise();
  39. ListCSwordModuleInfo::const_iterator end_it = modules.end();
  40. for( ListCSwordModuleInfo::const_iterator it = modules.begin(); it != end_it; ++it) {
  41. (*it)->connectIndexingFinished(this, TQT_SLOT(slotFinished()));
  42. (*it)->connectIndexingProgress(this, TQT_SLOT(slotModuleProgress(int)));
  43. progress->setLabel(i18n("Creating index for work %1").arg((*it)->name()));
  44. tqDebug("Building index for work %s", (*it)->name().latin1());
  45. (*it)->buildIndex();
  46. m_currentModuleIndex++;
  47. (*it)->disconnectIndexingSignals(this);
  48. }
  49. delete progress;
  50. progress = 0;
  51. }
  52. void CModuleIndexDialog::indexUnindexedModules( const ListCSwordModuleInfo& modules ) {
  53. tqDebug("indexUnindexedModules");
  54. ListCSwordModuleInfo unindexedMods;
  55. ListCSwordModuleInfo::const_iterator end_it = modules.end();
  56. for( ListCSwordModuleInfo::const_iterator it = modules.begin(); it != end_it; ++it) {
  57. if ((*it)->hasIndex()) {
  58. continue;
  59. }
  60. unindexedMods << (*it);
  61. }
  62. indexAllModules(unindexedMods);
  63. }
  64. /*!
  65. \fn CModuleIndexDialog::slotModuleProgress( int percentage )
  66. */
  67. void CModuleIndexDialog::slotModuleProgress( int percentage ) {
  68. // tqDebug("progress %d", percentage);
  69. progress->progressBar()->setProgress( m_currentModuleIndex * 100 + percentage );
  70. TDEApplication::kApplication()->processEvents( 10 ); //10 ms only
  71. }
  72. void CModuleIndexDialog::slotFinished( ) {
  73. tqDebug("indexing finished()");
  74. progress->progressBar()->setProgress( progress->progressBar()->totalSteps() );
  75. TDEApplication::kApplication()->processEvents( 1 ); //1 ms only
  76. }
  77. #include "cmoduleindexdialog.moc"