bool ItemSet<T>::addItem(const T& item) { if (containsItem(item) == false) { items_.push_back(item); return true; } return false; }
void updateButtonUnderMouse (const MouseEvent& e) { TreeViewItem* newItem = 0; if (owner.openCloseButtonsVisible) { Rectangle<int> pos; TreeViewItem* item = findItemAt (e.y, pos); if (item != 0 && e.x < pos.getX() && e.x >= pos.getX() - owner.getIndentSize()) { newItem = item; if (! newItem->mightContainSubItems()) newItem = 0; } } if (buttonUnderMouse != newItem) { if (buttonUnderMouse != 0 && containsItem (buttonUnderMouse)) { const Rectangle<int> r (buttonUnderMouse->getItemPosition (false)); repaint (0, r.getY(), r.getX(), buttonUnderMouse->getItemHeight()); } buttonUnderMouse = newItem; if (buttonUnderMouse != 0) { const Rectangle<int> r (buttonUnderMouse->getItemPosition (false)); repaint (0, r.getY(), r.getX(), buttonUnderMouse->getItemHeight()); } } }
void DrawingItemGroup::removeItem(DrawingItem* item) { if (item && containsItem(item)) { mItems.removeAll(item); updatePoints(); } }
void DrawingItemGroup::addItem(DrawingItem* item) { if (item && !containsItem(item)) { mItems.append(item); updatePoints(); } }
int ItemSet<T>::merge(const ItemSet<T>& other) { int numAdded = 0; // Insert all Items from the other ItemSet which are not // already in this one. // for (size_t i = 0; i < other.items_.size(); ++i) { if (! containsItem(other.items_[i])) { items_.push_back(other.items_[i]); ++numAdded; } } return numAdded; }
/* Removes 'item' from the ShoppingCart */ void removeItemFromCart(struct ShoppingCart *cart, struct CartItem *item) { int i; int index = containsItem(cart, item); if (index > -1) { for (i = index; i < cart->numItems; i++) { cart->items[i] = cart->items[i + 1]; } } cart->numItems--; // ADDED LINE BELOW cart->totalPrice -= item->price; }