]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView_pimpl.C
fix some C++ parsing bugs
[lyx.git] / src / BufferView_pimpl.C
index e34057b8307002bf64e1948b5149e30a85d59d64..70c4e9e948639877b351a3491e3c5fb39eaa2a65 100644 (file)
@@ -111,7 +111,7 @@ BufferView::Pimpl::Pimpl(BufferView * bv, LyXView * owner,
        resizecon = workarea().workAreaResize
                .connect(boost::bind(&BufferView::Pimpl::workAreaResize, this));
        dispatchcon = workarea().dispatch
-               .connect(boost::bind(&BufferView::Pimpl::dispatch, this, _1));
+               .connect(boost::bind(&BufferView::Pimpl::workAreaDispatch, this, _1));
        kpresscon = workarea().workAreaKeyPress
                .connect(boost::bind(&BufferView::Pimpl::workAreaKeyPress, this, _1, _2));
        selectioncon = workarea().selectionRequested
@@ -380,7 +380,7 @@ void BufferView::Pimpl::scrollDocView(int value)
        else if (vbt->cursor.y() > last)
                vbt->setCursorFromCoordinates(0, last);
 
-       owner_->updateLayoutChoice();
+       owner_->updateLayoutChoice();
 }
 
 
@@ -914,6 +914,23 @@ void BufferView::Pimpl::trackChanges()
 }
 
 
+// Doesn't go through lyxfunc, so we need to update the
+// layout choice etc. ourselves
+bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & ev_in)
+{
+       // e.g. Qt mouse press when no buffer
+       if (!available())
+               return false;
+
+       bool const res = dispatch(ev_in);
+
+       bv_->owner()->updateLayoutChoice();
+       bv_->fitCursor();
+
+       return res;
+}
+
+
 bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
 {
        // Make sure that the cached BufferView is correct.
@@ -928,10 +945,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
                << " button[" << ev.button() << ']'
                << endl;
 
-       // e.g. Qt mouse press when no buffer
-       if (!buffer_)
-               return false;
-
        LyXTextClass const & tclass = buffer_->params.getLyXTextClass();
 
        switch (ev.action) {
@@ -1102,33 +1115,40 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
        case LFUN_INSET_APPLY: {
                string const name = ev.getArg(0);
 
-               InsetBase * base = owner_->getDialogs().getOpenInset(name);
-               if (base) {
+               InsetBase * inset = owner_->getDialogs().getOpenInset(name);
+               if (inset) {
                        // This works both for 'original' and 'mathed' insets.
                        // Note that the localDispatch performs updateInset
                        // also.
                        FuncRequest fr(bv_, LFUN_INSET_MODIFY, ev.argument);
-                       base->localDispatch(fr);
+                       inset->localDispatch(fr);
                } else {
-                       Inset * inset = createInset(ev);
-                       if (inset && insertInset(inset)) {
-                               updateInset(inset);
-                       } else {
-                               delete inset;
-                       }
+                       FuncRequest fr(bv_, LFUN_INSET_INSERT, ev.argument);
+                       dispatch(fr);
                }
+       }
+       break;
+
+       case LFUN_INSET_INSERT: {
+               Inset * inset = createInset(ev);
+               if (inset && insertInset(inset)) {
+                       updateInset(inset);
 
-               if (name == "bibitem") {
-                       // We need to do a redraw because the maximum
-                       // InsetBibitem width could have changed
+                       string const name = ev.getArg(0);
+                       if (name == "bibitem") {
+                               // We need to do a redraw because the maximum
+                               // InsetBibitem width could have changed
 #warning please check you mean repaint() not update(),
 #warning and whether the repaint() is needed at all
-                       bv_->repaint();
-                       bv_->fitCursor();
+                               bv_->repaint();
+                               bv_->fitCursor();
+                       }
+               } else {
+                       delete inset;
                }
        }
        break;
-
+       
        case LFUN_FLOAT_LIST:
                if (tclass.floats().typeExist(ev.argument)) {
                        Inset * inset = new InsetFloatList(ev.argument);
@@ -1192,7 +1212,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
                        }
                }
 
-               bv_->owner()->getDialogs().showThesaurus(arg);
+               bv_->owner()->getDialogs().show("thesaurus", arg);
        }
                break;