]> git.lyx.org Git - features.git/commitdiff
Move code from GuiApplication::dispatch() to GuiView::dispatch().
authorAbdelrazak Younes <younes@lyx.org>
Sat, 4 Dec 2010 22:48:08 +0000 (22:48 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sat, 4 Dec 2010 22:48:08 +0000 (22:48 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36726 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h

index 4656e63a69f5855ce8593e043a099075055a19ab..3976826b7b76cde4868fce533d3b6f2505578c4b 100644 (file)
@@ -1604,83 +1604,13 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                break;
 
        default:
-               // Everything below is only for active window
-               if (current_view_ == 0)
-                       break;
-       
-               // Let the current GuiView dispatch its own actions.
-               current_view_->dispatch(cmd, dr);
-
-               if (dr.dispatched())
-                       break;
-
-               BufferView * bv = current_view_->currentBufferView();
-               LASSERT(bv, /**/);
-       
-               // Avoid a screen redraw in the middle of a dispatch operation just
-               // because a warning or an error was displayed.
-               current_view_->setBusy(true);
-
-               // Let the current BufferView dispatch its own actions.
-               bv->dispatch(cmd, dr);
-               if (dr.dispatched())
-                       break;
-       
-               BufferView * doc_bv = current_view_->documentBufferView();
-               // Try with the document BufferView dispatch if any.
-               if (doc_bv) {
-                       doc_bv->dispatch(cmd, dr);
-                       if (dr.dispatched())
-                               break;
-               }
-       
-               // OK, so try the current Buffer itself...
-               bv->buffer().dispatch(cmd, dr);
-               if (dr.dispatched())
-                       break;
-       
-               // and with the document Buffer.
-               if (doc_bv) {
-                       doc_bv->buffer().dispatch(cmd, dr);
-                       if (dr.dispatched())
-                               break;
-               }
-       
-               // Let the current Cursor dispatch its own actions.
-               Cursor old = bv->cursor();
-               bv->cursor().dispatch(cmd);
-       
-               // notify insets we just left
-               // FIXME: move this code to Cursor::dispatch
-               if (bv->cursor() != old) {
-                       old.beginUndoGroup();
-                       old.fixIfBroken();
-                       bool badcursor = notifyCursorLeavesOrEnters(old, bv->cursor());
-                       if (badcursor) {
-                               bv->cursor().fixIfBroken();
-                               bv->fixInlineCompletionPos();
-                       }
-                       old.endUndoGroup();
-               }
-       
-               // update completion. We do it here and not in
-               // processKeySym to avoid another redraw just for a
-               // changed inline completion
-               if (cmd.origin() == FuncRequest::KEYBOARD) {
-                       if (cmd.action() == LFUN_SELF_INSERT
-                                       || (cmd.action() == LFUN_ERT_INSERT && bv->cursor().inMathed()))
-                               current_view_->updateCompletion(bv->cursor(), true, true);
-                       else if (cmd.action() == LFUN_CHAR_DELETE_BACKWARD)
-                               current_view_->updateCompletion(bv->cursor(), false, true);
-                       else
-                               current_view_->updateCompletion(bv->cursor(), false, false);
-               }
-       
-               dr = bv->cursor().result();
-
-               current_view_->setBusy(false);
+               // The LFUN must be for one of GuiView, BufferView, Buffer or Cursor;
+               // let's try that:
+               if (current_view_)
+                       current_view_->dispatch(cmd, dr);
+               break;
        }
-       
+
        // if we executed a mutating lfun, mark the buffer as dirty
        Buffer * doc_buffer = (current_view_ && current_view_->documentBufferView())
                      ? &(current_view_->documentBufferView()->buffer()) : 0;
index a0f4824867ea69b346becf8ef374f8d7e1b187de..55c94f71d26133057331f0575f5e258dc1f4ee32 100644 (file)
@@ -3019,6 +3019,69 @@ bool GuiView::GuiViewPrivate::asyncBufferProcessing(
 #endif
 }
 
+void GuiView::dispatchToBufferView(FuncRequest const & cmd, DispatchResult & dr)
+{
+       BufferView * bv = currentBufferView();
+       LASSERT(bv, /**/);
+
+       // Avoid a screen redraw in the middle of a dispatch operation just
+       // because a warning or an error was displayed.
+       setBusy(true);
+
+       // Let the current BufferView dispatch its own actions.
+       bv->dispatch(cmd, dr);
+
+       // Try with the document BufferView dispatch if any.
+       BufferView * doc_bv = documentBufferView();
+       if (doc_bv && !dr.dispatched())
+                       doc_bv->dispatch(cmd, dr);
+
+       // OK, so try the current Buffer itself...
+       if (!dr.dispatched())
+               bv->buffer().dispatch(cmd, dr);
+
+       // and with the document Buffer.
+       if (doc_bv && !dr.dispatched())
+               doc_bv->buffer().dispatch(cmd, dr);
+
+       // Then let the current Cursor dispatch its own actions.
+       if (!dr.dispatched()) {
+               Cursor old = bv->cursor();
+               bv->cursor().dispatch(cmd);
+
+               // notify insets we just left
+               // FIXME: move this code to Cursor::dispatch
+               if (bv->cursor() != old) {
+                       old.beginUndoGroup();
+                       old.fixIfBroken();
+                       bool badcursor = notifyCursorLeavesOrEnters(old, bv->cursor());
+                       if (badcursor) {
+                               bv->cursor().fixIfBroken();
+                               bv->fixInlineCompletionPos();
+                       }
+                       old.endUndoGroup();
+               }
+
+               // update completion. We do it here and not in
+               // processKeySym to avoid another redraw just for a
+               // changed inline completion
+               if (cmd.origin() == FuncRequest::KEYBOARD) {
+                       if (cmd.action() == LFUN_SELF_INSERT
+                               || (cmd.action() == LFUN_ERT_INSERT && bv->cursor().inMathed()))
+                               updateCompletion(bv->cursor(), true, true);
+                       else if (cmd.action() == LFUN_CHAR_DELETE_BACKWARD)
+                               updateCompletion(bv->cursor(), false, true);
+                       else
+                               updateCompletion(bv->cursor(), false, false);
+               }
+
+               dr = bv->cursor().result();
+       }
+
+       setBusy(false);
+}
+
+
 void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 {
        BufferView * bv = currentBufferView();
@@ -3477,7 +3540,9 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        break;
                }
                default:
-                       dr.dispatched(false);
+                       // The LFUN must be for one of BufferView, Buffer or Cursor;
+                       // let's try that:
+                       dispatchToBufferView(cmd, dr);
                        break;
        }
 
@@ -3488,8 +3553,6 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                if (statusBar()->isVisible())
                        statusBar()->hide();
        }
-
-       return;
 }
 
 
index 52926ece4308e4b0fcf9df823a64630cc6646247..a7fd79e8ca66120026c71b5da3aff8a7a6afc9a3 100644 (file)
@@ -413,6 +413,8 @@ private:
        ///
        void dispatchVC(FuncRequest const & cmd, DispatchResult & dr);
        ///
+       void dispatchToBufferView(FuncRequest const & cmd, DispatchResult & dr);
+       ///
        void showMessage();
 
        /// This view ID.