OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MWGui::TradeItemModel Class Reference

An item model that allows 'borrowing' items from another item model. Used for previewing barter offers. Also filters items that the merchant does not sell. More...

#include <tradeitemmodel.hpp>

Inheritance diagram for MWGui::TradeItemModel:
Collaboration diagram for MWGui::TradeItemModel:

Public Member Functions

 TradeItemModel (ItemModel *sourceModel, const MWWorld::Ptr &merchant)
 
virtual ItemStack getItem (ModelIndex index)
 Throws for invalid index or out of range index. More...
 
virtual size_t getItemCount ()
 
virtual void update ()
 Rebuild the item model, this will invalidate existing model indices. More...
 
void borrowItemFromUs (ModelIndex itemIndex, size_t count)
 
void borrowItemToUs (ModelIndex itemIndex, ItemModel *source, size_t count)
 
void returnItemBorrowedToUs (ModelIndex itemIndex, size_t count)
 
void returnItemBorrowedFromUs (ModelIndex itemIndex, ItemModel *source, size_t count)
 
void transferItems ()
 Permanently transfers items that were borrowed to us from another model to this model. More...
 
void abort ()
 Aborts trade. More...
 
void adjustEncumbrance (float &encumbrance)
 
std::vector< ItemStackgetItemsBorrowedToUs ()
 
- Public Member Functions inherited from MWGui::ProxyItemModel
 ProxyItemModel ()
 
virtual ~ProxyItemModel ()
 
virtual MWWorld::Ptr copyItem (const ItemStack &item, size_t count, bool setNewOwner=false)
 
virtual void removeItem (const ItemStack &item, size_t count)
 
virtual ModelIndex getIndex (ItemStack item)
 Returns an invalid index if the item was not found. More...
 
void setSourceModel (ItemModel *sourceModel)
 
ModelIndex mapToSource (ModelIndex index)
 
ModelIndex mapFromSource (ModelIndex index)
 
- Public Member Functions inherited from MWGui::ItemModel
 ItemModel ()
 
virtual ~ItemModel ()
 
virtual MWWorld::Ptr moveItem (const ItemStack &item, size_t count, ItemModel *otherModel)
 
virtual bool allowedToInsertItems () const
 Is the player allowed to insert items into this model? (default true) More...
 

Private Member Functions

void borrowImpl (const ItemStack &item, std::vector< ItemStack > &out)
 
void unborrowImpl (const ItemStack &item, size_t count, std::vector< ItemStack > &out)
 

Private Attributes

std::vector< ItemStackmItems
 
std::vector< ItemStackmBorrowedToUs
 
std::vector< ItemStackmBorrowedFromUs
 
MWWorld::Ptr mMerchant
 

Additional Inherited Members

- Public Types inherited from MWGui::ItemModel
typedef int ModelIndex
 
- Protected Attributes inherited from MWGui::ProxyItemModel
ItemModelmSourceModel
 

Detailed Description

An item model that allows 'borrowing' items from another item model. Used for previewing barter offers. Also filters items that the merchant does not sell.

Constructor & Destructor Documentation

MWGui::TradeItemModel::TradeItemModel ( ItemModel sourceModel,
const MWWorld::Ptr merchant 
)

Member Function Documentation

void MWGui::TradeItemModel::abort ( )

Aborts trade.

Here is the caller graph for this function:

void MWGui::TradeItemModel::adjustEncumbrance ( float &  encumbrance)

Adjusts the given encumbrance by adding weight for items that have been lent to us, and removing weight for items we've lent to someone else.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWGui::TradeItemModel::borrowImpl ( const ItemStack item,
std::vector< ItemStack > &  out 
)
private

Here is the caller graph for this function:

void MWGui::TradeItemModel::borrowItemFromUs ( ModelIndex  itemIndex,
size_t  count 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWGui::TradeItemModel::borrowItemToUs ( ModelIndex  itemIndex,
ItemModel source,
size_t  count 
)
Note
itemIndex points to an item in source

Here is the call graph for this function:

Here is the caller graph for this function:

ItemStack MWGui::TradeItemModel::getItem ( ModelIndex  index)
virtual

Throws for invalid index or out of range index.

Implements MWGui::ItemModel.

Here is the caller graph for this function:

size_t MWGui::TradeItemModel::getItemCount ( )
virtual

The number of items in the model, this specifies the range of indices you can pass to the getItem function (but this range is only valid until the next call to update())

Implements MWGui::ItemModel.

Here is the caller graph for this function:

std::vector< ItemStack > MWGui::TradeItemModel::getItemsBorrowedToUs ( )

Here is the caller graph for this function:

void MWGui::TradeItemModel::returnItemBorrowedFromUs ( ModelIndex  itemIndex,
ItemModel source,
size_t  count 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWGui::TradeItemModel::returnItemBorrowedToUs ( ModelIndex  itemIndex,
size_t  count 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWGui::TradeItemModel::transferItems ( )

Permanently transfers items that were borrowed to us from another model to this model.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWGui::TradeItemModel::unborrowImpl ( const ItemStack item,
size_t  count,
std::vector< ItemStack > &  out 
)
private

Here is the caller graph for this function:

void MWGui::TradeItemModel::update ( )
virtual

Rebuild the item model, this will invalidate existing model indices.

Implements MWGui::ItemModel.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

std::vector<ItemStack> MWGui::TradeItemModel::mBorrowedFromUs
private
std::vector<ItemStack> MWGui::TradeItemModel::mBorrowedToUs
private
std::vector<ItemStack> MWGui::TradeItemModel::mItems
private
MWWorld::Ptr MWGui::TradeItemModel::mMerchant
private

The documentation for this class was generated from the following files: