2
// C++ Implementation: cmoduleindexdialog
7
// Author: The BibleTime team <info@bibletime.info>, (C) 2006
9
// Copyright: See COPYING file that comes with this distribution
13
#include "cmoduleindexdialog.h"
15
#include "util/scoped_resource.h"
21
#include <kapplication.h>
22
#include <kprogress.h>
25
CModuleIndexDialog* CModuleIndexDialog::getInstance() {
26
static CModuleIndexDialog* instance = 0;
28
instance = new CModuleIndexDialog();
34
void CModuleIndexDialog::indexAllModules( const ListCSwordModuleInfo& modules ) {
35
qDebug("indexAllModules");
36
if (modules.count() == 0) {
40
m_currentModuleIndex = 0;
41
progress = new KProgressDialog(0, "progressDialog", i18n("Preparing instant search"), QString::null, true);
42
progress->setAllowCancel(false);
43
progress->progressBar()->setTotalSteps( modules.count() * 100 );
44
progress->setMinimumDuration(0);
48
ListCSwordModuleInfo::const_iterator end_it = modules.end();
49
for( ListCSwordModuleInfo::const_iterator it = modules.begin(); it != end_it; ++it) {
50
(*it)->connectIndexingFinished(this, SLOT(slotFinished()));
51
(*it)->connectIndexingProgress(this, SLOT(slotModuleProgress(int)));
53
progress->setLabel(i18n("Creating index for work %1").arg((*it)->name()));
54
qDebug("Building index for work %s", (*it)->name().latin1());
58
m_currentModuleIndex++;
59
(*it)->disconnectIndexingSignals(this);
66
void CModuleIndexDialog::indexUnindexedModules( const ListCSwordModuleInfo& modules ) {
67
qDebug("indexUnindexedModules");
68
ListCSwordModuleInfo unindexedMods;
70
ListCSwordModuleInfo::const_iterator end_it = modules.end();
71
for( ListCSwordModuleInfo::const_iterator it = modules.begin(); it != end_it; ++it) {
72
if ((*it)->hasIndex()) {
76
unindexedMods << (*it);
79
indexAllModules(unindexedMods);
84
\fn CModuleIndexDialog::slotModuleProgress( int percentage )
86
void CModuleIndexDialog::slotModuleProgress( int percentage ) {
87
// qDebug("progress %d", percentage);
89
progress->progressBar()->setProgress( m_currentModuleIndex * 100 + percentage );
90
KApplication::kApplication()->processEvents( 10 ); //10 ms only
93
void CModuleIndexDialog::slotFinished( ) {
94
qDebug("indexing finished()");
96
progress->progressBar()->setProgress( progress->progressBar()->totalSteps() );
97
KApplication::kApplication()->processEvents( 1 ); //1 ms only