1 /* Copyright (C) 2004-2021 J.F.Dockes 2 * This program is free software; you can redistribute it and/or modify 3 * it under the terms of the GNU General Public License as published by 4 * the Free Software Foundation; either version 2 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the 14 * Free Software Foundation, Inc., 15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 */ 17 #ifndef _DOCSEQDB_H_INCLUDED_ 18 #define _DOCSEQDB_H_INCLUDED_ 19 20 #include <memory> 21 22 #include "docseq.h" 23 #include "searchdata.h" 24 #include "rclquery.h" 25 26 /** A DocSequence from a Db query */ 27 class DocSequenceDb : public DocSequence { 28 public: 29 DocSequenceDb(std::shared_ptr<Rcl::Db> db, 30 std::shared_ptr<Rcl::Query> q, const std::string &t, 31 std::shared_ptr<Rcl::SearchData> sdata); ~DocSequenceDb()32 virtual ~DocSequenceDb() {} 33 virtual bool getDoc(int num, Rcl::Doc &doc, std::string * = 0) override; 34 virtual int getResCnt() override; 35 virtual void getTerms(HighlightData& hld) override; 36 37 // Called to fill-up the snippets window. Ignoers 38 // buildabstract/replaceabstract and syntabslen 39 virtual bool getAbstract(Rcl::Doc &doc, std::vector<Rcl::Snippet>&, 40 int maxlen, bool sortbypage) override; 41 42 virtual bool getAbstract(Rcl::Doc &doc, std::vector<std::string>&) override; 43 virtual int getFirstMatchPage(Rcl::Doc&, std::string& term) override; 44 virtual bool docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups) 45 override; 46 virtual std::string getDescription() override; 47 virtual std::list<std::string> expand(Rcl::Doc &doc) override; canFilter()48 virtual bool canFilter() override {return true;} 49 virtual bool setFiltSpec(const DocSeqFiltSpec &filtspec) override; canSort()50 virtual bool canSort() override {return true;} 51 virtual bool setSortSpec(const DocSeqSortSpec &sortspec) override; setAbstractParams(bool qba,bool qra)52 virtual void setAbstractParams(bool qba, bool qra) { 53 m_queryBuildAbstract = qba; 54 m_queryReplaceAbstract = qra; 55 } 56 snippetsCapable()57 virtual bool snippetsCapable() override { 58 return true; 59 } 60 virtual std::string title() override; 61 62 protected: getDb()63 virtual std::shared_ptr<Rcl::Db> getDb() override { 64 return m_db; 65 } 66 private: 67 std::shared_ptr<Rcl::Db> m_db; 68 std::shared_ptr<Rcl::Query> m_q; 69 std::shared_ptr<Rcl::SearchData> m_sdata; 70 std::shared_ptr<Rcl::SearchData> m_fsdata; // Filtered 71 int m_rescnt{-1}; 72 bool m_queryBuildAbstract{true}; 73 bool m_queryReplaceAbstract{false}; 74 bool m_isFiltered{false}; 75 bool m_isSorted{false}; 76 bool m_needSetQuery{false}; // search data changed, need to reapply before fetch 77 bool m_lastSQStatus{true}; 78 bool setQuery(); 79 }; 80 81 #endif /* _DOCSEQDB_H_INCLUDED_ */ 82