mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Fix bug #5600: View source panel isn't updating after restart.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37096 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0faafa47bf
commit
cc00b9aaca
@ -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();
|
||||
|
@ -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_;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user