diff options
| author | 2010-09-19 16:37:19 +0000 | |
|---|---|---|
| committer | 2010-09-19 16:37:19 +0000 | |
| commit | c4d955d4020712843ce724625f9bf49dde57d218 (patch) | |
| tree | 8cb5093869df206385b3f19cc4a3fad448b87d6e /src/modules/help/index.cpp | |
| parent | removed logviewer progress dialog; added inline progressbar; fixes #968 (diff) | |
| download | KVIrc-c4d955d4020712843ce724625f9bf49dde57d218.tar.gz KVIrc-c4d955d4020712843ce724625f9bf49dde57d218.tar.bz2 KVIrc-c4d955d4020712843ce724625f9bf49dde57d218.zip | |
module help: removed modal progress dialog, implemented inline progress bar
module logviewer: reworked a bit the progressbar
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5022 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/help/index.cpp')
| -rw-r--r-- | src/modules/help/index.cpp | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/src/modules/help/index.cpp b/src/modules/help/index.cpp index 2db4979e6..0bd2a0033 100644 --- a/src/modules/help/index.cpp +++ b/src/modules/help/index.cpp @@ -48,8 +48,7 @@ #include <QTextCodec> #include <ctype.h> #include <QTextDocument> -#include <QProgressDialog> -#include "kvi_locale.h" +#include <QTimer> QT_BEGIN_NAMESPACE @@ -85,6 +84,11 @@ Index::Index( const QString &dp, const QString &hp ) lastWindowClosed = false; connect( qApp, SIGNAL(lastWindowClosed()), this, SLOT(setLastWinClosed()) ); + + m_pTimer = new QTimer(this); + m_pTimer->setSingleShot(true); + m_pTimer->setInterval(0); + connect(m_pTimer, SIGNAL(timeout()), this, SLOT(filterNext())); } Index::Index( const QStringList &dl, const QString &hp ) @@ -118,38 +122,30 @@ void Index::setDocList( const QStringList &lst ) docList = lst; } -int Index::makeIndex() +void Index::makeIndex() { - if ( !alreadyHaveDocList ) - setupDocumentList(); - if ( docList.isEmpty() ) - return 1; - QStringList::Iterator it = docList.begin(); - int steps = docList.count() / 100; - if ( !steps ) - steps++; - int prog = 0; - - QProgressDialog* pProgressDialog = new QProgressDialog( __tr2qs("Indexing help files"), __tr2qs("Cancel"), 0, docList.count() ); - pProgressDialog->setWindowTitle(__tr2qs("KVIrc")); - pProgressDialog->setMinimumDuration(500); - pProgressDialog->setWindowModality(Qt::WindowModal); + if ( !alreadyHaveDocList ) + setupDocumentList(); - for ( int i = 0; it != docList.end(); ++it, ++i ) { - if ( lastWindowClosed ||pProgressDialog->wasCanceled()) { - delete pProgressDialog; - return -1; - } - QUrl url(*it); - parseDocument( url.toLocalFile(), i ); - pProgressDialog->setValue(i); - if ( i%steps == 0 ) { - prog++; - emit indexingProgress( prog ); - } - } - delete pProgressDialog; - return 0; + lastWindowClosed = false; + emit indexingStart( docList.count() ); + dict.clear(); + m_iCurItem = 0; + m_pTimer->start(); //singleshot +} + +void Index::filterNext() +{ + if(m_iCurItem < docList.count() && !lastWindowClosed) + { + QUrl url(docList.at(m_iCurItem)); + parseDocument( url.toLocalFile(), m_iCurItem ); + emit indexingProgress( m_iCurItem ); + m_iCurItem++; + m_pTimer->start(); //singleshot + } else { + emit indexingEnd(); + } } void Index::setupDocumentList() |
