ViewSourceWidget::ViewSourceWidget()
: bv_(0), document_(new QTextDocument(this)),
- highlighter_(new LaTeXHighlighter(document_))
+ highlighter_(new LaTeXHighlighter(document_)),
+ force_getcontent_(true)
{
setupUi(this);
connect(viewFullSourceCB, SIGNAL(clicked()),
- this, SLOT(updateView()));
+ this, SLOT(fullSourceChanged()));
connect(autoUpdateCB, SIGNAL(toggled(bool)),
updatePB, SLOT(setDisabled(bool)));
connect(autoUpdateCB, SIGNAL(toggled(bool)),
\return true if the content has changed since last call.
*/
static bool getContent(BufferView const * view, bool fullSource,
- QString & qstr, string const format)
+ QString & qstr, string const format, bool force_getcontent)
{
// get the *top* level paragraphs that contain the cursor,
// or the selected text
docstring s = ostr.str();
static size_t crc = 0;
size_t newcrc = crcCheck(s);
- if (newcrc == crc)
+ if (newcrc == crc && !force_getcontent)
return false;
crc = newcrc;
qstr = toqstr(s);
void ViewSourceWidget::setBufferView(BufferView const * bv)
{
+ if (bv_ != bv)
+ force_getcontent_ = true;
bv_ = bv;
setEnabled(bv ? true : false);
}
+void ViewSourceWidget::fullSourceChanged()
+{
+ if (autoUpdateCB->isChecked())
+ updateView();
+}
+
+
void ViewSourceWidget::updateView()
{
if (!bv_) {
outputFormatCO->currentIndex()).toString());
QString content;
- if (getContent(bv_, viewFullSourceCB->isChecked(), content, format))
+ if (getContent(bv_, viewFullSourceCB->isChecked(), content,
+ format, force_getcontent_))
document_->setPlainText(content);
CursorSlice beg = bv_->cursor().selectionBegin().bottom();