]> git.lyx.org Git - features.git/commitdiff
Fix bug #5600: View source panel isn't updating after restart.
authorVincent van Ravesteijn <vfr@lyx.org>
Tue, 4 Jan 2011 00:00:20 +0000 (00:00 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Tue, 4 Jan 2011 00:00:20 +0000 (00:00 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37096 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiViewSource.cpp
src/frontends/qt4/GuiViewSource.h

index 1afee03fba5da48fc82a8dcc9de29d6632c23d54..e538090c87b214c66131826056289cff4b8f50c6 100644 (file)
@@ -43,12 +43,13 @@ namespace frontend {
 
 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)),
@@ -89,7 +90,7 @@ static size_t crcCheck(docstring const & s)
        \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
@@ -110,7 +111,7 @@ static bool getContent(BufferView const * view, bool fullSource,
        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);
@@ -120,11 +121,20 @@ static bool getContent(BufferView const * view, bool fullSource,
 
 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_) {
@@ -139,7 +149,8 @@ void ViewSourceWidget::updateView()
                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();
index e364e6ff832db1e88297b7c1fb01b55bcfd1e89a..e3c7a814e5b142eb021bb1ba72f6489e9d070bea 100644 (file)
@@ -46,6 +46,8 @@ public Q_SLOTS:
        void updateView();
        ///
        void updateDefaultFormat();
+       ///
+       void fullSourceChanged();
 
 private:
        ///
@@ -54,6 +56,8 @@ private:
        QTextDocument * document_;
        /// LaTeX syntax highlighter
        LaTeXHighlighter * highlighter_;
+       ///
+       bool force_getcontent_;
 };