diff options
Diffstat (limited to 'pokemodr/ItemUI.cpp')
| -rw-r--r-- | pokemodr/ItemUI.cpp | 100 |
1 files changed, 48 insertions, 52 deletions
diff --git a/pokemodr/ItemUI.cpp b/pokemodr/ItemUI.cpp index b8194a42..70cf36b5 100644 --- a/pokemodr/ItemUI.cpp +++ b/pokemodr/ItemUI.cpp @@ -1,43 +1,39 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pokegen/ItemUI.cpp -// Purpose: Item UI form handling -// Author: Ben Boeckel -// Modified by: Ben Boeckel -// Created: Sun Jan 27 12:31:08 2008 -// Copyright: ©2007-2008 Ben Boeckel and Nerdy Productions -// Licence: -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program. If not, see <http://www.gnu.org/licenses/>. -///////////////////////////////////////////////////////////////////////////// - -#include <QMetaObject> +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ +// General includes #include <BugCatcher.h> #include <Exception.h> +// Pokemod includes #include <ItemType.h> #include <Pokemod.h> +// Header include #include "ItemUI.h" -ItemUI::ItemUI(Item* i, QWidget* parent) : +ItemUI::ItemUI(Item* item, QWidget* parent) : ObjectUI(parent), - item(i), - item_mod(new Item(i->getPokemod(), *i, i->getId())) + m_item(item), + m_item_mod(new Item(*item)) { setupUi(this); QMetaObject::connectSlotsByName(this); - setObjects(item, item_mod); + setObjects(m_item, m_item_mod); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); init(); } @@ -45,79 +41,79 @@ ItemUI::ItemUI(Item* i, QWidget* parent) : void ItemUI::refreshGui() { varType->clear(); - for (int i = 0; i < item->getPokemod()->getItemTypeCount(); ++i) + for (int i = 0; i < m_item->pokemod()->itemTypeCount(); ++i) { - const ItemType* it = item->getPokemod()->getItemType(i); - varType->addItem(it->getName()); - varType->setItemData(i, it->getId()); + const ItemType* itemType = m_item->pokemod()->itemType(i); + varType->addItem(itemType->name()); + varType->setItemData(i, itemType->id()); } - varPrice->setMaximum(item->getPokemod()->getRules()->getMaxMoney()); + varPrice->setMaximum(m_item->pokemod()->rules()->maxMoney()); } void ItemUI::setGui() { - varName->setText(item_mod->getName()); - boxSellable->setChecked(item_mod->getSellable() ? Qt::Checked : Qt::Unchecked); - varType->setCurrentIndex(varType->findData(item_mod->getType())); - varPrice->setValue(item_mod->getPrice()); - varDescription->setText(item_mod->getDescription()); + 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()); } void ItemUI::on_buttonApply_clicked() { - *item = *item_mod; + *m_item = *m_item_mod; emit(changed(false)); } void ItemUI::on_buttonDiscard_clicked() { - *item_mod = *item; + *m_item_mod = *m_item; setGui(); emit(changed(false)); } -void ItemUI::on_varName_textChanged(const QString& n) +void ItemUI::on_varName_textChanged(const QString& name) { - item_mod->setName(n); + m_item_mod->setName(name); emit(changed(true)); } -void ItemUI::on_boxSellable_toggled(const bool s) +void ItemUI::on_boxSellable_toggled(const bool sellable) { - item_mod->setSellable(s); + m_item_mod->setSellable(sellable); emit(changed(true)); } -void ItemUI::on_varType_currentIndexChanged(const int t) +void ItemUI::on_varType_currentIndexChanged(const int type) { try { - item_mod->setType(varType->itemData(t).toInt()); + m_item_mod->setType(varType->itemData(type).toInt()); emit(changed(true)); } - catch (Exception& e) + catch (Exception& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -void ItemUI::on_varPrice_valueChanged(const int p) +void ItemUI::on_varPrice_valueChanged(const int price) { try { - item_mod->setPrice(p); + m_item_mod->setPrice(price); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } void ItemUI::on_varDescription_textChanged() { - item_mod->setDescription(varDescription->toPlainText()); + m_item_mod->setDescription(varDescription->toPlainText()); emit(changed(true)); } |
