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"
18 #include <QCloseEvent>
19 #include "validators.h"
20 #include "qt_helpers.h"
22 #include "controllers/ControlTabular.h"
25 #include <QPushButton>
34 QTabularDialog::QTabularDialog(QTabular * form)
39 connect(closePB, SIGNAL(clicked()),
40 form, SLOT(slotClose()));
42 widthED->setValidator(unsignedLengthValidator(widthED));
44 connect( borderSetPB, SIGNAL( clicked() ), this, SLOT( borderSet_clicked() ) );
45 connect( borderUnsetPB, SIGNAL( clicked() ), this, SLOT( borderUnset_clicked() ) );
46 connect( longTabularCB, SIGNAL( toggled(bool) ), longtableGB, SLOT( setEnabled(bool) ) );
47 connect( longTabularCB, SIGNAL( toggled(bool) ), newpageCB, SLOT( setEnabled(bool) ) );
48 connect( hAlignCB, SIGNAL( activated(int) ), this, SLOT( hAlign_changed(int) ) );
49 connect( vAlignCB, SIGNAL( activated(int) ), this, SLOT( vAlign_changed(int) ) );
50 connect( multicolumnCB, SIGNAL( clicked() ), this, SLOT( multicolumn_clicked() ) );
51 connect( newpageCB, SIGNAL( clicked() ), this, SLOT( ltNewpage_clicked() ) );
52 connect( headerStatusCB, SIGNAL( clicked() ), this, SLOT( ltHeaderStatus_clicked() ) );
53 connect( headerBorderAboveCB, SIGNAL( clicked() ), this, SLOT( ltHeaderBorderAbove_clicked() ) );
54 connect( headerBorderBelowCB, SIGNAL( clicked() ), this, SLOT( ltHeaderBorderBelow_clicked() ) );
55 connect( firstheaderStatusCB, SIGNAL( clicked() ), this, SLOT( ltFirstHeaderStatus_clicked() ) );
56 connect( firstheaderBorderAboveCB, SIGNAL( clicked() ), this, SLOT( ltFirstHeaderBorderAbove_clicked() ) );
57 connect( firstheaderBorderBelowCB, SIGNAL( clicked() ), this, SLOT( ltFirstHeaderBorderBelow_clicked() ) );
58 connect( firstheaderNoContentsCB, SIGNAL( clicked() ), this, SLOT( ltFirstHeaderEmpty_clicked() ) );
59 connect( footerStatusCB, SIGNAL( clicked() ), this, SLOT( ltFooterStatus_clicked() ) );
60 connect( footerBorderAboveCB, SIGNAL( clicked() ), this, SLOT( ltFooterBorderAbove_clicked() ) );
61 connect( footerBorderBelowCB, SIGNAL( clicked() ), this, SLOT( ltFooterBorderBelow_clicked() ) );
62 connect( lastfooterStatusCB, SIGNAL( clicked() ), this, SLOT( ltLastFooterStatus_clicked() ) );
63 connect( lastfooterBorderAboveCB, SIGNAL( clicked() ), this, SLOT( ltLastFooterBorderAbove_clicked() ) );
64 connect( lastfooterBorderBelowCB, SIGNAL( clicked() ), this, SLOT( ltLastFooterBorderBelow_clicked() ) );
65 connect( lastfooterNoContentsCB, SIGNAL( clicked() ), this, SLOT( ltLastFooterEmpty_clicked() ) );
66 connect( specialAlignmentED, SIGNAL( returnPressed() ), this, SLOT( specialAlignment_changed() ) );
67 connect( widthED, SIGNAL( returnPressed() ), this, SLOT( width_changed() ) );
68 connect( widthUnit, SIGNAL( selectionChanged(LyXLength::UNIT) ), this, SLOT( width_changed() ) );
69 connect( closePB, SIGNAL( clicked() ), this, SLOT( close_clicked() ) );
70 connect( borders, SIGNAL( topSet(bool) ), this, SLOT( topBorder_changed() ) );
71 connect( borders, SIGNAL( bottomSet(bool) ), this, SLOT( bottomBorder_changed() ) );
72 connect( borders, SIGNAL( rightSet(bool) ), this, SLOT( rightBorder_changed() ) );
73 connect( borders, SIGNAL( leftSet(bool) ), this, SLOT( leftBorder_changed() ) );
74 connect( rotateTabularCB, SIGNAL( clicked() ), this, SLOT( rotateTabular() ) );
75 connect( rotateCellCB, SIGNAL( clicked() ), this, SLOT( rotateCell() ) );
76 connect( longTabularCB, SIGNAL( clicked() ), this, SLOT( longTabular() ) );
80 void QTabularDialog::change_adaptor()
86 void QTabularDialog::closeEvent(QCloseEvent * e)
93 void QTabularDialog::close_clicked()
99 void QTabularDialog::borderSet_clicked()
101 form_->controller().set(LyXTabular::SET_ALL_LINES);
102 form_->update_borders();
107 void QTabularDialog::borderUnset_clicked()
109 form_->controller().set(LyXTabular::UNSET_ALL_LINES);
110 form_->update_borders();
115 void QTabularDialog::leftBorder_changed()
117 form_->controller().toggleLeftLine();
122 void QTabularDialog::rightBorder_changed()
124 form_->controller().toggleRightLine();
129 void QTabularDialog::topBorder_changed()
131 form_->controller().toggleTopLine();
136 void QTabularDialog::bottomBorder_changed()
138 form_->controller().toggleBottomLine();
143 void QTabularDialog::specialAlignment_changed()
145 string special = fromqstr(specialAlignmentED->text());
146 form_->controller().setSpecial(special);
151 void QTabularDialog::width_changed()
154 string const width = widgetsToLength(widthED, widthUnit);
155 form_->controller().setWidth(width);
159 void QTabularDialog::multicolumn_clicked()
161 form_->controller().toggleMultiColumn();
166 void QTabularDialog::rotateTabular()
168 form_->controller().rotateTabular(rotateTabularCB->isChecked());
173 void QTabularDialog::rotateCell()
175 form_->controller().rotateCell(rotateCellCB->isChecked());
180 void QTabularDialog::hAlign_changed(int align)
182 ControlTabular::HALIGN h = ControlTabular::LEFT;
185 case 0: h = ControlTabular::LEFT; break;
186 case 1: h = ControlTabular::CENTER; break;
187 case 2: h = ControlTabular::RIGHT; break;
188 case 3: h = ControlTabular::BLOCK; break;
191 form_->controller().halign(h);
195 void QTabularDialog::vAlign_changed(int align)
197 ControlTabular::VALIGN v = ControlTabular::TOP;
200 case 0: v = ControlTabular::TOP; break;
201 case 1: v = ControlTabular::MIDDLE; break;
202 case 2: v = ControlTabular::BOTTOM; break;
205 form_->controller().valign(v);
209 void QTabularDialog::longTabular()
211 form_->controller().longTabular(longTabularCB->isChecked());
216 void QTabularDialog::ltNewpage_clicked()
218 form_->controller().set(LyXTabular::SET_LTNEWPAGE);
223 void QTabularDialog::ltHeaderStatus_clicked()
225 bool enable(headerStatusCB->isChecked());
227 form_->controller().set(LyXTabular::SET_LTHEAD, "");
229 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
230 headerBorderAboveCB->setEnabled(enable);
231 headerBorderBelowCB->setEnabled(enable);
232 firstheaderNoContentsCB->setEnabled(enable);
237 void QTabularDialog::ltHeaderBorderAbove_clicked()
239 if (headerBorderAboveCB->isChecked())
240 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_above");
242 form_->controller().set(LyXTabular::UNSET_LTHEAD, "dl_above");
247 void QTabularDialog::ltHeaderBorderBelow_clicked()
249 if (headerBorderBelowCB->isChecked())
250 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_below");
252 form_->controller().set(LyXTabular::UNSET_LTHEAD, "dl_below");
257 void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
259 if (firstheaderBorderAboveCB->isChecked())
260 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_above");
262 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "dl_above");
267 void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
269 if (firstheaderBorderBelowCB->isChecked())
270 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_below");
272 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "dl_below");
277 void QTabularDialog::ltFirstHeaderStatus_clicked()
279 bool enable(firstheaderStatusCB->isChecked());
281 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "");
283 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
284 firstheaderBorderAboveCB->setEnabled(enable);
285 firstheaderBorderBelowCB->setEnabled(enable);
290 void QTabularDialog::ltFirstHeaderEmpty_clicked()
292 bool enable(firstheaderNoContentsCB->isChecked());
294 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "empty");
296 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "empty");
297 firstheaderStatusCB->setEnabled(!enable);
298 firstheaderBorderAboveCB->setEnabled(!enable);
299 firstheaderBorderBelowCB->setEnabled(!enable);
304 void QTabularDialog::ltFooterStatus_clicked()
306 bool enable(footerStatusCB->isChecked());
308 form_->controller().set(LyXTabular::SET_LTFOOT, "");
310 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
311 footerBorderAboveCB->setEnabled(enable);
312 footerBorderBelowCB->setEnabled(enable);
313 lastfooterNoContentsCB->setEnabled(enable);
318 void QTabularDialog::ltFooterBorderAbove_clicked()
320 if (footerBorderAboveCB->isChecked())
321 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_above");
323 form_->controller().set(LyXTabular::UNSET_LTFOOT, "dl_above");
328 void QTabularDialog::ltFooterBorderBelow_clicked()
330 if (footerBorderBelowCB->isChecked())
331 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_below");
333 form_->controller().set(LyXTabular::UNSET_LTFOOT, "dl_below");
338 void QTabularDialog::ltLastFooterStatus_clicked()
340 bool enable(lastfooterStatusCB->isChecked());
342 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "");
344 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
345 lastfooterBorderAboveCB->setEnabled(enable);
346 lastfooterBorderBelowCB->setEnabled(enable);
351 void QTabularDialog::ltLastFooterBorderAbove_clicked()
353 if (lastfooterBorderAboveCB->isChecked())
354 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_above");
356 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "dl_above");
361 void QTabularDialog::ltLastFooterBorderBelow_clicked()
363 if (lastfooterBorderBelowCB->isChecked())
364 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_below");
366 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "dl_below");
371 void QTabularDialog::ltLastFooterEmpty_clicked()
373 bool enable(lastfooterNoContentsCB->isChecked());
375 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "empty");
377 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "empty");
378 lastfooterStatusCB->setEnabled(!enable);
379 lastfooterBorderAboveCB->setEnabled(!enable);
380 lastfooterBorderBelowCB->setEnabled(!enable);
384 } // namespace frontend
387 #include "QTabularDialog_moc.cpp"