From a74bfd9c423d9256465663834e2957f30b04a730 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 22 Jul 2015 09:41:04 +0300 Subject: [PATCH] Delete measurement. --HG-- branch : feature --- src/app/tape/tmainwindow.cpp | 20 ++++++++++++++++++++ src/app/tape/tmainwindow.h | 1 + src/libs/vformat/vmeasurements.cpp | 7 +++++++ src/libs/vformat/vmeasurements.h | 1 + 4 files changed, 29 insertions(+) diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index b9fbc08ed..97375e639 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -355,6 +355,24 @@ void TMainWindow::ReadOnly(bool 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() { @@ -655,6 +673,8 @@ void TMainWindow::InitWindow() ui->actionReadOnly->setEnabled(true); ui->actionSaveAs->setEnabled(true); + connect(ui->toolButtonRemove, &QToolButton::clicked, this, &TMainWindow::Remove); + InitTable(); } diff --git a/src/app/tape/tmainwindow.h b/src/app/tape/tmainwindow.h index c2f43c9e8..b537539b4 100644 --- a/src/app/tape/tmainwindow.h +++ b/src/app/tape/tmainwindow.h @@ -70,6 +70,7 @@ private slots: void SaveBirthDate(const QDate & date); void SaveNotes(); void ReadOnly(bool ro); + void Remove(); void AddCustom(); void AddKnown(); diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index 3c9421e44..63880ba60 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -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 { diff --git a/src/libs/vformat/vmeasurements.h b/src/libs/vformat/vmeasurements.h index 0029fae97..2121eaca5 100644 --- a/src/libs/vformat/vmeasurements.h +++ b/src/libs/vformat/vmeasurements.h @@ -45,6 +45,7 @@ public: void AddEmpty(const QString &name); void AddEmptyAfter(const QString &after, const QString &name); + void Remove(const QString &name); MeasurementsType Type() const; Unit MUnit() const;