1
/***************************************************************************
2
File : MatrixDialog.cpp
4
--------------------------------------------------------------------
5
Copyright : (C) 2006 by Ion Vasilief, Tilman Hoener zu Siederdissen
6
Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net
7
Description : Matrix properties dialog
9
***************************************************************************/
11
/***************************************************************************
13
* This program is free software; you can redistribute it and/or modify *
14
* it under the terms of the GNU General Public License as published by *
15
* the Free Software Foundation; either version 2 of the License, or *
16
* (at your option) any later version. *
18
* This program is distributed in the hope that it will be useful, *
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21
* GNU General Public License for more details. *
23
* You should have received a copy of the GNU General Public License *
24
* along with this program; if not, write to the Free Software *
25
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26
* Boston, MA 02110-1301 USA *
28
***************************************************************************/
29
#include "MatrixDialog.h"
32
#include <QPushButton>
39
MatrixDialog::MatrixDialog( QWidget* parent, Qt::WFlags fl )
40
: QDialog( parent, fl ),
43
setWindowTitle( tr( "QtiPlot - Matrix Properties" ) );
45
QGridLayout * topLayout = new QGridLayout();
46
QHBoxLayout * bottomLayout = new QHBoxLayout();
48
topLayout->addWidget( new QLabel(tr( "Cell Width" )), 0, 0 );
49
boxColWidth = new QSpinBox();
50
boxColWidth->setRange(0,1000);
51
boxColWidth->setSingleStep(10);
52
topLayout->addWidget( boxColWidth, 0, 1 );
54
topLayout->addWidget( new QLabel(tr( "Data Format" )), 1, 0 );
55
boxFormat = new QComboBox();
56
boxFormat->addItem( tr( "Decimal: 1000" ) );
57
boxFormat->addItem( tr( "Scientific: 1E3" ) );
59
topLayout->addWidget( boxFormat, 1, 1 );
61
topLayout->addWidget( new QLabel( tr( "Numeric Display" )), 2, 0 );
62
boxNumericDisplay = new QComboBox();
63
boxNumericDisplay->addItem( tr( "Default Decimal Digits" ) );
64
boxNumericDisplay->addItem( tr( "Significant Digits=" ) );
66
topLayout->addWidget( boxNumericDisplay, 2, 1 );
67
boxPrecision = new QSpinBox();
68
boxPrecision->setRange(0,100);
69
boxPrecision->setEnabled( false );
70
topLayout->addWidget( boxPrecision, 2, 2 );
72
buttonApply = new QPushButton(tr( "&Apply" ));
73
buttonApply->setAutoDefault( true );
74
bottomLayout->addWidget( buttonApply );
76
buttonOk = new QPushButton(tr( "&OK" ));
77
buttonOk->setAutoDefault( true );
78
buttonOk->setDefault( true );
79
bottomLayout->addWidget( buttonOk );
81
buttonCancel = new QPushButton(tr( "&Cancel" ));
82
buttonCancel->setAutoDefault( true );
83
bottomLayout->addWidget( buttonCancel );
85
QVBoxLayout * mainLayout = new QVBoxLayout(this);
86
mainLayout->addLayout(topLayout);
87
mainLayout->addLayout(bottomLayout);
89
// signals and slots connections
90
connect( buttonApply, SIGNAL( clicked() ), this, SLOT( apply() ) );
91
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
92
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( close() ) );
93
connect( boxNumericDisplay, SIGNAL( activated(int) ), this, SLOT( showPrecisionBox(int) ) );
94
connect( boxPrecision, SIGNAL( valueChanged(int) ), this, SLOT( changePrecision(int) ) );
97
void MatrixDialog::changePrecision(int precision)
99
if (boxFormat->currentIndex())
100
d_matrix->setNumericFormat('e', precision);
102
d_matrix->setNumericFormat('f', precision);
105
void MatrixDialog::showPrecisionBox(int item)
108
boxPrecision->setEnabled( true );
111
boxPrecision->setValue(6);
112
boxPrecision->setEnabled( false );
116
void MatrixDialog::apply()
118
d_matrix->setColumnsWidth(boxColWidth->value());
119
changePrecision(boxPrecision->value());
122
void MatrixDialog::setMatrix(Matrix *m)
128
boxColWidth->setValue(m->columnsWidth());
130
if (QString(m->textFormat()) == "f")
131
boxFormat->setCurrentIndex(0);
133
boxFormat->setCurrentIndex(1);
135
boxPrecision->setValue(m->precision());
136
if (m->precision() != 6)
138
boxPrecision->setEnabled( true );
139
boxNumericDisplay->setCurrentIndex(1);
142
connect(boxColWidth, SIGNAL(valueChanged(int)), d_matrix, SLOT(setColumnsWidth(int)));
143
m->saveCellsToMemory();
146
void MatrixDialog::accept()
152
void MatrixDialog::closeEvent(QCloseEvent* e)
155
d_matrix->forgetSavedCells();