1- #include " NumberGrid .hpp"
1+ #include " OutputGrid .hpp"
22#include " pre/widgets/DoubleOutput.hpp"
33#include " pre/models/units/Quantity.hpp"
44#include < QHBoxLayout>
88#include < QLineEdit>
99#include < QLabel>
1010
11- NumberGrid::NumberGrid ()
11+ OutputGrid::OutputGrid ()
1212 : columnLayout(new QHBoxLayout()),
1313 currentColumn(nullptr ),
1414 currentGrid(nullptr )
@@ -19,7 +19,7 @@ NumberGrid::NumberGrid()
1919 this ->setLayout (columnLayout);
2020}
2121
22- void NumberGrid ::addColumn () {
22+ void OutputGrid ::addColumn () {
2323 // Create new column
2424 currentColumn = new QVBoxLayout ();
2525 currentColumn->addStretch ();
@@ -32,7 +32,7 @@ void NumberGrid::addColumn() {
3232 columnLayout->insertLayout (i, currentColumn);
3333}
3434
35- void NumberGrid ::addGroup (const QString& name) {
35+ void OutputGrid ::addGroup (const QString& name) {
3636 if (currentColumn == nullptr ) {
3737 addColumn ();
3838 }
@@ -46,7 +46,7 @@ void NumberGrid::addGroup(const QString& name) {
4646 currentColumn->insertWidget (i, group);
4747}
4848
49- void NumberGrid ::addHeaders (const QStringList& headers) {
49+ void OutputGrid ::addHeaders (const QStringList& headers) {
5050 if (currentColumn == nullptr ) {
5151 addColumn ();
5252 }
@@ -63,7 +63,11 @@ void NumberGrid::addHeaders(const QStringList& headers) {
6363 }
6464}
6565
66- void NumberGrid::addValues (const QString& name, const QList<double >& values, const QList<const Quantity*> quantities, const QList<double >& allowed, const QList<double >& maximum, int decimals) {
66+ void OutputGrid::addValue (const QString& name, QWidget* widget) {
67+ addValues (name, {widget});
68+ }
69+
70+ void OutputGrid::addValues (const QString& name, QList<QWidget*> widgets) {
6771 if (currentColumn == nullptr ) {
6872 addColumn ();
6973 }
@@ -74,20 +78,10 @@ void NumberGrid::addValues(const QString& name, const QList<double>& values, con
7478
7579 int row = currentGrid->rowCount ();
7680 auto label = new QLabel (name);
77- currentGrid->addWidget (label, row, 0 );
7881
79- for (int col = 0 ; col < values.size (); ++col) {
80- auto output = new DoubleOutput (values[col], *quantities[col], decimals);
81- currentGrid->addWidget (output, row, col + 1 );
82-
83- // Set warning limits if nonzero ones are given
84- if (col < allowed.size () && col < maximum.size () && allowed[col] != 0.0 && maximum[col] != 0.0 ) {
85- output->setAllowedLimit (allowed[col]);
86- output->setMaximumLimit (maximum[col]);
87- }
82+ currentGrid->addWidget (label, row, 0 );
83+ for (int col = 0 ; col < widgets.size (); ++col) {
84+ currentGrid->addWidget (widgets[col], row, col + 1 );
8885 }
8986}
9087
91- void NumberGrid::addValue (const QString& name, double value, const Quantity& quantity, int decimals) {
92- addValues (name, {value}, {&quantity}, {}, {}, decimals);
93- }
0 commit comments