implemented dialog/glue for advanced search

This commit is contained in:
dockes 2005-10-17 13:36:53 +00:00
parent 763b5f58c7
commit 04a926456a
11 changed files with 626 additions and 371 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.7 2005-03-31 10:04:07 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.8 2005-10-17 13:36:53 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
#include <unistd.h>
@ -72,6 +72,26 @@ RclConfig::RclConfig()
return;
}
static ConfSimple::WalkerCode mtypesWalker(void *l,
const char *nm, const char *value)
{
std::list<string> *lst = (std::list<string> *)l;
if (nm && nm[0] == '.')
lst->push_back(value);
return ConfSimple::WALK_CONTINUE;
}
std::list<string> RclConfig::getAllMimeTypes()
{
std::list <string> lst;
if (mimemap == 0)
return lst;
mimemap->sortwalk(mtypesWalker, &lst);
lst.sort();
lst.unique();
return lst;
}
// Look up an executable filter.
// We look in RECOLL_BINDIR, RECOLL_CONFDIR, then let the system use
// the PATH
@ -96,3 +116,4 @@ string find_filter(RclConfig *conf, const string &icmd)
}
return icmd;
}

View File

@ -1,6 +1,8 @@
#ifndef _RCLCONFIG_H_INCLUDED_
#define _RCLCONFIG_H_INCLUDED_
/* @(#$Id: rclconfig.h,v 1.4 2005-02-04 09:39:44 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: rclconfig.h,v 1.5 2005-10-17 13:36:53 dockes Exp $ (C) 2004 J.F.Dockes */
#include <list>
#include "conftree.h"
@ -50,6 +52,7 @@ class RclConfig {
const string &getDefCharset() {return defcharset;}
const string &getDefLang() {return deflang;}
bool getGuessCharset() {return guesscharset;}
std::list<string> getAllMimeTypes();
};
std::string find_filter(RclConfig *conf, const string& cmd);

View File

@ -8,8 +8,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>480</height>
<width>563</width>
<height>560</height>
</rect>
</property>
<property name="caption">
@ -18,332 +18,357 @@
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<widget class="QLabel">
<vbox>
<property name="name">
<cstring>textLabel1_3</cstring>
<cstring>unnamed</cstring>
</property>
<property name="geometry">
<rect>
<x>120</x>
<y>20</y>
<width>110</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Complex search</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>searchPB</cstring>
</property>
<property name="geometry">
<rect>
<x>380</x>
<y>20</y>
<width>90</width>
<height>30</height>
</rect>
</property>
<property name="text">
<string>Search</string>
</property>
</widget>
<widget class="Line">
<property name="name">
<cstring>line1</cstring>
</property>
<property name="geometry">
<rect>
<x>22</x>
<y>58</y>
<width>550</width>
<height>16</height>
</rect>
</property>
<property name="frameShape">
<enum>HLine</enum>
</property>
<property name="frameShadow">
<enum>Sunken</enum>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout6</cstring>
</property>
<property name="geometry">
<rect>
<x>100</x>
<y>100</y>
<width>470</width>
<height>112</height>
</rect>
</property>
<vbox>
<widget class="QLayoutWidget">
<property name="name">
<cstring>unnamed</cstring>
<cstring>layout28</cstring>
</property>
<widget class="QLayoutWidget">
<vbox>
<property name="name">
<cstring>layout2</cstring>
<cstring>unnamed</cstring>
</property>
<hbox>
<widget class="QLayoutWidget">
<property name="name">
<cstring>unnamed</cstring>
<cstring>layout15</cstring>
</property>
<widget class="QLabel">
<hbox>
<property name="name">
<cstring>andWordsTL</cstring>
<cstring>unnamed</cstring>
</property>
<property name="frameShape">
<enum>NoFrame</enum>
<property name="margin">
<number>10</number>
</property>
<property name="frameShadow">
<enum>Plain</enum>
<property name="spacing">
<number>10</number>
</property>
<property name="text">
<string>All these words</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>andWordsLE</cstring>
</property>
</widget>
</hbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout2_2</cstring>
</property>
<hbox>
<widget class="QLabel">
<property name="name">
<cstring>textLabel2</cstring>
</property>
<property name="text">
<string>Search For</string>
</property>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout14</cstring>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>andWordsTL</cstring>
</property>
<property name="frameShape">
<enum>NoFrame</enum>
</property>
<property name="frameShadow">
<enum>Plain</enum>
</property>
<property name="text">
<string>All these words</string>
</property>
</widget>
<widget class="QLineEdit" row="0" column="1" rowspan="1" colspan="3">
<property name="name">
<cstring>andWordsLE</cstring>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
</widget>
<widget class="QLabel" row="1" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>phraseTL</cstring>
</property>
<property name="text">
<string>This exact phrase</string>
</property>
</widget>
<widget class="QLineEdit" row="1" column="2" rowspan="1" colspan="2">
<property name="name">
<cstring>phraseLE</cstring>
</property>
</widget>
<widget class="QLabel" row="2" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>orWordsTL</cstring>
</property>
<property name="text">
<string>Any of these words</string>
</property>
</widget>
<widget class="QLineEdit" row="2" column="2" rowspan="1" colspan="2">
<property name="name">
<cstring>orWordsLE</cstring>
</property>
</widget>
<widget class="QLabel" row="3" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>noWordsTL</cstring>
</property>
<property name="text">
<string>None of these words</string>
</property>
</widget>
<widget class="QLineEdit" row="3" column="3">
<property name="name">
<cstring>noWordsLE</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
</grid>
</widget>
</hbox>
</widget>
<widget class="Line">
<property name="name">
<cstring>unnamed</cstring>
<cstring>line2</cstring>
</property>
<widget class="QLabel">
<property name="name">
<cstring>phraseTL</cstring>
</property>
<property name="text">
<string>This exact phrase</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>phraseLE</cstring>
</property>
</widget>
</hbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout4</cstring>
</property>
<hbox>
<property name="frameShape">
<enum>HLine</enum>
</property>
<property name="frameShadow">
<enum>Sunken</enum>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>unnamed</cstring>
<cstring>layout19</cstring>
</property>
<widget class="QLabel">
<vbox>
<property name="name">
<cstring>orWordsTL</cstring>
<cstring>unnamed</cstring>
</property>
<property name="text">
<string>Any of these words</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>orWordsLE</cstring>
</property>
</widget>
</hbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout5</cstring>
</property>
<hbox>
<widget class="QCheckBox">
<property name="name">
<cstring>restrictFtCB</cstring>
</property>
<property name="text">
<string>Restrict file types</string>
</property>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout11</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout9</cstring>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel">
<property name="name">
<cstring>textLabel2_2</cstring>
</property>
<property name="text">
<string>Searched file types</string>
</property>
</widget>
<widget class="QListBox">
<property name="name">
<cstring>yesFiltypsLB</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>100</height>
</size>
</property>
<property name="selectionMode">
<enum>Extended</enum>
</property>
</widget>
</vbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout11</cstring>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QPushButton">
<property name="name">
<cstring>delFiltypPB</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>--------&gt;</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>addFiltypPB</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&lt;---------</string>
</property>
</widget>
</vbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout10</cstring>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel">
<property name="name">
<cstring>textLabel3</cstring>
</property>
<property name="text">
<string>Ignored file types</string>
</property>
</widget>
<widget class="QListBox">
<property name="name">
<cstring>noFiltypsLB</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>100</height>
</size>
</property>
<property name="selectionMode">
<enum>Extended</enum>
</property>
</widget>
</vbox>
</widget>
</hbox>
</widget>
</vbox>
</widget>
<widget class="Line">
<property name="name">
<cstring>unnamed</cstring>
<cstring>line3</cstring>
</property>
<widget class="QLabel">
<property name="frameShape">
<enum>HLine</enum>
</property>
<property name="frameShadow">
<enum>Sunken</enum>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout18</cstring>
</property>
<grid>
<property name="name">
<cstring>noWordsTL</cstring>
<cstring>unnamed</cstring>
</property>
<property name="text">
<string>None of these words</string>
</property>
</widget>
<widget class="QLineEdit">
<widget class="QLineEdit" row="1" column="0">
<property name="name">
<cstring>subtreeLE</cstring>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
</widget>
<widget class="QPushButton" row="1" column="1">
<property name="name">
<cstring>browsePB</cstring>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>textLabel1</cstring>
</property>
<property name="text">
<string>Restrict results to files in subtree:</string>
</property>
</widget>
</grid>
</widget>
<widget class="Line">
<property name="name">
<cstring>line1</cstring>
</property>
<property name="frameShape">
<enum>HLine</enum>
</property>
<property name="frameShadow">
<enum>Sunken</enum>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout25</cstring>
</property>
<hbox>
<property name="name">
<cstring>noWordsLE</cstring>
<cstring>unnamed</cstring>
</property>
</widget>
</hbox>
</widget>
</vbox>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>textLabel2</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>100</y>
<width>64</width>
<height>112</height>
</rect>
</property>
<property name="text">
<string>Search For</string>
</property>
</widget>
<widget class="Line">
<property name="name">
<cstring>line2</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>220</y>
<width>560</width>
<height>20</height>
</rect>
</property>
<property name="frameShape">
<enum>HLine</enum>
</property>
<property name="frameShadow">
<enum>Sunken</enum>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout10</cstring>
</property>
<property name="geometry">
<rect>
<x>440</x>
<y>250</y>
<width>102</width>
<height>170</height>
</rect>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel">
<property name="name">
<cstring>textLabel3</cstring>
</property>
<property name="text">
<string>Ignored file types</string>
</property>
</widget>
<widget class="QListBox">
<item>
<property name="text">
<string>New Item</string>
</property>
</item>
<property name="name">
<cstring>noFiltypsLB</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</vbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout9</cstring>
</property>
<property name="geometry">
<rect>
<x>100</x>
<y>250</y>
<width>111</width>
<height>170</height>
</rect>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel">
<property name="name">
<cstring>textLabel2_2</cstring>
</property>
<property name="text">
<string>Searched file types</string>
</property>
</widget>
<widget class="QListBox">
<item>
<property name="text">
<string>New Item</string>
</property>
</item>
<property name="name">
<cstring>yesFiltypsLB</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</vbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout11</cstring>
</property>
<property name="geometry">
<rect>
<x>270</x>
<y>300</y>
<width>82</width>
<height>68</height>
</rect>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QPushButton">
<property name="name">
<cstring>delFiltypPB</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>--------&gt;</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>addFiltypPB</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&lt;---------</string>
</property>
</widget>
</vbox>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>searchPB</cstring>
</property>
<property name="text">
<string>Start Search</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>dismissPB</cstring>
</property>
<property name="text">
<string>Dismiss</string>
</property>
</widget>
</hbox>
</widget>
</vbox>
</widget>
</vbox>
</widget>
<connections>
<connection>
@ -352,26 +377,53 @@
<receiver>advsearch</receiver>
<slot>delFiltypPB_clicked()</slot>
</connection>
<connection>
<sender>addFiltypPB</sender>
<signal>clicked()</signal>
<receiver>advsearch</receiver>
<slot>addFiltypPB_clicked()</slot>
</connection>
<connection>
<sender>searchPB</sender>
<signal>clicked()</signal>
<receiver>advsearch</receiver>
<slot>searchPB_clicked()</slot>
</connection>
<connection>
<sender>restrictFtCB</sender>
<signal>toggled(bool)</signal>
<receiver>advsearch</receiver>
<slot>restrictFtCB_toggled(bool)</slot>
</connection>
<connection>
<sender>dismissPB</sender>
<signal>clicked()</signal>
<receiver>advsearch</receiver>
<slot>close()</slot>
</connection>
<connection>
<sender>browsePB</sender>
<signal>clicked()</signal>
<receiver>advsearch</receiver>
<slot>browsePB_clicked()</slot>
</connection>
<connection>
<sender>addFiltypPB</sender>
<signal>clicked()</signal>
<receiver>advsearch</receiver>
<slot>addFiltypPB_clicked()</slot>
</connection>
</connections>
<includes>
<include location="local" impldecl="in declaration">recoll.h</include>
<include location="local" impldecl="in implementation">advsearch.ui.h</include>
</includes>
<signals>
<signal>startSearch(AdvSearchData)</signal>
</signals>
<slots>
<slot>delFiltypPB_clicked()</slot>
<slot>addFiltypPB_clicked()</slot>
<slot>restrictFtCB_toggled( bool on )</slot>
<slot>searchPB_clicked()</slot>
<slot>browsePB_clicked()</slot>
</slots>
<functions>
<function access="private">init()</function>
</functions>
<layoutdefaults spacing="6" margin="11"/>
</UI>

View File

@ -10,20 +10,107 @@
** destructor.
*****************************************************************************/
#include <qfiledialog.h>
#include <list>
#include <string>
using std::list;
using std::string;
#include "recoll.h"
#include "rclconfig.h"
#include "debuglog.h"
extern RclConfig *rclconfig;
// Constructor/initialization
void advsearch::init()
{
list<string> types = rclconfig->getAllMimeTypes();
QStringList ql;
for (list<string>::iterator it = types.begin(); it != types.end(); it++) {
ql.append(it->c_str());
}
yesFiltypsLB->insertStringList(ql);
}
// Move selected file types from the searched to the ignored box
void advsearch::delFiltypPB_clicked()
{
list<int> trl;
QStringList moved;
for (unsigned int i = 0; i < yesFiltypsLB->count();i++) {
QListBoxItem *item = yesFiltypsLB->item(i);
if (item && item->isSelected()) {
moved.push_back(item->text());
trl.push_front(i);
}
}
if (!moved.empty()) {
noFiltypsLB->insertStringList(moved);
for (list<int>::iterator it = trl.begin();it != trl.end(); it++)
yesFiltypsLB->removeItem(*it);
}
yesFiltypsLB->sort();
noFiltypsLB->sort();
}
// Move selected file types from the ignored to the searched box
void advsearch::addFiltypPB_clicked()
{
list<int> trl;
QStringList moved;
for (unsigned int i = 0; i < noFiltypsLB->count(); i++) {
QListBoxItem *item = noFiltypsLB->item(i);
if (item && item->isSelected()) {
moved.push_back(item->text());
trl.push_front(i);
}
}
if (!moved.empty()) {
yesFiltypsLB->insertStringList(moved);
for (list<int>::iterator it = trl.begin();it != trl.end(); it++)
noFiltypsLB->removeItem(*it);
}
yesFiltypsLB->sort();
noFiltypsLB->sort();
}
// Activate file type selection
void advsearch::restrictFtCB_toggled(bool on)
{
yesFiltypsLB->setEnabled(on);
delFiltypPB->setEnabled(on);
addFiltypPB->setEnabled(on);
noFiltypsLB->setEnabled(on);
}
void advsearch::searchPB_clicked()
{
AdvSearchData mydata;
mydata.allwords = string((const char*)(andWordsLE->text().utf8()));
mydata.phrase = string((const char*)(phraseLE->text().utf8()));
mydata.orwords = string((const char*)(orWordsLE->text().utf8()));
mydata.nowords = string((const char*)(noWordsLE->text().utf8()));
if (restrictFtCB->isOn() && noFiltypsLB->count() > 0) {
for (unsigned int i = 0; i < yesFiltypsLB->count(); i++) {
QCString ctext = noFiltypsLB->item(i)->text().utf8();
mydata.filetypes.push_back(string((const char *)ctext));
}
}
if (!subtreeLE->text().isEmpty()) {
mydata.topdir = string((const char*)(subtreeLE->text().utf8()));
}
emit startSearch(mydata);
}
void advsearch::browsePB_clicked()
{
QString dir = QFileDialog::getExistingDirectory();
subtreeLE->setText(dir);
}

View File

@ -172,6 +172,9 @@
<variable>bool dynSearchActive;</variable>
<variable>bool canBeep;</variable>
</variables>
<signals>
<signal>previewClosed(Preview *)</signal>
</signals>
<slots>
<slot>searchTextLine_textChanged( const QString &amp; text )</slot>
<slot>doSearch( bool next, bool reverse )</slot>
@ -181,6 +184,7 @@
</slots>
<functions>
<function access="private" specifier="non virtual">init()</function>
<function returnType="void">closeEvent( QCloseEvent * e)</function>
<function returnType="bool">eventFilter( QObject * target, QEvent * event )</function>
</functions>
<layoutdefaults spacing="6" margin="11"/>

View File

@ -21,6 +21,12 @@ void Preview::init()
canBeep = true;
}
void Preview::closeEvent(QCloseEvent *e)
{
emit previewClosed(this);
QWidget::closeEvent(e);
}
extern int recollNeedsExit;
bool Preview::eventFilter(QObject *target, QEvent *event)

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: pvmain.cpp,v 1.2 2005-10-10 12:29:43 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: pvmain.cpp,v 1.3 2005-10-17 13:36:53 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
#include <stdio.h>
@ -22,7 +22,7 @@ using std::pair;
#include "readfile.h"
const char *filename = "/home/dockes/tmp/tstpv-utf8.txt";
int recollNeedsExit;
int main( int argc, char ** argv )
{
QApplication a(argc, argv);

View File

@ -1,7 +1,8 @@
#ifndef _RECOLL_H_INCLUDED_
#define _RECOLL_H_INCLUDED_
/* @(#$Id: recoll.h,v 1.2 2005-02-09 12:07:30 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: recoll.h,v 1.3 2005-10-17 13:36:53 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
#include <list>
#include "rclconfig.h"
#include "rcldb.h"
#include "idxthread.h"
@ -15,4 +16,14 @@ extern string tmpdir;
extern int recollNeedsExit;
// Holder for data collected by the advanced search dialog
struct AdvSearchData {
std::string allwords;
std::string phrase;
std::string orwords;
std::string nowords;
std::list<std::string> filetypes; // restrict to types. Empty if inactive
std::string topdir; // restrict to subtree. Empty if inactive
};
#endif /* _RECOLL_H_INCLUDED_ */

View File

@ -8,8 +8,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>549</width>
<height>750</height>
<width>590</width>
<height>810</height>
</rect>
</property>
<property name="sizePolicy">
@ -22,7 +22,7 @@
</property>
<property name="minimumSize">
<size>
<width>549</width>
<width>590</width>
<height>160</height>
</size>
</property>
@ -35,7 +35,7 @@
</property>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout8</cstring>
<cstring>layout30</cstring>
</property>
<vbox>
<property name="name">
@ -43,7 +43,7 @@
</property>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout9</cstring>
<cstring>layout29</cstring>
</property>
<hbox>
<property name="name">
@ -109,14 +109,6 @@
<string>Next page</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>advSearchPB</cstring>
</property>
<property name="text">
<string>Adv. search</string>
</property>
</widget>
<spacer>
<property name="name">
<cstring>spacer1</cstring>
@ -129,11 +121,33 @@
</property>
<property name="sizeHint">
<size>
<width>346</width>
<width>42</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="Line">
<property name="name">
<cstring>line4</cstring>
</property>
<property name="frameShape">
<enum>VLine</enum>
</property>
<property name="frameShadow">
<enum>Sunken</enum>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>advSearchPB</cstring>
</property>
<property name="text">
<string>Advanced search</string>
</property>
</widget>
</hbox>
</widget>
<widget class="QTextEdit">
@ -173,10 +187,6 @@
<separator/>
<action name="fileExitAction"/>
</item>
<item text="&amp;Help" name="helpMenu">
<separator/>
<action name="helpQuick_startAction"/>
</item>
</menubar>
<toolbars>
</toolbars>
@ -206,17 +216,6 @@
<string>Start Indexing</string>
</property>
</action>
<action>
<property name="name">
<cstring>helpQuick_startAction</cstring>
</property>
<property name="text">
<string>Quick start</string>
</property>
<property name="menuText">
<string>Quick start</string>
</property>
</action>
</actions>
<connections>
<connection>
@ -231,12 +230,6 @@
<receiver>RecollMain</receiver>
<slot>fileStart_IndexingAction_activated()</slot>
</connection>
<connection>
<sender>helpQuick_startAction</sender>
<signal>activated()</signal>
<receiver>RecollMain</receiver>
<slot>helpQuick_startAction_activated()</slot>
</connection>
<connection>
<sender>Search</sender>
<signal>clicked()</signal>
@ -279,9 +272,16 @@
<receiver>RecollMain</receiver>
<slot>clearqPB_clicked()</slot>
</connection>
<connection>
<sender>advSearchPB</sender>
<signal>clicked()</signal>
<receiver>RecollMain</receiver>
<slot>advSearchPB_clicked()</slot>
</connection>
</connections>
<includes>
<include location="local" impldecl="in declaration">preview/.ui/preview.h</include>
<include location="local" impldecl="in declaration">recoll.h</include>
<include location="local" impldecl="in implementation">recollmain.ui.h</include>
</includes>
<variables>
@ -302,8 +302,9 @@
<slot>clearqPB_clicked()</slot>
<slot>listPrevPB_clicked()</slot>
<slot>listNextPB_clicked()</slot>
<slot>helpQuick_startAction_activated()</slot>
<slot>advSearchPB_clicked()</slot>
<slot>previewClosed( Preview * w )</slot>
<slot>startAdvSearch( AdvSearchData sdata )</slot>
</slots>
<functions>
<function access="private">init()</function>

View File

@ -31,14 +31,14 @@ using std::pair;
#include "internfile.h"
#include "smallut.h"
#include "plaintorich.h"
#include "unacpp.h"
#ifndef MIN
#define MIN(A,B) ((A) < (B) ? (A) : (B))
#endif
// Number of abstracts in a result page. This will avoid scrollbars
// with the default window size and font, most of the time.
static const int respagesize = 8;
@ -47,6 +47,7 @@ void RecollMain::init()
curPreview = 0;
}
// We want to catch ^Q everywhere to mean quit.
bool RecollMain::eventFilter( QObject * target, QEvent * event )
{
if (event->type() == QEvent::KeyPress) {
@ -68,6 +69,7 @@ void RecollMain::fileExit()
// things apart from a need to exit
void RecollMain::checkExit()
{
// Check if indexing thread done
if (indexingstatus) {
indexingstatus = false;
// Make sure we reopen the db to get the results.
@ -84,13 +86,13 @@ void RecollMain::fileStart_IndexingAction_activated()
startindexing = 1;
}
// Note that all our 'urls' are like : file://...
static string urltolocalpath(string url)
{
return url.substr(7, string::npos);
}
// Use external viewer to display file
// Double click in result list: use external viewer to display file
void RecollMain::reslistTE_doubleClicked(int par, int)
{
LOGDEB(("RecollMain::reslistTE_doubleClicked: par %d\n", par));
@ -154,7 +156,7 @@ void RecollMain::reslistTE_clicked(int par, int car)
reslistTE->setParagraphBackgroundColor(par, color);
int reldocnum = par - 1;
if (reslist_current == reldocnum)
if (curPreview && reslist_current == reldocnum)
return;
reslist_current = reldocnum;
@ -185,6 +187,8 @@ void RecollMain::reslistTE_clicked(int par, int car)
if (curPreview == 0) {
curPreview = new Preview(0, "Preview");
curPreview->setCaption(queryText->text());
connect(curPreview, SIGNAL(previewClosed(Preview *)),
this, SLOT(previewClosed(Preview *)));
if (curPreview == 0) {
QMessageBox::warning(0, "Warning",
"Can't create preview window",
@ -204,13 +208,40 @@ void RecollMain::reslistTE_clicked(int par, int car)
curPreview->pvTab->addTab(anon, "Tab");
curPreview->pvTab->showPage(anon);
}
string tabname;
if (!doc.title.empty()) {
tabname = doc.title;
} else {
tabname = path_getsimple(doc.url);
}
if (tabname.length() > 20) {
tabname = tabname.substr(0, 10) + "..." +
tabname.substr(tabname.length()-10);
}
curPreview->pvTab->changeTab(curPreview->pvTab->currentPage(),
QString::fromUtf8(doc.title.c_str(),
doc.title.length()));
QString::fromUtf8(tabname.c_str(),
tabname.length()));
if (doc.title.empty())
doc.title = path_getsimple(doc.url);
char datebuf[100];
datebuf[0] = 0;
if (!doc.mtime.empty()) {
time_t mtime = atol(doc.mtime.c_str());
struct tm *tm = localtime(&mtime);
strftime(datebuf, 99, "%F %T", tm);
}
string tiptxt = doc.url + string("\n");
tiptxt += doc.mimetype + " "
+ (doc.mtime.empty() ? "\n" : string(datebuf) + "\n");
if (!doc.title.empty())
tiptxt += doc.title + "\n";
curPreview->pvTab->setTabToolTip(curPreview->pvTab->currentPage(),
QString::fromUtf8(tiptxt.c_str(),
tiptxt.length()));
QStyleSheetItem *item =
new QStyleSheetItem(editor->styleSheet(),
"termtag" );
new QStyleSheetItem(editor->styleSheet(), "termtag" );
item->setColor("blue");
item->setFontWeight(QFont::Bold);
@ -388,15 +419,22 @@ void RecollMain::listNextPB_clicked()
}
}
void RecollMain::helpQuick_startAction_activated()
// If a preview (toplevel) window gets closed by the user, we need to
// clean up because there is no way to reopen it. And check the case
// where the current one is closed
void RecollMain::previewClosed(Preview *w)
{
if (w == curPreview) {
LOGDEB(("Active preview closed\n"));
curPreview = 0;
} else {
LOGDEB(("Old preview closed\n"));
}
delete w;
}
#include "advsearch.h"
advsearch *asearchform;
@ -409,12 +447,32 @@ void RecollMain::advSearchPB_clicked()
WStyle_Customize | WStyle_NormalBorder |
WStyle_Title | WStyle_SysMenu);
asearchform->setSizeGripEnabled(FALSE);
connect(asearchform, SIGNAL(startSearch(AdvSearchData)),
this, SLOT(startAdvSearch(AdvSearchData)));
asearchform->show();
} else {
asearchform->show();
}
}
void RecollMain::startAdvSearch(AdvSearchData sdata)
{
LOGDEB(("RecollMain::startAdvSearch\n"));
LOGDEB((" allwords: %s\n", sdata.allwords.c_str()));
LOGDEB((" phrase: %s\n", sdata.phrase.c_str()));
LOGDEB((" orwords: %s\n", sdata.orwords.c_str()));
LOGDEB((" nowords: %s\n", sdata.nowords.c_str()));
string ft;
for (list<string>::iterator it = sdata.filetypes.begin();
it != sdata.filetypes.end(); it++) {
ft += *it + " ";
}
if (!ft.empty())
LOGDEB(("Searched file types: %s\n", ft.c_str()));
if (!sdata.topdir.empty())
LOGDEB(("Restricted to: %s\n", sdata.topdir.c_str()));
}

View File

@ -2,8 +2,8 @@ include ../mk/sysconf
BIGLIB = ../lib/librcl.a
PROGS = wipedir smallut trfstreewalk trpathut transcode trmimeparse \
trexecmd utf8iter idfile
PROGS = trconftree wipedir smallut trfstreewalk trpathut transcode \
trmimeparse trexecmd utf8iter idfile
all: $(PROGS)
@ -67,5 +67,17 @@ utf8iter : $(UTF8ITER_OBJS)
trutf8iter.o : ../utils/utf8iter.cpp utf8iter.h
$(CXX) $(CXXFLAGS) -DTEST_UTF8ITER -c -o trutf8iter.o \
utf8iter.cpp
CONFTREE_OBJS= trconftree.o $(BIGLIB)
trconftree : $(CONFTREE_OBJS)
$(CXX) $(CXXFLAGS) -o trconftree $(CONFTREE_OBJS)
trconftree.o : ../utils/conftree.cpp
$(CXX) $(CXXFLAGS) -DTEST_CONFTREE -c -o trconftree.o \
conftree.cpp
clean:
rm -f *.o $(PROGS)