From c707715f3d1d427663240bd0074d8f3cb4e567d7 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Wed, 18 Jan 2017 16:37:38 +0100 Subject: [PATCH] [Companion] Delete category function added --- companion/src/mdichild.cpp | 29 +++++++++++++++++++++++++++++ companion/src/mdichild.h | 1 + 2 files changed, 30 insertions(+) diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index bd9bcc81d..d13407123 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -137,6 +137,7 @@ void MdiChild::showModelsListContextMenu(const QPoint & pos) else if (IS_HORUS(firmware->getBoard())) { if (modelsListModel->getCategoryIndex(modelIndex) >= 0) { contextMenu.addAction(CompanionIcon("add.png"), tr("&Add model"), this, SLOT(modelAdd())); + contextMenu.addAction(CompanionIcon("delete.png"), tr("&Delete category"), this, SLOT(categoryDelete())); } else { contextMenu.addAction(CompanionIcon("add.png"), tr("&Add category"), this, SLOT(categoryAdd())); @@ -342,6 +343,34 @@ void MdiChild::categoryAdd() setModified(); } +void MdiChild::categoryDelete() +{ + int categoryIndex = modelsListModel->getCategoryIndex(ui->modelsList->currentIndex()); + if (categoryIndex < 0 || categoryIndex >= (int)radioData.categories.size()) { + return; + } + + for (unsigned i=0; i categoryIndex) { + model.category--; + } + } + + setModified(); +} + void MdiChild::modelAdd() { int categoryIndex = modelsListModel->getCategoryIndex(ui->modelsList->currentIndex()); diff --git a/companion/src/mdichild.h b/companion/src/mdichild.h index 45510f557..6022989b9 100644 --- a/companion/src/mdichild.h +++ b/companion/src/mdichild.h @@ -73,6 +73,7 @@ class MdiChild : public QWidget void checkAndInitModel(int row); void generalEdit(); void categoryAdd(); + void categoryDelete(); void modelAdd(); void modelEdit(); void wizardEdit();