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 "validators.h"
18 #include "qt_helpers.h"
20 #include "controllers/ControlTabular.h"
22 #include <QCloseEvent>
24 #include <QPushButton>
33 QTabularDialog::QTabularDialog(QTabular * form)
38 widthED->setValidator(unsignedLengthValidator(widthED));
40 connect( borderSetPB, SIGNAL( clicked() ), this, SLOT( borderSet_clicked() ) );
41 connect( borderUnsetPB, SIGNAL( clicked() ), this, SLOT( borderUnset_clicked() ) );
42 connect( longTabularCB, SIGNAL( toggled(bool) ), longtableGB, SLOT( setEnabled(bool) ) );
43 connect( longTabularCB, SIGNAL( toggled(bool) ), newpageCB, SLOT( setEnabled(bool) ) );
44 connect( hAlignCB, SIGNAL( activated(int) ), this, SLOT( hAlign_changed(int) ) );
45 connect( vAlignCB, SIGNAL( activated(int) ), this, SLOT( vAlign_changed(int) ) );
46 connect( multicolumnCB, SIGNAL( clicked() ), this, SLOT( multicolumn_clicked() ) );
47 connect( newpageCB, SIGNAL( clicked() ), this, SLOT( ltNewpage_clicked() ) );
48 connect( headerStatusCB, SIGNAL( clicked() ), this, SLOT( ltHeaderStatus_clicked() ) );
49 connect( headerBorderAboveCB, SIGNAL( clicked() ), this, SLOT( ltHeaderBorderAbove_clicked() ) );
50 connect( headerBorderBelowCB, SIGNAL( clicked() ), this, SLOT( ltHeaderBorderBelow_clicked() ) );
51 connect( firstheaderStatusCB, SIGNAL( clicked() ), this, SLOT( ltFirstHeaderStatus_clicked() ) );
52 connect( firstheaderBorderAboveCB, SIGNAL( clicked() ), this, SLOT( ltFirstHeaderBorderAbove_clicked() ) );
53 connect( firstheaderBorderBelowCB, SIGNAL( clicked() ), this, SLOT( ltFirstHeaderBorderBelow_clicked() ) );
54 connect( firstheaderNoContentsCB, SIGNAL( clicked() ), this, SLOT( ltFirstHeaderEmpty_clicked() ) );
55 connect( footerStatusCB, SIGNAL( clicked() ), this, SLOT( ltFooterStatus_clicked() ) );
56 connect( footerBorderAboveCB, SIGNAL( clicked() ), this, SLOT( ltFooterBorderAbove_clicked() ) );
57 connect( footerBorderBelowCB, SIGNAL( clicked() ), this, SLOT( ltFooterBorderBelow_clicked() ) );
58 connect( lastfooterStatusCB, SIGNAL( clicked() ), this, SLOT( ltLastFooterStatus_clicked() ) );
59 connect( lastfooterBorderAboveCB, SIGNAL( clicked() ), this, SLOT( ltLastFooterBorderAbove_clicked() ) );
60 connect( lastfooterBorderBelowCB, SIGNAL( clicked() ), this, SLOT( ltLastFooterBorderBelow_clicked() ) );
61 connect( lastfooterNoContentsCB, SIGNAL( clicked() ), this, SLOT( ltLastFooterEmpty_clicked() ) );
62 connect( specialAlignmentED, SIGNAL( returnPressed() ), this, SLOT( specialAlignment_changed() ) );
63 connect( widthED, SIGNAL( returnPressed() ), this, SLOT( width_changed() ) );
64 connect( widthUnit, SIGNAL( selectionChanged(LyXLength::UNIT) ), this, SLOT( width_changed() ) );
65 connect( closePB, SIGNAL( clicked() ), this, SLOT( close_clicked() ) );
66 connect( borders, SIGNAL( topSet(bool) ), this, SLOT( topBorder_changed() ) );
67 connect( borders, SIGNAL( bottomSet(bool) ), this, SLOT( bottomBorder_changed() ) );
68 connect( borders, SIGNAL( rightSet(bool) ), this, SLOT( rightBorder_changed() ) );
69 connect( borders, SIGNAL( leftSet(bool) ), this, SLOT( leftBorder_changed() ) );
70 connect( rotateTabularCB, SIGNAL( clicked() ), this, SLOT( rotateTabular() ) );
71 connect( rotateCellCB, SIGNAL( clicked() ), this, SLOT( rotateCell() ) );
72 connect( longTabularCB, SIGNAL( clicked() ), this, SLOT( longTabular() ) );
76 void QTabularDialog::change_adaptor()
82 void QTabularDialog::closeEvent(QCloseEvent * e)
89 void QTabularDialog::close_clicked()
96 void QTabularDialog::borderSet_clicked()
98 form_->controller().set(LyXTabular::SET_ALL_LINES);
99 form_->update_borders();
104 void QTabularDialog::borderUnset_clicked()
106 form_->controller().set(LyXTabular::UNSET_ALL_LINES);
107 form_->update_borders();
112 void QTabularDialog::leftBorder_changed()
114 form_->controller().toggleLeftLine();
119 void QTabularDialog::rightBorder_changed()
121 form_->controller().toggleRightLine();
126 void QTabularDialog::topBorder_changed()
128 form_->controller().toggleTopLine();
133 void QTabularDialog::bottomBorder_changed()
135 form_->controller().toggleBottomLine();
140 void QTabularDialog::specialAlignment_changed()
142 string special = fromqstr(specialAlignmentED->text());
143 form_->controller().setSpecial(special);
148 void QTabularDialog::width_changed()
151 string const width = widgetsToLength(widthED, widthUnit);
152 form_->controller().setWidth(width);
156 void QTabularDialog::multicolumn_clicked()
158 form_->controller().toggleMultiColumn();
163 void QTabularDialog::rotateTabular()
165 form_->controller().rotateTabular(rotateTabularCB->isChecked());
170 void QTabularDialog::rotateCell()
172 form_->controller().rotateCell(rotateCellCB->isChecked());
177 void QTabularDialog::hAlign_changed(int align)
179 ControlTabular::HALIGN h = ControlTabular::LEFT;
182 case 0: h = ControlTabular::LEFT; break;
183 case 1: h = ControlTabular::CENTER; break;
184 case 2: h = ControlTabular::RIGHT; break;
185 case 3: h = ControlTabular::BLOCK; break;
188 form_->controller().halign(h);
192 void QTabularDialog::vAlign_changed(int align)
194 ControlTabular::VALIGN v = ControlTabular::TOP;
197 case 0: v = ControlTabular::TOP; break;
198 case 1: v = ControlTabular::MIDDLE; break;
199 case 2: v = ControlTabular::BOTTOM; break;
202 form_->controller().valign(v);
206 void QTabularDialog::longTabular()
208 form_->controller().longTabular(longTabularCB->isChecked());
213 void QTabularDialog::ltNewpage_clicked()
215 form_->controller().set(LyXTabular::SET_LTNEWPAGE);
220 void QTabularDialog::ltHeaderStatus_clicked()
222 bool enable(headerStatusCB->isChecked());
224 form_->controller().set(LyXTabular::SET_LTHEAD, "");
226 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
227 headerBorderAboveCB->setEnabled(enable);
228 headerBorderBelowCB->setEnabled(enable);
229 firstheaderNoContentsCB->setEnabled(enable);
234 void QTabularDialog::ltHeaderBorderAbove_clicked()
236 if (headerBorderAboveCB->isChecked())
237 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_above");
239 form_->controller().set(LyXTabular::UNSET_LTHEAD, "dl_above");
244 void QTabularDialog::ltHeaderBorderBelow_clicked()
246 if (headerBorderBelowCB->isChecked())
247 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_below");
249 form_->controller().set(LyXTabular::UNSET_LTHEAD, "dl_below");
254 void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
256 if (firstheaderBorderAboveCB->isChecked())
257 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_above");
259 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "dl_above");
264 void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
266 if (firstheaderBorderBelowCB->isChecked())
267 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_below");
269 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "dl_below");
274 void QTabularDialog::ltFirstHeaderStatus_clicked()
276 bool enable(firstheaderStatusCB->isChecked());
278 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "");
280 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
281 firstheaderBorderAboveCB->setEnabled(enable);
282 firstheaderBorderBelowCB->setEnabled(enable);
287 void QTabularDialog::ltFirstHeaderEmpty_clicked()
289 bool enable(firstheaderNoContentsCB->isChecked());
291 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "empty");
293 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "empty");
294 firstheaderStatusCB->setEnabled(!enable);
295 firstheaderBorderAboveCB->setEnabled(!enable);
296 firstheaderBorderBelowCB->setEnabled(!enable);
301 void QTabularDialog::ltFooterStatus_clicked()
303 bool enable(footerStatusCB->isChecked());
305 form_->controller().set(LyXTabular::SET_LTFOOT, "");
307 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
308 footerBorderAboveCB->setEnabled(enable);
309 footerBorderBelowCB->setEnabled(enable);
310 lastfooterNoContentsCB->setEnabled(enable);
315 void QTabularDialog::ltFooterBorderAbove_clicked()
317 if (footerBorderAboveCB->isChecked())
318 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_above");
320 form_->controller().set(LyXTabular::UNSET_LTFOOT, "dl_above");
325 void QTabularDialog::ltFooterBorderBelow_clicked()
327 if (footerBorderBelowCB->isChecked())
328 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_below");
330 form_->controller().set(LyXTabular::UNSET_LTFOOT, "dl_below");
335 void QTabularDialog::ltLastFooterStatus_clicked()
337 bool enable(lastfooterStatusCB->isChecked());
339 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "");
341 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
342 lastfooterBorderAboveCB->setEnabled(enable);
343 lastfooterBorderBelowCB->setEnabled(enable);
348 void QTabularDialog::ltLastFooterBorderAbove_clicked()
350 if (lastfooterBorderAboveCB->isChecked())
351 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_above");
353 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "dl_above");
358 void QTabularDialog::ltLastFooterBorderBelow_clicked()
360 if (lastfooterBorderBelowCB->isChecked())
361 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_below");
363 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "dl_below");
368 void QTabularDialog::ltLastFooterEmpty_clicked()
370 bool enable(lastfooterNoContentsCB->isChecked());
372 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "empty");
374 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "empty");
375 lastfooterStatusCB->setEnabled(!enable);
376 lastfooterBorderAboveCB->setEnabled(!enable);
377 lastfooterBorderBelowCB->setEnabled(!enable);
381 } // namespace frontend
384 #include "QTabularDialog_moc.cpp"