]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QMathMatrixDialog.C
Remove quite a few compiler warnings:
[lyx.git] / src / frontends / qt4 / QMathMatrixDialog.C
1 /**
2  * \file QMathMatrixDialog.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Jürgen Spitzmüller
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "QMathMatrixDialog.h"
14 #include "QMath.h"
15
16 #include "emptytable.h"
17 #include "qt_helpers.h"
18
19 #include "controllers/ControlMath.h"
20
21 #include <sstream>
22
23 #include <qlineedit.h>
24 #include <qpushbutton.h>
25 #include <qspinbox.h>
26
27 using std::ostringstream;
28 using std::string;
29
30 namespace lyx {
31 namespace frontend {
32
33 namespace {
34
35 char h_align_str[80] = "c";
36 char v_align_c[] = "tcb";
37
38 } // namespace anon
39
40
41 QMathMatrixDialog::QMathMatrixDialog(QMathMatrix * form)
42         : form_(form)
43 {
44         setupUi(this);
45
46         setCaption(qt_("LyX: Insert Matrix"));
47
48         table->setMinimumSize(100, 100);
49         rowsSB->setValue(2);
50         columnsSB->setValue(2);
51         valignCO->setCurrentItem(1);
52
53         connect(okPB, SIGNAL(clicked()),
54                 this, SLOT(slotOK()));
55         connect(closePB, SIGNAL(clicked()),
56                 this, SLOT(slotClose()));
57
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() ) );
66 }
67
68
69 void QMathMatrixDialog::columnsChanged(int)
70 {
71         int const nx = int(columnsSB->value());
72         for (int i = 0; i < nx; ++i)
73                 h_align_str[i] = 'c';
74
75         h_align_str[nx] = '\0';
76         halignED->setText(h_align_str);
77
78         return;
79 }
80
81
82 void QMathMatrixDialog::rowsChanged(int)
83 {
84 }
85
86
87 void QMathMatrixDialog::change_adaptor()
88 {
89         // FIXME: We need a filter for the halign input
90 }
91
92
93 void QMathMatrixDialog::slotOK()
94 {
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());
99
100         ostringstream os;
101         os << nx << ' ' << ny << ' ' << c << ' ' << sh;
102         form_->controller().dispatchMatrix(os.str().c_str());
103
104         // close the dialog
105         close();
106 }
107
108
109 void QMathMatrixDialog::slotClose()
110 {
111         close();
112 }
113
114 } // namespace frontend
115 } // namespace lyx
116
117 #include "QMathMatrixDialog_moc.cpp"