]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiTabularCreate.cpp
be59c0bec9b90e89a04ae1465bd313ab1ff47b27
[lyx.git] / src / frontends / qt4 / GuiTabularCreate.cpp
1 /**
2  * \file GuiTabularCreate.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GuiTabularCreate.h"
14
15 #include "EmptyTable.h"
16 #include "FuncRequest.h"
17
18 #include "support/convert.h"
19
20 #include <QCloseEvent>
21 #include <QSpinBox>
22 #include <QPushButton>
23
24 using std::string;
25
26
27 namespace lyx {
28 namespace frontend {
29
30 GuiTabularCreate::GuiTabularCreate(LyXView & lv)
31         : GuiDialog(lv, "tabularcreate"), Controller(this)
32 {
33         setupUi(this);
34         setViewTitle(_("Insert Table"));
35         setController(this, false);
36
37         rowsSB->setValue(5);
38         columnsSB->setValue(5);
39
40         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
41         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
42
43         connect(rowsSB, SIGNAL(valueChanged(int)),
44                 this, SLOT(rowsChanged(int)));
45         connect(columnsSB, SIGNAL(valueChanged(int)),
46                 this, SLOT(columnsChanged(int)));
47
48         bc().setPolicy(ButtonPolicy::IgnorantPolicy);
49         bc().setOK(okPB);
50         bc().setCancel(closePB);
51 }
52
53
54 void GuiTabularCreate::columnsChanged(int)
55 {
56         changed();
57 }
58
59
60 void GuiTabularCreate::rowsChanged(int)
61 {
62         changed();
63 }
64
65
66 void GuiTabularCreate::applyView()
67 {
68         params_.first = rowsSB->value();
69         params_.second = columnsSB->value();
70 }
71
72
73 bool GuiTabularCreate::initialiseParams(string const &)
74 {
75         params_.first  = 5;
76         params_.second = 5;
77         return true;
78 }
79
80
81 void GuiTabularCreate::clearParams()
82 {
83         params_.first  = 0;
84         params_.second = 0;
85 }
86
87
88 void GuiTabularCreate::dispatchParams()
89 {
90         string const data = convert<string>(params().first) + ' ' + convert<string>(params().second);
91         dispatch(FuncRequest(getLfun(), data));
92 }
93
94
95 Dialog * createGuiTabularCreate(LyXView & lv)
96 {
97         return new GuiTabularCreate(lv);
98 }
99
100
101 } // namespace frontend
102 } // namespace lyx
103
104 #include "GuiTabularCreate_moc.cpp"