indexing confgui seems to sort of work

This commit is contained in:
dockes 2007-10-09 14:08:24 +00:00
parent c800954fc7
commit 46fedcb495
8 changed files with 118 additions and 33 deletions

View File

@ -13,7 +13,9 @@ HEADERS += \
../qtgui/searchclause_w.h \ ../qtgui/searchclause_w.h \
../qtgui/ssearch_w.h \ ../qtgui/ssearch_w.h \
../qtgui/uiprefs_w.h \ ../qtgui/uiprefs_w.h \
../qtgui/viewaction_w.h ../qtgui/viewaction_w.h \
../qtgui/confgui/confgui.h \
../qtgui/confgui/confguiindex.h
SOURCES += \ SOURCES += \
@ -30,7 +32,10 @@ SOURCES += \
../qtgui/searchclause_w.cpp \ ../qtgui/searchclause_w.cpp \
../qtgui/ssearch_w.cpp \ ../qtgui/ssearch_w.cpp \
../qtgui/uiprefs_w.cpp \ ../qtgui/uiprefs_w.cpp \
../qtgui/viewaction_w.cpp ../qtgui/viewaction_w.cpp \
../qtgui/confgui/confgui.cpp \
../qtgui/confgui/confguiindex.cpp
FORMS = \ FORMS = \
advsearch.ui \ advsearch.ui \
@ -55,7 +60,10 @@ unix {
-lz -lz
INCLUDEPATH += ../common ../index ../internfile ../query ../unac \ 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 POST_TARGETDEPS = ../lib/librcl.a
} }

View File

@ -1,5 +1,5 @@
#ifndef lint #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 #endif
#include <qglobal.h> #include <qglobal.h>
@ -64,27 +64,62 @@ ConfIndexW::ConfIndexW(QWidget *parent, RclConfig *config)
{ {
setOkButton(); setOkButton();
setCancelButton(); setCancelButton();
if ((m_conf = m_rclconf->cloneMainConfig()) == 0)
return; reloadPanels();
m_conf->holdWrites(true);
addTab(new ConfTopPanelW(this, m_conf), QObject::tr("Global parameters"));
addTab(new ConfSubPanelW(this, m_conf), QObject::tr("Local parameters"));
connect(this, SIGNAL(applyButtonPressed()), this, SLOT(acceptChanges())); connect(this, SIGNAL(applyButtonPressed()), this, SLOT(acceptChanges()));
connect(this, SIGNAL(cancelButtonPressed()), this, SLOT(rejectChanges()));
} }
void ConfIndexW::acceptChanges() void ConfIndexW::acceptChanges()
{ {
LOGDEB(("ConfIndexW::acceptChanges()\n")); LOGDEB(("ConfIndexW::acceptChanges()\n"));
if (m_conf) { if (!m_conf) {
if (!m_conf->holdWrites(false)) { LOGERR(("ConfIndexW::acceptChanges: no config\n"));
QMessageBox::critical(0, "Recoll", return;
tr("Can't write configuration file"));
}
delete m_conf;
m_conf = 0;
// Update in-memory config
m_rclconf->updateMainConfig();
} }
// 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<QWidget *>::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) ConfTopPanelW::ConfTopPanelW(QWidget *parent, ConfNull *config)

View File

@ -1,6 +1,6 @@
#ifndef _confguiindex_h_included_ #ifndef _confguiindex_h_included_
#define _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 * Classes to handle the gui for the indexing configuration. These group
@ -36,9 +36,12 @@ public:
ConfIndexW(QWidget *parent, RclConfig *config); ConfIndexW(QWidget *parent, RclConfig *config);
public slots: public slots:
void acceptChanges(); void acceptChanges();
void rejectChanges();
void reloadPanels();
private: private:
RclConfig *m_rclconf; RclConfig *m_rclconf;
ConfNull *m_conf; ConfNull *m_conf;
list<QWidget *> m_widgets;
}; };
/** /**

View File

@ -42,10 +42,9 @@ class IdxThread : public QThread , public DbIxStatusUpdater {
} }
return true; return true;
} }
ConfIndexer *indexer;
// Maintain a copy/snapshot of idx status // Maintain a copy/snapshot of idx status
DbIxStatus m_statusSnap; DbIxStatus m_statusSnap;
int loglevel; const RclConfig *cnf;
}; };
int stopindexing; int stopindexing;
@ -57,25 +56,32 @@ static int stopidxthread;
void IdxThread::run() void IdxThread::run()
{ {
DebugLog::getdbl()->setloglevel(loglevel);
recoll_threadinit(); recoll_threadinit();
for (;;) { for (;;) {
if (stopidxthread) { if (stopidxthread) {
deleteZ(indexer);
return; return;
} }
if (startindexing) { if (startindexing) {
startindexing = 0; startindexing = 0;
indexingdone = 0; indexingdone = 0;
indexingstatus = IDXTS_NULL; 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()) { if (indexer->index()) {
indexingstatus = IDXTS_OK; indexingstatus = IDXTS_OK;
indexingReason = ""; indexingReason = "";
} else { } else {
indexingstatus = IDXTS_ERROR; indexingstatus = IDXTS_ERROR;
indexingReason = "Indexation failed: " + indexer->getReason(); indexingReason = "Indexing failed: " + indexer->getReason();
} }
indexingdone = 1; indexingdone = 1;
delete indexer;
} }
msleep(100); msleep(100);
} }
@ -85,11 +91,7 @@ static IdxThread idxthread;
void start_idxthread(const RclConfig& cnf) void start_idxthread(const RclConfig& cnf)
{ {
// We have to make a copy of the config (setKeydir changes it during idxthread.cnf = &cnf;
// indexation)
RclConfig *myconf = new RclConfig(cnf);
idxthread.indexer = new ConfIndexer(myconf, &idxthread);
idxthread.loglevel = DebugLog::getdbl()->getlevel();
idxthread.start(); idxthread.start();
} }

View File

@ -89,6 +89,8 @@
<action name="toolsSpellAction"/> <action name="toolsSpellAction"/>
</item> </item>
<item text="&amp;Preferences" name="preferencesMenu"> <item text="&amp;Preferences" name="preferencesMenu">
<action name="indexConfigAction"/>
<separator/>
<action name="queryPrefsAction"/> <action name="queryPrefsAction"/>
<action name="extIdxAction"/> <action name="extIdxAction"/>
<separator/> <separator/>
@ -288,6 +290,14 @@
<string>Previous page of results</string> <string>Previous page of results</string>
</property> </property>
</action> </action>
<action>
<property name="name">
<cstring>indexConfigAction</cstring>
</property>
<property name="menuText">
<string>&amp;Indexing configuration</string>
</property>
</action>
<action> <action>
<property name="name"> <property name="name">
<cstring>queryPrefsAction</cstring> <cstring>queryPrefsAction</cstring>

View File

@ -1,5 +1,5 @@
#ifndef lint #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 #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -72,6 +72,8 @@ using std::pair;
#include "internfile.h" #include "internfile.h"
#include "docseqdb.h" #include "docseqdb.h"
#include "docseqhist.h" #include "docseqhist.h"
#include "confguiindex.h"
using namespace confgui;
#include "rclmain_w.h" #include "rclmain_w.h"
#include "moc_rclmain_w.cpp" #include "moc_rclmain_w.cpp"
@ -98,6 +100,7 @@ void RclMain::init()
asearchform = 0; asearchform = 0;
sortform = 0; sortform = 0;
uiprefs = 0; uiprefs = 0;
indexConfig = 0;
spellform = 0; spellform = 0;
m_searchId = 0; m_searchId = 0;
// Set the focus to the search terms entry: // Set the focus to the search terms entry:
@ -197,6 +200,7 @@ void RclMain::init()
toolsSpellAction->setEnabled(FALSE); toolsSpellAction->setEnabled(FALSE);
#endif #endif
connect(indexConfigAction, SIGNAL(activated()), this, SLOT(showIndexConfig()));
connect(queryPrefsAction, SIGNAL(activated()), this, SLOT(showUIPrefs())); connect(queryPrefsAction, SIGNAL(activated()), this, SLOT(showUIPrefs()));
connect(extIdxAction, SIGNAL(activated()), this, SLOT(showExtIdxDialog())); 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() void RclMain::showUIPrefs()
{ {
if (uiprefs == 0) { if (uiprefs == 0) {

View File

@ -54,6 +54,10 @@ public: DummyRclMainBase(QWidget *parent) :Q3MainWindow(parent){setupUi(this);}
//MOC_SKIP_END //MOC_SKIP_END
class Preview; class Preview;
namespace confgui {
class ConfIndexW;
}
using confgui::ConfIndexW;
class RclMain : public DummyRclMainBase class RclMain : public DummyRclMainBase
{ {
@ -84,6 +88,7 @@ public slots:
virtual void showExtIdxDialog(); virtual void showExtIdxDialog();
virtual void sortDataChanged(DocSeqSortSpec spec); virtual void sortDataChanged(DocSeqSortSpec spec);
virtual void showUIPrefs(); virtual void showUIPrefs();
virtual void showIndexConfig();
virtual void setUIPrefs(); virtual void setUIPrefs();
virtual void enableNextPage(bool); virtual void enableNextPage(bool);
virtual void enablePrevPage(bool); virtual void enablePrevPage(bool);
@ -114,6 +119,7 @@ private:
AdvSearch *asearchform; AdvSearch *asearchform;
SortForm *sortform; SortForm *sortform;
UIPrefsDialog *uiprefs; UIPrefsDialog *uiprefs;
ConfIndexW *indexConfig;
SpellW *spellform; SpellW *spellform;
RefCntr<Rcl::SearchData> m_searchData; RefCntr<Rcl::SearchData> m_searchData;

View File

@ -13,7 +13,9 @@ HEADERS += \
searchclause_w.h \ searchclause_w.h \
ssearch_w.h \ ssearch_w.h \
uiprefs_w.h \ uiprefs_w.h \
viewaction_w.h viewaction_w.h \
confgui/confgui.h \
confgui/confguiindex.h
SOURCES += \ SOURCES += \
@ -30,7 +32,9 @@ SOURCES += \
searchclause_w.cpp \ searchclause_w.cpp \
ssearch_w.cpp \ ssearch_w.cpp \
uiprefs_w.cpp \ uiprefs_w.cpp \
viewaction_w.cpp viewaction_w.cpp \
confgui/confgui.cpp \
confgui/confguiindex.cpp
FORMS = \ FORMS = \
advsearch.ui \ advsearch.ui \
@ -66,7 +70,7 @@ unix {
-lz -lz
INCLUDEPATH += ../common ../index ../internfile ../query ../unac \ INCLUDEPATH += ../common ../index ../internfile ../query ../unac \
../utils ../aspell ../rcldb ../utils ../aspell ../rcldb confgui
POST_TARGETDEPS = ../lib/librcl.a POST_TARGETDEPS = ../lib/librcl.a
} }