arrange to enable passing a match term as an argument when opening a document with the native editor (only / mostly pdf for now)
This commit is contained in:
@@ -1498,7 +1498,7 @@ static bool lookForHtmlBrowser(string &exefile)
|
||||
return false;
|
||||
}
|
||||
|
||||
void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum)
|
||||
void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
|
||||
{
|
||||
LOGDEB(("RclMain::startNativeViewer: page %d\n", pagenum));
|
||||
// Look for appropriate viewer
|
||||
@@ -1520,10 +1520,13 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum)
|
||||
|
||||
if (pagenum == -1) {
|
||||
pagenum = 1;
|
||||
string lterm;
|
||||
if (m_source.isNotNull())
|
||||
pagenum = m_source->getFirstMatchPage(doc);
|
||||
pagenum = m_source->getFirstMatchPage(doc, lterm);
|
||||
if (pagenum == -1)
|
||||
pagenum = 1;
|
||||
else
|
||||
term = QString::fromUtf8(lterm.c_str());
|
||||
}
|
||||
char cpagenum[20];
|
||||
sprintf(cpagenum, "%d", pagenum);
|
||||
@@ -1666,6 +1669,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum)
|
||||
subs["i"] = doc.ipath;
|
||||
subs["M"] = doc.mimetype;
|
||||
subs["p"] = cpagenum;
|
||||
subs["s"] = (const char*)term.toLocal8Bit();
|
||||
subs["U"] = url;
|
||||
subs["u"] = url;
|
||||
// Let %(xx) access all metadata.
|
||||
|
||||
@@ -119,7 +119,8 @@ public slots:
|
||||
virtual void docExpand(Rcl::Doc);
|
||||
virtual void startPreview(int docnum, Rcl::Doc doc, int keymods);
|
||||
virtual void startPreview(Rcl::Doc);
|
||||
virtual void startNativeViewer(Rcl::Doc, int pagenum = -1);
|
||||
virtual void startNativeViewer(Rcl::Doc, int pagenum = -1,
|
||||
QString term=QString());
|
||||
virtual void saveDocToFile(Rcl::Doc);
|
||||
virtual void previewNextInTab(Preview *, int sid, int docnum);
|
||||
virtual void previewPrevInTab(Preview *, int sid, int docnum);
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <qclipboard.h>
|
||||
#include <qscrollbar.h>
|
||||
#include <QTextBlock>
|
||||
#include <QShortcut>
|
||||
#ifndef __APPLE__
|
||||
#include <qx11info_x11.h>
|
||||
#endif
|
||||
@@ -59,9 +60,8 @@
|
||||
#include "rclaspell.h"
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(A,B) ((A) < (B) ? (A) : (B))
|
||||
#endif
|
||||
static const QKeySequence quitKeySeq("Ctrl+q");
|
||||
static const QKeySequence closeKeySeq("Ctrl+w");
|
||||
|
||||
#ifndef RESLIST_TEXTBROWSER
|
||||
#include <QWebFrame>
|
||||
@@ -805,9 +805,13 @@ void ResList::newSnippetsW(const Rcl::Doc& doc)
|
||||
{
|
||||
SnippetsW *sp = new SnippetsW(doc, m_source);
|
||||
if (m_parent) {
|
||||
connect(sp, SIGNAL(startNativeViewer(Rcl::Doc, int)),
|
||||
m_parent, SLOT(startNativeViewer(Rcl::Doc, int)));
|
||||
connect(sp, SIGNAL(startNativeViewer(Rcl::Doc, int, QString)),
|
||||
m_parent, SLOT(startNativeViewer(Rcl::Doc, int, QString)));
|
||||
connect(new QShortcut(quitKeySeq, sp), SIGNAL (activated()),
|
||||
m_parent, SLOT (fileExit()));
|
||||
}
|
||||
connect(new QShortcut(closeKeySeq, sp), SIGNAL (activated()),
|
||||
sp, SLOT (close()));
|
||||
sp->show();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ void SnippetsW::init()
|
||||
|
||||
setWindowTitle(QString::fromUtf8(titleOrFilename.c_str()));
|
||||
|
||||
vector<pair<int, string> > vpabs;
|
||||
vector<Rcl::Snippet> vpabs;
|
||||
m_source->getAbstract(m_doc, vpabs);
|
||||
|
||||
HighlightData hdata;
|
||||
@@ -77,21 +77,23 @@ void SnippetsW::init()
|
||||
|
||||
g_hiliter.set_inputhtml(false);
|
||||
|
||||
for (vector<pair<int, string> >::const_iterator it = vpabs.begin();
|
||||
for (vector<Rcl::Snippet>::const_iterator it = vpabs.begin();
|
||||
it != vpabs.end(); it++) {
|
||||
html += "<tr><td>";
|
||||
if (it->first > 0) {
|
||||
char buf[100];
|
||||
sprintf(buf, "P. %d", it->first);
|
||||
if (it->page > 0) {
|
||||
char txt[100];
|
||||
sprintf(txt, "P. %d", it->page);
|
||||
char url[100];
|
||||
sprintf(url, "P%dT%s", it->page, it->term.c_str());
|
||||
html += "<a href=\"";
|
||||
html += buf;
|
||||
html += url;
|
||||
html += "\">";
|
||||
html += buf;
|
||||
html += txt;
|
||||
html += "</a>";
|
||||
}
|
||||
html += "</td><td>";
|
||||
list<string> lr;
|
||||
g_hiliter.plaintorich(it->second, lr, hdata);
|
||||
g_hiliter.plaintorich(it->snippet, lr, hdata);
|
||||
html.append(QString::fromUtf8(lr.front().c_str()));
|
||||
html.append("</td></tr>\n");
|
||||
}
|
||||
@@ -117,7 +119,12 @@ void SnippetsW::linkWasClicked(const QUrl &url)
|
||||
if (numpos == string::npos)
|
||||
return;
|
||||
int page = atoi(ascurl.c_str() + numpos);
|
||||
emit startNativeViewer(m_doc, page);
|
||||
string::size_type termpos = ascurl.find_first_of("T");
|
||||
string term;
|
||||
if (termpos != string::npos)
|
||||
term = ascurl.substr(termpos+1);
|
||||
emit startNativeViewer(m_doc, page,
|
||||
QString::fromUtf8(term.c_str()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
#ifndef _SNIPPETS_W_H_INCLUDED_
|
||||
#define _SNIPPETS_W_H_INCLUDED_
|
||||
#include <QString>
|
||||
|
||||
#include "rcldoc.h"
|
||||
#include "refcntr.h"
|
||||
@@ -39,7 +40,7 @@ protected slots:
|
||||
virtual void linkWasClicked(const QUrl &);
|
||||
|
||||
signals:
|
||||
void startNativeViewer(Rcl::Doc, int pagenum);
|
||||
void startNativeViewer(Rcl::Doc, int pagenum, QString term);
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
Reference in New Issue
Block a user