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