]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiTabularCreate.cpp
76f4362e3d2676c2ecd259a9cbe94ca90e183c1f
[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")
32 {
33         setupUi(this);
34         setViewTitle(_("Insert Table"));
35
36         rowsSB->setValue(5);
37         columnsSB->setValue(5);
38
39         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
40         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
41
42         connect(rowsSB, SIGNAL(valueChanged(int)),
43                 this, SLOT(rowsChanged(int)));
44         connect(columnsSB, SIGNAL(valueChanged(int)),
45                 this, SLOT(columnsChanged(int)));
46
47         bc().setPolicy(ButtonPolicy::IgnorantPolicy);
48         bc().setOK(okPB);
49         bc().setCancel(closePB);
50 }
51
52
53 void GuiTabularCreate::columnsChanged(int)
54 {
55         changed();
56 }
57
58
59 void GuiTabularCreate::rowsChanged(int)
60 {
61         changed();
62 }
63
64
65 void GuiTabularCreate::applyView()
66 {
67         params_.first = rowsSB->value();
68         params_.second = columnsSB->value();
69 }
70
71
72 bool GuiTabularCreate::initialiseParams(string const &)
73 {
74         params_.first  = 5;
75         params_.second = 5;
76         return true;
77 }
78
79
80 void GuiTabularCreate::clearParams()
81 {
82         params_.first  = 0;
83         params_.second = 0;
84 }
85
86
87 void GuiTabularCreate::dispatchParams()
88 {
89         string const data = convert<string>(params().first) + ' ' + convert<string>(params().second);
90         dispatch(FuncRequest(getLfun(), data));
91 }
92
93
94 Dialog * createGuiTabularCreate(LyXView & lv)
95 {
96         return new GuiTabularCreate(lv);
97 }
98
99
100 } // namespace frontend
101 } // namespace lyx
102
103 #include "GuiTabularCreate_moc.cpp"