Delete measurement.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-07-22 09:41:04 +03:00
parent b79807a8ef
commit a74bfd9c42
4 changed files with 29 additions and 0 deletions

View File

@ -355,6 +355,24 @@ void TMainWindow::ReadOnly(bool ro)
ui->groupBoxDetails->setDisabled(ro); ui->groupBoxDetails->setDisabled(ro);
} }
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::Remove()
{
const int row = ui->tableWidget->currentRow();
if (row == -1)
{
return;
}
QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), 0);
m->Remove(nameField->text());
MeasurementsWasSaved(false);
RefreshData();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::AddCustom() void TMainWindow::AddCustom()
{ {
@ -655,6 +673,8 @@ void TMainWindow::InitWindow()
ui->actionReadOnly->setEnabled(true); ui->actionReadOnly->setEnabled(true);
ui->actionSaveAs->setEnabled(true); ui->actionSaveAs->setEnabled(true);
connect(ui->toolButtonRemove, &QToolButton::clicked, this, &TMainWindow::Remove);
InitTable(); InitTable();
} }

View File

@ -70,6 +70,7 @@ private slots:
void SaveBirthDate(const QDate & date); void SaveBirthDate(const QDate & date);
void SaveNotes(); void SaveNotes();
void ReadOnly(bool ro); void ReadOnly(bool ro);
void Remove();
void AddCustom(); void AddCustom();
void AddKnown(); void AddKnown();

View File

@ -120,6 +120,13 @@ void VMeasurements::AddEmptyAfter(const QString &after, const QString &name)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::Remove(const QString &name)
{
const QDomNodeList list = elementsByTagName(TagBodyMeasurements);
list.at(0).removeChild(FindM(name));
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
MeasurementsType VMeasurements::Type() const MeasurementsType VMeasurements::Type() const
{ {

View File

@ -45,6 +45,7 @@ public:
void AddEmpty(const QString &name); void AddEmpty(const QString &name);
void AddEmptyAfter(const QString &after, const QString &name); void AddEmptyAfter(const QString &after, const QString &name);
void Remove(const QString &name);
MeasurementsType Type() const; MeasurementsType Type() const;
Unit MUnit() const; Unit MUnit() const;