From 212386be8a1573fb52b5da718961835816a3c8e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Mon, 3 Sep 2007 05:59:32 +0000 Subject: [PATCH] merge ButtonController and its view (Qt2BC in this case) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20018 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/Dialogs.cpp | 2 +- src/frontends/Dialogs.h | 2 +- src/frontends/controllers/BCView.cpp | 24 ---- src/frontends/controllers/BCView.h | 54 -------- .../controllers/ButtonController.cpp | 114 ----------------- src/frontends/controllers/ButtonController.h | 95 -------------- .../controllers/ControlCharacter.cpp | 3 +- .../controllers/ControlParagraph.cpp | 3 +- src/frontends/controllers/ControlPrint.cpp | 3 +- src/frontends/controllers/ControlVSpace.cpp | 3 +- src/frontends/controllers/Dialog.cpp | 87 ++----------- src/frontends/controllers/Dialog.h | 33 +++-- src/frontends/controllers/Makefile.am | 4 +- src/frontends/controllers/frontend_helpers.h | 40 +----- .../qt4/{Qt2BC.cpp => ButtonController.cpp} | 107 ++++++++++++---- .../qt4/{Qt2BC.h => ButtonController.h} | 85 +++++++++--- src/frontends/qt4/Dialogs.cpp | 7 +- src/frontends/qt4/GuiAbout.cpp | 11 +- src/frontends/qt4/GuiAbout.h | 2 +- src/frontends/qt4/GuiBibitem.cpp | 11 +- src/frontends/qt4/GuiBibitem.h | 2 +- src/frontends/qt4/GuiBibtex.cpp | 38 +++--- src/frontends/qt4/GuiBibtex.h | 2 +- src/frontends/qt4/GuiBox.cpp | 35 +++-- src/frontends/qt4/GuiBox.h | 2 +- src/frontends/qt4/GuiBranch.cpp | 7 +- src/frontends/qt4/GuiBranch.h | 2 +- src/frontends/qt4/GuiChanges.cpp | 9 +- src/frontends/qt4/GuiChanges.h | 2 +- src/frontends/qt4/GuiCharacter.cpp | 27 ++-- src/frontends/qt4/GuiCharacter.h | 2 +- src/frontends/qt4/GuiCitation.cpp | 2 +- src/frontends/qt4/GuiCitation.h | 4 +- src/frontends/qt4/GuiDelimiter.cpp | 2 +- src/frontends/qt4/GuiDelimiter.h | 2 +- src/frontends/qt4/GuiDialog.cpp | 121 ++++++++++++++++++ src/frontends/qt4/GuiDialog.h | 71 ++++++++++ src/frontends/qt4/GuiDialogView.cpp | 26 ++-- src/frontends/qt4/GuiDialogView.h | 15 ++- src/frontends/qt4/GuiDocument.cpp | 47 ++++--- src/frontends/qt4/GuiDocument.h | 2 +- src/frontends/qt4/GuiERT.cpp | 8 +- src/frontends/qt4/GuiERT.h | 3 +- src/frontends/qt4/GuiEmbeddedFiles.cpp | 2 - src/frontends/qt4/GuiErrorList.cpp | 5 +- src/frontends/qt4/GuiErrorList.h | 2 +- src/frontends/qt4/GuiExternal.cpp | 79 ++++++------ src/frontends/qt4/GuiExternal.h | 2 +- src/frontends/qt4/GuiFloat.cpp | 13 +- src/frontends/qt4/GuiFloat.h | 2 +- src/frontends/qt4/GuiGraphics.cpp | 91 +++++++------ src/frontends/qt4/GuiGraphics.h | 2 +- src/frontends/qt4/GuiInclude.cpp | 19 ++- src/frontends/qt4/GuiInclude.h | 2 +- src/frontends/qt4/GuiIndex.cpp | 17 ++- src/frontends/qt4/GuiIndex.h | 2 +- src/frontends/qt4/GuiListings.cpp | 9 +- src/frontends/qt4/GuiListings.h | 2 +- src/frontends/qt4/GuiLog.cpp | 2 +- src/frontends/qt4/GuiLog.h | 2 +- src/frontends/qt4/GuiMathMatrix.cpp | 2 +- src/frontends/qt4/GuiMathMatrix.h | 2 +- src/frontends/qt4/GuiNomencl.cpp | 20 ++- src/frontends/qt4/GuiNomencl.h | 5 +- src/frontends/qt4/GuiNote.cpp | 7 +- src/frontends/qt4/GuiNote.h | 2 +- src/frontends/qt4/GuiParagraph.cpp | 15 +-- src/frontends/qt4/GuiParagraph.h | 2 +- src/frontends/qt4/GuiPrefs.cpp | 25 +++- src/frontends/qt4/GuiPrefs.h | 2 +- src/frontends/qt4/GuiPrint.cpp | 9 +- src/frontends/qt4/GuiPrint.h | 2 +- src/frontends/qt4/GuiRef.cpp | 25 ++-- src/frontends/qt4/GuiRef.h | 2 +- src/frontends/qt4/GuiSearch.cpp | 11 +- src/frontends/qt4/GuiSearch.h | 2 +- src/frontends/qt4/GuiSendto.cpp | 9 +- src/frontends/qt4/GuiSendto.h | 2 +- src/frontends/qt4/GuiShowFile.cpp | 5 +- src/frontends/qt4/GuiShowFile.h | 2 +- src/frontends/qt4/GuiSpellchecker.cpp | 5 +- src/frontends/qt4/GuiSpellchecker.h | 2 +- src/frontends/qt4/GuiTabular.cpp | 103 +++++++-------- src/frontends/qt4/GuiTabular.h | 2 +- src/frontends/qt4/GuiTabularCreate.cpp | 7 +- src/frontends/qt4/GuiTabularCreate.h | 2 +- src/frontends/qt4/GuiTexinfo.cpp | 5 +- src/frontends/qt4/GuiTexinfo.h | 2 +- src/frontends/qt4/GuiThesaurus.cpp | 11 +- src/frontends/qt4/GuiThesaurus.h | 2 +- src/frontends/qt4/GuiToc.cpp | 3 +- src/frontends/qt4/GuiURL.cpp | 16 +-- src/frontends/qt4/GuiURL.h | 2 +- src/frontends/qt4/GuiVSpace.cpp | 23 ++-- src/frontends/qt4/GuiVSpace.h | 2 +- src/frontends/qt4/GuiViewSource.cpp | 2 +- src/frontends/qt4/GuiViewSource.h | 3 +- src/frontends/qt4/GuiWrap.cpp | 17 ++- src/frontends/qt4/GuiWrap.h | 2 +- src/frontends/qt4/Makefile.am | 6 +- 100 files changed, 812 insertions(+), 930 deletions(-) delete mode 100644 src/frontends/controllers/BCView.cpp delete mode 100644 src/frontends/controllers/BCView.h delete mode 100644 src/frontends/controllers/ButtonController.cpp delete mode 100644 src/frontends/controllers/ButtonController.h rename src/frontends/qt4/{Qt2BC.cpp => ButtonController.cpp} (59%) rename src/frontends/qt4/{Qt2BC.h => ButtonController.h} (56%) create mode 100644 src/frontends/qt4/GuiDialog.cpp create mode 100644 src/frontends/qt4/GuiDialog.h diff --git a/src/frontends/Dialogs.cpp b/src/frontends/Dialogs.cpp index 92d4fdd2ad..610c20fb8c 100644 --- a/src/frontends/Dialogs.cpp +++ b/src/frontends/Dialogs.cpp @@ -44,7 +44,7 @@ Dialog * Dialogs::find_or_build(string const & name) if (it != dialogs_.end()) return it->second.get(); - dialogs_[name] = build(name); + dialogs_[name].reset(build(name)); return dialogs_[name].get(); } diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index 3286c525d5..335bd3f31d 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -104,7 +104,7 @@ private: /// typedef boost::shared_ptr DialogPtr; /// - DialogPtr build(std::string const & name); + Dialog * build(std::string const & name); /// LyXView & lyxview_; diff --git a/src/frontends/controllers/BCView.cpp b/src/frontends/controllers/BCView.cpp deleted file mode 100644 index a04dfad06a..0000000000 --- a/src/frontends/controllers/BCView.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/** - * \file BCView.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Angus Leeming - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "BCView.h" -#include "ButtonController.h" - -namespace lyx { -namespace frontend { - -ButtonPolicy const & BCView::bp() const { return parent.policy(); } -ButtonPolicy & BCView::bp() { return parent.policy(); } - - -} // namespace frontend -} // namespace lyx diff --git a/src/frontends/controllers/BCView.h b/src/frontends/controllers/BCView.h deleted file mode 100644 index e7136ef4bc..0000000000 --- a/src/frontends/controllers/BCView.h +++ /dev/null @@ -1,54 +0,0 @@ -// -*- C++ -*- -/** - * \file BCView.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Allan Rae - * \author Angus Leeming - * \author Baruch Even - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef BCVIEW_H -#define BCVIEW_H - -namespace lyx { -namespace frontend { - -class ButtonController; -class ButtonPolicy; - - -/** \c BCView is the View to ButtonController's Controller. It - * stores the individual GUI widgets and sets their activation state - * upon receipt of instructions from the controller. - * - * It is a base class. The true, GUI, instantiations derive from it. - */ -class BCView -{ -public: - BCView(ButtonController & p) : parent(p) {} - virtual ~BCView() {} - - //@{ - /// Refresh the status of the Ok, Apply, Restore, Cancel buttons. - virtual void refresh() const = 0; - /// Refresh the status of any widgets in the read_only list - virtual void refreshReadOnly() const = 0; - //@} - - /// A shortcut to the BP of the BC. - ButtonPolicy const & bp() const; - ButtonPolicy & bp(); - - ButtonController & parent; -}; - - -} // namespace frontend -} // namespace lyx - -#endif // BCVIEW_H diff --git a/src/frontends/controllers/ButtonController.cpp b/src/frontends/controllers/ButtonController.cpp deleted file mode 100644 index 90f7889717..0000000000 --- a/src/frontends/controllers/ButtonController.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/** - * \file ButtonController.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Allan Rae - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "ButtonController.h" -#include "BCView.h" -#include "debug.h" - -namespace lyx { -namespace frontend { - -BCView & ButtonController::view() const -{ - BOOST_ASSERT(view_.get()); - return *view_.get(); -} - -void ButtonController::view(BCView * view) -{ - view_.reset(view); -} - - -void ButtonController::setPolicy(ButtonPolicy::Policy policy) -{ - policy_ = ButtonPolicy(policy); -} - - -void ButtonController::refresh() const -{ - view().refresh(); -} - - -void ButtonController::refreshReadOnly() const -{ - view().refreshReadOnly(); -} - - -void ButtonController::ok() -{ - input(ButtonPolicy::SMI_OKAY); -} - - -void ButtonController::input(ButtonPolicy::SMInput in) -{ - if (ButtonPolicy::SMI_NOOP == in) - return; - policy_.input(in); - view().refresh(); -} - - -void ButtonController::apply() -{ - input(ButtonPolicy::SMI_APPLY); -} - - -void ButtonController::cancel() -{ - input(ButtonPolicy::SMI_CANCEL); -} - - -void ButtonController::restore() -{ - input(ButtonPolicy::SMI_RESTORE); -} - - -void ButtonController::hide() -{ - input(ButtonPolicy::SMI_HIDE); -} - - -void ButtonController::valid(bool v) -{ - if (v) { - input(ButtonPolicy::SMI_VALID); - } else { - input(ButtonPolicy::SMI_INVALID); - } -} - - -bool ButtonController::readOnly(bool ro) -{ - LYXERR(Debug::GUI) << "Setting controller ro: " << ro << std::endl; - - if (ro) { - policy_.input(ButtonPolicy::SMI_READ_ONLY); - } else { - policy_.input(ButtonPolicy::SMI_READ_WRITE); - } - view().refreshReadOnly(); - view().refresh(); - return ro; -} - -} // namespace frontend -} // namespace lyx diff --git a/src/frontends/controllers/ButtonController.h b/src/frontends/controllers/ButtonController.h deleted file mode 100644 index 3ca665a8d2..0000000000 --- a/src/frontends/controllers/ButtonController.h +++ /dev/null @@ -1,95 +0,0 @@ -// -*- C++ -*- -/** - * \file ButtonController.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Allan Rae - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef BUTTONCONTROLLER_H -#define BUTTONCONTROLLER_H - -#include "ButtonPolicy.h" -#include "BCView.h" - -#include -#include - -namespace lyx { -namespace frontend { - -/** \c ButtonController controls the activation of the OK, Apply and - * Cancel buttons. - * - * It actually supports 4 buttons in all and it's up to the user to decide on - * the activation policy and which buttons correspond to which output of the - * state machine. - */ - -class ButtonController : boost::noncopyable { -public: - ButtonController() : policy_(ButtonPolicy::IgnorantPolicy) {} - //@{ - /** Methods to set and get the GUI view (containing the actual - * button widgets. - * \param ptr is owned by the ButtonController. - */ - void view(BCView * ptr); - BCView & view() const; - //@} - - //@{ - /** Methods to set and get the ButtonPolicy. - * \param ptr is owned by the ButtonController. - */ - void setPolicy(ButtonPolicy::Policy policy); - ButtonPolicy const & policy() const { return policy_; } - ButtonPolicy & policy() { return policy_; } - //@} - - /// - void input(ButtonPolicy::SMInput); - - //@{ - /// Tell the BC that a particular button has been pressed. - void ok(); - void apply(); - void cancel(); - void restore(); - //@} - - /// Tell the BC that the dialog is being hidden - void hide(); - - /**Refresh the activation state of the Ok, Apply, Close and - * Restore buttons. - */ - void refresh() const; - - /** Refresh the activation state of all the widgets under the control - * of the BC to reflect the read-only status of the underlying buffer. - */ - void refreshReadOnly() const; - - /** Passthrough function -- returns its input value - * Tell the BC about the read-only status of the underlying buffer. - */ - bool readOnly(bool = true); - - /** \param validity Tell the BC that the data is, or is not, valid. - * Sets the activation state of the buttons immediately. - */ - void valid(bool = true); - -private: - ButtonPolicy policy_; - boost::scoped_ptr view_; -}; - -} // namespace frontend -} // namespace lyx - -#endif // BUTTONCONTROLLER_H diff --git a/src/frontends/controllers/ControlCharacter.cpp b/src/frontends/controllers/ControlCharacter.cpp index b06c95ef58..fe9444be39 100644 --- a/src/frontends/controllers/ControlCharacter.cpp +++ b/src/frontends/controllers/ControlCharacter.cpp @@ -11,7 +11,6 @@ #include #include "ControlCharacter.h" -#include "ButtonController.h" #include "Buffer.h" #include "BufferParams.h" @@ -46,7 +45,7 @@ bool ControlCharacter::initialiseParams(string const &) getBar() != IGNORE || getColor() != Color::ignore || font_->language() != ignore_language) - dialog().bc().valid(); + dialog().setButtonsValid(true); return true; } diff --git a/src/frontends/controllers/ControlParagraph.cpp b/src/frontends/controllers/ControlParagraph.cpp index f30762e697..b2e262d0e9 100644 --- a/src/frontends/controllers/ControlParagraph.cpp +++ b/src/frontends/controllers/ControlParagraph.cpp @@ -15,7 +15,6 @@ #include "Buffer.h" #include "BufferParams.h" #include "BufferView.h" -#include "ButtonController.h" #include "Cursor.h" #include "FuncRequest.h" #include "Lexer.h" @@ -117,7 +116,7 @@ bool ControlParagraph::initialiseParams(string const & data) // If "update", then set the activation status of the button controller if (action > 0) { bool const accept = action == 1; - dialog().bc().valid(accept); + dialog().setButtonsValid(accept); } return true; } diff --git a/src/frontends/controllers/ControlPrint.cpp b/src/frontends/controllers/ControlPrint.cpp index bcb0df017b..21236906ee 100644 --- a/src/frontends/controllers/ControlPrint.cpp +++ b/src/frontends/controllers/ControlPrint.cpp @@ -12,7 +12,6 @@ #include "ControlPrint.h" -#include "ButtonController.h" #include "frontend_helpers.h" #include "Buffer.h" @@ -49,7 +48,7 @@ bool ControlPrint::initialiseParams(std::string const &) params_.reset(new PrinterParams(PrinterParams::PRINTER, lyxrc.printer, name)); - dialog().bc().valid(); // so that the user can press Ok + dialog().setButtonsValid(true); // so that the user can press Ok return true; } diff --git a/src/frontends/controllers/ControlVSpace.cpp b/src/frontends/controllers/ControlVSpace.cpp index 1a43d1af07..e642fedd05 100644 --- a/src/frontends/controllers/ControlVSpace.cpp +++ b/src/frontends/controllers/ControlVSpace.cpp @@ -12,7 +12,6 @@ #include #include "ControlVSpace.h" -#include "ButtonController.h" #include "FuncRequest.h" #include "insets/InsetVSpace.h" @@ -34,7 +33,7 @@ bool ControlVSpace::initialiseParams(string const & data) InsetVSpaceMailer::string2params(data, params_); // so that the user can press Ok - dialog().bc().valid(); + dialog().setButtonsValid(true); return true; } diff --git a/src/frontends/controllers/Dialog.cpp b/src/frontends/controllers/Dialog.cpp index 1c8cd2e97a..aae5975acd 100644 --- a/src/frontends/controllers/Dialog.cpp +++ b/src/frontends/controllers/Dialog.cpp @@ -12,9 +12,6 @@ #include "Dialog.h" -#include "ButtonController.h" -#include "BCView.h" - #include "frontends/LyXView.h" #include "debug.h" @@ -29,43 +26,16 @@ namespace lyx { namespace frontend { Dialog::Dialog(LyXView & lv, string const & name) - : is_closing_(false), kernel_(lv), name_(name), - bc_ptr_(new ButtonController) + : is_closing_(false), kernel_(lv), name_(name) {} -void Dialog::ApplyButton() -{ - apply(); - bc().apply(); -} - - -void Dialog::OKButton() -{ - is_closing_ = true; - apply(); - is_closing_ = false; - hide(); - bc().ok(); -} - - -void Dialog::CancelButton() -{ - hide(); - bc().cancel(); -} +Dialog::~Dialog() +{} -void Dialog::RestoreButton() -{ - // Tell the kernel that a request to refresh the dialog's contents - // has been received. It's up to the kernel to supply the necessary - // info by calling Dialog::update(). - kernel().updateDialog(name_); - bc().restore(); -} +void Dialog::setButtonsValid(bool valid) +{} void Dialog::show(string const & data) @@ -80,11 +50,9 @@ void Dialog::show(string const & data) return; } - bc().readOnly(kernel().isBufferReadonly()); + preShow(); view().show(); - - // The widgets may not be valid, so refresh the button controller - bc().refresh(); + postShow(); } @@ -99,11 +67,14 @@ void Dialog::update(string const & data) return; } - bc().readOnly(kernel().isBufferReadonly()); + preUpdate(); view().update(); + postUpdate(); +} - // The widgets may not be valid, so refresh the button controller - bc().refresh(); + +void Dialog::checkStatus() +{ } @@ -150,13 +121,6 @@ void Dialog::redraw() } -ButtonController & Dialog::bc() const -{ - BOOST_ASSERT(bc_ptr_.get()); - return *bc_ptr_.get(); -} - - void Dialog::setController(Controller * i) { BOOST_ASSERT(i && !controller_ptr_.get()); @@ -171,31 +135,6 @@ void Dialog::setView(View * v) } -void Dialog::checkStatus() -{ - // buffer independant dialogs are always active. - // This check allows us leave canApply unimplemented for some dialogs. - if (!controller().isBufferDependent()) - return; - - // deactivate the dialog if we have no buffer - if (!kernel().isBufferAvailable()) { - bc().readOnly(true); - return; - } - - // check whether this dialog may be active - if (controller().canApply()) { - bool const readonly = kernel().isBufferReadonly(); - bc().readOnly(readonly); - // refreshReadOnly() is too generous in _enabling_ widgets - // update dialog to disable disabled widgets again - if (!readonly || controller().canApplyToReadOnly()) - view().update(); - } else - bc().readOnly(true); -} - Dialog::Controller::Controller(Dialog & parent) : parent_(parent) diff --git a/src/frontends/controllers/Dialog.h b/src/frontends/controllers/Dialog.h index 8cf351de40..89d93a0f7c 100644 --- a/src/frontends/controllers/Dialog.h +++ b/src/frontends/controllers/Dialog.h @@ -23,7 +23,6 @@ namespace lyx { namespace frontend { -class ButtonController; class LyXView; /** \c Dialog collects the different parts of a Model-Controller-View @@ -35,23 +34,13 @@ public: /// \param name is the identifier given to the dialog by its parent /// container. Dialog(LyXView & lv, std::string const & name); + virtual ~Dialog(); /** The Dialog's name is the means by which a dialog identifies * itself to the kernel. */ std::string const & name() const { return name_; } - /** \name Buttons - * These methods are publicly accessible because they are invoked - * by the View when the user presses... guess what ;-) - */ - //@{ - void ApplyButton(); - void OKButton(); - void CancelButton(); - void RestoreButton(); - //@} - /** \name Container Access * These methods are publicly accessible because they are invoked * by the parent container acting on commands from the LyX kernel. @@ -65,6 +54,17 @@ public: void hide(); bool isVisible() const; + // Override in GuiDialog + virtual void preShow() {} + virtual void postShow() {} + virtual void preUpdate() {} + virtual void postUpdate() {} + + virtual void OkButton() {} + virtual void ApplyButton() {} + virtual void CancelButton() {} + virtual void RestoreButton() {} + /** This function is called, for example, if the GUI colours * have been changed. */ @@ -112,17 +112,17 @@ public: */ //@{ Controller & controller() const; - ButtonController & bc() const; View & view() const; //@} -private: + + virtual void setButtonsValid(bool valid); +protected: void apply(); bool is_closing_; Kernel kernel_; std::string name_; - boost::scoped_ptr bc_ptr_; boost::scoped_ptr controller_ptr_; boost::scoped_ptr view_ptr_; }; @@ -286,9 +286,6 @@ protected: Controller & getController() { return p_.controller(); } Controller const & getController() const { return p_.controller(); } - - ButtonController & bc() { return p_.bc(); } - ButtonController const & bc() const { return p_.bc(); } //@} private: diff --git a/src/frontends/controllers/Makefile.am b/src/frontends/controllers/Makefile.am index 4834bbf9e3..2e63998b10 100644 --- a/src/frontends/controllers/Makefile.am +++ b/src/frontends/controllers/Makefile.am @@ -7,10 +7,9 @@ EXTRA_DIST = pkglib_LTLIBRARIES = liblyxcontrollers.la SOURCEFILES = \ + Dialog.cpp \ Dialog.cpp \ Kernel.cpp \ - BCView.cpp \ - ButtonController.cpp \ ButtonPolicy.cpp \ ControlAboutlyx.cpp \ ControlBibtex.cpp \ @@ -53,7 +52,6 @@ SOURCEFILES = \ HEADERFILES = \ Kernel.h \ - ButtonController.h \ ButtonPolicy.h \ ControlAboutlyx.h \ ControlBibtex.h \ diff --git a/src/frontends/controllers/frontend_helpers.h b/src/frontends/controllers/frontend_helpers.h index 896c65b46e..79fa3adea5 100644 --- a/src/frontends/controllers/frontend_helpers.h +++ b/src/frontends/controllers/frontend_helpers.h @@ -19,17 +19,14 @@ #include #include #include -#include -#include -#include -#include - -class Buffer; class Color_color; /** Functions of use to the character GUI controller and view */ namespace lyx { + +namespace support { class FileFilterList; } + namespace frontend { /// @@ -83,14 +80,6 @@ std::vector const getLanguageData(bool character_dlg); /// sort colors for the gui std::vector const getSortedColors(std::vector colors); -} // namespace frontend - - -namespace support { class FileFilterList; } - - -namespace frontend { - /** Launch a file dialog and return the chosen file. filename: a suggested filename. title: the title of the dialog. @@ -157,29 +146,6 @@ browseDir(docstring const & pathname, std::vector const getLatexUnits(); -/** Functions to extract vectors of the first and second elems from a - vector > -*/ -template -std::vector const -getFirst(std::vector const & pr) -{ - std::vector tmp(pr.size()); - std::transform(pr.begin(), pr.end(), tmp.begin(), - boost::bind(&Pair::first, _1)); - return tmp; -} - -template -std::vector const -getSecond(std::vector const & pr) -{ - std::vector tmp(pr.size()); - std::transform(pr.begin(), pr.end(), tmp.begin(), - boost::bind(&Pair::second, _1)); - return tmp; -} - /** Build filelists of all availabe bst/cls/sty-files. Done through * kpsewhich and an external script, saved in *Files.lst. */ diff --git a/src/frontends/qt4/Qt2BC.cpp b/src/frontends/qt4/ButtonController.cpp similarity index 59% rename from src/frontends/qt4/Qt2BC.cpp rename to src/frontends/qt4/ButtonController.cpp index 9653c892ac..26279aa0ee 100644 --- a/src/frontends/qt4/Qt2BC.cpp +++ b/src/frontends/qt4/ButtonController.cpp @@ -1,19 +1,16 @@ /** - * \file Qt2BC.cpp + * \file ButtonController.cpp * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Allan Rae - * \author Angus Leeming * * Full author contact details are available in file CREDITS. */ #include -#include "Qt2BC.h" -#include "BCView.h" -#include "ButtonPolicy.h" +#include "ButtonController.h" #include "debug.h" #include "qt_helpers.h" @@ -22,17 +19,79 @@ #include #include - namespace lyx { namespace frontend { - -Qt2BC::Qt2BC(ButtonController & parent) - : BCView(parent), okay_(0), apply_(0), cancel_(0), restore_(0) +ButtonController::ButtonController() + : okay_(0), apply_(0), cancel_(0), restore_(0), + policy_(ButtonPolicy::IgnorantPolicy) {} -void Qt2BC::refresh() const +void ButtonController::setPolicy(ButtonPolicy::Policy policy) +{ + policy_ = ButtonPolicy(policy); +} + + +void ButtonController::ok() +{ + input(ButtonPolicy::SMI_OKAY); +} + + +void ButtonController::input(ButtonPolicy::SMInput in) +{ + if (ButtonPolicy::SMI_NOOP == in) + return; + policy_.input(in); + refresh(); +} + + +void ButtonController::apply() +{ + input(ButtonPolicy::SMI_APPLY); +} + + +void ButtonController::cancel() +{ + input(ButtonPolicy::SMI_CANCEL); +} + + +void ButtonController::restore() +{ + input(ButtonPolicy::SMI_RESTORE); +} + + +void ButtonController::hide() +{ + input(ButtonPolicy::SMI_HIDE); +} + + +void ButtonController::setValid(bool v) +{ + input(v ? ButtonPolicy::SMI_VALID : ButtonPolicy::SMI_INVALID); +} + + +bool ButtonController::setReadOnly(bool ro) +{ + LYXERR(Debug::GUI) << "Setting controller ro: " << ro << std::endl; + + policy_.input(ro ? + ButtonPolicy::SMI_READ_ONLY : ButtonPolicy::SMI_READ_WRITE); + refreshReadOnly(); + refresh(); + return ro; +} + + +void ButtonController::refresh() const { LYXERR(Debug::GUI) << "Calling BC refresh()" << std::endl; @@ -40,21 +99,21 @@ void Qt2BC::refresh() const if (okay_) { bool const enabled = - all_valid && bp().buttonStatus(ButtonPolicy::OKAY); + all_valid && policy().buttonStatus(ButtonPolicy::OKAY); okay_->setEnabled(enabled); } if (apply_) { bool const enabled = - all_valid && bp().buttonStatus(ButtonPolicy::APPLY); + all_valid && policy().buttonStatus(ButtonPolicy::APPLY); apply_->setEnabled(enabled); } if (restore_) { bool const enabled = - all_valid && bp().buttonStatus(ButtonPolicy::RESTORE); + all_valid && policy().buttonStatus(ButtonPolicy::RESTORE); restore_->setEnabled(enabled); } if (cancel_) { - bool const enabled = bp().buttonStatus(ButtonPolicy::CANCEL); + bool const enabled = policy().buttonStatus(ButtonPolicy::CANCEL); if (enabled) cancel_->setText(toqstr(_("Cancel"))); else @@ -63,12 +122,12 @@ void Qt2BC::refresh() const } -void Qt2BC::refreshReadOnly() const +void ButtonController::refreshReadOnly() const { if (read_only_.empty()) return; - bool const enable = !bp().isReadOnly(); + bool const enable = !policy().isReadOnly(); Widgets::const_iterator end = read_only_.end(); Widgets::const_iterator iter = read_only_.begin(); @@ -77,7 +136,7 @@ void Qt2BC::refreshReadOnly() const } -void Qt2BC::setWidgetEnabled(QWidget * obj, bool enabled) const +void ButtonController::setWidgetEnabled(QWidget * obj, bool enabled) const { if (QLineEdit * le = qobject_cast(obj)) le->setReadOnly(!enabled); @@ -88,13 +147,13 @@ void Qt2BC::setWidgetEnabled(QWidget * obj, bool enabled) const } -void Qt2BC::addCheckedLineEdit(QLineEdit * input, QWidget * label) +void ButtonController::addCheckedLineEdit(QLineEdit * input, QWidget * label) { checked_widgets.push_back(CheckedLineEdit(input, label)); } -bool Qt2BC::checkWidgets() const +bool ButtonController::checkWidgets() const { bool valid = true; @@ -115,13 +174,6 @@ bool Qt2BC::checkWidgets() const // ////////////////////////////////////////////////////////////// -void addCheckedLineEdit(BCView & bcview, QLineEdit * input, QWidget * label) -{ - Qt2BC * bc = static_cast(&bcview); - bc->addCheckedLineEdit(input, label); -} - - static void setWarningColor(QWidget * widget) { QPalette pal = widget->palette(); @@ -130,7 +182,6 @@ static void setWarningColor(QWidget * widget) } - CheckedLineEdit::CheckedLineEdit(QLineEdit * input, QWidget * label) : input_(input), label_(label) {} @@ -152,7 +203,7 @@ bool CheckedLineEdit::check() const else setWarningColor(input_); - if (label_) { + if (!label_) { if (valid) label_->setPalette(QPalette()); else diff --git a/src/frontends/qt4/Qt2BC.h b/src/frontends/qt4/ButtonController.h similarity index 56% rename from src/frontends/qt4/Qt2BC.h rename to src/frontends/qt4/ButtonController.h index fbef62c962..fd226cd827 100644 --- a/src/frontends/qt4/Qt2BC.h +++ b/src/frontends/qt4/ButtonController.h @@ -1,24 +1,20 @@ // -*- C++ -*- /** - * \file Qt2BC.h + * \file ButtonController.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Allan Rae - * \author Angus Leeming - * \author Baruch Even * * Full author contact details are available in file CREDITS. */ -#ifndef QT2BC_H -#define QT2BC_H +#ifndef BUTTONCONTROLLER_H +#define BUTTONCONTROLLER_H -#include "BCView.h" +#include "ButtonPolicy.h" #include "gettext.h" -#include - class QWidget; class QPushButton; class QLineEdit; @@ -26,10 +22,6 @@ class QLineEdit; namespace lyx { namespace frontend { - -void addCheckedLineEdit(BCView & bcview, - QLineEdit * input, QWidget * label = 0); - class CheckedLineEdit { public: @@ -49,11 +41,66 @@ private: state machine. */ -class Qt2BC : public BCView + +/** \c ButtonController controls the activation of the OK, Apply and + * Cancel buttons. + * + * It actually supports 4 buttons in all and it's up to the user to decide on + * the activation policy and which buttons correspond to which output of the + * state machine. + */ + +class ButtonController { public: + ButtonController(); + + //@{ + /** Methods to set and get the ButtonPolicy. + * \param ptr is owned by the ButtonController. + */ + void setPolicy(ButtonPolicy::Policy policy); + ButtonPolicy const & policy() const { return policy_; } + ButtonPolicy & policy() { return policy_; } + //@} + /// - Qt2BC(ButtonController & parent); + void input(ButtonPolicy::SMInput); + + //@{ + /// Tell the BC that a particular button has been pressed. + void ok(); + void apply(); + void cancel(); + void restore(); + //@} + + /// Tell the BC that the dialog is being hidden + void hide(); + + /**Refresh the activation state of the Ok, Apply, Close and + * Restore buttons. + */ + void refresh() const; + + /** Refresh the activation state of all the widgets under the control + * of the BC to reflect the read-only status of the underlying buffer. + */ + void refreshReadOnly() const; + + /** Passthrough function -- returns its input value + * Tell the BC about the read-only status of the underlying buffer. + */ + bool setReadOnly(bool = true); + + /** \param validity Tell the BC that the data is, or is not, valid. + * Sets the activation state of the buttons immediately. + */ + void setValid(bool = true); + + // + // View + // //@{ /** Store pointers to these widgets. @@ -70,11 +117,6 @@ public: */ void addReadOnly(QWidget * obj) { read_only_.push_back(obj); } - /// Refresh the status of the Ok, Apply, Restore, Cancel buttons. - virtual void refresh() const; - /// Refresh the status of any widgets in the read_only list - virtual void refreshReadOnly() const; - /** Add a widget to the list of all widgets whose validity should * be checked explicitly when the buttons are refreshed. */ @@ -99,9 +141,12 @@ private: typedef std::list Widgets; Widgets read_only_; + +private: + ButtonPolicy policy_; }; } // namespace frontend } // namespace lyx -#endif // QT2BC_H +#endif // BUTTONCONTROLLER_H diff --git a/src/frontends/qt4/Dialogs.cpp b/src/frontends/qt4/Dialogs.cpp index 231e0defef..78fa8e9e4b 100644 --- a/src/frontends/qt4/Dialogs.cpp +++ b/src/frontends/qt4/Dialogs.cpp @@ -11,8 +11,8 @@ #include #include "Dialogs.h" +#include "GuiDialog.h" -#include "Qt2BC.h" #include "ButtonController.h" #include "DockView.h" #include "GuiView.h" @@ -110,12 +110,11 @@ bool Dialogs::isValidName(string const & name) const } -Dialogs::DialogPtr Dialogs::build(string const & name) +Dialog * Dialogs::build(string const & name) { BOOST_ASSERT(isValidName(name)); - DialogPtr dialog(new Dialog(lyxview_, name)); - dialog->bc().view(new Qt2BC(dialog->bc())); + GuiDialog * dialog = new GuiDialog(lyxview_, name); if (name == "aboutlyx") { dialog->setController(new ControlAboutlyx(*dialog)); diff --git a/src/frontends/qt4/GuiAbout.cpp b/src/frontends/qt4/GuiAbout.cpp index 90acf73c91..36ef8ace72 100644 --- a/src/frontends/qt4/GuiAbout.cpp +++ b/src/frontends/qt4/GuiAbout.cpp @@ -11,11 +11,8 @@ #include #include "GuiAbout.h" -#include "Qt2BC.h" #include "qt_helpers.h" - -#include "controllers/ButtonController.h" -#include "controllers/ControlAboutlyx.h" +#include "gettext.h" #include "support/lstrings.h" @@ -38,7 +35,7 @@ namespace lyx { namespace frontend { -GuiAbout::GuiAbout(Dialog & parent) +GuiAbout::GuiAbout(GuiDialog & parent) : GuiView(parent, _("About LyX")) { } @@ -112,8 +109,8 @@ void GuiAbout::build_dialog() dialog_->setMinimumSize(dialog_->sizeHint()); // Manage the cancel/close button - bcview().setCancel(dialog_->closePB); - bc().refresh(); + bc().setCancel(dialog_->closePB); + //FIXME bc().refresh(); } } // namespace frontend diff --git a/src/frontends/qt4/GuiAbout.h b/src/frontends/qt4/GuiAbout.h index 0be3eae0e5..27ed42ed79 100644 --- a/src/frontends/qt4/GuiAbout.h +++ b/src/frontends/qt4/GuiAbout.h @@ -36,7 +36,7 @@ public: class GuiAbout : public GuiView { public: - GuiAbout(Dialog &); + GuiAbout(GuiDialog &); /// parent controller ControlAboutlyx & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiBibitem.cpp b/src/frontends/qt4/GuiBibitem.cpp index 88512371c3..3f9412640a 100644 --- a/src/frontends/qt4/GuiBibitem.cpp +++ b/src/frontends/qt4/GuiBibitem.cpp @@ -11,7 +11,6 @@ #include #include "GuiBibitem.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include @@ -62,7 +61,7 @@ void GuiBibitemDialog::closeEvent(QCloseEvent *e) ///////////////////////////////////////////////////////////////////// -GuiBibitem::GuiBibitem(Dialog & parent) +GuiBibitem::GuiBibitem(GuiDialog & parent) : GuiView(parent, _("Bibliography Entry Settings")) { } @@ -72,10 +71,10 @@ void GuiBibitem::build_dialog() { dialog_.reset(new GuiBibitemDialog(this)); - bcview().setOK(dialog_->okPB); - bcview().setCancel(dialog_->closePB); - bcview().addReadOnly(dialog_->keyED); - bcview().addReadOnly(dialog_->labelED); + bc().setOK(dialog_->okPB); + bc().setCancel(dialog_->closePB); + bc().addReadOnly(dialog_->keyED); + bc().addReadOnly(dialog_->labelED); } diff --git a/src/frontends/qt4/GuiBibitem.h b/src/frontends/qt4/GuiBibitem.h index 7f6859f4e9..57b536f16f 100644 --- a/src/frontends/qt4/GuiBibitem.h +++ b/src/frontends/qt4/GuiBibitem.h @@ -42,7 +42,7 @@ class GuiBibitem : public GuiView { public: /// - GuiBibitem(Dialog &); + GuiBibitem(GuiDialog &); /// parent controller ControlCommand & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiBibtex.cpp b/src/frontends/qt4/GuiBibtex.cpp index 06210eefbd..0dba536ab4 100644 --- a/src/frontends/qt4/GuiBibtex.cpp +++ b/src/frontends/qt4/GuiBibtex.cpp @@ -15,7 +15,6 @@ #include "GuiBibtex.h" #include "ui_BibtexAddUi.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include "Validator.h" #include "LyXRC.h" @@ -80,14 +79,10 @@ GuiBibtexDialog::GuiBibtexDialog(GuiBibtex * form) this, SLOT(addPressed())); add_ = new UiDialog(this, true); - - Qt2BC * bcview = new Qt2BC(add_bc_); - add_bc_.view(bcview); add_bc_.setPolicy(ButtonPolicy::OkCancelPolicy); - - bcview->setOK(add_->addPB); - bcview->setCancel(add_->closePB); - bcview->addCheckedLineEdit(add_->bibED, 0); + add_bc_.setOK(add_->addPB); + add_bc_.setCancel(add_->closePB); + add_bc_.addCheckedLineEdit(add_->bibED, 0); connect(add_->bibED, SIGNAL(textChanged(const QString &)), this, SLOT(bibEDChanged())); @@ -105,7 +100,6 @@ GuiBibtexDialog::GuiBibtexDialog(GuiBibtex * form) this, SLOT(browseBibPressed())); connect(add_->closePB, SIGNAL(clicked()), add_, SLOT(reject())); - } @@ -114,7 +108,7 @@ void GuiBibtexDialog::bibEDChanged() // Indicate to the button controller that the contents have // changed. The actual test of validity is carried out by // the checkedLineEdit. - add_bc_.valid(true); + add_bc_.setValid(true); } @@ -176,7 +170,7 @@ void GuiBibtexDialog::browseBibPressed() void GuiBibtexDialog::addPressed() { - add_bc_.valid(false); + add_bc_.setValid(false); add_->exec(); } @@ -231,7 +225,7 @@ void GuiBibtexDialog::databaseChanged() void GuiBibtexDialog::availableChanged() { - add_bc_.valid(true); + add_bc_.setValid(true); } @@ -244,12 +238,12 @@ void GuiBibtexDialog::closeEvent(QCloseEvent *e) ///////////////////////////////////////////////////////////////////// // -// QBibTex +// GuiBibTex // ///////////////////////////////////////////////////////////////////// -GuiBibtex::GuiBibtex(Dialog & parent) +GuiBibtex::GuiBibtex(GuiDialog & parent) : GuiView(parent, _("BibTeX Bibliography")) { } @@ -259,14 +253,14 @@ void GuiBibtex::build_dialog() { dialog_.reset(new GuiBibtexDialog(this)); - bcview().setOK(dialog_->okPB); - bcview().setCancel(dialog_->closePB); - bcview().addReadOnly(dialog_->databaseLW); - bcview().addReadOnly(dialog_->stylePB); - bcview().addReadOnly(dialog_->styleCB); - bcview().addReadOnly(dialog_->bibtocCB); - bcview().addReadOnly(dialog_->addBibPB); - bcview().addReadOnly(dialog_->deletePB); + bc().setOK(dialog_->okPB); + bc().setCancel(dialog_->closePB); + bc().addReadOnly(dialog_->databaseLW); + bc().addReadOnly(dialog_->stylePB); + bc().addReadOnly(dialog_->styleCB); + bc().addReadOnly(dialog_->bibtocCB); + bc().addReadOnly(dialog_->addBibPB); + bc().addReadOnly(dialog_->deletePB); } diff --git a/src/frontends/qt4/GuiBibtex.h b/src/frontends/qt4/GuiBibtex.h index 8033c51db3..30afc2ba5e 100644 --- a/src/frontends/qt4/GuiBibtex.h +++ b/src/frontends/qt4/GuiBibtex.h @@ -71,7 +71,7 @@ class GuiBibtex : public GuiView public: friend class GuiBibtexDialog; - GuiBibtex(Dialog &); + GuiBibtex(GuiDialog &); /// parent controller ControlBibtex & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiBox.cpp b/src/frontends/qt4/GuiBox.cpp index 2dc3045923..3b06509ce3 100644 --- a/src/frontends/qt4/GuiBox.cpp +++ b/src/frontends/qt4/GuiBox.cpp @@ -16,7 +16,6 @@ #include "LengthCombo.h" #include "qt_helpers.h" -#include "Qt2BC.h" #include "lengthcommon.h" #include "LyXRC.h" // to set the default length values #include "Validator.h" @@ -142,7 +141,7 @@ void GuiBoxDialog::restoreClicked() ////////////////////////////////////////////////////////////////// -GuiBox::GuiBox(Dialog & parent) +GuiBox::GuiBox(GuiDialog & parent) : GuiView(parent, _("Box Settings")) {} @@ -162,24 +161,24 @@ void GuiBox::build_dialog() for (unsigned int i = 1; i < gui_names_spec_.size(); ++i) dialog_->heightUnitsLC->addItem(toqstr(gui_names_spec_[i])); - bcview().addReadOnly(dialog_->typeCO); - bcview().addReadOnly(dialog_->innerBoxCO); - bcview().addReadOnly(dialog_->valignCO); - bcview().addReadOnly(dialog_->ialignCO); - bcview().addReadOnly(dialog_->halignCO); - bcview().addReadOnly(dialog_->widthED); - bcview().addReadOnly(dialog_->heightED); - bcview().addReadOnly(dialog_->widthUnitsLC); - bcview().addReadOnly(dialog_->heightUnitsLC); - - bcview().setRestore(dialog_->restorePB); - bcview().setOK(dialog_->okPB); - bcview().setApply(dialog_->applyPB); - bcview().setCancel(dialog_->closePB); + bc().addReadOnly(dialog_->typeCO); + bc().addReadOnly(dialog_->innerBoxCO); + bc().addReadOnly(dialog_->valignCO); + bc().addReadOnly(dialog_->ialignCO); + bc().addReadOnly(dialog_->halignCO); + bc().addReadOnly(dialog_->widthED); + bc().addReadOnly(dialog_->heightED); + bc().addReadOnly(dialog_->widthUnitsLC); + bc().addReadOnly(dialog_->heightUnitsLC); + + bc().setRestore(dialog_->restorePB); + bc().setOK(dialog_->okPB); + bc().setApply(dialog_->applyPB); + bc().setCancel(dialog_->closePB); // initialize the length validator - addCheckedLineEdit(bcview(), dialog_->widthED, dialog_->widthLA); - addCheckedLineEdit(bcview(), dialog_->heightED, dialog_->heightLA); + bc().addCheckedLineEdit(dialog_->widthED, dialog_->widthLA); + bc().addCheckedLineEdit(dialog_->heightED, dialog_->heightLA); } diff --git a/src/frontends/qt4/GuiBox.h b/src/frontends/qt4/GuiBox.h index 6d9e3dfc49..1cd65f96c5 100644 --- a/src/frontends/qt4/GuiBox.h +++ b/src/frontends/qt4/GuiBox.h @@ -47,7 +47,7 @@ class GuiBox : public GuiView { public: /// - GuiBox(Dialog &); + GuiBox(GuiDialog &); /// parent controller ControlBox & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiBranch.cpp b/src/frontends/qt4/GuiBranch.cpp index f292dc7311..78af17f9f6 100644 --- a/src/frontends/qt4/GuiBranch.cpp +++ b/src/frontends/qt4/GuiBranch.cpp @@ -11,7 +11,6 @@ #include #include "GuiBranch.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include "BranchList.h" @@ -63,7 +62,7 @@ void GuiBranchDialog::change_adaptor() ///////////////////////////////////////////////////////////////////// -GuiBranch::GuiBranch(Dialog & parent) +GuiBranch::GuiBranch(GuiDialog & parent) : GuiView(parent, _("Branch Settings")) {} @@ -72,8 +71,8 @@ void GuiBranch::build_dialog() { dialog_.reset(new GuiBranchDialog(this)); - bcview().setOK(dialog_->okPB); - bcview().setCancel(dialog_->closePB); + bc().setOK(dialog_->okPB); + bc().setCancel(dialog_->closePB); } diff --git a/src/frontends/qt4/GuiBranch.h b/src/frontends/qt4/GuiBranch.h index d3c3b66e8d..2bf448d46c 100644 --- a/src/frontends/qt4/GuiBranch.h +++ b/src/frontends/qt4/GuiBranch.h @@ -42,7 +42,7 @@ class GuiBranch : public GuiView { public: /// Constructor - GuiBranch(Dialog &); + GuiBranch(GuiDialog &); /// parent controller ControlBranch & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiChanges.cpp b/src/frontends/qt4/GuiChanges.cpp index 7f4bb8b7b8..6375e79318 100644 --- a/src/frontends/qt4/GuiChanges.cpp +++ b/src/frontends/qt4/GuiChanges.cpp @@ -12,7 +12,6 @@ #include #include "GuiChanges.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include "support/lstrings.h" @@ -76,7 +75,7 @@ void GuiChangesDialog::closeEvent(QCloseEvent *e) ///////////////////////////////////////////////////////////////////// -GuiChanges::GuiChanges(Dialog & parent) +GuiChanges::GuiChanges(GuiDialog & parent) : GuiView(parent, _("Merge Changes")) { } @@ -86,9 +85,9 @@ void GuiChanges::build_dialog() { dialog_.reset(new GuiChangesDialog(this)); - bcview().setCancel(dialog_->closePB); - bcview().addReadOnly(dialog_->acceptPB); - bcview().addReadOnly(dialog_->rejectPB); + bc().setCancel(dialog_->closePB); + bc().addReadOnly(dialog_->acceptPB); + bc().addReadOnly(dialog_->rejectPB); } diff --git a/src/frontends/qt4/GuiChanges.h b/src/frontends/qt4/GuiChanges.h index 0bb2937da6..19efd6e31d 100644 --- a/src/frontends/qt4/GuiChanges.h +++ b/src/frontends/qt4/GuiChanges.h @@ -47,7 +47,7 @@ class GuiChanges : public GuiView { public: /// - GuiChanges(Dialog &); + GuiChanges(GuiDialog &); /// parent controller ControlChanges & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiCharacter.cpp b/src/frontends/qt4/GuiCharacter.cpp index f10b40619e..369486cd60 100644 --- a/src/frontends/qt4/GuiCharacter.cpp +++ b/src/frontends/qt4/GuiCharacter.cpp @@ -12,7 +12,6 @@ #include #include "GuiCharacter.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include "frontend_helpers.h" #include "Color.h" @@ -85,7 +84,7 @@ void GuiCharacterDialog::closeEvent(QCloseEvent * e) ///////////////////////////////////////////////////////////////////// -GuiCharacter::GuiCharacter(Dialog & parent) +GuiCharacter::GuiCharacter(GuiDialog & parent) : GuiView(parent, _("Text Style")) { } @@ -133,18 +132,18 @@ void GuiCharacter::build_dialog() dialog_->langCO->addItem(toqstr(cit->first)); } - bcview().setOK(dialog_->okPB); - bcview().setApply(dialog_->applyPB); - bcview().setCancel(dialog_->closePB); - bcview().addReadOnly(dialog_->familyCO); - bcview().addReadOnly(dialog_->seriesCO); - bcview().addReadOnly(dialog_->sizeCO); - bcview().addReadOnly(dialog_->shapeCO); - bcview().addReadOnly(dialog_->miscCO); - bcview().addReadOnly(dialog_->langCO); - bcview().addReadOnly(dialog_->colorCO); - bcview().addReadOnly(dialog_->toggleallCB); - bcview().addReadOnly(dialog_->autoapplyCB); + bc().setOK(dialog_->okPB); + bc().setApply(dialog_->applyPB); + bc().setCancel(dialog_->closePB); + bc().addReadOnly(dialog_->familyCO); + bc().addReadOnly(dialog_->seriesCO); + bc().addReadOnly(dialog_->sizeCO); + bc().addReadOnly(dialog_->shapeCO); + bc().addReadOnly(dialog_->miscCO); + bc().addReadOnly(dialog_->langCO); + bc().addReadOnly(dialog_->colorCO); + bc().addReadOnly(dialog_->toggleallCB); + bc().addReadOnly(dialog_->autoapplyCB); // FIXME: hack to work around resizing bug in Qt >= 4.2 // bug verified with Qt 4.2.{0-3} (JSpitzm) diff --git a/src/frontends/qt4/GuiCharacter.h b/src/frontends/qt4/GuiCharacter.h index 09e9507db0..519901dcd6 100644 --- a/src/frontends/qt4/GuiCharacter.h +++ b/src/frontends/qt4/GuiCharacter.h @@ -44,7 +44,7 @@ class GuiCharacter : public GuiView public: friend class GuiCharacterDialog; - GuiCharacter(Dialog &); + GuiCharacter(GuiDialog &); /// parent controller ControlCharacter & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiCitation.cpp b/src/frontends/qt4/GuiCitation.cpp index 1bf47e6d80..94ce988001 100644 --- a/src/frontends/qt4/GuiCitation.cpp +++ b/src/frontends/qt4/GuiCitation.cpp @@ -462,7 +462,7 @@ void GuiCitationDialog::changed() // /////////////////////////////////////////////////////////////////////// -GuiCitation::GuiCitation(Dialog & parent) +GuiCitation::GuiCitation(GuiDialog & parent) : ControlCitation(parent) { } diff --git a/src/frontends/qt4/GuiCitation.h b/src/frontends/qt4/GuiCitation.h index 573525cc31..7de1d472ed 100644 --- a/src/frontends/qt4/GuiCitation.h +++ b/src/frontends/qt4/GuiCitation.h @@ -15,7 +15,7 @@ #ifndef GUICITATION_H #define GUICITATION_H -#include "Dialog.h" +#include "GuiDialog.h" #include "GuiSelectionManager.h" #include "ui_CitationUi.h" #include "ControlCitation.h" @@ -109,7 +109,7 @@ class GuiCitation : public ControlCitation { public: /// - GuiCitation(Dialog &); + GuiCitation(GuiDialog &); virtual ~GuiCitation() {} virtual bool initialiseParams(std::string const & data); diff --git a/src/frontends/qt4/GuiDelimiter.cpp b/src/frontends/qt4/GuiDelimiter.cpp index 40eb280d0f..e93682b81f 100644 --- a/src/frontends/qt4/GuiDelimiter.cpp +++ b/src/frontends/qt4/GuiDelimiter.cpp @@ -58,7 +58,7 @@ QString fix_name(QString const & str, bool big) } // namespace anon -GuiDelimiter::GuiDelimiter(Dialog & parent) +GuiDelimiter::GuiDelimiter(GuiDialog & parent) : GuiView(parent, _("Math Delimiter")) {} diff --git a/src/frontends/qt4/GuiDelimiter.h b/src/frontends/qt4/GuiDelimiter.h index 301eabc7b9..b57b1c2734 100644 --- a/src/frontends/qt4/GuiDelimiter.h +++ b/src/frontends/qt4/GuiDelimiter.h @@ -54,7 +54,7 @@ class GuiDelimiter : public GuiView public: friend class GuiDelimiterDialog; /// - GuiDelimiter(Dialog &); + GuiDelimiter(GuiDialog &); /// parent controller ControlMath & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiDialog.cpp b/src/frontends/qt4/GuiDialog.cpp new file mode 100644 index 0000000000..581ac333c3 --- /dev/null +++ b/src/frontends/qt4/GuiDialog.cpp @@ -0,0 +1,121 @@ +/** + * \file Dialog.cpp + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Angus Leeming + * + * Full author contact details are available in file CREDITS. + */ + +#include + +#include "GuiDialog.h" +#include "debug.h" + + +namespace lyx { +namespace frontend { + +GuiDialog::GuiDialog(LyXView & lv, std::string const & name) + : Dialog(lv, name) +{} + + +void GuiDialog::setButtonsValid(bool valid) +{ + bc().setValid(valid); +} + + +void GuiDialog::ApplyButton() +{ + apply(); + bc().apply(); +} + + +void GuiDialog::OKButton() +{ + is_closing_ = true; + apply(); + is_closing_ = false; + hide(); + bc().ok(); +} + + +void GuiDialog::CancelButton() +{ + hide(); + bc().cancel(); +} + + +void GuiDialog::RestoreButton() +{ + // Tell the kernel that a request to refresh the dialog's contents + // has been received. It's up to the kernel to supply the necessary + // info by calling GuiDialog::update(). + kernel().updateDialog(name_); + bc().restore(); +} + + +void GuiDialog::preShow() +{ + bc().setReadOnly(kernel().isBufferReadonly()); +} + + +void GuiDialog::postShow() +{ + // The widgets may not be valid, so refresh the button controller + bc().refresh(); +} + + +void GuiDialog::preUpdate() +{ + bc().setReadOnly(kernel().isBufferReadonly()); +} + + +void GuiDialog::postUpdate() +{ + // The widgets may not be valid, so refresh the button controller + bc().refresh(); +} + + +void GuiDialog::checkStatus() +{ + // buffer independant dialogs are always active. + // This check allows us leave canApply unimplemented for some dialogs. + if (!controller().isBufferDependent()) + return; + + // deactivate the dialog if we have no buffer + if (!kernel().isBufferAvailable()) { + bc().setReadOnly(true); + return; + } + + // check whether this dialog may be active + if (controller().canApply()) { + bool const readonly = kernel().isBufferReadonly(); + bc().setReadOnly(readonly); + // refreshReadOnly() is too generous in _enabling_ widgets + // update dialog to disable disabled widgets again +/* + * FIXME: + if (!readonly || controller().canApplyToReadOnly()) + update(); +*/ + } else { + bc().setReadOnly(true); + } +} + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/qt4/GuiDialog.h b/src/frontends/qt4/GuiDialog.h new file mode 100644 index 0000000000..db52058e65 --- /dev/null +++ b/src/frontends/qt4/GuiDialog.h @@ -0,0 +1,71 @@ +// -*- C++ -*- +/** + * \file GuiDialog.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Angus Leeming + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef GUIDIALOG_H +#define GUIDIALOG_H + +#include "Dialog.h" +#include "ButtonController.h" + +namespace lyx { +namespace frontend { + +/** \c Dialog collects the different parts of a Model-Controller-View + * split of a generic dialog together. + */ +class GuiDialog : public Dialog +{ +public: + /// \param lv is the access point for the dialog to the LyX kernel. + /// \param name is the identifier given to the dialog by its parent + /// container. + GuiDialog(LyXView & lv, std::string const & name); + + /** \name Buttons + * These methods are publicly accessible because they are invoked + * by the View when the user presses... guess what ;-) + */ + //@{ + void ApplyButton(); + void OKButton(); + void CancelButton(); + void RestoreButton(); + //@} + + /** Check whether we may apply our data. + * + * The buttons are disabled if not and (re-)enabled if yes. + */ + void checkStatus(); + void setButtonsValid(bool valid); + + + /** \name Dialog Components + * Methods to access the various components making up a dialog. + */ + //@{ + ButtonController const & bc() const { return bc_; } + ButtonController & bc() { return bc_; } + //@} + + void preShow(); + void postShow(); + void preUpdate(); + void postUpdate(); + +private: + ButtonController bc_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // GUIDIALOG_H diff --git a/src/frontends/qt4/GuiDialogView.cpp b/src/frontends/qt4/GuiDialogView.cpp index 153ef7bb50..9fd6b9151e 100644 --- a/src/frontends/qt4/GuiDialogView.cpp +++ b/src/frontends/qt4/GuiDialogView.cpp @@ -11,23 +11,20 @@ #include #include "GuiDialogView.h" -#include "Qt2BC.h" #include "qt_helpers.h" -#include "controllers/ButtonController.h" - namespace lyx { namespace frontend { -GuiDialogView::GuiDialogView(Dialog & parent, docstring const & t) - : Dialog::View(parent,t), updating_(false) +GuiDialogView::GuiDialogView(GuiDialog & parent, docstring const & t) + : Dialog::View(parent, t), updating_(false), parent_(parent) {} -Qt2BC & GuiDialogView::bcview() +ButtonController & GuiDialogView::bc() { - return static_cast(dialog().bc().view()); + return parent_.bc(); } @@ -45,9 +42,8 @@ bool GuiDialogView::readOnly() const void GuiDialogView::show() { - if (!form()) { + if (!form()) build(); - } QSize const sizeHint = form()->sizeHint(); if (sizeHint.height() >= 0 && sizeHint.width() >= 0) @@ -87,37 +83,37 @@ void GuiDialogView::changed() { if (updating_) return; - bc().valid(isValid()); + parent_.bc().setValid(isValid()); } void GuiDialogView::slotWMHide() { - dialog().CancelButton(); + parent_.CancelButton(); } void GuiDialogView::slotApply() { - dialog().ApplyButton(); + parent_.ApplyButton(); } void GuiDialogView::slotOK() { - dialog().OKButton(); + parent_.OKButton(); } void GuiDialogView::slotClose() { - dialog().CancelButton(); + parent_.CancelButton(); } void GuiDialogView::slotRestore() { - dialog().RestoreButton(); + parent_.RestoreButton(); } } // namespace frontend diff --git a/src/frontends/qt4/GuiDialogView.h b/src/frontends/qt4/GuiDialogView.h index d0eba362bc..8d2fb4e2de 100644 --- a/src/frontends/qt4/GuiDialogView.h +++ b/src/frontends/qt4/GuiDialogView.h @@ -12,7 +12,7 @@ #ifndef GUIDIALOGVIEW_H #define GUIDIALOGVIEW_H -#include "Dialog.h" +#include "GuiDialog.h" #include @@ -23,15 +23,14 @@ namespace lyx { namespace frontend { -class Qt2BC; - /** This class is an Qt2 GUI base class. */ -class GuiDialogView : public QObject, public Dialog::View { +class GuiDialogView : public QObject, public Dialog::View +{ Q_OBJECT public: /// - GuiDialogView(Dialog &, docstring const &); + GuiDialogView(GuiDialog &, docstring const &); /// virtual ~GuiDialogView() {} /// @@ -41,7 +40,7 @@ public: virtual void changed(); /// - Qt2BC & bcview(); + ButtonController & bc(); protected: /// build the actual dialog @@ -63,6 +62,8 @@ protected: /// are we updating ? bool updating_; + GuiDialog & parent_; + public Q_SLOTS: // dialog closed from WM void slotWMHide(); @@ -87,7 +88,7 @@ private: template class GuiView : public GuiDialogView { protected: - GuiView(Dialog & p, docstring const & t) + GuiView(GuiDialog & p, docstring const & t) : GuiDialogView(p, t) {} diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 48e312457a..9119b22501 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -15,7 +15,6 @@ #include "FloatPlacement.h" #include "LengthCombo.h" #include "PanelStack.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include "Validator.h" @@ -41,7 +40,7 @@ #include #include -#include +#include using lyx::support::token; using lyx::support::bformat; @@ -171,9 +170,18 @@ void PreambleModule::closeEvent(QCloseEvent * e) // ///////////////////////////////////////////////////////////////////// +template +std::vector const +getSecond(std::vector const & pr) +{ + std::vector tmp(pr.size()); + std::transform(pr.begin(), pr.end(), tmp.begin(), + boost::bind(&Pair::second, _1)); + return tmp; +} + GuiDocumentDialog::GuiDocumentDialog(GuiDocument * form) - : form_(form), - lang_(getSecond(getLanguageData(false))) + : form_(form), lang_(getSecond(getLanguageData(false))) { setupUi(this); @@ -186,10 +194,10 @@ GuiDocumentDialog::GuiDocumentDialog(GuiDocument * form) connect(defaultPB, SIGNAL(clicked()), this, SLOT(useDefaultsClicked())); // Manage the restore, ok, apply, restore and cancel/close buttons - form_->bcview().setOK(okPB); - form_->bcview().setApply(applyPB); - form_->bcview().setCancel(closePB); - form_->bcview().setRestore(restorePB); + form_->bc().setOK(okPB); + form_->bc().setApply(applyPB); + form_->bc().setCancel(closePB); + form_->bc().setRestore(restorePB); textLayoutModule = new UiWidget; @@ -247,7 +255,7 @@ GuiDocumentDialog::GuiDocumentDialog(GuiDocument * form) Spacing::Other, qt_("Custom")); // initialize the length validator - addCheckedLineEdit(form_->bcview(), textLayoutModule->skipLE); + form_->bc().addCheckedLineEdit(textLayoutModule->skipLE); fontModule = new UiWidget; // fonts @@ -337,9 +345,9 @@ GuiDocumentDialog::GuiDocumentDialog(GuiDocument * form) pageLayoutModule->pagestyleCO->addItem(qt_("plain")); pageLayoutModule->pagestyleCO->addItem(qt_("headings")); pageLayoutModule->pagestyleCO->addItem(qt_("fancy")); - addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperheightLE, + form_->bc().addCheckedLineEdit(pageLayoutModule->paperheightLE, pageLayoutModule->paperheightL); - addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperwidthLE, + form_->bc().addCheckedLineEdit(pageLayoutModule->paperwidthLE, pageLayoutModule->paperwidthL); // paper @@ -415,19 +423,19 @@ GuiDocumentDialog::GuiDocumentDialog(GuiDocument * form) marginsModule->footskipLE->setValidator(unsignedLengthValidator( marginsModule->footskipLE)); - addCheckedLineEdit(form_->bcview(), marginsModule->topLE, + form_->bc().addCheckedLineEdit(marginsModule->topLE, marginsModule->topL); - addCheckedLineEdit(form_->bcview(), marginsModule->bottomLE, + form_->bc().addCheckedLineEdit(marginsModule->bottomLE, marginsModule->bottomL); - addCheckedLineEdit(form_->bcview(), marginsModule->innerLE, + form_->bc().addCheckedLineEdit(marginsModule->innerLE, marginsModule->innerL); - addCheckedLineEdit(form_->bcview(), marginsModule->outerLE, + form_->bc().addCheckedLineEdit(marginsModule->outerLE, marginsModule->outerL); - addCheckedLineEdit(form_->bcview(), marginsModule->headsepLE, + form_->bc().addCheckedLineEdit(marginsModule->headsepLE, marginsModule->headsepL); - addCheckedLineEdit(form_->bcview(), marginsModule->headheightLE, + form_->bc().addCheckedLineEdit(marginsModule->headheightLE, marginsModule->headheightL); - addCheckedLineEdit(form_->bcview(), marginsModule->footskipLE, + form_->bc().addCheckedLineEdit(marginsModule->footskipLE, marginsModule->footskipL); @@ -509,7 +517,6 @@ GuiDocumentDialog::GuiDocumentDialog(GuiDocument * form) biblioModule->citeStyleCO->setCurrentIndex(0); - mathsModule = new UiWidget; connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)), mathsModule->amsCB, SLOT(setDisabled(bool))); @@ -1393,7 +1400,7 @@ void GuiDocumentDialog::updateParams(BufferParams const & params) ///////////////////////////////////////////////////////////////////// -GuiDocument::GuiDocument(Dialog & parent) +GuiDocument::GuiDocument(GuiDialog & parent) : GuiView(parent, _("Document Settings")) {} diff --git a/src/frontends/qt4/GuiDocument.h b/src/frontends/qt4/GuiDocument.h index 7590cdaa93..296e0140d6 100644 --- a/src/frontends/qt4/GuiDocument.h +++ b/src/frontends/qt4/GuiDocument.h @@ -123,7 +123,7 @@ public: friend class GuiDocumentDialog; - GuiDocument(Dialog &); + GuiDocument(GuiDialog &); void showPreamble(); /// parent controller diff --git a/src/frontends/qt4/GuiERT.cpp b/src/frontends/qt4/GuiERT.cpp index f9b994129b..a8648c9792 100644 --- a/src/frontends/qt4/GuiERT.cpp +++ b/src/frontends/qt4/GuiERT.cpp @@ -11,7 +11,7 @@ #include #include "GuiERT.h" -#include "Qt2BC.h" +#include "gettext.h" #include #include @@ -58,7 +58,7 @@ void GuiERTDialog::change_adaptor() // ///////////////////////////////////////////////////////////////////// -GuiERT::GuiERT(Dialog & parent) +GuiERT::GuiERT(GuiDialog & parent) : GuiView(parent, _("TeX Code Settings")) { } @@ -68,8 +68,8 @@ void GuiERT::build_dialog() { dialog_.reset(new GuiERTDialog(this)); - bcview().setOK(dialog_->okPB); - bcview().setCancel(dialog_->closePB); + bc().setOK(dialog_->okPB); + bc().setCancel(dialog_->closePB); } diff --git a/src/frontends/qt4/GuiERT.h b/src/frontends/qt4/GuiERT.h index 4bc641eb1d..e95b734f0a 100644 --- a/src/frontends/qt4/GuiERT.h +++ b/src/frontends/qt4/GuiERT.h @@ -16,7 +16,6 @@ #include "ControlERT.h" #include "ui_ERTUi.h" -#include #include namespace lyx { @@ -42,7 +41,7 @@ class GuiERT : public GuiView { public: /// constructor - GuiERT(Dialog &); + GuiERT(GuiDialog &); /// parent controller ControlERT & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiEmbeddedFiles.cpp b/src/frontends/qt4/GuiEmbeddedFiles.cpp index dc1b57105a..49ebc9427f 100644 --- a/src/frontends/qt4/GuiEmbeddedFiles.cpp +++ b/src/frontends/qt4/GuiEmbeddedFiles.cpp @@ -11,8 +11,6 @@ #include #include "GuiEmbeddedFiles.h" -#include "Qt2BC.h" - #include "debug.h" namespace lyx { diff --git a/src/frontends/qt4/GuiErrorList.cpp b/src/frontends/qt4/GuiErrorList.cpp index c05b26c787..526f299688 100644 --- a/src/frontends/qt4/GuiErrorList.cpp +++ b/src/frontends/qt4/GuiErrorList.cpp @@ -11,7 +11,6 @@ #include #include "GuiErrorList.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include @@ -69,7 +68,7 @@ void GuiErrorListDialog::showEvent(QShowEvent *e) ///////////////////////////////////////////////////////////////////// -GuiErrorList::GuiErrorList(Dialog & parent) +GuiErrorList::GuiErrorList(GuiDialog & parent) : GuiView(parent, docstring()) {} @@ -77,7 +76,7 @@ GuiErrorList::GuiErrorList(Dialog & parent) void GuiErrorList::build_dialog() { dialog_.reset(new GuiErrorListDialog(this)); - bcview().setCancel(dialog_->closePB); + bc().setCancel(dialog_->closePB); } diff --git a/src/frontends/qt4/GuiErrorList.h b/src/frontends/qt4/GuiErrorList.h index b236554170..2ed5f72da7 100644 --- a/src/frontends/qt4/GuiErrorList.h +++ b/src/frontends/qt4/GuiErrorList.h @@ -45,7 +45,7 @@ class GuiErrorList : public GuiView public: friend class GuiErrorListDialog; - GuiErrorList(Dialog &); + GuiErrorList(GuiDialog &); /// parent controller ControlErrorList & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiExternal.cpp b/src/frontends/qt4/GuiExternal.cpp index bbdf922c43..44ffefd58a 100644 --- a/src/frontends/qt4/GuiExternal.cpp +++ b/src/frontends/qt4/GuiExternal.cpp @@ -14,8 +14,6 @@ #include "lengthcommon.h" #include "LyXRC.h" -#include "controllers/ButtonController.h" - #include "insets/ExternalTemplate.h" #include "insets/InsetExternal.h" @@ -25,7 +23,6 @@ #include "support/lyxlib.h" #include "GuiExternal.h" -#include "Qt2BC.h" #include "LengthCombo.h" #include "qt_helpers.h" @@ -485,7 +482,7 @@ void getExtra(external::ExtraData & data, } // namespace anon -GuiExternal::GuiExternal(Dialog & parent) +GuiExternal::GuiExternal(GuiDialog & parent) : GuiView(parent, _("External Material")) {} @@ -494,43 +491,43 @@ void GuiExternal::build_dialog() { dialog_.reset(new GuiExternalDialog(this)); - bcview().setOK(dialog_->okPB); - bcview().setApply(dialog_->applyPB); - bcview().setCancel(dialog_->closePB); - - bcview().addReadOnly(dialog_->fileED); - bcview().addReadOnly(dialog_->browsePB); - bcview().addReadOnly(dialog_->editPB); - bcview().addReadOnly(dialog_->externalCO); - bcview().addReadOnly(dialog_->draftCB); - bcview().addReadOnly(dialog_->displayscaleED); - bcview().addReadOnly(dialog_->showCO); - bcview().addReadOnly(dialog_->displayCB); - bcview().addReadOnly(dialog_->angleED); - bcview().addReadOnly(dialog_->originCO); - bcview().addReadOnly(dialog_->heightUnitCO); - bcview().addReadOnly(dialog_->heightED); - bcview().addReadOnly(dialog_->aspectratioCB); - bcview().addReadOnly(dialog_->widthUnitCO); - bcview().addReadOnly(dialog_->widthED); - bcview().addReadOnly(dialog_->clipCB); - bcview().addReadOnly(dialog_->getbbPB); - bcview().addReadOnly(dialog_->ytED); - bcview().addReadOnly(dialog_->xlED); - bcview().addReadOnly(dialog_->xrED); - bcview().addReadOnly(dialog_->ybED); - bcview().addReadOnly(dialog_->extraFormatCO); - bcview().addReadOnly(dialog_->extraED); - - addCheckedLineEdit(bcview(), dialog_->angleED, dialog_->angleLA); - addCheckedLineEdit(bcview(), dialog_->displayscaleED, dialog_->scaleLA); - addCheckedLineEdit(bcview(), dialog_->heightED, dialog_->heightLA); - addCheckedLineEdit(bcview(), dialog_->widthED, dialog_->widthLA); - addCheckedLineEdit(bcview(), dialog_->xlED, dialog_->lbLA); - addCheckedLineEdit(bcview(), dialog_->ybED, dialog_->lbLA); - addCheckedLineEdit(bcview(), dialog_->xrED, dialog_->rtLA); - addCheckedLineEdit(bcview(), dialog_->ytED, dialog_->rtLA); - addCheckedLineEdit(bcview(), dialog_->fileED, dialog_->fileLA); + bc().setOK(dialog_->okPB); + bc().setApply(dialog_->applyPB); + bc().setCancel(dialog_->closePB); + + bc().addReadOnly(dialog_->fileED); + bc().addReadOnly(dialog_->browsePB); + bc().addReadOnly(dialog_->editPB); + bc().addReadOnly(dialog_->externalCO); + bc().addReadOnly(dialog_->draftCB); + bc().addReadOnly(dialog_->displayscaleED); + bc().addReadOnly(dialog_->showCO); + bc().addReadOnly(dialog_->displayCB); + bc().addReadOnly(dialog_->angleED); + bc().addReadOnly(dialog_->originCO); + bc().addReadOnly(dialog_->heightUnitCO); + bc().addReadOnly(dialog_->heightED); + bc().addReadOnly(dialog_->aspectratioCB); + bc().addReadOnly(dialog_->widthUnitCO); + bc().addReadOnly(dialog_->widthED); + bc().addReadOnly(dialog_->clipCB); + bc().addReadOnly(dialog_->getbbPB); + bc().addReadOnly(dialog_->ytED); + bc().addReadOnly(dialog_->xlED); + bc().addReadOnly(dialog_->xrED); + bc().addReadOnly(dialog_->ybED); + bc().addReadOnly(dialog_->extraFormatCO); + bc().addReadOnly(dialog_->extraED); + + bc().addCheckedLineEdit(dialog_->angleED, dialog_->angleLA); + bc().addCheckedLineEdit(dialog_->displayscaleED, dialog_->scaleLA); + bc().addCheckedLineEdit(dialog_->heightED, dialog_->heightLA); + bc().addCheckedLineEdit(dialog_->widthED, dialog_->widthLA); + bc().addCheckedLineEdit(dialog_->xlED, dialog_->lbLA); + bc().addCheckedLineEdit(dialog_->ybED, dialog_->lbLA); + bc().addCheckedLineEdit(dialog_->xrED, dialog_->rtLA); + bc().addCheckedLineEdit(dialog_->ytED, dialog_->rtLA); + bc().addCheckedLineEdit(dialog_->fileED, dialog_->fileLA); std::vector templates(controller().getTemplates()); diff --git a/src/frontends/qt4/GuiExternal.h b/src/frontends/qt4/GuiExternal.h index ffc1efe7ef..7eb372a80b 100644 --- a/src/frontends/qt4/GuiExternal.h +++ b/src/frontends/qt4/GuiExternal.h @@ -58,7 +58,7 @@ class GuiExternal : public GuiView public: friend class GuiExternalDialog; - GuiExternal(Dialog &); + GuiExternal(GuiDialog &); /// parent controller ControlExternal & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiFloat.cpp b/src/frontends/qt4/GuiFloat.cpp index 3312ca9872..95430d91b5 100644 --- a/src/frontends/qt4/GuiFloat.cpp +++ b/src/frontends/qt4/GuiFloat.cpp @@ -11,7 +11,6 @@ #include #include "GuiFloat.h" -#include "Qt2BC.h" #include "FloatPlacement.h" #include "insets/InsetFloat.h" @@ -59,7 +58,7 @@ void GuiFloatDialog::closeEvent(QCloseEvent * e) } -GuiFloat::GuiFloat(Dialog & parent) +GuiFloat::GuiFloat(GuiDialog & parent) : GuiView(parent, _("Float Settings")) { } @@ -69,12 +68,12 @@ void GuiFloat::build_dialog() { dialog_.reset(new GuiFloatDialog(this)); - bcview().setCancel(dialog_->closePB); - bcview().setApply(dialog_->applyPB); - bcview().setOK(dialog_->okPB); - bcview().setRestore(dialog_->restorePB); + bc().setCancel(dialog_->closePB); + bc().setApply(dialog_->applyPB); + bc().setOK(dialog_->okPB); + bc().setRestore(dialog_->restorePB); - bcview().addReadOnly(dialog_->floatFP); + bc().addReadOnly(dialog_->floatFP); } diff --git a/src/frontends/qt4/GuiFloat.h b/src/frontends/qt4/GuiFloat.h index 565f8652e9..7ef8c0fdfd 100644 --- a/src/frontends/qt4/GuiFloat.h +++ b/src/frontends/qt4/GuiFloat.h @@ -45,7 +45,7 @@ public: /// friend class GuiFloatDialog; /// - GuiFloat(Dialog &); + GuiFloat(GuiDialog &); /// parent controller ControlFloat & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiGraphics.cpp b/src/frontends/qt4/GuiGraphics.cpp index a2a05a7892..d9a8280c3c 100644 --- a/src/frontends/qt4/GuiGraphics.cpp +++ b/src/frontends/qt4/GuiGraphics.cpp @@ -19,7 +19,6 @@ #include "LengthCombo.h" #include "lengthcommon.h" #include "LyXRC.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include "Validator.h" @@ -32,10 +31,6 @@ #include "support/lyxlib.h" #include "support/os.h" -#include - -#include "insets/InsetGraphicsParams.h" - #include #include #include @@ -43,6 +38,8 @@ #include #include +#include +#include using lyx::support::float_equal; using lyx::support::token; @@ -61,6 +58,16 @@ namespace lyx { namespace frontend { +template +std::vector const +getFirst(std::vector const & pr) +{ + std::vector tmp(pr.size()); + std::transform(pr.begin(), pr.end(), tmp.begin(), + boost::bind(&Pair::first, _1)); + return tmp; +} + GuiGraphicsDialog::GuiGraphicsDialog(GuiGraphics * form) : form_(form) { @@ -329,7 +336,7 @@ void GuiGraphicsDialog::on_angle_textChanged(const QString & filename) } -GuiGraphics::GuiGraphics(Dialog & parent) +GuiGraphics::GuiGraphics(GuiDialog & parent) : GuiView(parent, _("Graphics")) { } @@ -339,39 +346,39 @@ void GuiGraphics::build_dialog() { dialog_.reset(new GuiGraphicsDialog(this)); - bcview().setOK(dialog_->okPB); - bcview().setApply(dialog_->applyPB); - bcview().setRestore(dialog_->restorePB); - bcview().setCancel(dialog_->closePB); - - bcview().addReadOnly(dialog_->latexoptions); - bcview().addReadOnly(dialog_->subfigure); - bcview().addReadOnly(dialog_->filenameL); - bcview().addReadOnly(dialog_->filename); - bcview().addReadOnly(dialog_->browsePB); - bcview().addReadOnly(dialog_->unzipCB); - bcview().addReadOnly(dialog_->bbFrame); - bcview().addReadOnly(dialog_->draftCB); - bcview().addReadOnly(dialog_->clip); - bcview().addReadOnly(dialog_->unzipCB); - bcview().addReadOnly(dialog_->displayGB); - bcview().addReadOnly(dialog_->sizeGB); - bcview().addReadOnly(dialog_->rotationGB); - bcview().addReadOnly(dialog_->latexoptions); - bcview().addReadOnly(dialog_->getPB); - bcview().addReadOnly(dialog_->rotateOrderCB); + bc().setOK(dialog_->okPB); + bc().setApply(dialog_->applyPB); + bc().setRestore(dialog_->restorePB); + bc().setCancel(dialog_->closePB); + + bc().addReadOnly(dialog_->latexoptions); + bc().addReadOnly(dialog_->subfigure); + bc().addReadOnly(dialog_->filenameL); + bc().addReadOnly(dialog_->filename); + bc().addReadOnly(dialog_->browsePB); + bc().addReadOnly(dialog_->unzipCB); + bc().addReadOnly(dialog_->bbFrame); + bc().addReadOnly(dialog_->draftCB); + bc().addReadOnly(dialog_->clip); + bc().addReadOnly(dialog_->unzipCB); + bc().addReadOnly(dialog_->displayGB); + bc().addReadOnly(dialog_->sizeGB); + bc().addReadOnly(dialog_->rotationGB); + bc().addReadOnly(dialog_->latexoptions); + bc().addReadOnly(dialog_->getPB); + bc().addReadOnly(dialog_->rotateOrderCB); // initialize the length validator - addCheckedLineEdit(bcview(), dialog_->Scale, dialog_->scaleCB); - addCheckedLineEdit(bcview(), dialog_->Width, dialog_->WidthCB); - addCheckedLineEdit(bcview(), dialog_->Height, dialog_->HeightCB); - addCheckedLineEdit(bcview(), dialog_->displayscale, dialog_->scaleLA); - addCheckedLineEdit(bcview(), dialog_->angle, dialog_->angleL); - addCheckedLineEdit(bcview(), dialog_->lbX, dialog_->xL); - addCheckedLineEdit(bcview(), dialog_->lbY, dialog_->yL); - addCheckedLineEdit(bcview(), dialog_->rtX, dialog_->xL_2); - addCheckedLineEdit(bcview(), dialog_->rtY, dialog_->yL_2); - addCheckedLineEdit(bcview(), dialog_->filename, dialog_->filenameL); + bc().addCheckedLineEdit(dialog_->Scale, dialog_->scaleCB); + bc().addCheckedLineEdit(dialog_->Width, dialog_->WidthCB); + bc().addCheckedLineEdit(dialog_->Height, dialog_->HeightCB); + bc().addCheckedLineEdit(dialog_->displayscale, dialog_->scaleLA); + bc().addCheckedLineEdit(dialog_->angle, dialog_->angleL); + bc().addCheckedLineEdit(dialog_->lbX, dialog_->xL); + bc().addCheckedLineEdit(dialog_->lbY, dialog_->yL); + bc().addCheckedLineEdit(dialog_->rtX, dialog_->xL_2); + bc().addCheckedLineEdit(dialog_->rtY, dialog_->yL_2); + bc().addCheckedLineEdit(dialog_->filename, dialog_->filenameL); } @@ -383,6 +390,16 @@ static int getItemNo(const vector & v, string const & s) return (cit != v.end()) ? int(cit - v.begin()) : 0; } +template +std::vector const +getSecond(std::vector const & pr) +{ + std::vector tmp(pr.size()); + std::transform(pr.begin(), pr.end(), tmp.begin(), + boost::bind(&Pair::second, _1)); + return tmp; +} + void GuiGraphics::update_contents() { diff --git a/src/frontends/qt4/GuiGraphics.h b/src/frontends/qt4/GuiGraphics.h index 3ff7253384..bb2675c1d0 100644 --- a/src/frontends/qt4/GuiGraphics.h +++ b/src/frontends/qt4/GuiGraphics.h @@ -59,7 +59,7 @@ public: /// friend class GuiGraphicsDialog; /// - GuiGraphics(Dialog &); + GuiGraphics(GuiDialog &); /// parent controller ControlGraphics & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiInclude.cpp b/src/frontends/qt4/GuiInclude.cpp index a2650d5f35..1cfc42ca69 100644 --- a/src/frontends/qt4/GuiInclude.cpp +++ b/src/frontends/qt4/GuiInclude.cpp @@ -15,7 +15,6 @@ #include "GuiInclude.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include "LyXRC.h" @@ -184,7 +183,7 @@ void GuiIncludeDialog::browseClicked() ///////////////////////////////////////////////////////////////////// -GuiInclude::GuiInclude(Dialog & parent) +GuiInclude::GuiInclude(GuiDialog & parent) : GuiView(parent, _("Child Document")) {} @@ -193,15 +192,15 @@ void GuiInclude::build_dialog() { dialog_.reset(new GuiIncludeDialog(this)); - bcview().setOK(dialog_->okPB); - bcview().setCancel(dialog_->closePB); - bcview().addReadOnly(dialog_->filenameED); - bcview().addReadOnly(dialog_->browsePB); - bcview().addReadOnly(dialog_->visiblespaceCB); - bcview().addReadOnly(dialog_->typeCO); - bcview().addReadOnly(dialog_->listingsED); + bc().setOK(dialog_->okPB); + bc().setCancel(dialog_->closePB); + bc().addReadOnly(dialog_->filenameED); + bc().addReadOnly(dialog_->browsePB); + bc().addReadOnly(dialog_->visiblespaceCB); + bc().addReadOnly(dialog_->typeCO); + bc().addReadOnly(dialog_->listingsED); - addCheckedLineEdit(bcview(), dialog_->filenameED, dialog_->filenameLA); + bc().addCheckedLineEdit(dialog_->filenameED, dialog_->filenameLA); } diff --git a/src/frontends/qt4/GuiInclude.h b/src/frontends/qt4/GuiInclude.h index d176547a93..f1873bcca3 100644 --- a/src/frontends/qt4/GuiInclude.h +++ b/src/frontends/qt4/GuiInclude.h @@ -56,7 +56,7 @@ public: /// friend class GuiIncludeDialog; /// - GuiInclude(Dialog &); + GuiInclude(GuiDialog &); /// parent controller ControlInclude & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiIndex.cpp b/src/frontends/qt4/GuiIndex.cpp index cebac4debd..a567a9ce7b 100644 --- a/src/frontends/qt4/GuiIndex.cpp +++ b/src/frontends/qt4/GuiIndex.cpp @@ -10,13 +10,11 @@ #include +#include "GuiIndex.h" + #include "debug.h" #include "qt_helpers.h" -#include "GuiIndex.h" -#include "Qt2BC.h" -#include "ButtonController.h" - #include #include #include @@ -90,7 +88,8 @@ void GuiIndexDialog::closeEvent(QCloseEvent * e) ///////////////////////////////////////////////////////////////////// -GuiIndex::GuiIndex(Dialog & parent, docstring const & title, QString const & label) +GuiIndex::GuiIndex(GuiDialog & parent, docstring const & title, + QString const & label) : GuiView(parent, title), label_(label) { } @@ -102,9 +101,9 @@ void GuiIndex::build_dialog() dialog_->keywordLA->setText(label_); - bcview().setOK(dialog_->okPB); - bcview().setCancel(dialog_->closePB); - bcview().addReadOnly(dialog_->keywordED); + bc().setOK(dialog_->okPB); + bc().setCancel(dialog_->closePB); + bc().addReadOnly(dialog_->keywordED); } @@ -113,7 +112,7 @@ void GuiIndex::update_contents() docstring const contents = controller().params()["name"]; dialog_->keywordED->setText(toqstr(contents)); - bc().valid(!contents.empty()); + bc().setValid(!contents.empty()); } diff --git a/src/frontends/qt4/GuiIndex.h b/src/frontends/qt4/GuiIndex.h index 31929004a9..b745d6295a 100644 --- a/src/frontends/qt4/GuiIndex.h +++ b/src/frontends/qt4/GuiIndex.h @@ -44,7 +44,7 @@ class GuiIndex : public GuiView public: friend class GuiIndexDialog; - GuiIndex(Dialog &, docstring const & title, QString const & label); + GuiIndex(GuiDialog &, docstring const & title, QString const & label); /// parent controller ControlCommand & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiListings.cpp b/src/frontends/qt4/GuiListings.cpp index 04926b24e9..ea4de2e9ea 100644 --- a/src/frontends/qt4/GuiListings.cpp +++ b/src/frontends/qt4/GuiListings.cpp @@ -12,7 +12,6 @@ #include #include "GuiListings.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include "insets/InsetListingsParams.h" #include "debug.h" @@ -408,7 +407,7 @@ void GuiListingsDialog::on_languageCO_currentIndexChanged(int index) ///////////////////////////////////////////////////////////////////// -GuiListings::GuiListings(Dialog & parent) +GuiListings::GuiListings(GuiDialog & parent) : GuiView(parent, _("Program Listing Settings")) { } @@ -418,9 +417,9 @@ void GuiListings::build_dialog() { dialog_.reset(new GuiListingsDialog(this)); - bcview().setOK(dialog_->okPB); - bcview().setApply(dialog_->applyPB); - bcview().setCancel(dialog_->closePB); + bc().setOK(dialog_->okPB); + bc().setApply(dialog_->applyPB); + bc().setCancel(dialog_->closePB); dialog_->listingsTB->setPlainText( qt_("Input listing parameters on the right. Enter ? for a list of parameters.")); diff --git a/src/frontends/qt4/GuiListings.h b/src/frontends/qt4/GuiListings.h index 1aa6e0f54c..092dcfa7b5 100644 --- a/src/frontends/qt4/GuiListings.h +++ b/src/frontends/qt4/GuiListings.h @@ -57,7 +57,7 @@ class GuiListings : public GuiView { public: friend class GuiListingsDialog; - GuiListings(Dialog &); + GuiListings(GuiDialog &); /// parent controller ControlListings & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiLog.cpp b/src/frontends/qt4/GuiLog.cpp index 112f879a09..274ad265fe 100644 --- a/src/frontends/qt4/GuiLog.cpp +++ b/src/frontends/qt4/GuiLog.cpp @@ -107,7 +107,7 @@ void LogHighlighter::highlightBlock(QString const & text) ///////////////////////////////////////////////////////////////////// -GuiLog::GuiLog(Dialog & parent) +GuiLog::GuiLog(GuiDialog & parent) : GuiView(parent, docstring()) {} diff --git a/src/frontends/qt4/GuiLog.h b/src/frontends/qt4/GuiLog.h index 430c1e3f36..8259afe37f 100644 --- a/src/frontends/qt4/GuiLog.h +++ b/src/frontends/qt4/GuiLog.h @@ -47,7 +47,7 @@ public: /// friend class GuiLogDialog; /// - GuiLog(Dialog &); + GuiLog(GuiDialog &); /// parent controller ControlLog & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiMathMatrix.cpp b/src/frontends/qt4/GuiMathMatrix.cpp index 5a83b0d09d..5d43963413 100644 --- a/src/frontends/qt4/GuiMathMatrix.cpp +++ b/src/frontends/qt4/GuiMathMatrix.cpp @@ -28,7 +28,7 @@ using std::string; namespace lyx { namespace frontend { -GuiMathMatrix::GuiMathMatrix(Dialog & parent) +GuiMathMatrix::GuiMathMatrix(GuiDialog & parent) : GuiView(parent, _("Math Matrix")) {} diff --git a/src/frontends/qt4/GuiMathMatrix.h b/src/frontends/qt4/GuiMathMatrix.h index 050f20fc53..42d1cb906e 100644 --- a/src/frontends/qt4/GuiMathMatrix.h +++ b/src/frontends/qt4/GuiMathMatrix.h @@ -47,7 +47,7 @@ class GuiMathMatrix : public GuiView { public: friend class GuiMathMatrixDialog; - GuiMathMatrix(Dialog &); + GuiMathMatrix(GuiDialog &); /// parent controller ControlMath & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiNomencl.cpp b/src/frontends/qt4/GuiNomencl.cpp index 48dd5e4e8b..ff5f27f7e3 100644 --- a/src/frontends/qt4/GuiNomencl.cpp +++ b/src/frontends/qt4/GuiNomencl.cpp @@ -11,14 +11,12 @@ #include +#include "GuiNomencl.h" + #include "debug.h" #include "ControlCommand.h" #include "qt_helpers.h" -#include "GuiNomencl.h" -#include "Qt2BC.h" -#include "ButtonController.h" - #include #include #include @@ -85,7 +83,7 @@ void GuiNomenclDialog::closeEvent(QCloseEvent * e) ///////////////////////////////////////////////////////////////////// -GuiNomencl::GuiNomencl(Dialog & parent, docstring const & title) +GuiNomencl::GuiNomencl(GuiDialog & parent, docstring const & title) : GuiView(parent, title) { } @@ -95,11 +93,11 @@ void GuiNomencl::build_dialog() { dialog_.reset(new GuiNomenclDialog(this)); - bcview().setOK(dialog_->okPB); - bcview().setCancel(dialog_->closePB); - bcview().addReadOnly(dialog_->symbolED); - bcview().addReadOnly(dialog_->descriptionTE); - bcview().addReadOnly(dialog_->prefixED); + bc().setOK(dialog_->okPB); + bc().setCancel(dialog_->closePB); + bc().addReadOnly(dialog_->symbolED); + bc().addReadOnly(dialog_->descriptionTE); + bc().addReadOnly(dialog_->prefixED); } @@ -111,7 +109,7 @@ void GuiNomencl::update_contents() description.replace("\\\\","\n"); dialog_->descriptionTE->setPlainText(description); - bc().valid(isValid()); + bc().setValid(isValid()); } diff --git a/src/frontends/qt4/GuiNomencl.h b/src/frontends/qt4/GuiNomencl.h index 2d9536ed57..14911641d7 100644 --- a/src/frontends/qt4/GuiNomencl.h +++ b/src/frontends/qt4/GuiNomencl.h @@ -26,7 +26,8 @@ namespace frontend { class GuiNomencl; -class GuiNomenclDialog : public QDialog, public Ui::NomenclUi { +class GuiNomenclDialog : public QDialog, public Ui::NomenclUi +{ Q_OBJECT public: GuiNomenclDialog(GuiNomencl * form); @@ -46,7 +47,7 @@ class GuiNomencl : public GuiView public: friend class GuiNomenclDialog; - GuiNomencl(Dialog &, docstring const & title); + GuiNomencl(GuiDialog &, docstring const & title); /// parent controller ControlCommand & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiNote.cpp b/src/frontends/qt4/GuiNote.cpp index 250d2d34b6..c83c44c0e0 100644 --- a/src/frontends/qt4/GuiNote.cpp +++ b/src/frontends/qt4/GuiNote.cpp @@ -11,7 +11,6 @@ #include #include "GuiNote.h" -#include "Qt2BC.h" #include "insets/InsetNote.h" @@ -62,7 +61,7 @@ void GuiNoteDialog::change_adaptor() ///////////////////////////////////////////////////////////////////// -GuiNote::GuiNote(Dialog & parent) +GuiNote::GuiNote(GuiDialog & parent) : GuiView(parent, _("Note Settings")) {} @@ -71,8 +70,8 @@ void GuiNote::build_dialog() { dialog_.reset(new GuiNoteDialog(this)); - bcview().setOK(dialog_->okPB); - bcview().setCancel(dialog_->closePB); + bc().setOK(dialog_->okPB); + bc().setCancel(dialog_->closePB); } diff --git a/src/frontends/qt4/GuiNote.h b/src/frontends/qt4/GuiNote.h index 1d71caebfb..a541f6a12f 100644 --- a/src/frontends/qt4/GuiNote.h +++ b/src/frontends/qt4/GuiNote.h @@ -45,7 +45,7 @@ public: friend class GuiNoteDialog; /// Constructor - GuiNote(Dialog &); + GuiNote(GuiDialog &); /// parent controller ControlNote & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiParagraph.cpp b/src/frontends/qt4/GuiParagraph.cpp index 4a6c3d3bc3..8b40befb6b 100644 --- a/src/frontends/qt4/GuiParagraph.cpp +++ b/src/frontends/qt4/GuiParagraph.cpp @@ -12,13 +12,12 @@ #include #include "GuiParagraph.h" -#include "Qt2BC.h" -#include "qt_helpers.h" #include "debug.h" +#include "frontend_helpers.h" #include "ParagraphParameters.h" +#include "qt_helpers.h" #include "Spacing.h" -#include "frontend_helpers.h" #include #include @@ -163,7 +162,7 @@ LyXAlignment GuiParagraphDialog::getAlignmentFromDialog() ///////////////////////////////////////////////////////////////////// -GuiParagraph::GuiParagraph(Dialog & parent) +GuiParagraph::GuiParagraph(GuiDialog & parent) : GuiView(parent, _("Paragraph Settings")) {} @@ -174,10 +173,10 @@ void GuiParagraph::build_dialog() dialog_.reset(new GuiParagraphDialog(this)); // Manage the ok, apply, restore and cancel/close buttons - bcview().setOK(dialog_->okPB); - bcview().setApply(dialog_->applyPB); - bcview().setCancel(dialog_->closePB); - bcview().setRestore(dialog_->restorePB); + bc().setOK(dialog_->okPB); + bc().setApply(dialog_->applyPB); + bc().setCancel(dialog_->closePB); + bc().setRestore(dialog_->restorePB); } diff --git a/src/frontends/qt4/GuiParagraph.h b/src/frontends/qt4/GuiParagraph.h index 746f7cc276..7be6505640 100644 --- a/src/frontends/qt4/GuiParagraph.h +++ b/src/frontends/qt4/GuiParagraph.h @@ -59,7 +59,7 @@ class GuiParagraph : public GuiView public: friend class GuiParagraphDialog; - GuiParagraph(Dialog &); + GuiParagraph(GuiDialog &); /// parent controller ControlParagraph & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 8ba269eb39..5dab09eb74 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -12,7 +12,6 @@ #include "GuiPrefs.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include "GuiApplication.h" @@ -45,8 +44,11 @@ #include #include +#include + #include #include +#include using namespace Ui; @@ -1571,6 +1573,17 @@ void PrefFileformats::remove_format() // ///////////////////////////////////////////////////////////////////// +template +std::vector const +getSecond(std::vector const & pr) +{ + std::vector tmp(pr.size()); + std::transform(pr.begin(), pr.end(), tmp.begin(), + boost::bind(&Pair::second, _1)); + return tmp; +} + + PrefLanguage::PrefLanguage(QWidget * parent) : PrefModule(_("Language"), 0, parent) { @@ -1946,10 +1959,10 @@ GuiPrefsDialog::GuiPrefsDialog(GuiPrefs * form) prefsPS->updateGeometry(); #endif - form_->bcview().setOK(savePB); - form_->bcview().setApply(applyPB); - form_->bcview().setCancel(closePB); - form_->bcview().setRestore(restorePB); + form_->bc().setOK(savePB); + form_->bc().setApply(applyPB); + form_->bc().setCancel(closePB); + form_->bc().setRestore(restorePB); } @@ -2000,7 +2013,7 @@ void GuiPrefsDialog::updateRc(LyXRC const & rc) ///////////////////////////////////////////////////////////////////// -GuiPrefs::GuiPrefs(Dialog & parent) +GuiPrefs::GuiPrefs(GuiDialog & parent) : GuiView(parent, _("Preferences")) { } diff --git a/src/frontends/qt4/GuiPrefs.h b/src/frontends/qt4/GuiPrefs.h index 428c9287fe..493bef3999 100644 --- a/src/frontends/qt4/GuiPrefs.h +++ b/src/frontends/qt4/GuiPrefs.h @@ -361,7 +361,7 @@ private: class GuiPrefs : public GuiView { public: - GuiPrefs(Dialog &); + GuiPrefs(GuiDialog &); Converters & converters(); Formats & formats(); diff --git a/src/frontends/qt4/GuiPrint.cpp b/src/frontends/qt4/GuiPrint.cpp index 7aea586cce..aa861ab843 100644 --- a/src/frontends/qt4/GuiPrint.cpp +++ b/src/frontends/qt4/GuiPrint.cpp @@ -12,9 +12,8 @@ #include #include "GuiPrint.h" -#include "Qt2BC.h" -#include "qt_helpers.h" +#include "qt_helpers.h" #include "PrinterParams.h" #include "support/os.h" @@ -104,7 +103,7 @@ void GuiPrintDialog::pagerangeChanged() } -GuiPrint::GuiPrint(Dialog & parent) +GuiPrint::GuiPrint(GuiDialog & parent) : GuiView(parent, _("Print Document")) { } @@ -114,8 +113,8 @@ void GuiPrint::build_dialog() { dialog_.reset(new GuiPrintDialog(this)); - bcview().setOK(dialog_->printPB); - bcview().setCancel(dialog_->closePB); + bc().setOK(dialog_->printPB); + bc().setCancel(dialog_->closePB); } diff --git a/src/frontends/qt4/GuiPrint.h b/src/frontends/qt4/GuiPrint.h index b8f8c15d8b..494654a17e 100644 --- a/src/frontends/qt4/GuiPrint.h +++ b/src/frontends/qt4/GuiPrint.h @@ -46,7 +46,7 @@ public: /// friend class GuiPrintDialog; /// - GuiPrint(Dialog &); + GuiPrint(GuiDialog &); /// parent controller ControlPrint & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiRef.cpp b/src/frontends/qt4/GuiRef.cpp index b268a3f478..ab3a971073 100644 --- a/src/frontends/qt4/GuiRef.cpp +++ b/src/frontends/qt4/GuiRef.cpp @@ -12,11 +12,8 @@ #include #include "GuiRef.h" -#include "Qt2BC.h" #include "qt_helpers.h" -#include "ButtonController.h" - #include "insets/InsetRef.h" #include @@ -181,7 +178,7 @@ void GuiRefDialog::closeEvent(QCloseEvent * e) ///////////////////////////////////////////////////////////////////// -GuiRef::GuiRef(Dialog & parent) +GuiRef::GuiRef(GuiDialog & parent) : GuiView(parent, _("Cross-reference")), sort_(false), at_ref_(false) { @@ -192,15 +189,15 @@ void GuiRef::build_dialog() { dialog_.reset(new GuiRefDialog(this)); - bcview().setOK(dialog_->okPB); - bcview().setApply(dialog_->applyPB); - bcview().setCancel(dialog_->closePB); - bcview().addReadOnly(dialog_->refsLW); - bcview().addReadOnly(dialog_->sortCB); - bcview().addReadOnly(dialog_->nameED); - bcview().addReadOnly(dialog_->referenceED); - bcview().addReadOnly(dialog_->typeCO); - bcview().addReadOnly(dialog_->bufferCO); + bc().setOK(dialog_->okPB); + bc().setApply(dialog_->applyPB); + bc().setCancel(dialog_->closePB); + bc().addReadOnly(dialog_->refsLW); + bc().addReadOnly(dialog_->sortCB); + bc().addReadOnly(dialog_->nameED); + bc().addReadOnly(dialog_->referenceED); + bc().addReadOnly(dialog_->typeCO); + bc().addReadOnly(dialog_->bufferCO); restored_buffer_ = -1; } @@ -243,7 +240,7 @@ void GuiRef::update_contents() dialog_->bufferCO->setCurrentIndex(controller().getBufferNum()); updateRefs(); - bc().valid(false); + bc().setValid(false); } diff --git a/src/frontends/qt4/GuiRef.h b/src/frontends/qt4/GuiRef.h index 81288a9cb3..5d22ca336e 100644 --- a/src/frontends/qt4/GuiRef.h +++ b/src/frontends/qt4/GuiRef.h @@ -57,7 +57,7 @@ class GuiRef : public GuiView public: friend class GuiRefDialog; - GuiRef(Dialog &); + GuiRef(GuiDialog &); /// parent controller ControlRef & controller() diff --git a/src/frontends/qt4/GuiSearch.cpp b/src/frontends/qt4/GuiSearch.cpp index f936472384..42a74587b4 100644 --- a/src/frontends/qt4/GuiSearch.cpp +++ b/src/frontends/qt4/GuiSearch.cpp @@ -13,7 +13,6 @@ #include "GuiSearch.h" #include "qt_helpers.h" -#include "Qt2BC.h" #include #include @@ -130,7 +129,7 @@ void GuiSearchDialog::replaceallClicked() ///////////////////////////////////////////////////////////////////// -GuiSearch::GuiSearch(Dialog & parent) +GuiSearch::GuiSearch(GuiDialog & parent) : GuiView(parent, _("Find and Replace")) { } @@ -140,10 +139,10 @@ void GuiSearch::build_dialog() { dialog_.reset(new GuiSearchDialog(this)); - bcview().setCancel(dialog_->closePB); - bcview().addReadOnly(dialog_->replaceCO); - bcview().addReadOnly(dialog_->replacePB); - bcview().addReadOnly(dialog_->replaceallPB); + bc().setCancel(dialog_->closePB); + bc().addReadOnly(dialog_->replaceCO); + bc().addReadOnly(dialog_->replacePB); + bc().addReadOnly(dialog_->replaceallPB); dialog_->replacePB->setEnabled(false); dialog_->replaceallPB->setEnabled(false); diff --git a/src/frontends/qt4/GuiSearch.h b/src/frontends/qt4/GuiSearch.h index a022a66bba..d36b33b62a 100644 --- a/src/frontends/qt4/GuiSearch.h +++ b/src/frontends/qt4/GuiSearch.h @@ -50,7 +50,7 @@ public: /// friend class GuiSearchDialog; /// - GuiSearch(Dialog &); + GuiSearch(GuiDialog &); /// parent controller ControlSearch & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiSendto.cpp b/src/frontends/qt4/GuiSendto.cpp index 3015fd8a00..e635272be0 100644 --- a/src/frontends/qt4/GuiSendto.cpp +++ b/src/frontends/qt4/GuiSendto.cpp @@ -11,7 +11,6 @@ #include #include "GuiSendto.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include "Format.h" @@ -76,7 +75,7 @@ void GuiSendtoDialog::closeEvent(QCloseEvent * e) ///////////////////////////////////////////////////////////////////// -GuiSendto::GuiSendto(Dialog & parent) +GuiSendto::GuiSendto(GuiDialog & parent) : GuiView(parent, _("Send Document to Command")) { } @@ -87,9 +86,9 @@ void GuiSendto::build_dialog() dialog_.reset(new GuiSendtoDialog(this)); // Manage the ok, apply, restore and cancel/close buttons - bcview().setOK(dialog_->okPB); - bcview().setApply(dialog_->applyPB); - bcview().setCancel(dialog_->closePB); + bc().setOK(dialog_->okPB); + bc().setApply(dialog_->applyPB); + bc().setCancel(dialog_->closePB); } diff --git a/src/frontends/qt4/GuiSendto.h b/src/frontends/qt4/GuiSendto.h index efdd78b41f..8fd9faf32a 100644 --- a/src/frontends/qt4/GuiSendto.h +++ b/src/frontends/qt4/GuiSendto.h @@ -53,7 +53,7 @@ public: /// friend class GuiSendtoDialog; /// - GuiSendto(Dialog &); + GuiSendto(GuiDialog &); /// parent controller ControlSendto & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiShowFile.cpp b/src/frontends/qt4/GuiShowFile.cpp index 306b3efd5f..ab89573a43 100644 --- a/src/frontends/qt4/GuiShowFile.cpp +++ b/src/frontends/qt4/GuiShowFile.cpp @@ -11,7 +11,6 @@ #include #include "GuiShowFile.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include @@ -49,7 +48,7 @@ void GuiShowFileDialog::closeEvent(QCloseEvent * e) ///////////////////////////////////////////////////////////////////// -GuiShowFile::GuiShowFile(Dialog & parent) +GuiShowFile::GuiShowFile(GuiDialog & parent) : GuiView(parent, _("Show File")) { } @@ -59,7 +58,7 @@ void GuiShowFile::build_dialog() { dialog_.reset(new GuiShowFileDialog(this)); - bcview().setCancel(dialog_->closePB); + bc().setCancel(dialog_->closePB); } diff --git a/src/frontends/qt4/GuiShowFile.h b/src/frontends/qt4/GuiShowFile.h index 0c72c16428..5a219dd9a2 100644 --- a/src/frontends/qt4/GuiShowFile.h +++ b/src/frontends/qt4/GuiShowFile.h @@ -41,7 +41,7 @@ class GuiShowFile : public GuiView public: friend class GuiShowFileDialog; - GuiShowFile(Dialog &); + GuiShowFile(GuiDialog &); /// parent controller ControlShowFile & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiSpellchecker.cpp b/src/frontends/qt4/GuiSpellchecker.cpp index 15756d51c7..ddf0af2e62 100644 --- a/src/frontends/qt4/GuiSpellchecker.cpp +++ b/src/frontends/qt4/GuiSpellchecker.cpp @@ -11,7 +11,6 @@ #include #include "GuiSpellchecker.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include @@ -127,7 +126,7 @@ void GuiSpellcheckerDialog::reject() ///////////////////////////////////////////////////////////////////// -GuiSpellchecker::GuiSpellchecker(Dialog & parent) +GuiSpellchecker::GuiSpellchecker(GuiDialog & parent) : GuiView(parent, _("Spellchecker")) {} @@ -136,7 +135,7 @@ void GuiSpellchecker::build_dialog() { dialog_.reset(new GuiSpellcheckerDialog(this)); - bcview().setCancel(dialog_->closePB); + bc().setCancel(dialog_->closePB); dialog_->wordED->setReadOnly(true); } diff --git a/src/frontends/qt4/GuiSpellchecker.h b/src/frontends/qt4/GuiSpellchecker.h index 9c4a9258b5..cce38ec91d 100644 --- a/src/frontends/qt4/GuiSpellchecker.h +++ b/src/frontends/qt4/GuiSpellchecker.h @@ -55,7 +55,7 @@ class GuiSpellchecker : public GuiView public: friend class GuiSpellcheckerDialog; - GuiSpellchecker(Dialog &); + GuiSpellchecker(GuiDialog &); /// update from controller void partialUpdate(int id); diff --git a/src/frontends/qt4/GuiTabular.cpp b/src/frontends/qt4/GuiTabular.cpp index 050a487eac..c024504351 100644 --- a/src/frontends/qt4/GuiTabular.cpp +++ b/src/frontends/qt4/GuiTabular.cpp @@ -15,14 +15,10 @@ #include "GuiTabular.h" #include "GuiSetBorder.h" -#include "Qt2BC.h" - #include "LengthCombo.h" #include "Validator.h" #include "qt_helpers.h" -#include "controllers/ButtonController.h" - #include "support/convert.h" #include @@ -516,7 +512,7 @@ void GuiTabularDialog::ltLastFooterEmpty_clicked() ///////////////////////////////////////////////////////////////////// -GuiTabular::GuiTabular(Dialog & parent) +GuiTabular::GuiTabular(GuiDialog & parent) : GuiView(parent, _("Table Settings")) { } @@ -526,57 +522,53 @@ void GuiTabular::build_dialog() { dialog_.reset(new GuiTabularDialog(this)); - bcview().setCancel(dialog_->closePB); - - bcview().addReadOnly(dialog_->topspaceED); - bcview().addReadOnly(dialog_->topspaceUnit); - bcview().addReadOnly(dialog_->topspaceCO); - bcview().addReadOnly(dialog_->bottomspaceED); - bcview().addReadOnly(dialog_->bottomspaceUnit); - bcview().addReadOnly(dialog_->bottomspaceCO); - bcview().addReadOnly(dialog_->interlinespaceED); - bcview().addReadOnly(dialog_->interlinespaceUnit); - bcview().addReadOnly(dialog_->interlinespaceCO); - bcview().addReadOnly(dialog_->borderDefaultRB); - bcview().addReadOnly(dialog_->booktabsRB); - - bcview().addReadOnly(dialog_->multicolumnCB); - bcview().addReadOnly(dialog_->rotateCellCB); - bcview().addReadOnly(dialog_->rotateTabularCB); - bcview().addReadOnly(dialog_->specialAlignmentED); - bcview().addReadOnly(dialog_->widthED); - bcview().addReadOnly(dialog_->widthUnit); - bcview().addReadOnly(dialog_->hAlignCB); - bcview().addReadOnly(dialog_->vAlignCB); - bcview().addReadOnly(dialog_->borderSetPB); - bcview().addReadOnly(dialog_->borderUnsetPB); - bcview().addReadOnly(dialog_->borders); - bcview().addReadOnly(dialog_->longTabularCB); - bcview().addReadOnly(dialog_->headerStatusCB); - bcview().addReadOnly(dialog_->headerBorderAboveCB); - bcview().addReadOnly(dialog_->headerBorderBelowCB); - bcview().addReadOnly(dialog_->firstheaderStatusCB); - bcview().addReadOnly(dialog_->firstheaderBorderAboveCB); - bcview().addReadOnly(dialog_->firstheaderBorderBelowCB); - bcview().addReadOnly(dialog_->firstheaderNoContentsCB); - bcview().addReadOnly(dialog_->footerStatusCB); - bcview().addReadOnly(dialog_->footerBorderAboveCB); - bcview().addReadOnly(dialog_->footerBorderBelowCB); - bcview().addReadOnly(dialog_->lastfooterStatusCB); - bcview().addReadOnly(dialog_->lastfooterBorderAboveCB); - bcview().addReadOnly(dialog_->lastfooterBorderBelowCB); - bcview().addReadOnly(dialog_->lastfooterNoContentsCB); - bcview().addReadOnly(dialog_->newpageCB); + bc().setCancel(dialog_->closePB); + + bc().addReadOnly(dialog_->topspaceED); + bc().addReadOnly(dialog_->topspaceUnit); + bc().addReadOnly(dialog_->topspaceCO); + bc().addReadOnly(dialog_->bottomspaceED); + bc().addReadOnly(dialog_->bottomspaceUnit); + bc().addReadOnly(dialog_->bottomspaceCO); + bc().addReadOnly(dialog_->interlinespaceED); + bc().addReadOnly(dialog_->interlinespaceUnit); + bc().addReadOnly(dialog_->interlinespaceCO); + bc().addReadOnly(dialog_->borderDefaultRB); + bc().addReadOnly(dialog_->booktabsRB); + + bc().addReadOnly(dialog_->multicolumnCB); + bc().addReadOnly(dialog_->rotateCellCB); + bc().addReadOnly(dialog_->rotateTabularCB); + bc().addReadOnly(dialog_->specialAlignmentED); + bc().addReadOnly(dialog_->widthED); + bc().addReadOnly(dialog_->widthUnit); + bc().addReadOnly(dialog_->hAlignCB); + bc().addReadOnly(dialog_->vAlignCB); + bc().addReadOnly(dialog_->borderSetPB); + bc().addReadOnly(dialog_->borderUnsetPB); + bc().addReadOnly(dialog_->borders); + bc().addReadOnly(dialog_->longTabularCB); + bc().addReadOnly(dialog_->headerStatusCB); + bc().addReadOnly(dialog_->headerBorderAboveCB); + bc().addReadOnly(dialog_->headerBorderBelowCB); + bc().addReadOnly(dialog_->firstheaderStatusCB); + bc().addReadOnly(dialog_->firstheaderBorderAboveCB); + bc().addReadOnly(dialog_->firstheaderBorderBelowCB); + bc().addReadOnly(dialog_->firstheaderNoContentsCB); + bc().addReadOnly(dialog_->footerStatusCB); + bc().addReadOnly(dialog_->footerBorderAboveCB); + bc().addReadOnly(dialog_->footerBorderBelowCB); + bc().addReadOnly(dialog_->lastfooterStatusCB); + bc().addReadOnly(dialog_->lastfooterBorderAboveCB); + bc().addReadOnly(dialog_->lastfooterBorderBelowCB); + bc().addReadOnly(dialog_->lastfooterNoContentsCB); + bc().addReadOnly(dialog_->newpageCB); // initialize the length validator - addCheckedLineEdit(bcview(), dialog_->widthED, - dialog_->fixedWidthColLA); - addCheckedLineEdit(bcview(), dialog_->topspaceED, - dialog_->topspaceLA); - addCheckedLineEdit(bcview(), dialog_->bottomspaceED, - dialog_->bottomspaceLA); - addCheckedLineEdit(bcview(), dialog_->interlinespaceED, - dialog_->interlinespaceLA); + bc().addCheckedLineEdit(dialog_->widthED, dialog_->fixedWidthColLA); + bc().addCheckedLineEdit(dialog_->topspaceED, dialog_->topspaceLA); + bc().addCheckedLineEdit(dialog_->bottomspaceED, dialog_->bottomspaceLA); + bc().addCheckedLineEdit(dialog_->interlinespaceED, dialog_->interlinespaceLA); } @@ -668,7 +660,8 @@ void GuiTabular::update_contents() bool const isReadonly = bc().policy().isReadOnly(); dialog_->specialAlignmentED->setEnabled(!isReadonly); - Length::UNIT default_unit = controller().useMetricUnits() ? Length::CM : Length::IN; + Length::UNIT default_unit = + controller().useMetricUnits() ? Length::CM : Length::IN; dialog_->borderDefaultRB->setChecked(!tabular.useBookTabs()); dialog_->booktabsRB->setChecked(tabular.useBookTabs()); diff --git a/src/frontends/qt4/GuiTabular.h b/src/frontends/qt4/GuiTabular.h index d9bcc9abe2..7339d5c60b 100644 --- a/src/frontends/qt4/GuiTabular.h +++ b/src/frontends/qt4/GuiTabular.h @@ -83,7 +83,7 @@ class GuiTabular : public GuiView public: friend class GuiTabularDialog; - GuiTabular(Dialog &); + GuiTabular(GuiDialog &); /// parent controller ControlTabular & controller() diff --git a/src/frontends/qt4/GuiTabularCreate.cpp b/src/frontends/qt4/GuiTabularCreate.cpp index e98ab486fb..0f9a1a48fa 100644 --- a/src/frontends/qt4/GuiTabularCreate.cpp +++ b/src/frontends/qt4/GuiTabularCreate.cpp @@ -11,7 +11,6 @@ #include #include "GuiTabularCreate.h" -#include "Qt2BC.h" #include "EmptyTable.h" #include @@ -64,7 +63,7 @@ void GuiTabularCreateDialog::rowsChanged(int) ///////////////////////////////////////////////////////////////////// -GuiTabularCreate::GuiTabularCreate(Dialog & parent) +GuiTabularCreate::GuiTabularCreate(GuiDialog & parent) : GuiView(parent, _("Insert Table")) { } @@ -74,8 +73,8 @@ void GuiTabularCreate::build_dialog() { dialog_.reset(new GuiTabularCreateDialog(this)); - bcview().setOK(dialog_->okPB); - bcview().setCancel(dialog_->closePB); + bc().setOK(dialog_->okPB); + bc().setCancel(dialog_->closePB); } diff --git a/src/frontends/qt4/GuiTabularCreate.h b/src/frontends/qt4/GuiTabularCreate.h index 474f4e42e9..75056ca1fe 100644 --- a/src/frontends/qt4/GuiTabularCreate.h +++ b/src/frontends/qt4/GuiTabularCreate.h @@ -42,7 +42,7 @@ public: /// friend class GuiTabularCreateDialog; /// - GuiTabularCreate(Dialog &); + GuiTabularCreate(GuiDialog &); /// parent controller ControlTabularCreate & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiTexinfo.cpp b/src/frontends/qt4/GuiTexinfo.cpp index c9eea00434..2efa10b37a 100644 --- a/src/frontends/qt4/GuiTexinfo.cpp +++ b/src/frontends/qt4/GuiTexinfo.cpp @@ -11,7 +11,6 @@ #include #include "GuiTexinfo.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include "support/filetools.h" @@ -122,7 +121,7 @@ void GuiTexinfoDialog::enableViewPB() ///////////////////////////////////////////////////////////////////// -GuiTexinfo::GuiTexinfo(Dialog & parent) +GuiTexinfo::GuiTexinfo(GuiDialog & parent) : GuiView(parent, _("TeX Information")), warningPosted(false), activeStyle(ControlTexinfo::cls) { @@ -135,7 +134,7 @@ void GuiTexinfo::build_dialog() updateStyles(ControlTexinfo::cls); - bcview().setCancel(dialog_->closePB); + bc().setCancel(dialog_->closePB); } diff --git a/src/frontends/qt4/GuiTexinfo.h b/src/frontends/qt4/GuiTexinfo.h index 6e840d1f44..649b6644f2 100644 --- a/src/frontends/qt4/GuiTexinfo.h +++ b/src/frontends/qt4/GuiTexinfo.h @@ -52,7 +52,7 @@ public: /// friend class GuiTexinfoDialog; /// - GuiTexinfo(Dialog &); + GuiTexinfo(GuiDialog &); /// parent controller ControlTexinfo & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiThesaurus.cpp b/src/frontends/qt4/GuiThesaurus.cpp index dc076319f0..6d1490ca47 100644 --- a/src/frontends/qt4/GuiThesaurus.cpp +++ b/src/frontends/qt4/GuiThesaurus.cpp @@ -11,7 +11,6 @@ #include #include "GuiThesaurus.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include "debug.h" @@ -141,7 +140,7 @@ void GuiThesaurusDialog::updateLists() // ///////////////////////////////////////////////////////////////////// -GuiThesaurus::GuiThesaurus(Dialog & parent) +GuiThesaurus::GuiThesaurus(GuiDialog & parent) : GuiView(parent, _("Thesaurus")) { } @@ -151,10 +150,10 @@ void GuiThesaurus::build_dialog() { dialog_.reset(new GuiThesaurusDialog(this)); - bcview().setCancel(dialog_->closePB); - bcview().setApply(dialog_->replacePB); - bcview().addReadOnly(dialog_->replaceED); - bcview().addReadOnly(dialog_->replacePB); + bc().setCancel(dialog_->closePB); + bc().setApply(dialog_->replacePB); + bc().addReadOnly(dialog_->replaceED); + bc().addReadOnly(dialog_->replacePB); } diff --git a/src/frontends/qt4/GuiThesaurus.h b/src/frontends/qt4/GuiThesaurus.h index cb8f48ce1b..2a008be672 100644 --- a/src/frontends/qt4/GuiThesaurus.h +++ b/src/frontends/qt4/GuiThesaurus.h @@ -56,7 +56,7 @@ public: /// friend class GuiThesaurusDialog; /// - GuiThesaurus(Dialog &); + GuiThesaurus(GuiDialog &); /// parent controller ControlThesaurus & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiToc.cpp b/src/frontends/qt4/GuiToc.cpp index 7ec2110c1f..3749d117c7 100644 --- a/src/frontends/qt4/GuiToc.cpp +++ b/src/frontends/qt4/GuiToc.cpp @@ -14,12 +14,11 @@ #include "GuiToc.h" #include "TocModel.h" -#include "Qt2BC.h" #include "qt_helpers.h" #include "debug.h" -#include "controllers/ControlToc.h" +#include "ControlToc.h" #include diff --git a/src/frontends/qt4/GuiURL.cpp b/src/frontends/qt4/GuiURL.cpp index 518987cfa1..40761fb49f 100644 --- a/src/frontends/qt4/GuiURL.cpp +++ b/src/frontends/qt4/GuiURL.cpp @@ -11,9 +11,7 @@ #include #include "GuiURL.h" -#include "Qt2BC.h" #include "qt_helpers.h" -#include "ButtonController.h" #include #include @@ -56,7 +54,7 @@ void GuiURLDialog::closeEvent(QCloseEvent * e) -UrlView::UrlView(Dialog & parent) +UrlView::UrlView(GuiDialog & parent) : GuiView(parent, _("URL")) { } @@ -66,11 +64,11 @@ void UrlView::build_dialog() { dialog_.reset(new GuiURLDialog(this)); - bcview().setOK(dialog_->okPB); - bcview().setCancel(dialog_->closePB); - bcview().addReadOnly(dialog_->urlED); - bcview().addReadOnly(dialog_->nameED); - bcview().addReadOnly(dialog_->hyperlinkCB); + bc().setOK(dialog_->okPB); + bc().setCancel(dialog_->closePB); + bc().addReadOnly(dialog_->urlED); + bc().addReadOnly(dialog_->nameED); + bc().addReadOnly(dialog_->hyperlinkCB); } @@ -82,7 +80,7 @@ void UrlView::update_contents() dialog_->nameED->setText(toqstr(params["name"])); dialog_->hyperlinkCB->setChecked(params.getCmdName() != "url"); - bc().valid(isValid()); + bc().setValid(isValid()); } diff --git a/src/frontends/qt4/GuiURL.h b/src/frontends/qt4/GuiURL.h index 6c9c5ffee9..4015ae40e9 100644 --- a/src/frontends/qt4/GuiURL.h +++ b/src/frontends/qt4/GuiURL.h @@ -41,7 +41,7 @@ class UrlView : public GuiView { public: friend class QURLDialog; - UrlView(Dialog &); + UrlView(GuiDialog &); /// parent controller ControlCommand & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiVSpace.cpp b/src/frontends/qt4/GuiVSpace.cpp index 3473f82f79..df7c13da94 100644 --- a/src/frontends/qt4/GuiVSpace.cpp +++ b/src/frontends/qt4/GuiVSpace.cpp @@ -16,7 +16,6 @@ #include #include "GuiVSpace.h" -#include "Qt2BC.h" #include "LengthCombo.h" #include "qt_helpers.h" @@ -26,8 +25,8 @@ #include "Spacing.h" #include "VSpace.h" -#include "controllers/ControlVSpace.h" -#include "controllers/frontend_helpers.h" +#include "ControlVSpace.h" +#include "frontend_helpers.h" #include "support/lstrings.h" @@ -181,7 +180,7 @@ static VSpace setVSpaceFromWidgets(int spacing, } -GuiVSpace::GuiVSpace(Dialog & parent) +GuiVSpace::GuiVSpace(GuiDialog & parent) : GuiView(parent, _("Vertical Space Settings")) {} @@ -192,18 +191,18 @@ void GuiVSpace::build_dialog() dialog_.reset(new GuiVSpaceDialog(this)); // Manage the ok, apply, restore and cancel/close buttons - bcview().setOK(dialog_->okPB); - bcview().setApply(dialog_->applyPB); - bcview().setCancel(dialog_->closePB); + bc().setOK(dialog_->okPB); + bc().setApply(dialog_->applyPB); + bc().setCancel(dialog_->closePB); // disable for read-only documents - bcview().addReadOnly(dialog_->spacingCO); - bcview().addReadOnly(dialog_->valueLE); - bcview().addReadOnly(dialog_->unitCO); - bcview().addReadOnly(dialog_->keepCB); + bc().addReadOnly(dialog_->spacingCO); + bc().addReadOnly(dialog_->valueLE); + bc().addReadOnly(dialog_->unitCO); + bc().addReadOnly(dialog_->keepCB); // initialize the length validator - addCheckedLineEdit(bcview(), dialog_->valueLE, dialog_->valueL); + bc().addCheckedLineEdit(dialog_->valueLE, dialog_->valueL); // remove the %-items from the unit choice dialog_->unitCO->noPercents(); diff --git a/src/frontends/qt4/GuiVSpace.h b/src/frontends/qt4/GuiVSpace.h index 9cc1f74a7a..708ffdd92a 100644 --- a/src/frontends/qt4/GuiVSpace.h +++ b/src/frontends/qt4/GuiVSpace.h @@ -50,7 +50,7 @@ public: /// friend class GuiVSpaceDialog; /// - GuiVSpace(Dialog &); + GuiVSpace(GuiDialog &); /// parent controller ControlVSpace & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/GuiViewSource.cpp b/src/frontends/qt4/GuiViewSource.cpp index e22b0652d1..1ea2214125 100644 --- a/src/frontends/qt4/GuiViewSource.cpp +++ b/src/frontends/qt4/GuiViewSource.cpp @@ -160,7 +160,7 @@ void LaTeXHighlighter::highlightBlock(QString const & text) } -GuiViewSource::GuiViewSource(Dialog & parent) +GuiViewSource::GuiViewSource(GuiDialog & parent) : ControlViewSource(parent) { document_ = new QTextDocument(this); diff --git a/src/frontends/qt4/GuiViewSource.h b/src/frontends/qt4/GuiViewSource.h index 1f3e56e769..9345936023 100644 --- a/src/frontends/qt4/GuiViewSource.h +++ b/src/frontends/qt4/GuiViewSource.h @@ -15,6 +15,7 @@ #define GUIVIEWSOURCE_H #include "ControlViewSource.h" +#include "GuiDialog.h" #include "Application.h" #include "ui_ViewSourceUi.h" @@ -63,7 +64,7 @@ private: class GuiViewSource : public QObject, public ControlViewSource { public: /// - GuiViewSource(Dialog &); + GuiViewSource(GuiDialog &); /// QTextDocument * document() { return document_; } /// diff --git a/src/frontends/qt4/GuiWrap.cpp b/src/frontends/qt4/GuiWrap.cpp index af19e66503..d6718eae43 100644 --- a/src/frontends/qt4/GuiWrap.cpp +++ b/src/frontends/qt4/GuiWrap.cpp @@ -11,7 +11,6 @@ #include #include "GuiWrap.h" -#include "Qt2BC.h" #include "LengthCombo.h" #include "qt_helpers.h" @@ -75,7 +74,7 @@ void GuiWrapDialog::change_adaptor() // ///////////////////////////////////////////////////////////////////// -GuiWrap::GuiWrap(Dialog & parent) +GuiWrap::GuiWrap(GuiDialog & parent) : GuiView(parent, _("Text Wrap Settings")) { } @@ -85,14 +84,14 @@ void GuiWrap::build_dialog() { dialog_.reset(new GuiWrapDialog(this)); - bcview().setRestore(dialog_->restorePB); - bcview().setOK(dialog_->okPB); - bcview().setApply(dialog_->applyPB); - bcview().setCancel(dialog_->closePB); + bc().setRestore(dialog_->restorePB); + bc().setOK(dialog_->okPB); + bc().setApply(dialog_->applyPB); + bc().setCancel(dialog_->closePB); - bcview().addReadOnly(dialog_->widthED); - bcview().addReadOnly(dialog_->unitsLC); - bcview().addReadOnly(dialog_->valignCO); + bc().addReadOnly(dialog_->widthED); + bc().addReadOnly(dialog_->unitsLC); + bc().addReadOnly(dialog_->valignCO); } diff --git a/src/frontends/qt4/GuiWrap.h b/src/frontends/qt4/GuiWrap.h index 8bdf588c86..2956f7ddcf 100644 --- a/src/frontends/qt4/GuiWrap.h +++ b/src/frontends/qt4/GuiWrap.h @@ -42,7 +42,7 @@ class GuiWrap : public GuiView public: friend class GuiWrapDialog; - GuiWrap(Dialog &); + GuiWrap(GuiDialog &); /// parent controller ControlWrap & controller() { return static_cast(this->getController()); } diff --git a/src/frontends/qt4/Makefile.am b/src/frontends/qt4/Makefile.am index ccf241fa05..ff01af670c 100644 --- a/src/frontends/qt4/Makefile.am +++ b/src/frontends/qt4/Makefile.am @@ -38,6 +38,7 @@ SOURCEFILES = \ Action.cpp \ alert_pimpl.cpp \ BulletsModule.cpp \ + ButtonController.cpp \ ColorCache.cpp \ Dialogs.cpp \ EmptyTable.cpp \ @@ -57,6 +58,7 @@ SOURCEFILES = \ GuiCommandBuffer.cpp \ GuiCommandEdit.cpp \ GuiDelimiter.cpp \ + GuiDialog.cpp \ GuiDialogView.cpp \ GuiDocument.cpp \ GuiEmbeddedFiles.cpp \ @@ -110,7 +112,6 @@ SOURCEFILES = \ LengthCombo.cpp \ LyXFileDialog.cpp \ PanelStack.cpp \ - Qt2BC.cpp \ qt_helpers.cpp \ socket_callback.cpp \ TocModel.cpp \ @@ -118,13 +119,13 @@ SOURCEFILES = \ Validator.cpp NOMOCHEADER = \ + ButtonController.h \ GuiClipboard.h \ GuiFontLoader.h \ GuiFontMetrics.h \ GuiSelection.h \ GuiImage.h \ GuiPainter.h \ - Qt2BC.h \ qt_helpers.h MOCHEADER = \ @@ -147,6 +148,7 @@ MOCHEADER = \ GuiCommandBuffer.h \ GuiCommandEdit.h \ GuiDelimiter.h \ + GuiDialog.h \ GuiDialogView.h \ GuiDocument.h \ GuiEmbeddedFiles.h \ -- 2.39.2