GUI: got rid of the sort parameters dialog and sort by mime type, replaced by 2 arrows in toolbar for sorting by date, ascending or descending
This commit is contained in:
+7
-6
@@ -105,6 +105,12 @@ static inline string make_parentterm(const string& udi)
|
||||
return pterm;
|
||||
}
|
||||
|
||||
static inline void leftzeropad(string& s, unsigned len)
|
||||
{
|
||||
if (s.length() && s.length() < len)
|
||||
s = s.insert(0, len - s.length(), '0');
|
||||
}
|
||||
|
||||
/* See comment in class declaration: return all subdocuments of a
|
||||
* document given by its unique id.
|
||||
*/
|
||||
@@ -172,6 +178,7 @@ bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data,
|
||||
if (doc.meta.find(*it) == doc.meta.end())
|
||||
parms.get(*it, doc.meta[*it]);
|
||||
}
|
||||
doc.meta[Doc::keymt] = doc.dmtime.empty() ? doc.fmtime : doc.dmtime;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -861,12 +868,6 @@ void Db::setAbstractParams(int idxtrunc, int syntlen, int syntctxlen)
|
||||
m_synthAbsWordCtxLen = syntctxlen;
|
||||
}
|
||||
|
||||
static inline void leftzeropad(string& s, unsigned len)
|
||||
{
|
||||
if (s.length() && s.length() < len)
|
||||
s = s.insert(0, len-s.length(), '0');
|
||||
}
|
||||
|
||||
static const int MB = 1024 * 1024;
|
||||
static const string nc("\n\r\x0c");
|
||||
|
||||
|
||||
+28
-7
@@ -27,18 +27,34 @@ namespace Rcl {
|
||||
// Sort helper class
|
||||
class QSorter : public Xapian::Sorter {
|
||||
public:
|
||||
QSorter(const string& f) : m_fld(docfToDatf(f) + "=") {}
|
||||
QSorter(const string& f)
|
||||
: m_fld(docfToDatf(f) + "=")
|
||||
{
|
||||
m_ismtime = !m_fld.compare("mtime=");
|
||||
if (m_ismtime) {
|
||||
m_fld = "dmtime=";
|
||||
}
|
||||
}
|
||||
|
||||
virtual std::string operator()(const Xapian::Document& xdoc) const {
|
||||
virtual std::string operator()(const Xapian::Document& xdoc) const
|
||||
{
|
||||
string data = xdoc.get_data();
|
||||
|
||||
// It would be simpler to do the record->Rcl::Doc thing, but
|
||||
// hand-doing this will be faster. It makes more assumptions
|
||||
// about the format than a ConfTree though:
|
||||
string::size_type i1, i2;
|
||||
i1 = data.find(m_fld);
|
||||
if (i1 == string::npos)
|
||||
return string();
|
||||
if (i1 == string::npos) {
|
||||
if (m_ismtime) {
|
||||
// Ugly: specialcase mtime as it's either dmtime or fmtime
|
||||
i1 = data.find("fmtime=");
|
||||
if (i1 == string::npos) {
|
||||
return string();
|
||||
}
|
||||
} else {
|
||||
return string();
|
||||
}
|
||||
}
|
||||
i1 += m_fld.length();
|
||||
if (i1 >= data.length())
|
||||
return string();
|
||||
@@ -50,6 +66,7 @@ public:
|
||||
|
||||
private:
|
||||
string m_fld;
|
||||
bool m_ismtime;
|
||||
};
|
||||
|
||||
Query::Query(Db *db)
|
||||
@@ -78,8 +95,12 @@ Db *Query::whatDb()
|
||||
}
|
||||
|
||||
void Query::setSortBy(const string& fld, bool ascending) {
|
||||
m_sortField = m_db->getConf()->fieldCanon(fld);
|
||||
m_sortAscending = ascending;
|
||||
if (fld.empty()) {
|
||||
m_sortField.erase();
|
||||
} else {
|
||||
m_sortField = m_db->getConf()->fieldCanon(fld);
|
||||
m_sortAscending = ascending;
|
||||
}
|
||||
LOGDEB0(("RclQuery::setSortBy: [%s] %s\n", m_sortField.c_str(),
|
||||
m_sortAscending ? "ascending" : "descending"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user