OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
containeritemmodel.hpp
Go to the documentation of this file.
1 #ifndef MWGUI_CONTAINER_ITEM_MODEL_H
2 #define MWGUI_CONTAINER_ITEM_MODEL_H
3 
4 #include "itemmodel.hpp"
5 
6 namespace MWGui
7 {
8 
12  {
13  public:
14  ContainerItemModel (const std::vector<MWWorld::Ptr>& itemSources, const std::vector<MWWorld::Ptr>& worldItems);
17 
18  ContainerItemModel (const MWWorld::Ptr& source);
19 
20  virtual ItemStack getItem (ModelIndex index);
21  virtual ModelIndex getIndex (ItemStack item);
22  virtual size_t getItemCount();
23 
24  virtual MWWorld::Ptr copyItem (const ItemStack& item, size_t count, bool setNewOwner=false);
25  virtual void removeItem (const ItemStack& item, size_t count);
26 
27  virtual void update();
28 
29  private:
30  std::vector<MWWorld::Ptr> mItemSources;
31  std::vector<MWWorld::Ptr> mWorldItems;
32 
33  std::vector<ItemStack> mItems;
34  };
35 
36 }
37 
38 #endif
The base class that all item models should derive from.
Definition: itemmodel.hpp:43
std::vector< ItemStack > mItems
Definition: containeritemmodel.hpp:33
The container item model supports multiple item sources, which are needed for making NPCs sell items ...
Definition: containeritemmodel.hpp:11
virtual MWWorld::Ptr copyItem(const ItemStack &item, size_t count, bool setNewOwner=false)
Definition: containeritemmodel.cpp:74
virtual ModelIndex getIndex(ItemStack item)
Returns an invalid index if the item was not found.
Definition: containeritemmodel.cpp:62
virtual void removeItem(const ItemStack &item, size_t count)
Definition: containeritemmodel.cpp:82
virtual size_t getItemCount()
Definition: containeritemmodel.cpp:57
A single item stack managed by an item model.
Definition: itemmodel.hpp:12
std::vector< MWWorld::Ptr > mItemSources
Definition: containeritemmodel.hpp:30
ContainerItemModel(const std::vector< MWWorld::Ptr > &itemSources, const std::vector< MWWorld::Ptr > &worldItems)
Definition: containeritemmodel.cpp:36
virtual void update()
Rebuild the item model, this will invalidate existing model indices.
Definition: containeritemmodel.cpp:118
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
std::vector< MWWorld::Ptr > mWorldItems
Definition: containeritemmodel.hpp:31
virtual ItemStack getItem(ModelIndex index)
Throws for invalid index or out of range index.
Definition: containeritemmodel.cpp:48