]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiWorkArea.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiWorkArea.cpp
index fce8cf87e35ff8ac28d26a03825ee9d135b8c402..dde2d710cae292ed2cb0cdf1aa14b75d2f8dc220 100644 (file)
@@ -239,17 +239,17 @@ GuiWorkArea::GuiWorkArea(QWidget *)
        : buffer_view_(0), lyx_view_(0),
        cursor_visible_(false),
        need_resize_(false), schedule_redraw_(false),
-       preedit_lines_(1), completer_(new GuiCompleter(this)),
+       preedit_lines_(1), completer_(new GuiCompleter(this, this)),
        context_target_pos_()
 {
 }
 
 
 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)),
+       preedit_lines_(1), completer_(new GuiCompleter(this, this)),
        context_target_pos_()
 {
        setGuiView(gv);
@@ -321,6 +321,7 @@ GuiWorkArea::~GuiWorkArea()
        delete buffer_view_;
        delete cursor_;
        // Completer has a QObject parent and is thus automatically destroyed.
+       // See #4758.
        // delete completer_;
 }
 
@@ -439,6 +440,8 @@ void GuiWorkArea::redraw(bool update_metrics)
 
        if (lyxerr.debugging(Debug::WORKAREA))
                buffer_view_->coordCache().dump();
+
+       setReadOnly(buffer_view_->buffer().isReadonly());
 }
 
 
@@ -463,7 +466,8 @@ void GuiWorkArea::dispatch(FuncRequest const & cmd0, KeyModifier mod)
 {
        // Handle drag&drop
        if (cmd0.action == LFUN_FILE_OPEN) {
-               lyx_view_->dispatch(cmd0);
+               DispatchResult dr;
+               lyx_view_->dispatch(cmd0, dr);
                return;
        }
 
@@ -697,14 +701,7 @@ void GuiWorkArea::contextMenuEvent(QContextMenuEvent * e)
 
 void GuiWorkArea::focusInEvent(QFocusEvent * e)
 {
-       /*
-       LYXERR(Debug::DEBUG, "GuiWorkArea::focusInEvent(): " << this << std::endl);
-       GuiWorkArea * old_gwa = theGuiApp()->currentView()->currentWorkArea();
-       if (old_gwa)
-               old_gwa->stopBlinkingCursor();
-       lyx_view_->setCurrentWorkArea(this);
-       */
-
+       LYXERR(Debug::DEBUG, "GuiWorkArea::focusInEvent(): " << this << endl);
        if (lyx_view_->currentWorkArea() != this)
                lyx_view_->setCurrentWorkArea(this);
 
@@ -715,7 +712,7 @@ void GuiWorkArea::focusInEvent(QFocusEvent * e)
 
 void GuiWorkArea::focusOutEvent(QFocusEvent * e)
 {
-       LYXERR(Debug::DEBUG, "GuiWorkArea::focusOutEvent(): " << this << std::endl);
+       LYXERR(Debug::DEBUG, "GuiWorkArea::focusOutEvent(): " << this << endl);
        stopBlinkingCursor();
        QAbstractScrollArea::focusOutEvent(e);
 }
@@ -1219,8 +1216,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();
@@ -1512,7 +1512,7 @@ void TabWorkArea::on_currentTabChanged(int i)
        currentWorkAreaChanged(wa);
 
        LYXERR(Debug::GUI, "currentTabChanged " << i
-               << "File" << wa->bufferView().buffer().absFileName());
+               << " File: " << wa->bufferView().buffer().absFileName());
 }