2 * \file QMathMatrixDialog.C
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"
16 #include "emptytable.h"
17 #include "qt_helpers.h"
19 #include "controllers/ControlMath.h"
23 #include <qlineedit.h>
24 #include <qpushbutton.h>
27 using std::ostringstream;
35 char h_align_str[80] = "c";
36 char v_align_c[] = "tcb";
41 QMathMatrixDialog::QMathMatrixDialog(QMathMatrix * form)
46 setWindowTitle(qt_("LyX: Insert Matrix"));
48 table->setMinimumSize(100, 100);
50 columnsSB->setValue(2);
51 valignCO->setCurrentIndex(1);
53 connect(okPB, SIGNAL(clicked()),
54 this, SLOT(slotOK()));
55 connect(closePB, SIGNAL(clicked()),
56 this, SLOT(slotClose()));
58 connect( table, SIGNAL( rowsChanged(int) ), rowsSB, SLOT( setValue(int) ) );
59 connect( table, SIGNAL( colsChanged(int) ), columnsSB, SLOT( setValue(int) ) );
60 connect( rowsSB, SIGNAL( valueChanged(int) ), table, SLOT( setNumberRows(int) ) );
61 connect( columnsSB, SIGNAL( valueChanged(int) ), table, SLOT( setNumberColumns(int) ) );
62 connect( rowsSB, SIGNAL( valueChanged(int) ), this, SLOT( rowsChanged(int) ) );
63 connect( columnsSB, SIGNAL( valueChanged(int) ), this, SLOT( columnsChanged(int) ) );
64 connect( valignCO, SIGNAL( highlighted(const QString&) ), this, SLOT( change_adaptor() ) );
65 connect( halignED, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
69 void QMathMatrixDialog::columnsChanged(int)
71 int const nx = int(columnsSB->value());
72 for (int i = 0; i < nx; ++i)
75 h_align_str[nx] = '\0';
76 halignED->setText(h_align_str);
80 void QMathMatrixDialog::rowsChanged(int)
85 void QMathMatrixDialog::change_adaptor()
87 // FIXME: We need a filter for the halign input
91 void QMathMatrixDialog::slotOK()
93 char const c = v_align_c[valignCO->currentIndex()];
94 string const sh = fromqstr(halignED->text());
95 int const nx = int(columnsSB->value());
96 int const ny = int(rowsSB->value());
99 os << nx << ' ' << ny << ' ' << c << ' ' << sh;
100 form_->controller().dispatchMatrix(os.str().c_str());
107 void QMathMatrixDialog::slotClose()
112 } // namespace frontend
115 #include "QMathMatrixDialog_moc.cpp"