~ubuntu-branches/ubuntu/jaunty/bibletime/jaunty

« back to all changes in this revision

Viewing changes to bibletime/frontend/cmoduleindexdialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ralph Janke
  • Date: 2008-05-10 15:18:16 UTC
  • mfrom: (1.1.6 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080510151816-bqp8y1to705zd0fm
Tags: 1.6.5.1-1
* New upstream version (Closes: #441161, #271502)
* fixes for new autotools and gcc 4.3 (Closes: #407291)
* added poxml to Build-Depends
* No DFSG necessary anymore since biblestudy howto has 
  now Commons Licence 
* Added libclucene-dev to dev-depends (Closes: #436677)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
13
#include "cmoduleindexdialog.h"
 
14
 
 
15
#include "util/scoped_resource.h"
 
16
 
 
17
//Qt includes
 
18
#include <qstring.h>
 
19
 
 
20
//KDE includes
 
21
#include <kapplication.h>
 
22
#include <kprogress.h>
 
23
#include <klocale.h>
 
24
 
 
25
CModuleIndexDialog* CModuleIndexDialog::getInstance() {
 
26
        static CModuleIndexDialog* instance = 0;
 
27
        if (instance == 0) {
 
28
                instance = new CModuleIndexDialog();
 
29
        }
 
30
 
 
31
        return instance;
 
32
}
 
33
 
 
34
void CModuleIndexDialog::indexAllModules( const ListCSwordModuleInfo& modules ) {
 
35
        qDebug("indexAllModules");
 
36
        if (modules.count() == 0) {
 
37
                return;
 
38
        }
 
39
        
 
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);
 
45
//      progress->show();
 
46
//      progress->raise();
 
47
 
 
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)));
 
52
 
 
53
                progress->setLabel(i18n("Creating index for work %1").arg((*it)->name()));
 
54
                qDebug("Building index for work %s", (*it)->name().latin1());
 
55
                
 
56
                (*it)->buildIndex();
 
57
 
 
58
                m_currentModuleIndex++;
 
59
                (*it)->disconnectIndexingSignals(this);
 
60
        }
 
61
 
 
62
        delete progress;
 
63
        progress = 0;
 
64
}
 
65
 
 
66
void CModuleIndexDialog::indexUnindexedModules( const ListCSwordModuleInfo& modules ) {
 
67
        qDebug("indexUnindexedModules");
 
68
        ListCSwordModuleInfo unindexedMods;
 
69
        
 
70
        ListCSwordModuleInfo::const_iterator end_it = modules.end();
 
71
        for( ListCSwordModuleInfo::const_iterator it = modules.begin(); it != end_it; ++it) {
 
72
                if ((*it)->hasIndex()) {
 
73
                        continue;
 
74
                }
 
75
 
 
76
                unindexedMods << (*it);
 
77
        }
 
78
        
 
79
        indexAllModules(unindexedMods);
 
80
}
 
81
 
 
82
 
 
83
/*!
 
84
    \fn CModuleIndexDialog::slotModuleProgress( int percentage )
 
85
 */
 
86
void CModuleIndexDialog::slotModuleProgress( int percentage ) {
 
87
//      qDebug("progress %d", percentage);
 
88
        
 
89
        progress->progressBar()->setProgress( m_currentModuleIndex * 100 + percentage );
 
90
        KApplication::kApplication()->processEvents( 10 ); //10 ms only
 
91
}
 
92
 
 
93
void CModuleIndexDialog::slotFinished( ) {
 
94
        qDebug("indexing finished()");
 
95
        
 
96
        progress->progressBar()->setProgress( progress->progressBar()->totalSteps() );
 
97
        KApplication::kApplication()->processEvents( 1 ); //1 ms only
 
98
}