allow displaying current doc filter (media/message etc.) as menu

This commit is contained in:
Jean-Francois Dockes 2014-05-27 10:49:12 +02:00
parent 7def227c19
commit bd46735d9c
7 changed files with 227 additions and 106 deletions

View File

@ -104,7 +104,7 @@ void rwSettings(bool writing)
"/Recoll/prefs/ssearch/noComplete", Bool, false); "/Recoll/prefs/ssearch/noComplete", Bool, false);
SETTING_RW(prefs.ssearchAsYouType, SETTING_RW(prefs.ssearchAsYouType,
"/Recoll/prefs/ssearch/asYouType", Bool, false); "/Recoll/prefs/ssearch/asYouType", Bool, false);
SETTING_RW(prefs.catgToolBar, "/Recoll/prefs/catgToolBar", Bool, false); SETTING_RW(prefs.filterCtlStyle, "/Recoll/prefs/filterCtlStyle", Int, 0);
SETTING_RW(prefs.ssearchAutoPhrase, SETTING_RW(prefs.ssearchAutoPhrase,
"/Recoll/prefs/ssearchAutoPhrase", Bool, true); "/Recoll/prefs/ssearchAutoPhrase", Bool, true);
SETTING_RW(prefs.ssearchAutoPhraseThreshPC, SETTING_RW(prefs.ssearchAutoPhraseThreshPC,

View File

@ -45,7 +45,8 @@ class PrefsPack {
bool ssearchAsYouType; bool ssearchAsYouType;
// Decide if we display the doc category filter control as a // Decide if we display the doc category filter control as a
// toolbar+combobox or as a button group under simple search // toolbar+combobox or as a button group under simple search
bool catgToolBar; enum FilterCtlStyle {FCS_BT, FCS_CMB, FCS_MN};
int filterCtlStyle;
int respagesize; int respagesize;
int maxhltextmbs; int maxhltextmbs;
QString reslistfontfamily; QString reslistfontfamily;

View File

@ -46,29 +46,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QFrame" name="catgBGRP">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QRadioButton" name="allRDB">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>45</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>All</string>
</property>
</widget>
</widget>
</item>
<item> <item>
<widget class="ResList" name="reslist" native="true"> <widget class="ResList" name="reslist" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
@ -82,46 +59,13 @@
</layout> </layout>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="Toolbar">
<property name="windowTitle">
<string>Search tools</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="toolsAdvanced_SearchAction"/>
<addaction name="toolsDoc_HistoryAction"/>
<addaction name="toolsSpellAction"/>
</widget>
<widget class="QToolBar" name="Toolbar1">
<property name="windowTitle">
<string>Result list</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="firstPageAction"/>
<addaction name="prevPageAction"/>
<addaction name="nextPageAction"/>
<addaction name="separator"/>
<addaction name="actionSortByDateAsc"/>
<addaction name="actionSortByDateDesc"/>
<addaction name="separator"/>
<addaction name="actionShowResultsAsTable"/>
</widget>
<widget class="QMenuBar" name="MenuBar"> <widget class="QMenuBar" name="MenuBar">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>800</width>
<height>21</height> <height>25</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="fileMenu"> <widget class="QMenu" name="fileMenu">

View File

@ -52,6 +52,7 @@ using std::pair;
#include <QFileSystemWatcher> #include <QFileSystemWatcher>
#include <QThread> #include <QThread>
#include <QProgressDialog> #include <QProgressDialog>
#include <QToolBar>
#include "recoll.h" #include "recoll.h"
#include "debuglog.h" #include "debuglog.h"
@ -156,35 +157,62 @@ void RclMain::init()
} }
curid->setChecked(true); curid->setChecked(true);
// Toolbar+combobox version of the category selector m_toolsTB = new QToolBar(this);
QComboBox *catgCMB = 0; m_toolsTB->setObjectName(QString::fromUtf8("m_toolsTB"));
if (prefs.catgToolBar) { m_toolsTB->addAction(toolsAdvanced_SearchAction);
QToolBar *catgToolBar = new QToolBar(this); m_toolsTB->addAction(toolsDoc_HistoryAction);
catgCMB = new QComboBox(catgToolBar); m_toolsTB->addAction(toolsSpellAction);
catgCMB->setEditable(FALSE); this->addToolBar(Qt::TopToolBarArea, m_toolsTB);
catgCMB->addItem(tr("All"));
catgToolBar->setObjectName(QString::fromUtf8("catgToolBar"));
catgCMB->setToolTip(tr("Document category filter"));
catgToolBar->addWidget(catgCMB);
this->addToolBar(Qt::TopToolBarArea, catgToolBar);
}
// Document categories buttons m_resTB = new QToolBar(this);
QHBoxLayout *bgrphbox = new QHBoxLayout(catgBGRP); m_resTB->setObjectName(QString::fromUtf8("m_resTB"));
QButtonGroup *bgrp = new QButtonGroup(catgBGRP); this->addToolBar(Qt::TopToolBarArea, m_resTB);
// Document filter buttons and combobox
// Combobox version of the document filter control
m_filtCMB = new QComboBox(m_resTB);
m_filtCMB->setEditable(FALSE);
m_filtCMB->addItem(tr("All"));
m_filtCMB->setToolTip(tr("Document filter"));
// Buttons version of the document filter control
m_filtFRM = new QFrame(this);
m_filtFRM->setObjectName(QString::fromUtf8("m_filtFRM"));
QSizePolicy sizePolicy2(QSizePolicy::Preferred, QSizePolicy::Maximum);
sizePolicy2.setHorizontalStretch(0);
sizePolicy2.setVerticalStretch(0);
sizePolicy2.setHeightForWidth(m_filtFRM->sizePolicy().hasHeightForWidth());
m_filtFRM->setSizePolicy(sizePolicy2);
QHBoxLayout *bgrphbox = new QHBoxLayout(m_filtFRM);
m_filtBGRP = new QButtonGroup(m_filtFRM);
QRadioButton *allRDB = new QRadioButton(m_filtFRM);
verticalLayout->insertWidget(1, m_filtFRM);
allRDB->setObjectName(QString::fromUtf8("allRDB"));
allRDB->setGeometry(QRect(0, 0, 45, 20));
allRDB->setText(tr("All"));
bgrphbox->addWidget(allRDB); bgrphbox->addWidget(allRDB);
int bgrpid = 0; int bgrpid = 0;
bgrp->addButton(allRDB, bgrpid++); m_filtBGRP->addButton(allRDB, bgrpid++);
connect(bgrp, SIGNAL(buttonClicked(int)), this, SLOT(catgFilter(int)));
allRDB->setChecked(true); allRDB->setChecked(true);
// Menu version of the document filter control
m_filtMN = new QMenu(MenuBar);
m_filtMN->setObjectName(QString::fromUtf8("m_filtMN"));
MenuBar->insertMenu(helpMenu->menuAction(), m_filtMN);
m_filtMN->setTitle("F&ilter");
QActionGroup *fltag = new QActionGroup(this);
fltag->setExclusive(true);
QAction *act = fltag->addAction(tr("All"));
m_filtMN->addAction(act);
act->setCheckable(true);
act->setData((int)0);
// Go through the filter list and setup buttons and combobox
vector<string> cats; vector<string> cats;
theconfig->getGuiFilterNames(cats); theconfig->getGuiFilterNames(cats);
// Text for button 0 is not used. Next statement just avoids unused
// variable compiler warning for catg_strings
m_catgbutvec.push_back(catg_strings[0]); m_catgbutvec.push_back(catg_strings[0]);
for (vector<string>::const_iterator it = cats.begin(); for (vector<string>::const_iterator it = cats.begin();
it != cats.end(); it++) { it != cats.end(); it++) {
QRadioButton *but = new QRadioButton(catgBGRP); QRadioButton *but = new QRadioButton(m_filtFRM);
QString catgnm = QString::fromUtf8(it->c_str(), it->length()); QString catgnm = QString::fromUtf8(it->c_str(), it->length());
m_catgbutvec.push_back(*it); m_catgbutvec.push_back(*it);
// We strip text before the first colon before setting the button name. // We strip text before the first colon before setting the button name.
@ -196,15 +224,19 @@ void RclMain::init()
but_txt = catgnm.right(catgnm.size()-(colon+1)); but_txt = catgnm.right(catgnm.size()-(colon+1));
} }
but->setText(tr(but_txt.toUtf8())); but->setText(tr(but_txt.toUtf8()));
if (prefs.catgToolBar && catgCMB) m_filtCMB->addItem(tr(but_txt.toUtf8()));
catgCMB->addItem(tr(catgnm.toUtf8()));
bgrphbox->addWidget(but); bgrphbox->addWidget(but);
bgrp->addButton(but, bgrpid++); m_filtBGRP->addButton(but, bgrpid++);
QAction *act = fltag->addAction(tr(but_txt.toUtf8()));
m_filtMN->addAction(act);
act->setCheckable(true);
act->setData((int)(m_catgbutvec.size()-1));
m_filtMN->connect(m_filtMN, SIGNAL(triggered(QAction *)), this,
SLOT(catgFilter(QAction *)));
} }
catgBGRP->setLayout(bgrphbox); m_filtFRM->setLayout(bgrphbox);
connect(m_filtBGRP, SIGNAL(buttonClicked(int)),this, SLOT(catgFilter(int)));
if (prefs.catgToolBar) connect(m_filtCMB, SIGNAL(activated(int)), this, SLOT(catgFilter(int)));
catgBGRP->hide();
sSearch->queryText->installEventFilter(this); sSearch->queryText->installEventFilter(this);
@ -266,9 +298,6 @@ void RclMain::init()
connect(extIdxAction, SIGNAL(triggered()), connect(extIdxAction, SIGNAL(triggered()),
this, SLOT(showExtIdxDialog())); this, SLOT(showExtIdxDialog()));
if (prefs.catgToolBar && catgCMB)
connect(catgCMB, SIGNAL(activated(int)),
this, SLOT(catgFilter(int)));
connect(toggleFullScreenAction, SIGNAL(triggered()), connect(toggleFullScreenAction, SIGNAL(triggered()),
this, SLOT(toggleFullScreen())); this, SLOT(toggleFullScreen()));
connect(actionShowQueryDetails, SIGNAL(triggered()), connect(actionShowQueryDetails, SIGNAL(triggered()),
@ -350,6 +379,8 @@ void RclMain::init()
connect(reslist, SIGNAL(previewRequested(Rcl::Doc)), connect(reslist, SIGNAL(previewRequested(Rcl::Doc)),
this, SLOT(startPreview(Rcl::Doc))); this, SLOT(startPreview(Rcl::Doc)));
setFilterCtlStyle(prefs.filterCtlStyle);
if (prefs.keepSort && prefs.sortActive) { if (prefs.keepSort && prefs.sortActive) {
m_sortspec.field = (const char *)prefs.sortField.toUtf8(); m_sortspec.field = (const char *)prefs.sortField.toUtf8();
m_sortspec.desc = prefs.sortDesc; m_sortspec.desc = prefs.sortDesc;
@ -370,6 +401,49 @@ void RclMain::resultCount(int n)
actionSortByDateDesc->setEnabled(n>0); actionSortByDateDesc->setEnabled(n>0);
} }
void RclMain::setFilterCtlStyle(int stl)
{
switch (stl) {
case PrefsPack::FCS_MN:
setupResTB(false);
m_filtFRM->setVisible(false);
m_filtMN->menuAction()->setVisible(true);
break;
case PrefsPack::FCS_CMB:
setupResTB(true);
m_filtFRM->setVisible(false);
m_filtMN->menuAction()->setVisible(false);
break;
case PrefsPack::FCS_BT:
default:
setupResTB(false);
m_filtFRM->setVisible(true);
m_filtMN->menuAction()->setVisible(false);
}
}
// Set up the "results" toolbox, adding the filter combobox or not depending
// on config option
void RclMain::setupResTB(bool combo)
{
m_resTB->clear();
m_resTB->addAction(firstPageAction);
m_resTB->addAction(prevPageAction);
m_resTB->addAction(nextPageAction);
m_resTB->addSeparator();
m_resTB->addAction(actionSortByDateAsc);
m_resTB->addAction(actionSortByDateDesc);
if (combo) {
m_resTB->addSeparator();
m_filtCMB->show();
m_resTB->addWidget(m_filtCMB);
} else {
m_filtCMB->hide();
}
m_resTB->addSeparator();
m_resTB->addAction(actionShowResultsAsTable);
}
// This is called by a timer right after we come up. Try to open // This is called by a timer right after we come up. Try to open
// the database and talk to the user if we can't // the database and talk to the user if we can't
void RclMain::initDbOpen() void RclMain::initDbOpen()
@ -2080,13 +2154,35 @@ QString RclMain::getQueryDescription()
return QString::fromUtf8(m_source->getDescription().c_str()); return QString::fromUtf8(m_source->getDescription().c_str());
} }
// User pressed a category button: set filter params in reslist // Set filter, action style
void RclMain::catgFilter(QAction *act)
{
int id = act->data().toInt();
catgFilter(id);
}
// User pressed a filter button: set filter params in reslist
void RclMain::catgFilter(int id) void RclMain::catgFilter(int id)
{ {
LOGDEB(("RclMain::catgFilter: id %d\n")); LOGDEB(("RclMain::catgFilter: id %d\n", id));
if (id < 0 || id >= int(m_catgbutvec.size())) if (id < 0 || id >= int(m_catgbutvec.size()))
return; return;
switch (prefs.filterCtlStyle) {
case PrefsPack::FCS_MN:
m_filtCMB->setCurrentIndex(id);
m_filtBGRP->buttons()[id]->setChecked(true);
break;
case PrefsPack::FCS_CMB:
m_filtBGRP->buttons()[id]->setChecked(true);
m_filtMN->actions()[id]->setChecked(true);
break;
case PrefsPack::FCS_BT:
default:
m_filtCMB->setCurrentIndex(id);
m_filtMN->actions()[id]->setChecked(true);
}
m_filtspec.reset(); m_filtspec.reset();
if (id != 0) { if (id != 0) {

View File

@ -31,6 +31,7 @@
#include "spell_w.h" #include "spell_w.h"
#include "refcntr.h" #include "refcntr.h"
#include "pathut.h" #include "pathut.h"
#include "guiutils.h"
class IdxSchedW; class IdxSchedW;
class ExecCmd; class ExecCmd;
@ -68,6 +69,8 @@ public:
displayingTable(0), displayingTable(0),
m_idNoStem(0), m_idNoStem(0),
m_idAllStem(0), m_idAllStem(0),
m_toolsTB(0), m_resTB(0),
m_filtFRM(0), m_filtCMB(0), m_filtBGRP(0), m_filtMN(0),
m_idxproc(0), m_idxproc(0),
m_sortspecnochange(false), m_sortspecnochange(false),
m_indexerState(IXST_RUNNINGNOTMINE), m_indexerState(IXST_RUNNINGNOTMINE),
@ -144,6 +147,7 @@ public slots:
virtual void setStemLang(QAction *id); virtual void setStemLang(QAction *id);
virtual void adjustPrefsMenu(); virtual void adjustPrefsMenu();
virtual void catgFilter(int); virtual void catgFilter(int);
virtual void catgFilter(QAction *);
virtual void initDbOpen(); virtual void initDbOpen();
virtual void toggleFullScreen(); virtual void toggleFullScreen();
virtual void on_actionSortByDateAsc_toggled(bool on); virtual void on_actionSortByDateAsc_toggled(bool on);
@ -152,6 +156,7 @@ public slots:
virtual void onSortDataChanged(DocSeqSortSpec); virtual void onSortDataChanged(DocSeqSortSpec);
virtual void resultCount(int); virtual void resultCount(int);
virtual void applyStyleSheet(); virtual void applyStyleSheet();
virtual void setFilterCtlStyle(int stl);
signals: signals:
void docSourceChanged(RefCntr<DocSequence>); void docSourceChanged(RefCntr<DocSequence>);
@ -175,8 +180,14 @@ private:
QTimer *periodictimer; QTimer *periodictimer;
ResTable *restable; ResTable *restable;
bool displayingTable; bool displayingTable;
QAction *m_idNoStem; QAction *m_idNoStem;
QAction *m_idAllStem; QAction *m_idAllStem;
QToolBar *m_toolsTB;
QToolBar *m_resTB;
QFrame *m_filtFRM;
QComboBox *m_filtCMB;
QButtonGroup *m_filtBGRP;
QMenu *m_filtMN;
QFileSystemWatcher m_watcher; QFileSystemWatcher m_watcher;
vector<ExecCmd*> m_viewers; vector<ExecCmd*> m_viewers;
ExecCmd *m_idxproc; // Indexing process ExecCmd *m_idxproc; // Indexing process
@ -196,6 +207,7 @@ private:
QString m_urltoview; QString m_urltoview;
virtual void init(); virtual void init();
virtual void setupResTB(bool combo);
virtual void previewPrevOrNextInTab(Preview *, int sid, int docnum, virtual void previewPrevOrNextInTab(Preview *, int sid, int docnum,
bool next); bool next);
virtual void execViewer(const map<string, string>& subs, bool istempfile, virtual void execViewer(const map<string, string>& subs, bool istempfile,

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>531</width> <width>542</width>
<height>427</height> <height>449</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -149,6 +149,9 @@
<property name="text"> <property name="text">
<string>&lt;BR&gt;</string> <string>&lt;BR&gt;</string>
</property> </property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget> </widget>
</item> </item>
<item> <item>
@ -156,6 +159,9 @@
<property name="text"> <property name="text">
<string>&lt;PRE&gt;</string> <string>&lt;PRE&gt;</string>
</property> </property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget> </widget>
</item> </item>
<item> <item>
@ -163,6 +169,9 @@
<property name="text"> <property name="text">
<string>&lt;PRE&gt; + wrap</string> <string>&lt;PRE&gt; + wrap</string>
</property> </property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -175,14 +184,48 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="catgToolBarCB"> <layout class="QHBoxLayout" name="horizontalLayout1">
<property name="text"> <item>
<string>Display category filter as toolbar instead of button panel (needs restart).</string> <widget class="QLabel" name="label1">
</property> <property name="toolTip">
<property name="checked"> <string>Decide if document filters are shown as radio buttons, toolbar combobox, or menu.</string>
<bool>false</bool> </property>
</property> <property name="text">
</widget> <string>Document filter choice style:</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="filterBT_RB">
<property name="text">
<string>Buttons Panel</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup_2</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="filterCMB_RB">
<property name="text">
<string>Toolbar Combobox</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup_2</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="filterMN_RB">
<property name="text">
<string>Menu</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup_2</string>
</attribute>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="ssNoCompleteCB"> <widget class="QCheckBox" name="ssNoCompleteCB">
@ -397,7 +440,7 @@
<item> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<item> <item>
<widget class="QLabel" name="tLSTL"> <widget class="QLabel" name="tLSTL1">
<property name="text"> <property name="text">
<string>Snippets window CSS file</string> <string>Snippets window CSS file</string>
</property> </property>
@ -882,4 +925,8 @@ May be slow for big documents.</string>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<resources/> <resources/>
<connections/> <connections/>
<buttongroups>
<buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroup_2"/>
</buttongroups>
</ui> </ui>

View File

@ -103,7 +103,20 @@ void UIPrefsDialog::setFromPrefs()
pageLenSB->setValue(prefs.respagesize); pageLenSB->setValue(prefs.respagesize);
collapseDupsCB->setChecked(prefs.collapseDuplicates); collapseDupsCB->setChecked(prefs.collapseDuplicates);
maxHLTSB->setValue(prefs.maxhltextmbs); maxHLTSB->setValue(prefs.maxhltextmbs);
catgToolBarCB->setChecked(prefs.catgToolBar);
switch (prefs.filterCtlStyle) {
case PrefsPack::FCS_MN:
filterMN_RB->setChecked(1);
break;
case PrefsPack::FCS_CMB:
filterCMB_RB->setChecked(1);
break;
case PrefsPack::FCS_BT:
default:
fprintf(stderr, "filter ctl style %d\n", prefs.filterCtlStyle);
filterBT_RB->setChecked(1);
break;
}
ssAutoSpaceCB->setChecked(prefs.ssearchOnWS); ssAutoSpaceCB->setChecked(prefs.ssearchOnWS);
ssNoCompleteCB->setChecked(prefs.ssearchNoComplete); ssNoCompleteCB->setChecked(prefs.ssearchNoComplete);
ssAutoAllCB->setChecked(prefs.ssearchAsYouType); ssAutoAllCB->setChecked(prefs.ssearchAsYouType);
@ -224,7 +237,15 @@ void UIPrefsDialog::accept()
prefs.ssearchNoComplete = ssNoCompleteCB->isChecked(); prefs.ssearchNoComplete = ssNoCompleteCB->isChecked();
prefs.ssearchAsYouType = ssAutoAllCB->isChecked(); prefs.ssearchAsYouType = ssAutoAllCB->isChecked();
prefs.catgToolBar = catgToolBarCB->isChecked(); if (filterMN_RB->isChecked()) {
prefs.filterCtlStyle = PrefsPack::FCS_MN;
} else if (filterCMB_RB->isChecked()) {
prefs.filterCtlStyle = PrefsPack::FCS_CMB;
} else {
prefs.filterCtlStyle = PrefsPack::FCS_BT;
}
m_mainWindow->setFilterCtlStyle(prefs.filterCtlStyle);
prefs.respagesize = pageLenSB->value(); prefs.respagesize = pageLenSB->value();
prefs.collapseDuplicates = collapseDupsCB->isChecked(); prefs.collapseDuplicates = collapseDupsCB->isChecked();
prefs.maxhltextmbs = maxHLTSB->value(); prefs.maxhltextmbs = maxHLTSB->value();