GUI: snippets: add context menu to switch page/relevance sort
This commit is contained in:
parent
6a405e2089
commit
939b10b994
@ -77,6 +77,7 @@ static PlainToRichQtSnippets g_hiliter;
|
|||||||
|
|
||||||
void SnippetsW::init()
|
void SnippetsW::init()
|
||||||
{
|
{
|
||||||
|
m_sortingByPage = prefs.snipwSortByPage;
|
||||||
QPushButton *searchButton = new QPushButton(tr("Search"));
|
QPushButton *searchButton = new QPushButton(tr("Search"));
|
||||||
searchButton->setAutoDefault(false);
|
searchButton->setAutoDefault(false);
|
||||||
buttonBox->addButton(searchButton, QDialogButtonBox::ActionRole);
|
buttonBox->addButton(searchButton, QDialogButtonBox::ActionRole);
|
||||||
@ -102,6 +103,7 @@ void SnippetsW::init()
|
|||||||
connect(nextPB, SIGNAL(clicked()), this, SLOT(slotEditFindNext()));
|
connect(nextPB, SIGNAL(clicked()), this, SLOT(slotEditFindNext()));
|
||||||
connect(prevPB, SIGNAL(clicked()), this, SLOT(slotEditFindPrevious()));
|
connect(prevPB, SIGNAL(clicked()), this, SLOT(slotEditFindPrevious()));
|
||||||
|
|
||||||
|
|
||||||
delete browserw;
|
delete browserw;
|
||||||
#if defined(USING_WEBKIT)
|
#if defined(USING_WEBKIT)
|
||||||
browserw = new QWebView(this);
|
browserw = new QWebView(this);
|
||||||
@ -119,6 +121,9 @@ void SnippetsW::init()
|
|||||||
}
|
}
|
||||||
if (!prefs.snipCssFile.isEmpty())
|
if (!prefs.snipCssFile.isEmpty())
|
||||||
ws->setUserStyleSheetUrl(QUrl::fromLocalFile(prefs.snipCssFile));
|
ws->setUserStyleSheetUrl(QUrl::fromLocalFile(prefs.snipCssFile));
|
||||||
|
browserw->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(browserw, SIGNAL(customContextMenuRequested(const QPoint&)),
|
||||||
|
this, SLOT(createPopupMenu(const QPoint&)));
|
||||||
#elif defined(USING_WEBENGINE)
|
#elif defined(USING_WEBENGINE)
|
||||||
browserw = new QWebEngineView(this);
|
browserw = new QWebEngineView(this);
|
||||||
verticalLayout->insertWidget(0, browserw);
|
verticalLayout->insertWidget(0, browserw);
|
||||||
@ -129,6 +134,9 @@ void SnippetsW::init()
|
|||||||
ws->setFontSize(QWEBSETTINGS::DefaultFontSize, prefs.reslistfontsize);
|
ws->setFontSize(QWEBSETTINGS::DefaultFontSize, prefs.reslistfontsize);
|
||||||
}
|
}
|
||||||
// Stylesheet TBD
|
// Stylesheet TBD
|
||||||
|
browserw->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(browserw, SIGNAL(customContextMenuRequested(const QPoint&)),
|
||||||
|
this, SLOT(createPopupMenu(const QPoint&)));
|
||||||
#else
|
#else
|
||||||
browserw = new QTextBrowser(this);
|
browserw = new QTextBrowser(this);
|
||||||
verticalLayout->insertWidget(0, browserw);
|
verticalLayout->insertWidget(0, browserw);
|
||||||
@ -147,9 +155,33 @@ void SnippetsW::init()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SnippetsW::createPopupMenu(const QPoint& pos)
|
||||||
|
{
|
||||||
|
QMenu *popup = new QMenu(this);
|
||||||
|
if (m_sortingByPage) {
|
||||||
|
popup->addAction(tr("Sort By Relevance"), this,
|
||||||
|
SLOT(reloadByRelevance()));
|
||||||
|
} else {
|
||||||
|
popup->addAction(tr("Sort By Page"), this, SLOT(reloadByPage()));
|
||||||
|
}
|
||||||
|
popup->popup(mapToGlobal(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SnippetsW::reloadByRelevance()
|
||||||
|
{
|
||||||
|
m_sortingByPage = false;
|
||||||
|
onSetDoc(m_doc, m_source);
|
||||||
|
}
|
||||||
|
void SnippetsW::reloadByPage()
|
||||||
|
{
|
||||||
|
m_sortingByPage = true;
|
||||||
|
onSetDoc(m_doc, m_source);
|
||||||
|
}
|
||||||
|
|
||||||
void SnippetsW::onSetDoc(Rcl::Doc doc, std::shared_ptr<DocSequence> source)
|
void SnippetsW::onSetDoc(Rcl::Doc doc, std::shared_ptr<DocSequence> source)
|
||||||
{
|
{
|
||||||
m_doc = doc;
|
m_doc = doc;
|
||||||
|
m_source = source;
|
||||||
if (!source)
|
if (!source)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -168,8 +200,7 @@ void SnippetsW::onSetDoc(Rcl::Doc doc, std::shared_ptr<DocSequence> source)
|
|||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
|
|
||||||
vector<Rcl::Snippet> vpabs;
|
vector<Rcl::Snippet> vpabs;
|
||||||
source->getAbstract(m_doc, vpabs,
|
source->getAbstract(m_doc, vpabs, prefs.snipwMaxLength, m_sortingByPage);
|
||||||
prefs.snipwMaxLength, prefs.snipwSortByPage);
|
|
||||||
|
|
||||||
HighlightData hdata;
|
HighlightData hdata;
|
||||||
source->getTerms(hdata);
|
source->getTerms(hdata);
|
||||||
|
|||||||
@ -44,18 +44,24 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
virtual void onLinkClicked(const QUrl &);
|
virtual void onLinkClicked(const QUrl &);
|
||||||
virtual void onSetDoc(Rcl::Doc doc, std::shared_ptr<DocSequence> source);
|
virtual void onSetDoc(Rcl::Doc doc, std::shared_ptr<DocSequence> source);
|
||||||
|
virtual void createPopupMenu(const QPoint& pos);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void slotEditFind();
|
virtual void slotEditFind();
|
||||||
virtual void slotEditFindNext();
|
virtual void slotEditFindNext();
|
||||||
virtual void slotEditFindPrevious();
|
virtual void slotEditFindPrevious();
|
||||||
virtual void slotSearchTextChanged(const QString&);
|
virtual void slotSearchTextChanged(const QString&);
|
||||||
|
virtual void reloadByRelevance();
|
||||||
|
virtual void reloadByPage();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void startNativeViewer(Rcl::Doc, int pagenum, QString term);
|
void startNativeViewer(Rcl::Doc, int pagenum, QString term);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
std::shared_ptr<DocSequence> m_source;
|
||||||
Rcl::Doc m_doc;
|
Rcl::Doc m_doc;
|
||||||
|
bool m_sortingByPage;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USING_WEBENGINE
|
#ifdef USING_WEBENGINE
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user