From bc5ea83a3a25addc574a3633c34d35c11513a8a9 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Tue, 21 May 2019 11:20:14 +0200 Subject: [PATCH] qt gui: fix highlighting for the table mode display. the query terms were fetched too early, before executing the query. Also share hiliter between restable and reslist and avoid allocating another DocSource for restable, share the one from reslist. --- src/qtgui/reslist.cpp | 39 +++++++++++++++++++++------------------ src/qtgui/reslist.h | 7 +++++++ src/qtgui/restable.cpp | 27 +++++++++++---------------- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/src/qtgui/reslist.cpp b/src/qtgui/reslist.cpp index afde70fa..25397a67 100644 --- a/src/qtgui/reslist.cpp +++ b/src/qtgui/reslist.cpp @@ -301,25 +301,28 @@ string QtGuiResListPager::iconUrl(RclConfig *config, Rcl::Doc& doc) /////// /////// End reslistpager methods -class PlainToRichQtReslist : public PlainToRich { -public: - virtual string startMatch(unsigned int idx) { - if (0 && m_hdata) { - string s1, s2; - stringsToString >(m_hdata->groups[idx], s1); - stringsToString >( - m_hdata->ugroups[m_hdata->grpsugidx[idx]], s2); - LOGDEB2("Reslist startmatch: group " << s1 << " user group " << - s2 << "\n"); - } - - return string(""); +string PlainToRichQtReslist::startMatch(unsigned int idx) +{ + (void)idx; +#if 0 + if (m_hdata) { + string s1, s2; + stringsToString >(m_hdata->groups[idx], s1); + stringsToString >( + m_hdata->ugroups[m_hdata->grpsugidx[idx]], s2); + LOGDEB2("Reslist startmatch: group " << s1 << " user group " << + s2 << "\n"); } - virtual string endMatch() { - return string(""); - } -}; +#endif + return string(""); +} + +string PlainToRichQtReslist::endMatch() +{ + return string(""); +} + static PlainToRichQtReslist g_hiliter; ///////////////////////////////////// diff --git a/src/qtgui/reslist.h b/src/qtgui/reslist.h index 73628537..7831fd95 100644 --- a/src/qtgui/reslist.h +++ b/src/qtgui/reslist.h @@ -22,6 +22,8 @@ #include #include +#include "plaintorich.h" + #if defined(USING_WEBENGINE) # include # define RESLIST_PARENTCLASS QWebEngineView @@ -180,5 +182,10 @@ private: #endif +class PlainToRichQtReslist : public PlainToRich { +public: + virtual string startMatch(unsigned int idx); + virtual string endMatch(); +}; #endif /* _RESLIST_H_INCLUDED_ */ diff --git a/src/qtgui/restable.cpp b/src/qtgui/restable.cpp index 49a95f0a..ac999512 100644 --- a/src/qtgui/restable.cpp +++ b/src/qtgui/restable.cpp @@ -62,19 +62,6 @@ static const QKeySequence closeKeySeq("Ctrl+w"); static const int ROWHEIGHTPAD = 2; static const int TEXTINCELLVTRANS = -4; -////////////////////////////////////////////////////////////////////////////// -// Restable hiliter: to highlight search term in the table. This is actually -// the same as reslist's, could be shared. -class PlainToRichQtReslist : public PlainToRich { -public: - virtual ~PlainToRichQtReslist() {} - virtual string startMatch(unsigned int) - { - return string(""); - } - virtual string endMatch() {return string("");} -}; static PlainToRichQtReslist g_hiliter; ////////////////////////////////////////////////////////////////////////// @@ -99,7 +86,10 @@ bool ResTablePager::append(const string& data, int, const Rcl::Doc&) { m_parent->m_detail->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); m_parent->m_detail->textCursor().insertBlock(); - m_parent->m_detail->insertHtml(QString::fromUtf8(data.c_str())); + m_parent->m_detail->insertHtml(u8s2qs(data)); + +// LOGDEB("RESTABLEPAGER::APPEND: data : " << data << std::endl); +// m_parent->m_detail->setHtml(u8s2qs(data)); return true; } @@ -303,9 +293,12 @@ void RecollModel::setDocSource(std::shared_ptr nsource) if (!nsource) { m_source = std::shared_ptr(); } else { - m_source = std::shared_ptr(new DocSource(theconfig, nsource)); + // We used to allocate a new DocSource here instead of sharing + // the input, but I can't see why. + //m_source = std::shared_ptr(new + //DocSource(theconfig,nsource)); + m_source = nsource; m_hdata.clear(); - m_source->getTerms(m_hdata); } } @@ -562,6 +555,7 @@ void ResTable::init() this, SLOT(onDoubleClick(const QModelIndex&))); m_pager = new ResTablePager(this); + m_pager->setHighLighter(&g_hiliter); QSettings settings; QVariant saved = settings.value("resTableSplitterSizes"); @@ -779,6 +773,7 @@ void ResTable::readDocSource(bool resetPos) if (resetPos) tableView->verticalScrollBar()->setSliderPosition(0); + m_model->m_source->getTerms(m_model->m_hdata); m_model->readDocSource(); m_detail->clear(); m_detaildocnum = -1;