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 Juergen Spitzmueller
10 * Full author contact details are available in file CREDITS
16 #include "ControlTabular.h"
19 #include "QTabularDialog.h"
21 #include "lengthcombo.h"
22 #include "qsetborder.h"
23 #include "qt_helpers.h"
25 #include <qcheckbox.h>
26 #include <qpushbutton.h>
27 #include <qlineedit.h>
30 QTabularDialog::QTabularDialog(QTabular * form)
31 : QTabularDialogBase(0, 0, false, 0),
34 connect(closePB, SIGNAL(clicked()),
35 form, SLOT(slotClose()));
39 void QTabularDialog::change_adaptor()
45 void QTabularDialog::closeEvent(QCloseEvent * e)
51 void QTabularDialog::close_clicked()
56 void QTabularDialog::columnAppend_clicked()
58 form_->controller().set(LyXTabular::APPEND_COLUMN);
62 void QTabularDialog::rowAppend_clicked()
64 form_->controller().set(LyXTabular::APPEND_ROW);
68 void QTabularDialog::columnDelete_clicked()
70 form_->controller().set(LyXTabular::DELETE_COLUMN);
74 void QTabularDialog::rowDelete_clicked()
76 form_->controller().set(LyXTabular::DELETE_ROW);
80 void QTabularDialog::borderSet_clicked()
82 form_->controller().set(LyXTabular::SET_ALL_LINES);
83 form_->update_borders();
87 void QTabularDialog::borderUnset_clicked()
89 form_->controller().set(LyXTabular::UNSET_ALL_LINES);
90 form_->update_borders();
95 void QTabularDialog::leftBorder_changed()
97 if (form_->controller().isMulticolumnCell())
98 form_->controller().set(LyXTabular::M_TOGGLE_LINE_LEFT);
100 form_->controller().set(LyXTabular::TOGGLE_LINE_LEFT);
105 void QTabularDialog::rightBorder_changed()
107 if (form_->controller().isMulticolumnCell())
108 form_->controller().set(LyXTabular::M_TOGGLE_LINE_RIGHT);
110 form_->controller().set(LyXTabular::TOGGLE_LINE_RIGHT);
115 void QTabularDialog::topBorder_changed()
117 if (form_->controller().isMulticolumnCell())
118 form_->controller().set(LyXTabular::M_TOGGLE_LINE_TOP);
120 form_->controller().set(LyXTabular::TOGGLE_LINE_TOP);
125 void QTabularDialog::bottomBorder_changed()
127 if (form_->controller().isMulticolumnCell())
128 form_->controller().set(LyXTabular::M_TOGGLE_LINE_BOTTOM);
130 form_->controller().set(LyXTabular::TOGGLE_LINE_BOTTOM);
135 void QTabularDialog::specialAlignment_changed()
137 string special = fromqstr(specialAlignmentED->text());
138 if (form_->controller().isMulticolumnCell())
139 form_->controller().set(LyXTabular::SET_SPECIAL_MULTI, special);
141 form_->controller().set(LyXTabular::SET_SPECIAL_COLUMN, special);
145 void QTabularDialog::width_changed()
148 LyXLength(widthED->text().toDouble(),
149 widthUnit->currentLengthItem()).asString();
150 if (form_->controller().isMulticolumnCell())
151 form_->controller().set(LyXTabular::SET_MPWIDTH, width);
153 form_->controller().set(LyXTabular::SET_PWIDTH, width);
155 form_->update_contents();
159 void QTabularDialog::multicolumn_clicked()
161 form_->controller().set(LyXTabular::MULTICOLUMN);
163 form_->update_contents();
167 void QTabularDialog::rotateTabular_checked(int state)
171 form_->controller().set(LyXTabular::UNSET_ROTATE_TABULAR);
174 // "no change state", should not happen
177 form_->controller().set(LyXTabular::SET_ROTATE_TABULAR);
183 void QTabularDialog::rotateCell_checked(int state)
187 form_->controller().set(LyXTabular::UNSET_ROTATE_CELL);
190 // "no change state", should not happen
193 form_->controller().set(LyXTabular::SET_ROTATE_CELL);
199 void QTabularDialog::hAlign_changed(int align)
201 LyXTabular::Feature num = LyXTabular::ALIGN_LEFT;
202 LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
207 num = LyXTabular::ALIGN_LEFT;
208 multi_num = LyXTabular::M_ALIGN_LEFT;
213 num = LyXTabular::ALIGN_CENTER;
214 multi_num = LyXTabular::M_ALIGN_CENTER;
219 num = LyXTabular::ALIGN_RIGHT;
220 multi_num = LyXTabular::M_ALIGN_RIGHT;
224 num = LyXTabular::ALIGN_BLOCK;
225 //multi_num: no equivalent
230 if (form_->controller().isMulticolumnCell())
231 form_->controller().set(multi_num);
233 form_->controller().set(num);
237 void QTabularDialog::vAlign_changed(int align)
239 LyXTabular::Feature num = LyXTabular::VALIGN_CENTER;
240 LyXTabular::Feature multi_num = LyXTabular::M_VALIGN_CENTER;
245 num = LyXTabular::VALIGN_TOP;
246 multi_num = LyXTabular::M_VALIGN_TOP;
251 num = LyXTabular::VALIGN_CENTER;
252 multi_num = LyXTabular::M_VALIGN_CENTER;
257 num = LyXTabular::VALIGN_BOTTOM;
258 multi_num = LyXTabular::M_VALIGN_BOTTOM;
262 if (form_->controller().isMulticolumnCell())
263 form_->controller().set(multi_num);
265 form_->controller().set(num);
269 void QTabularDialog::longTabular_changed(int state)
273 form_->controller().set(LyXTabular::UNSET_LONGTABULAR);
276 // "no change state", should not happen
279 form_->controller().set(LyXTabular::SET_LONGTABULAR);
286 void QTabularDialog::ltNewpage_clicked()
288 form_->controller().set(LyXTabular::SET_LTNEWPAGE);
293 void QTabularDialog::ltHeaderStatus_clicked()
295 bool enable(headerStatusCB->isChecked());
297 form_->controller().set(LyXTabular::SET_LTHEAD, "");
299 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
300 headerBorderAboveCB->setEnabled(enable);
301 headerBorderBelowCB->setEnabled(enable);
302 firstheaderNoContentsCB->setEnabled(enable);
307 void QTabularDialog::ltHeaderBorderAbove_clicked()
309 if (headerBorderAboveCB->isChecked())
310 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_above");
312 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
317 void QTabularDialog::ltHeaderBorderBelow_clicked()
319 if (headerBorderBelowCB->isChecked())
320 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_below");
322 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
327 void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
329 if (firstheaderBorderAboveCB->isChecked())
330 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_above");
332 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
337 void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
339 if (firstheaderBorderBelowCB->isChecked())
340 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_below");
342 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
347 void QTabularDialog::ltFirstHeaderStatus_clicked()
349 bool enable(firstheaderStatusCB->isChecked());
351 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "");
353 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
354 firstheaderBorderAboveCB->setEnabled(enable);
355 firstheaderBorderBelowCB->setEnabled(enable);
360 void QTabularDialog::ltFirstHeaderEmpty_clicked()
362 bool enable(firstheaderNoContentsCB->isChecked());
364 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "empty");
366 ltFirstHeaderBorderBelow_clicked();
367 ltFirstHeaderBorderAbove_clicked();
369 firstheaderStatusCB->setEnabled(!enable);
370 firstheaderBorderAboveCB->setEnabled(!enable);
371 firstheaderBorderBelowCB->setEnabled(!enable);
376 void QTabularDialog::ltFooterStatus_clicked()
378 bool enable(footerStatusCB->isChecked());
380 form_->controller().set(LyXTabular::SET_LTFOOT, "");
382 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
383 footerBorderAboveCB->setEnabled(enable);
384 footerBorderBelowCB->setEnabled(enable);
385 lastfooterNoContentsCB->setEnabled(enable);
390 void QTabularDialog::ltFooterBorderAbove_clicked()
392 if (footerBorderAboveCB->isChecked())
393 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_above");
395 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
400 void QTabularDialog::ltFooterBorderBelow_clicked()
402 if (footerBorderBelowCB->isChecked())
403 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_below");
405 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
410 void QTabularDialog::ltLastFooterStatus_clicked()
412 bool enable(lastfooterStatusCB->isChecked());
414 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "");
416 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
417 lastfooterBorderAboveCB->setEnabled(enable);
418 lastfooterBorderBelowCB->setEnabled(enable);
423 void QTabularDialog::ltLastFooterBorderAbove_clicked()
425 if (lastfooterBorderAboveCB->isChecked())
426 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_above");
428 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
433 void QTabularDialog::ltLastFooterBorderBelow_clicked()
435 if (lastfooterBorderBelowCB->isChecked())
436 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_below");
438 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
443 void QTabularDialog::ltLastFooterEmpty_clicked()
445 bool enable(lastfooterNoContentsCB->isChecked());
447 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "empty");
449 ltLastFooterBorderBelow_clicked();
450 ltLastFooterBorderAbove_clicked();
452 lastfooterStatusCB->setEnabled(!enable);
453 lastfooterBorderAboveCB->setEnabled(!enable);
454 lastfooterBorderBelowCB->setEnabled(!enable);