2 * \file QTabularDialog.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Jürgen Spitzmüller
10 * Full author contact details are available in file CREDITS.
15 #include "QTabularDialog.h"
17 #include "lengthvalidator.h"
18 #include "qt_helpers.h"
20 #include "controllers/ControlTabular.h"
22 #include <qcheckbox.h>
23 #include <qpushbutton.h>
24 #include <qlineedit.h>
34 LengthValidator * unsignedLengthValidator(QLineEdit * ed)
36 LengthValidator * v = new LengthValidator(ed);
37 v->setBottom(LyXLength());
44 QTabularDialog::QTabularDialog(QTabular * form)
45 : QTabularDialogBase(0, 0, false, 0),
48 connect(closePB, SIGNAL(clicked()),
49 form, SLOT(slotClose()));
51 widthED->setValidator(unsignedLengthValidator(widthED));
55 void QTabularDialog::change_adaptor()
61 void QTabularDialog::closeEvent(QCloseEvent * e)
68 void QTabularDialog::close_clicked()
74 void QTabularDialog::borderSet_clicked()
76 form_->controller().set(LyXTabular::SET_ALL_LINES);
77 form_->update_borders();
82 void QTabularDialog::borderUnset_clicked()
84 form_->controller().set(LyXTabular::UNSET_ALL_LINES);
85 form_->update_borders();
90 void QTabularDialog::leftBorder_changed()
92 form_->controller().toggleLeftLine();
97 void QTabularDialog::rightBorder_changed()
99 form_->controller().toggleRightLine();
104 void QTabularDialog::topBorder_changed()
106 form_->controller().toggleTopLine();
111 void QTabularDialog::bottomBorder_changed()
113 form_->controller().toggleBottomLine();
118 void QTabularDialog::specialAlignment_changed()
120 string special = fromqstr(specialAlignmentED->text());
121 form_->controller().setSpecial(special);
126 void QTabularDialog::width_changed()
129 string const width = widgetsToLength(widthED, widthUnit);
130 form_->controller().setWidth(width);
134 void QTabularDialog::multicolumn_clicked()
136 form_->controller().toggleMultiColumn();
141 void QTabularDialog::rotateTabular()
143 form_->controller().rotateTabular(rotateTabularCB->isChecked());
148 void QTabularDialog::rotateCell()
150 form_->controller().rotateCell(rotateCellCB->isChecked());
155 void QTabularDialog::hAlign_changed(int align)
157 ControlTabular::HALIGN h = ControlTabular::LEFT;
160 case 0: h = ControlTabular::LEFT; break;
161 case 1: h = ControlTabular::CENTER; break;
162 case 2: h = ControlTabular::RIGHT; break;
163 case 3: h = ControlTabular::BLOCK; break;
166 form_->controller().halign(h);
170 void QTabularDialog::vAlign_changed(int align)
172 ControlTabular::VALIGN v = ControlTabular::TOP;
175 case 0: v = ControlTabular::TOP; break;
176 case 1: v = ControlTabular::MIDDLE; break;
177 case 2: v = ControlTabular::BOTTOM; break;
180 form_->controller().valign(v);
184 void QTabularDialog::longTabular()
186 form_->controller().longTabular(longTabularCB->isChecked());
191 void QTabularDialog::ltNewpage_clicked()
193 form_->controller().set(LyXTabular::SET_LTNEWPAGE);
198 void QTabularDialog::ltHeaderStatus_clicked()
200 bool enable(headerStatusCB->isChecked());
202 form_->controller().set(LyXTabular::SET_LTHEAD, "");
204 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
205 headerBorderAboveCB->setEnabled(enable);
206 headerBorderBelowCB->setEnabled(enable);
207 firstheaderNoContentsCB->setEnabled(enable);
212 void QTabularDialog::ltHeaderBorderAbove_clicked()
214 if (headerBorderAboveCB->isChecked())
215 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_above");
217 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
222 void QTabularDialog::ltHeaderBorderBelow_clicked()
224 if (headerBorderBelowCB->isChecked())
225 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_below");
227 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
232 void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
234 if (firstheaderBorderAboveCB->isChecked())
235 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_above");
237 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
242 void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
244 if (firstheaderBorderBelowCB->isChecked())
245 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_below");
247 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
252 void QTabularDialog::ltFirstHeaderStatus_clicked()
254 bool enable(firstheaderStatusCB->isChecked());
256 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "");
258 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
259 firstheaderBorderAboveCB->setEnabled(enable);
260 firstheaderBorderBelowCB->setEnabled(enable);
265 void QTabularDialog::ltFirstHeaderEmpty_clicked()
267 bool enable(firstheaderNoContentsCB->isChecked());
269 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "empty");
271 ltFirstHeaderBorderBelow_clicked();
272 ltFirstHeaderBorderAbove_clicked();
274 firstheaderStatusCB->setEnabled(!enable);
275 firstheaderBorderAboveCB->setEnabled(!enable);
276 firstheaderBorderBelowCB->setEnabled(!enable);
281 void QTabularDialog::ltFooterStatus_clicked()
283 bool enable(footerStatusCB->isChecked());
285 form_->controller().set(LyXTabular::SET_LTFOOT, "");
287 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
288 footerBorderAboveCB->setEnabled(enable);
289 footerBorderBelowCB->setEnabled(enable);
290 lastfooterNoContentsCB->setEnabled(enable);
295 void QTabularDialog::ltFooterBorderAbove_clicked()
297 if (footerBorderAboveCB->isChecked())
298 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_above");
300 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
305 void QTabularDialog::ltFooterBorderBelow_clicked()
307 if (footerBorderBelowCB->isChecked())
308 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_below");
310 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
315 void QTabularDialog::ltLastFooterStatus_clicked()
317 bool enable(lastfooterStatusCB->isChecked());
319 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "");
321 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
322 lastfooterBorderAboveCB->setEnabled(enable);
323 lastfooterBorderBelowCB->setEnabled(enable);
328 void QTabularDialog::ltLastFooterBorderAbove_clicked()
330 if (lastfooterBorderAboveCB->isChecked())
331 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_above");
333 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
338 void QTabularDialog::ltLastFooterBorderBelow_clicked()
340 if (lastfooterBorderBelowCB->isChecked())
341 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_below");
343 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
348 void QTabularDialog::ltLastFooterEmpty_clicked()
350 bool enable(lastfooterNoContentsCB->isChecked());
352 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "empty");
354 ltLastFooterBorderBelow_clicked();
355 ltLastFooterBorderAbove_clicked();
357 lastfooterStatusCB->setEnabled(!enable);
358 lastfooterBorderAboveCB->setEnabled(!enable);
359 lastfooterBorderBelowCB->setEnabled(!enable);
363 } // namespace frontend