if (it != dialogs_.end())
return it->second.get();
- dialogs_[name] = build(name);
+ dialogs_[name].reset(build(name));
return dialogs_[name].get();
}
///
typedef boost::shared_ptr<Dialog> DialogPtr;
///
- DialogPtr build(std::string const & name);
+ Dialog * build(std::string const & name);
///
LyXView & lyxview_;
+++ /dev/null
-/**
- * \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 <config.h>
-
-#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
+++ /dev/null
-// -*- 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
+++ /dev/null
-/**
- * \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 <config.h>
-
-#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
+++ /dev/null
-// -*- 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 <boost/scoped_ptr.hpp>
-#include <boost/noncopyable.hpp>
-
-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<BCView> view_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // BUTTONCONTROLLER_H
#include <config.h>
#include "ControlCharacter.h"
-#include "ButtonController.h"
#include "Buffer.h"
#include "BufferParams.h"
getBar() != IGNORE ||
getColor() != Color::ignore ||
font_->language() != ignore_language)
- dialog().bc().valid();
+ dialog().setButtonsValid(true);
return true;
}
#include "Buffer.h"
#include "BufferParams.h"
#include "BufferView.h"
-#include "ButtonController.h"
#include "Cursor.h"
#include "FuncRequest.h"
#include "Lexer.h"
// 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;
}
#include "ControlPrint.h"
-#include "ButtonController.h"
#include "frontend_helpers.h"
#include "Buffer.h"
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;
}
#include <config.h>
#include "ControlVSpace.h"
-#include "ButtonController.h"
#include "FuncRequest.h"
#include "insets/InsetVSpace.h"
InsetVSpaceMailer::string2params(data, params_);
// so that the user can press Ok
- dialog().bc().valid();
+ dialog().setButtonsValid(true);
return true;
}
#include "Dialog.h"
-#include "ButtonController.h"
-#include "BCView.h"
-
#include "frontends/LyXView.h"
#include "debug.h"
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)
return;
}
- bc().readOnly(kernel().isBufferReadonly());
+ preShow();
view().show();
-
- // The widgets may not be valid, so refresh the button controller
- bc().refresh();
+ postShow();
}
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()
+{
}
}
-ButtonController & Dialog::bc() const
-{
- BOOST_ASSERT(bc_ptr_.get());
- return *bc_ptr_.get();
-}
-
-
void Dialog::setController(Controller * i)
{
BOOST_ASSERT(i && !controller_ptr_.get());
}
-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)
namespace lyx {
namespace frontend {
-class ButtonController;
class LyXView;
/** \c Dialog collects the different parts of a Model-Controller-View
/// \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.
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.
*/
*/
//@{
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<ButtonController> bc_ptr_;
boost::scoped_ptr<Controller> controller_ptr_;
boost::scoped_ptr<View> view_ptr_;
};
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:
pkglib_LTLIBRARIES = liblyxcontrollers.la
SOURCEFILES = \
+ Dialog.cpp \
Dialog.cpp \
Kernel.cpp \
- BCView.cpp \
- ButtonController.cpp \
ButtonPolicy.cpp \
ControlAboutlyx.cpp \
ControlBibtex.cpp \
HEADERFILES = \
Kernel.h \
- ButtonController.h \
ButtonPolicy.h \
ControlAboutlyx.h \
ControlBibtex.h \
#include <utility>
#include <vector>
#include <string>
-#include <boost/bind.hpp>
-#include <algorithm>
-#include <utility>
-#include <map>
-
-class Buffer;
class Color_color;
/** Functions of use to the character GUI controller and view */
namespace lyx {
+
+namespace support { class FileFilterList; }
+
namespace frontend {
///
/// sort colors for the gui
std::vector<Color_color> const getSortedColors(std::vector<Color_color> 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.
std::vector<docstring> const getLatexUnits();
-/** Functions to extract vectors of the first and second elems from a
- vector<pair<A,B> >
-*/
-template<class Pair>
-std::vector<typename Pair::first_type> const
-getFirst(std::vector<Pair> const & pr)
-{
- std::vector<typename Pair::first_type> tmp(pr.size());
- std::transform(pr.begin(), pr.end(), tmp.begin(),
- boost::bind(&Pair::first, _1));
- return tmp;
-}
-
-template<class Pair>
-std::vector<typename Pair::second_type> const
-getSecond(std::vector<Pair> const & pr)
-{
- std::vector<typename Pair::second_type> 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.
*/
--- /dev/null
+/**
+ * \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 <config.h>
+
+#include "ButtonController.h"
+#include "debug.h"
+#include "qt_helpers.h"
+
+#include <QPushButton>
+#include <QLineEdit>
+#include <QLabel>
+#include <QValidator>
+
+namespace lyx {
+namespace frontend {
+
+ButtonController::ButtonController()
+ : okay_(0), apply_(0), cancel_(0), restore_(0),
+ policy_(ButtonPolicy::IgnorantPolicy)
+{}
+
+
+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;
+
+ bool const all_valid = checkWidgets();
+
+ if (okay_) {
+ bool const enabled =
+ all_valid && policy().buttonStatus(ButtonPolicy::OKAY);
+ okay_->setEnabled(enabled);
+ }
+ if (apply_) {
+ bool const enabled =
+ all_valid && policy().buttonStatus(ButtonPolicy::APPLY);
+ apply_->setEnabled(enabled);
+ }
+ if (restore_) {
+ bool const enabled =
+ all_valid && policy().buttonStatus(ButtonPolicy::RESTORE);
+ restore_->setEnabled(enabled);
+ }
+ if (cancel_) {
+ bool const enabled = policy().buttonStatus(ButtonPolicy::CANCEL);
+ if (enabled)
+ cancel_->setText(toqstr(_("Cancel")));
+ else
+ cancel_->setText(toqstr(_("Close")));
+ }
+}
+
+
+void ButtonController::refreshReadOnly() const
+{
+ if (read_only_.empty())
+ return;
+
+ bool const enable = !policy().isReadOnly();
+
+ Widgets::const_iterator end = read_only_.end();
+ Widgets::const_iterator iter = read_only_.begin();
+ for (; iter != end; ++iter)
+ setWidgetEnabled(*iter, enable);
+}
+
+
+void ButtonController::setWidgetEnabled(QWidget * obj, bool enabled) const
+{
+ if (QLineEdit * le = qobject_cast<QLineEdit*>(obj))
+ le->setReadOnly(!enabled);
+ else
+ obj->setEnabled(enabled);
+
+ obj->setFocusPolicy(enabled ? Qt::StrongFocus : Qt::NoFocus);
+}
+
+
+void ButtonController::addCheckedLineEdit(QLineEdit * input, QWidget * label)
+{
+ checked_widgets.push_back(CheckedLineEdit(input, label));
+}
+
+
+bool ButtonController::checkWidgets() const
+{
+ bool valid = true;
+
+ CheckedWidgetList::const_iterator it = checked_widgets.begin();
+ CheckedWidgetList::const_iterator end = checked_widgets.end();
+
+ for (; it != end; ++it)
+ valid &= it->check();
+
+ // return valid status after checking ALL widgets
+ return valid;
+}
+
+
+//////////////////////////////////////////////////////////////
+//
+// CheckedLineEdit
+//
+//////////////////////////////////////////////////////////////
+
+static void setWarningColor(QWidget * widget)
+{
+ QPalette pal = widget->palette();
+ pal.setColor(QPalette::Active, QPalette::Foreground, QColor(255, 0, 0));
+ widget->setPalette(pal);
+}
+
+
+CheckedLineEdit::CheckedLineEdit(QLineEdit * input, QWidget * label)
+ : input_(input), label_(label)
+{}
+
+
+bool CheckedLineEdit::check() const
+{
+ QValidator const * validator = input_->validator();
+ if (!validator)
+ return true;
+
+ QString t = input_->text();
+ int p = 0;
+ bool const valid = validator->validate(t, p) == QValidator::Acceptable;
+
+ // Visual feedback.
+ if (valid)
+ input_->setPalette(QPalette());
+ else
+ setWarningColor(input_);
+
+ if (!label_) {
+ if (valid)
+ label_->setPalette(QPalette());
+ else
+ setWarningColor(label_);
+ }
+
+ return valid;
+}
+
+} // namespace frontend
+} // namespace lyx
--- /dev/null
+// -*- 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 "gettext.h"
+
+class QWidget;
+class QPushButton;
+class QLineEdit;
+
+namespace lyx {
+namespace frontend {
+
+class CheckedLineEdit
+{
+public:
+ CheckedLineEdit(QLineEdit * input, QWidget * label = 0);
+ bool check() const;
+
+private:
+ // non-owned
+ QLineEdit * input_;
+ QWidget * label_;
+};
+
+/** General purpose button controller for up to four buttons.
+ Controls the activation of the OK, Apply and Cancel buttons.
+ 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.
+*/
+
+
+/** \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_; }
+ //@}
+
+ ///
+ 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.
+ */
+ void setOK(QPushButton * obj) { okay_ = obj; }
+ void setApply(QPushButton * obj) { apply_ = obj; }
+ void setCancel(QPushButton * obj) { cancel_ = obj; }
+ void setRestore(QPushButton * obj) { restore_ = obj; }
+ //@}
+
+ /** Add a pointer to the list of widgets whose activation
+ * state is dependent upon the read-only status of the
+ * underlying buffer.
+ */
+ void addReadOnly(QWidget * obj) { read_only_.push_back(obj); }
+
+ /** Add a widget to the list of all widgets whose validity should
+ * be checked explicitly when the buttons are refreshed.
+ */
+ void addCheckedLineEdit(QLineEdit * input, QWidget * label = 0);
+
+protected:
+ /// \return true if all CheckedWidgets are in a valid state.
+ bool checkWidgets() const;
+
+private:
+ typedef std::list<CheckedLineEdit> CheckedWidgetList;
+ CheckedWidgetList checked_widgets;
+
+private:
+ /// Updates the widget sensitivity (enabled/disabled)
+ void setWidgetEnabled(QWidget *, bool enabled) const;
+
+ QPushButton * okay_;
+ QPushButton * apply_;
+ QPushButton * cancel_;
+ QPushButton * restore_;
+
+ typedef std::list<QWidget *> Widgets;
+ Widgets read_only_;
+
+private:
+ ButtonPolicy policy_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // BUTTONCONTROLLER_H
#include <config.h>
#include "Dialogs.h"
+#include "GuiDialog.h"
-#include "Qt2BC.h"
#include "ButtonController.h"
#include "DockView.h"
#include "GuiView.h"
}
-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));
#include <config.h>
#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"
namespace frontend {
-GuiAbout::GuiAbout(Dialog & parent)
+GuiAbout::GuiAbout(GuiDialog & parent)
: GuiView<GuiAboutDialog>(parent, _("About LyX"))
{
}
dialog_->setMinimumSize(dialog_->sizeHint());
// Manage the cancel/close button
- bcview().setCancel(dialog_->closePB);
- bc().refresh();
+ bc().setCancel(dialog_->closePB);
+ //FIXME bc().refresh();
}
} // namespace frontend
class GuiAbout : public GuiView<GuiAboutDialog>
{
public:
- GuiAbout(Dialog &);
+ GuiAbout(GuiDialog &);
/// parent controller
ControlAboutlyx & controller()
{ return static_cast<ControlAboutlyx &>(this->getController()); }
#include <config.h>
#include "GuiBibitem.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include <QCloseEvent>
/////////////////////////////////////////////////////////////////////
-GuiBibitem::GuiBibitem(Dialog & parent)
+GuiBibitem::GuiBibitem(GuiDialog & parent)
: GuiView<GuiBibitemDialog>(parent, _("Bibliography Entry Settings"))
{
}
{
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);
}
{
public:
///
- GuiBibitem(Dialog &);
+ GuiBibitem(GuiDialog &);
/// parent controller
ControlCommand & controller()
{ return static_cast<ControlCommand &>(this->getController()); }
#include "GuiBibtex.h"
#include "ui_BibtexAddUi.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include "Validator.h"
#include "LyXRC.h"
this, SLOT(addPressed()));
add_ = new UiDialog<Ui::BibtexAddUi>(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()));
this, SLOT(browseBibPressed()));
connect(add_->closePB, SIGNAL(clicked()),
add_, SLOT(reject()));
-
}
// 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);
}
void GuiBibtexDialog::addPressed()
{
- add_bc_.valid(false);
+ add_bc_.setValid(false);
add_->exec();
}
void GuiBibtexDialog::availableChanged()
{
- add_bc_.valid(true);
+ add_bc_.setValid(true);
}
/////////////////////////////////////////////////////////////////////
//
-// QBibTex
+// GuiBibTex
//
/////////////////////////////////////////////////////////////////////
-GuiBibtex::GuiBibtex(Dialog & parent)
+GuiBibtex::GuiBibtex(GuiDialog & parent)
: GuiView<GuiBibtexDialog>(parent, _("BibTeX Bibliography"))
{
}
{
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);
}
public:
friend class GuiBibtexDialog;
- GuiBibtex(Dialog &);
+ GuiBibtex(GuiDialog &);
/// parent controller
ControlBibtex & controller()
{ return static_cast<ControlBibtex &>(this->getController()); }
#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"
//////////////////////////////////////////////////////////////////
-GuiBox::GuiBox(Dialog & parent)
+GuiBox::GuiBox(GuiDialog & parent)
: GuiView<GuiBoxDialog>(parent, _("Box Settings"))
{}
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);
}
{
public:
///
- GuiBox(Dialog &);
+ GuiBox(GuiDialog &);
/// parent controller
ControlBox & controller()
{ return static_cast<ControlBox &>(this->getController()); }
#include <config.h>
#include "GuiBranch.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include "BranchList.h"
/////////////////////////////////////////////////////////////////////
-GuiBranch::GuiBranch(Dialog & parent)
+GuiBranch::GuiBranch(GuiDialog & parent)
: GuiView<GuiBranchDialog>(parent, _("Branch Settings"))
{}
{
dialog_.reset(new GuiBranchDialog(this));
- bcview().setOK(dialog_->okPB);
- bcview().setCancel(dialog_->closePB);
+ bc().setOK(dialog_->okPB);
+ bc().setCancel(dialog_->closePB);
}
{
public:
/// Constructor
- GuiBranch(Dialog &);
+ GuiBranch(GuiDialog &);
/// parent controller
ControlBranch & controller()
{ return static_cast<ControlBranch &>(this->getController()); }
#include <config.h>
#include "GuiChanges.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include "support/lstrings.h"
/////////////////////////////////////////////////////////////////////
-GuiChanges::GuiChanges(Dialog & parent)
+GuiChanges::GuiChanges(GuiDialog & parent)
: GuiView<GuiChangesDialog>(parent, _("Merge Changes"))
{
}
{
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);
}
{
public:
///
- GuiChanges(Dialog &);
+ GuiChanges(GuiDialog &);
/// parent controller
ControlChanges & controller()
{ return static_cast<ControlChanges &>(this->getController()); }
#include <config.h>
#include "GuiCharacter.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include "frontend_helpers.h"
#include "Color.h"
/////////////////////////////////////////////////////////////////////
-GuiCharacter::GuiCharacter(Dialog & parent)
+GuiCharacter::GuiCharacter(GuiDialog & parent)
: GuiView<GuiCharacterDialog>(parent, _("Text Style"))
{
}
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)
public:
friend class GuiCharacterDialog;
- GuiCharacter(Dialog &);
+ GuiCharacter(GuiDialog &);
/// parent controller
ControlCharacter & controller()
{ return static_cast<ControlCharacter &>(this->getController()); }
//
///////////////////////////////////////////////////////////////////////
-GuiCitation::GuiCitation(Dialog & parent)
+GuiCitation::GuiCitation(GuiDialog & parent)
: ControlCitation(parent)
{
}
#ifndef GUICITATION_H
#define GUICITATION_H
-#include "Dialog.h"
+#include "GuiDialog.h"
#include "GuiSelectionManager.h"
#include "ui_CitationUi.h"
#include "ControlCitation.h"
{
public:
///
- GuiCitation(Dialog &);
+ GuiCitation(GuiDialog &);
virtual ~GuiCitation() {}
virtual bool initialiseParams(std::string const & data);
} // namespace anon
-GuiDelimiter::GuiDelimiter(Dialog & parent)
+GuiDelimiter::GuiDelimiter(GuiDialog & parent)
: GuiView<GuiDelimiterDialog>(parent, _("Math Delimiter"))
{}
public:
friend class GuiDelimiterDialog;
///
- GuiDelimiter(Dialog &);
+ GuiDelimiter(GuiDialog &);
/// parent controller
ControlMath & controller()
{ return static_cast<ControlMath &>(this->getController()); }
--- /dev/null
+/**
+ * \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 <config.h>
+
+#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
--- /dev/null
+// -*- 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
#include <config.h>
#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<Qt2BC &>(dialog().bc().view());
+ return parent_.bc();
}
void GuiDialogView::show()
{
- if (!form()) {
+ if (!form())
build();
- }
QSize const sizeHint = form()->sizeHint();
if (sizeHint.height() >= 0 && sizeHint.width() >= 0)
{
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
#ifndef GUIDIALOGVIEW_H
#define GUIDIALOGVIEW_H
-#include "Dialog.h"
+#include "GuiDialog.h"
#include <boost/scoped_ptr.hpp>
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() {}
///
virtual void changed();
///
- Qt2BC & bcview();
+ ButtonController & bc();
protected:
/// build the actual dialog
/// are we updating ?
bool updating_;
+ GuiDialog & parent_;
+
public Q_SLOTS:
// dialog closed from WM
void slotWMHide();
template <class GUIDialog>
class GuiView : public GuiDialogView {
protected:
- GuiView(Dialog & p, docstring const & t)
+ GuiView(GuiDialog & p, docstring const & t)
: GuiDialogView(p, t)
{}
#include "FloatPlacement.h"
#include "LengthCombo.h"
#include "PanelStack.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include "Validator.h"
#include <QScrollBar>
#include <QTextCursor>
-#include <map>
+#include <algorithm>
using lyx::support::token;
using lyx::support::bformat;
//
/////////////////////////////////////////////////////////////////////
+template<class Pair>
+std::vector<typename Pair::second_type> const
+getSecond(std::vector<Pair> const & pr)
+{
+ std::vector<typename Pair::second_type> 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);
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<Ui::TextLayoutUi>;
Spacing::Other, qt_("Custom"));
// initialize the length validator
- addCheckedLineEdit(form_->bcview(), textLayoutModule->skipLE);
+ form_->bc().addCheckedLineEdit(textLayoutModule->skipLE);
fontModule = new UiWidget<Ui::FontUi>;
// fonts
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
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);
biblioModule->citeStyleCO->setCurrentIndex(0);
-
mathsModule = new UiWidget<Ui::MathsUi>;
connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)),
mathsModule->amsCB, SLOT(setDisabled(bool)));
/////////////////////////////////////////////////////////////////////
-GuiDocument::GuiDocument(Dialog & parent)
+GuiDocument::GuiDocument(GuiDialog & parent)
: GuiView<GuiDocumentDialog>(parent, _("Document Settings"))
{}
friend class GuiDocumentDialog;
- GuiDocument(Dialog &);
+ GuiDocument(GuiDialog &);
void showPreamble();
/// parent controller
#include <config.h>
#include "GuiERT.h"
-#include "Qt2BC.h"
+#include "gettext.h"
#include <QRadioButton>
#include <QPushButton>
//
/////////////////////////////////////////////////////////////////////
-GuiERT::GuiERT(Dialog & parent)
+GuiERT::GuiERT(GuiDialog & parent)
: GuiView<GuiERTDialog>(parent, _("TeX Code Settings"))
{
}
{
dialog_.reset(new GuiERTDialog(this));
- bcview().setOK(dialog_->okPB);
- bcview().setCancel(dialog_->closePB);
+ bc().setOK(dialog_->okPB);
+ bc().setCancel(dialog_->closePB);
}
#include "ControlERT.h"
#include "ui_ERTUi.h"
-#include <QCloseEvent>
#include <QDialog>
namespace lyx {
{
public:
/// constructor
- GuiERT(Dialog &);
+ GuiERT(GuiDialog &);
/// parent controller
ControlERT & controller()
{ return static_cast<ControlERT &>(this->getController()); }
#include <config.h>
#include "GuiEmbeddedFiles.h"
-#include "Qt2BC.h"
-
#include "debug.h"
namespace lyx {
#include <config.h>
#include "GuiErrorList.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include <QListWidget>
/////////////////////////////////////////////////////////////////////
-GuiErrorList::GuiErrorList(Dialog & parent)
+GuiErrorList::GuiErrorList(GuiDialog & parent)
: GuiView<GuiErrorListDialog>(parent, docstring())
{}
void GuiErrorList::build_dialog()
{
dialog_.reset(new GuiErrorListDialog(this));
- bcview().setCancel(dialog_->closePB);
+ bc().setCancel(dialog_->closePB);
}
public:
friend class GuiErrorListDialog;
- GuiErrorList(Dialog &);
+ GuiErrorList(GuiDialog &);
/// parent controller
ControlErrorList & controller()
{ return static_cast<ControlErrorList &>(this->getController()); }
#include "lengthcommon.h"
#include "LyXRC.h"
-#include "controllers/ButtonController.h"
-
#include "insets/ExternalTemplate.h"
#include "insets/InsetExternal.h"
#include "support/lyxlib.h"
#include "GuiExternal.h"
-#include "Qt2BC.h"
#include "LengthCombo.h"
#include "qt_helpers.h"
} // namespace anon
-GuiExternal::GuiExternal(Dialog & parent)
+GuiExternal::GuiExternal(GuiDialog & parent)
: GuiView<GuiExternalDialog>(parent, _("External Material"))
{}
{
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<string> templates(controller().getTemplates());
public:
friend class GuiExternalDialog;
- GuiExternal(Dialog &);
+ GuiExternal(GuiDialog &);
/// parent controller
ControlExternal & controller()
{ return static_cast<ControlExternal &>(this->getController()); }
#include <config.h>
#include "GuiFloat.h"
-#include "Qt2BC.h"
#include "FloatPlacement.h"
#include "insets/InsetFloat.h"
}
-GuiFloat::GuiFloat(Dialog & parent)
+GuiFloat::GuiFloat(GuiDialog & parent)
: GuiView<GuiFloatDialog>(parent, _("Float Settings"))
{
}
{
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);
}
///
friend class GuiFloatDialog;
///
- GuiFloat(Dialog &);
+ GuiFloat(GuiDialog &);
/// parent controller
ControlFloat & controller()
{ return static_cast<ControlFloat &>(this->getController()); }
#include "LengthCombo.h"
#include "lengthcommon.h"
#include "LyXRC.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include "Validator.h"
#include "support/lyxlib.h"
#include "support/os.h"
-#include <cmath>
-
-#include "insets/InsetGraphicsParams.h"
-
#include <QCheckBox>
#include <QCloseEvent>
#include <QLabel>
#include <QPushButton>
#include <QValidator>
+#include <algorithm>
+#include <cmath>
using lyx::support::float_equal;
using lyx::support::token;
namespace frontend {
+template<class Pair>
+std::vector<typename Pair::first_type> const
+getFirst(std::vector<Pair> const & pr)
+{
+ std::vector<typename Pair::first_type> tmp(pr.size());
+ std::transform(pr.begin(), pr.end(), tmp.begin(),
+ boost::bind(&Pair::first, _1));
+ return tmp;
+}
+
GuiGraphicsDialog::GuiGraphicsDialog(GuiGraphics * form)
: form_(form)
{
}
-GuiGraphics::GuiGraphics(Dialog & parent)
+GuiGraphics::GuiGraphics(GuiDialog & parent)
: GuiView<GuiGraphicsDialog>(parent, _("Graphics"))
{
}
{
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);
}
return (cit != v.end()) ? int(cit - v.begin()) : 0;
}
+template<class Pair>
+std::vector<typename Pair::second_type> const
+getSecond(std::vector<Pair> const & pr)
+{
+ std::vector<typename Pair::second_type> tmp(pr.size());
+ std::transform(pr.begin(), pr.end(), tmp.begin(),
+ boost::bind(&Pair::second, _1));
+ return tmp;
+}
+
void GuiGraphics::update_contents()
{
///
friend class GuiGraphicsDialog;
///
- GuiGraphics(Dialog &);
+ GuiGraphics(GuiDialog &);
/// parent controller
ControlGraphics & controller()
{ return static_cast<ControlGraphics &>(this->getController()); }
#include "GuiInclude.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include "LyXRC.h"
/////////////////////////////////////////////////////////////////////
-GuiInclude::GuiInclude(Dialog & parent)
+GuiInclude::GuiInclude(GuiDialog & parent)
: GuiView<GuiIncludeDialog>(parent, _("Child Document"))
{}
{
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);
}
///
friend class GuiIncludeDialog;
///
- GuiInclude(Dialog &);
+ GuiInclude(GuiDialog &);
/// parent controller
ControlInclude & controller()
{ return static_cast<ControlInclude &>(this->getController()); }
#include <config.h>
+#include "GuiIndex.h"
+
#include "debug.h"
#include "qt_helpers.h"
-#include "GuiIndex.h"
-#include "Qt2BC.h"
-#include "ButtonController.h"
-
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
/////////////////////////////////////////////////////////////////////
-GuiIndex::GuiIndex(Dialog & parent, docstring const & title, QString const & label)
+GuiIndex::GuiIndex(GuiDialog & parent, docstring const & title,
+ QString const & label)
: GuiView<GuiIndexDialog>(parent, title), label_(label)
{
}
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);
}
docstring const contents = controller().params()["name"];
dialog_->keywordED->setText(toqstr(contents));
- bc().valid(!contents.empty());
+ bc().setValid(!contents.empty());
}
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<ControlCommand &>(this->getController()); }
#include <config.h>
#include "GuiListings.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include "insets/InsetListingsParams.h"
#include "debug.h"
/////////////////////////////////////////////////////////////////////
-GuiListings::GuiListings(Dialog & parent)
+GuiListings::GuiListings(GuiDialog & parent)
: GuiView<GuiListingsDialog>(parent, _("Program Listing Settings"))
{
}
{
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."));
public:
friend class GuiListingsDialog;
- GuiListings(Dialog &);
+ GuiListings(GuiDialog &);
/// parent controller
ControlListings & controller()
{ return static_cast<ControlListings &>(this->getController()); }
/////////////////////////////////////////////////////////////////////
-GuiLog::GuiLog(Dialog & parent)
+GuiLog::GuiLog(GuiDialog & parent)
: GuiView<GuiLogDialog>(parent, docstring())
{}
///
friend class GuiLogDialog;
///
- GuiLog(Dialog &);
+ GuiLog(GuiDialog &);
/// parent controller
ControlLog & controller()
{ return static_cast<ControlLog &>(this->getController()); }
namespace lyx {
namespace frontend {
-GuiMathMatrix::GuiMathMatrix(Dialog & parent)
+GuiMathMatrix::GuiMathMatrix(GuiDialog & parent)
: GuiView<GuiMathMatrixDialog>(parent, _("Math Matrix"))
{}
public:
friend class GuiMathMatrixDialog;
- GuiMathMatrix(Dialog &);
+ GuiMathMatrix(GuiDialog &);
/// parent controller
ControlMath & controller()
{ return static_cast<ControlMath &>(this->getController()); }
#include <config.h>
+#include "GuiNomencl.h"
+
#include "debug.h"
#include "ControlCommand.h"
#include "qt_helpers.h"
-#include "GuiNomencl.h"
-#include "Qt2BC.h"
-#include "ButtonController.h"
-
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
/////////////////////////////////////////////////////////////////////
-GuiNomencl::GuiNomencl(Dialog & parent, docstring const & title)
+GuiNomencl::GuiNomencl(GuiDialog & parent, docstring const & title)
: GuiView<GuiNomenclDialog>(parent, title)
{
}
{
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);
}
description.replace("\\\\","\n");
dialog_->descriptionTE->setPlainText(description);
- bc().valid(isValid());
+ bc().setValid(isValid());
}
class GuiNomencl;
-class GuiNomenclDialog : public QDialog, public Ui::NomenclUi {
+class GuiNomenclDialog : public QDialog, public Ui::NomenclUi
+{
Q_OBJECT
public:
GuiNomenclDialog(GuiNomencl * form);
public:
friend class GuiNomenclDialog;
- GuiNomencl(Dialog &, docstring const & title);
+ GuiNomencl(GuiDialog &, docstring const & title);
/// parent controller
ControlCommand & controller()
{ return static_cast<ControlCommand &>(this->getController()); }
#include <config.h>
#include "GuiNote.h"
-#include "Qt2BC.h"
#include "insets/InsetNote.h"
/////////////////////////////////////////////////////////////////////
-GuiNote::GuiNote(Dialog & parent)
+GuiNote::GuiNote(GuiDialog & parent)
: GuiView<GuiNoteDialog>(parent, _("Note Settings"))
{}
{
dialog_.reset(new GuiNoteDialog(this));
- bcview().setOK(dialog_->okPB);
- bcview().setCancel(dialog_->closePB);
+ bc().setOK(dialog_->okPB);
+ bc().setCancel(dialog_->closePB);
}
friend class GuiNoteDialog;
/// Constructor
- GuiNote(Dialog &);
+ GuiNote(GuiDialog &);
/// parent controller
ControlNote & controller()
{ return static_cast<ControlNote &>(this->getController()); }
#include <config.h>
#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 <QCheckBox>
#include <QCloseEvent>
/////////////////////////////////////////////////////////////////////
-GuiParagraph::GuiParagraph(Dialog & parent)
+GuiParagraph::GuiParagraph(GuiDialog & parent)
: GuiView<GuiParagraphDialog>(parent, _("Paragraph Settings"))
{}
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);
}
public:
friend class GuiParagraphDialog;
- GuiParagraph(Dialog &);
+ GuiParagraph(GuiDialog &);
/// parent controller
ControlParagraph & controller()
{ return static_cast<ControlParagraph &>(this->getController()); }
#include "GuiPrefs.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include "GuiApplication.h"
#include <QCloseEvent>
#include <boost/tuple/tuple.hpp>
+#include <boost/bind.hpp>
+
#include <iomanip>
#include <sstream>
+#include <algorithm>
using namespace Ui;
//
/////////////////////////////////////////////////////////////////////
+template<class Pair>
+std::vector<typename Pair::second_type> const
+getSecond(std::vector<Pair> const & pr)
+{
+ std::vector<typename Pair::second_type> 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)
{
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);
}
/////////////////////////////////////////////////////////////////////
-GuiPrefs::GuiPrefs(Dialog & parent)
+GuiPrefs::GuiPrefs(GuiDialog & parent)
: GuiView<GuiPrefsDialog>(parent, _("Preferences"))
{
}
class GuiPrefs : public GuiView<GuiPrefsDialog>
{
public:
- GuiPrefs(Dialog &);
+ GuiPrefs(GuiDialog &);
Converters & converters();
Formats & formats();
#include <config.h>
#include "GuiPrint.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
+#include "qt_helpers.h"
#include "PrinterParams.h"
#include "support/os.h"
}
-GuiPrint::GuiPrint(Dialog & parent)
+GuiPrint::GuiPrint(GuiDialog & parent)
: GuiView<GuiPrintDialog>(parent, _("Print Document"))
{
}
{
dialog_.reset(new GuiPrintDialog(this));
- bcview().setOK(dialog_->printPB);
- bcview().setCancel(dialog_->closePB);
+ bc().setOK(dialog_->printPB);
+ bc().setCancel(dialog_->closePB);
}
///
friend class GuiPrintDialog;
///
- GuiPrint(Dialog &);
+ GuiPrint(GuiDialog &);
/// parent controller
ControlPrint & controller()
{ return static_cast<ControlPrint &>(this->getController()); }
#include <config.h>
#include "GuiRef.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
-#include "ButtonController.h"
-
#include "insets/InsetRef.h"
#include <QLineEdit>
/////////////////////////////////////////////////////////////////////
-GuiRef::GuiRef(Dialog & parent)
+GuiRef::GuiRef(GuiDialog & parent)
: GuiView<GuiRefDialog>(parent, _("Cross-reference")),
sort_(false), at_ref_(false)
{
{
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;
}
dialog_->bufferCO->setCurrentIndex(controller().getBufferNum());
updateRefs();
- bc().valid(false);
+ bc().setValid(false);
}
public:
friend class GuiRefDialog;
- GuiRef(Dialog &);
+ GuiRef(GuiDialog &);
/// parent controller
ControlRef & controller()
#include "GuiSearch.h"
#include "qt_helpers.h"
-#include "Qt2BC.h"
#include <QLineEdit>
#include <QCloseEvent>
/////////////////////////////////////////////////////////////////////
-GuiSearch::GuiSearch(Dialog & parent)
+GuiSearch::GuiSearch(GuiDialog & parent)
: GuiView<GuiSearchDialog>(parent, _("Find and Replace"))
{
}
{
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);
///
friend class GuiSearchDialog;
///
- GuiSearch(Dialog &);
+ GuiSearch(GuiDialog &);
/// parent controller
ControlSearch & controller()
{ return static_cast<ControlSearch &>(this->getController()); }
#include <config.h>
#include "GuiSendto.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include "Format.h"
/////////////////////////////////////////////////////////////////////
-GuiSendto::GuiSendto(Dialog & parent)
+GuiSendto::GuiSendto(GuiDialog & parent)
: GuiView<GuiSendtoDialog>(parent, _("Send Document to Command"))
{
}
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);
}
///
friend class GuiSendtoDialog;
///
- GuiSendto(Dialog &);
+ GuiSendto(GuiDialog &);
/// parent controller
ControlSendto & controller()
{ return static_cast<ControlSendto &>(this->getController()); }
#include <config.h>
#include "GuiShowFile.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include <QTextBrowser>
/////////////////////////////////////////////////////////////////////
-GuiShowFile::GuiShowFile(Dialog & parent)
+GuiShowFile::GuiShowFile(GuiDialog & parent)
: GuiView<GuiShowFileDialog>(parent, _("Show File"))
{
}
{
dialog_.reset(new GuiShowFileDialog(this));
- bcview().setCancel(dialog_->closePB);
+ bc().setCancel(dialog_->closePB);
}
public:
friend class GuiShowFileDialog;
- GuiShowFile(Dialog &);
+ GuiShowFile(GuiDialog &);
/// parent controller
ControlShowFile & controller()
{ return static_cast<ControlShowFile &>(this->getController()); }
#include <config.h>
#include "GuiSpellchecker.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include <QProgressBar>
/////////////////////////////////////////////////////////////////////
-GuiSpellchecker::GuiSpellchecker(Dialog & parent)
+GuiSpellchecker::GuiSpellchecker(GuiDialog & parent)
: GuiView<GuiSpellcheckerDialog>(parent, _("Spellchecker"))
{}
{
dialog_.reset(new GuiSpellcheckerDialog(this));
- bcview().setCancel(dialog_->closePB);
+ bc().setCancel(dialog_->closePB);
dialog_->wordED->setReadOnly(true);
}
public:
friend class GuiSpellcheckerDialog;
- GuiSpellchecker(Dialog &);
+ GuiSpellchecker(GuiDialog &);
/// update from controller
void partialUpdate(int id);
#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 <QCloseEvent>
/////////////////////////////////////////////////////////////////////
-GuiTabular::GuiTabular(Dialog & parent)
+GuiTabular::GuiTabular(GuiDialog & parent)
: GuiView<GuiTabularDialog>(parent, _("Table Settings"))
{
}
{
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);
}
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());
public:
friend class GuiTabularDialog;
- GuiTabular(Dialog &);
+ GuiTabular(GuiDialog &);
/// parent controller
ControlTabular & controller()
#include <config.h>
#include "GuiTabularCreate.h"
-#include "Qt2BC.h"
#include "EmptyTable.h"
#include <QCloseEvent>
/////////////////////////////////////////////////////////////////////
-GuiTabularCreate::GuiTabularCreate(Dialog & parent)
+GuiTabularCreate::GuiTabularCreate(GuiDialog & parent)
: GuiView<GuiTabularCreateDialog>(parent, _("Insert Table"))
{
}
{
dialog_.reset(new GuiTabularCreateDialog(this));
- bcview().setOK(dialog_->okPB);
- bcview().setCancel(dialog_->closePB);
+ bc().setOK(dialog_->okPB);
+ bc().setCancel(dialog_->closePB);
}
///
friend class GuiTabularCreateDialog;
///
- GuiTabularCreate(Dialog &);
+ GuiTabularCreate(GuiDialog &);
/// parent controller
ControlTabularCreate & controller()
{ return static_cast<ControlTabularCreate &>(this->getController()); }
#include <config.h>
#include "GuiTexinfo.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include "support/filetools.h"
/////////////////////////////////////////////////////////////////////
-GuiTexinfo::GuiTexinfo(Dialog & parent)
+GuiTexinfo::GuiTexinfo(GuiDialog & parent)
: GuiView<GuiTexinfoDialog>(parent, _("TeX Information")),
warningPosted(false), activeStyle(ControlTexinfo::cls)
{
updateStyles(ControlTexinfo::cls);
- bcview().setCancel(dialog_->closePB);
+ bc().setCancel(dialog_->closePB);
}
///
friend class GuiTexinfoDialog;
///
- GuiTexinfo(Dialog &);
+ GuiTexinfo(GuiDialog &);
/// parent controller
ControlTexinfo & controller()
{ return static_cast<ControlTexinfo &>(this->getController()); }
#include <config.h>
#include "GuiThesaurus.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include "debug.h"
//
/////////////////////////////////////////////////////////////////////
-GuiThesaurus::GuiThesaurus(Dialog & parent)
+GuiThesaurus::GuiThesaurus(GuiDialog & parent)
: GuiView<GuiThesaurusDialog>(parent, _("Thesaurus"))
{
}
{
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);
}
///
friend class GuiThesaurusDialog;
///
- GuiThesaurus(Dialog &);
+ GuiThesaurus(GuiDialog &);
/// parent controller
ControlThesaurus & controller()
{ return static_cast<ControlThesaurus &>(this->getController()); }
#include "GuiToc.h"
#include "TocModel.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
#include "debug.h"
-#include "controllers/ControlToc.h"
+#include "ControlToc.h"
#include <algorithm>
#include <config.h>
#include "GuiURL.h"
-#include "Qt2BC.h"
#include "qt_helpers.h"
-#include "ButtonController.h"
#include <QCheckBox>
#include <QCloseEvent>
-UrlView::UrlView(Dialog & parent)
+UrlView::UrlView(GuiDialog & parent)
: GuiView<GuiURLDialog>(parent, _("URL"))
{
}
{
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);
}
dialog_->nameED->setText(toqstr(params["name"]));
dialog_->hyperlinkCB->setChecked(params.getCmdName() != "url");
- bc().valid(isValid());
+ bc().setValid(isValid());
}
{
public:
friend class QURLDialog;
- UrlView(Dialog &);
+ UrlView(GuiDialog &);
/// parent controller
ControlCommand & controller()
{ return static_cast<ControlCommand &>(this->getController()); }
#include <config.h>
#include "GuiVSpace.h"
-#include "Qt2BC.h"
#include "LengthCombo.h"
#include "qt_helpers.h"
#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"
}
-GuiVSpace::GuiVSpace(Dialog & parent)
+GuiVSpace::GuiVSpace(GuiDialog & parent)
: GuiView<GuiVSpaceDialog>(parent, _("Vertical Space Settings"))
{}
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();
///
friend class GuiVSpaceDialog;
///
- GuiVSpace(Dialog &);
+ GuiVSpace(GuiDialog &);
/// parent controller
ControlVSpace & controller()
{ return static_cast<ControlVSpace &>(this->getController()); }
}
-GuiViewSource::GuiViewSource(Dialog & parent)
+GuiViewSource::GuiViewSource(GuiDialog & parent)
: ControlViewSource(parent)
{
document_ = new QTextDocument(this);
#define GUIVIEWSOURCE_H
#include "ControlViewSource.h"
+#include "GuiDialog.h"
#include "Application.h"
#include "ui_ViewSourceUi.h"
class GuiViewSource : public QObject, public ControlViewSource {
public:
///
- GuiViewSource(Dialog &);
+ GuiViewSource(GuiDialog &);
///
QTextDocument * document() { return document_; }
///
#include <config.h>
#include "GuiWrap.h"
-#include "Qt2BC.h"
#include "LengthCombo.h"
#include "qt_helpers.h"
//
/////////////////////////////////////////////////////////////////////
-GuiWrap::GuiWrap(Dialog & parent)
+GuiWrap::GuiWrap(GuiDialog & parent)
: GuiView<GuiWrapDialog>(parent, _("Text Wrap Settings"))
{
}
{
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);
}
public:
friend class GuiWrapDialog;
- GuiWrap(Dialog &);
+ GuiWrap(GuiDialog &);
/// parent controller
ControlWrap & controller()
{ return static_cast<ControlWrap &>(this->getController()); }
Action.cpp \
alert_pimpl.cpp \
BulletsModule.cpp \
+ ButtonController.cpp \
ColorCache.cpp \
Dialogs.cpp \
EmptyTable.cpp \
GuiCommandBuffer.cpp \
GuiCommandEdit.cpp \
GuiDelimiter.cpp \
+ GuiDialog.cpp \
GuiDialogView.cpp \
GuiDocument.cpp \
GuiEmbeddedFiles.cpp \
LengthCombo.cpp \
LyXFileDialog.cpp \
PanelStack.cpp \
- Qt2BC.cpp \
qt_helpers.cpp \
socket_callback.cpp \
TocModel.cpp \
Validator.cpp
NOMOCHEADER = \
+ ButtonController.h \
GuiClipboard.h \
GuiFontLoader.h \
GuiFontMetrics.h \
GuiSelection.h \
GuiImage.h \
GuiPainter.h \
- Qt2BC.h \
qt_helpers.h
MOCHEADER = \
GuiCommandBuffer.h \
GuiCommandEdit.h \
GuiDelimiter.h \
+ GuiDialog.h \
GuiDialogView.h \
GuiDocument.h \
GuiEmbeddedFiles.h \
+++ /dev/null
-/**
- * \file Qt2BC.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 <config.h>
-
-#include "Qt2BC.h"
-#include "BCView.h"
-#include "ButtonPolicy.h"
-#include "debug.h"
-#include "qt_helpers.h"
-
-#include <QPushButton>
-#include <QLineEdit>
-#include <QLabel>
-#include <QValidator>
-
-
-namespace lyx {
-namespace frontend {
-
-
-Qt2BC::Qt2BC(ButtonController & parent)
- : BCView(parent), okay_(0), apply_(0), cancel_(0), restore_(0)
-{}
-
-
-void Qt2BC::refresh() const
-{
- LYXERR(Debug::GUI) << "Calling BC refresh()" << std::endl;
-
- bool const all_valid = checkWidgets();
-
- if (okay_) {
- bool const enabled =
- all_valid && bp().buttonStatus(ButtonPolicy::OKAY);
- okay_->setEnabled(enabled);
- }
- if (apply_) {
- bool const enabled =
- all_valid && bp().buttonStatus(ButtonPolicy::APPLY);
- apply_->setEnabled(enabled);
- }
- if (restore_) {
- bool const enabled =
- all_valid && bp().buttonStatus(ButtonPolicy::RESTORE);
- restore_->setEnabled(enabled);
- }
- if (cancel_) {
- bool const enabled = bp().buttonStatus(ButtonPolicy::CANCEL);
- if (enabled)
- cancel_->setText(toqstr(_("Cancel")));
- else
- cancel_->setText(toqstr(_("Close")));
- }
-}
-
-
-void Qt2BC::refreshReadOnly() const
-{
- if (read_only_.empty())
- return;
-
- bool const enable = !bp().isReadOnly();
-
- Widgets::const_iterator end = read_only_.end();
- Widgets::const_iterator iter = read_only_.begin();
- for (; iter != end; ++iter)
- setWidgetEnabled(*iter, enable);
-}
-
-
-void Qt2BC::setWidgetEnabled(QWidget * obj, bool enabled) const
-{
- if (QLineEdit * le = qobject_cast<QLineEdit*>(obj))
- le->setReadOnly(!enabled);
- else
- obj->setEnabled(enabled);
-
- obj->setFocusPolicy(enabled ? Qt::StrongFocus : Qt::NoFocus);
-}
-
-
-void Qt2BC::addCheckedLineEdit(QLineEdit * input, QWidget * label)
-{
- checked_widgets.push_back(CheckedLineEdit(input, label));
-}
-
-
-bool Qt2BC::checkWidgets() const
-{
- bool valid = true;
-
- CheckedWidgetList::const_iterator it = checked_widgets.begin();
- CheckedWidgetList::const_iterator end = checked_widgets.end();
-
- for (; it != end; ++it)
- valid &= it->check();
-
- // return valid status after checking ALL widgets
- return valid;
-}
-
-
-//////////////////////////////////////////////////////////////
-//
-// CheckedLineEdit
-//
-//////////////////////////////////////////////////////////////
-
-void addCheckedLineEdit(BCView & bcview, QLineEdit * input, QWidget * label)
-{
- Qt2BC * bc = static_cast<Qt2BC *>(&bcview);
- bc->addCheckedLineEdit(input, label);
-}
-
-
-static void setWarningColor(QWidget * widget)
-{
- QPalette pal = widget->palette();
- pal.setColor(QPalette::Active, QPalette::Foreground, QColor(255, 0, 0));
- widget->setPalette(pal);
-}
-
-
-
-CheckedLineEdit::CheckedLineEdit(QLineEdit * input, QWidget * label)
- : input_(input), label_(label)
-{}
-
-
-bool CheckedLineEdit::check() const
-{
- QValidator const * validator = input_->validator();
- if (!validator)
- return true;
-
- QString t = input_->text();
- int p = 0;
- bool const valid = validator->validate(t, p) == QValidator::Acceptable;
-
- // Visual feedback.
- if (valid)
- input_->setPalette(QPalette());
- else
- setWarningColor(input_);
-
- if (label_) {
- if (valid)
- label_->setPalette(QPalette());
- else
- setWarningColor(label_);
- }
-
- return valid;
-}
-
-} // namespace frontend
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file Qt2BC.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
-
-#include "BCView.h"
-#include "gettext.h"
-
-#include <list>
-
-class QWidget;
-class QPushButton;
-class QLineEdit;
-
-namespace lyx {
-namespace frontend {
-
-
-void addCheckedLineEdit(BCView & bcview,
- QLineEdit * input, QWidget * label = 0);
-
-class CheckedLineEdit
-{
-public:
- CheckedLineEdit(QLineEdit * input, QWidget * label = 0);
- bool check() const;
-
-private:
- // non-owned
- QLineEdit * input_;
- QWidget * label_;
-};
-
-/** General purpose button controller for up to four buttons.
- Controls the activation of the OK, Apply and Cancel buttons.
- 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 Qt2BC : public BCView
-{
-public:
- ///
- Qt2BC(ButtonController & parent);
-
- //@{
- /** Store pointers to these widgets.
- */
- void setOK(QPushButton * obj) { okay_ = obj; }
- void setApply(QPushButton * obj) { apply_ = obj; }
- void setCancel(QPushButton * obj) { cancel_ = obj; }
- void setRestore(QPushButton * obj) { restore_ = obj; }
- //@}
-
- /** Add a pointer to the list of widgets whose activation
- * state is dependent upon the read-only status of the
- * underlying buffer.
- */
- 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.
- */
- void addCheckedLineEdit(QLineEdit * input, QWidget * label = 0);
-
-protected:
- /// \return true if all CheckedWidgets are in a valid state.
- bool checkWidgets() const;
-
-private:
- typedef std::list<CheckedLineEdit> CheckedWidgetList;
- CheckedWidgetList checked_widgets;
-
-private:
- /// Updates the widget sensitivity (enabled/disabled)
- void setWidgetEnabled(QWidget *, bool enabled) const;
-
- QPushButton * okay_;
- QPushButton * apply_;
- QPushButton * cancel_;
- QPushButton * restore_;
-
- typedef std::list<QWidget *> Widgets;
- Widgets read_only_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QT2BC_H