GUI filename search: arrange for directories to be sorted first by default
This commit is contained in:
parent
13333e6512
commit
322e17081f
@ -296,6 +296,8 @@ void RclMain::init()
|
|||||||
connect(sSearch,
|
connect(sSearch,
|
||||||
SIGNAL(startSearch(std::shared_ptr<Rcl::SearchData>, bool)),
|
SIGNAL(startSearch(std::shared_ptr<Rcl::SearchData>, bool)),
|
||||||
this, SLOT(startSearch(std::shared_ptr<Rcl::SearchData>, bool)));
|
this, SLOT(startSearch(std::shared_ptr<Rcl::SearchData>, bool)));
|
||||||
|
connect(sSearch, SIGNAL(searchTypeChanged(int)),
|
||||||
|
this, SLOT(onSearchTypeChanged(int)));
|
||||||
connect(sSearch, SIGNAL(setDescription(QString)),
|
connect(sSearch, SIGNAL(setDescription(QString)),
|
||||||
this, SLOT(onSetDescription(QString)));
|
this, SLOT(onSetDescription(QString)));
|
||||||
connect(sSearch, SIGNAL(clearSearch()),
|
connect(sSearch, SIGNAL(clearSearch()),
|
||||||
@ -690,6 +692,21 @@ void RclMain::fileExit()
|
|||||||
qApp->exit(0);
|
qApp->exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset sort order when search type changes.
|
||||||
|
void RclMain::onSearchTypeChanged(int stp)
|
||||||
|
{
|
||||||
|
SSearch::SSearchType tp = (SSearch::SSearchType)stp;
|
||||||
|
switch (tp) {
|
||||||
|
case SSearch::SST_FNM:
|
||||||
|
m_sortspec.desc = false;
|
||||||
|
m_sortspec.field = "mtype";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
m_sortspec.reset();
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Start a db query and set the reslist docsource
|
// Start a db query and set the reslist docsource
|
||||||
void RclMain::startSearch(std::shared_ptr<Rcl::SearchData> sdata, bool issimple)
|
void RclMain::startSearch(std::shared_ptr<Rcl::SearchData> sdata, bool issimple)
|
||||||
{
|
{
|
||||||
@ -735,6 +752,14 @@ void RclMain::startSearch(std::shared_ptr<Rcl::SearchData> sdata, bool issimple)
|
|||||||
src->setAbstractParams(prefs.queryBuildAbstract,
|
src->setAbstractParams(prefs.queryBuildAbstract,
|
||||||
prefs.queryReplaceAbstract);
|
prefs.queryReplaceAbstract);
|
||||||
m_source = std::shared_ptr<DocSequence>(src);
|
m_source = std::shared_ptr<DocSequence>(src);
|
||||||
|
|
||||||
|
// If this is a file name search sort by mtype so that directories
|
||||||
|
// come first (see the rclquery sort key generator)
|
||||||
|
if (sSearch->searchTypCMB->currentIndex() == SSearch::SST_FNM &&
|
||||||
|
m_sortspec.field.empty()) {
|
||||||
|
m_sortspec.field = "mtype";
|
||||||
|
m_sortspec.desc = false;
|
||||||
|
}
|
||||||
m_source->setSortSpec(m_sortspec);
|
m_source->setSortSpec(m_sortspec);
|
||||||
m_source->setFiltSpec(m_filtspec);
|
m_source->setFiltSpec(m_filtspec);
|
||||||
|
|
||||||
@ -840,6 +865,12 @@ void RclMain::onSortCtlChanged()
|
|||||||
} else {
|
} else {
|
||||||
prefs.sortActive = prefs.sortDesc = false;
|
prefs.sortActive = prefs.sortDesc = false;
|
||||||
prefs.sortField = "";
|
prefs.sortField = "";
|
||||||
|
// If this is a file name search sort by mtype so that directories
|
||||||
|
// come first (see the rclquery sort key generator)
|
||||||
|
if (sSearch->searchTypCMB->currentIndex() == SSearch::SST_FNM) {
|
||||||
|
m_sortspec.field = "mtype";
|
||||||
|
m_sortspec.desc = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (m_source)
|
if (m_source)
|
||||||
m_source->setSortSpec(m_sortspec);
|
m_source->setSortSpec(m_sortspec);
|
||||||
|
|||||||
@ -138,6 +138,7 @@ public slots:
|
|||||||
virtual void previewPrevInTab(Preview *, int sid, int docnum);
|
virtual void previewPrevInTab(Preview *, int sid, int docnum);
|
||||||
virtual void previewExposed(Preview *, int sid, int docnum);
|
virtual void previewExposed(Preview *, int sid, int docnum);
|
||||||
virtual void resetSearch();
|
virtual void resetSearch();
|
||||||
|
virtual void onSearchTypeChanged(int);
|
||||||
virtual void eraseDocHistory();
|
virtual void eraseDocHistory();
|
||||||
virtual void eraseSearchHistory();
|
virtual void eraseSearchHistory();
|
||||||
virtual void exportSimpleSearchHistory();
|
virtual void exportSimpleSearchHistory();
|
||||||
|
|||||||
@ -170,7 +170,7 @@ void SSearch::init()
|
|||||||
connect(clearqPB, SIGNAL(clicked()), queryText, SLOT(clear()));
|
connect(clearqPB, SIGNAL(clicked()), queryText, SLOT(clear()));
|
||||||
connect(searchPB, SIGNAL(clicked()), this, SLOT(startSimpleSearch()));
|
connect(searchPB, SIGNAL(clicked()), this, SLOT(startSimpleSearch()));
|
||||||
connect(searchTypCMB, SIGNAL(activated(int)), this,
|
connect(searchTypCMB, SIGNAL(activated(int)), this,
|
||||||
SLOT(searchTypeChanged(int)));
|
SLOT(onSearchTypeChanged(int)));
|
||||||
|
|
||||||
m_completermodel = new RclCompleterModel(this);
|
m_completermodel = new RclCompleterModel(this);
|
||||||
m_completer = new QCompleter(m_completermodel, this);
|
m_completer = new QCompleter(m_completermodel, this);
|
||||||
@ -355,7 +355,7 @@ void SSearch::searchTextChanged(const QString& text)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSearch::searchTypeChanged(int typ)
|
void SSearch::onSearchTypeChanged(int typ)
|
||||||
{
|
{
|
||||||
LOGDEB1("Search type now " << typ << "\n");
|
LOGDEB1("Search type now " << typ << "\n");
|
||||||
// Adjust context help
|
// Adjust context help
|
||||||
@ -416,6 +416,7 @@ void SSearch::searchTypeChanged(int typ)
|
|||||||
default:
|
default:
|
||||||
queryText->setToolTip(tr("Enter search terms here."));
|
queryText->setToolTip(tr("Enter search terms here."));
|
||||||
}
|
}
|
||||||
|
emit searchTypeChanged((int)typ);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSearch::startSimpleSearch()
|
void SSearch::startSimpleSearch()
|
||||||
|
|||||||
@ -86,7 +86,7 @@ public:
|
|||||||
virtual bool eventFilter(QObject *target, QEvent *event);
|
virtual bool eventFilter(QObject *target, QEvent *event);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void searchTypeChanged(int);
|
virtual void onSearchTypeChanged(int);
|
||||||
virtual void setSearchString(const QString& text);
|
virtual void setSearchString(const QString& text);
|
||||||
virtual void startSimpleSearch();
|
virtual void startSimpleSearch();
|
||||||
virtual void addTerm(QString);
|
virtual void addTerm(QString);
|
||||||
@ -105,6 +105,7 @@ private slots:
|
|||||||
virtual void onCompleterShown();
|
virtual void onCompleterShown();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void searchTypeChanged(int);
|
||||||
void startSearch(std::shared_ptr<Rcl::SearchData>, bool);
|
void startSearch(std::shared_ptr<Rcl::SearchData>, bool);
|
||||||
void setDescription(QString);
|
void setDescription(QString);
|
||||||
void clearSearch();
|
void clearSearch();
|
||||||
|
|||||||
@ -71,12 +71,14 @@ class QSorter : public Xapian::KeyMaker
|
|||||||
public:
|
public:
|
||||||
QSorter(const string& f)
|
QSorter(const string& f)
|
||||||
: m_fld(docfToDatf(f) + "=") {
|
: m_fld(docfToDatf(f) + "=") {
|
||||||
m_ismtime = !m_fld.compare("dmtime=");
|
if (m_fld == "dmtime=") {
|
||||||
if (m_ismtime)
|
m_ismtime = true;
|
||||||
m_issize = false;
|
} else if (m_fld == "fbytes=" || m_fld == "dbytes=" ||
|
||||||
else
|
m_fld == "pcbytes=") {
|
||||||
m_issize = !m_fld.compare("fbytes=") || !m_fld.compare("dbytes=") ||
|
m_issize = true;
|
||||||
!m_fld.compare("pcbytes=");
|
} else if (m_fld == "mtype=") {
|
||||||
|
m_ismtype = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::string operator()(const Xapian::Document& xdoc) const {
|
virtual std::string operator()(const Xapian::Document& xdoc) const {
|
||||||
@ -111,6 +113,14 @@ public:
|
|||||||
// Left zeropad values for appropriate numeric sorting
|
// Left zeropad values for appropriate numeric sorting
|
||||||
leftzeropad(term, 12);
|
leftzeropad(term, 12);
|
||||||
return term;
|
return term;
|
||||||
|
} else if (m_ismtype) {
|
||||||
|
// Arrange for directories to always sort first
|
||||||
|
if (term == "inode/directory" ||
|
||||||
|
term == "application/x-fsdirectory") {
|
||||||
|
term.insert(0, 1, ' ');
|
||||||
|
}
|
||||||
|
// No further processing needed for mtype
|
||||||
|
return term;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process data for better sorting. We should actually do the
|
// Process data for better sorting. We should actually do the
|
||||||
@ -136,8 +146,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
string m_fld;
|
string m_fld;
|
||||||
bool m_ismtime;
|
bool m_ismtime{false};
|
||||||
bool m_issize;
|
bool m_issize{false};
|
||||||
|
bool m_ismtype{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
Query::Query(Db *db)
|
Query::Query(Db *db)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user