git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20773 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-10-06 09:39:29 +00:00
parent 06fe2c019f
commit 540a00cd02
6 changed files with 69 additions and 126 deletions

View File

@ -1,51 +0,0 @@
/**
* \file ControlTabularCreate.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author unknown
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "ControlTabularCreate.h"
#include "FuncRequest.h"
#include "support/convert.h"
using std::string;
namespace lyx {
namespace frontend {
ControlTabularCreate::ControlTabularCreate(Dialog & parent)
: Controller(parent)
{}
bool ControlTabularCreate::initialiseParams(string const &)
{
params_.first = 5;
params_.second = 5;
return true;
}
void ControlTabularCreate::clearParams()
{
params_.first = 0;
params_.second = 0;
}
void ControlTabularCreate::dispatchParams()
{
string const data = convert<string>(params().first) + ' ' + convert<string>(params().second);
dispatch(FuncRequest(getLfun(), data));
}
} // namespace frontend
} // namespace lyx

View File

@ -1,51 +0,0 @@
// -*- C++ -*-
/**
* \file ControlTabularCreate.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author unknown
*
* Full author contact details are available in file CREDITS.
*/
#ifndef CONTROLTABULARCREATE_H
#define CONTROLTABULARCREATE_H
#include "Dialog.h"
#include <utility>
namespace lyx {
namespace frontend {
/** A controller for the TabularCreate Dialog.
*/
class ControlTabularCreate : public Controller {
public:
///
ControlTabularCreate(Dialog &);
///
virtual bool initialiseParams(std::string const & data);
/// clean-up on hide.
virtual void clearParams();
///
virtual void dispatchParams();
///
virtual bool isBufferDependent() const { return true; }
///
virtual kb_action getLfun() const { return LFUN_TABULAR_INSERT; }
///
typedef std::pair<size_t, size_t> rowsCols;
///
rowsCols & params() { return params_; }
private:
/// rows, cols params
rowsCols params_;
};
} // namespace frontend
} // namespace lyx
#endif // CONTROLTABULARCREATE_H

View File

@ -31,7 +31,6 @@ SOURCEFILES = \
ControlSearch.cpp \ ControlSearch.cpp \
ControlSendto.cpp \ ControlSendto.cpp \
ControlSpellchecker.cpp \ ControlSpellchecker.cpp \
ControlTabularCreate.cpp \
ControlThesaurus.cpp \ ControlThesaurus.cpp \
ControlToc.cpp \ ControlToc.cpp \
frontend_helpers.cpp frontend_helpers.cpp
@ -60,7 +59,6 @@ HEADERFILES = \
ControlSearch.h \ ControlSearch.h \
ControlSendto.h \ ControlSendto.h \
ControlSpellchecker.h \ ControlSpellchecker.h \
ControlTabularCreate.h \
ControlThesaurus.h \ ControlThesaurus.h \
ControlToc.h \ ControlToc.h \
frontend_helpers.h frontend_helpers.h

View File

@ -41,8 +41,6 @@
#include "GuiSendto.h" #include "GuiSendto.h"
#include "GuiShowFile.h" #include "GuiShowFile.h"
#include "GuiSpellchecker.h" #include "GuiSpellchecker.h"
#include "GuiTabular.h"
#include "GuiTabularCreate.h"
#include "GuiToc.h" #include "GuiToc.h"
#include "GuiView.h" #include "GuiView.h"
#include "GuiViewSource.h" #include "GuiViewSource.h"
@ -232,7 +230,7 @@ Dialog * Dialogs::build(string const & name)
} else if (name == "tabular") { } else if (name == "tabular") {
dialog = createGuiTabular(lyxview_); dialog = createGuiTabular(lyxview_);
} else if (name == "tabularcreate") { } else if (name == "tabularcreate") {
dialog = new GuiTabularCreateDialog(lyxview_); dialog = createGuiTabularCreate(lyxview_);
} else if (name == "texinfo") { } else if (name == "texinfo") {
dialog = createGuiTexInfo(lyxview_); dialog = createGuiTexInfo(lyxview_);
#ifdef HAVE_LIBAIKSAURUS #ifdef HAVE_LIBAIKSAURUS

View File

@ -12,23 +12,27 @@
#include "GuiTabularCreate.h" #include "GuiTabularCreate.h"
#include "ControlTabularCreate.h"
#include "EmptyTable.h" #include "EmptyTable.h"
#include "FuncRequest.h"
#include "support/convert.h"
#include <QCloseEvent> #include <QCloseEvent>
#include <QSpinBox> #include <QSpinBox>
#include <QPushButton> #include <QPushButton>
using std::string;
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
GuiTabularCreateDialog::GuiTabularCreateDialog(LyXView & lv) GuiTabularCreate::GuiTabularCreate(LyXView & lv)
: GuiDialog(lv, "tabularcreate") : GuiDialog(lv, "tabularcreate"), Controller(this)
{ {
setupUi(this); setupUi(this);
setViewTitle(_("Insert Table")); setViewTitle(_("Insert Table"));
setController(new ControlTabularCreate(*this)); setController(this, false);
rowsSB->setValue(5); rowsSB->setValue(5);
columnsSB->setValue(5); columnsSB->setValue(5);
@ -47,30 +51,53 @@ GuiTabularCreateDialog::GuiTabularCreateDialog(LyXView & lv)
} }
ControlTabularCreate & GuiTabularCreateDialog::controller() void GuiTabularCreate::columnsChanged(int)
{
return static_cast<ControlTabularCreate &>(GuiDialog::controller());
}
void GuiTabularCreateDialog::columnsChanged(int)
{ {
changed(); changed();
} }
void GuiTabularCreateDialog::rowsChanged(int) void GuiTabularCreate::rowsChanged(int)
{ {
changed(); changed();
} }
void GuiTabularCreateDialog::applyView() void GuiTabularCreate::applyView()
{ {
controller().params().first = rowsSB->value(); params_.first = rowsSB->value();
controller().params().second = columnsSB->value(); params_.second = columnsSB->value();
} }
bool GuiTabularCreate::initialiseParams(string const &)
{
params_.first = 5;
params_.second = 5;
return true;
}
void GuiTabularCreate::clearParams()
{
params_.first = 0;
params_.second = 0;
}
void GuiTabularCreate::dispatchParams()
{
string const data = convert<string>(params().first) + ' ' + convert<string>(params().second);
dispatch(FuncRequest(getLfun(), data));
}
Dialog * createGuiTabularCreate(LyXView & lv)
{
return new GuiTabularCreate(lv);
}
} // namespace frontend } // namespace frontend
} // namespace lyx } // namespace lyx

View File

@ -13,29 +13,51 @@
#define GUITABULARCREATE_H #define GUITABULARCREATE_H
#include "GuiDialog.h" #include "GuiDialog.h"
#include "ControlTabularCreate.h"
#include "ui_TabularCreateUi.h" #include "ui_TabularCreateUi.h"
#include <utility>
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
class GuiTabularCreateDialog : public GuiDialog, public Ui::TabularCreateUi
class GuiTabularCreate
: public GuiDialog, public Ui::TabularCreateUi, public Controller
{ {
Q_OBJECT Q_OBJECT
public: public:
GuiTabularCreateDialog(LyXView & lv); GuiTabularCreate(LyXView & lv);
private Q_SLOTS: private Q_SLOTS:
void columnsChanged(int); void columnsChanged(int);
void rowsChanged(int); void rowsChanged(int);
/// parent controller /// parent controller
ControlTabularCreate & controller(); Controller & controller() { return *this; }
private: private:
/// Apply changes /// Apply changes
void applyView(); void applyView();
///
bool initialiseParams(std::string const & data);
/// clean-up on hide.
void clearParams();
///
void dispatchParams();
///
bool isBufferDependent() const { return true; }
///
kb_action getLfun() const { return LFUN_TABULAR_INSERT; }
///
typedef std::pair<size_t, size_t> rowsCols;
///
rowsCols & params() { return params_; }
private:
/// rows, cols params
rowsCols params_;
}; };
} // namespace frontend } // namespace frontend