Special aligment for text columns.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-08-01 16:00:33 +03:00
parent 08c9f9a064
commit 5524fd60e6
2 changed files with 19 additions and 11 deletions

View File

@ -1383,10 +1383,10 @@ bool TMainWindow::MaybeSave()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::AddCell(const QString &text, int row, int column, bool ok) void TMainWindow::AddCell(const QString &text, int row, int column, int aligment, bool ok)
{ {
QTableWidgetItem *item = new QTableWidgetItem(text); QTableWidgetItem *item = new QTableWidgetItem(text);
item->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); item->setTextAlignment(aligment);
// set the item non-editable (view only), and non-selectable // set the item non-editable (view only), and non-selectable
Qt::ItemFlags flags = item->flags(); Qt::ItemFlags flags = item->flags();
@ -1477,8 +1477,9 @@ void TMainWindow::RefreshTable()
if (mType == MeasurementsType::Individual) if (mType == MeasurementsType::Individual)
{ {
AddCell(meash->GetName(), currentRow, 0); // name AddCell(meash->GetName(), currentRow, 0, Qt::AlignVCenter); // name
AddCell(QString().setNum(*meash->GetValue()), currentRow, 1, meash->IsFormulaOk()); // calculated value AddCell(QString().setNum(*meash->GetValue()), currentRow, 1, Qt::AlignHCenter | Qt::AlignVCenter,
meash->IsFormulaOk()); // calculated value
QString formula; QString formula;
try try
@ -1491,16 +1492,23 @@ void TMainWindow::RefreshTable()
formula = meash->GetFormula(); formula = meash->GetFormula();
} }
AddCell(formula, currentRow, 2); // formula AddCell(formula, currentRow, 2, Qt::AlignVCenter); // formula
} }
else else
{ {
AddCell(meash->GetName(), currentRow, 0); // name AddCell(meash->GetName(), currentRow, 0, Qt::AlignVCenter); // name
AddCell(QString().setNum(data->GetTableValue(meash->GetName(), mType)), currentRow, 1, AddCell(QString().setNum(data->GetTableValue(meash->GetName(), mType)), currentRow, 1,
meash->IsFormulaOk()); // calculated value Qt::AlignHCenter | Qt::AlignVCenter, meash->IsFormulaOk()); // calculated value
AddCell(QString().setNum(meash->GetBase()), currentRow, 3); // base value
AddCell(QString().setNum(meash->GetKsize()), currentRow, 4); // in sizes AddCell(QString().setNum(meash->GetBase()), currentRow, 3,
AddCell(QString().setNum(meash->GetKheight()), currentRow, 5); // in heights Qt::AlignHCenter | Qt::AlignVCenter); // base value
AddCell(QString().setNum(meash->GetKsize()), currentRow, 4,
Qt::AlignHCenter | Qt::AlignVCenter); // in sizes
AddCell(QString().setNum(meash->GetKheight()), currentRow, 5,
Qt::AlignHCenter | Qt::AlignVCenter); // in heights
} }
} }

View File

@ -128,7 +128,7 @@ private:
bool MaybeSave(); bool MaybeSave();
void AddCell(const QString &text, int row, int column, bool ok = true); void AddCell(const QString &text, int row, int column, int aligment, bool ok = true);
QComboBox *SetGradationList(const QString &label, const QStringList &list); QComboBox *SetGradationList(const QString &label, const QStringList &list);
void SetDefaultHeight(int value); void SetDefaultHeight(int value);