From 11474f6b89abcf7fa99f21f9414234b8c15bbbf6 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 25 Jan 2010 13:31:07 +0000 Subject: [PATCH] Get rid of Buffer::setReadOnly() pseudo signal. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33222 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 9 +-------- src/Buffer.h | 2 -- src/frontends/WorkArea.h | 2 -- src/frontends/WorkAreaManager.cpp | 7 ------- src/frontends/WorkAreaManager.h | 2 -- src/frontends/qt4/GuiWorkArea.cpp | 9 +++++++-- src/frontends/qt4/GuiWorkArea.h | 4 +++- 7 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index bc72f21afd..865f468fe7 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -603,7 +603,7 @@ void Buffer::setReadonly(bool const flag) { if (d->read_only != flag) { d->read_only = flag; - setReadOnly(flag); + changed(false); } } @@ -2952,13 +2952,6 @@ void Buffer::setBusy(bool on) const } -void Buffer::setReadOnly(bool on) const -{ - if (d->wa_) - d->wa_->setReadOnly(on); -} - - void Buffer::updateTitles() const { if (d->wa_) diff --git a/src/Buffer.h b/src/Buffer.h index deca3a49db..460bd06860 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -492,8 +492,6 @@ public: void errors(std::string const & err, bool from_master = false) const; /// This function is called when the buffer busy status change. void setBusy(bool on) const; - /// This function is called when the buffer readonly status change. - void setReadOnly(bool on) const; /// Update window titles of all users. void updateTitles() const; /// Reset autosave timers for all users. diff --git a/src/frontends/WorkArea.h b/src/frontends/WorkArea.h index 059268617c..c5aadfef6f 100644 --- a/src/frontends/WorkArea.h +++ b/src/frontends/WorkArea.h @@ -43,8 +43,6 @@ public: /// close this work area. /// Slot for Buffer::closing signal. virtual void close() = 0; - /// This function is called when the buffer readonly status change. - virtual void setReadOnly(bool) = 0; /// Update window titles of all users. virtual void updateWindowTitle() = 0; diff --git a/src/frontends/WorkAreaManager.cpp b/src/frontends/WorkAreaManager.cpp index f79863be36..4149d2cab4 100644 --- a/src/frontends/WorkAreaManager.cpp +++ b/src/frontends/WorkAreaManager.cpp @@ -46,13 +46,6 @@ void WorkAreaManager::closeAll() } -void WorkAreaManager::setReadOnly(bool on) -{ - for (iterator it = work_areas_.begin(); it != work_areas_.end(); ++it) - (*it)->setReadOnly(on); -} - - void WorkAreaManager::updateTitles() { for (iterator it = work_areas_.begin(); it != work_areas_.end(); ++it) diff --git a/src/frontends/WorkAreaManager.h b/src/frontends/WorkAreaManager.h index 7b7e715fd1..dfef00e6f6 100644 --- a/src/frontends/WorkAreaManager.h +++ b/src/frontends/WorkAreaManager.h @@ -38,8 +38,6 @@ public: void redrawAll(bool update_metrics); /// void closeAll(); - /// This function is called when the buffer readonly status change. - void setReadOnly(bool); /// Update window titles of all users. void updateTitles(); diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 410f5e97dd..1af30982de 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -246,7 +246,7 @@ GuiWorkArea::GuiWorkArea(QWidget *) GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & gv) - : buffer_view_(0), lyx_view_(0), + : buffer_view_(0), read_only_(buffer.isReadonly()), lyx_view_(0), cursor_visible_(false), need_resize_(false), schedule_redraw_(false), preedit_lines_(1), completer_(new GuiCompleter(this, this)), @@ -440,6 +440,8 @@ void GuiWorkArea::redraw(bool update_metrics) if (lyxerr.debugging(Debug::WORKAREA)) buffer_view_->coordCache().dump(); + + setReadOnly(buffer_view_->buffer().isReadonly()); } @@ -1213,8 +1215,11 @@ void GuiWorkArea::updateWindowTitle() } -void GuiWorkArea::setReadOnly(bool) +void GuiWorkArea::setReadOnly(bool read_only) { + if (read_only_ == read_only) + return; + read_only_ = read_only; updateWindowTitle(); if (this == lyx_view_->currentWorkArea()) lyx_view_->updateDialogs(); diff --git a/src/frontends/qt4/GuiWorkArea.h b/src/frontends/qt4/GuiWorkArea.h index 8585b25aed..4ec0af11a9 100644 --- a/src/frontends/qt4/GuiWorkArea.h +++ b/src/frontends/qt4/GuiWorkArea.h @@ -184,7 +184,7 @@ private: /// hide the cursor virtual void removeCursor(); - /// This function is called when the buffer readonly status change. + /// This function should be called to update the buffer readonly status. void setReadOnly(bool); /// Update window titles of all users. @@ -231,6 +231,8 @@ private: /// BufferView * buffer_view_; + /// Read only Buffer status cache. + bool read_only_; /// GuiView * lyx_view_; /// is the cursor currently displayed