diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2009-01-17 13:44:43 -0500 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2009-01-17 13:44:43 -0500 |
| commit | 304bda728609ad4b2b0af80fbe6fa0f334d00945 (patch) | |
| tree | 19f2f213785ae916960d1f4969a39387e72513f6 | |
| parent | 4f8a14ce9e04cd371e4787debbaeb14eb8ec381d (diff) | |
Removed unneeded files
28 files changed, 0 insertions, 2009 deletions
diff --git a/sigmod/SpeciesAbility.cpp b/sigmod/SpeciesAbility.cpp deleted file mode 100644 index 3941a43a..00000000 --- a/sigmod/SpeciesAbility.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2007-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 "SpeciesAbility.h" - -// Sigmod includes -#include "Macros.h" -#include "Sigmod.h" -#include "Species.h" - -Sigmod::SpeciesAbility::SpeciesAbility(const SpeciesAbility& ability) : - Object(ability.parent(), ability.id()) -{ - *this = ability; -} - -Sigmod::SpeciesAbility::SpeciesAbility(const Species* parent, const int id) : - Object(parent, id), - m_ability(INT_MAX), - m_weight(1) -{ -} - -Sigmod::SpeciesAbility::SpeciesAbility(const SpeciesAbility& ability, const Species* parent, const int id) : - Object(parent, id) -{ - *this = ability; -} - -Sigmod::SpeciesAbility::SpeciesAbility(const QDomElement& xml, const Species* parent, const int id) : - Object(parent, id) -{ - LOAD_ID(); - load(xml); -} - -void Sigmod::SpeciesAbility::validate() -{ - TEST_BEGIN(); - TEST(ability); - TEST(weight); - TEST_END(); -} - -void Sigmod::SpeciesAbility::load(const QDomElement& xml) -{ - LOAD_BEGIN(); - LOAD(ability); - LOAD(weight); -} - -QDomElement Sigmod::SpeciesAbility::save() const -{ - SAVE_CREATE(); - SAVE(ability); - SAVE(weight); - return xml; -} - -SETTER(SpeciesAbility, int, Ability, ability) -SETTER(SpeciesAbility, int, Weight, weight) - -GETTER(SpeciesAbility, int, ability) -GETTER(SpeciesAbility, int, weight) - -CHECK_INDEX(SpeciesAbility, int, ability, sigmod(), ability) -CHECK_BOUNDS(SpeciesAbility, int, weight, 1, INT_MAX) - -Sigmod::SpeciesAbility& Sigmod::SpeciesAbility::operator=(const SpeciesAbility& rhs) -{ - if (this == &rhs) - return *this; - COPY(ability); - COPY(weight); - return *this; -} diff --git a/sigmod/SpeciesAbility.h b/sigmod/SpeciesAbility.h deleted file mode 100644 index 92233c9c..00000000 --- a/sigmod/SpeciesAbility.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2007-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/>. - */ - -#ifndef SIGMOD_SPECIESABILITY -#define SIGMOD_SPECIESABILITY - -// Sigmod includes -#include "Object.h" - -namespace Sigmod -{ -// Forward declarations -class Species; - -class SIGMOD_EXPORT SpeciesAbility : public Object -{ - Q_OBJECT - - public: - SpeciesAbility(const SpeciesAbility& ability); - SpeciesAbility(const Species* parent, const int id); - SpeciesAbility(const SpeciesAbility& ability, const Species* parent, const int id); - SpeciesAbility(const QDomElement& xml, const Species* parent, const int id = -1); - - void validate(); - - void load(const QDomElement& xml); - QDomElement save() const; - - void setAbility(const int ability); - void setWeight(const int weight); - - int ability() const; - int weight() const; - - bool abilityCheck(const int ability) const; - bool weightCheck(const int weight) const; - - SpeciesAbility& operator=(const SpeciesAbility& rhs); - private: - int m_ability; - int m_weight; -}; -} - -#endif diff --git a/sigmod/SpeciesItem.cpp b/sigmod/SpeciesItem.cpp deleted file mode 100644 index fcd12a8a..00000000 --- a/sigmod/SpeciesItem.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2007-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 "SpeciesItem.h" - -// Sigmod includes -#include "Macros.h" -#include "Sigmod.h" -#include "Species.h" - -Sigmod::SpeciesItem::SpeciesItem(const SpeciesItem& item) : - Object(item.parent(), item.id()) -{ - *this = item; -} - -Sigmod::SpeciesItem::SpeciesItem(const Species* parent, const int id) : - Object(parent, id), - m_item(INT_MAX), - m_weight(1) -{ -} - -Sigmod::SpeciesItem::SpeciesItem(const SpeciesItem& item, const Species* parent, const int id) : - Object(parent, id) -{ - *this = item; -} - -Sigmod::SpeciesItem::SpeciesItem(const QDomElement& xml, const Species* parent, const int id) : - Object(parent, id) -{ - LOAD_ID(); - load(xml); -} - -void Sigmod::SpeciesItem::validate() -{ - TEST_BEGIN(); - TEST(item); - TEST(weight); - TEST_END(); -} - -void Sigmod::SpeciesItem::load(const QDomElement& xml) -{ - LOAD_BEGIN(); - LOAD(item); - LOAD(weight); -} - -QDomElement Sigmod::SpeciesItem::save() const -{ - SAVE_CREATE(); - SAVE(item); - SAVE(weight); - return xml; -} - -SETTER(SpeciesItem, int, Item, item) -SETTER(SpeciesItem, int, Weight, weight) - -GETTER(SpeciesItem, int, item) -GETTER(SpeciesItem, int, weight) - -CHECK_INDEX(SpeciesItem, int, item, sigmod(), item) -CHECK_BOUNDS(SpeciesItem, int, weight, 1, INT_MAX) - -Sigmod::SpeciesItem& Sigmod::SpeciesItem::operator=(const SpeciesItem& rhs) -{ - if (this == &rhs) - return *this; - COPY(item); - COPY(weight); - return *this; -} diff --git a/sigmod/SpeciesItem.h b/sigmod/SpeciesItem.h deleted file mode 100644 index b3ce640c..00000000 --- a/sigmod/SpeciesItem.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2007-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/>. - */ - -#ifndef SIGMOD_SPECIESITEM -#define SIGMOD_SPECIESITEM - -// Sigmod includes -#include "Object.h" - -namespace Sigmod -{ -// Forward declarations -class Species; - -class SIGMOD_EXPORT SpeciesItem : public Object -{ - Q_OBJECT - - public: - SpeciesItem(const SpeciesItem& item); - SpeciesItem(const Species* parent, const int id); - SpeciesItem(const SpeciesItem& item, const Species* parent, const int id); - SpeciesItem(const QDomElement& xml, const Species* parent, const int id = -1); - - void validate(); - - void load(const QDomElement& xml); - QDomElement save() const; - - void setItem(const int item); - void setWeight(const int weight); - - int item() const; - int weight() const; - - bool itemCheck(const int item) const; - bool weightCheck(const int weight) const; - - SpeciesItem& operator=(const SpeciesItem& rhs); - private: - int m_item; - int m_weight; -}; -} - -#endif diff --git a/sigmod/test/TestSpeciesAbility.cpp b/sigmod/test/TestSpeciesAbility.cpp deleted file mode 100644 index ef7ff121..00000000 --- a/sigmod/test/TestSpeciesAbility.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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 "TestSpeciesAbility.h" - -// Sigmod includes -#include "../Sigmod.h" -#include "../Species.h" -#include "../SpeciesAbility.h" - -// Qt includes -#include <QtCore/QFile> -#include <QtTest/QTest> - -void TestSpeciesAbility::initTestCase() -{ - TestSigmodObject::initTestCase(); - - Sigmod::Species* species = m_sigmod->newSpecies(); - - m_speciesAbility1 = species->newAbility(); - m_speciesAbility2 = species->newAbility(); - m_speciesAbility3 = species->newAbility(); -} - -void TestSpeciesAbility::cleanupTestCase() -{ - TestSigmodObject::cleanupTestCase(); -} - -void TestSpeciesAbility::init() -{ - TestSigmodObject::init(); - - makeConnections(m_speciesAbility1); - makeConnections(m_speciesAbility2); - makeConnections(m_speciesAbility3); -} - -void TestSpeciesAbility::cleanup() -{ - closeConnections(m_speciesAbility1); - closeConnections(m_speciesAbility2); - closeConnections(m_speciesAbility3); - - TestSigmodObject::cleanup(); -} - -void TestSpeciesAbility::validation() -{ - m_speciesAbility1->validate(); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 1); - - m_sigmod->newAbility(); - - m_speciesAbility1->setAbility(0); - m_speciesAbility1->validate(); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 1); -} - -void TestSpeciesAbility::saving() -{ - QDomDocument xml = Sigmod::Object::xml(m_speciesAbility1); - QFile file("speciesAbility.xml"); - - QVERIFY(file.open(QIODevice::WriteOnly)); - file.write(xml.toByteArray()); - file.close(); -} - -void TestSpeciesAbility::loading() -{ - QDomDocument xml; - QFile file("speciesAbility.xml"); - - m_sigmod->newAbility(); - - m_speciesAbility1->setAbility(1); - m_speciesAbility1->setWeight(10); - - QVERIFY(file.open(QIODevice::ReadOnly)); - QVERIFY(xml.setContent(&file)); - m_speciesAbility1->load(xml.firstChildElement("SpeciesAbility")); - - QCOMPARE(m_speciesAbility1->ability(), 0); - QCOMPARE(m_speciesAbility1->weight(), 1); -} - -void TestSpeciesAbility::setAbility() -{ - m_speciesAbility2->setAbility(2); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 1); - - m_sigmod->newAbility(); - - m_speciesAbility2->setAbility(2); - m_speciesAbility2->setAbility(2); - - QCOMPARE(m_speciesAbility2->ability(), 2); - - QCOMPARE(m_changedCount, 1); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 1); -} - -void TestSpeciesAbility::setWeight() -{ - m_speciesAbility2->setWeight(0); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 1); - - m_speciesAbility2->setWeight(5); - m_speciesAbility2->setWeight(5); - - QCOMPARE(m_speciesAbility2->weight(), 5); - - QCOMPARE(m_changedCount, 1); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 1); -} - -void TestSpeciesAbility::assignment() -{ - *m_speciesAbility3 = *m_speciesAbility2; - - QCOMPARE(m_speciesAbility3->ability(), 2); - QCOMPARE(m_speciesAbility3->weight(), 5); -} - -QTEST_APPLESS_MAIN(TestSpeciesAbility) diff --git a/sigmod/test/TestSpeciesAbility.h b/sigmod/test/TestSpeciesAbility.h deleted file mode 100644 index b54c876f..00000000 --- a/sigmod/test/TestSpeciesAbility.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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/>. - */ - -#ifndef SIGMOD_TESTSPECIESABILITY -#define SIGMOD_TESTSPECIESABILITY - -// Test includes -#include "TestSigmodObject.h" - -// Sigmod includes -#include "../SpeciesAbility.h" - -class TestSpeciesAbility : public TestSigmodObject -{ - Q_OBJECT - - private slots: - void initTestCase(); - void cleanupTestCase(); - - void init(); - void cleanup(); - - void validation(); - void saving(); - void loading(); - - void setAbility(); - void setWeight(); - - void assignment(); - private: - Sigmod::SpeciesAbility* m_speciesAbility1; - Sigmod::SpeciesAbility* m_speciesAbility2; - Sigmod::SpeciesAbility* m_speciesAbility3; -}; - -#endif diff --git a/sigmod/test/TestSpeciesItem.cpp b/sigmod/test/TestSpeciesItem.cpp deleted file mode 100644 index 80b019b3..00000000 --- a/sigmod/test/TestSpeciesItem.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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 "TestSpeciesItem.h" - -// Sigmod includes -#include "../Sigmod.h" -#include "../Species.h" -#include "../SpeciesItem.h" - -// Qt includes -#include <QtCore/QFile> -#include <QtTest/QTest> - -void TestSpeciesItem::initTestCase() -{ - TestSigmodObject::initTestCase(); - - Sigmod::Species* species = m_sigmod->newSpecies(); - - m_speciesItem1 = species->newItem(); - m_speciesItem2 = species->newItem(); - m_speciesItem3 = species->newItem(); -} - -void TestSpeciesItem::cleanupTestCase() -{ - TestSigmodObject::cleanupTestCase(); -} - -void TestSpeciesItem::init() -{ - TestSigmodObject::init(); - - makeConnections(m_speciesItem1); - makeConnections(m_speciesItem2); - makeConnections(m_speciesItem3); -} - -void TestSpeciesItem::cleanup() -{ - closeConnections(m_speciesItem1); - closeConnections(m_speciesItem2); - closeConnections(m_speciesItem3); - - TestSigmodObject::cleanup(); -} - -void TestSpeciesItem::validation() -{ - m_speciesItem1->validate(); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 1); - - m_sigmod->newItem(); - - m_speciesItem1->setItem(0); - m_speciesItem1->validate(); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 1); -} - -void TestSpeciesItem::saving() -{ - QDomDocument xml = Sigmod::Object::xml(m_speciesItem1); - QFile file("speciesItem.xml"); - - QVERIFY(file.open(QIODevice::WriteOnly)); - file.write(xml.toByteArray()); - file.close(); -} - -void TestSpeciesItem::loading() -{ - QDomDocument xml; - QFile file("speciesItem.xml"); - - m_sigmod->newItem(); - - m_speciesItem1->setItem(1); - m_speciesItem1->setWeight(10); - - QVERIFY(file.open(QIODevice::ReadOnly)); - QVERIFY(xml.setContent(&file)); - m_speciesItem1->load(xml.firstChildElement("SpeciesItem")); - - QCOMPARE(m_speciesItem1->item(), 0); - QCOMPARE(m_speciesItem1->weight(), 1); -} - -void TestSpeciesItem::setItem() -{ - m_speciesItem2->setItem(2); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 1); - - m_sigmod->newItem(); - - m_speciesItem2->setItem(2); - m_speciesItem2->setItem(2); - - QCOMPARE(m_speciesItem2->item(), 2); - - QCOMPARE(m_changedCount, 1); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 1); -} - -void TestSpeciesItem::setWeight() -{ - m_speciesItem2->setWeight(0); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 1); - - m_speciesItem2->setWeight(5); - m_speciesItem2->setWeight(5); - - QCOMPARE(m_speciesItem2->weight(), 5); - - QCOMPARE(m_changedCount, 1); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 1); -} - -void TestSpeciesItem::assignment() -{ - *m_speciesItem3 = *m_speciesItem2; - - QCOMPARE(m_speciesItem3->item(), 2); - QCOMPARE(m_speciesItem3->weight(), 5); -} - -QTEST_APPLESS_MAIN(TestSpeciesItem) diff --git a/sigmod/test/TestSpeciesItem.h b/sigmod/test/TestSpeciesItem.h deleted file mode 100644 index 7a097bf2..00000000 --- a/sigmod/test/TestSpeciesItem.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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/>. - */ - -#ifndef SIGMOD_TESTSPECIESITEM -#define SIGMOD_TESTSPECIESITEM - -// Test includes -#include "TestSigmodObject.h" - -// Sigmod includes -#include "../SpeciesItem.h" - -class TestSpeciesItem : public TestSigmodObject -{ - Q_OBJECT - - private slots: - void initTestCase(); - void cleanupTestCase(); - - void init(); - void cleanup(); - - void validation(); - void saving(); - void loading(); - - void setItem(); - void setWeight(); - - void assignment(); - private: - Sigmod::SpeciesItem* m_speciesItem1; - Sigmod::SpeciesItem* m_speciesItem2; - Sigmod::SpeciesItem* m_speciesItem3; -}; - -#endif diff --git a/sigmodr/SpeciesAbilityUI.cpp b/sigmodr/SpeciesAbilityUI.cpp deleted file mode 100644 index 20334daa..00000000 --- a/sigmodr/SpeciesAbilityUI.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 "SpeciesAbilityUI.h" - -// Sigmod includes -#include "../sigmod/Ability.h" -#include "../sigmod/Sigmod.h" -#include "../sigmod/SpeciesAbility.h" - -Sigmodr::SpeciesAbilityUI::SpeciesAbilityUI(Sigmod::SpeciesAbility* ability, QWidget* parent) : - ObjectUI(parent) -{ - setupUi(this); - setObjects(ability, new Sigmod::SpeciesAbility(*ability)); -} - -Sigmodr::SpeciesAbilityUI::~SpeciesAbilityUI() -{ -} - -void Sigmodr::SpeciesAbilityUI::refreshGui() -{ - const bool blocked = varAbility->blockSignals(true); - varAbility->clear(); - for (int i = 0; i < sigmod()->abilityCount(); ++i) - { - const Sigmod::Ability* ability = sigmod()->ability(i); - varAbility->addItem(ability->name(), ability->id()); - } - varAbility->blockSignals(blocked); -} - -void Sigmodr::SpeciesAbilityUI::setGui() -{ - varAbility->setCurrentIndex(varAbility->findData(qobject_cast<Sigmod::SpeciesAbility*>(modified())->ability())); - varWeight->setValue(qobject_cast<Sigmod::SpeciesAbility*>(modified())->weight()); -} - -void Sigmodr::SpeciesAbilityUI::apply() -{ - *qobject_cast<Sigmod::SpeciesAbility*>(original()) = *qobject_cast<Sigmod::SpeciesAbility*>(modified()); - emit(changed(false)); -} - -void Sigmodr::SpeciesAbilityUI::discard() -{ - *qobject_cast<Sigmod::SpeciesAbility*>(modified()) = *qobject_cast<Sigmod::SpeciesAbility*>(original()); - setGui(); - emit(changed(false)); -} - -void Sigmodr::SpeciesAbilityUI::on_varAbility_activated(const int ability) -{ - qobject_cast<Sigmod::SpeciesAbility*>(modified())->setAbility(varAbility->itemData(ability).toInt()); -} - -void Sigmodr::SpeciesAbilityUI::on_varWeight_valueChanged(const int weight) -{ - qobject_cast<Sigmod::SpeciesAbility*>(modified())->setWeight(weight); -} diff --git a/sigmodr/SpeciesAbilityUI.h b/sigmodr/SpeciesAbilityUI.h deleted file mode 100644 index c3d10bb0..00000000 --- a/sigmodr/SpeciesAbilityUI.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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/>. - */ - -#ifndef SIGMODR_SPECIESABILITYUI -#define SIGMODR_SPECIESABILITYUI - -// Sigmodr includes -#include "ObjectUI.h" - -// Form include -#include "ui_speciesability.h" - -// Forward declarations -namespace Sigmod -{ -class SpeciesAbility; -} - -namespace Sigmodr -{ -class SpeciesAbilityUI : public ObjectUI, private Ui::formSpeciesAbility -{ - Q_OBJECT - - public: - SpeciesAbilityUI(Sigmod::SpeciesAbility* ability, QWidget* parent); - ~SpeciesAbilityUI(); - public slots: - void apply(); - void discard(); - protected slots: - void on_varAbility_activated(const int ability); - void on_varWeight_valueChanged(const int weight); - private slots: - void refreshGui(); - void setGui(); -}; -} - -#endif diff --git a/sigmodr/SpeciesItemUI.cpp b/sigmodr/SpeciesItemUI.cpp deleted file mode 100644 index 8070d3e8..00000000 --- a/sigmodr/SpeciesItemUI.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 "SpeciesItemUI.h" - -// Sigmod includes -#include "../sigmod/Item.h" -#include "../sigmod/Sigmod.h" -#include "../sigmod/SpeciesItem.h" - -Sigmodr::SpeciesItemUI::SpeciesItemUI(Sigmod::SpeciesItem* item, QWidget* parent) : - ObjectUI(parent) -{ - setupUi(this); - setObjects(item, new Sigmod::SpeciesItem(*item)); -} - -Sigmodr::SpeciesItemUI::~SpeciesItemUI() -{ -} - -void Sigmodr::SpeciesItemUI::refreshGui() -{ - const bool blocked = varItem->blockSignals(true); - varItem->clear(); - for (int i = 0; i < sigmod()->itemCount(); ++i) - { - const Sigmod::Item* item = sigmod()->item(i); - varItem->addItem(item->name(), item->id()); - } - varItem->blockSignals(blocked); -} - -void Sigmodr::SpeciesItemUI::setGui() -{ - varItem->setCurrentIndex(varItem->findData(qobject_cast<Sigmod::SpeciesItem*>(modified())->item())); - varWeight->setValue(qobject_cast<Sigmod::SpeciesItem*>(modified())->weight()); -} - -void Sigmodr::SpeciesItemUI::apply() -{ - *qobject_cast<Sigmod::SpeciesItem*>(original()) = *qobject_cast<Sigmod::SpeciesItem*>(modified()); - emit(changed(false)); -} - -void Sigmodr::SpeciesItemUI::discard() -{ - *qobject_cast<Sigmod::SpeciesItem*>(modified()) = *qobject_cast<Sigmod::SpeciesItem*>(original()); - setGui(); - emit(changed(false)); -} - -void Sigmodr::SpeciesItemUI::on_varItem_activated(const int item) -{ - qobject_cast<Sigmod::SpeciesItem*>(modified())->setItem(varItem->itemData(item).toInt()); -} - -void Sigmodr::SpeciesItemUI::on_varWeight_valueChanged(const int weight) -{ - qobject_cast<Sigmod::SpeciesItem*>(modified())->setWeight(weight); -} diff --git a/sigmodr/SpeciesItemUI.h b/sigmodr/SpeciesItemUI.h deleted file mode 100644 index e14f0ccc..00000000 --- a/sigmodr/SpeciesItemUI.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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/>. - */ - -#ifndef SIGMODR_SPECIESITEMUI -#define SIGMODR_SPECIESITEMUI - -// Sigmodr includes -#include "ObjectUI.h" - -// Form include -#include "ui_speciesitem.h" - -// Forward declarations -namespace Sigmod -{ -class SpeciesItem; -} - -namespace Sigmodr -{ -class SpeciesItemUI : public ObjectUI, private Ui::formSpeciesItem -{ - Q_OBJECT - - public: - SpeciesItemUI(Sigmod::SpeciesItem* item, QWidget* parent); - ~SpeciesItemUI(); - public slots: - void apply(); - void discard(); - protected slots: - void on_varItem_activated(const int item); - void on_varWeight_valueChanged(const int weight); - private slots: - void refreshGui(); - void setGui(); -}; -} - -#endif diff --git a/sigmodr/gui/speciesability.ui b/sigmodr/gui/speciesability.ui deleted file mode 100644 index 4832aa1a..00000000 --- a/sigmodr/gui/speciesability.ui +++ /dev/null @@ -1,80 +0,0 @@ -<ui version="4.0" > - <class>formSpeciesAbility</class> - <widget class="QWidget" name="formSpeciesAbility" > - <layout class="QVBoxLayout" > - <item> - <widget class="QGroupBox" name="boxItem" > - <property name="title" > - <string>Ability</string> - </property> - <property name="toolTip" > - <string>Ability available</string> - </property> - <property name="statusTip" > - <string>Ability available</string> - </property> - <property name="whatsThis" > - <string>Ability available</string> - </property> - <layout class="QHBoxLayout" > - <item> - <widget class="KComboBox" name="varAbility" /> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="boxWeight" > - <property name="title" > - <string>Weight</string> - </property> - <property name="toolTip" > - <string>Weighting for the ability</string> - </property> - <property name="statusTip" > - <string>Weighting for the ability</string> - </property> - <property name="whatsThis" > - <string>Weighting for the ability</string> - </property> - <layout class="QHBoxLayout" > - <item> - <widget class="KIntNumInput" name="varWeight" > - <property name="minimum" > - <number>1</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" > - <size> - <width>0</width> - <height>1</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>KComboBox</class> - <extends>QComboBox</extends> - <header location="global" >KComboBox</header> - </customwidget> - <customwidget> - <class>KIntNumInput</class> - <extends>QWidget</extends> - <header location="global" >KIntNumInput</header> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> diff --git a/sigmodr/gui/speciesitem.ui b/sigmodr/gui/speciesitem.ui deleted file mode 100644 index 16572769..00000000 --- a/sigmodr/gui/speciesitem.ui +++ /dev/null @@ -1,80 +0,0 @@ -<ui version="4.0" > - <class>formSpeciesItem</class> - <widget class="QWidget" name="formSpeciesItem" > - <layout class="QVBoxLayout" > - <item> - <widget class="QGroupBox" name="boxItem" > - <property name="title" > - <string>Item</string> - </property> - <property name="toolTip" > - <string>Item that can be held when found in the wild</string> - </property> - <property name="statusTip" > - <string>Item that can be held when found in the wild</string> - </property> - <property name="whatsThis" > - <string>Item that can be held when found in the wild</string> - </property> - <layout class="QHBoxLayout" > - <item> - <widget class="KComboBox" name="varItem" /> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="boxWeight" > - <property name="title" > - <string>Weight</string> - </property> - <property name="toolTip" > - <string>Weighting for the item</string> - </property> - <property name="statusTip" > - <string>Weighting for the item</string> - </property> - <property name="whatsThis" > - <string>Weighting for the item</string> - </property> - <layout class="QHBoxLayout" > - <item> - <widget class="KIntNumInput" name="varWeight" > - <property name="minimum" > - <number>1</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" > - <size> - <width>0</width> - <height>1</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>KComboBox</class> - <extends>QComboBox</extends> - <header location="global" >KComboBox</header> - </customwidget> - <customwidget> - <class>KIntNumInput</class> - <extends>QWidget</extends> - <header location="global" >KIntNumInput</header> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> diff --git a/sigmodr/models/SpeciesAbilityGroupModel.cpp b/sigmodr/models/SpeciesAbilityGroupModel.cpp deleted file mode 100644 index b3447525..00000000 --- a/sigmodr/models/SpeciesAbilityGroupModel.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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 "SpeciesAbilityGroupModel.h" - -// Model includes -#include "SpeciesAbilityModel.h" - -// Sigmod includes -#include "../../sigmod/Species.h" -#include "../../sigmod/SpeciesAbility.h" - -// KDE includes -#include <KMenu> - -Sigmodr::SpeciesAbilityGroupModel::SpeciesAbilityGroupModel(BaseModel* parent, Sigmod::Species* species) : - GroupModel(parent, species, "Abilities") -{ - for (int i = 0; i < species->abilityCount(); ++i) - addObject(species->ability(i)); -} - -Sigmodr::SpeciesAbilityGroupModel::~SpeciesAbilityGroupModel() -{ -} - -QVariant Sigmodr::SpeciesAbilityGroupModel::data(const int role) const -{ - if (role == Sigmodr::BaseModel::ContextMenuRole) - { - KMenu* menu = new KMenu; - menu->addAction("&Add Ability", this, SLOT(addObject())); - return QVariant::fromValue(menu); - } - return Sigmodr::GroupModel::data(role); -} - -bool Sigmodr::SpeciesAbilityGroupModel::setData(const QVariant& value, int role) -{ - if (role == Sigmodr::BaseModel::XmlRole) - { - QString data = value.toString(); - if (!data.isEmpty()) - { - QDomDocument xml; - if (loadFromData(data, &xml) && (xml.doctype().name() == "SpeciesAbility")) - { - addObject(qobject_cast<Sigmod::Species*>(m_object)->newAbility(xml.documentElement())); - return true; - } - } - } - return false; -} - -QString Sigmodr::SpeciesAbilityGroupModel::types() const -{ - return "SpeciesAbility"; -} - -void Sigmodr::SpeciesAbilityGroupModel::addObject(Sigmod::Object* object) -{ - if (!object) - object = qobject_cast<Sigmod::Species*>(m_object)->newAbility(); - if (object->className() == "SpeciesAbility") - addChild(new SpeciesAbilityModel(this, qobject_cast<Sigmod::SpeciesAbility*>(object))); -} - -void Sigmodr::SpeciesAbilityGroupModel::deleteObject(BaseModel* model) -{ - const int index = find(model); - if (0 <= index) - { - qobject_cast<Sigmod::Species*>(m_object)->deleteAbility(index); - m_objects[index]->deleteLater(); - m_objects.removeAt(index); - childRowChanged(index); - } -} diff --git a/sigmodr/models/SpeciesAbilityGroupModel.h b/sigmodr/models/SpeciesAbilityGroupModel.h deleted file mode 100644 index edd450cd..00000000 --- a/sigmodr/models/SpeciesAbilityGroupModel.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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/>. - */ - -#ifndef SIGMODR_SPECIESABILITYGROUPMODEL -#define SIGMODR_SPECIESABILITYGROUPMODEL - -// Model includes -#include "GroupModel.h" - -// Forward declarations -namespace Sigmod -{ -class Species; -} - -namespace Sigmodr -{ -class SpeciesAbilityGroupModel : public GroupModel -{ - Q_OBJECT - - public: - SpeciesAbilityGroupModel(BaseModel* parent, Sigmod::Species* species); - ~SpeciesAbilityGroupModel(); - - QVariant data(const int role = Qt::DisplayRole) const; - bool setData(const QVariant& value, int role = Qt::EditRole); - - QString types() const; - public slots: - void addObject(Sigmod::Object* object = NULL); - void deleteObject(BaseModel* model); -}; -} - -#endif diff --git a/sigmodr/models/SpeciesAbilityModel.cpp b/sigmodr/models/SpeciesAbilityModel.cpp deleted file mode 100644 index 9e5ee6c2..00000000 --- a/sigmodr/models/SpeciesAbilityModel.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 "SpeciesAbilityModel.h" - -// Model includes -#include "GroupModel.h" - -// Sigmodr includes -#include "../SpeciesAbilityUI.h" - -// Sigmod includes -#include "../../sigmod/Ability.h" -#include "../../sigmod/Sigmod.h" -#include "../../sigmod/Species.h" -#include "../../sigmod/SpeciesAbility.h" - -// KDE includes -#include <KMenu> - -Sigmodr::SpeciesAbilityModel::SpeciesAbilityModel(BaseModel* parent, Sigmod::SpeciesAbility* ability) : - ObjectModel(parent, ability) -{ -} - -Sigmodr::SpeciesAbilityModel::~SpeciesAbilityModel() -{ -} - -QVariant Sigmodr::SpeciesAbilityModel::data(int role) const -{ - if (role == Qt::DisplayRole) - { - const Sigmod::Ability* ability = m_object->sigmod()->abilityById(qobject_cast<Sigmod::SpeciesAbility*>(m_object)->ability()); - if (ability) - return ability->name(); - return ""; - } - else if (role == Sigmodr::BaseModel::XmlRole) - { - QDomDocument xml(m_object->className()); - xml.appendChild(m_object->save()); - return xml.toString(); - } - else if (role == Sigmodr::BaseModel::WidgetRole) - { - QWidget* widget = new SpeciesAbilityUI(qobject_cast<Sigmod::SpeciesAbility*>(m_object), NULL); - return QVariant::fromValue(widget); - } - else if (role == Sigmodr::BaseModel::ContextMenuRole) - { - KMenu* menu = new KMenu; - menu->addAction("&Delete Ability", this, SLOT(deleteSelf())); - return QVariant::fromValue(menu); - } - return Sigmodr::ObjectModel::data(role); -} - -void Sigmodr::SpeciesAbilityModel::deleteSelf() -{ - qobject_cast<GroupModel*>(m_parent)->deleteObject(this); -} diff --git a/sigmodr/models/SpeciesAbilityModel.h b/sigmodr/models/SpeciesAbilityModel.h deleted file mode 100644 index 1588b49f..00000000 --- a/sigmodr/models/SpeciesAbilityModel.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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/>. - */ - -#ifndef SIGMODR_SPECIESABILITYMODEL -#define SIGMODR_SPECIESABILITYMODEL - -// Model includes -#include "ObjectModel.h" - -// Forward declarations -namespace Sigmod -{ -class SpeciesAbility; -} - -namespace Sigmodr -{ - class SpeciesAbilityModel : public ObjectModel -{ - Q_OBJECT - - public: - SpeciesAbilityModel(BaseModel* parent, Sigmod::SpeciesAbility* ability); - ~SpeciesAbilityModel(); - - QVariant data(int role = Qt::DisplayRole) const; - public slots: - void deleteSelf(); -}; -} - -#endif diff --git a/sigmodr/models/SpeciesItemGroupModel.cpp b/sigmodr/models/SpeciesItemGroupModel.cpp deleted file mode 100644 index 8431c6c7..00000000 --- a/sigmodr/models/SpeciesItemGroupModel.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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 "SpeciesItemGroupModel.h" - -// Model includes -#include "SpeciesItemModel.h" - -// Sigmod includes -#include "../../sigmod/Species.h" -#include "../../sigmod/SpeciesItem.h" - -// KDE includes -#include <KMenu> - -Sigmodr::SpeciesItemGroupModel::SpeciesItemGroupModel(BaseModel* parent, Sigmod::Species* species) : - GroupModel(parent, species, "Items") -{ - for (int i = 0; i < species->itemCount(); ++i) - addObject(species->item(i)); -} - -Sigmodr::SpeciesItemGroupModel::~SpeciesItemGroupModel() -{ -} - -QVariant Sigmodr::SpeciesItemGroupModel::data(const int role) const -{ - if (role == Sigmodr::BaseModel::ContextMenuRole) - { - KMenu* menu = new KMenu; - menu->addAction("&Add Item", this, SLOT(addObject())); - return QVariant::fromValue(menu); - } - return Sigmodr::GroupModel::data(role); -} - -bool Sigmodr::SpeciesItemGroupModel::setData(const QVariant& value, int role) -{ - if (role == Sigmodr::BaseModel::XmlRole) - { - QString data = value.toString(); - if (!data.isEmpty()) - { - QDomDocument xml; - if (loadFromData(data, &xml) && (xml.doctype().name() == "SpeceisItem")) - { - addObject(qobject_cast<Sigmod::Species*>(m_object)->newItem(xml.documentElement())); - return true; - } - } - } - return false; -} - -QString Sigmodr::SpeciesItemGroupModel::types() const -{ - return "SpeciesItem"; -} - -void Sigmodr::SpeciesItemGroupModel::addObject(Sigmod::Object* object) -{ - if (!object) - object = qobject_cast<Sigmod::Species*>(m_object)->newItem(); - if (object->className() == "SpeciesItem") - addChild(new SpeciesItemModel(this, qobject_cast<Sigmod::SpeciesItem*>(object))); -} - -void Sigmodr::SpeciesItemGroupModel::deleteObject(BaseModel* model) -{ - const int index = find(model); - if (0 <= index) - { - qobject_cast<Sigmod::Species*>(m_object)->deleteItem(index); - m_objects[index]->deleteLater(); - m_objects.removeAt(index); - childRowChanged(index); - } -} diff --git a/sigmodr/models/SpeciesItemGroupModel.h b/sigmodr/models/SpeciesItemGroupModel.h deleted file mode 100644 index fcb3667a..00000000 --- a/sigmodr/models/SpeciesItemGroupModel.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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/>. - */ - -#ifndef SIGMODR_SPECIESITEMGROUPMODEL -#define SIGMODR_SPECIESITEMGROUPMODEL - -// Model includes -#include "GroupModel.h" - -// Forward declarations -namespace Sigmod -{ -class Species; -} - -namespace Sigmodr -{ -class SpeciesItemGroupModel : public GroupModel -{ - Q_OBJECT - - public: - SpeciesItemGroupModel(BaseModel* parent, Sigmod::Species* species); - ~SpeciesItemGroupModel(); - - QVariant data(const int role = Qt::DisplayRole) const; - bool setData(const QVariant& value, int role = Qt::EditRole); - - QString types() const; - public slots: - void addObject(Sigmod::Object* object = NULL); - void deleteObject(BaseModel* model); -}; -} - -#endif diff --git a/sigmodr/models/SpeciesItemModel.cpp b/sigmodr/models/SpeciesItemModel.cpp deleted file mode 100644 index 28ec11df..00000000 --- a/sigmodr/models/SpeciesItemModel.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 "SpeciesItemModel.h" - -// Model includes -#include "GroupModel.h" - -// Sigmodr includes -#include "../SpeciesItemUI.h" - -// Sigmod includes -#include "../../sigmod/Item.h" -#include "../../sigmod/Sigmod.h" -#include "../../sigmod/Species.h" -#include "../../sigmod/SpeciesItem.h" - -// KDE includes -#include <KMenu> - -Sigmodr::SpeciesItemModel::SpeciesItemModel(BaseModel* parent, Sigmod::SpeciesItem* item) : - ObjectModel(parent, item) -{ -} - -Sigmodr::SpeciesItemModel::~SpeciesItemModel() -{ -} - -QVariant Sigmodr::SpeciesItemModel::data(int role) const -{ - if (role == Qt::DisplayRole) - { - const Sigmod::Item* item = m_object->sigmod()->itemById(qobject_cast<Sigmod::SpeciesItem*>(m_object)->item()); - if (item) - return item->name(); - return ""; - } - else if (role == Sigmodr::BaseModel::XmlRole) - { - QDomDocument xml(m_object->className()); - xml.appendChild(m_object->save()); - return xml.toString(); - } - else if (role == Sigmodr::BaseModel::WidgetRole) - { - QWidget* widget = new SpeciesItemUI(qobject_cast<Sigmod::SpeciesItem*>(m_object), NULL); - return QVariant::fromValue(widget); - } - else if (role == Sigmodr::BaseModel::ContextMenuRole) - { - KMenu* menu = new KMenu; - menu->addAction("&Delete Item", this, SLOT(deleteSelf())); - return QVariant::fromValue(menu); - } - return Sigmodr::ObjectModel::data(role); -} - -void Sigmodr::SpeciesItemModel::deleteSelf() -{ - qobject_cast<GroupModel*>(m_parent)->deleteObject(this); -} diff --git a/sigmodr/models/SpeciesItemModel.h b/sigmodr/models/SpeciesItemModel.h deleted file mode 100644 index eebe8b3e..00000000 --- a/sigmodr/models/SpeciesItemModel.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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/>. - */ - -#ifndef SIGMODR_SPECIESITEMMODEL -#define SIGMODR_SPECIESITEMMODEL - -// Model includes -#include "ObjectModel.h" - -// Forward declarations -namespace Sigmod -{ -class SpeciesItem; -} - -namespace Sigmodr -{ -class SpeciesItemModel : public ObjectModel -{ - Q_OBJECT - - public: - SpeciesItemModel(BaseModel* parent, Sigmod::SpeciesItem* item); - ~SpeciesItemModel(); - - QVariant data(int role = Qt::DisplayRole) const; - public slots: - void deleteSelf(); -}; -} - -#endif diff --git a/sigmodr/models/SpeciesMoveGroupModel.cpp b/sigmodr/models/SpeciesMoveGroupModel.cpp deleted file mode 100644 index e0ec2e3a..00000000 --- a/sigmodr/models/SpeciesMoveGroupModel.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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 "SpeciesMoveGroupModel.h" - -// Model includes -#include "SpeciesMoveModel.h" - -// Sigmod includes -#include "../../sigmod/Species.h" -#include "../../sigmod/SpeciesMove.h" - -// KDE includes -#include <KMenu> - -Sigmodr::SpeciesMoveGroupModel::SpeciesMoveGroupModel(BaseModel* parent, Sigmod::Species* species) : - GroupModel(parent, species, "Moves") -{ - for (int i = 0; i < species->moveCount(); ++i) - addObject(species->move(i)); -} - -Sigmodr::SpeciesMoveGroupModel::~SpeciesMoveGroupModel() -{ -} - -QVariant Sigmodr::SpeciesMoveGroupModel::data(const int role) const -{ - if (role == Sigmodr::BaseModel::ContextMenuRole) - { - KMenu* menu = new KMenu; - menu->addAction("&Add Move", this, SLOT(addObject())); - return QVariant::fromValue(menu); - } - return Sigmodr::GroupModel::data(role); -} - -bool Sigmodr::SpeciesMoveGroupModel::setData(const QVariant& value, int role) -{ - if (role == Sigmodr::BaseModel::XmlRole) - { - QString data = value.toString(); - if (!data.isEmpty()) - { - QDomDocument xml; - if (loadFromData(data, &xml) && (xml.doctype().name() == "SpeciesMove")) - { - addObject(qobject_cast<Sigmod::Species*>(m_object)->newMove(xml.documentElement())); - return true; - } - } - } - return false; -} - -QString Sigmodr::SpeciesMoveGroupModel::types() const -{ - return "SpeciesMove"; -} - -void Sigmodr::SpeciesMoveGroupModel::addObject(Sigmod::Object* object) -{ - if (!object) - object = qobject_cast<Sigmod::Species*>(m_object)->newMove(); - if (object->className() == "SpeciesMove") - addChild(new SpeciesMoveModel(this, qobject_cast<Sigmod::SpeciesMove*>(object))); -} - -void Sigmodr::SpeciesMoveGroupModel::deleteObject(BaseModel* model) -{ - const int index = find(model); - if (0 <= index) - { - qobject_cast<Sigmod::Species*>(m_object)->deleteMove(index); - m_objects[index]->deleteLater(); - m_objects.removeAt(index); - childRowChanged(index); - } -} diff --git a/sigmodr/models/SpeciesMoveGroupModel.h b/sigmodr/models/SpeciesMoveGroupModel.h deleted file mode 100644 index 9b9b1f32..00000000 --- a/sigmodr/models/SpeciesMoveGroupModel.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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/>. - */ - -#ifndef SIGMODR_SPECIESMOVEGROUPMODEL -#define SIGMODR_SPECIESMOVEGROUPMODEL - -// Model includes -#include "GroupModel.h" - -// Forward declarations -namespace Sigmod -{ -class Species; -} - -namespace Sigmodr -{ -class SpeciesMoveGroupModel : public GroupModel -{ - Q_OBJECT - - public: - SpeciesMoveGroupModel(BaseModel* parent, Sigmod::Species* species); - ~SpeciesMoveGroupModel(); - - QVariant data(const int role = Qt::DisplayRole) const; - bool setData(const QVariant& value, int role = Qt::EditRole); - - QString types() const; - public slots: - void addObject(Sigmod::Object* object = NULL); - void deleteObject(BaseModel* model); -}; -} - -#endif diff --git a/sigscript/SpeciesAbilityWrapper.cpp b/sigscript/SpeciesAbilityWrapper.cpp deleted file mode 100644 index 62306f6c..00000000 --- a/sigscript/SpeciesAbilityWrapper.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 "SpeciesAbilityWrapper.h" - -// Sigscript includes -#include "SigmodWrapper.h" -#include "SpeciesWrapper.h" - -Sigscript::SpeciesAbilityWrapper* Sigscript::SpeciesAbilityWrapper::create(const Sigmod::SpeciesAbility* ability, SpeciesWrapper* parent) -{ - Signature sig = Signature(parent, Subsignature(ability->className(), ability->id())); - if (!m_instances.contains(sig)) - m_instances[sig] = new SpeciesAbilityWrapper(ability, parent); - return qobject_cast<SpeciesAbilityWrapper*>(m_instances[sig]); -} - -Sigscript::SpeciesAbilityWrapper::SpeciesAbilityWrapper(const Sigmod::SpeciesAbility* ability, SpeciesWrapper* parent) : - ObjectWrapper(ability, parent), - m_ability(ability) -{ -} - -Sigscript::AbilityWrapper* Sigscript::SpeciesAbilityWrapper::ability() -{ - return sigmod()->ability(m_ability->ability()); -} - -int Sigscript::SpeciesAbilityWrapper::weight() const -{ - return m_ability->weight(); -} diff --git a/sigscript/SpeciesAbilityWrapper.h b/sigscript/SpeciesAbilityWrapper.h deleted file mode 100644 index 4e3b2cad..00000000 --- a/sigscript/SpeciesAbilityWrapper.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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/>. - */ - -#ifndef SIGSCRIPT_SPECIESABILITYWRAPPER -#define SIGSCRIPT_SPECIESABILITYWRAPPER - -// Sigscript includes -#include "ObjectWrapper.h" - -// Sigmod includes -#include "../sigmod/SpeciesAbility.h" - -namespace Sigscript -{ -// Forward declarations -class AbilityWrapper; -class SpeciesWrapper; - -class SIGSCRIPT_EXPORT SpeciesAbilityWrapper : public ObjectWrapper -{ - Q_OBJECT - - public: - static SpeciesAbilityWrapper* create(const Sigmod::SpeciesAbility* ability, SpeciesWrapper* parent); - - Q_SCRIPTABLE AbilityWrapper* ability(); - Q_SCRIPTABLE int weight() const; - private: - SpeciesAbilityWrapper(const Sigmod::SpeciesAbility* ability, SpeciesWrapper* parent); - SpeciesAbilityWrapper& operator=(const SpeciesAbilityWrapper& rhs); - - const Sigmod::SpeciesAbility* m_ability; -}; -} -Q_DECLARE_METATYPE(Sigscript::SpeciesAbilityWrapper*) - -#endif diff --git a/sigscript/SpeciesItemWrapper.cpp b/sigscript/SpeciesItemWrapper.cpp deleted file mode 100644 index a734c978..00000000 --- a/sigscript/SpeciesItemWrapper.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 "SpeciesItemWrapper.h" - -// Sigscript includes -#include "SigmodWrapper.h" -#include "SpeciesWrapper.h" - -Sigscript::SpeciesItemWrapper* Sigscript::SpeciesItemWrapper::create(const Sigmod::SpeciesItem* item, SpeciesWrapper* parent) -{ - Signature sig = Signature(parent, Subsignature(item->className(), item->id())); - if (!m_instances.contains(sig)) - m_instances[sig] = new SpeciesItemWrapper(item, parent); - return qobject_cast<SpeciesItemWrapper*>(m_instances[sig]); -} - -Sigscript::SpeciesItemWrapper::SpeciesItemWrapper(const Sigmod::SpeciesItem* item, SpeciesWrapper* parent) : - ObjectWrapper(item, parent), - m_item(item) -{ -} - -Sigscript::ItemWrapper* Sigscript::SpeciesItemWrapper::item() -{ - return sigmod()->item(m_item->item()); -} - -int Sigscript::SpeciesItemWrapper::weight() const -{ - ALLOW_OVERRIDE_SO(item, int, weight); - return m_item->weight(); -} diff --git a/sigscript/SpeciesItemWrapper.h b/sigscript/SpeciesItemWrapper.h deleted file mode 100644 index 6412175c..00000000 --- a/sigscript/SpeciesItemWrapper.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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/>. - */ - -#ifndef SIGSCRIPT_SPECIESITEMWRAPPER -#define SIGSCRIPT_SPECIESITEMWRAPPER - -// Sigscript includes -#include "ObjectWrapper.h" - -// Sigmod includes -#include "../sigmod/SpeciesItem.h" - -namespace Sigscript -{ -// Forward declarations -class ItemWrapper; -class SpeciesWrapper; - -class SIGSCRIPT_EXPORT SpeciesItemWrapper : public ObjectWrapper -{ - Q_OBJECT - - public: - static SpeciesItemWrapper* create(const Sigmod::SpeciesItem* item, SpeciesWrapper* parent); - - Q_SCRIPTABLE ItemWrapper* item(); - Q_SCRIPTABLE int weight() const; - private: - SpeciesItemWrapper(const Sigmod::SpeciesItem* item, SpeciesWrapper* parent); - SpeciesItemWrapper& operator=(const SpeciesItemWrapper& rhs); - - const Sigmod::SpeciesItem* m_item; -}; -} -Q_DECLARE_METATYPE(Sigscript::SpeciesItemWrapper*) - -#endif |
