summaryrefslogtreecommitdiffstats
path: root/pokemodr/StoreUI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemodr/StoreUI.cpp')
-rw-r--r--pokemodr/StoreUI.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/pokemodr/StoreUI.cpp b/pokemodr/StoreUI.cpp
index c7043f77..31db81a9 100644
--- a/pokemodr/StoreUI.cpp
+++ b/pokemodr/StoreUI.cpp
@@ -25,30 +25,27 @@
// General includes
#include "../general/BugCatcher.h"
-#include "../general/Exception.h"
-
-// Qt includes
-#include <QListWidgetItem>
-#include <QVariant>
StoreUI::StoreUI(Store* store, QWidget* parent) :
- ObjectUI(parent),
- m_store(store),
- m_store_mod(new Store(*store))
+ ObjectUI(parent)
{
setupUi(this);
QMetaObject::connectSlotsByName(this);
- setObjects(m_store, m_store_mod);
+ setObjects(store, new Store(*store));
connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool)));
init();
}
+StoreUI::~StoreUI()
+{
+}
+
void StoreUI::refreshGui()
{
varItems->clear();
- for (int i = 0; i < static_cast<const Pokemod*>(m_store->pokemod())->itemCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(static_cast<Store*>(original())->pokemod())->itemCount(); ++i)
{
- const Item* item = static_cast<const Pokemod*>(m_store->pokemod())->item(i);
+ const Item* item = static_cast<const Pokemod*>(static_cast<Store*>(original())->pokemod())->item(i);
QListWidgetItem* widgetItem = new QListWidgetItem(item->name(), varItems);
widgetItem->setData(Qt::UserRole, item->id());
}
@@ -56,30 +53,30 @@ void StoreUI::refreshGui()
void StoreUI::setGui()
{
- varName->setText(m_store_mod->name());
+ varName->setText(static_cast<Store*>(modified())->name());
for (int i = 0; i < varItems->count(); ++i)
{
QListWidgetItem* widgetItem = varItems->item(i);
- widgetItem->setSelected(m_store_mod->item(widgetItem->data(Qt::UserRole).toInt()));
+ widgetItem->setSelected(static_cast<Store*>(modified())->item(widgetItem->data(Qt::UserRole).toInt()));
}
}
void StoreUI::on_buttonApply_clicked()
{
- *m_store = *m_store_mod;
+ *static_cast<Store*>(original()) = *static_cast<Store*>(modified());
emit(changed(false));
}
void StoreUI::on_buttonDiscard_clicked()
{
- *m_store_mod = *m_store;
+ *static_cast<Store*>(modified()) = *static_cast<Store*>(original());
setGui();
emit(changed(false));
}
void StoreUI::on_varName_textChanged(const QString& name)
{
- m_store_mod->setName(name);
+ static_cast<Store*>(modified())->setName(name);
emit(changed(true));
}
@@ -90,7 +87,7 @@ void StoreUI::on_varItems_itemSelectionChanged()
for (int i = 0; i < varItems->count(); ++i)
{
const QListWidgetItem* widgetItem = varItems->item(i);
- m_store_mod->setItem(widgetItem->data(Qt::UserRole).toInt(), widgetItem->isSelected());
+ static_cast<Store*>(modified())->setItem(widgetItem->data(Qt::UserRole).toInt(), widgetItem->isSelected());
}
emit(changed(true));
}