Preview: toggling between main text and fields would confuse the text format (plain/rich)
This commit is contained in:
parent
e6d5f72886
commit
4cbdfd7f89
@ -954,6 +954,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
|
|||||||
PreviewTextEdit *editor = currentEditor();
|
PreviewTextEdit *editor = currentEditor();
|
||||||
editor->setText("");
|
editor->setText("");
|
||||||
editor->setTextFormat(Qt::RichText);
|
editor->setTextFormat(Qt::RichText);
|
||||||
|
editor->m_data.format = Qt::RichText;
|
||||||
bool inputishtml = !fdoc.mimetype.compare("text/html");
|
bool inputishtml = !fdoc.mimetype.compare("text/html");
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -1031,6 +1032,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
|
|||||||
qrichlst.push_back(qr);
|
qrichlst.push_back(qr);
|
||||||
} else {
|
} else {
|
||||||
editor->setTextFormat(Qt::PlainText);
|
editor->setTextFormat(Qt::PlainText);
|
||||||
|
editor->m_data.format = Qt::PlainText;
|
||||||
for (int pos = 0; pos < (int)qr.length(); pos += l) {
|
for (int pos = 0; pos < (int)qr.length(); pos += l) {
|
||||||
l = MIN(CHUNKL, qr.length() - pos);
|
l = MIN(CHUNKL, qr.length() - pos);
|
||||||
qrichlst.push_back(qr.mid(pos, l));
|
qrichlst.push_back(qr.mid(pos, l));
|
||||||
@ -1127,6 +1129,7 @@ void PreviewTextEdit::toggleFields()
|
|||||||
|
|
||||||
// If currently displaying fields, switch to body text
|
// If currently displaying fields, switch to body text
|
||||||
if (m_dspflds) {
|
if (m_dspflds) {
|
||||||
|
setTextFormat(m_data.format);
|
||||||
setText(m_data.richtxt);
|
setText(m_data.richtxt);
|
||||||
m_dspflds = false;
|
m_dspflds = false;
|
||||||
return;
|
return;
|
||||||
@ -1134,6 +1137,7 @@ void PreviewTextEdit::toggleFields()
|
|||||||
|
|
||||||
// Else display fields
|
// Else display fields
|
||||||
m_dspflds = true;
|
m_dspflds = true;
|
||||||
|
setTextFormat(Qt::RichText);
|
||||||
QString txt = "<html><head></head><body>\n";
|
QString txt = "<html><head></head><body>\n";
|
||||||
txt += "<b>" + QString::fromLocal8Bit(m_data.url.c_str());
|
txt += "<b>" + QString::fromLocal8Bit(m_data.url.c_str());
|
||||||
if (!m_data.ipath.empty())
|
if (!m_data.ipath.empty())
|
||||||
@ -1143,7 +1147,8 @@ void PreviewTextEdit::toggleFields()
|
|||||||
for (map<string,string>::const_iterator it = m_data.fdoc.meta.begin();
|
for (map<string,string>::const_iterator it = m_data.fdoc.meta.begin();
|
||||||
it != m_data.fdoc.meta.end(); it++) {
|
it != m_data.fdoc.meta.end(); it++) {
|
||||||
txt += "<dt>" + QString::fromUtf8(it->first.c_str()) + "</dt> "
|
txt += "<dt>" + QString::fromUtf8(it->first.c_str()) + "</dt> "
|
||||||
+ "<dd>" + QString::fromUtf8(it->second.c_str()) + "</dd>\n";
|
+ "<dd>" + QString::fromUtf8(escapeHtml(it->second).c_str())
|
||||||
|
+ "</dd>\n";
|
||||||
}
|
}
|
||||||
txt += "</dl></body></html>";
|
txt += "</dl></body></html>";
|
||||||
setText(txt);
|
setText(txt);
|
||||||
|
|||||||
@ -57,10 +57,11 @@ public:
|
|||||||
// doc out of internfile (previous fields come from the index) with
|
// doc out of internfile (previous fields come from the index) with
|
||||||
// main text erased (for space).
|
// main text erased (for space).
|
||||||
Rcl::Doc fdoc;
|
Rcl::Doc fdoc;
|
||||||
// Saved rich text: the textedit seems to sometimes (but not
|
// Saved rich (or plain actually) text: the textedit seems to
|
||||||
// always) return its text stripped of tags, so this is needed
|
// sometimes (but not always) return its text stripped of tags, so
|
||||||
// (for printing for example)
|
// this is needed (for printing for example)
|
||||||
QString richtxt;
|
QString richtxt;
|
||||||
|
Qt::TextFormat format;
|
||||||
TabData()
|
TabData()
|
||||||
: docnum(-1)
|
: docnum(-1)
|
||||||
{}
|
{}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user