From 4cbdfd7f89a6d2f5cb495d140800dfac5418d16c Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Wed, 7 Jul 2010 13:08:38 +0200 Subject: [PATCH] Preview: toggling between main text and fields would confuse the text format (plain/rich) --- src/qtgui/preview_w.cpp | 7 ++++++- src/qtgui/preview_w.h | 9 +++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/qtgui/preview_w.cpp b/src/qtgui/preview_w.cpp index 35a2c970..8da35d71 100644 --- a/src/qtgui/preview_w.cpp +++ b/src/qtgui/preview_w.cpp @@ -954,6 +954,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum) PreviewTextEdit *editor = currentEditor(); editor->setText(""); editor->setTextFormat(Qt::RichText); + editor->m_data.format = Qt::RichText; bool inputishtml = !fdoc.mimetype.compare("text/html"); #if 0 @@ -1031,6 +1032,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum) qrichlst.push_back(qr); } else { editor->setTextFormat(Qt::PlainText); + editor->m_data.format = Qt::PlainText; for (int pos = 0; pos < (int)qr.length(); pos += l) { l = MIN(CHUNKL, qr.length() - pos); qrichlst.push_back(qr.mid(pos, l)); @@ -1127,6 +1129,7 @@ void PreviewTextEdit::toggleFields() // If currently displaying fields, switch to body text if (m_dspflds) { + setTextFormat(m_data.format); setText(m_data.richtxt); m_dspflds = false; return; @@ -1134,6 +1137,7 @@ void PreviewTextEdit::toggleFields() // Else display fields m_dspflds = true; + setTextFormat(Qt::RichText); QString txt = "\n"; txt += "" + QString::fromLocal8Bit(m_data.url.c_str()); if (!m_data.ipath.empty()) @@ -1143,7 +1147,8 @@ void PreviewTextEdit::toggleFields() for (map::const_iterator it = m_data.fdoc.meta.begin(); it != m_data.fdoc.meta.end(); it++) { txt += "
" + QString::fromUtf8(it->first.c_str()) + "
" - + "
" + QString::fromUtf8(it->second.c_str()) + "
\n"; + + "
" + QString::fromUtf8(escapeHtml(it->second).c_str()) + + "
\n"; } txt += ""; setText(txt); diff --git a/src/qtgui/preview_w.h b/src/qtgui/preview_w.h index c7e1420c..33327b38 100644 --- a/src/qtgui/preview_w.h +++ b/src/qtgui/preview_w.h @@ -57,10 +57,11 @@ public: // doc out of internfile (previous fields come from the index) with // main text erased (for space). Rcl::Doc fdoc; - // Saved rich text: the textedit seems to sometimes (but not - // always) return its text stripped of tags, so this is needed - // (for printing for example) - QString richtxt; + // Saved rich (or plain actually) text: the textedit seems to + // sometimes (but not always) return its text stripped of tags, so + // this is needed (for printing for example) + QString richtxt; + Qt::TextFormat format; TabData() : docnum(-1) {}