Base value in standard table cannot be modified.

--HG--
branch : develop
This commit is contained in:
dismine 2014-10-01 12:58:38 +03:00
parent 0dabadbb98
commit 730ed3006d
2 changed files with 21 additions and 26 deletions

View File

@ -165,10 +165,7 @@ void DialogIncrements::FillMeasurements()
item->setTextAlignment(Qt::AlignHCenter); item->setTextAlignment(Qt::AlignHCenter);
item->setFont(QFont("Times", 12, QFont::Bold)); item->setFont(QFont("Times", 12, QFont::Bold));
item->setToolTip(m->GetGuiText()); item->setToolTip(m->GetGuiText());
// set the item non-editable (view only), and non-selectable SetItemViewOnly(item);
Qt::ItemFlags flags = item->flags();
flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
item->setTextAlignment(Qt::AlignLeft); item->setTextAlignment(Qt::AlignLeft);
ui->tableWidgetMeasurements->setItem(currentRow, 0, item); ui->tableWidgetMeasurements->setItem(currentRow, 0, item);
@ -177,50 +174,41 @@ void DialogIncrements::FillMeasurements()
QTableWidgetItem *item = new QTableWidgetItem(QString() QTableWidgetItem *item = new QTableWidgetItem(QString()
.setNum(data->GetTableValue(qApp->VarFromUser(iMap.key())))); .setNum(data->GetTableValue(qApp->VarFromUser(iMap.key()))));
item->setTextAlignment(Qt::AlignHCenter); item->setTextAlignment(Qt::AlignHCenter);
// set the item non-editable (view only), and non-selectable SetItemViewOnly(item);
Qt::ItemFlags flags = item->flags();
flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
ui->tableWidgetMeasurements->setItem(currentRow, 1, item);// calculated value ui->tableWidgetMeasurements->setItem(currentRow, 1, item);// calculated value
} }
item = new QTableWidgetItem(QString().setNum(m->GetBase())); item = new QTableWidgetItem(QString().setNum(m->GetBase()));
item->setTextAlignment(Qt::AlignHCenter); item->setTextAlignment(Qt::AlignHCenter);
if (qApp->patternType() == MeasurementsType::Standard)
{
SetItemViewOnly(item);
}
ui->tableWidgetMeasurements->setItem(currentRow, 2, item); ui->tableWidgetMeasurements->setItem(currentRow, 2, item);
if (qApp->patternType() == MeasurementsType::Standard) if (qApp->patternType() == MeasurementsType::Standard)
{ {
QTableWidgetItem *item = new QTableWidgetItem(QString().setNum(m->GetKsize())); QTableWidgetItem *item = new QTableWidgetItem(QString().setNum(m->GetKsize()));
item->setTextAlignment(Qt::AlignHCenter); item->setTextAlignment(Qt::AlignHCenter);
// set the item non-editable (view only), and non-selectable SetItemViewOnly(item);
Qt::ItemFlags flags = item->flags();
flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
ui->tableWidgetMeasurements->setItem(currentRow, 3, item);// in sizes ui->tableWidgetMeasurements->setItem(currentRow, 3, item);// in sizes
item = new QTableWidgetItem(QString().setNum(m->GetKheight())); item = new QTableWidgetItem(QString().setNum(m->GetKheight()));
item->setTextAlignment(Qt::AlignHCenter); item->setTextAlignment(Qt::AlignHCenter);
// set the item non-editable (view only), and non-selectable SetItemViewOnly(item);
flags = item->flags();
flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
ui->tableWidgetMeasurements->setItem(currentRow, 4, item);// in heights ui->tableWidgetMeasurements->setItem(currentRow, 4, item);// in heights
} }
item = new QTableWidgetItem(m->GetDescription()); item = new QTableWidgetItem(m->GetDescription());
item->setToolTip(m->GetDescription()); item->setToolTip(m->GetDescription());
item->setTextAlignment(Qt::AlignHCenter); SetItemViewOnly(item);
// set the item non-editable (view only), and non-selectable
flags = item->flags();
flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
item->setTextAlignment(Qt::AlignLeft); item->setTextAlignment(Qt::AlignLeft);
ui->tableWidgetMeasurements->setItem(currentRow, 5, item); ui->tableWidgetMeasurements->setItem(currentRow, 5, item);
} }
ui->tableWidgetMeasurements->setRowCount(currentRow+1);
ui->tableWidgetMeasurements->verticalHeader()->setDefaultSectionSize(20); ui->tableWidgetMeasurements->verticalHeader()->setDefaultSectionSize(20);
ui->tableWidgetMeasurements->resizeColumnsToContents(); ui->tableWidgetMeasurements->resizeColumnsToContents();
ui->tableWidgetMeasurements->resizeRowsToContents(); ui->tableWidgetMeasurements->resizeRowsToContents();
ui->tableWidgetMeasurements->setRowCount(currentRow+1);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -258,10 +246,7 @@ void DialogIncrements::FillIncrements()
{ {
item = new QTableWidgetItem(QString().setNum(data->GetTableValue(iMap.value()))); item = new QTableWidgetItem(QString().setNum(data->GetTableValue(iMap.value())));
item->setTextAlignment(Qt::AlignHCenter); item->setTextAlignment(Qt::AlignHCenter);
// set the item non-editable (view only), and non-selectable SetItemViewOnly(item);
Qt::ItemFlags flags = item->flags();
flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
ui->tableWidgetIncrement->setItem(currentRow, 1, item); ui->tableWidgetIncrement->setItem(currentRow, 1, item);
} }
@ -350,6 +335,15 @@ void DialogIncrements::FillLengthArcs()
FillTable(data->DataLengthArcs(), ui->tableWidgetArcs); FillTable(data->DataLengthArcs(), ui->tableWidgetArcs);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::SetItemViewOnly(QTableWidgetItem *item)
{
// set the item non-editable (view only), and non-selectable
Qt::ItemFlags flags = item->flags();
flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::ShowMeasurements() void DialogIncrements::ShowMeasurements()
{ {

View File

@ -103,6 +103,7 @@ private:
void AddIncrementToFile(const quint32 &id, const QString &name, const qreal &base, void AddIncrementToFile(const quint32 &id, const QString &name, const qreal &base,
const qreal &ksize, const qreal &kheight, const QString &description); const qreal &ksize, const qreal &kheight, const QString &description);
void HideColumns(QTableWidget *table); void HideColumns(QTableWidget *table);
void SetItemViewOnly(QTableWidgetItem *item);
}; };
#endif // DIALOGINCREMENTS_H #endif // DIALOGINCREMENTS_H