2015-08-09 23:47:08 +02:00
|
|
|
// fmenulist.cpp
|
|
|
|
// class FMenuList
|
|
|
|
|
|
|
|
#include "fmenulist.h"
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FMenuList
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// constructor and destructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FMenuList::FMenuList()
|
2015-09-22 04:18:20 +02:00
|
|
|
: itemlist()
|
|
|
|
{ }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FMenuList::~FMenuList() // destructor
|
|
|
|
{
|
|
|
|
// delete all items
|
|
|
|
if ( ! itemlist.empty() )
|
|
|
|
{
|
|
|
|
std::vector<FMenuItem*>::iterator iter;
|
|
|
|
iter = itemlist.begin();
|
|
|
|
|
|
|
|
while ( iter != itemlist.end() )
|
|
|
|
{
|
|
|
|
(*iter)->setSuperMenu(0);
|
|
|
|
//delAccelerator (*iter);
|
|
|
|
iter = itemlist.erase(iter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// private methods of FMenuList
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public methods of FMenuList
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FMenuList::hasSelectedItem()
|
|
|
|
{
|
|
|
|
if ( ! itemlist.empty() )
|
|
|
|
{
|
|
|
|
std::vector<FMenuItem*>::const_iterator iter, end;
|
|
|
|
iter = itemlist.begin();
|
|
|
|
end = itemlist.end();
|
|
|
|
|
|
|
|
while ( iter != end )
|
|
|
|
{
|
|
|
|
if ( (*iter)->isSelected() )
|
|
|
|
return true;
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-09-20 05:44:50 +02:00
|
|
|
void FMenuList::insert (FMenuItem* i)
|
2015-08-09 23:47:08 +02:00
|
|
|
{
|
2015-09-20 05:44:50 +02:00
|
|
|
itemlist.push_back(i);
|
2015-08-09 23:47:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-09-20 05:44:50 +02:00
|
|
|
void FMenuList::remove (FMenuItem* i)
|
2015-08-09 23:47:08 +02:00
|
|
|
{
|
|
|
|
std::vector<FMenuItem*>::iterator iter;
|
|
|
|
|
2015-09-20 05:44:50 +02:00
|
|
|
//delAccelerator (i);
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
if ( itemlist.empty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
iter = itemlist.begin();
|
|
|
|
while ( iter != itemlist.end() )
|
|
|
|
{
|
2015-09-20 05:44:50 +02:00
|
|
|
if ( (*iter) == i )
|
2015-08-09 23:47:08 +02:00
|
|
|
{
|
|
|
|
iter = itemlist.erase(iter);
|
2015-09-20 05:44:50 +02:00
|
|
|
i->setSuperMenu(0);
|
2015-08-09 23:47:08 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FMenuList::remove (int pos)
|
|
|
|
{
|
|
|
|
if ( int(count()) < pos )
|
|
|
|
return;
|
|
|
|
|
|
|
|
itemlist.erase (itemlist.begin()+pos-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FMenuList::clear()
|
|
|
|
{
|
|
|
|
itemlist.clear();
|
|
|
|
}
|
2015-08-16 20:05:39 +02:00
|
|
|
|