git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20764 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-10-05 22:27:04 +00:00
parent c2f2b1742d
commit 58296b3994
6 changed files with 59 additions and 142 deletions

View File

@ -1,65 +0,0 @@
/**
* \file ControlVSpace.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Edwin Leuven
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "ControlVSpace.h"
#include "FuncRequest.h"
#include "insets/InsetVSpace.h"
using std::istringstream;
using std::string;
namespace lyx {
namespace frontend {
ControlVSpace::ControlVSpace(Dialog & parent)
: Controller(parent)
{}
bool ControlVSpace::initialiseParams(string const & data)
{
InsetVSpaceMailer::string2params(data, params_);
dialog().setButtonsValid(true);
return true;
}
void ControlVSpace::clearParams()
{
params_ = VSpace();
}
void ControlVSpace::dispatchParams()
{
string const str = InsetVSpaceMailer::params2string(params_);
dispatch(FuncRequest(getLfun(), str));
}
VSpace & ControlVSpace::params()
{
return params_;
}
VSpace const & ControlVSpace::params() const
{
return params_;
}
} // namespace frontend
} // namespace lyx

View File

@ -1,49 +0,0 @@
// -*- C++ -*-
/**
* \file ControlVSpace.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Edwin Leuven
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#ifndef CONTROLVSPACE_H
#define CONTROLVSPACE_H
#include "Dialog.h"
#include "VSpace.h"
namespace lyx {
namespace frontend {
class ControlVSpace : public Controller {
public:
///
ControlVSpace(Dialog &);
///
virtual bool initialiseParams(std::string const & data);
/// clean-up on hide.
virtual void clearParams();
/// clean-up on hide.
virtual void dispatchParams();
///
virtual bool isBufferDependent() const { return true; }
///
VSpace & params();
///
VSpace const & params() const;
///
bool inInset() const;
private:
///
VSpace params_;
};
} // namespace frontend
} // namespace lyx
#endif // CONTROLPARAGRAPH_H

View File

@ -38,7 +38,6 @@ SOURCEFILES = \
ControlTexinfo.cpp \ ControlTexinfo.cpp \
ControlThesaurus.cpp \ ControlThesaurus.cpp \
ControlToc.cpp \ ControlToc.cpp \
ControlVSpace.cpp \
frontend_helpers.cpp frontend_helpers.cpp
HEADERFILES = \ HEADERFILES = \
@ -72,7 +71,6 @@ HEADERFILES = \
ControlTexinfo.h \ ControlTexinfo.h \
ControlThesaurus.h \ ControlThesaurus.h \
ControlToc.h \ ControlToc.h \
ControlVSpace.h \
frontend_helpers.h frontend_helpers.h
if MONOLITHIC_CONTROLLERS if MONOLITHIC_CONTROLLERS

View File

@ -50,7 +50,6 @@
#include "GuiViewSource.h" #include "GuiViewSource.h"
#include "TocWidget.h" #include "TocWidget.h"
#include "GuiURL.h" #include "GuiURL.h"
#include "GuiVSpace.h"
#ifdef HAVE_LIBAIKSAURUS #ifdef HAVE_LIBAIKSAURUS
#include "ControlThesaurus.h" #include "ControlThesaurus.h"
@ -253,7 +252,7 @@ Dialog * Dialogs::build(string const & name)
} else if (name == "url") { } else if (name == "url") {
dialog = new GuiURLDialog(lyxview_); dialog = new GuiURLDialog(lyxview_);
} else if (name == "vspace") { } else if (name == "vspace") {
dialog = new GuiVSpaceDialog(lyxview_); dialog = createGuiVSpace(lyxview_);
} else if (name == "wrap") { } else if (name == "wrap") {
dialog = createGuiWrap(lyxview_); dialog = createGuiWrap(lyxview_);
} else if (name == "listings") { } else if (name == "listings") {

View File

@ -17,14 +17,14 @@
#include "GuiVSpace.h" #include "GuiVSpace.h"
#include "ControlVSpace.h"
#include "LengthCombo.h" #include "LengthCombo.h"
#include "qt_helpers.h" #include "qt_helpers.h"
#include "Validator.h" #include "Validator.h"
#include "LyXRC.h" // to set the default length values #include "LyXRC.h" // to set the default length values
#include "Spacing.h" #include "Spacing.h"
#include "VSpace.h" #include "FuncRequest.h"
#include "insets/InsetVSpace.h"
#include "support/lstrings.h" #include "support/lstrings.h"
@ -40,12 +40,12 @@ using std::string;
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
GuiVSpaceDialog::GuiVSpaceDialog(LyXView & lv) GuiVSpace::GuiVSpace(LyXView & lv)
: GuiDialog(lv, "vspace") : GuiDialog(lv, "vspace"), Controller(this)
{ {
setupUi(this); setupUi(this);
setViewTitle(_("Vertical Space Settings")); setViewTitle(_("Vertical Space Settings"));
setController(new ControlVSpace(*this)); setController(this, false);
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK())); connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply())); connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
@ -84,26 +84,20 @@ GuiVSpaceDialog::GuiVSpaceDialog(LyXView & lv)
} }
ControlVSpace & GuiVSpaceDialog::controller() void GuiVSpace::closeEvent(QCloseEvent * e)
{
return static_cast<ControlVSpace &>(GuiDialog::controller());
}
void GuiVSpaceDialog::closeEvent(QCloseEvent * e)
{ {
slotClose(); slotClose();
e->accept(); e->accept();
} }
void GuiVSpaceDialog::change_adaptor() void GuiVSpace::change_adaptor()
{ {
changed(); changed();
} }
void GuiVSpaceDialog::enableCustom(int selection) void GuiVSpace::enableCustom(int selection)
{ {
bool const enable = selection == 5; bool const enable = selection == 5;
valueLE->setEnabled(enable); valueLE->setEnabled(enable);
@ -164,26 +158,49 @@ static VSpace setVSpaceFromWidgets(int spacing,
} }
void GuiVSpaceDialog::applyView() void GuiVSpace::applyView()
{ {
// If a vspace choice is "Length" but there's no text in // If a vspace choice is "Length" but there's no text in
// the input field, do not insert a vspace at all. // the input field, do not insert a vspace at all.
if (spacingCO->currentIndex() == 5 && valueLE->text().isEmpty()) if (spacingCO->currentIndex() == 5 && valueLE->text().isEmpty())
return; return;
VSpace const space = setVSpaceFromWidgets(spacingCO->currentIndex(), params_ = setVSpaceFromWidgets(spacingCO->currentIndex(),
valueLE, unitCO, keepCB->isChecked()); valueLE, unitCO, keepCB->isChecked());
controller().params() = space;
} }
void GuiVSpaceDialog::updateContents() void GuiVSpace::updateContents()
{ {
setWidgetsFromVSpace(controller().params(), setWidgetsFromVSpace(params_, spacingCO, valueLE, unitCO, keepCB);
spacingCO, valueLE, unitCO, keepCB);
} }
bool GuiVSpace::initialiseParams(string const & data)
{
InsetVSpaceMailer::string2params(data, params_);
dialog().setButtonsValid(true);
return true;
}
void GuiVSpace::clearParams()
{
params_ = VSpace();
}
void GuiVSpace::dispatchParams()
{
dispatch(FuncRequest(getLfun(), InsetVSpaceMailer::params2string(params_)));
}
Dialog * createGuiVSpace(LyXView & lv) { return new GuiVSpace(lv); }
} // namespace frontend } // namespace frontend
} // namespace lyx } // namespace lyx

View File

@ -7,6 +7,7 @@
* \author André Pönitz * \author André Pönitz
* \author Angus Leeming * \author Angus Leeming
* \author Jürgen Spitzmüller * \author Jürgen Spitzmüller
* \author Edwin Leuven
* *
* Full author contact details are available in file CREDITS. * Full author contact details are available in file CREDITS.
*/ */
@ -15,31 +16,47 @@
#define GUIVSPACE_H #define GUIVSPACE_H
#include "GuiDialog.h" #include "GuiDialog.h"
#include "ControlVSpace.h"
#include "ui_VSpaceUi.h" #include "ui_VSpaceUi.h"
#include "VSpace.h"
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
class GuiVSpaceDialog : public GuiDialog, public Ui::VSpaceUi class GuiVSpace : public GuiDialog, public Ui::VSpaceUi, public Controller
{ {
Q_OBJECT Q_OBJECT
public: public:
GuiVSpaceDialog(LyXView & lv); GuiVSpace(LyXView & lv);
private Q_SLOTS: private Q_SLOTS:
///
void change_adaptor(); void change_adaptor();
///
void closeEvent(QCloseEvent *); void closeEvent(QCloseEvent *);
///
void enableCustom(int); void enableCustom(int);
private: private:
/// parent controller /// parent controller
ControlVSpace & controller(); Controller & controller() { return *this; }
/// Apply from dialog /// Apply from dialog
void applyView(); void applyView();
/// Update the dialog /// Update the dialog
void updateContents(); void updateContents();
///
bool initialiseParams(std::string const & data);
/// clean-up on hide.
void clearParams();
/// clean-up on hide.
void dispatchParams();
///
bool isBufferDependent() const { return true; }
///
bool inInset() const;
///
VSpace params_;
}; };
} // namespace frontend } // namespace frontend