diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-04-27 17:57:32 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-04-27 17:57:32 +0000 |
| commit | 0fa52c1f61c457c9b68bec53bcce3af858e5eb44 (patch) | |
| tree | c5b10b77a01b417775097476029bcf67fac79975 /pokemodr/ItemUI.cpp | |
| parent | 807071d35159de0660f9df31c48d5bf895ca3622 (diff) | |
[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
Diffstat (limited to 'pokemodr/ItemUI.cpp')
| -rw-r--r-- | pokemodr/ItemUI.cpp | 42 |
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)); } |
