diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index 31e041486..be6bb5c18 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -240,6 +240,16 @@ int CComponentsForm::getCCItemId(CComponentsItem* cc_Item) const return -1; } +int CComponentsForm::getCCItemId(const std::string &item_name) const +{ + if (!item_name.empty()){ + for (size_t i= 0; i< v_cc_items.size(); i++) + if (v_cc_items.at(i)->getItemName() == item_name) + return i; + } + return -1; +} + int CComponentsForm::genIndex() { int count = v_cc_items.size(); @@ -339,6 +349,12 @@ void CComponentsForm::removeCCItem(CComponentsItem* cc_Item) removeCCItem(id); } +void CComponentsForm::removeCCItem(const std::string &item_name) +{ + uint id = getCCItemId(item_name); + removeCCItem(id); +} + void CComponentsForm::exchangeCCItem(const uint& cc_item_id_a, const uint& cc_item_id_b) { if (!v_cc_items.empty()) diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index 69b02bd09..2ff0bb825 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -100,11 +100,27 @@ class CComponentsForm : public CComponentsItem int addCCItem(const std::vector &cc_items); void insertCCItem(const uint& cc_item_id, CComponentsItem* cc_Item); - ///removes item object from container and deallocates instance + /**Function to remove item from item collection and deallocates instance. + * @param[in] cc_item_id + * @li item id as unsigned int + */ void removeCCItem(const uint& cc_item_id); - ///removes item object from container and deallocates instance + + /**Function to remove item from item collection and deallocates instance. + * @param[in] cc_Item + * @li CComponentsItem* + */ void removeCCItem(CComponentsItem* cc_Item); + /**Function to remove item from item collection and deallocates instance. + * @param[in] item_name + * @li std::string + * NOTE: Requires that unique names are assigned! + * @see + * getItemName() + */ + void removeCCItem(const std::string &item_name); + void replaceCCItem(const uint& cc_item_id, CComponentsItem* new_cc_Item); void replaceCCItem(CComponentsItem* old_cc_Item, CComponentsItem* new_cc_Item); void exchangeCCItem(const uint& item_id_a, const uint& item_id_b); @@ -118,6 +134,18 @@ class CComponentsForm : public CComponentsItem */ int getCCItemId(CComponentsItem* cc_Item) const; + /**Function to get current item id from passed item name. + * @param[in] item_name + * @li std::string + * @return + * int, in case of not found item returns -1 + * NOTE: Requires that unique names are assigned! + * @see + * setItemName() + * getItemName() + */ + int getCCItemId(const std::string &item_name) const; + /**Function to get current item from item collection. * @param[in] cc_item_id * @li item id as unsigned int