From 88475dabca6afc78e21ad0af958f20104b652c7a Mon Sep 17 00:00:00 2001 From: dockes Date: Mon, 22 Jun 2009 16:41:00 +0000 Subject: [PATCH] moved periodic timer control from main.cpp to rclmain_w.cpp --- src/qtgui/main.cpp | 13 +++++-------- src/qtgui/rclmain_w.cpp | 10 ++++++++++ src/qtgui/rclmain_w.h | 1 + 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index 6b19915c..e9ba28c0 100644 --- a/src/qtgui/main.cpp +++ b/src/qtgui/main.cpp @@ -37,8 +37,8 @@ static char rcsid[] = "@(#$Id: main.cpp,v 1.73 2008-12-17 08:01:40 dockes Exp $ #endif #include -#include #include +#include #include #include #include @@ -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 diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index db131ee3..17c7ea7a 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -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); diff --git a/src/qtgui/rclmain_w.h b/src/qtgui/rclmain_w.h index c2e25248..2792727c 100644 --- a/src/qtgui/rclmain_w.h +++ b/src/qtgui/rclmain_w.h @@ -123,6 +123,7 @@ private: UIPrefsDialog *uiprefs; ConfIndexW *indexConfig; SpellW *spellform; + QTimer *periodictimer; vector m_tempfiles; map m_stemLangToId;