summaryrefslogtreecommitdiffstats
path: root/pokemodr/ItemUI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemodr/ItemUI.cpp')
-rw-r--r--pokemodr/ItemUI.cpp42
1 files changed, 22 insertions, 20 deletions
diff --git a/pokemodr/ItemUI.cpp b/pokemodr/ItemUI.cpp
index 9257b0a8..f2d50867 100644
--- a/pokemodr/ItemUI.cpp
+++ b/pokemodr/ItemUI.cpp
@@ -19,68 +19,70 @@
#include "ItemUI.h"
// Pokemod includes
+#include "../pokemod/Item.h"
#include "../pokemod/ItemType.h"
#include "../pokemod/Pokemod.h"
// General includes
#include "../general/BugCatcher.h"
-#include "../general/Exception.h"
ItemUI::ItemUI(Item* item, QWidget* parent) :
- ObjectUI(parent),
- m_item(item),
- m_item_mod(new Item(*item))
+ ObjectUI(parent)
{
setupUi(this);
QMetaObject::connectSlotsByName(this);
- setObjects(m_item, m_item_mod);
+ setObjects(item, new Item(*item));
connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool)));
init();
}
+ItemUI::~ItemUI()
+{
+}
+
void ItemUI::refreshGui()
{
varType->clear();
- for (int i = 0; i < static_cast<const Pokemod*>(m_item->pokemod())->itemTypeCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(static_cast<Item*>(original())->pokemod())->itemTypeCount(); ++i)
{
- const ItemType* itemType = static_cast<const Pokemod*>(m_item->pokemod())->itemType(i);
+ const ItemType* itemType = static_cast<const Pokemod*>(static_cast<Item*>(original())->pokemod())->itemType(i);
varType->addItem(itemType->name());
varType->setItemData(i, itemType->id());
}
- varPrice->setMaximum(static_cast<const Pokemod*>(m_item->pokemod())->rules()->maxMoney());
+ varPrice->setMaximum(static_cast<const Pokemod*>(static_cast<Item*>(original())->pokemod())->rules()->maxMoney());
}
void ItemUI::setGui()
{
- varName->setText(m_item_mod->name());
- boxSellable->setChecked(m_item_mod->sellable() ? Qt::Checked : Qt::Unchecked);
- varType->setCurrentIndex(varType->findData(m_item_mod->type()));
- varPrice->setValue(m_item_mod->price());
- varDescription->setText(m_item_mod->description());
+ varName->setText(static_cast<Item*>(modified())->name());
+ boxSellable->setChecked(static_cast<Item*>(modified())->sellable() ? Qt::Checked : Qt::Unchecked);
+ varType->setCurrentIndex(varType->findData(static_cast<Item*>(modified())->type()));
+ varPrice->setValue(static_cast<Item*>(modified())->price());
+ varDescription->setText(static_cast<Item*>(modified())->description());
}
void ItemUI::on_buttonApply_clicked()
{
- *m_item = *m_item_mod;
+ *static_cast<Item*>(original()) = *static_cast<Item*>(modified());
emit(changed(false));
}
void ItemUI::on_buttonDiscard_clicked()
{
- *m_item_mod = *m_item;
+ *static_cast<Item*>(modified()) = *static_cast<Item*>(original());
setGui();
emit(changed(false));
}
void ItemUI::on_varName_textChanged(const QString& name)
{
- m_item_mod->setName(name);
+ static_cast<Item*>(modified())->setName(name);
emit(changed(true));
}
void ItemUI::on_boxSellable_toggled(const bool sellable)
{
- m_item_mod->setSellable(sellable);
+ static_cast<Item*>(modified())->setSellable(sellable);
emit(changed(true));
}
@@ -88,7 +90,7 @@ void ItemUI::on_varType_currentIndexChanged(const int type)
{
try
{
- m_item_mod->setType(varType->itemData(type).toInt());
+ static_cast<Item*>(modified())->setType(varType->itemData(type).toInt());
emit(changed(true));
}
catch (Exception& exception)
@@ -102,7 +104,7 @@ void ItemUI::on_varPrice_valueChanged(const int price)
{
try
{
- m_item_mod->setPrice(price);
+ static_cast<Item*>(modified())->setPrice(price);
emit(changed(true));
}
catch (BoundsException& exception)
@@ -114,6 +116,6 @@ void ItemUI::on_varPrice_valueChanged(const int price)
void ItemUI::on_varDescription_textChanged()
{
- m_item_mod->setDescription(varDescription->toPlainText());
+ static_cast<Item*>(modified())->setDescription(varDescription->toPlainText());
emit(changed(true));
}