diff --git a/src/qt4gui/recoll.pro.in b/src/qt4gui/recoll.pro.in index f9a9e8d6..a2c4c292 100644 --- a/src/qt4gui/recoll.pro.in +++ b/src/qt4gui/recoll.pro.in @@ -13,7 +13,9 @@ HEADERS += \ ../qtgui/searchclause_w.h \ ../qtgui/ssearch_w.h \ ../qtgui/uiprefs_w.h \ - ../qtgui/viewaction_w.h + ../qtgui/viewaction_w.h \ + ../qtgui/confgui/confgui.h \ + ../qtgui/confgui/confguiindex.h SOURCES += \ @@ -30,7 +32,10 @@ SOURCES += \ ../qtgui/searchclause_w.cpp \ ../qtgui/ssearch_w.cpp \ ../qtgui/uiprefs_w.cpp \ - ../qtgui/viewaction_w.cpp + ../qtgui/viewaction_w.cpp \ + ../qtgui/confgui/confgui.cpp \ + ../qtgui/confgui/confguiindex.cpp + FORMS = \ advsearch.ui \ @@ -55,7 +60,10 @@ unix { -lz INCLUDEPATH += ../common ../index ../internfile ../query ../unac \ - ../utils ../aspell ../rcldb ../qt4gui/.ui ../qtgui ../../qtgui + ../utils ../aspell ../rcldb ../qt4gui/.ui \ + ../qtgui ../../qtgui \ + ../qtgui/confgui ../../qtgui/confgui + POST_TARGETDEPS = ../lib/librcl.a } diff --git a/src/qtgui/confgui/confguiindex.cpp b/src/qtgui/confgui/confguiindex.cpp index 78e5cf40..7a12b9aa 100644 --- a/src/qtgui/confgui/confguiindex.cpp +++ b/src/qtgui/confgui/confguiindex.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: confguiindex.cpp,v 1.5 2007-10-09 11:08:17 dockes Exp $ (C) 2007 J.F.Dockes"; +static char rcsid[] = "@(#$Id: confguiindex.cpp,v 1.6 2007-10-09 14:08:24 dockes Exp $ (C) 2007 J.F.Dockes"; #endif #include @@ -64,27 +64,62 @@ ConfIndexW::ConfIndexW(QWidget *parent, RclConfig *config) { setOkButton(); setCancelButton(); - if ((m_conf = m_rclconf->cloneMainConfig()) == 0) - return; - m_conf->holdWrites(true); - addTab(new ConfTopPanelW(this, m_conf), QObject::tr("Global parameters")); - addTab(new ConfSubPanelW(this, m_conf), QObject::tr("Local parameters")); + + reloadPanels(); + connect(this, SIGNAL(applyButtonPressed()), this, SLOT(acceptChanges())); + connect(this, SIGNAL(cancelButtonPressed()), this, SLOT(rejectChanges())); } void ConfIndexW::acceptChanges() { LOGDEB(("ConfIndexW::acceptChanges()\n")); - if (m_conf) { - if (!m_conf->holdWrites(false)) { - QMessageBox::critical(0, "Recoll", - tr("Can't write configuration file")); - } - delete m_conf; - m_conf = 0; - // Update in-memory config - m_rclconf->updateMainConfig(); + if (!m_conf) { + LOGERR(("ConfIndexW::acceptChanges: no config\n")); + return; } + // Let the changes to disk + if (!m_conf->holdWrites(false)) { + QMessageBox::critical(0, "Recoll", + tr("Can't write configuration file")); + } + // Delete local copy + delete m_conf; + m_conf = 0; + // Update in-memory config + m_rclconf->updateMainConfig(); + + QTimer::singleShot(0, this, SLOT(reloadPanels())); +} + +void ConfIndexW::rejectChanges() +{ + LOGDEB(("ConfIndexW::rejectChanges()\n")); + // Discard local changes, and make new copy + delete m_conf; + m_conf = 0; + QTimer::singleShot(0, this, SLOT(reloadPanels())); +} + +void ConfIndexW::reloadPanels() +{ + if ((m_conf = m_rclconf->cloneMainConfig()) == 0) + return; + m_conf->holdWrites(true); + for (list::iterator it = m_widgets.begin(); + it != m_widgets.end(); it++) { + removePage(*it); + delete *it; + } + m_widgets.clear(); + + QWidget *w = new ConfTopPanelW(this, m_conf); + m_widgets.push_back(w); + addTab(w, QObject::tr("Global parameters")); + + w = new ConfSubPanelW(this, m_conf); + m_widgets.push_back(w); + addTab(w, QObject::tr("Local parameters")); } ConfTopPanelW::ConfTopPanelW(QWidget *parent, ConfNull *config) diff --git a/src/qtgui/confgui/confguiindex.h b/src/qtgui/confgui/confguiindex.h index fbb72745..d346bfc0 100644 --- a/src/qtgui/confgui/confguiindex.h +++ b/src/qtgui/confgui/confguiindex.h @@ -1,6 +1,6 @@ #ifndef _confguiindex_h_included_ #define _confguiindex_h_included_ -/* @(#$Id: confguiindex.h,v 1.3 2007-10-09 11:08:17 dockes Exp $ (C) 2007 J.F.Dockes */ +/* @(#$Id: confguiindex.h,v 1.4 2007-10-09 14:08:24 dockes Exp $ (C) 2007 J.F.Dockes */ /** * Classes to handle the gui for the indexing configuration. These group @@ -36,9 +36,12 @@ public: ConfIndexW(QWidget *parent, RclConfig *config); public slots: void acceptChanges(); + void rejectChanges(); + void reloadPanels(); private: RclConfig *m_rclconf; ConfNull *m_conf; + list m_widgets; }; /** diff --git a/src/qtgui/idxthread.cpp b/src/qtgui/idxthread.cpp index 6b15f482..10e9fc33 100644 --- a/src/qtgui/idxthread.cpp +++ b/src/qtgui/idxthread.cpp @@ -42,10 +42,9 @@ class IdxThread : public QThread , public DbIxStatusUpdater { } return true; } - ConfIndexer *indexer; // Maintain a copy/snapshot of idx status DbIxStatus m_statusSnap; - int loglevel; + const RclConfig *cnf; }; int stopindexing; @@ -57,25 +56,32 @@ static int stopidxthread; void IdxThread::run() { - DebugLog::getdbl()->setloglevel(loglevel); recoll_threadinit(); for (;;) { if (stopidxthread) { - deleteZ(indexer); return; } if (startindexing) { startindexing = 0; indexingdone = 0; indexingstatus = IDXTS_NULL; + // We have to make a copy of the config (setKeydir changes + // it during indexation) + RclConfig *myconf = new RclConfig(*cnf); + int loglevel; + myconf->setKeyDir(""); + myconf->getConfParam("loglevel", &loglevel); + DebugLog::getdbl()->setloglevel(loglevel); + ConfIndexer *indexer = new ConfIndexer(myconf, this); if (indexer->index()) { indexingstatus = IDXTS_OK; indexingReason = ""; } else { indexingstatus = IDXTS_ERROR; - indexingReason = "Indexation failed: " + indexer->getReason(); + indexingReason = "Indexing failed: " + indexer->getReason(); } indexingdone = 1; + delete indexer; } msleep(100); } @@ -85,11 +91,7 @@ static IdxThread idxthread; void start_idxthread(const RclConfig& cnf) { - // We have to make a copy of the config (setKeydir changes it during - // indexation) - RclConfig *myconf = new RclConfig(cnf); - idxthread.indexer = new ConfIndexer(myconf, &idxthread); - idxthread.loglevel = DebugLog::getdbl()->getlevel(); + idxthread.cnf = &cnf; idxthread.start(); } diff --git a/src/qtgui/rclmain.ui b/src/qtgui/rclmain.ui index b4ba2ca3..8f6b83c2 100644 --- a/src/qtgui/rclmain.ui +++ b/src/qtgui/rclmain.ui @@ -89,6 +89,8 @@ + + @@ -288,6 +290,14 @@ Previous page of results + + + indexConfigAction + + + &Indexing configuration + + queryPrefsAction diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index 2ee92ab8..bf7a6fb1 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.43 2007-09-20 08:42:34 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.44 2007-10-09 14:08:24 dockes Exp $ (C) 2005 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -72,6 +72,8 @@ using std::pair; #include "internfile.h" #include "docseqdb.h" #include "docseqhist.h" +#include "confguiindex.h" +using namespace confgui; #include "rclmain_w.h" #include "moc_rclmain_w.cpp" @@ -98,6 +100,7 @@ void RclMain::init() asearchform = 0; sortform = 0; uiprefs = 0; + indexConfig = 0; spellform = 0; m_searchId = 0; // Set the focus to the search terms entry: @@ -197,6 +200,7 @@ void RclMain::init() toolsSpellAction->setEnabled(FALSE); #endif + connect(indexConfigAction, SIGNAL(activated()), this, SLOT(showIndexConfig())); connect(queryPrefsAction, SIGNAL(activated()), this, SLOT(showUIPrefs())); connect(extIdxAction, SIGNAL(activated()), this, SLOT(showExtIdxDialog())); @@ -502,6 +506,19 @@ void RclMain::showSpellDialog() } +void RclMain::showIndexConfig() +{ + LOGDEB(("showIndexConfig()\n")); + if (indexConfig == 0) { + indexConfig = new ConfIndexW(0, rclconfig); + LOGDEB(("showIndexConfig(): confindexW created\n")); + } else { + // Close and reopen, in hope that makes us visible... + indexConfig->close(); + } + indexConfig->show(); +} + void RclMain::showUIPrefs() { if (uiprefs == 0) { diff --git a/src/qtgui/rclmain_w.h b/src/qtgui/rclmain_w.h index 3d5549de..2e1ba069 100644 --- a/src/qtgui/rclmain_w.h +++ b/src/qtgui/rclmain_w.h @@ -54,6 +54,10 @@ public: DummyRclMainBase(QWidget *parent) :Q3MainWindow(parent){setupUi(this);} //MOC_SKIP_END class Preview; +namespace confgui { +class ConfIndexW; +} +using confgui::ConfIndexW; class RclMain : public DummyRclMainBase { @@ -84,6 +88,7 @@ public slots: virtual void showExtIdxDialog(); virtual void sortDataChanged(DocSeqSortSpec spec); virtual void showUIPrefs(); + virtual void showIndexConfig(); virtual void setUIPrefs(); virtual void enableNextPage(bool); virtual void enablePrevPage(bool); @@ -114,6 +119,7 @@ private: AdvSearch *asearchform; SortForm *sortform; UIPrefsDialog *uiprefs; + ConfIndexW *indexConfig; SpellW *spellform; RefCntr m_searchData; diff --git a/src/qtgui/recoll.pro.in b/src/qtgui/recoll.pro.in index 285dc4c4..79b601a6 100644 --- a/src/qtgui/recoll.pro.in +++ b/src/qtgui/recoll.pro.in @@ -13,7 +13,9 @@ HEADERS += \ searchclause_w.h \ ssearch_w.h \ uiprefs_w.h \ - viewaction_w.h + viewaction_w.h \ + confgui/confgui.h \ + confgui/confguiindex.h SOURCES += \ @@ -30,7 +32,9 @@ SOURCES += \ searchclause_w.cpp \ ssearch_w.cpp \ uiprefs_w.cpp \ - viewaction_w.cpp + viewaction_w.cpp \ + confgui/confgui.cpp \ + confgui/confguiindex.cpp FORMS = \ advsearch.ui \ @@ -66,7 +70,7 @@ unix { -lz INCLUDEPATH += ../common ../index ../internfile ../query ../unac \ - ../utils ../aspell ../rcldb + ../utils ../aspell ../rcldb confgui POST_TARGETDEPS = ../lib/librcl.a }