bool CPetInventoryGlyph::doAction(CGlyphAction *action) {
	CInventoryGlyphAction *invAction = static_cast<CInventoryGlyphAction *>(action);
	CPetInventoryGlyphs *owner = dynamic_cast<CPetInventoryGlyphs *>(_owner);
	if (!invAction)
		return false;

	switch (invAction->getMode()) {
	case ACTION_REMOVED:
		if (invAction->_item == _item) {
			_item = nullptr;
			_background = nullptr;
			_field34 = 0;
		}
		break;

	case ACTION_REMOVE:
		if (_item == invAction->_item && _owner) {
			int v = populateItem(_item, 0);
			_background = owner->getBackground(v);

			if (isHighlighted()) {
				Point glyphPos = _owner->getHighlightedGlyphPos();
				reposition(glyphPos);
				updateTooltip();
			}
		}
		break;

	default:
		break;
	}

	return true;
}
void CPetInventoryGlyph::setItem(CGameObject *item, bool isLoading) {
	_item = item;

	if (_owner && item) {
		int v1 = populateItem(item, isLoading);
		_background = static_cast<CPetInventoryGlyphs *>(_owner)->getBackground(v1);
		_image = static_cast<CPetInventory *>(getPetSection())->getImage(v1);
	}
}
//---------------------------------------------------------------
// ConversationsModel::addRow
// @see header
//---------------------------------------------------------------
void ConversationsModel::addRow(const CCsConversationEntry& entry, bool dynamicUpdate)
{
    int msgId = entry.EntryId();
    //match, if found update else add item
    QModelIndexList indexList = this->match(index(0, 0), ConvergedMsgId, msgId, -1,
        Qt::MatchExactly);

    // if not found, add new item
    if (indexList.count() == 0) {
        QStandardItem* item = new QStandardItem();
        populateItem(*item, entry);
        if (!dynamicUpdate) {
            insertRow(0, item);
        }
        else {
            int i;
            for (i = rowCount() - 1; i >= 0; --i) {
                QStandardItem* modelItem = this->item(i, 0);
                if (modelItem->data(ConvergedMsgId).toInt() < item->data(ConvergedMsgId).toInt()) {
                    if (i == rowCount() - 1) {
                        appendRow(item);
                    }
                    else {
                        insertRow(i + 1, item);
                    }
                    return;
                }
            }
            if (i == 0) {
                insertRow(0, item);
            }
        }
    }
    else {
        // Update an existing item
        QModelIndex index = indexList[0];
        QStandardItem* item = this->item(index.row(), 0);
        populateItem(*item, entry);
    }
}
void CPetInventoryGlyph::getTooltip(CPetText *text) {
	if (text) {
		text->setText("");

		if (_field34 && _item) {
			int itemIndex = populateItem(_item, 0);
			if (itemIndex >= 14 && itemIndex <= 18) {
				CPETObjectStateMsg stateMsg(0);
				stateMsg.execute(_item);

				text->setText(CString::format("%s %s",
					stateMsg._value ? "A hot " : "A cold ",
					g_vm->_itemDescriptions[itemIndex].c_str()
				));

			} else {
				text->setText(g_vm->_itemDescriptions[itemIndex]);
			}
		}
	}
}