diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-05-15 19:55:43 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-05-15 19:55:43 +0000 |
| commit | fdd0eec1d145fb8ac97b4cc9aaed5218214416ec (patch) | |
| tree | 2389a0d53fe3eaa644ccb220345995feec748823 /pokemodr | |
| parent | 77124f3f105ea3837022d20a49028309a211c4b0 (diff) | |
| download | sigen-fdd0eec1d145fb8ac97b4cc9aaed5218214416ec.tar.gz sigen-fdd0eec1d145fb8ac97b4cc9aaed5218214416ec.tar.xz sigen-fdd0eec1d145fb8ac97b4cc9aaed5218214416ec.zip | |
[FIX] Refactored out connections made within widgets
[FIX] Flag, Fractiona, and Point widgets fixed to only emit signals when actually changed
[FIX] Pokemod classes now emit signals
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@138 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr')
41 files changed, 207 insertions, 234 deletions
diff --git a/pokemodr/AbilityUI.cpp b/pokemodr/AbilityUI.cpp index 14e5f0cb..a0b693c7 100644 --- a/pokemodr/AbilityUI.cpp +++ b/pokemodr/AbilityUI.cpp @@ -27,10 +27,6 @@ AbilityUI::AbilityUI(Ability* ability, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(ability, new Ability(*ability)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/AuthorUI.cpp b/pokemodr/AuthorUI.cpp index 45020256..235931e0 100644 --- a/pokemodr/AuthorUI.cpp +++ b/pokemodr/AuthorUI.cpp @@ -27,10 +27,6 @@ AuthorUI::AuthorUI(Author* author, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(author, new Author(*author)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/BadgeUI.cpp b/pokemodr/BadgeUI.cpp index cb4b5b9a..a07943a2 100644 --- a/pokemodr/BadgeUI.cpp +++ b/pokemodr/BadgeUI.cpp @@ -31,10 +31,6 @@ BadgeUI::BadgeUI(Badge* badge, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(badge, new Badge(*badge)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/CoinListObjectUI.cpp b/pokemodr/CoinListObjectUI.cpp index 2e672415..7fe2d9d6 100644 --- a/pokemodr/CoinListObjectUI.cpp +++ b/pokemodr/CoinListObjectUI.cpp @@ -32,10 +32,6 @@ CoinListObjectUI::CoinListObjectUI(CoinListObject* object, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(object, new CoinListObject(*object)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/CoinListUI.cpp b/pokemodr/CoinListUI.cpp index da0cd85e..5c0800cc 100644 --- a/pokemodr/CoinListUI.cpp +++ b/pokemodr/CoinListUI.cpp @@ -30,10 +30,6 @@ CoinListUI::CoinListUI(CoinList* coinList, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(coinList, new CoinList(*coinList)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/EggGroupUI.cpp b/pokemodr/EggGroupUI.cpp index fc2b5ed8..23faa3b5 100644 --- a/pokemodr/EggGroupUI.cpp +++ b/pokemodr/EggGroupUI.cpp @@ -27,10 +27,6 @@ EggGroupUI::EggGroupUI(EggGroup* eggGroup, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(eggGroup, new EggGroup(*eggGroup)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/FlagWidget.cpp b/pokemodr/FlagWidget.cpp index 70f47a45..0386fe9a 100644 --- a/pokemodr/FlagWidget.cpp +++ b/pokemodr/FlagWidget.cpp @@ -37,6 +37,8 @@ Flag FlagWidget::value() const void FlagWidget::setValue(const Flag& value) { + if (m_value == value) + return; m_value = value; setChecked(m_value.status() == Flag::Ignore); varFlag->setValue(m_value.flag()); diff --git a/pokemodr/FractionWidget.cpp b/pokemodr/FractionWidget.cpp index a418133a..da51da9d 100644 --- a/pokemodr/FractionWidget.cpp +++ b/pokemodr/FractionWidget.cpp @@ -52,9 +52,21 @@ void FractionWidget::setBehavior(const int behavior) void FractionWidget::setValue(const Fraction& value) { + if (m_value == value) + return; m_value = value; varDenominator->setValue(m_value.denominator()); varNumerator->setValue(m_value.numerator()); + if (0 < m_behavior) + { + varNumerator->setMaximum(INT_MAX); + varDenominator->setMaximum(m_value.numerator()); + } + else + { + varNumerator->setMaximum(m_value.denominator()); + varDenominator->setMaximum(INT_MAX); + } emit(valueChanged(m_value)); } diff --git a/pokemodr/ItemTypeUI.cpp b/pokemodr/ItemTypeUI.cpp index f95827ac..8a17f6b6 100644 --- a/pokemodr/ItemTypeUI.cpp +++ b/pokemodr/ItemTypeUI.cpp @@ -27,10 +27,6 @@ ItemTypeUI::ItemTypeUI(ItemType* itemType, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(itemType, new ItemType(*itemType)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/ItemUI.cpp b/pokemodr/ItemUI.cpp index cf99132c..9d3c9ec1 100644 --- a/pokemodr/ItemUI.cpp +++ b/pokemodr/ItemUI.cpp @@ -29,10 +29,6 @@ ItemUI::ItemUI(Item* item, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(item, new Item(*item)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/MapTrainerTeamMemberUI.cpp b/pokemodr/MapTrainerTeamMemberUI.cpp index d08f17e3..65b9e802 100644 --- a/pokemodr/MapTrainerTeamMemberUI.cpp +++ b/pokemodr/MapTrainerTeamMemberUI.cpp @@ -31,10 +31,6 @@ MapTrainerTeamMemberUI::MapTrainerTeamMemberUI(MapTrainerTeamMember* teamMember, setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(teamMember, new MapTrainerTeamMember(*teamMember)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/MapTrainerUI.cpp b/pokemodr/MapTrainerUI.cpp index 1ca6b1cd..30632013 100644 --- a/pokemodr/MapTrainerUI.cpp +++ b/pokemodr/MapTrainerUI.cpp @@ -33,10 +33,6 @@ MapTrainerUI::MapTrainerUI(MapTrainer* trainer, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(trainer, new MapTrainer(*trainer)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/MapUI.cpp b/pokemodr/MapUI.cpp index 749b2bf5..0c32c759 100644 --- a/pokemodr/MapUI.cpp +++ b/pokemodr/MapUI.cpp @@ -41,10 +41,6 @@ MapUI::MapUI(Map* map, QWidget* parent) : QMetaObject::connectSlotsByName(this); setObjects(map, new Map(*map)); m_model = new TilemapModel(this, static_cast<Map*>(modified())->map(), static_cast<const Pokemod*>(original()->pokemod())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/MapWarpUI.cpp b/pokemodr/MapWarpUI.cpp index b12a53a7..72ecdd0c 100644 --- a/pokemodr/MapWarpUI.cpp +++ b/pokemodr/MapWarpUI.cpp @@ -31,10 +31,6 @@ MapWarpUI::MapWarpUI(MapWarp* warp, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(warp, new MapWarp(*warp)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/MapWildListEncounterUI.cpp b/pokemodr/MapWildListEncounterUI.cpp index c3bfe837..7468023e 100644 --- a/pokemodr/MapWildListEncounterUI.cpp +++ b/pokemodr/MapWildListEncounterUI.cpp @@ -29,10 +29,6 @@ MapWildListEncounterUI::MapWildListEncounterUI(MapWildListEncounter* encounter, setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(encounter, new MapWildListEncounter(*encounter)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/MapWildListUI.cpp b/pokemodr/MapWildListUI.cpp index 00f332eb..fc506eb1 100644 --- a/pokemodr/MapWildListUI.cpp +++ b/pokemodr/MapWildListUI.cpp @@ -31,10 +31,6 @@ MapWildListUI::MapWildListUI(MapWildList* wildList, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(wildList, new MapWildList(*wildList)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/MoveUI.cpp b/pokemodr/MoveUI.cpp index ca9d085f..4109cb2d 100644 --- a/pokemodr/MoveUI.cpp +++ b/pokemodr/MoveUI.cpp @@ -29,10 +29,6 @@ MoveUI::MoveUI(Move* move, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(move, new Move(*move)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/NatureUI.cpp b/pokemodr/NatureUI.cpp index f8f49c77..3a71fcbf 100644 --- a/pokemodr/NatureUI.cpp +++ b/pokemodr/NatureUI.cpp @@ -28,10 +28,6 @@ NatureUI::NatureUI(Nature* nature, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(nature, new Nature(*nature)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/ObjectUI.cpp b/pokemodr/ObjectUI.cpp new file mode 100644 index 00000000..29423d8c --- /dev/null +++ b/pokemodr/ObjectUI.cpp @@ -0,0 +1,145 @@ +/* + * 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/>. + */ + +// Header include +#include "ObjectUI.h" + +// Pokemod includes +#include "../pokemod/Object.h" + +// Qt includes +#include <QCloseEvent> +#include <QMetaObject> + +// KDE includes +#include <KMessageBox> + +ObjectUI::ObjectUI(QWidget* parent) : + QWidget(parent), + m_changed(false), + m_object(NULL), + m_object_mod(NULL) +{ + connect(this, SIGNAL(changed(bool)), SLOT(setChanged(bool))); + connect(this, SIGNAL(changed()), SLOT(setChanged())); +} + +ObjectUI::~ObjectUI() +{ + if (m_changed) + { +// if (KMessageBox::questionYesNo(this, "You have unsaved changes, would you like to save them?", QString("Unsaved %1").arg(m_object->className())) == KMessageBox::Yes) +// apply(); +// else +// discard(); + } + delete m_object_mod; +} + +void ObjectUI::closeEvent(QCloseEvent* event) +{ + if (m_changed) + { + switch (KMessageBox::questionYesNoCancel(this, "You have unsaved changes, would you like to save them?", QString("Unsaved %1").arg(m_object->className()))) + { + case KMessageBox::Yes: + event->accept(); + apply(); + break; + case KMessageBox::No: + event->accept(); + discard(); + break; + case KMessageBox::Cancel: + event->ignore(); + break; + } + } +} + +void ObjectUI::reload() +{ + refreshGui(); + setGui(); +} + +bool ObjectUI::isChanged() const +{ + return m_changed; +} + +const Object* ObjectUI::original() const +{ + return m_object; +} + +Object* ObjectUI::original() +{ + return m_object; +} + +const Object* ObjectUI::modified() const +{ + return m_object_mod; +} + +Object* ObjectUI::modified() +{ + return m_object_mod; +} + +void ObjectUI::setChanged(const bool changed) +{ + m_changed = changed; +} + +void ObjectUI::errorMessage(const QString& message) +{ + KMessageBox::error(this, message, "Error"); +} + +void ObjectUI::warningMessage(const QString& message) +{ + KMessageBox::warningContinueCancel(this, message, "Warning"); +} + +void ObjectUI::initGui() +{ +} + +void ObjectUI::refreshGui() +{ +} + +void ObjectUI::setObjects(Object* original, Object* modified) +{ + m_object = original; + m_object_mod = modified; + connect(m_object_mod, SIGNAL(changed()), this, SIGNAL(changed())); + connect(m_object_mod, SIGNAL(error(const QString&)), this, SLOT(setGui())); + connect(m_object_mod, SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(m_object_mod, SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); + connect(m_object_mod, SIGNAL(changed()), this, SLOT(setChanged())); + connect(m_object_mod, SIGNAL(changed()), this, SLOT(setGui())); +} + +void ObjectUI::init() +{ + initGui(); + reload(); + emit(changed(false)); +} diff --git a/pokemodr/ObjectUI.h b/pokemodr/ObjectUI.h index 3a31801b..0c2b8278 100644 --- a/pokemodr/ObjectUI.h +++ b/pokemodr/ObjectUI.h @@ -18,130 +18,48 @@ #ifndef __POKEMODR_OBJECTUI__ #define __POKEMODR_OBJECTUI__ -// Pokemod includes -#include "../pokemod/Object.h" - // Qt includes -#include <QCloseEvent> -#include <QMetaObject> #include <QWidget> -// KDE includes -#include <KMessageBox> - -#define DBL_PREC 7 +// Forward declarations +class QCloseEvent; +class Object; class ObjectUI : public QWidget { Q_OBJECT public: - ObjectUI(QWidget* parent) : - QWidget(parent), - m_changed(false), - m_object(NULL), - m_object_mod(NULL) - { - connect(this, SIGNAL(changed(bool)), SLOT(setChanged(bool))); - } - virtual ~ObjectUI() - { - if (m_changed) - { -// if (KMessageBox::questionYesNo(this, "You have unsaved changes, would you like to save them?", QString("Unsaved %1").arg(m_object->className())) == KMessageBox::Yes) -// apply(); -// else -// discard(); - } - delete m_object_mod; - } + ObjectUI(QWidget* parent); + virtual ~ObjectUI(); - void closeEvent(QCloseEvent* event) - { - if (m_changed) - { - switch (KMessageBox::questionYesNoCancel(this, "You have unsaved changes, would you like to save them?", QString("Unsaved %1").arg(m_object->className()))) - { - case KMessageBox::Yes: - event->accept(); - apply(); - break; - case KMessageBox::No: - event->accept(); - discard(); - break; - case KMessageBox::Cancel: - event->ignore(); - break; - } - } - } - void reload() - { - refreshGui(); - setGui(); - } + void closeEvent(QCloseEvent* event); + void reload(); - bool isChanged() const - { - return m_changed; - } + bool isChanged() const; - const Object* original() const - { - return m_object; - } - Object* original() - { - return m_object; - } - const Object* modified() const - { - return m_object_mod; - } - Object* modified() - { - return m_object_mod; - } + const Object* original() const; + Object* original(); + const Object* modified() const; + Object* modified(); signals: + void changed(); void changed(bool); public slots: virtual void apply() = 0; virtual void discard() = 0; protected slots: - void setChanged(const bool changed = true) - { - m_changed = changed; - } - void errorMessage(const QString& message) - { - KMessageBox::error(this, message, "Error"); - } - void warningMessage(const QString& message) - { - KMessageBox::warningContinueCancel(this, message, "Warning"); - } + void setChanged(const bool changed = true); + void errorMessage(const QString& message); + void warningMessage(const QString& message); - void initGui() - { - } - void refreshGui() - { - } + virtual void initGui(); + virtual void refreshGui(); virtual void setGui() = 0; protected: - void setObjects(Object* original, Object* modified) - { - m_object = original; - m_object_mod = modified; - } + void setObjects(Object* original, Object* modified); - void init() - { - initGui(); - reload(); - emit(changed(false)); - } + void init(); private: bool m_changed; diff --git a/pokemodr/PointWidget.cpp b/pokemodr/PointWidget.cpp index 8fa61091..c342f8ad 100644 --- a/pokemodr/PointWidget.cpp +++ b/pokemodr/PointWidget.cpp @@ -33,6 +33,8 @@ Point PointWidget::value() const void PointWidget::setValue(const Point& value) { + if (m_value == value) + return; m_value = value; varX->setValue(m_value.x()); varY->setValue(m_value.y()); diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp index 4df5f88d..e96e08b7 100644 --- a/pokemodr/PokeModrUI.cpp +++ b/pokemodr/PokeModrUI.cpp @@ -120,6 +120,7 @@ PokeModrUI::PokeModrUI(KConfigGroup config, KConfigGroup history, QWidget* paren // } setAutoSaveSettings("MainWindow", true); treePokemod->setModel(new PokemodTreeModel(QStringList(), treePokemod)); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(update())); } PokeModrUI::~PokeModrUI() @@ -128,6 +129,11 @@ PokeModrUI::~PokeModrUI() // on_actionQuit_triggered(); } +void PokeModrUI::update() +{ + treePokemod->update(treePokemod->currentIndex()); +} + void PokeModrUI::closeEvent(QCloseEvent* event) { quit(); @@ -217,7 +223,6 @@ void PokeModrUI::saveAsPokemod() void PokeModrUI::closePokeMod() { - // TODO: Close the Pokemod with the current editor open // if (formPanel->widget()) // { diff --git a/pokemodr/PokeModrUI.h b/pokemodr/PokeModrUI.h index 36118d84..2a715b21 100644 --- a/pokemodr/PokeModrUI.h +++ b/pokemodr/PokeModrUI.h @@ -41,7 +41,9 @@ class PokeModrUI : public KMainWindow, private Ui::formPokeModr public: PokeModrUI(KConfigGroup config, KConfigGroup history, QWidget* parent = 0); ~PokeModrUI(); - public slots: + protected slots: + void update(); + void closeEvent(QCloseEvent* event); void setChangedTitle(const bool changed); diff --git a/pokemodr/PokemodTreeModel.cpp b/pokemodr/PokemodTreeModel.cpp index e41ec0d8..2844f73f 100644 --- a/pokemodr/PokemodTreeModel.cpp +++ b/pokemodr/PokemodTreeModel.cpp @@ -22,6 +22,7 @@ #include "models/RootModel.h" // Qt includes +#include <QDomDocument> #include <QMimeData> PokemodTreeModel::PokemodTreeModel(const QStringList& pokemods, QObject* parent) : diff --git a/pokemodr/PokemodUI.cpp b/pokemodr/PokemodUI.cpp index f04ee87e..5977ea52 100644 --- a/pokemodr/PokemodUI.cpp +++ b/pokemodr/PokemodUI.cpp @@ -35,10 +35,6 @@ PokemodUI::PokemodUI(Pokemod* pokemod, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(pokemod, new Pokemod(*pokemod)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } @@ -64,7 +60,7 @@ void PokemodUI::refreshGui() types << static_cast<Pokemod*>(original())->item(i)->name(); // TODO: set the typechart corrently // for (int j = 0; j < static_cast<Pokemod*>(original())->typeCount(); ++j) -// static_cast<TypechartWidgetItem*>(varTypechart->item(i, j))->setData(Qt::EditRole, QVariant::fromValue((*typeChart)(i, j))); +// varTypechart->item(i, j)->setData(Qt::EditRole, QVariant::fromValue(typeChart->at(i, j))); } varTypechart->setVerticalHeaderLabels(types); varTypechart->setHorizontalHeaderLabels(types); diff --git a/pokemodr/RulesUI.cpp b/pokemodr/RulesUI.cpp index e7648f14..9a489570 100644 --- a/pokemodr/RulesUI.cpp +++ b/pokemodr/RulesUI.cpp @@ -27,10 +27,6 @@ RulesUI::RulesUI(Rules* rules, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(rules, new Rules(*rules)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } @@ -52,10 +48,7 @@ void RulesUI::setGui() boxAllowAbilities->setChecked(static_cast<Rules*>(modified())->abilityAllowed() ? Qt::Checked : Qt::Unchecked); boxAllowNatures->setChecked(static_cast<Rules*>(modified())->natureAllowed() ? Qt::Checked : Qt::Unchecked); varBoxes->setValue(static_cast<Rules*>(modified())->numBoxes()); - if (static_cast<Rules*>(modified())->numBoxes()) - varBoxSize->setEnabled(true); - else - varBoxSize->setEnabled(false); + varBoxSize->setEnabled(0 < static_cast<Rules*>(modified())->numBoxes()); varBoxSize->setValue(static_cast<Rules*>(modified())->boxSize()); varMaxParty->setValue(static_cast<Rules*>(modified())->maxParty()); varMaxFight->setMaximum(static_cast<Rules*>(modified())->maxParty()); @@ -73,6 +66,7 @@ void RulesUI::setGui() varNumSteps->setValue(static_cast<Rules*>(modified())->happySteps()); boxEffortValues->setChecked(static_cast<Rules*>(modified())->effortValuesAllowed() ? Qt::Checked : Qt::Unchecked); varMaxEV->setValue(static_cast<Rules*>(modified())->maxTotalEV()); + varMaxEVPerStat->setEnabled(0 < static_cast<Rules*>(modified())->maxTotalEV()); varMaxEVPerStat->setMaximum(static_cast<Rules*>(modified())->maxTotalEV()); varMaxEVPerStat->setValue(static_cast<Rules*>(modified())->maxEVPerStat()); varPokerus->setValue(static_cast<Rules*>(modified())->pokerusChance()); diff --git a/pokemodr/SoundUI.cpp b/pokemodr/SoundUI.cpp index 299861ab..717c4b95 100644 --- a/pokemodr/SoundUI.cpp +++ b/pokemodr/SoundUI.cpp @@ -38,10 +38,6 @@ SoundUI::SoundUI(Sound* sound, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(sound, new Sound(*sound)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } @@ -53,7 +49,7 @@ SoundUI::~SoundUI() void SoundUI::initGui() { seeker->setMediaObject(m_media); - connect(m_media, SIGNAL(finished()), buttonStop, SLOT(clicked())); + connect(m_media, SIGNAL(finished()), buttonStop, SIGNAL(clicked())); buttonPlayPause->setIcon(KIcon("media-playback-play")); buttonStop->setIcon(KIcon("media-playback-stop")); buttonBrowse->setIcon(KIcon("document-open")); diff --git a/pokemodr/SpeciesAbilityUI.cpp b/pokemodr/SpeciesAbilityUI.cpp index 93d28634..e7158469 100644 --- a/pokemodr/SpeciesAbilityUI.cpp +++ b/pokemodr/SpeciesAbilityUI.cpp @@ -29,10 +29,6 @@ SpeciesAbilityUI::SpeciesAbilityUI(SpeciesAbility* ability, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(ability, new SpeciesAbility(*ability)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/SpeciesEvolutionUI.cpp b/pokemodr/SpeciesEvolutionUI.cpp index b6313b38..f920da41 100644 --- a/pokemodr/SpeciesEvolutionUI.cpp +++ b/pokemodr/SpeciesEvolutionUI.cpp @@ -32,10 +32,6 @@ SpeciesEvolutionUI::SpeciesEvolutionUI(SpeciesEvolution* evolution, QWidget* par setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(evolution, new SpeciesEvolution(*evolution)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/SpeciesItemUI.cpp b/pokemodr/SpeciesItemUI.cpp index b3d412ed..713eb0e9 100644 --- a/pokemodr/SpeciesItemUI.cpp +++ b/pokemodr/SpeciesItemUI.cpp @@ -29,10 +29,6 @@ SpeciesItemUI::SpeciesItemUI(SpeciesItem* item, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(item, new SpeciesItem(*item)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/SpeciesMoveUI.cpp b/pokemodr/SpeciesMoveUI.cpp index 0f402c15..f694478e 100644 --- a/pokemodr/SpeciesMoveUI.cpp +++ b/pokemodr/SpeciesMoveUI.cpp @@ -29,10 +29,6 @@ SpeciesMoveUI::SpeciesMoveUI(SpeciesMove* move, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(move, new SpeciesMove(*move)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/SpeciesUI.cpp b/pokemodr/SpeciesUI.cpp index a75506c2..461a16ef 100644 --- a/pokemodr/SpeciesUI.cpp +++ b/pokemodr/SpeciesUI.cpp @@ -33,10 +33,6 @@ SpeciesUI::SpeciesUI(Species* species, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(species, new Species(*species)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/StoreUI.cpp b/pokemodr/StoreUI.cpp index 16428ea1..56c0a6b6 100644 --- a/pokemodr/StoreUI.cpp +++ b/pokemodr/StoreUI.cpp @@ -29,10 +29,6 @@ StoreUI::StoreUI(Store* store, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(store, new Store(*store)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/TODO b/pokemodr/TODO index adaf0254..3223fbdc 100644 --- a/pokemodr/TODO +++ b/pokemodr/TODO @@ -3,8 +3,6 @@ Dialog (with command dialogs) ItemEffect MoveEffect -Set better permissions on slots - Set sub class stuff by passing it on to subclasses via setData TilemapModel is (probably) wrong diff --git a/pokemodr/TileUI.cpp b/pokemodr/TileUI.cpp index 9f5bd0bb..e9e1d96f 100644 --- a/pokemodr/TileUI.cpp +++ b/pokemodr/TileUI.cpp @@ -31,10 +31,6 @@ TileUI::TileUI(Tile* tile, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(tile, new Tile(*tile)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/TimeUI.cpp b/pokemodr/TimeUI.cpp index d2e9e6b1..9d7ae0b6 100644 --- a/pokemodr/TimeUI.cpp +++ b/pokemodr/TimeUI.cpp @@ -27,10 +27,6 @@ TimeUI::TimeUI(Time* time, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(time, new Time(*time)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/TrainerUI.cpp b/pokemodr/TrainerUI.cpp index 03d39792..d7b8830e 100644 --- a/pokemodr/TrainerUI.cpp +++ b/pokemodr/TrainerUI.cpp @@ -30,10 +30,6 @@ TrainerUI::TrainerUI(Trainer * trainer, QWidget * parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(trainer, new Trainer(*trainer)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/TypeUI.cpp b/pokemodr/TypeUI.cpp index 893c9709..b7f51043 100644 --- a/pokemodr/TypeUI.cpp +++ b/pokemodr/TypeUI.cpp @@ -27,10 +27,6 @@ TypeUI::TypeUI(Type* type, QWidget* parent) : setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(type, new Type(*type)); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); - connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/models/BaseModel.cpp b/pokemodr/models/BaseModel.cpp index 761ff3e7..4754ddec 100644 --- a/pokemodr/models/BaseModel.cpp +++ b/pokemodr/models/BaseModel.cpp @@ -18,6 +18,9 @@ // Header include #include "BaseModel.h" +// Pokemod includes +#include "../../pokemod/Object.h" + BaseModel::BaseModel(BaseModel* parent, Object* object, const QString& name) : m_object(object), m_name(name), @@ -50,6 +53,11 @@ Qt::DropActions BaseObjectModel::supportedDropActions() return Qt::CopyAction | Qt::MoveAction; } +QString BaseObjectModel::type() const +{ + return m_object->className(); +} + ObjectModel::ObjectModel(BaseModel* parent, Object* object) : BaseObjectModel(parent, object) { diff --git a/pokemodr/models/BaseModel.h b/pokemodr/models/BaseModel.h index f690e5d0..ab52d327 100644 --- a/pokemodr/models/BaseModel.h +++ b/pokemodr/models/BaseModel.h @@ -23,8 +23,8 @@ #include <QString> #include <QVariant> -// Pokemod includes -#include "../../pokemod/Object.h" +// Forward declarations +class Object; class BaseModel { @@ -93,10 +93,7 @@ class BaseObjectModel : public BaseModel Qt::DropActions supportedDragActions(); Qt::DropActions supportedDropActions(); - QString type() const - { - return m_object->className(); - } + QString type() const; }; class ObjectModel : public BaseObjectModel diff --git a/pokemodr/pokemodr.pro b/pokemodr/pokemodr.pro index 48c86082..83de43cb 100644 --- a/pokemodr/pokemodr.pro +++ b/pokemodr/pokemodr.pro @@ -84,6 +84,7 @@ SOURCES += AbilityUI.cpp \ MapWildListEncounterUI.cpp \ MoveUI.cpp \ NatureUI.cpp \ + ObjectUI.cpp \ PointWidget.cpp \ PokemodTree.cpp \ PokemodTreeModel.cpp \ |
