remember history of restrict subdirs in adv search
This commit is contained in:
parent
d2d2c73794
commit
a3db7c1937
@ -332,9 +332,17 @@
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLineEdit" row="1" column="0">
|
||||
<widget class="QComboBox" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>subtreeLE</cstring>
|
||||
<cstring>subtreeCMB</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>8</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@ -342,6 +350,24 @@
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizeLimit">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="maxCount">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="insertionPolicy">
|
||||
<enum>AtTop</enum>
|
||||
</property>
|
||||
<property name="duplicatesEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Enter top directory for search</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" row="1" column="1">
|
||||
<property name="name">
|
||||
@ -364,20 +390,20 @@
|
||||
</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="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>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.1 2006-09-04 15:13:01 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.2 2006-09-11 12:05:38 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -25,6 +25,7 @@ static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.1 2006-09-04 15:13:01 dockes
|
||||
#include <qlineedit.h>
|
||||
#include <qframe.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qlistbox.h>
|
||||
#include <qlayout.h>
|
||||
#include <qtooltip.h>
|
||||
@ -44,26 +45,33 @@ using std::string;
|
||||
#include "rclconfig.h"
|
||||
#include "debuglog.h"
|
||||
#include "searchdata.h"
|
||||
#include "guiutils.h"
|
||||
|
||||
extern RclConfig *rclconfig;
|
||||
|
||||
void AdvSearch::init()
|
||||
{
|
||||
// signals and slots connections
|
||||
connect( delFiltypPB, SIGNAL( clicked() ), this, SLOT( delFiltypPB_clicked() ) );
|
||||
connect( searchPB, SIGNAL( clicked() ), this, SLOT( searchPB_clicked() ) );
|
||||
connect( restrictFtCB, SIGNAL( toggled(bool) ), this, SLOT( restrictFtCB_toggled(bool) ) );
|
||||
connect( dismissPB, SIGNAL( clicked() ), this, SLOT( close() ) );
|
||||
connect( browsePB, SIGNAL( clicked() ), this, SLOT( browsePB_clicked() ) );
|
||||
connect( addFiltypPB, SIGNAL( clicked() ), this, SLOT( addFiltypPB_clicked() ) );
|
||||
connect( andWordsLE, SIGNAL( returnPressed() ), this, SLOT( searchPB_clicked() ) );
|
||||
connect( orWordsLE, SIGNAL( returnPressed() ), this, SLOT( searchPB_clicked() ) );
|
||||
connect( noWordsLE, SIGNAL( returnPressed() ), this, SLOT( searchPB_clicked() ) );
|
||||
connect( phraseLE, SIGNAL( returnPressed() ), this, SLOT( searchPB_clicked() ) );
|
||||
connect( subtreeLE, SIGNAL( returnPressed() ), this, SLOT( searchPB_clicked() ) );
|
||||
connect( delAFiltypPB, SIGNAL( clicked() ), this, SLOT( delAFiltypPB_clicked() ) );
|
||||
connect( addAFiltypPB, SIGNAL( clicked() ), this, SLOT( addAFiltypPB_clicked() ) );
|
||||
|
||||
connect(delFiltypPB, SIGNAL(clicked()), this, SLOT(delFiltypPB_clicked()));
|
||||
connect(searchPB, SIGNAL(clicked()), this, SLOT(searchPB_clicked()));
|
||||
connect(restrictFtCB, SIGNAL(toggled(bool)),
|
||||
this, SLOT(restrictFtCB_toggled(bool)));
|
||||
connect(dismissPB, SIGNAL(clicked()), this, SLOT(close()));
|
||||
connect(browsePB, SIGNAL(clicked()), this, SLOT(browsePB_clicked()));
|
||||
connect(addFiltypPB, SIGNAL(clicked()), this, SLOT(addFiltypPB_clicked()));
|
||||
connect(andWordsLE, SIGNAL(returnPressed()),
|
||||
this, SLOT(searchPB_clicked()));
|
||||
connect(orWordsLE, SIGNAL(returnPressed()),
|
||||
this, SLOT(searchPB_clicked()));
|
||||
connect(noWordsLE, SIGNAL(returnPressed()),
|
||||
this, SLOT(searchPB_clicked()));
|
||||
connect(phraseLE, SIGNAL(returnPressed()), this, SLOT(searchPB_clicked()));
|
||||
connect(subtreeCMB->lineEdit(), SIGNAL(returnPressed()),
|
||||
this, SLOT(searchPB_clicked()));
|
||||
connect(delAFiltypPB, SIGNAL(clicked()),
|
||||
this, SLOT(delAFiltypPB_clicked()));
|
||||
connect(addAFiltypPB, SIGNAL(clicked()),
|
||||
this, SLOT(addAFiltypPB_clicked()));
|
||||
|
||||
list<string> types = rclconfig->getAllMimeTypes();
|
||||
|
||||
@ -73,6 +81,8 @@ void AdvSearch::init()
|
||||
}
|
||||
yesFiltypsLB->insertStringList(ql);
|
||||
|
||||
subtreeCMB->insertStringList(prefs.asearchSubdirHist);
|
||||
subtreeCMB->setEditText("");
|
||||
}
|
||||
|
||||
|
||||
@ -174,8 +184,16 @@ void AdvSearch::searchPB_clicked()
|
||||
mydata.filetypes.push_back(string((const char *)ctext));
|
||||
}
|
||||
}
|
||||
if (!subtreeLE->text().isEmpty()) {
|
||||
mydata.topdir = string((const char*)(subtreeLE->text().utf8()));
|
||||
|
||||
if (!subtreeCMB->currentText().isEmpty()) {
|
||||
mydata.topdir =
|
||||
string((const char*)(subtreeCMB->currentText().utf8()));
|
||||
// If this was started by clicking, need to insert the new entry
|
||||
if (subtreeCMB->text(0) != subtreeCMB->currentText())
|
||||
subtreeCMB->insertItem(subtreeCMB->currentText(), 0);
|
||||
prefs.asearchSubdirHist.clear();
|
||||
for (int index = 0; index < subtreeCMB->count(); index++)
|
||||
prefs.asearchSubdirHist.push_back(subtreeCMB->text(index));
|
||||
}
|
||||
emit startSearch(mydata);
|
||||
}
|
||||
@ -184,6 +202,6 @@ void AdvSearch::searchPB_clicked()
|
||||
void AdvSearch::browsePB_clicked()
|
||||
{
|
||||
QString dir = QFileDialog::getExistingDirectory();
|
||||
subtreeLE->setText(dir);
|
||||
subtreeCMB->setEditText(dir);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.14 2006-09-11 09:08:44 dockes Exp $ (C) 2005 Jean-Francois Dockes";
|
||||
static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.15 2006-09-11 12:05:38 dockes Exp $ (C) 2005 Jean-Francois Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -167,7 +167,6 @@ void rwSettings(bool writing)
|
||||
const string allEdbsSk = "allExtDbs";
|
||||
const string actEdbsSk = "actExtDbs";
|
||||
if (writing) {
|
||||
LOGDEB(("settings: writing to dynconf\n"));
|
||||
g_dynconf->eraseAll(allEdbsSk);
|
||||
for (list<string>::const_iterator it = prefs.allExtraDbs.begin();
|
||||
it != prefs.allExtraDbs.end(); it++) {
|
||||
@ -203,7 +202,6 @@ void rwSettings(bool writing)
|
||||
}
|
||||
prefs.activeExtraDbs = g_dynconf->getStringList(actEdbsSk);
|
||||
}
|
||||
|
||||
#if 0
|
||||
{
|
||||
list<string>::const_iterator it;
|
||||
@ -219,6 +217,21 @@ void rwSettings(bool writing)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
const string asbdSk = "asearchSbd";
|
||||
if (writing) {
|
||||
while (prefs.asearchSubdirHist.size() > 20)
|
||||
prefs.asearchSubdirHist.pop_back();
|
||||
g_dynconf->eraseAll(asbdSk);
|
||||
for (QStringList::iterator it = prefs.asearchSubdirHist.begin();
|
||||
it != prefs.asearchSubdirHist.end(); it++) {
|
||||
g_dynconf->enterString(asbdSk, (const char *)((*it).utf8()));
|
||||
}
|
||||
} else {
|
||||
list<string> tl = g_dynconf->getStringList(asbdSk);
|
||||
for (list<string>::iterator it = tl.begin(); it != tl.end(); it++)
|
||||
prefs.asearchSubdirHist.push_front(QString::fromUtf8(it->c_str()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
#ifndef _GUIUTILS_H_INCLUDED_
|
||||
#define _GUIUTILS_H_INCLUDED_
|
||||
/*
|
||||
* @(#$Id: guiutils.h,v 1.6 2006-04-27 09:23:10 dockes Exp $ (C) 2005 Jean-Francois Dockes
|
||||
* @(#$Id: guiutils.h,v 1.7 2006-09-11 12:05:38 dockes Exp $ (C) 2005 Jean-Francois Dockes
|
||||
* jean-francois.dockes@wanadoo.fr
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -68,6 +68,9 @@ class PrefsPack {
|
||||
// to the qt settings file to avoid any bin string/ charset conv issues
|
||||
list<string> allExtraDbs;
|
||||
list<string> activeExtraDbs;
|
||||
// Advanced search subdir restriction: we don't activate the last value
|
||||
// but just remember previously entered values
|
||||
QStringList asearchSubdirHist;
|
||||
// Textual history of simple searches (this is just the combobox list)
|
||||
QStringList ssearchHistory;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: ssearch_w.cpp,v 1.2 2006-09-11 07:10:25 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: ssearch_w.cpp,v 1.3 2006-09-11 12:05:38 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -66,6 +66,8 @@ void SSearch::startSimpleSearch()
|
||||
{
|
||||
LOGDEB(("SSearch::startSimpleSearch\n"));
|
||||
|
||||
if (queryText->currentText().length() == 0)
|
||||
return;
|
||||
Rcl::AdvSearchData sdata;
|
||||
QCString u8 = queryText->currentText().utf8();
|
||||
switch (searchTypCMB->currentItem()) {
|
||||
@ -81,6 +83,8 @@ void SSearch::startSimpleSearch()
|
||||
break;
|
||||
}
|
||||
|
||||
// Search terms history
|
||||
|
||||
// Need to remove any previous occurence of the search entry from
|
||||
// the listbox list, The qt listbox doesn't do lru correctly (if
|
||||
// already in the list the new entry would remain at it's place,
|
||||
@ -96,11 +100,13 @@ void SSearch::startSimpleSearch()
|
||||
}
|
||||
}
|
||||
} while (changed);
|
||||
if (queryText->text(0) != queryText->currentText())
|
||||
queryText->insertItem(queryText->currentText(), 0);
|
||||
|
||||
// Save the current state of the listbox list to file
|
||||
prefs.ssearchHistory.clear();
|
||||
for (int index = 0; index < queryText->count(); index++)
|
||||
prefs.ssearchHistory.push_back(queryText->text(index));
|
||||
prefs.ssearchHistory.push_back(queryText->text(index).utf8());
|
||||
|
||||
emit startSearch(sdata);
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@
|
||||
<enum>AtTop</enum>
|
||||
</property>
|
||||
<property name="duplicatesEnabled">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Enter search terms here</string>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: history.cpp,v 1.6 2006-09-11 09:08:44 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: history.cpp,v 1.7 2006-09-11 12:05:39 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -150,6 +150,20 @@ bool RclHistory::eraseAll(const string &sk)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool RclHistory::truncate(const string &sk, unsigned int n)
|
||||
{
|
||||
// Is this doc already in history ? If it is we remove the old entry
|
||||
list<string> names = m_data.getNames(sk);
|
||||
if (names.size() <= n)
|
||||
return true;
|
||||
unsigned int i = 0;
|
||||
for (list<string>::const_iterator it = names.begin();
|
||||
it != names.end(); it++, i++) {
|
||||
if (i >= n)
|
||||
m_data.erase(*it, sk);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool RclHistory::enterString(const string sk, const string value)
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*/
|
||||
#ifndef _HISTORY_H_INCLUDED_
|
||||
#define _HISTORY_H_INCLUDED_
|
||||
/* @(#$Id: history.h,v 1.4 2006-09-11 09:08:44 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: history.h,v 1.5 2006-09-11 12:05:39 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
/**
|
||||
* Dynamic configuration storage
|
||||
@ -101,6 +101,7 @@ class RclHistory {
|
||||
bool enterString(const string sk, const string value);
|
||||
list<string> getStringList(const string sk);
|
||||
bool eraseAll(const string& sk);
|
||||
bool truncate(const string& sk, unsigned int n);
|
||||
|
||||
private:
|
||||
unsigned int m_mlen;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user