menue.h/cpp: add member to get item id by name

Origin commit data
------------------
Commit: 02c845370a
Author: Thilo Graf <dbt@novatux.de>
Date: 2021-07-19 (Mon, 19 Jul 2021)
This commit is contained in:
2021-07-19 05:50:08 +02:00
committed by vanhofen
parent 1d436ed98f
commit 4a375e5d9e
2 changed files with 14 additions and 1 deletions

View File

@@ -817,6 +817,18 @@ int CMenuWidget::getItemId(CMenuItem* menuItem)
return -1;
}
int CMenuWidget::getItemId(const char *name)
{
for (uint i= 0; i< items.size(); i++)
{
std::string s_item_name(items[i]->getName());
std::string s_name(name);
if (s_name == s_item_name)
return i;
}
return -1;
}
CMenuItem* CMenuWidget::getItem(const uint& item_id)
{
for (uint i= 0; i< items.size(); i++)

View File

@@ -639,7 +639,8 @@ class CMenuWidget : public CMenuTarget, public CComponentsSignals
void resetWidget(bool delete_items = false);
void insertItem(const uint& item_id, CMenuItem* menuItem);
void removeItem(const uint& item_id);
int getItemId(CMenuItem* menuItem);
int getItemId(CMenuItem *menuItem);
int getItemId(const char *name);
int getItemsCount()const{return items.size();};
CMenuItem* getItem(const uint& item_id);
virtual void paint();