add show stats entry to file menu

This commit is contained in:
Jean-Francois Dockes 2016-04-08 19:00:18 +02:00
parent 6f114bf58b
commit c09ca43fb7
6 changed files with 81 additions and 35 deletions

View file

@ -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)) {

View file

@ -84,6 +84,7 @@
<addaction name="separator"/>
<addaction name="showMissingHelpers_Action"/>
<addaction name="showActiveTypes_Action"/>
<addaction name="actionShow_index_statistics"/>
<addaction name="separator"/>
<addaction name="toggleFullScreenAction"/>
<addaction name="separator"/>
@ -374,6 +375,9 @@
</property>
</action>
<action name="enbSynAction">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Enable synonyms</string>
</property>
@ -383,9 +387,6 @@
<property name="name" stdset="0">
<cstring>enbSynAction</cstring>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</action>
<action name="toggleFullScreenAction">
<property name="text">
@ -521,6 +522,11 @@
<string>Indexing with special options</string>
</property>
</action>
<action name="actionShow_index_statistics">
<property name="text">
<string>Show index statistics</string>
</property>
</action>
</widget>
<layoutdefault spacing="2" margin="2"/>
<customwidgets>

View file

@ -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()),

View file

@ -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();

View file

@ -22,9 +22,6 @@
#include <list>
#include <map>
#include <string>
using std::list;
using std::multimap;
using std::string;
#include <qmessagebox.h>
#include <qpushbutton.h>
@ -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<comboboxchoice>::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<string> 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);
int idx = cmbIdx((comboboxchoice)prefs.termMatchType);
expTypeCMB->setCurrentIndex(idx);
onModeChanged(idx);
}
modeSet(cmbidx);
int SpellW::cmbIdx(comboboxchoice mode)
{
vector<comboboxchoice>::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<string> 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];
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"));

View file

@ -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<comboboxchoice> m_c2t;
comboboxchoice m_prevmode;
void init();
void copy();
void showStats();
int cmbIdx(comboboxchoice mode);
void setModeCommon(comboboxchoice mode);
};
#endif /* _ASPELL_W_H_INCLUDED_ */