From fa718ffe174eb144fd38961b20d59a80bc14ba52 Mon Sep 17 00:00:00 2001 From: ribes Date: Thu, 21 Jan 2010 17:02:14 +0000 Subject: [PATCH] We can now remove resources --- src/engine/BL_SALOMEServices.cxx | 14 +++++++++++++- src/engine/BL_SALOMEServices.hxx | 1 + src/genericgui/JM_ResourceCatalog.cxx | 17 +++++++++++++++++ src/genericgui/JM_ResourceCatalog.hxx | 2 ++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/engine/BL_SALOMEServices.cxx b/src/engine/BL_SALOMEServices.cxx index f6604b5..fc5cb9a 100644 --- a/src/engine/BL_SALOMEServices.cxx +++ b/src/engine/BL_SALOMEServices.cxx @@ -80,7 +80,6 @@ BL::SALOMEServices::getResourceList() } delete resourceList; } - return resource_list; } @@ -151,6 +150,19 @@ BL::SALOMEServices::addResource(BL::ResourceDescr & new_resource) } } +void +BL::SALOMEServices::removeResource(const std::string & name) +{ + try + { + _resources_manager->RemoveResource(name.c_str(), true, ""); + } + catch (const SALOME::SALOME_Exception & ex) + { + DEBTRACE("SALOME Exception in removeResource ! " << ex.details.text.in()); + } +} + std::string BL::SALOMEServices::create_job(BL::Job * job) { diff --git a/src/engine/BL_SALOMEServices.hxx b/src/engine/BL_SALOMEServices.hxx index 6908379..cce2c2b 100644 --- a/src/engine/BL_SALOMEServices.hxx +++ b/src/engine/BL_SALOMEServices.hxx @@ -63,6 +63,7 @@ namespace BL{ std::list getResourceList(); BL::ResourceDescr getResourceDescr(const std::string& name); void addResource(BL::ResourceDescr & new_resource); + void removeResource(const std::string & name); std::string create_job(BL::Job * job); std::string start_job(BL::Job * job); diff --git a/src/genericgui/JM_ResourceCatalog.cxx b/src/genericgui/JM_ResourceCatalog.cxx index 94e72ed..134f368 100644 --- a/src/genericgui/JM_ResourceCatalog.cxx +++ b/src/genericgui/JM_ResourceCatalog.cxx @@ -47,11 +47,14 @@ JM::ResourceCatalog::ResourceCatalog(QWidget *parent, BL::SALOMEServices * salom _edit_button = new QPushButton("Edit"); _edit_button->setEnabled(false); _add_button = new QPushButton("Add"); + _remove_button = new QPushButton("Remove"); + _remove_button->setEnabled(false); QHBoxLayout * button_layout = new QHBoxLayout(this); button_layout->addWidget(_show_button); button_layout->addWidget(_edit_button); button_layout->addWidget(_add_button); + button_layout->addWidget(_remove_button); QWidget * layout_widget = new QWidget(this); layout_widget->setLayout(button_layout); @@ -66,6 +69,7 @@ JM::ResourceCatalog::ResourceCatalog(QWidget *parent, BL::SALOMEServices * salom connect(_show_button, SIGNAL(clicked()), this, SLOT(show_button())); connect(_edit_button, SIGNAL(clicked()), this, SLOT(edit_button())); connect(_add_button, SIGNAL(clicked()), this, SLOT(add_button())); + connect(_remove_button, SIGNAL(clicked()), this, SLOT(remove_button())); // Double click on an item connect(_resource_files_list, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(item_choosed(QListWidgetItem*))); // Selection management @@ -117,11 +121,13 @@ JM::ResourceCatalog::buttons_management() { _show_button->setEnabled(false); _edit_button->setEnabled(false); + _remove_button->setEnabled(false); } else { _show_button->setEnabled(true); _edit_button->setEnabled(true); + _remove_button->setEnabled(true); } } @@ -139,6 +145,16 @@ JM::ResourceCatalog::add_button() _salome_services); resource_widget->exec(); delete resource_widget; + refresh_resource_list(); +} + +void +JM::ResourceCatalog::remove_button() +{ + QList item_list = _resource_files_list->selectedItems(); + QString item_name = item_list.at(0)->text(); + _salome_services->removeResource(item_name.toStdString()); + refresh_resource_list(); } void @@ -151,4 +167,5 @@ JM::ResourceCatalog::edit_button() item_name.toStdString()); resource_widget->exec(); delete resource_widget; + refresh_resource_list(); } diff --git a/src/genericgui/JM_ResourceCatalog.hxx b/src/genericgui/JM_ResourceCatalog.hxx index 2323b36..e051097 100644 --- a/src/genericgui/JM_ResourceCatalog.hxx +++ b/src/genericgui/JM_ResourceCatalog.hxx @@ -48,6 +48,7 @@ namespace JM void show_button(); void edit_button(); void add_button(); + void remove_button(); protected: QWidget* _parent; @@ -57,6 +58,7 @@ namespace JM QPushButton * _show_button; QPushButton * _edit_button; QPushButton * _add_button; + QPushButton * _remove_button; QListWidget * _resource_files_list; }; } -- 2.39.2