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 setCaption(qt_("LyX: Insert Matrix"));
48 table->setMinimumSize(100, 100);
50 columnsSB->setValue(2);
51 valignCO->setCurrentItem(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);
82 void QMathMatrixDialog::rowsChanged(int)
87 void QMathMatrixDialog::change_adaptor()
89 // FIXME: We need a filter for the halign input
93 void QMathMatrixDialog::slotOK()
95 char const c = v_align_c[valignCO->currentItem()];
96 string const sh = fromqstr(halignED->text());
97 int const nx = int(columnsSB->value());
98 int const ny = int(rowsSB->value());
101 os << nx << ' ' << ny << ' ' << c << ' ' << sh;
102 form_->controller().dispatchMatrix(os.str().c_str());
109 void QMathMatrixDialog::slotClose()
114 } // namespace frontend
117 #include "QMathMatrixDialog_moc.cpp"