]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiView.cpp
no need to cast anymore
[lyx.git] / src / frontends / qt4 / GuiView.cpp
index 950631194fa08da8fcb9a5acd5dc7ee303a5ad9f..bdd32b86fc4e642d517148b9721549eeb8f36977 100644 (file)
@@ -162,8 +162,8 @@ struct GuiView::GuiViewPrivate
        ~GuiViewPrivate()
        {
                delete splitter_;
-               delete stack_widget_;
                delete bg_widget_;
+               delete stack_widget_;
                delete menubar_;
                delete toolbars_;
        }
@@ -705,15 +705,14 @@ GuiWorkArea const * GuiView::currentWorkArea() const
 }
 
 
-void GuiView::setCurrentWorkArea(GuiWorkArea * work_area)
+void GuiView::setCurrentWorkArea(GuiWorkArea * wa)
 {
-       BOOST_ASSERT(work_area);
+       BOOST_ASSERT(wa);
 
        // Changing work area can result from opening a file so
        // update the toc in any case.
        updateToc();
 
-       GuiWorkArea * wa = static_cast<GuiWorkArea *>(work_area);
        d.current_work_area_ = wa;
        for (int i = 0; i != d.splitter_->count(); ++i) {
                if (d.tabWorkArea(i)->setCurrentWorkArea(wa))
@@ -722,11 +721,10 @@ void GuiView::setCurrentWorkArea(GuiWorkArea * work_area)
 }
 
 
-void GuiView::removeWorkArea(GuiWorkArea * work_area)
+void GuiView::removeWorkArea(GuiWorkArea * wa)
 {
-       BOOST_ASSERT(work_area);
-       GuiWorkArea * gwa = static_cast<GuiWorkArea *>(work_area);
-       if (gwa == d.current_work_area_) {
+       BOOST_ASSERT(wa);
+       if (wa == d.current_work_area_) {
                disconnectBuffer();
                disconnectBufferView();
                hideBufferDependent();
@@ -739,7 +737,7 @@ void GuiView::removeWorkArea(GuiWorkArea * work_area)
 
        for (int i = 0; i != d.splitter_->count(); ++i) {
                TabWorkArea * twa = d.tabWorkArea(i);
-               if (!twa->removeWorkArea(gwa))
+               if (!twa->removeWorkArea(wa))
                        // Not found in this tab group.
                        continue;
 
@@ -962,7 +960,7 @@ FuncStatus GuiView::getStatus(FuncRequest const & cmd)
                        }
                }
                else if (name == "latexlog")
-                       enable = FileName(buf->logName()).isFileReadable();
+                       enable = FileName(buf->logName()).isReadableFile();
                else if (name == "spellchecker")
 #if defined (USE_ASPELL) || defined (USE_ISPELL) || defined (USE_PSPELL)
                        enable = !buf->isReadonly();
@@ -1018,16 +1016,26 @@ FuncStatus GuiView::getStatus(FuncRequest const & cmd)
 }
 
 
-void GuiView::dispatch(FuncRequest const & cmd)
+bool GuiView::dispatch(FuncRequest const & cmd)
 {
-       // By default we won't need any new update.
-       Update::flags update_flags = Update::None;
+       BufferView * bv = view();       
+       // By default we won't need any update.
+       if (bv)
+               bv->cursor().updateFlags(Update::None);
 
        switch(cmd.action) {
                case LFUN_BUFFER_SWITCH:
                        setBuffer(theBufferList().getBuffer(to_utf8(cmd.argument())));
                        break;
 
+               case LFUN_BUFFER_NEXT:
+                       setBuffer(theBufferList().next(buffer()));
+                       break;
+
+               case LFUN_BUFFER_PREVIOUS:
+                       setBuffer(theBufferList().previous(buffer()));
+                       break;
+
                case LFUN_COMMAND_EXECUTE: {
                        bool const show_it = cmd.argument() != "off";
                        d.toolbars_->showCommandBuffer(show_it);
@@ -1143,9 +1151,6 @@ void GuiView::dispatch(FuncRequest const & cmd)
                        if (inset) {
                                FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
                                inset->dispatch(view()->cursor(), fr);
-                               // ideally, the update flag should be set by the insets,
-                               // but this is not possible currently
-                               update_flags = Update::Force | Update::FitCursor;
                        } else {
                                FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
                                lyx::dispatch(fr);
@@ -1154,12 +1159,10 @@ void GuiView::dispatch(FuncRequest const & cmd)
                }
 
                default:
-                       theLyXFunc().setLyXView(this);
-                       lyx::dispatch(cmd);
+                       return false;
        }
 
-       if (view())
-               view()->cursor().updateFlags(update_flags);
+       return true;
 }
 
 
@@ -1367,7 +1370,7 @@ void GuiView::updateBufferDependent(bool switched) const
                        // A bit clunky, but the dialog will request
                        // that the kernel provides it with the necessary
                        // data.
-                       dialog->updateDialog(dialog->name());
+                       dialog->updateDialog();
                }
        }
 }