add capability to remember page breaks generated by, e.g. pdftotext, and use them to start an external viewer on a match page

This commit is contained in:
"Jean-Francois Dockes ext:(%22)
2012-08-21 15:03:02 +02:00
parent ec3dbb4092
commit 0ebfc496d8
15 changed files with 292 additions and 85 deletions
+24 -5
View File
@@ -35,6 +35,7 @@ using std::pair;
#include <qscrollbar.h>
#include <qmenu.h>
#include <qtextedit.h>
#include <qtextbrowser.h>
#include <qprogressdialog.h>
#include <qevent.h>
#include <qlabel.h>
@@ -732,10 +733,10 @@ class LoadThread : public QThread {
FileInterner::FIF_forPreview);
FIMissingStore mst;
interner.setMissingStore(&mst);
// We don't set the interner's target mtype to html because we
// do want the html filter to do its work: we won't use the
// text, but we need the conversion to utf-8
// interner.setTargetMType("text/html");
// Even when previewHtml is set, we don't set the interner's
// target mtype to html because we do want the html filter to
// do its work: we won't use the text/plain, but we want the
// text/html to be converted to utf-8 (for highlight processing)
try {
string ipath = idoc.ipath;
FileInterner::Status ret = interner.internfile(out, ipath);
@@ -883,6 +884,22 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
// while still inserting at bottom
list<QString> qrichlst;
PreviewTextEdit *editor = currentEditor();
// For an actual html file, if we want to have the images and
// style loaded in the preview, we need to set the search
// path. Not too sure this is a good idea as I find them rather
// distracting when looking for text, esp. with qtextedit
// relatively limited html support (text sometimes get hidden by
// images).
#if 0
string path = fileurltolocalpath(idoc.url);
if (!path.empty()) {
path = path_getfather(path);
QStringList paths(QString::fromLocal8Bit(path.c_str()));
editor->setSearchPaths(paths);
}
#endif
editor->setHtml("");
editor->m_format = Qt::RichText;
bool inputishtml = !fdoc.mimetype.compare("text/html");
@@ -1073,7 +1090,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
}
PreviewTextEdit::PreviewTextEdit(QWidget* parent, const char* nm, Preview *pv)
: QTextEdit(parent), m_preview(pv),
: QTextBrowser(parent), m_preview(pv),
m_plaintorich(new PlainToRichQtPreview()),
m_dspflds(false), m_docnum(-1)
{
@@ -1081,6 +1098,8 @@ PreviewTextEdit::PreviewTextEdit(QWidget* parent, const char* nm, Preview *pv)
setObjectName(nm);
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(createPopupMenu(const QPoint&)));
setOpenExternalLinks(false);
setOpenLinks(false);
}
PreviewTextEdit::~PreviewTextEdit()
+15 -3
View File
@@ -17,11 +17,24 @@
#ifndef _PREVIEW_W_H_INCLUDED_
#define _PREVIEW_W_H_INCLUDED_
// Always use a qtextbrowser for now, there is no compelling reason to
// switch to webkit here
#if 1 || defined(RESLIST_TEXTBROWSER)
#define PREVIEW_TEXTBROWSER
#endif
#include <stdio.h>
#include <qvariant.h>
#include <qwidget.h>
#include <qtextedit.h>
#ifdef PREVIEW_TEXTBROWSER
#include <QTextBrowser>
#define PREVIEW_PARENTCLASS QTextBrowser
#else
#include <QtWebKit/QWebView>
#define PREVIEW_PARENTCLASS QWebView
#endif
#include <qimage.h>
#include "rcldb.h"
@@ -31,13 +44,12 @@
class QTabWidget;
class QLabel;
class QLineEdit;
class QPushButton;
class QCheckBox;
class Preview;
class PlainToRichQtPreview;
class PreviewTextEdit : public QTextEdit {
class PreviewTextEdit : public PREVIEW_PARENTCLASS {
Q_OBJECT;
public:
PreviewTextEdit(QWidget* parent, const char* name, Preview *pv);
+9
View File
@@ -1520,6 +1520,14 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
return;
}
int pagenum = 1;
if (m_source.isNotNull())
pagenum = m_source->getFirstMatchPage(doc);
if (pagenum == -1)
pagenum = 1;
char cpagenum[20];
sprintf(cpagenum, "%d", pagenum);
// Extract possible viewer attributes
ConfSimple attrs;
string cmd;
@@ -1657,6 +1665,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
subs["F"] = orgfn;
subs["i"] = doc.ipath;
subs["M"] = doc.mimetype;
subs["p"] = cpagenum;
subs["U"] = url;
subs["u"] = url;
// Let %(xx) access all metadata.