extensions/topmenus/TopMenu.cpp
changeset 1496 4145ca042242
parent 1495 5e85546abc33
child 1497 1cab582efa5f
     1.1 --- a/extensions/topmenus/TopMenu.cpp	Wed Sep 26 20:34:50 2007 +0000
     1.2 +++ b/extensions/topmenus/TopMenu.cpp	Wed Sep 26 21:44:12 2007 +0000
     1.3 @@ -225,6 +225,14 @@
     1.4  		parent_cat->obj_list.push_back(obj);
     1.5  		parent_cat->reorder = true;
     1.6  		parent_cat->serial++;
     1.7 +
     1.8 +		/* If the category just went from 0 to 1 items, mark it as 
     1.9 +		 * changed, so clients get the category drawn.
    1.10 +		 */
    1.11 +		if (parent_cat->obj_list.size() == 1)
    1.12 +		{
    1.13 +			m_SerialNo++;
    1.14 +		}
    1.15  	}
    1.16  
    1.17  	m_ObjLookup.insert(name, obj);
    1.18 @@ -295,6 +303,14 @@
    1.19  				if (parent_cat->obj_list[i] == obj)
    1.20  				{
    1.21  					parent_cat->obj_list.erase(parent_cat->obj_list.iterAt(i));
    1.22 +
    1.23 +					/* If this category now has no items, mark root as changed 
    1.24 +					 * so clients won't get the category drawn anymore.
    1.25 +					 */
    1.26 +					if (parent_cat->obj_list.size() == 0)
    1.27 +					{
    1.28 +						m_SerialNo++;
    1.29 +					}
    1.30  					break;
    1.31  				}
    1.32  			}
    1.33 @@ -552,6 +568,10 @@
    1.34  	/* Add the sorted items */
    1.35  	for (size_t i = 0; i < m_SortedCats.size(); i++)
    1.36  	{
    1.37 +		if (m_Categories[m_SortedCats[i]]->obj_list.size() == 0)
    1.38 +		{
    1.39 +			continue;
    1.40 +		}
    1.41  		root_menu->AppendItem(m_Categories[m_SortedCats[i]]->obj->name, ItemDrawInfo(""));
    1.42  	}
    1.43  
    1.44 @@ -579,6 +599,10 @@
    1.45  		/* Add the new sorted categories */
    1.46  		for (size_t i = 0; i < m_SortedCats.size(); i++)
    1.47  		{
    1.48 +			if (m_Categories[item_list[i].obj_index]->obj_list.size() == 0)
    1.49 +			{
    1.50 +				continue;
    1.51 +			}
    1.52  			root_menu->AppendItem(m_Categories[item_list[i].obj_index]->obj->name, ItemDrawInfo(""));
    1.53  		}
    1.54