2 * \file QMathMatrixDialog.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Jürgen Spitzmüller
8 * Full author contact details are available in file CREDITS.
13 #include "QMathMatrixDialog.h"
15 #include "EmptyTable.h"
16 #include "qt_helpers.h"
18 #include "controllers/ControlMath.h"
22 #include <qlineedit.h>
23 #include <qpushbutton.h>
28 using std::ostringstream;
36 char h_align_str[80] = "c";
37 char v_align_c[] = "tcb";
42 typedef QController<ControlMath, QView<QMathMatrixDialog> > matrix_base;
45 QMathMatrix::QMathMatrix(Dialog & parent)
46 : matrix_base(parent, _("Math Matrix"))
50 void QMathMatrix::build_dialog()
52 dialog_.reset(new QMathMatrixDialog(this));
56 QMathMatrixDialog::QMathMatrixDialog(QMathMatrix * form)
61 setWindowTitle(qt_("LyX: Insert Matrix"));
63 table->setMinimumSize(100, 100);
65 columnsSB->setValue(5);
66 valignCO->setCurrentIndex(1);
68 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
69 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
71 connect(table, SIGNAL(rowsChanged(int)),
72 rowsSB, SLOT(setValue(int)));
73 connect(table, SIGNAL(colsChanged(int)),
74 columnsSB, SLOT(setValue(int)));
75 connect(rowsSB, SIGNAL(valueChanged(int)),
76 table, SLOT(setNumberRows(int)));
77 connect(columnsSB, SIGNAL(valueChanged(int)),
78 table, SLOT(setNumberColumns(int)));
79 connect(rowsSB, SIGNAL(valueChanged(int)),
80 this, SLOT(rowsChanged(int)));
81 connect(columnsSB, SIGNAL(valueChanged(int)),
82 this, SLOT(columnsChanged(int)) );
83 connect(valignCO, SIGNAL(highlighted(const QString&)),
84 this, SLOT(change_adaptor()));
85 connect(halignED, SIGNAL(textChanged(const QString&)),
86 this, SLOT(change_adaptor()));
90 void QMathMatrixDialog::columnsChanged(int)
92 int const nx = int(columnsSB->value());
93 for (int i = 0; i < nx; ++i)
96 h_align_str[nx] = '\0';
97 halignED->setText(h_align_str);
101 void QMathMatrixDialog::rowsChanged(int)
106 void QMathMatrixDialog::change_adaptor()
108 // FIXME: We need a filter for the halign input
112 void QMathMatrixDialog::slotOK()
114 char const c = v_align_c[valignCO->currentIndex()];
115 string const sh = fromqstr(halignED->text());
116 int const nx = int(columnsSB->value());
117 int const ny = int(rowsSB->value());
120 os << nx << ' ' << ny << ' ' << c << ' ' << sh;
121 form_->controller().dispatchMatrix(os.str().c_str());
128 void QMathMatrixDialog::slotClose()
133 } // namespace frontend
136 #include "QMathMatrixDialog_moc.cpp"