diff --git a/src/query/docseq.cpp b/src/query/docseq.cpp index 970a5334..bc313820 100644 --- a/src/query/docseq.cpp +++ b/src/query/docseq.cpp @@ -35,19 +35,20 @@ int DocSequence::getSeqSlice(int offs, int cnt, vector& result) return ret; } -void DocSource::unwind() +// Remove stacked modifying sources (sort, filter) until we get to a real one +void DocSource::stripStack() { - RefCntr base = m_seq; - while (!m_seq.isNull() && !(m_seq->getSourceSeq()).isNull()) { - base = m_seq->getSourceSeq(); + if (m_seq.isNull()) + return; + while (m_seq->getSourceSeq().isNotNull()) { + m_seq = m_seq->getSourceSeq(); } - m_seq = base; } bool DocSource::buildStack() { LOGDEB2(("DocSource::buildStack()\n")); - unwind(); + stripStack(); if (m_seq.isNull()) return false; diff --git a/src/query/docseq.h b/src/query/docseq.h index b385962f..7584221b 100644 --- a/src/query/docseq.h +++ b/src/query/docseq.h @@ -35,20 +35,14 @@ struct ResListEntry { string subHeader; }; -/** Sort specification. Will be made closer to the db interface one day */ +/** Sort specification. */ class DocSeqSortSpec { public: - DocSeqSortSpec() : sortdepth(0) {} - enum Field {RCLFLD_MIMETYPE, RCLFLD_MTIME}; - void addCrit(Field fld, bool desc = false) { - crits.push_back(fld); - dirs.push_back(desc); - } - bool isNotNull() const {return sortdepth > 0;} - void reset() {crits.clear(); dirs.clear();sortdepth = 0;} - int sortdepth; // We only re-sort the first sortdepth most relevant docs - std::vector crits; - std::vector dirs; + DocSeqSortSpec() : desc(false) {} + bool isNotNull() const {return !field.empty();} + void reset() {field.erase();} + string field; + bool desc; }; /** Filtering spec. This is only used to filter by doc category for now, hence @@ -203,7 +197,7 @@ public: virtual string title(); private: bool buildStack(); - void unwind(); + void stripStack(); DocSeqFiltSpec m_fspec; DocSeqSortSpec m_sspec; static string o_sort_trans;