Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
ItemMarketEntry Class Referenceabstract

Abstract base for one row of the item market – the row-type hierarchy root. More...

#include <itemmarketentry.h>

Inheritance diagram for ItemMarketEntry:
Collaboration diagram for ItemMarketEntry:

Public Types

enum  { CompatNo = 0 , CompatYes , CompatEither }
 Three-state compatibility for the mode filters. More...
enum  {
  HashKeyName , HashKeyInStockCount , HashKeyCanSell , HashKeyItemWorth ,
  HashKeyWhichType
}
 Cache keys for the memoised mode-stable values. More...

Public Member Functions

 ItemMarketEntry (int compatMoneyCurrency=CompatEither, int compatBuyMode=CompatEither)
virtual ~ItemMarketEntry ()
virtual void initOnce ()
 One-time setup for the first instance of a type.
void finishConstruction ()
 Finalise construction (register the instance).
QString name ()
 Cached display name.
virtual QString _name ()=0
 Subtype: compute the display name.
int inStockCount ()
 Cached owned/sellable count.
virtual int _inStockCount ()=0
 Subtype: compute the owned/sellable count.
bool canSell ()
 Cached sellable flag.
virtual bool _canSell ()=0
 Subtype: compute sellability.
int itemWorth ()
 Cached unit value.
virtual int _itemWorth ()=0
 Subtype: compute the unit value.
QString whichType ()
 Cached type label.
virtual QString _whichType ()=0
 Subtype: report the type label.
virtual QString infoText ()
 Detailed-tooltip body (default none).
virtual int stackCount ()=0
 Subtype: new stack slots needed (see note above).
virtual int onCartLeft ()=0
 Subtype: how many more may be added.
bool requestFilter ()
 Helper: does this row pass the current mode filter?
int getCartCount ()
 Current cart quantity (backs onCart).
int cartWorth ()
 Value of the cart quantity.
int totalStackCount ()
 Stacks across all rows of this type.
int totalWorth ()
 Signed worth across ALL rows (sell +, buy -).
int moneyLeftover ()
 Money remaining if this checks out.
virtual bool canCheckout ()
 Can this row alone check out?
bool canAnyCheckout ()
 Can any row check out?
virtual void checkout ()=0
 Subtype: apply this row's transaction.
void setCartCount (int val)
 Set the cart quantity (backs onCart).
void reUpdateConstants ()
 Clear the cached mode-stable values.

Public Attributes

int compatMoneyCurrency = CompatEither
 Money/coins compatibility.
int compatBuyMode = CompatEither
 Buy/sell compatibility.
int onCart = 0
 Backing cart quantity.
bool exclude = false
 Exclude from aggregate totals (see note).
int viewTag = -1
 Left-list view filter tag.
int cartSignVal = 1
 Net contribution sign (-1 buy / +1 sell).
QHash< int, QVariant > cache
 Memoised mode-stable values (see HashKey* enum).

Static Public Attributes

static bool * isMoneyCurrency = nullptr
 Shared: current currency mode.
static bool * isBuyMode = nullptr
 Shared: current buy/sell mode.
static PlayerBasicsplayer = nullptr
 Shared: player money/coins.
static QHash< QString, QVector< ItemMarketEntry * > * > instances
 All rows, grouped by type.
static QVector< ItemMarketEntry * > instancesCombined
 All rows, flat.
static QVector< ItemMarketEntry * > * activeList = nullptr
 Current model's live rows.

Protected Member Functions

void doReUpdateConstants ()
 Force a refresh of the "mode-stable" values.

Protected Attributes

 : void onCartChanged()
 < Quantity on the cart.

Detailed Description

Abstract base for one row of the item market – the row-type hierarchy root.

Each market row is an ItemMarketEntry subtype: a player item, a store item, money/coins, a message, or a Game Corner Pokemon. This base defines the shared cart mechanics (onCart, worth, stack/space limits, checkout gating) and a virtual table of _name(), _inStockCount(), _canSell(), _itemWorth(), _whichType(), stackCount(), onCartLeft(), checkout() that subtypes implement. The compatMoneyCurrency / compatBuyMode flags filter which rows appear in which of the model's four modes.

Note
Static members (isMoneyCurrency, isBuyMode, player, instances) are shared because the market model is effectively a singleton; expensive per-row values are memoised in cache.
See also
ItemMarketModel, and the subtypes ItemMarketEntryMoney/Message/StoreItem/ PlayerItem/GCPokemon.

Definition at line 41 of file itemmarketentry.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Cache keys for the memoised mode-stable values.

Enumerator
HashKeyName 
HashKeyInStockCount 
HashKeyCanSell 
HashKeyItemWorth 
HashKeyWhichType 

Definition at line 80 of file itemmarketentry.h.

◆ anonymous enum

anonymous enum

Three-state compatibility for the mode filters.

Enumerator
CompatNo 
CompatYes 
CompatEither 

Definition at line 72 of file itemmarketentry.h.

Constructor & Destructor Documentation

◆ ItemMarketEntry()

ItemMarketEntry::ItemMarketEntry ( int compatMoneyCurrency = CompatEither,
int compatBuyMode = CompatEither )

◆ ~ItemMarketEntry()

ItemMarketEntry::~ItemMarketEntry ( )
virtual

Definition at line 35 of file itemmarketentry.cpp.

References instances, instancesCombined, and whichType().

Member Function Documentation

◆ _canSell()

virtual bool ItemMarketEntry::_canSell ( )
pure virtual

◆ _inStockCount()

virtual int ItemMarketEntry::_inStockCount ( )
pure virtual

◆ _itemWorth()

virtual int ItemMarketEntry::_itemWorth ( )
pure virtual

◆ _name()

virtual QString ItemMarketEntry::_name ( )
pure virtual

◆ _whichType()

virtual QString ItemMarketEntry::_whichType ( )
pure virtual

◆ canAnyCheckout()

bool ItemMarketEntry::canAnyCheckout ( )

Can any row check out?

Definition at line 218 of file itemmarketentry.cpp.

References activeList.

◆ canCheckout()

bool ItemMarketEntry::canCheckout ( )
virtual

◆ canSell()

bool ItemMarketEntry::canSell ( )

Cached sellable flag.

Definition at line 87 of file itemmarketentry.cpp.

References _canSell(), cache, and HashKeyCanSell.

◆ cartWorth()

int ItemMarketEntry::cartWorth ( )

Value of the cart quantity.

Definition at line 154 of file itemmarketentry.cpp.

References itemWorth(), onCart, and requestFilter().

Referenced by ItemMarketEntryPlayerItem::checkout(), and ItemMarketEntryStoreItem::checkout().

◆ checkout()

virtual void ItemMarketEntry::checkout ( )
pure virtual

◆ doReUpdateConstants()

void ItemMarketEntry::doReUpdateConstants ( )
protected

Force a refresh of the "mode-stable" values.

Referenced by reUpdateConstants().

◆ finishConstruction()

◆ getCartCount()

int ItemMarketEntry::getCartCount ( )

Current cart quantity (backs onCart).

Definition at line 149 of file itemmarketentry.cpp.

References onCart.

◆ infoText()

virtual QString ItemMarketEntry::infoText ( )
inlinevirtual

Detailed-tooltip body (default none).

Reimplemented in ItemMarketEntryPlayerItem, and ItemMarketEntryStoreItem.

Definition at line 125 of file itemmarketentry.h.

◆ initOnce()

void ItemMarketEntry::initOnce ( )
virtual

One-time setup for the first instance of a type.

Definition at line 53 of file itemmarketentry.cpp.

Referenced by finishConstruction().

◆ inStockCount()

int ItemMarketEntry::inStockCount ( )

Cached owned/sellable count.

Definition at line 79 of file itemmarketentry.cpp.

References _inStockCount(), cache, and HashKeyInStockCount.

◆ itemWorth()

int ItemMarketEntry::itemWorth ( )

◆ moneyLeftover()

int ItemMarketEntry::moneyLeftover ( )

Money remaining if this checks out.

Definition at line 202 of file itemmarketentry.cpp.

References player, and totalWorth().

Referenced by canCheckout(), ItemMarketEntryGCPokemon::onCartLeft(), ItemMarketEntryPlayerItem::onCartLeft(), and ItemMarketEntryStoreItem::onCartLeft().

◆ name()

QString ItemMarketEntry::name ( )

Cached display name.

Definition at line 71 of file itemmarketentry.cpp.

References _name(), cache, and HashKeyName.

◆ onCartLeft()

virtual int ItemMarketEntry::onCartLeft ( )
pure virtual

◆ requestFilter()

◆ reUpdateConstants()

void ItemMarketEntry::reUpdateConstants ( )

◆ setCartCount()

void ItemMarketEntry::setCartCount ( int val)

Set the cart quantity (backs onCart).

Definition at line 231 of file itemmarketentry.cpp.

References onCart.

◆ stackCount()

virtual int ItemMarketEntry::stackCount ( )
pure virtual

Subtype: new stack slots needed (see note above).

Implemented in ItemMarketEntryGCPokemon, ItemMarketEntryMessage, ItemMarketEntryMoney, ItemMarketEntryPlayerItem, and ItemMarketEntryStoreItem.

◆ totalStackCount()

int ItemMarketEntry::totalStackCount ( )

Stacks across all rows of this type.

Definition at line 162 of file itemmarketentry.cpp.

References activeList, and whichType().

Referenced by ItemMarketEntryGCPokemon::onCartLeft(), and ItemMarketEntryStoreItem::onCartLeft().

◆ totalWorth()

int ItemMarketEntry::totalWorth ( )

Signed worth across ALL rows (sell +, buy -).

Definition at line 183 of file itemmarketentry.cpp.

References activeList.

Referenced by moneyLeftover().

◆ whichType()

QString ItemMarketEntry::whichType ( )

Cached type label.

Definition at line 103 of file itemmarketentry.cpp.

References _whichType(), cache, and HashKeyWhichType.

Referenced by finishConstruction(), totalStackCount(), and ~ItemMarketEntry().

Member Data Documentation

◆ __pad0__

ItemMarketEntry::__pad0__
protected

< Quantity on the cart.

Can this row check out? Value of this row's cart qty. New stack slots this row needs. How many more can be added. Total stacks across this type. < Display name (mode-stable). Owned/sellable count (mode-stable). Sellable (mode-stable). Unit value (mode-stable). Row type label (mode-stable). This row's cart quantity changed.

Definition at line 1 of file itemmarketentry.h.

◆ activeList

QVector< ItemMarketEntry * > * ItemMarketEntry::activeList = nullptr
static

Current model's live rows.

Definition at line 206 of file itemmarketentry.h.

Referenced by ItemMarketModel::buildList(), canAnyCheckout(), totalStackCount(), and totalWorth().

◆ cache

QHash<int, QVariant> ItemMarketEntry::cache

Memoised mode-stable values (see HashKey* enum).

Definition at line 211 of file itemmarketentry.h.

Referenced by canSell(), inStockCount(), itemWorth(), name(), reUpdateConstants(), and whichType().

◆ cartSignVal

int ItemMarketEntry::cartSignVal = 1

Net contribution sign (-1 buy / +1 sell).

Definition at line 187 of file itemmarketentry.h.

Referenced by ItemMarketEntryStoreItem::ItemMarketEntryStoreItem().

◆ compatBuyMode

int ItemMarketEntry::compatBuyMode = CompatEither

Buy/sell compatibility.

Definition at line 166 of file itemmarketentry.h.

Referenced by ItemMarketEntry(), and requestFilter().

◆ compatMoneyCurrency

int ItemMarketEntry::compatMoneyCurrency = CompatEither

Money/coins compatibility.

Definition at line 165 of file itemmarketentry.h.

Referenced by ItemMarketEntry(), and requestFilter().

◆ exclude

bool ItemMarketEntry::exclude = false

Exclude from aggregate totals (see note).

Definition at line 174 of file itemmarketentry.h.

Referenced by ItemMarketEntryMessage::ItemMarketEntryMessage(), and ItemMarketEntryMoney::ItemMarketEntryMoney().

◆ instances

QHash< QString, QVector< ItemMarketEntry * > * > ItemMarketEntry::instances
static
Initial value:
=
QHash<QString, QVector<ItemMarketEntry*>*>()

All rows, grouped by type.

Definition at line 196 of file itemmarketentry.h.

Referenced by finishConstruction(), and ~ItemMarketEntry().

◆ instancesCombined

QVector< ItemMarketEntry * > ItemMarketEntry::instancesCombined
static
Initial value:
=
QVector<ItemMarketEntry*>()

All rows, flat.

Definition at line 199 of file itemmarketentry.h.

Referenced by finishConstruction(), and ~ItemMarketEntry().

◆ isBuyMode

bool * ItemMarketEntry::isBuyMode = nullptr
static

Shared: current buy/sell mode.

Definition at line 192 of file itemmarketentry.h.

Referenced by ItemMarketEntryMoney::buying(), ItemMarketModel::ItemMarketModel(), and requestFilter().

◆ isMoneyCurrency

bool * ItemMarketEntry::isMoneyCurrency = nullptr
static

◆ onCart

◆ player

◆ viewTag

int ItemMarketEntry::viewTag = -1

Left-list view filter tag.

Definition at line 179 of file itemmarketentry.h.


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