diff --git a/src/qtgui/rclm_wins.cpp b/src/qtgui/rclm_wins.cpp index fb23796f..e13950c1 100644 --- a/src/qtgui/rclm_wins.cpp +++ b/src/qtgui/rclm_wins.cpp @@ -74,6 +74,14 @@ void RclMain::showSpellDialog() } } +void RclMain::showIndexStatistics() +{ + showSpellDialog(); + if (spellform == 0) + return; + spellform->setMode(SpellW::TYPECMB_STATS); +} + void RclMain::showFragButs() { if (fragbuts && fragbuts->isStale(0)) { diff --git a/src/qtgui/rclmain.ui b/src/qtgui/rclmain.ui index 3b4142d3..2dbb00ed 100644 --- a/src/qtgui/rclmain.ui +++ b/src/qtgui/rclmain.ui @@ -84,6 +84,7 @@ + @@ -374,6 +375,9 @@ + + true + Enable synonyms @@ -383,9 +387,6 @@ enbSynAction - - true - @@ -521,6 +522,11 @@ Indexing with special options + + + Show index statistics + + diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index e038f719..78514680 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -334,7 +334,8 @@ void RclMain::init() this, SLOT(saveLastQuery())); connect(actionLoad_saved_query, SIGNAL(triggered()), this, SLOT(loadSavedQuery())); - + connect(actionShow_index_statistics, SIGNAL(triggered()), + this, SLOT(showIndexStatistics())); connect(helpAbout_RecollAction, SIGNAL(triggered()), this, SLOT(showAboutDialog())); connect(showMissingHelpers_Action, SIGNAL(triggered()), diff --git a/src/qtgui/rclmain_w.h b/src/qtgui/rclmain_w.h index 1fd2e85c..432e241a 100644 --- a/src/qtgui/rclmain_w.h +++ b/src/qtgui/rclmain_w.h @@ -122,6 +122,7 @@ public slots: virtual void previewClosed(Preview *w); virtual void showAdvSearchDialog(); virtual void showSpellDialog(); + virtual void showIndexStatistics(); virtual void showFragButs(); virtual void showSpecIdx(); virtual void showAboutDialog(); diff --git a/src/qtgui/spell_w.cpp b/src/qtgui/spell_w.cpp index 731076ee..10b7a961 100644 --- a/src/qtgui/spell_w.cpp +++ b/src/qtgui/spell_w.cpp @@ -22,9 +22,6 @@ #include #include #include -using std::list; -using std::multimap; -using std::string; #include #include @@ -53,6 +50,10 @@ using std::string; #include "rclaspell.h" #endif +using std::list; +using std::multimap; +using std::string; + void SpellW::init() { m_c2t.clear(); @@ -73,15 +74,6 @@ void SpellW::init() expTypeCMB->addItem(tr("Show index statistics")); m_c2t.push_back(TYPECMB_STATS); - int typ = prefs.termMatchType; - vector::const_iterator it = - std::find(m_c2t.begin(), m_c2t.end(), typ); - if (it == m_c2t.end()) - it = m_c2t.begin(); - int cmbidx = it - m_c2t.begin(); - - expTypeCMB->setCurrentIndex(cmbidx); - // Stemming language combobox stemLangCMB->clear(); vector langs; @@ -105,7 +97,7 @@ void SpellW::init() connect(baseWordLE, SIGNAL(returnPressed()), this, SLOT(doExpand())); connect(expandPB, SIGNAL(clicked()), this, SLOT(doExpand())); connect(dismissPB, SIGNAL(clicked()), this, SLOT(close())); - connect(expTypeCMB, SIGNAL(activated(int)), this, SLOT(modeSet(int))); + connect(expTypeCMB, SIGNAL(activated(int)), this, SLOT(onModeChanged(int))); resTW->setShowGrid(0); #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) @@ -122,11 +114,18 @@ void SpellW::init() resTW->setColumnWidth(1, 150); resTW->installEventFilter(this); - if (o_index_stripchars) { - caseSensCB->setEnabled(false); - caseSensCB->setEnabled(false); - } - modeSet(cmbidx); + int idx = cmbIdx((comboboxchoice)prefs.termMatchType); + expTypeCMB->setCurrentIndex(idx); + onModeChanged(idx); +} + +int SpellW::cmbIdx(comboboxchoice mode) +{ + vector::const_iterator it = + std::find(m_c2t.begin(), m_c2t.end(), mode); + if (it == m_c2t.end()) + it = m_c2t.begin(); + return it - m_c2t.begin(); } static const int maxexpand = 10000; @@ -306,6 +305,8 @@ void SpellW::showStats() if (!theconfig) return; + baseWordLE->setText(QString::fromLocal8Bit(theconfig->getDbDir().c_str())); + ExecCmd cmd; vector args; int status; @@ -313,9 +314,9 @@ void SpellW::showStats() args.push_back(theconfig->getDbDir()); string output; status = cmd.doexec("du", args, 0, &output); - int dbkbytes = 0; + long long dbkbytes = 0; if (!status) { - dbkbytes = atoi(output.c_str()); + dbkbytes = atoll(output.c_str()); } resTW->setRowCount(row+1); resTW->setItem(row, 0, @@ -372,12 +373,34 @@ void SpellW::textDoubleClicked(int row, int) emit(wordSelect(item->text())); } -void SpellW::modeSet(int idx) +void SpellW::onModeChanged(int idx) { if (idx < 0 || idx > int(m_c2t.size())) return; - comboboxchoice mode = m_c2t[idx]; + comboboxchoice mode = m_c2t[idx]; + setModeCommon(mode); +} + +void SpellW::setMode(comboboxchoice mode) +{ + expTypeCMB->setCurrentIndex(cmbIdx(mode)); + setModeCommon(mode); +} + +void SpellW::setModeCommon(comboboxchoice mode) +{ + if (m_prevmode == TYPECMB_STATS) { + baseWordLE->setText(""); + } + m_prevmode = mode; resTW->setRowCount(0); + if (o_index_stripchars) { + caseSensCB->setEnabled(false); + diacSensCB->setEnabled(false); + } else { + caseSensCB->setEnabled(true); + diacSensCB->setEnabled(true); + } if (mode == TYPECMB_STEM) { stemLangCMB->setEnabled(true); @@ -387,8 +410,6 @@ void SpellW::modeSet(int idx) caseSensCB->setEnabled(false); } else { stemLangCMB->setEnabled(false); - diacSensCB->setEnabled(true); - caseSensCB->setEnabled(true); } if (mode == TYPECMB_STATS) baseWordLE->setEnabled(false); @@ -400,6 +421,8 @@ void SpellW::modeSet(int idx) QStringList labels(tr("Item")); labels.push_back(tr("Value")); resTW->setHorizontalHeaderLabels(labels); + diacSensCB->setEnabled(false); + caseSensCB->setEnabled(false); doExpand(); } else { QStringList labels(tr("Term")); diff --git a/src/qtgui/spell_w.h b/src/qtgui/spell_w.h index faa99419..d1cfd6a3 100644 --- a/src/qtgui/spell_w.h +++ b/src/qtgui/spell_w.h @@ -25,34 +25,41 @@ #include "ui_spell.h" class SpellW : public QWidget, public Ui::SpellBase { - Q_OBJECT + Q_OBJECT; public: SpellW(QWidget* parent = 0) - : QWidget(parent) - { + : QWidget(parent), m_prevmode(TYPECMB_NONE) { setupUi(this); init(); } virtual bool eventFilter(QObject *target, QEvent *event ); + + enum comboboxchoice {TYPECMB_NONE, TYPECMB_WILD, TYPECMB_REG, TYPECMB_STEM, + TYPECMB_ASPELL, TYPECMB_STATS}; public slots: virtual void doExpand(); virtual void wordChanged(const QString&); virtual void textDoubleClicked(); virtual void textDoubleClicked(int, int); - virtual void modeSet(int); + virtual void setMode(comboboxchoice); +private slots: + virtual void onModeChanged(int); + signals: void wordSelect(QString); private: - enum comboboxchoice {TYPECMB_WILD, TYPECMB_REG, TYPECMB_STEM, - TYPECMB_ASPELL, TYPECMB_STATS}; // combobox index to expansion type - std::vector m_c2t; + std::vector m_c2t; + comboboxchoice m_prevmode; + void init(); void copy(); void showStats(); + int cmbIdx(comboboxchoice mode); + void setModeCommon(comboboxchoice mode); }; #endif /* _ASPELL_W_H_INCLUDED_ */