OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
sortfilteritemmodel.hpp
Go to the documentation of this file.
1 #ifndef MWGUI_SORT_FILTER_ITEM_MODEL_H
2 #define MWGUI_SORT_FILTER_ITEM_MODEL_H
3 
4 #include "itemmodel.hpp"
5 
6 namespace MWGui
7 {
8 
10  {
11  public:
12  SortFilterItemModel (ItemModel* sourceModel);
13 
14  virtual void update();
15 
16  bool filterAccepts (const ItemStack& item);
17 
18  virtual ItemStack getItem (ModelIndex index);
19  virtual size_t getItemCount();
20 
22  void addDragItem (const MWWorld::Ptr& dragItem, size_t count);
23  void clearDragItems();
24 
25  void setCategory (int category);
26  void setFilter (int filter);
27 
29  void setSortByType(bool sort) { mSortByType = sort; }
30 
31  static const int Category_Weapon = (1<<1);
32  static const int Category_Apparel = (1<<2);
33  static const int Category_Misc = (1<<3);
34  static const int Category_Magic = (1<<4);
35  static const int Category_All = 255;
36 
37  static const int Filter_OnlyIngredients = (1<<0);
38  static const int Filter_OnlyEnchanted = (1<<1);
39  static const int Filter_OnlyEnchantable = (1<<2);
40  static const int Filter_OnlyChargedSoulstones = (1<<3);
41  static const int Filter_OnlyUsableItems = (1<<4); // Only items with a Use action
42  static const int Filter_OnlyRepairable = (1<<5);
43  static const int Filter_OnlyRechargable = (1<<6);
44 
45 
46  private:
47  std::vector<ItemStack> mItems;
48 
49  std::vector<std::pair<MWWorld::Ptr, size_t> > mDragItems;
50 
51  int mCategory;
52  int mFilter;
54  };
55 
56 }
57 
58 #endif
virtual size_t getItemCount()
Definition: sortfilteritemmodel.cpp:186
static const int Filter_OnlyRepairable
Definition: sortfilteritemmodel.hpp:42
The base class that all item models should derive from.
Definition: itemmodel.hpp:43
std::vector< std::pair< MWWorld::Ptr, size_t > > mDragItems
Definition: sortfilteritemmodel.hpp:49
int mCategory
Definition: sortfilteritemmodel.hpp:51
static const int Filter_OnlyIngredients
Definition: sortfilteritemmodel.hpp:37
bool filterAccepts(const ItemStack &item)
Definition: sortfilteritemmodel.cpp:96
A proxy item model can be used to filter or rearrange items from a source model (or even add new item...
Definition: itemmodel.hpp:83
A single item stack managed by an item model.
Definition: itemmodel.hpp:12
SortFilterItemModel(ItemModel *sourceModel)
Definition: sortfilteritemmodel.cpp:78
static const int Filter_OnlyEnchanted
Definition: sortfilteritemmodel.hpp:38
std::vector< ItemStack > mItems
Definition: sortfilteritemmodel.hpp:47
static const int Filter_OnlyUsableItems
Definition: sortfilteritemmodel.hpp:41
static const int Filter_OnlyEnchantable
Definition: sortfilteritemmodel.hpp:39
static const int Category_Weapon
Definition: sortfilteritemmodel.hpp:31
static const int Category_Misc
Definition: sortfilteritemmodel.hpp:33
static const int Category_Magic
Definition: sortfilteritemmodel.hpp:34
void addDragItem(const MWWorld::Ptr &dragItem, size_t count)
Dragged items are not displayed.
Definition: sortfilteritemmodel.cpp:86
void setFilter(int filter)
Definition: sortfilteritemmodel.cpp:196
virtual ItemStack getItem(ModelIndex index)
Throws for invalid index or out of range index.
Definition: sortfilteritemmodel.cpp:177
static const int Category_Apparel
Definition: sortfilteritemmodel.hpp:32
virtual void update()
Rebuild the item model, this will invalidate existing model indices.
Definition: sortfilteritemmodel.cpp:201
Definition: sortfilteritemmodel.hpp:9
int mFilter
Definition: sortfilteritemmodel.hpp:52
void setSortByType(bool sort)
Use ItemStack::Type for sorting?
Definition: sortfilteritemmodel.hpp:29
void setCategory(int category)
Definition: sortfilteritemmodel.cpp:191
static const int Filter_OnlyChargedSoulstones
Definition: sortfilteritemmodel.hpp:40
bool mSortByType
Definition: sortfilteritemmodel.hpp:53
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
static const int Category_All
Definition: sortfilteritemmodel.hpp:35
void clearDragItems()
Definition: sortfilteritemmodel.cpp:91
static const int Filter_OnlyRechargable
Definition: sortfilteritemmodel.hpp:43