summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-01-25 07:46:12 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-01-25 07:46:12 +0000
commit2d8ee00f42b980d8351c810062d17271b3a65cf6 (patch)
tree40fc087b70eb8788288003dbeb891261681dc3d7
parent8641b372df45df8ca10c96b83205af5eb12d94a1 (diff)
[FIX] ObjectUI::setObjects now protected
[FIX] members made with new now delete-d [ADD] ItemTypeUI git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@47 6ecfd1a5-f3ed-3746-8530-beee90d26b22
-rw-r--r--Changelog9
-rw-r--r--pokemodr/ItemTypeUI.cpp89
-rw-r--r--pokemodr/ItemTypeUI.h58
-rw-r--r--pokemodr/ObjectUI.h12
-rw-r--r--pokemodr/PokeModrUI.cpp5
-rw-r--r--pokemodr/RulesUI.h4
-rw-r--r--pokemodr/TimeUI.h4
7 files changed, 174 insertions, 7 deletions
diff --git a/Changelog b/Changelog
index 3935de6d..262b524c 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,13 @@
-----------------
+Rev: 47
+Date: 25 January 2008
+User: MathStuf
+-----------------
+[FIX] ObjectUI::setObjects now protected
+[FIX] members made with new now delete-d
+[ADD] ItemTypeUI
+
+-----------------
Rev: 46
Date: 24 January 2008
User: MathStuf
diff --git a/pokemodr/ItemTypeUI.cpp b/pokemodr/ItemTypeUI.cpp
new file mode 100644
index 00000000..03da5f43
--- /dev/null
+++ b/pokemodr/ItemTypeUI.cpp
@@ -0,0 +1,89 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokegen/ItemTypeUI.cpp
+// Purpose: Item Type UI form handling
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Fri Jan 25 00:30:28 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 <QString>
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+#include "ItemTypeUI.h"
+
+ItemTypeUI::ItemTypeUI(ItemType* i, QWidget* parent) :
+ ObjectUI(parent),
+ itemType(i),
+ itemType_mod(new ItemType(i->getPokemod(), *i, i->getId()))
+{
+ setupUi(this);
+ QMetaObject::connectSlotsByName(this);
+ setObjects(itemType, itemType_mod);
+ setGui();
+}
+
+// KToolBar ItemTypeUI::getToolBar() const
+// {
+//
+// }
+
+void ItemTypeUI::setGui()
+{
+ varName->setText(itemType_mod->getName());
+ varComputer->setValue(itemType_mod->getComputer());
+ varPlayer->setValue(itemType_mod->getPlayer());
+}
+
+void ItemTypeUI::on_buttonApply_clicked()
+{
+ *itemType = *itemType_mod;
+ emit(setChanged(false));
+ setGui();
+}
+
+void ItemTypeUI::on_buttonDiscard_clicked()
+{
+ *itemType_mod = *itemType;
+ emit(setChanged(false));
+ setGui();
+}
+
+void ItemTypeUI::on_varName_textChanged(const QString& n)
+{
+ itemType_mod->setName(n);
+ emit(setChanged(true));
+}
+
+void ItemTypeUI::on_varComputer_valueChanged(const int c)
+{
+ itemType_mod->setComputer(c);
+ emit(setChanged(true));
+}
+
+void ItemTypeUI::on_varPlayer_valueChanged(const int p)
+{
+ try
+ {
+ itemType_mod->setPlayer(p);
+ emit(setChanged(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
diff --git a/pokemodr/ItemTypeUI.h b/pokemodr/ItemTypeUI.h
new file mode 100644
index 00000000..a4b76d63
--- /dev/null
+++ b/pokemodr/ItemTypeUI.h
@@ -0,0 +1,58 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokegen/ItemTypeUI.h
+// Purpose: Item Type UI form handling
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Fri Jan 25 00:24:05 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/>.
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __POKEMODR_ITEMTYPEUI__
+#define __POKEMODR_ITEMTYPEUI__
+
+#include <ktoolbar.h>
+#include <QObject>
+#include <QWidget>
+#include "../pokemod/ItemType.h"
+#include "ObjectUI.h"
+#include "ui_itemtype.h"
+
+class ItemTypeUI : public ObjectUI, private Ui::formItemType
+{
+ Q_OBJECT
+
+ public:
+ ItemTypeUI(ItemType* i, QWidget* parent);
+ ~ItemTypeUI()
+ {
+ delete itemType_mod;
+ }
+
+ KToolBar getToolBar() const;
+ public slots:
+ void on_buttonApply_clicked();
+ void on_buttonDiscard_clicked();
+ void on_varName_textChanged(const QString& n);
+ void on_varComputer_valueChanged(const int c);
+ void on_varPlayer_valueChanged(const int p);
+ private:
+ void setGui();
+
+ ItemType* itemType;
+ ItemType* itemType_mod;
+};
+
+#endif
diff --git a/pokemodr/ObjectUI.h b/pokemodr/ObjectUI.h
index 391ac6af..351612a7 100644
--- a/pokemodr/ObjectUI.h
+++ b/pokemodr/ObjectUI.h
@@ -45,12 +45,6 @@ class ObjectUI : public QWidget
{
}
- void setObjects(Object* orig, Object* mod)
- {
- obj = orig;
- obj_mod = mod;
- }
-
// virtual KToolBar getToolbar(QWidget* parent) = 0;
const Object* getOriginal() const
@@ -77,6 +71,12 @@ class ObjectUI : public QWidget
isChanged = c;
}
protected:
+ void setObjects(Object* orig, Object* mod)
+ {
+ obj = orig;
+ obj_mod = mod;
+ }
+
virtual void setGui() = 0;
bool isChanged;
diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp
index 1b5400c2..9af87b61 100644
--- a/pokemodr/PokeModrUI.cpp
+++ b/pokemodr/PokeModrUI.cpp
@@ -30,6 +30,7 @@
#include <iostream>
#include "../pokemod/Pokemod.h"
+#include "ItemTypeUI.h"
#include "RulesUI.h"
#include "TimeUI.h"
@@ -52,9 +53,11 @@ PokeModrUI::PokeModrUI(KConfigGroup cfg, KConfigGroup history, QWidget* parent)
try
{
Pokemod foo;
+ foo.newItemType();
+ formPanel->setViewport(new ItemTypeUI(&foo.getItemType(0), formPanel));
// foo.newTime();
// formPanel->setViewport(new TimeUI(&foo.getTime(0), formPanel));
- formPanel->setViewport(new RulesUI(&foo.getRules(), formPanel));
+// formPanel->setViewport(new RulesUI(&foo.getRules(), formPanel));
}
catch (Exception& e)
{
diff --git a/pokemodr/RulesUI.h b/pokemodr/RulesUI.h
index d3130437..c108a82a 100644
--- a/pokemodr/RulesUI.h
+++ b/pokemodr/RulesUI.h
@@ -34,6 +34,10 @@ class RulesUI : public ObjectUI, private Ui::formRules
public:
RulesUI(Rules* r, QWidget* parent);
+ ~RulesUI()
+ {
+ delete rules_mod;
+ }
KToolBar getToolbar(QWidget* parent);
public slots:
diff --git a/pokemodr/TimeUI.h b/pokemodr/TimeUI.h
index 604f8408..306ea1da 100644
--- a/pokemodr/TimeUI.h
+++ b/pokemodr/TimeUI.h
@@ -36,6 +36,10 @@ class TimeUI : public ObjectUI, private Ui::formTime
public:
TimeUI(Time* t, QWidget* parent);
+ ~TimeUI()
+ {
+ delete time_mod;
+ }
// KToolbar getToolbar(QWidget* parent);
public slots: