preview: clarify a bit the search code. Found no way to highlight anchors, still an issue (filed QTBUG-78927)

This commit is contained in:
Jean-Francois Dockes 2019-10-02 10:25:35 +02:00
parent b64751e138
commit 70e4cb0651
2 changed files with 21 additions and 19 deletions

View File

@ -131,8 +131,6 @@ void Preview::init()
"RCL.SEARCH.GUI.PREVIEW"); "RCL.SEARCH.GUI.PREVIEW");
// signals and slots connections // signals and slots connections
connect(searchTextCMB, SIGNAL(activated(int)),
this, SLOT(searchTextFromIndex(int)));
connect(searchTextCMB, SIGNAL(editTextChanged(const QString&)), connect(searchTextCMB, SIGNAL(editTextChanged(const QString&)),
this, SLOT(searchTextChanged(const QString&))); this, SLOT(searchTextChanged(const QString&)));
connect(nextPB, SIGNAL(clicked()), this, SLOT(nextPressed())); connect(nextPB, SIGNAL(clicked()), this, SLOT(nextPressed()));
@ -259,25 +257,30 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
void Preview::searchTextChanged(const QString & text) void Preview::searchTextChanged(const QString & text)
{ {
LOGDEB1("Search line text changed. text: '" << qs2utf8s(text) << "'\n"); LOGDEB("Preview::searchTextChanged:(" << qs2utf8s(text) << ") current: ("<<
m_searchTextFromIndex = -1; qs2utf8s(searchTextCMB->currentText()) << ") currentindex " <<
if (text.isEmpty()) { searchTextCMB->currentIndex() << "\n");
m_dynSearchActive = false; if (!searchTextCMB->itemText(searchTextCMB->currentIndex()).compare(text)) {
clearPB->setEnabled(false); // Then we assume that the text was set by selecting in the
// combobox There does not seem to be another way to
// discriminate select and hand edit. Note that the
// activated() signal is called *after* the editTextChanged()
// one, so it is useless.
m_searchTextFromIndex = searchTextCMB->currentIndex();
doSearch("", false, false);
} else { } else {
m_dynSearchActive = true; m_searchTextFromIndex = -1;
clearPB->setEnabled(true); if (text.isEmpty()) {
doSearch(text, false, false); m_dynSearchActive = false;
clearPB->setEnabled(false);
} else {
m_dynSearchActive = true;
clearPB->setEnabled(true);
doSearch(text, false, false);
}
} }
} }
void Preview::searchTextFromIndex(int idx)
{
LOGDEB1("search line from index " << idx << "\n");
m_searchTextFromIndex = idx;
}
void Preview::emitSaveDocToFile() void Preview::emitSaveDocToFile()
{ {
PreviewTextEdit *ce = currentEditor(); PreviewTextEdit *ce = currentEditor();

View File

@ -137,7 +137,6 @@ public:
public slots: public slots:
// Search stuff // Search stuff
virtual void searchTextChanged(const QString& text); virtual void searchTextChanged(const QString& text);
virtual void searchTextFromIndex(int);
virtual void doSearch(const QString& str, bool next, bool reverse, virtual void doSearch(const QString& str, bool next, bool reverse,
bool wo = false); bool wo = false);
virtual void nextPressed(); virtual void nextPressed();
@ -173,7 +172,7 @@ private:
bool m_dynSearchActive{false}; bool m_dynSearchActive{false};
// Index value the search text comes from. -1 if text was edited // Index value the search text comes from. -1 if text was edited
int m_searchTextFromIndex{-1}; int m_searchTextFromIndex{0};
bool m_canBeep{true}; bool m_canBeep{true};
bool m_loading{false}; bool m_loading{false};