From 0fa52c1f61c457c9b68bec53bcce3af858e5eb44 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 27 Apr 2008 17:57:32 +0000 Subject: [FIX] More header cleanliness [FIX] UI classes now just use the ObjectUI pointers [FIX] Some miscellaneous qmake options git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@112 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemodr/ItemUI.cpp | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'pokemodr/ItemUI.cpp') 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(m_item->pokemod())->itemTypeCount(); ++i) + for (int i = 0; i < static_cast(static_cast(original())->pokemod())->itemTypeCount(); ++i) { - const ItemType* itemType = static_cast(m_item->pokemod())->itemType(i); + const ItemType* itemType = static_cast(static_cast(original())->pokemod())->itemType(i); varType->addItem(itemType->name()); varType->setItemData(i, itemType->id()); } - varPrice->setMaximum(static_cast(m_item->pokemod())->rules()->maxMoney()); + varPrice->setMaximum(static_cast(static_cast(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(modified())->name()); + boxSellable->setChecked(static_cast(modified())->sellable() ? Qt::Checked : Qt::Unchecked); + varType->setCurrentIndex(varType->findData(static_cast(modified())->type())); + varPrice->setValue(static_cast(modified())->price()); + varDescription->setText(static_cast(modified())->description()); } void ItemUI::on_buttonApply_clicked() { - *m_item = *m_item_mod; + *static_cast(original()) = *static_cast(modified()); emit(changed(false)); } void ItemUI::on_buttonDiscard_clicked() { - *m_item_mod = *m_item; + *static_cast(modified()) = *static_cast(original()); setGui(); emit(changed(false)); } void ItemUI::on_varName_textChanged(const QString& name) { - m_item_mod->setName(name); + static_cast(modified())->setName(name); emit(changed(true)); } void ItemUI::on_boxSellable_toggled(const bool sellable) { - m_item_mod->setSellable(sellable); + static_cast(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(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(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(modified())->setDescription(varDescription->toPlainText()); emit(changed(true)); } -- cgit