]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiTabularCreate.cpp
QDialogButtonBox for the remaining dialogs.
[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 <QSpinBox>
21 #include <QPushButton>
22
23 using namespace std;
24
25 namespace lyx {
26 namespace frontend {
27
28 GuiTabularCreate::GuiTabularCreate(GuiView & lv)
29         : GuiDialog(lv, "tabularcreate", qt_("Insert Table"))
30 {
31         setupUi(this);
32
33         rowsSB->setValue(5);
34         columnsSB->setValue(5);
35         table->setMinimumSize(100, 100);
36
37         connect(table, SIGNAL(rowsChanged(int)),
38                 rowsSB, SLOT(setValue(int)));
39         connect(table, SIGNAL(colsChanged(int)),
40                 columnsSB, SLOT(setValue(int)));
41         connect(rowsSB, SIGNAL(valueChanged(int)),
42                 table, SLOT(setNumberRows(int)));
43         connect(columnsSB, SIGNAL(valueChanged(int)),
44                 table, SLOT(setNumberColumns(int)));
45
46         connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
47                 this, SLOT(slotButtonBox(QAbstractButton *)));
48
49         connect(rowsSB, SIGNAL(valueChanged(int)),
50                 this, SLOT(rowsChanged(int)));
51         connect(columnsSB, SIGNAL(valueChanged(int)),
52                 this, SLOT(columnsChanged(int)));
53
54         bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
55         bc().setOK(buttonBox->button(QDialogButtonBox::Ok));
56         bc().setApply(buttonBox->button(QDialogButtonBox::Apply));
57         bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
58         bc().setValid(isValid());
59 }
60
61
62 void GuiTabularCreate::columnsChanged(int)
63 {
64         changed();
65 }
66
67
68 void GuiTabularCreate::rowsChanged(int)
69 {
70         changed();
71 }
72
73
74 void GuiTabularCreate::applyView()
75 {
76         params_.first = rowsSB->value();
77         params_.second = columnsSB->value();
78 }
79
80
81 bool GuiTabularCreate::initialiseParams(string const &)
82 {
83         params_.first  = 5;
84         params_.second = 5;
85         return true;
86 }
87
88
89 void GuiTabularCreate::clearParams()
90 {
91         params_.first  = 0;
92         params_.second = 0;
93 }
94
95
96 void GuiTabularCreate::dispatchParams()
97 {
98         string const sdata = 
99                 convert<string>(params().first) + ' ' + convert<string>(params().second);
100         dispatch(FuncRequest(getLfun(), sdata));
101 }
102
103
104 Dialog * createGuiTabularCreate(GuiView & lv)
105 {
106         return new GuiTabularCreate(lv);
107 }
108
109
110 } // namespace frontend
111 } // namespace lyx
112
113 #include "moc_GuiTabularCreate.cpp"