From fcdc4f8a6b5c82f106ade3bedee13ea1a03ec92d Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Tue, 13 Nov 2007 14:04:32 +0000 Subject: [PATCH] Some more cosmetics and removal of unused methods in GuiView. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21582 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXFunc.cpp | 14 +-- src/frontends/LyXView.h | 1 - src/frontends/qt4/GuiCommandBuffer.cpp | 12 +-- src/frontends/qt4/GuiCommandBuffer.h | 3 - src/frontends/qt4/GuiView.cpp | 26 +---- src/frontends/qt4/GuiView.h | 140 +++++++++++-------------- 6 files changed, 79 insertions(+), 117 deletions(-) diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 04b68a03dd..0c6aa466f2 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -951,7 +951,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) case LFUN_COMMAND_EXECUTE: BOOST_ASSERT(lyx_view_); - lyx_view_->showMiniBuffer(true); + lyx_view_->dispatch(cmd); break; case LFUN_CANCEL: @@ -1085,7 +1085,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) case LFUN_BUFFER_EXPORT: BOOST_ASSERT(lyx_view_ && lyx_view_->buffer()); if (argument == "custom") - lyx_view_->getDialogs().show("sendto"); + lyx_view_->showDialog("sendto"); else lyx_view_->buffer()->doExport(argument, false); break; @@ -1439,7 +1439,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) if (name == "character") { data = freefont2string(); if (!data.empty()) - lyx_view_->getDialogs().show("character", data); + lyx_view_->showDialogWithData("character", data); } else if (name == "latexlog") { Buffer::LogType type; string const logfile = lyx_view_->buffer()->logName(&type); @@ -1452,13 +1452,13 @@ void LyXFunc::dispatch(FuncRequest const & cmd) break; } data += Lexer::quoteString(logfile); - lyx_view_->getDialogs().show("log", data); + lyx_view_->showDialogWithData("log", data); } else if (name == "vclog") { string const data = "vc " + Lexer::quoteString(lyx_view_->buffer()->lyxvc().getLogFile()); - lyx_view_->getDialogs().show("log", data); + lyx_view_->showDialogWithData("log", data); } else - lyx_view_->getDialogs().show(name, data); + lyx_view_->showDialogWithData(name, data); break; } @@ -1570,7 +1570,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) } else if (name == "paragraph") { dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE)); } else if (name == "prefs") { - lyx_view_->getDialogs().update(name, string()); + lyx_view_->updateDialog(name, string()); } break; } diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index ac04535407..77aa49ed8c 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -100,7 +100,6 @@ public: /// virtual bool isToolbarVisible(std::string const & id) = 0; /// - virtual void showMiniBuffer(bool visible) = 0; virtual void openMenu(docstring const & name) = 0; /// get access to the dialogs diff --git a/src/frontends/qt4/GuiCommandBuffer.cpp b/src/frontends/qt4/GuiCommandBuffer.cpp index d77db6a90f..2a1ca377b4 100644 --- a/src/frontends/qt4/GuiCommandBuffer.cpp +++ b/src/frontends/qt4/GuiCommandBuffer.cpp @@ -12,10 +12,10 @@ #include -#include "GuiView.h" - #include "GuiCommandBuffer.h" + #include "GuiCommandEdit.h" +#include "GuiView.h" #include "qt_helpers.h" #include "BufferView.h" @@ -87,7 +87,7 @@ protected: GuiCommandBuffer::GuiCommandBuffer(GuiView * view) - : view_(view), lv_(*view), history_pos_(history_.end()) + : view_(view), history_pos_(history_.end()) { transform(lyxaction.func_begin(), lyxaction.func_end(), back_inserter(commands_), firster()); @@ -266,13 +266,13 @@ string const GuiCommandBuffer::historyDown() docstring const GuiCommandBuffer::getCurrentState() const { - return lv_.view()->cursor().currentState(); + return view_->view()->cursor().currentState(); } void GuiCommandBuffer::hide() const { - lv_.showMiniBuffer(false); + view_->showMiniBuffer(false); } @@ -324,7 +324,7 @@ void GuiCommandBuffer::dispatch(string const & str) history_pos_ = history_.end(); FuncRequest func = lyxaction.lookupFunc(str); func.origin = FuncRequest::COMMANDBUFFER; - lv_.dispatch(func); + view_->dispatch(func); } } // namespace frontend diff --git a/src/frontends/qt4/GuiCommandBuffer.h b/src/frontends/qt4/GuiCommandBuffer.h index b3a1004d4e..9f8ec74216 100644 --- a/src/frontends/qt4/GuiCommandBuffer.h +++ b/src/frontends/qt4/GuiCommandBuffer.h @@ -25,7 +25,6 @@ class QListWidgetItem; namespace lyx { namespace frontend { -class LyXView; class GuiView; class GuiCommandEdit; @@ -54,8 +53,6 @@ public Q_SLOTS: private: /// owning view GuiView * view_; - /// - LyXView & lv_; /// command widget GuiCommandEdit * edit_; diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 5dc221fe16..406c045f7c 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -684,12 +684,6 @@ void GuiView::updateStatusBar() } -void GuiView::activated(FuncRequest const & func) -{ - dispatch(func); -} - - bool GuiView::hasFocus() const { return qApp->activeWindow() == this; @@ -785,14 +779,6 @@ bool GuiView::focusNextPrevChild(bool /*next*/) } -void GuiView::showView() -{ - setWindowTitle(qt_("LyX")); - show(); - updateFloatingGeometry(); -} - - void GuiView::setBusy(bool yes) { if (d.current_work_area_) { @@ -900,12 +886,6 @@ void GuiView::addTabWorkArea() } -GuiWorkArea * GuiView::currentWorkArea() -{ - return d.current_work_area_; -} - - GuiWorkArea const * GuiView::currentWorkArea() const { return d.current_work_area_; @@ -1225,11 +1205,15 @@ void GuiView::resetAutosaveTimers() void GuiView::dispatch(FuncRequest const & cmd) { - string const argument = to_utf8(cmd.argument()); switch(cmd.action) { case LFUN_BUFFER_SWITCH: setBuffer(theBufferList().getBuffer(to_utf8(cmd.argument()))); break; + + case LFUN_COMMAND_EXECUTE: + showMiniBuffer(true); + break; + default: theLyXFunc().setLyXView(this); lyx::dispatch(cmd); diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index 45cedc88ac..9b29d12607 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -81,19 +81,9 @@ public: void updateToolbars(); ToolbarInfo * getToolbarInfo(std::string const & name); void toggleToolbarState(std::string const & name, bool allowauto); - - /// show - display the top-level window - void showView(); - - /// menu item has been selected - void activated(FuncRequest const &); - /// QMenu * createPopupMenu(); - /// - void addTabWorkArea(); - /// dispatch to current BufferView void dispatch(FuncRequest const & cmd); @@ -103,34 +93,45 @@ public: /// set a buffer to the current workarea. void setBuffer(Buffer * b); ///< \c Buffer to set. -Q_SIGNALS: - void closing(int); - -public Q_SLOTS: - /// idle timeout. - /// clear any temporary message and replace with current status. - void clearMessage(); + /// GuiBufferDelegate. + ///@{ + void resetAutosaveTimers(); + void errors(std::string const &); + void structureChanged() { updateToc(); } + ///@} + //// + void showDialog(std::string const & name); + void showDialogWithData(std::string const & name, + std::string const & data); + void showInsetDialog(std::string const & name, + std::string const & data, Inset * inset); + void updateDialog(std::string const & name, + std::string const & data); + + /// called on timeout + void autoSave(); /// - void updateWindowTitle(GuiWorkArea * wa); + void updateEmbeddedFiles(); - /// - void on_currentWorkAreaChanged(GuiWorkArea *); + /// \return the current buffer view. + BufferView * view(); - /// slots to change the icon size - void smallSizedIcons(); - void normalSizedIcons(); - void bigSizedIcons(); + /// get access to the dialogs + Dialogs & getDialogs() { return *dialogs_; } + /// + Dialogs const & getDialogs() const { return *dialogs_; } -private: - friend class GuiWorkArea; + /// load a buffer into the current workarea. + Buffer * loadLyXFile(support::FileName const & name, ///< File to load. + bool tolastfiles = true); ///< append to the "Open recent" menu? - /// make sure we quit cleanly - virtual void closeEvent(QCloseEvent * e); - /// - virtual void resizeEvent(QResizeEvent * e); + /** redraw \c inset in all the BufferViews in which it is currently + * visible. If successful return a pointer to the owning Buffer. + */ + Buffer const * updateInset(Inset const *); /// - virtual void moveEvent(QMoveEvent * e); + void restartCursor(); /// \return the \c Workarea associated to \p Buffer /// \retval 0 if no \c WorkArea is found. @@ -146,17 +147,30 @@ private: void removeWorkArea(GuiWorkArea * work_area); /// return the current WorkArea (the one that has the focus). GuiWorkArea const * currentWorkArea() const; - /// FIXME: This non-const access is needed because of - /// a mis-designed \c ControlSpellchecker. - GuiWorkArea * currentWorkArea(); - /// GuiBufferDelegate. - ///@{ - void resetAutosaveTimers(); - void errors(std::string const &); - void structureChanged() { updateToc(); } - ///@} +Q_SIGNALS: + void closing(int); +public Q_SLOTS: + /// idle timeout. + /// clear any temporary message and replace with current status. + void clearMessage(); + +private Q_SLOTS: + /// + void updateWindowTitle(GuiWorkArea * wa); + + /// + void on_currentWorkAreaChanged(GuiWorkArea *); + + /// slots to change the icon size + void smallSizedIcons(); + void normalSizedIcons(); + void bigSizedIcons(); + +private: + /// + void addTabWorkArea(); /// connect to signals in the given BufferView void connectBufferView(BufferView & bv); @@ -166,57 +180,27 @@ private: void connectBuffer(Buffer & buf); /// disconnect from signals in the given buffer void disconnectBuffer(); - - //// - void showDialog(std::string const & name); - void showDialogWithData(std::string const & name, - std::string const & data); - void showInsetDialog(std::string const & name, - std::string const & data, Inset * inset); - void updateDialog(std::string const & name, - std::string const & data); - /// void updateToc(); - /// void dragEnterEvent(QDragEnterEvent * ev); /// void dropEvent(QDropEvent * ev); + /// make sure we quit cleanly + virtual void closeEvent(QCloseEvent * e); + /// + virtual void resizeEvent(QResizeEvent * e); + /// + virtual void moveEvent(QMoveEvent * e); /// in order to catch Tab key press. bool event(QEvent * e); bool focusNextPrevChild(bool); /// QRect updateFloatingGeometry(); - /// called on timeout - void autoSave(); - /// - void updateEmbeddedFiles(); - - /// \return the current buffer view. - BufferView * view(); - - /// get access to the dialogs - Dialogs & getDialogs() { return *dialogs_; } - /// - Dialogs const & getDialogs() const { return *dialogs_; } - - //@} - - /// load a buffer into the current workarea. - Buffer * loadLyXFile(support::FileName const & name, ///< File to load. - bool tolastfiles = true); ///< append to the "Open recent" menu? - - /** redraw \c inset in all the BufferViews in which it is currently - * visible. If successful return a pointer to the owning Buffer. - */ - Buffer const * updateInset(Inset const *); /// - void restartCursor(); - + void setIconSize(unsigned int size); -private: /// struct GuiViewPrivate; GuiViewPrivate & d; @@ -230,8 +214,6 @@ private: /// QRect floatingGeometry_; - void setIconSize(unsigned int size); - struct ToolbarSize { int top_width; int bottom_width; -- 2.39.2