moved periodic timer control from main.cpp to rclmain_w.cpp

This commit is contained in:
dockes 2009-06-22 16:41:00 +00:00
parent 8a377d135a
commit 88475dabca
3 changed files with 16 additions and 8 deletions

View File

@ -37,8 +37,8 @@ static char rcsid[] = "@(#$Id: main.cpp,v 1.73 2008-12-17 08:01:40 dockes Exp $
#endif
#include <qtextcodec.h>
#include <qthread.h>
#include <qtimer.h>
#include <qthread.h>
#include <qmessagebox.h>
#include <qcheckbox.h>
#include <qcombobox.h>
@ -372,13 +372,12 @@ int main(int argc, char **argv)
// after mainWindow->show() , else the QMessageBox above never
// returns.
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
QTimer *timer = new QTimer(&app);
mainWindow->connect(timer, SIGNAL(timeout()),
mainWindow, SLOT(periodic100()));
timer->start(100);
app.connect(&app, SIGNAL(aboutToQuit()), mainWindow, SLOT(close()));
// Start the indexing thread. It will immediately go to sleep waiting for
// something to do.
start_idxthread(*rclconfig);
if (op_flags & OPT_q) {
SSearch::SSearchType stype;
if (op_flags & OPT_o) {
@ -393,9 +392,7 @@ int main(int argc, char **argv)
mainWindow->sSearch->searchTypCMB->setCurrentItem(int(stype));
mainWindow->
sSearch->setSearchString(QString::fromLocal8Bit(question.c_str()));
// The 200 ms are a hack to jump over the first db close by
// periodic100()...
QTimer::singleShot(200, mainWindow->sSearch, SLOT(startSimpleSearch()));
QTimer::singleShot(0, mainWindow->sSearch, SLOT(startSimpleSearch()));
}
// fprintf(stderr, "Go\n");
// Let's go

View File

@ -122,6 +122,8 @@ void RclMain::init()
spellform = 0;
m_idxStatusAck = false;
periodictimer = new QTimer(this);
(void)new HelpClient(this);
HelpClient::installMap(this->name(), "RCL.SEARCH.SIMPLE");
@ -260,6 +262,10 @@ void RclMain::init()
connect(catgBGRP, SIGNAL(clicked(int)), this, SLOT(catgFilter(int)));
if (prefs.catgToolBar && catgCMB)
connect(catgCMB, SIGNAL(activated(int)), this, SLOT(catgFilter(int)));
connect(periodictimer, SIGNAL(timeout()), this, SLOT(periodic100()));
// Start timer on a slow period (used for checking ^C). Will be
// speeded up during indexing
periodictimer->start(1000);
#if (QT_VERSION < 0x040000)
nextPageAction->setIconSet(createIconSet("nextpage.png"));
@ -470,9 +476,13 @@ void RclMain::toggleIndexing()
if (idxthread_getStatus() == IDXTS_NULL) {
// Indexing in progress
stop_indexing();
periodictimer->stop();
periodictimer->start(1000);
fileToggleIndexingAction->setText(tr("Update &Index"));
} else {
start_indexing(false);
periodictimer->stop();
periodictimer->start(100);
fileToggleIndexingAction->setText(tr("Stop &Indexing"));
}
fileToggleIndexingAction->setEnabled(FALSE);

View File

@ -123,6 +123,7 @@ private:
UIPrefsDialog *uiprefs;
ConfIndexW *indexConfig;
SpellW *spellform;
QTimer *periodictimer;
vector<TempFile> m_tempfiles;
map<QString, int> m_stemLangToId;