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 #pragma implementation
19 #include "ControlTabular.h"
22 #include "QTabularDialog.h"
24 #include "lengthcombo.h"
25 #include "qsetborder.h"
26 #include "qt_helpers.h"
28 #include <qcheckbox.h>
29 #include <qpushbutton.h>
30 #include <qlineedit.h>
33 QTabularDialog::QTabularDialog(QTabular * form)
34 : QTabularDialogBase(0, 0, false, 0),
37 connect(closePB, SIGNAL(clicked()),
38 form, SLOT(slotClose()));
42 void QTabularDialog::change_adaptor()
48 void QTabularDialog::closeEvent(QCloseEvent * e)
54 void QTabularDialog::close_clicked()
59 void QTabularDialog::columnAppend_clicked()
61 form_->controller().set(LyXTabular::APPEND_COLUMN);
65 void QTabularDialog::rowAppend_clicked()
67 form_->controller().set(LyXTabular::APPEND_ROW);
71 void QTabularDialog::columnDelete_clicked()
73 form_->controller().set(LyXTabular::DELETE_COLUMN);
77 void QTabularDialog::rowDelete_clicked()
79 form_->controller().set(LyXTabular::DELETE_ROW);
83 void QTabularDialog::borderSet_clicked()
85 form_->controller().set(LyXTabular::SET_ALL_LINES);
86 form_->update_borders();
90 void QTabularDialog::borderUnset_clicked()
92 form_->controller().set(LyXTabular::UNSET_ALL_LINES);
93 form_->update_borders();
98 void QTabularDialog::leftBorder_changed()
100 if (form_->controller().isMulticolumnCell())
101 form_->controller().set(LyXTabular::M_TOGGLE_LINE_LEFT);
103 form_->controller().set(LyXTabular::TOGGLE_LINE_LEFT);
108 void QTabularDialog::rightBorder_changed()
110 if (form_->controller().isMulticolumnCell())
111 form_->controller().set(LyXTabular::M_TOGGLE_LINE_RIGHT);
113 form_->controller().set(LyXTabular::TOGGLE_LINE_RIGHT);
118 void QTabularDialog::topBorder_changed()
120 if (form_->controller().isMulticolumnCell())
121 form_->controller().set(LyXTabular::M_TOGGLE_LINE_TOP);
123 form_->controller().set(LyXTabular::TOGGLE_LINE_TOP);
128 void QTabularDialog::bottomBorder_changed()
130 if (form_->controller().isMulticolumnCell())
131 form_->controller().set(LyXTabular::M_TOGGLE_LINE_BOTTOM);
133 form_->controller().set(LyXTabular::TOGGLE_LINE_BOTTOM);
138 void QTabularDialog::specialAlignment_changed()
140 string special = fromqstr(specialAlignmentED->text());
141 if (form_->controller().isMulticolumnCell())
142 form_->controller().set(LyXTabular::SET_SPECIAL_MULTI, special);
144 form_->controller().set(LyXTabular::SET_SPECIAL_COLUMN, special);
148 void QTabularDialog::width_changed()
151 LyXLength(widthED->text().toDouble(),
152 widthUnit->currentLengthItem()).asString();
153 if (form_->controller().isMulticolumnCell())
154 form_->controller().set(LyXTabular::SET_MPWIDTH, width);
156 form_->controller().set(LyXTabular::SET_PWIDTH, width);
158 form_->update_contents();
162 void QTabularDialog::multicolumn_clicked()
164 form_->controller().set(LyXTabular::MULTICOLUMN);
166 form_->update_contents();
170 void QTabularDialog::rotateTabular_checked(int state)
174 form_->controller().set(LyXTabular::UNSET_ROTATE_TABULAR);
177 // "no change state", should not happen
180 form_->controller().set(LyXTabular::SET_ROTATE_TABULAR);
186 void QTabularDialog::rotateCell_checked(int state)
190 form_->controller().set(LyXTabular::UNSET_ROTATE_CELL);
193 // "no change state", should not happen
196 form_->controller().set(LyXTabular::SET_ROTATE_CELL);
202 void QTabularDialog::hAlign_changed(int align)
204 LyXTabular::Feature num = LyXTabular::ALIGN_LEFT;
205 LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
210 num = LyXTabular::ALIGN_LEFT;
211 multi_num = LyXTabular::M_ALIGN_LEFT;
216 num = LyXTabular::ALIGN_CENTER;
217 multi_num = LyXTabular::M_ALIGN_CENTER;
222 num = LyXTabular::ALIGN_RIGHT;
223 multi_num = LyXTabular::M_ALIGN_RIGHT;
227 num = LyXTabular::ALIGN_BLOCK;
228 //multi_num: no equivalent
233 if (form_->controller().isMulticolumnCell())
234 form_->controller().set(multi_num);
236 form_->controller().set(num);
240 void QTabularDialog::vAlign_changed(int align)
242 LyXTabular::Feature num = LyXTabular::VALIGN_CENTER;
243 LyXTabular::Feature multi_num = LyXTabular::M_VALIGN_CENTER;
248 num = LyXTabular::VALIGN_TOP;
249 multi_num = LyXTabular::M_VALIGN_TOP;
254 num = LyXTabular::VALIGN_CENTER;
255 multi_num = LyXTabular::M_VALIGN_CENTER;
260 num = LyXTabular::VALIGN_BOTTOM;
261 multi_num = LyXTabular::M_VALIGN_BOTTOM;
265 if (form_->controller().isMulticolumnCell())
266 form_->controller().set(multi_num);
268 form_->controller().set(num);
272 void QTabularDialog::longTabular_changed(int state)
276 form_->controller().set(LyXTabular::UNSET_LONGTABULAR);
279 // "no change state", should not happen
282 form_->controller().set(LyXTabular::SET_LONGTABULAR);
289 void QTabularDialog::ltNewpage_clicked()
291 form_->controller().set(LyXTabular::SET_LTNEWPAGE);
296 void QTabularDialog::ltHeaderStatus_clicked()
298 bool enable(headerStatusCB->isChecked());
300 form_->controller().set(LyXTabular::SET_LTHEAD, "");
302 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
303 headerBorderAboveCB->setEnabled(enable);
304 headerBorderBelowCB->setEnabled(enable);
305 firstheaderNoContentsCB->setEnabled(enable);
310 void QTabularDialog::ltHeaderBorderAbove_clicked()
312 if (headerBorderAboveCB->isChecked())
313 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_above");
315 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
320 void QTabularDialog::ltHeaderBorderBelow_clicked()
322 if (headerBorderBelowCB->isChecked())
323 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_below");
325 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
330 void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
332 if (firstheaderBorderAboveCB->isChecked())
333 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_above");
335 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
340 void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
342 if (firstheaderBorderBelowCB->isChecked())
343 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_below");
345 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
350 void QTabularDialog::ltFirstHeaderStatus_clicked()
352 bool enable(firstheaderStatusCB->isChecked());
354 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "");
356 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
357 firstheaderBorderAboveCB->setEnabled(enable);
358 firstheaderBorderBelowCB->setEnabled(enable);
363 void QTabularDialog::ltFirstHeaderEmpty_clicked()
365 bool enable(firstheaderNoContentsCB->isChecked());
367 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "empty");
369 ltFirstHeaderBorderBelow_clicked();
370 ltFirstHeaderBorderAbove_clicked();
372 firstheaderStatusCB->setEnabled(!enable);
373 firstheaderBorderAboveCB->setEnabled(!enable);
374 firstheaderBorderBelowCB->setEnabled(!enable);
379 void QTabularDialog::ltFooterStatus_clicked()
381 bool enable(footerStatusCB->isChecked());
383 form_->controller().set(LyXTabular::SET_LTFOOT, "");
385 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
386 footerBorderAboveCB->setEnabled(enable);
387 footerBorderBelowCB->setEnabled(enable);
388 lastfooterNoContentsCB->setEnabled(enable);
393 void QTabularDialog::ltFooterBorderAbove_clicked()
395 if (footerBorderAboveCB->isChecked())
396 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_above");
398 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
403 void QTabularDialog::ltFooterBorderBelow_clicked()
405 if (footerBorderBelowCB->isChecked())
406 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_below");
408 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
413 void QTabularDialog::ltLastFooterStatus_clicked()
415 bool enable(lastfooterStatusCB->isChecked());
417 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "");
419 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
420 lastfooterBorderAboveCB->setEnabled(enable);
421 lastfooterBorderBelowCB->setEnabled(enable);
426 void QTabularDialog::ltLastFooterBorderAbove_clicked()
428 if (lastfooterBorderAboveCB->isChecked())
429 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_above");
431 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
436 void QTabularDialog::ltLastFooterBorderBelow_clicked()
438 if (lastfooterBorderBelowCB->isChecked())
439 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_below");
441 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
446 void QTabularDialog::ltLastFooterEmpty_clicked()
448 bool enable(lastfooterNoContentsCB->isChecked());
450 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "empty");
452 ltLastFooterBorderBelow_clicked();
453 ltLastFooterBorderAbove_clicked();
455 lastfooterStatusCB->setEnabled(!enable);
456 lastfooterBorderAboveCB->setEnabled(!enable);
457 lastfooterBorderBelowCB->setEnabled(!enable);