Show column Calculated value.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-07-21 19:13:09 +03:00
parent 930c7cbf42
commit 2cb4b18491
3 changed files with 37 additions and 5 deletions

View File

@ -384,7 +384,8 @@ void TMainWindow::AddCustom()
if (mType == MeasurementsType::Individual) if (mType == MeasurementsType::Individual)
{ {
AddCell(name, currentRow, 0, id); // name AddCell(name, currentRow, 0, id); // name
AddCell("0", currentRow, 2); // value AddCell("0", currentRow, 1); // calculated value
AddCell("0", currentRow, 2); // formula
} }
else else
{ {
@ -399,6 +400,9 @@ void TMainWindow::AddCustom()
ui->tableWidget->blockSignals(false); ui->tableWidget->blockSignals(false);
ui->tableWidget->selectRow(currentRow); ui->tableWidget->selectRow(currentRow);
ui->tableWidget->resizeColumnsToContents();
ui->tableWidget->resizeRowsToContents();
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
MeasurementsWasSaved(false); MeasurementsWasSaved(false);
} }
@ -615,17 +619,42 @@ void TMainWindow::InitTable()
{ {
if (mType == MeasurementsType::Standard) if (mType == MeasurementsType::Standard)
{ {
ui->tableWidget->setColumnHidden( 2, true );// value ui->tableWidget->setColumnHidden( 2, true );// formula
} }
else else
{ {
ui->tableWidget->setColumnHidden( 1, true );// calculated value
ui->tableWidget->setColumnHidden( 3, true );// base value ui->tableWidget->setColumnHidden( 3, true );// base value
ui->tableWidget->setColumnHidden( 4, true );// in sizes ui->tableWidget->setColumnHidden( 4, true );// in sizes
ui->tableWidget->setColumnHidden( 5, true );// in heights ui->tableWidget->setColumnHidden( 5, true );// in heights
} }
connect(ui->tableWidget, &QTableWidget::itemSelectionChanged, this, &TMainWindow::ShowMData); connect(ui->tableWidget, &QTableWidget::itemSelectionChanged, this, &TMainWindow::ShowMData);
ShowUnits();
ui->tableWidget->resizeColumnsToContents();
ui->tableWidget->resizeRowsToContents();
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::ShowUnits()
{
const QString unit = VDomDocument::UnitsToStr(mUnit);
ShowHeaderUnits(ui->tableWidget, 1, unit);// calculated value
ShowHeaderUnits(ui->tableWidget, 3, unit);// base value
ShowHeaderUnits(ui->tableWidget, 4, unit);// in sizes
ShowHeaderUnits(ui->tableWidget, 5, unit);// in heights
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::ShowHeaderUnits(QTableWidget *table, int column, const QString &unit)
{
SCASSERT(table != nullptr);
const QString header = table->horizontalHeaderItem(column)->text();
const QString unitHeader = QString("%1 (%2)").arg(header).arg(unit);
table->horizontalHeaderItem(column)->setText(unitHeader);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -93,6 +93,9 @@ private:
void InitWindow(); void InitWindow();
void InitTable(); void InitTable();
void ShowUnits();
void ShowHeaderUnits(QTableWidget *table, int column, const QString &unit);
void MeasurementsWasSaved(bool saved); void MeasurementsWasSaved(bool saved);
void SetCurrentFile(const QString &fileName); void SetCurrentFile(const QString &fileName);
bool SaveMeasurements(const QString &fileName, QString &error); bool SaveMeasurements(const QString &fileName, QString &error);

View File

@ -72,7 +72,7 @@
</column> </column>
<column> <column>
<property name="text"> <property name="text">
<string>Value</string> <string>Formula</string>
</property> </property>
</column> </column>
<column> <column>
@ -343,7 +343,7 @@
<item row="4" column="1"> <item row="4" column="1">
<widget class="QLabel" name="labelCalculatedValue"> <widget class="QLabel" name="labelCalculatedValue">
<property name="text"> <property name="text">
<string notr="true">0</string> <string notr="true"/>
</property> </property>
</widget> </widget>
</item> </item>