diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-06-19 02:06:10 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-06-19 02:06:10 +0000 |
| commit | 6dd3d36c4552565756dcedab2ddd44e90a553252 (patch) | |
| tree | 85fce9e5b97bd3a5f9f60b8d427ca8155d76609f | |
| parent | 5d7d71ddb75f636f94028da346f43565ffb798df (diff) | |
| download | sigen-6dd3d36c4552565756dcedab2ddd44e90a553252.tar.gz sigen-6dd3d36c4552565756dcedab2ddd44e90a553252.tar.xz sigen-6dd3d36c4552565756dcedab2ddd44e90a553252.zip | |
[FIX] Validation works in Pokémodr
[FIX] Macros moved to their own file
[FIX] Macros for subclasses added
[FIX] Key shortcuts added to context menu items
[FIX] Rules had a redundant field
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@212 6ecfd1a5-f3ed-3746-8530-beee90d26b22
103 files changed, 680 insertions, 603 deletions
@@ -1,4 +1,15 @@ ----------------- +Rev: 212 +Date: 18 June 2008 +User: MathStuf +----------------- +[FIX] Validation works in Pokémodr +[FIX] Macros moved to their own file +[FIX] Macros for subclasses added +[FIX] Key shortcuts added to context menu items +[FIX] Rules had a redundant field + +----------------- Rev: 211 Date: 17 June 2008 User: MathStuf diff --git a/pokemod/Ability.cpp b/pokemod/Ability.cpp index 0e586182..939e1576 100644 --- a/pokemod/Ability.cpp +++ b/pokemod/Ability.cpp @@ -19,6 +19,7 @@ #include "Ability.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" Pokemod::Ability::Ability(const Ability& ability) : @@ -53,8 +54,10 @@ Pokemod::Ability::~Ability() void Pokemod::Ability::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); + TEST_END(); } void Pokemod::Ability::load(const QDomElement& xml, int id) diff --git a/pokemod/Author.cpp b/pokemod/Author.cpp index c4adc89d..dac4ef33 100644 --- a/pokemod/Author.cpp +++ b/pokemod/Author.cpp @@ -19,6 +19,7 @@ #include "Author.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" // Qt includes @@ -52,6 +53,7 @@ Pokemod::Author::Author(const QDomElement& xml, const Pokemod* parent, const int void Pokemod::Author::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); if (m_email.isEmpty()) @@ -60,6 +62,7 @@ void Pokemod::Author::validate() emit(error("Email is invalid")); if (m_role.isEmpty()) emit(error("Role is empty")); + TEST_END(); } void Pokemod::Author::load(const QDomElement& xml, int id) diff --git a/pokemod/Badge.cpp b/pokemod/Badge.cpp index 5a580f00..b69d02e7 100644 --- a/pokemod/Badge.cpp +++ b/pokemod/Badge.cpp @@ -17,12 +17,12 @@ // Header include #include "Badge.h" + +// Pokemod includes +#include "Macros.h" #include "Pokemod.h" #include "Rules.h" -// Qt includes -#include <QBuffer> - Pokemod::Badge::Badge(const Badge& badge) : Object("Badge", badge.parent(), badge.id()) { @@ -54,12 +54,14 @@ Pokemod::Badge::Badge(const QDomElement& xml, const Pokemod* parent, const int i void Pokemod::Badge::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); TEST(setFace, face); TEST(setBadge, badge); TEST(setObey, obey); TEST_ARRAY(setStat, stat, (static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? ST_End_GSC : ST_End_RBY)); + TEST_END(); } void Pokemod::Badge::load(const QDomElement& xml, int id) diff --git a/pokemod/CoinList.cpp b/pokemod/CoinList.cpp index 336b2126..04ae14b9 100644 --- a/pokemod/CoinList.cpp +++ b/pokemod/CoinList.cpp @@ -20,6 +20,7 @@ // Pokemod includes #include "CoinListObject.h" +#include "Macros.h" #include "Pokemod.h" // Qt includes @@ -57,6 +58,7 @@ Pokemod::CoinList::~CoinList() void Pokemod::CoinList::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); if (!objectCount()) @@ -64,25 +66,37 @@ void Pokemod::CoinList::validate() QSet<int> idChecker; QSet<int> itemChecker; QSet<int> speciesChecker; - foreach (CoinListObject* object, m_objects) - { - object->validate(); - if (idChecker.contains(object->id())) - emit(error(subclass("object", object->id()))); - idChecker.insert(object->id()); + TEST_SUB_BEGIN(CoinListObject, objects); + TEST_SUB("object", id); if (object->type() == CoinListObject::Item) { - if (itemChecker.contains(object->object())) - emit(error(subclass("object item", object->id()))); - itemChecker.insert(object->object()); + TEST_SUB_RAW(item, "object item", object); } else if (object->type() == CoinListObject::Species) { - if (speciesChecker.contains(object->object())) - emit(error(subclass("object species", object->id()))); - speciesChecker.insert(object->object()); + TEST_SUB_RAW(species, "object species", object); } - } + TEST_SUB_END(); +// foreach (CoinListObject* object, m_objects) +// { +// object->validate(); +// if (idChecker.contains(object->id())) +// emit(error(subclass("object", object->id()))); +// idChecker.insert(object->id()); +// if (object->type() == CoinListObject::Item) +// { +// if (itemChecker.contains(object->object())) +// emit(error(subclass("object item", object->id()))); +// itemChecker.insert(object->object()); +// } +// else if (object->type() == CoinListObject::Species) +// { +// if (speciesChecker.contains(object->object())) +// emit(error(subclass("object species", object->id()))); +// speciesChecker.insert(object->object()); +// } +// } + TEST_END(); } void Pokemod::CoinList::load(const QDomElement& xml, int id) diff --git a/pokemod/CoinListObject.cpp b/pokemod/CoinListObject.cpp index 38aafdda..36cfaa92 100644 --- a/pokemod/CoinListObject.cpp +++ b/pokemod/CoinListObject.cpp @@ -20,6 +20,7 @@ // Pokemod includes #include "CoinList.h" +#include "Macros.h" #include "Pokemod.h" const QStringList Pokemod::CoinListObject::TypeStr = QStringList() << "Item" << "Team Member"; @@ -53,9 +54,11 @@ Pokemod::CoinListObject::CoinListObject(const QDomElement& xml, const CoinList* void Pokemod::CoinListObject::validate() { + TEST_BEGIN(); TEST(setType, type); TEST(setObject, object); TEST(setAmount, amount); + TEST_END(); } void Pokemod::CoinListObject::load(const QDomElement& xml, int id) diff --git a/pokemod/EggGroup.cpp b/pokemod/EggGroup.cpp index abebe36c..eee5b353 100644 --- a/pokemod/EggGroup.cpp +++ b/pokemod/EggGroup.cpp @@ -19,6 +19,7 @@ #include "EggGroup.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" Pokemod::EggGroup::EggGroup(const EggGroup& eggGroup) : @@ -47,8 +48,10 @@ Pokemod::EggGroup::EggGroup(const QDomElement& xml, const Pokemod* parent, const void Pokemod::EggGroup::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); + TEST_END(); } void Pokemod::EggGroup::load(const QDomElement& xml, int id) diff --git a/pokemod/GlobalScript.cpp b/pokemod/GlobalScript.cpp index 63383826..47418b4c 100644 --- a/pokemod/GlobalScript.cpp +++ b/pokemod/GlobalScript.cpp @@ -19,6 +19,7 @@ #include "GlobalScript.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" Pokemod::GlobalScript::GlobalScript(const GlobalScript& globalScript) : @@ -52,8 +53,10 @@ Pokemod::GlobalScript::~GlobalScript() void Pokemod::GlobalScript::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); + TEST_END(); } void Pokemod::GlobalScript::load(const QDomElement& xml, int id) diff --git a/pokemod/Item.cpp b/pokemod/Item.cpp index 21d3fc4c..67c28fc2 100644 --- a/pokemod/Item.cpp +++ b/pokemod/Item.cpp @@ -19,6 +19,7 @@ #include "Item.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" #include "Rules.h" @@ -60,10 +61,12 @@ Pokemod::Item::~Item() void Pokemod::Item::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); TEST(setType, type); TEST(setPrice, price); + TEST_END(); } void Pokemod::Item::load(const QDomElement& xml, int id) diff --git a/pokemod/ItemType.cpp b/pokemod/ItemType.cpp index 12a23a98..d01a8901 100644 --- a/pokemod/ItemType.cpp +++ b/pokemod/ItemType.cpp @@ -19,6 +19,7 @@ #include "ItemType.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" QStringList Pokemod::ItemType::CountStr = QStringList() << "Distinct" << "Total"; @@ -52,10 +53,12 @@ Pokemod::ItemType::ItemType(const QDomElement& xml, const Pokemod* parent, const void Pokemod::ItemType::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); TEST(setPlayer, player); TEST(setCount, count); + TEST_END(); } void Pokemod::ItemType::load(const QDomElement& xml, int id) diff --git a/pokemod/Macros.h b/pokemod/Macros.h new file mode 100644 index 00000000..fb9fde21 --- /dev/null +++ b/pokemod/Macros.h @@ -0,0 +1,228 @@ +/* + * 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 __POKEMOD_MACROS__ +#define __POKEMOD_MACROS__ + +// Qt includes +#include <QBuffer> + +#define LOAD_NODE(variable) xml.firstChildElement(variable) +#define LOAD_DATA(node) node.firstChild().toText().data() +#define LOAD_ID() \ + if (id == INT_MAX) \ + id = xml.attribute("id", "2147483647").toInt(); \ + setId(id); \ + clear() +#define LOAD(type, variable) m_##variable = LOAD_##type(LOAD_NODE(#variable)) +#define LOAD_bool(node) ((LOAD_DATA(node) == "true") ? true : false) +#define LOAD_int(node) LOAD_DATA(node).toInt() +#define LOAD_QString LOAD_DATA +#define LOAD_Fraction(node) Fraction(node.attribute("numerator", "1").toInt(), node.attribute("denominator", "1").toInt()) +#define LOAD_Point(node) Point(node.attribute("x", "0").toInt(), node.attribute("y", "0").toInt()) +// FIXME: QPixmap::fromData static member would be nice +#define LOAD_QPixmap(node) QPixmap::fromImage(QImage::fromData(QByteArray::fromBase64(LOAD_DATA(node).toUtf8()))) +#define LOAD_QByteArray(node) QByteArray::fromBase64(LOAD_DATA(node).toUtf8()) +#define LOAD_Rules() m_rules->load(xml.firstChildElement("Rules")) +#define LOAD_Script(node) Script(node.attribute("interpreter", ""), LOAD_DATA(node)) +#define LOAD_ARRAY(type, variable, size) \ + QDomElement xml_##variable = LOAD_NODE(#variable).firstChildElement("element"); \ + while (!xml_##variable.isNull()) \ + { \ + int index = xml_##variable.attribute("index", "-1").toInt(); \ + if (0 <= index) \ + m_##variable[index] = LOAD_##type(xml_##variable); \ + xml_##variable = xml_##variable.nextSiblingElement("element"); \ + } +#define LOAD_LIST(type, variable) \ + QDomElement xml_##variable = LOAD_NODE(#variable); \ + xml_##variable = LOAD_NODE(#variable).firstChildElement("element"); \ + while (!xml_##variable.isNull()) \ + { \ + int element = LOAD_int(xml_##variable); \ + if (!m_##variable.contains(element)) \ + m_##variable.append(element); \ + xml_##variable = xml_##variable.nextSiblingElement("element"); \ + } +#define LOAD_MATRIX(setter, type, variable) \ + QDomElement xml_##variable = LOAD_NODE(#variable); \ + int height_##variable = xml_##variable.attribute("height", "1").toInt(); \ + int width_##variable = xml_##variable.attribute("width", "1").toInt(); \ + m_##variable.resize(width_##variable, height_##variable); \ + xml_##variable = LOAD_NODE(#variable).firstChildElement("element"); \ + while (!xml_##variable.isNull()) \ + { \ + int row = xml_##variable.attribute("row", "-1").toInt(); \ + int column = xml_##variable.attribute("column", "-1").toInt(); \ + if ((0 <= row) && (0 <= column)) \ + setter(row, column, LOAD_##type(xml_##variable)); \ + xml_##variable = xml_##variable.nextSiblingElement("element"); \ + } +#define LOAD_Typechart(setter, type, variable) \ + QDomElement xml_##variable = LOAD_NODE(#variable); \ + int height_##variable = xml_##variable.attribute("height", "1").toInt(); \ + int width_##variable = xml_##variable.attribute("width", "1").toInt(); \ + xml_##variable = LOAD_NODE(#variable).firstChildElement("element"); \ + while (!xml_##variable.isNull()) \ + { \ + int row = xml_##variable.attribute("row", "-1").toInt(); \ + int column = xml_##variable.attribute("column", "-1").toInt(); \ + if ((0 <= row) && (row < height_##variable) && (0 <= column) && (column < width_##variable)) \ + setter(row, column, LOAD_##type(xml_##variable)); \ + xml_##variable = xml_##variable.nextSiblingElement("element"); \ + } +#define LOAD_SUB(setter, class) \ + QDomElement xml_##class = xml.firstChildElement(#class); \ + while (!xml_##class.isNull()) \ + { \ + setter(xml_##class); \ + xml_##class = xml_##class.nextSiblingElement(#class); \ + } + +#define SAVE_CREATE() \ + QDomElement xml = QDomDocument().createElement(className()); \ + xml.setAttribute("id", id()) +#define SAVE_VALUE(element, value) element.appendChild(QDomDocument().createTextNode(value)) +#define SAVE_VALUE_SAFE(element, value) element.appendChild(QDomDocument().createCDATASection(value)) +#define SAVE(type, variable) \ + QDomElement xml_##variable = QDomDocument().createElement(#variable); \ + SAVE_##type(variable, variable()); \ + xml.appendChild(xml_##variable) +#define SAVE_bool(variable, value) SAVE_VALUE(xml_##variable, value ? "true" : "false") +#define SAVE_int(variable, value) SAVE_VALUE(xml_##variable, QString::number(value)) +#define SAVE_QString(variable, value) SAVE_VALUE(xml_##variable, value) +#define SAVE_Fraction(variable, value) \ + Fraction frac_##variable = value; \ + xml_##variable.setAttribute("numerator", frac_##variable.numerator()); \ + xml_##variable.setAttribute("denominator", frac_##variable.denominator()) +#define SAVE_Point(variable, value) \ + Point point_##variable = value; \ + xml_##variable.setAttribute("x", point_##variable.x()); \ + xml_##variable.setAttribute("y", point_##variable.y()) +#define SAVE_QPixmap(variable, value) \ + QByteArray bytes_##variable; \ + QBuffer* buffer_##variable = new QBuffer(&bytes_##variable); \ + buffer_##variable->open(QIODevice::WriteOnly); \ + value.save(buffer_##variable, "PNG"); \ + SAVE_VALUE(xml_##variable, bytes_##variable.toBase64()); \ + delete buffer_##variable +#define SAVE_QByteArray(variable, value) SAVE_VALUE(xml_##variable, value.toBase64()) +#define SAVE_Rules(variable) xml.appendChild(m_##variable->save()) +#define SAVE_Script(variable, value) \ + Script script_##variable = value; \ + xml_##variable.setAttribute("interpreter", script_##variable.interpreter()); \ + SAVE_VALUE_SAFE(xml_##variable, script_##variable.script()) +#define SAVE_ARRAY(type, variable, size) \ + QDomElement xml_array_##variable = QDomDocument().createElement(#variable); \ + for (int i = 0; i < size; ++i) \ + { \ + QDomElement xml_##variable = QDomDocument().createElement("element"); \ + xml_##variable.setAttribute("index", QString::number(i)); \ + SAVE_##type(variable, variable(i)); \ + xml_array_##variable.appendChild(xml_##variable); \ + } \ + xml.appendChild(xml_array_##variable) +#define SAVE_LIST(type, variable) \ + QDomElement xml_list_##variable = QDomDocument().createElement(#variable); \ + xml_list_##variable.setAttribute("size", m_##variable.size()); \ + for (int i = 0; i < m_##variable.size(); ++i) \ + { \ + QDomElement xml_##variable = QDomDocument().createElement("element"); \ + SAVE_##type(variable, m_##variable[i]); \ + xml_list_##variable.appendChild(xml_##variable); \ + } \ + xml.appendChild(xml_list_##variable) +#define SAVE_MATRIX(type, variable) \ + QDomElement xml_matrix_##variable = QDomDocument().createElement(#variable); \ + xml_matrix_##variable.setAttribute("height", m_##variable.height()); \ + xml_matrix_##variable.setAttribute("width", m_##variable.width()); \ + for (int i = 0; i < m_##variable.height(); ++i) \ + { \ + for (int j = 0; j < m_##variable.width(); ++j) \ + { \ + QDomElement xml_##variable = QDomDocument().createElement("element"); \ + xml_##variable.setAttribute("row", QString::number(i)); \ + xml_##variable.setAttribute("column", QString::number(j)); \ + SAVE_##type(variable, variable(i, j)); \ + xml_matrix_##variable.appendChild(xml_##variable); \ + } \ + } \ + xml.appendChild(xml_matrix_##variable) +#define SAVE_SUB(class, variable) \ + foreach (class* sub, m_##variable) \ + xml.appendChild(sub->save()) + +#define COPY(variable) m_##variable = rhs.m_##variable +#define COPY_Rules(variable) *m_##variable = *rhs.m_##variable +#define COPY_ARRAY(variable, size) \ + for (int i = 0; i < size; ++i) \ + COPY(variable[i]) +#define COPY_SUB(class, variable) \ + foreach (class* subclass, rhs.m_##variable) \ + m_##variable.append(new class(*subclass, this, subclass->id())) + +#define TEST_BEGIN() \ + connect(this, SIGNAL(warning(const QString&)), SIGNAL(valWarning(const QString&))); \ + connect(this, SIGNAL(error(const QString&)), SIGNAL(valError(const QString&))); \ + emit(valMessage(QString("++%1 (%2)").arg(className()).arg(id()))) +#define TEST_END() \ + emit(valMessage(QString("--%1 (%2)").arg(className()).arg(id()))); \ + disconnect(this, SIGNAL(warning(const QString&)), this, SIGNAL(valWarning(const QString&))); \ + disconnect(this, SIGNAL(error(const QString&)), this, SIGNAL(valError(const QString&))) +#define TEST(setter, variable) setter(m_##variable) +#define TEST_ARRAY(setter, variable, size) \ + for (int i = 0; i < size; ++i) \ + setter(i, variable(i)) +#define TEST_LIST(setter, variable) \ + foreach (int variable, m_##variable) \ + setter(variable, true) +#define TEST_MATRIX(setter, variable) \ + for (int i = 0; i < m_##variable.height(); ++i) \ + { \ + for (int j = 0; j < m_##variable.width(); ++j) \ + setter(i, j, variable(i, j)); \ + } +#define TEST_CHILD(object) \ + connect(object, SIGNAL(valMessage(const QString&)), this, SIGNAL(valMessage(const QString&))); \ + connect(object, SIGNAL(valWarning(const QString&)), this, SIGNAL(valWarning(const QString&))); \ + connect(object, SIGNAL(valError(const QString&)), this, SIGNAL(valError(const QString&))); \ + object->validate(); \ + disconnect(object, SIGNAL(valMessage(const QString&)), this, SIGNAL(valMessage(const QString&))); \ + disconnect(object, SIGNAL(valWarning(const QString&)), this, SIGNAL(valWarning(const QString&))); \ + disconnect(object, SIGNAL(valError(const QString&)), this, SIGNAL(valError(const QString&))) +#define TEST_SUB_BEGIN(type, variable) \ + foreach (type* object, m_##variable) \ + { \ + TEST_CHILD(object) +#define TEST_SUB(name, value) TEST_SUB_RAW(value, name, value) +#define TEST_SUB_RAW(checking, name, value) \ + if (checking##Checker.contains(object->value())) \ + emit(error(subclass(name, object->id()))); \ + checking##Checker.insert(object->value()) +#define TEST_SUB_END() } + +#define CHECK(variable) CHECK_ARRAY(variable, variable) +#define CHECK_ARRAY(variable, value) \ + if (m_##variable == value) \ + return; \ + else \ + { \ + m_##variable = value; \ + emit(changed()); \ + } + +#endif diff --git a/pokemod/Map.cpp b/pokemod/Map.cpp index 419d75e3..11a69fe7 100644 --- a/pokemod/Map.cpp +++ b/pokemod/Map.cpp @@ -19,6 +19,7 @@ #include "Map.h" // Pokemod includes +#include "Macros.h" #include "MapEffect.h" #include "MapTrainer.h" #include "MapWarp.h" @@ -63,6 +64,7 @@ Pokemod::Map::~Map() void Pokemod::Map::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); TEST(setFlyWarp, flyWarp); @@ -72,54 +74,33 @@ void Pokemod::Map::validate() QSet<QString> nameChecker; if (!effectCount()) emit(warning("There are no effects")); - foreach (MapEffect* effect, m_effects) - { - effect->validate(); - if (idChecker.contains(effect->id())) - emit(error(subclass("effect", effect->id()))); - idChecker.insert(effect->id()); - if (nameChecker.contains(effect->name())) - emit(error(subclass("effect", effect->name()))); - nameChecker.insert(effect->name()); - } + TEST_SUB_BEGIN(MapEffect, effects); + TEST_SUB("effect", id); + TEST_SUB("effect", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!trainerCount()) emit(warning("There are no trainers")); - foreach (MapTrainer* trainer, m_trainers) - { - trainer->validate(); - if (idChecker.contains(trainer->id())) - emit(error(subclass("trainer", trainer->id()))); - idChecker.insert(trainer->id()); - if (nameChecker.contains(trainer->name())) - emit(error(subclass("trainer", trainer->name()))); - nameChecker.insert(trainer->name()); - } + TEST_SUB_BEGIN(MapTrainer, trainers); + TEST_SUB("trainer", id); + TEST_SUB("trainer", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!warpCount()) emit(error("There are no warps")); - foreach (MapWarp* warp, m_warps) - { - warp->validate(); - if (idChecker.contains(warp->id())) - emit(error(subclass("warp", warp->id()))); - idChecker.insert(warp->id()); - if (nameChecker.contains(warp->name())) - emit(error(subclass("warp", warp->name()))); - nameChecker.insert(warp->name()); - } + TEST_SUB_BEGIN(MapWarp, warps); + TEST_SUB("warp", id); + TEST_SUB("warp", name); + TEST_SUB_END(); idChecker.clear(); if (!wildListCount()) - emit(error("There are no wild lists")); - foreach (MapWildList* wildList, m_wildLists) - { - wildList->validate(); - if (idChecker.contains(wildList->id())) - emit(error(subclass("effect", wildList->id()))); - idChecker.insert(wildList->id()); - } + emit(warning("There are no wild lists")); + TEST_SUB_BEGIN(MapWildList, wildLists); + TEST_SUB("wild list", id); + TEST_SUB_END(); + TEST_END(); } void Pokemod::Map::load(const QDomElement& xml, int id) diff --git a/pokemod/MapEffect.cpp b/pokemod/MapEffect.cpp index 4f628e54..e3e1d1f5 100644 --- a/pokemod/MapEffect.cpp +++ b/pokemod/MapEffect.cpp @@ -19,12 +19,10 @@ #include "MapEffect.h" // Pokemod includes +#include "Macros.h" #include "Map.h" #include "Pokemod.h" -// Qt includes -#include <QBuffer> - Pokemod::MapEffect::MapEffect(const MapEffect& effect) : Object("MapEffect", effect.parent(), effect.id()) { @@ -55,10 +53,12 @@ Pokemod::MapEffect::MapEffect(const QDomElement& xml, const Map* parent, const i void Pokemod::MapEffect::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); TEST(setCoordinate, coordinate); TEST(setSkin, skin); + TEST_END(); } void Pokemod::MapEffect::load(const QDomElement& xml, int id) diff --git a/pokemod/MapTrainer.cpp b/pokemod/MapTrainer.cpp index d1fead4e..5c5e665d 100644 --- a/pokemod/MapTrainer.cpp +++ b/pokemod/MapTrainer.cpp @@ -19,6 +19,7 @@ #include "MapTrainer.h" // Pokemod includes +#include "Macros.h" #include "Map.h" #include "MapTrainerTeamMember.h" #include "Pokemod.h" @@ -63,6 +64,7 @@ Pokemod::MapTrainer::~MapTrainer() void Pokemod::MapTrainer::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); TEST(setTrainerClass, trainerClass); @@ -72,13 +74,10 @@ void Pokemod::MapTrainer::validate() if (!teamMemberCount()) emit(error("There are no team members")); QSet<int> idChecker; - foreach (MapTrainerTeamMember* teamMember, m_teamMember) - { - teamMember->validate(); - if (idChecker.contains(teamMember->id())) - emit(error(subclass("team member", teamMember->id()))); - idChecker.insert(teamMember->id()); - } + TEST_SUB_BEGIN(MapTrainerTeamMember, teamMembers); + TEST_SUB("team member", id); + TEST_SUB_END(); + TEST_END(); } void Pokemod::MapTrainer::load(const QDomElement& xml, int id) @@ -101,7 +100,7 @@ QDomElement Pokemod::MapTrainer::save() const SAVE(Point, coordinate); SAVE(int, numberFight); SAVE(Script, script); - SAVE_SUB(MapTrainerTeamMember, teamMember); + SAVE_SUB(MapTrainerTeamMember, teamMembers); return xml; } @@ -188,13 +187,13 @@ int Pokemod::MapTrainer::leadTeamMember() const const Pokemod::MapTrainerTeamMember* Pokemod::MapTrainer::teamMember(const int index) const { Q_ASSERT(index < teamMemberCount()); - return m_teamMember.at(index); + return m_teamMembers.at(index); } Pokemod::MapTrainerTeamMember* Pokemod::MapTrainer::teamMember(const int index) { Q_ASSERT(index < teamMemberCount()); - return m_teamMember[index]; + return m_teamMembers[index]; } const Pokemod::MapTrainerTeamMember* Pokemod::MapTrainer::teamMemberById(const int id) const @@ -211,7 +210,7 @@ int Pokemod::MapTrainer::teamMemberIndex(const int id) const { for (int i = 0; i < teamMemberCount(); ++i) { - if (m_teamMember[i]->id() == id) + if (m_teamMembers[i]->id() == id) return i; } return INT_MAX; @@ -219,7 +218,7 @@ int Pokemod::MapTrainer::teamMemberIndex(const int id) const int Pokemod::MapTrainer::teamMemberCount() const { - return m_teamMember.size(); + return m_teamMembers.size(); } Pokemod::MapTrainerTeamMember* Pokemod::MapTrainer::newTeamMember() @@ -239,15 +238,15 @@ Pokemod::MapTrainerTeamMember* Pokemod::MapTrainer::newTeamMember(const MapTrain Pokemod::MapTrainerTeamMember* Pokemod::MapTrainer::newTeamMember(MapTrainerTeamMember* teamMember) { - m_teamMember.append(teamMember); + m_teamMembers.append(teamMember); return teamMember; } void Pokemod::MapTrainer::deleteTeamMember(const int index) { Q_ASSERT(index < teamMemberCount()); - delete m_teamMember[index]; - m_teamMember.removeAt(index); + delete m_teamMembers[index]; + m_teamMembers.removeAt(index); } void Pokemod::MapTrainer::deleteTeamMemberById(const int id) @@ -274,7 +273,7 @@ Pokemod::MapTrainer& Pokemod::MapTrainer::operator=(const MapTrainer& rhs) COPY(numberFight); COPY(script); COPY(leadTeamMember); - COPY_SUB(MapTrainerTeamMember, teamMember); + COPY_SUB(MapTrainerTeamMember, teamMembers); return *this; } diff --git a/pokemod/MapTrainer.h b/pokemod/MapTrainer.h index 7b927c1f..6d3bda87 100644 --- a/pokemod/MapTrainer.h +++ b/pokemod/MapTrainer.h @@ -87,7 +87,7 @@ class MapTrainer : public Object int m_numberFight; Script m_script; int m_leadTeamMember; - QList<MapTrainerTeamMember*> m_teamMember; + QList<MapTrainerTeamMember*> m_teamMembers; }; } diff --git a/pokemod/MapTrainerTeamMember.cpp b/pokemod/MapTrainerTeamMember.cpp index 1085f1b1..921de3c8 100644 --- a/pokemod/MapTrainerTeamMember.cpp +++ b/pokemod/MapTrainerTeamMember.cpp @@ -20,6 +20,7 @@ // Pokemod includes #include "Item.h" +#include "Macros.h" #include "MapTrainer.h" #include "Pokemod.h" #include "Rules.h" @@ -56,6 +57,7 @@ Pokemod::MapTrainerTeamMember::MapTrainerTeamMember(const QDomElement& xml, cons void Pokemod::MapTrainerTeamMember::validate() { + TEST_BEGIN(); TEST(setSpecies, species); TEST(setLevel, level); if (static_cast<const Pokemod*>(pokemod())->rules()->maxAbilities() < m_ability.size()) @@ -70,6 +72,7 @@ void Pokemod::MapTrainerTeamMember::validate() if (static_cast<const Pokemod*>(pokemod())->rules()->maxNatures() < m_nature.size()) emit(error("Too many natures")); TEST_LIST(setNature, nature); + TEST_END(); } void Pokemod::MapTrainerTeamMember::load(const QDomElement& xml, int id) diff --git a/pokemod/MapWarp.cpp b/pokemod/MapWarp.cpp index 3e3677b7..e3f1f090 100644 --- a/pokemod/MapWarp.cpp +++ b/pokemod/MapWarp.cpp @@ -19,6 +19,7 @@ #include "MapWarp.h" // Pokemod includes +#include "Macros.h" #include "Map.h" #include "Pokemod.h" @@ -55,11 +56,13 @@ Pokemod::MapWarp::MapWarp(const QDomElement& xml, const Map* parent, const int i void Pokemod::MapWarp::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); TEST(setType, type); TEST(setToMap, toMap); TEST(setToWarp, toWarp); + TEST_END(); } void Pokemod::MapWarp::load(const QDomElement& xml, int id) diff --git a/pokemod/MapWildList.cpp b/pokemod/MapWildList.cpp index d08c84ce..1a05b1b4 100644 --- a/pokemod/MapWildList.cpp +++ b/pokemod/MapWildList.cpp @@ -19,6 +19,7 @@ #include "MapWildList.h" // Pokemod includes +#include "Macros.h" #include "Map.h" #include "MapWildListEncounter.h" @@ -56,18 +57,16 @@ Pokemod::MapWildList::~MapWildList() void Pokemod::MapWildList::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); if (!encounterCount()) emit(error("There are no encounters")); QSet<int> idChecker; - foreach (MapWildListEncounter* encounter, m_encounters) - { - encounter->validate(); - if (idChecker.contains(encounter->id())) - emit(error(subclass("encounter", encounter->id()))); - idChecker.insert(encounter->id()); - } + TEST_SUB_BEGIN(MapWildListEncounter, encounters); + TEST_SUB("encounter", id); + TEST_SUB_END(); + TEST_END(); } void Pokemod::MapWildList::load(const QDomElement& xml, int id) diff --git a/pokemod/MapWildListEncounter.cpp b/pokemod/MapWildListEncounter.cpp index 50407c47..8af75ef7 100644 --- a/pokemod/MapWildListEncounter.cpp +++ b/pokemod/MapWildListEncounter.cpp @@ -19,6 +19,7 @@ #include "MapWildListEncounter.h" // Pokemod includes +#include "Macros.h" #include "MapWildList.h" #include "Pokemod.h" #include "Rules.h" @@ -52,9 +53,11 @@ Pokemod::MapWildListEncounter::MapWildListEncounter(const QDomElement& xml, cons void Pokemod::MapWildListEncounter::validate() { + TEST_BEGIN(); TEST(setSpecies, species); TEST(setLevel, level); TEST(setWeight, weight); + TEST_END(); } void Pokemod::MapWildListEncounter::load(const QDomElement& xml, int id) diff --git a/pokemod/Move.cpp b/pokemod/Move.cpp index 51ed7a8a..16802dcd 100644 --- a/pokemod/Move.cpp +++ b/pokemod/Move.cpp @@ -19,6 +19,7 @@ #include "Move.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" // Qt includes @@ -64,10 +65,12 @@ Pokemod::Move::~Move() void Pokemod::Move::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); TEST(setType, type); TEST(setPowerPoints, powerPoints); + TEST_END(); } void Pokemod::Move::load(const QDomElement& xml, int id) diff --git a/pokemod/Nature.cpp b/pokemod/Nature.cpp index e36efb61..e3d61452 100644 --- a/pokemod/Nature.cpp +++ b/pokemod/Nature.cpp @@ -19,6 +19,7 @@ #include "Nature.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" #include "Rules.h" @@ -51,9 +52,11 @@ Pokemod::Nature::Nature(const QDomElement& xml, const Pokemod* parent, const int void Pokemod::Nature::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); TEST(setWeight, weight); + TEST_END(); } void Pokemod::Nature::load(const QDomElement& xml, int id) diff --git a/pokemod/Object.cpp b/pokemod/Object.cpp index ffd1d8f7..ba94556c 100644 --- a/pokemod/Object.cpp +++ b/pokemod/Object.cpp @@ -18,6 +18,9 @@ // Header include #include "Object.h" +// Pokemod includes +#include "Macros.h" + Pokemod::Object::Object(const Object& object) : QObject(0), m_id(object.id()), diff --git a/pokemod/Object.h b/pokemod/Object.h index 9fe8694d..e4542a85 100644 --- a/pokemod/Object.h +++ b/pokemod/Object.h @@ -50,6 +50,9 @@ class Object : public QObject return xml; } signals: + void valMessage(const QString& message) const; + void valWarning(const QString& message) const; + void valError(const QString& message) const; void warning(const QString& message) const; void error(const QString& message) const; @@ -81,182 +84,4 @@ inline Object::~Object() } -#define LOAD_NODE(variable) xml.firstChildElement(variable) -#define LOAD_DATA(node) node.firstChild().toText().data() -#define LOAD_ID() \ - if (id == INT_MAX) \ - id = xml.attribute("id", "2147483647").toInt(); \ - setId(id); \ - clear() -#define LOAD(type, variable) m_##variable = LOAD_##type(LOAD_NODE(#variable)) -#define LOAD_bool(node) ((LOAD_DATA(node) == "true") ? true : false) -#define LOAD_int(node) LOAD_DATA(node).toInt() -#define LOAD_QString LOAD_DATA -#define LOAD_Fraction(node) Fraction(node.attribute("numerator", "1").toInt(), node.attribute("denominator", "1").toInt()) -#define LOAD_Point(node) Point(node.attribute("x", "0").toInt(), node.attribute("y", "0").toInt()) -// FIXME: QPixmap::fromData static member would be nice -#define LOAD_QPixmap(node) QPixmap::fromImage(QImage::fromData(QByteArray::fromBase64(LOAD_DATA(node).toUtf8()))) -#define LOAD_QByteArray(node) QByteArray::fromBase64(LOAD_DATA(node).toUtf8()) -#define LOAD_Rules() m_rules->load(xml.firstChildElement("Rules")) -#define LOAD_Script(node) Script(node.attribute("interpreter", ""), LOAD_DATA(node)) -#define LOAD_ARRAY(type, variable, size) \ - QDomElement xml_##variable = LOAD_NODE(#variable).firstChildElement("element"); \ - while (!xml_##variable.isNull()) \ - { \ - int index = xml_##variable.attribute("index", "-1").toInt(); \ - if (0 <= index) \ - m_##variable[index] = LOAD_##type(xml_##variable); \ - xml_##variable = xml_##variable.nextSiblingElement("element"); \ - } -#define LOAD_LIST(type, variable) \ - QDomElement xml_##variable = LOAD_NODE(#variable); \ - xml_##variable = LOAD_NODE(#variable).firstChildElement("element"); \ - while (!xml_##variable.isNull()) \ - { \ - int element = LOAD_int(xml_##variable); \ - if (!m_##variable.contains(element)) \ - m_##variable.append(element); \ - xml_##variable = xml_##variable.nextSiblingElement("element"); \ - } -#define LOAD_MATRIX(setter, type, variable) \ - QDomElement xml_##variable = LOAD_NODE(#variable); \ - int height_##variable = xml_##variable.attribute("height", "1").toInt(); \ - int width_##variable = xml_##variable.attribute("width", "1").toInt(); \ - m_##variable.resize(width_##variable, height_##variable); \ - xml_##variable = LOAD_NODE(#variable).firstChildElement("element"); \ - while (!xml_##variable.isNull()) \ - { \ - int row = xml_##variable.attribute("row", "-1").toInt(); \ - int column = xml_##variable.attribute("column", "-1").toInt(); \ - if ((0 <= row) && (0 <= column)) \ - setter(row, column, LOAD_##type(xml_##variable)); \ - xml_##variable = xml_##variable.nextSiblingElement("element"); \ - } -#define LOAD_Typechart(setter, type, variable) \ - QDomElement xml_##variable = LOAD_NODE(#variable); \ - int height_##variable = xml_##variable.attribute("height", "1").toInt(); \ - int width_##variable = xml_##variable.attribute("width", "1").toInt(); \ - xml_##variable = LOAD_NODE(#variable).firstChildElement("element"); \ - while (!xml_##variable.isNull()) \ - { \ - int row = xml_##variable.attribute("row", "-1").toInt(); \ - int column = xml_##variable.attribute("column", "-1").toInt(); \ - if ((0 <= row) && (row < height_##variable) && (0 <= column) && (column < width_##variable)) \ - setter(row, column, LOAD_##type(xml_##variable)); \ - xml_##variable = xml_##variable.nextSiblingElement("element"); \ - } -#define LOAD_SUB(setter, class) \ - QDomElement xml_##class = xml.firstChildElement(#class); \ - while (!xml_##class.isNull()) \ - { \ - setter(xml_##class); \ - xml_##class = xml_##class.nextSiblingElement(#class); \ - } - -#define SAVE_CREATE() \ - QDomElement xml = QDomDocument().createElement(className()); \ - xml.setAttribute("id", id()) -#define SAVE_VALUE(element, value) element.appendChild(QDomDocument().createTextNode(value)) -#define SAVE_VALUE_SAFE(element, value) element.appendChild(QDomDocument().createCDATASection(value)) -#define SAVE(type, variable) \ - QDomElement xml_##variable = QDomDocument().createElement(#variable); \ - SAVE_##type(variable, variable()); \ - xml.appendChild(xml_##variable) -#define SAVE_bool(variable, value) SAVE_VALUE(xml_##variable, value ? "true" : "false") -#define SAVE_int(variable, value) SAVE_VALUE(xml_##variable, QString::number(value)) -#define SAVE_QString(variable, value) SAVE_VALUE(xml_##variable, value) -#define SAVE_Fraction(variable, value) \ - Fraction frac_##variable = value; \ - xml_##variable.setAttribute("numerator", frac_##variable.numerator()); \ - xml_##variable.setAttribute("denominator", frac_##variable.denominator()) -#define SAVE_Point(variable, value) \ - Point point_##variable = value; \ - xml_##variable.setAttribute("x", point_##variable.x()); \ - xml_##variable.setAttribute("y", point_##variable.y()) -#define SAVE_QPixmap(variable, value) \ - QByteArray bytes_##variable; \ - QBuffer* buffer_##variable = new QBuffer(&bytes_##variable); \ - buffer_##variable->open(QIODevice::WriteOnly); \ - value.save(buffer_##variable, "PNG"); \ - SAVE_VALUE(xml_##variable, bytes_##variable.toBase64()); \ - delete buffer_##variable -#define SAVE_QByteArray(variable, value) SAVE_VALUE(xml_##variable, value.toBase64()) -#define SAVE_Rules(variable) xml.appendChild(m_##variable->save()) -#define SAVE_Script(variable, value) \ - Script script_##variable = value; \ - xml_##variable.setAttribute("interpreter", script_##variable.interpreter()); \ - SAVE_VALUE_SAFE(xml_##variable, script_##variable.script()) -#define SAVE_ARRAY(type, variable, size) \ - QDomElement xml_array_##variable = QDomDocument().createElement(#variable); \ - for (int i = 0; i < size; ++i) \ - { \ - QDomElement xml_##variable = QDomDocument().createElement("element"); \ - xml_##variable.setAttribute("index", QString::number(i)); \ - SAVE_##type(variable, variable(i)); \ - xml_array_##variable.appendChild(xml_##variable); \ - } \ - xml.appendChild(xml_array_##variable) -#define SAVE_LIST(type, variable) \ - QDomElement xml_list_##variable = QDomDocument().createElement(#variable); \ - xml_list_##variable.setAttribute("size", m_##variable.size()); \ - for (int i = 0; i < m_##variable.size(); ++i) \ - { \ - QDomElement xml_##variable = QDomDocument().createElement("element"); \ - SAVE_##type(variable, m_##variable[i]); \ - xml_list_##variable.appendChild(xml_##variable); \ - } \ - xml.appendChild(xml_list_##variable) -#define SAVE_MATRIX(type, variable) \ - QDomElement xml_matrix_##variable = QDomDocument().createElement(#variable); \ - xml_matrix_##variable.setAttribute("height", m_##variable.height()); \ - xml_matrix_##variable.setAttribute("width", m_##variable.width()); \ - for (int i = 0; i < m_##variable.height(); ++i) \ - { \ - for (int j = 0; j < m_##variable.width(); ++j) \ - { \ - QDomElement xml_##variable = QDomDocument().createElement("element"); \ - xml_##variable.setAttribute("row", QString::number(i)); \ - xml_##variable.setAttribute("column", QString::number(j)); \ - SAVE_##type(variable, variable(i, j)); \ - xml_matrix_##variable.appendChild(xml_##variable); \ - } \ - } \ - xml.appendChild(xml_matrix_##variable) -#define SAVE_SUB(class, variable) \ - foreach (class* sub, m_##variable) \ - xml.appendChild(sub->save()) - -#define COPY(variable) m_##variable = rhs.m_##variable -#define COPY_Rules(variable) *m_##variable = *rhs.m_##variable -#define COPY_ARRAY(variable, size) \ - for (int i = 0; i < size; ++i) \ - COPY(variable[i]) -#define COPY_SUB(class, variable) \ - foreach (class* subclass, rhs.m_##variable) \ - m_##variable.append(new class(*subclass, this, subclass->id())) - -#define TEST(setter, variable) setter(m_##variable) -#define TEST_ARRAY(setter, variable, size) \ - for (int i = 0; i < size; ++i) \ - setter(i, variable(i)) -#define TEST_LIST(setter, variable) \ - foreach (int variable, m_##variable) \ - setter(variable, true) -#define TEST_MATRIX(setter, variable) \ - for (int i = 0; i < m_##variable.height(); ++i) \ - { \ - for (int j = 0; j < m_##variable.width(); ++j) \ - setter(i, j, variable(i, j)); \ - } \ - -#define CHECK(variable) CHECK_ARRAY(variable, variable) -#define CHECK_ARRAY(variable, value) \ - if (m_##variable == value) \ - return; \ - else \ - { \ - m_##variable = value; \ - emit(changed()); \ - } - #endif diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp index e670daf7..c5e2599c 100644 --- a/pokemod/Pokemod.cpp +++ b/pokemod/Pokemod.cpp @@ -27,6 +27,7 @@ #include "GlobalScript.h" #include "Item.h" #include "ItemType.h" +#include "Macros.h" #include "Map.h" #include "Move.h" #include "Nature.h" @@ -86,6 +87,7 @@ Pokemod::Pokemod::~Pokemod() void Pokemod::Pokemod::validate() { + TEST_BEGIN(); if (m_title.isEmpty()) emit(error("Title is empty")); if (m_version.isEmpty()) @@ -94,301 +96,179 @@ void Pokemod::Pokemod::validate() emit(warning("Description is empty")); if (mapIndex(m_startMap) == INT_MAX) emit(error("Invalid starting map")); - else - { - if (mapById(m_startMap)->warpIndex(m_startWarp) == INT_MAX) - emit(error("Invalid starting warp")); - } + else if (mapById(m_startMap)->warpIndex(m_startWarp) == INT_MAX) + emit(error("Invalid starting warp")); if ((m_typechart.width() != typeCount()) || (m_typechart.height() != typeCount())) emit(error("Type chart is invalid")); - m_rules->validate(); + TEST_CHILD(m_rules); QSet<int> idChecker; QSet<QString> nameChecker; QSet<int> timeChecker; if (abilityCount() < m_rules->maxAbilities()) emit(error("There are too few abilities")); - foreach (Ability* ability, m_abilities) - { - ability->validate(); - if (idChecker.contains(ability->id())) - emit(error(subclass("ability", ability->id()))); - idChecker.insert(ability->id()); - if (nameChecker.contains(ability->name())) - emit(error(subclass("ability", ability->name()))); - nameChecker.insert(ability->name()); - } + TEST_SUB_BEGIN(Ability, abilities); + TEST_SUB("ability", id); + TEST_SUB("ability", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!authorCount()) emit(error("There are no authors")); - foreach (Author* author, m_authors) - { - author->validate(); - if (idChecker.contains(author->id())) - emit(error(subclass("author", author->id()))); - idChecker.insert(author->id()); - if (nameChecker.contains(author->name())) - emit(error(subclass("author", author->name()))); - nameChecker.insert(author->name()); - } + TEST_SUB_BEGIN(Author, authors); + TEST_SUB("author", id); + TEST_SUB("author", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!badgeCount()) emit(error("There are no badges")); - foreach (Badge* badge, m_badges) - { - badge->validate(); - if (idChecker.contains(badge->id())) - emit(error(subclass("badge", badge->id()))); - idChecker.insert(badge->id()); - if (nameChecker.contains(badge->name())) - emit(error(subclass("badge", badge->name()))); - nameChecker.insert(badge->name()); - } + TEST_SUB_BEGIN(Badge, badges); + TEST_SUB("badge", id); + TEST_SUB("badge", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!coinListCount()) emit(warning("There are no coin lists")); - foreach (CoinList* coinList, m_coinLists) - { - coinList->validate(); - if (idChecker.contains(coinList->id())) - emit(error(subclass("coin list", coinList->id()))); - idChecker.insert(coinList->id()); - if (nameChecker.contains(coinList->name())) - emit(error(subclass("coin list", coinList->name()))); - nameChecker.insert(coinList->name()); - } + TEST_SUB_BEGIN(CoinList, coinLists); + TEST_SUB("coin list", id); + TEST_SUB("coin list", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (m_rules->breedingAllowed()) { if (!eggGroupCount()) emit(error("There are no egg groups")); - foreach (EggGroup* eggGroup, m_eggGroups) - { - eggGroup->validate(); - if (idChecker.contains(eggGroup->id())) - emit(error(subclass("egg group", eggGroup->id()))); - idChecker.insert(eggGroup->id()); - if (nameChecker.contains(eggGroup->name())) - emit(error(subclass("egg group", eggGroup->name()))); - nameChecker.insert(eggGroup->name()); - } + TEST_SUB_BEGIN(EggGroup, eggGroups); + TEST_SUB("egg group", id); + TEST_SUB("egg group", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); } if (!globalScriptCount()) emit(warning("There are no global scripts")); - foreach (GlobalScript* globalScript, m_globalScripts) - { - globalScript->validate(); - if (idChecker.contains(globalScript->id())) - emit(error(subclass("global script", globalScript->id()))); - idChecker.insert(globalScript->id()); - if (nameChecker.contains(globalScript->name())) - emit(error(subclass("global script", globalScript->name()))); - nameChecker.insert(globalScript->name()); - } + TEST_SUB_BEGIN(GlobalScript, globalScripts); + TEST_SUB("global script", id); + TEST_SUB("global script", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!itemCount()) emit(warning("There are no items")); - foreach (Item* item, m_items) - { - item->validate(); - if (idChecker.contains(item->id())) - emit(error(subclass("item", item->id()))); - idChecker.insert(item->id()); - if (nameChecker.contains(item->name())) - emit(error(subclass("item", item->name()))); - nameChecker.insert(item->name()); - } + TEST_SUB_BEGIN(Item, items); + TEST_SUB("item", id); + TEST_SUB("item", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!itemTypeCount() && itemCount()) emit(error("There are no item types")); - foreach (ItemType* itemType, m_itemTypes) - { - itemType->validate(); - if (idChecker.contains(itemType->id())) - emit(error(subclass("item type", itemType->id()))); - idChecker.insert(itemType->id()); - if (nameChecker.contains(itemType->name())) - emit(error(subclass("item type", itemType->name()))); - nameChecker.insert(itemType->name()); - } + TEST_SUB_BEGIN(ItemType, itemTypes); + TEST_SUB("item type", id); + TEST_SUB("item type", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!mapCount()) emit(error("There are no maps")); - foreach (Map* map, m_maps) - { - map->validate(); - if (idChecker.contains(map->id())) - emit(error(subclass("map", map->id()))); - idChecker.insert(map->id()); - if (nameChecker.contains(map->name())) - emit(error(subclass("map", map->name()))); - nameChecker.insert(map->name()); - } + TEST_SUB_BEGIN(Map, maps); + TEST_SUB("map", id); + TEST_SUB("map", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!moveCount()) emit(error("There are no moves")); - foreach (Move* move, m_moves) - { - move->validate(); - if (idChecker.contains(move->id())) - emit(error(subclass("move", move->id()))); - idChecker.insert(move->id()); - if (nameChecker.contains(move->name())) - emit(error(subclass("move", move->name()))); - nameChecker.insert(move->name()); - } + TEST_SUB_BEGIN(Move, moves); + TEST_SUB("move", id); + TEST_SUB("move", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (natureCount() < m_rules->maxNatures()) emit(error("There are too few natures")); - foreach (Nature* nature, m_natures) - { - nature->validate(); - if (idChecker.contains(nature->id())) - emit(error(subclass("ability", nature->id()))); - idChecker.insert(nature->id()); - if (nameChecker.contains(nature->name())) - emit(error(subclass("nature", nature->name()))); - nameChecker.insert(nature->name()); - } + TEST_SUB_BEGIN(Nature, natures); + TEST_SUB("nature", id); + TEST_SUB("nature", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!soundCount()) - emit(error("There are no sounds")); - foreach (Sound* sound, m_sounds) - { - sound->validate(); - if (idChecker.contains(sound->id())) - emit(error(subclass("sound", sound->id()))); - idChecker.insert(sound->id()); - if (nameChecker.contains(sound->name())) - emit(error(subclass("sound", sound->name()))); - nameChecker.insert(sound->name()); - } + emit(warning("There are no sounds")); + TEST_SUB_BEGIN(Sound, sounds); + TEST_SUB("sound", id); + TEST_SUB("sound", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!speciesCount()) emit(error("There are no species")); - foreach (Species* species, m_species) - { - species->validate(); - if (idChecker.contains(species->id())) - emit(error(subclass("species", species->id()))); - idChecker.insert(species->id()); - if (nameChecker.contains(species->name())) - emit(error(subclass("species", species->name()))); - nameChecker.insert(species->name()); - } + TEST_SUB_BEGIN(Species, species); + TEST_SUB("species", id); + TEST_SUB("species", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!statusCount()) emit(error("There are no status effects")); - foreach (Status* status, m_status) - { - status->validate(); - if (idChecker.contains(status->id())) - emit(error(subclass("status effect", status->id()))); - idChecker.insert(status->id()); - if (nameChecker.contains(status->name())) - emit(error(subclass("status effect", status->name()))); - nameChecker.insert(status->name()); - } + TEST_SUB_BEGIN(Status, status); + TEST_SUB("status", id); + TEST_SUB("status", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!storeCount()) emit(warning("There are no stores")); - foreach (Store* store, m_stores) - { - store->validate(); - if (idChecker.contains(store->id())) - emit(error(subclass("store", store->id()))); - idChecker.insert(store->id()); - if (nameChecker.contains(store->name())) - emit(error(subclass("store", store->name()))); - nameChecker.insert(store->name()); - } + TEST_SUB_BEGIN(Store, stores); + TEST_SUB("store", id); + TEST_SUB("store", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!tileCount()) emit(error("There are no tiles")); - foreach (Tile* tile, m_tiles) - { - tile->validate(); - if (idChecker.contains(tile->id())) - emit(error(subclass("tile", tile->id()))); - idChecker.insert(tile->id()); - if (nameChecker.contains(tile->name())) - emit(error(subclass("tile", tile->name()))); - nameChecker.insert(tile->name()); - } + TEST_SUB_BEGIN(Tile, tiles); + TEST_SUB("tile", id); + TEST_SUB("tile", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!trainerCount()) emit(warning("There are no trainers")); - foreach (Trainer* trainer, m_trainers) - { - trainer->validate(); - if (idChecker.contains(trainer->id())) - emit(error(subclass("trainer", trainer->id()))); - idChecker.insert(trainer->id()); - if (nameChecker.contains(trainer->name())) - emit(error(subclass("trainer", trainer->name()))); - nameChecker.insert(trainer->name()); - } + TEST_SUB_BEGIN(Trainer, trainers); + TEST_SUB("trainer", id); + TEST_SUB("trainer", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!timeCount()) emit(error("There are no times")); - foreach (Time* time, m_times) - { - time->validate(); - if (idChecker.contains(time->id())) - emit(error(subclass("time", time->id()))); - idChecker.insert(time->id()); - if (nameChecker.contains(time->name())) - emit(error(subclass("time", time->name()))); - nameChecker.insert(time->name()); - if (timeChecker.contains((60 * time->hour()) + time->minute())) - emit(error(subclass("time", QString("%1:%2").arg(time->hour(), time->minute())))); - timeChecker.insert((60 * time->hour()) + time->minute()); - } + TEST_SUB_BEGIN(Time, times); + TEST_SUB("time", id); + TEST_SUB("time", name); + if (timeChecker.contains((60 * object->hour()) + object->minute())) + emit(error(subclass("time", QString("%1:%2").arg(object->hour(), object->minute())))); + timeChecker.insert((60 * object->hour()) + object->minute()); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!typeCount()) emit(error("There are no types")); - foreach (Type* type, m_types) - { - type->validate(); - if (idChecker.contains(type->id())) - emit(error(subclass("type", type->id()))); - idChecker.insert(type->id()); - if (nameChecker.contains(type->name())) - emit(error(subclass("type", type->name()))); - nameChecker.insert(type->name()); - } + TEST_SUB_BEGIN(Type, types); + TEST_SUB("type", id); + TEST_SUB("type", name); + TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!weatherCount()) - emit(error("There are no weathers")); - foreach (Weather* weather, m_weathers) - { - weather->validate(); - if (idChecker.contains(weather->id())) - emit(error(subclass("weather", weather->id()))); - idChecker.insert(weather->id()); - if (nameChecker.contains(weather->name())) - emit(error(subclass("weather", weather->name()))); - nameChecker.insert(weather->name()); - } + emit(warning("There are no weathers")); + TEST_SUB_BEGIN(Weather, weathers); + TEST_SUB("weather", id); + TEST_SUB("weather", name); + TEST_SUB_END(); + TEST_END(); } void Pokemod::Pokemod::load(const QDomElement& xml, const int) @@ -470,11 +350,6 @@ QDomElement Pokemod::Pokemod::save() const return xml; } -int Pokemod::Pokemod::maxCompatability(const Pokemod& pokemod) const -{ - // TODO: MaxCompatability between two versions -} - void Pokemod::Pokemod::setTitle(const QString& title) { CHECK(title); diff --git a/pokemod/Pokemod.h b/pokemod/Pokemod.h index 94366001..18c8b80a 100644 --- a/pokemod/Pokemod.h +++ b/pokemod/Pokemod.h @@ -67,8 +67,6 @@ class Pokemod : public Object void load(const QDomElement& xml, const int = 0); QDomElement save() const; - int maxCompatability(const Pokemod& rhs) const; - void setTitle(const QString& title); void setVersion(const QString& version); void setDescription(const QString& description); diff --git a/pokemod/Rules.cpp b/pokemod/Rules.cpp index 38bfe6ef..225679ac 100644 --- a/pokemod/Rules.cpp +++ b/pokemod/Rules.cpp @@ -19,6 +19,7 @@ #include "Rules.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" const QStringList Pokemod::Rules::DVStr = QStringList() << "16" << "32"; @@ -34,7 +35,6 @@ Pokemod::Rules::Rules(const Pokemod* parent) : m_genderAllowed(false), m_breedingAllowed(false), m_criticalDomains(false), - m_maxMultiplier(1), m_numBoxes(0), m_boxSize(1), m_maxParty(1), @@ -76,8 +76,8 @@ Pokemod::Rules::Rules(const QDomElement& xml, const Pokemod* parent) : void Pokemod::Rules::validate() { + TEST_BEGIN(); TEST(setBreedingAllowed, breedingAllowed); - TEST(setMaxMultiplier, maxMultiplier); TEST(setNumBoxes, numBoxes); TEST(setBoxSize, boxSize); TEST(setMaxParty, maxParty); @@ -94,6 +94,7 @@ void Pokemod::Rules::validate() TEST(setPokerusChance, pokerusChance); if (.005 < m_pokerusChance) emit(warning("Pokerus chance is high")); + TEST_END(); } void Pokemod::Rules::load(const QDomElement& xml, const int /*id*/) @@ -101,7 +102,6 @@ void Pokemod::Rules::load(const QDomElement& xml, const int /*id*/) LOAD(bool, genderAllowed); LOAD(bool, breedingAllowed); LOAD(bool, criticalDomains); - LOAD(int, maxMultiplier); LOAD(int, numBoxes); LOAD(int, boxSize); LOAD(int, maxParty); @@ -134,7 +134,6 @@ QDomElement Pokemod::Rules::save() const SAVE(bool, genderAllowed); SAVE(bool, breedingAllowed); SAVE(bool, criticalDomains); - SAVE(int, maxMultiplier); SAVE(int, numBoxes); SAVE(int, boxSize); SAVE(int, maxParty); @@ -182,16 +181,6 @@ void Pokemod::Rules::setCriticalDomains(const bool criticalDomains) CHECK(criticalDomains); } -void Pokemod::Rules::setMaxMultiplier(const int maxMultiplier) -{ - if (!maxMultiplier) - { - emit(error(bounds("maxMultiplier"))); - return; - } - CHECK(maxMultiplier); -} - void Pokemod::Rules::setNumBoxes(const int numBoxes) { CHECK(numBoxes); @@ -377,11 +366,6 @@ bool Pokemod::Rules::criticalDomains() const return m_criticalDomains; } -int Pokemod::Rules::maxMultiplier() const -{ - return m_maxMultiplier; -} - int Pokemod::Rules::numBoxes() const { return m_numBoxes; @@ -509,7 +493,6 @@ Pokemod::Rules& Pokemod::Rules::operator=(const Rules& rhs) COPY(genderAllowed); COPY(breedingAllowed); COPY(criticalDomains); - COPY(maxMultiplier); COPY(numBoxes); COPY(boxSize); COPY(maxParty); diff --git a/pokemod/Rules.h b/pokemod/Rules.h index 5c93115e..3c77ca50 100644 --- a/pokemod/Rules.h +++ b/pokemod/Rules.h @@ -47,7 +47,6 @@ class Rules : public Object void setGenderAllowed(const bool genderAllowed); void setBreedingAllowed(const bool breedingAllowed); void setCriticalDomains(const bool criticalDomains); - void setMaxMultiplier(const int maxMultiplier); void setNumBoxes(const int numBoxes); void setBoxSize(const int boxSize); void setMaxParty(const int maxParty); @@ -76,7 +75,6 @@ class Rules : public Object bool genderAllowed() const; bool breedingAllowed() const; bool criticalDomains() const; - int maxMultiplier() const; int numBoxes() const; int boxSize() const; int maxParty() const; @@ -107,7 +105,6 @@ class Rules : public Object bool m_genderAllowed; bool m_breedingAllowed; bool m_criticalDomains; - int m_maxMultiplier; int m_numBoxes; int m_boxSize; int m_maxParty; diff --git a/pokemod/Sound.cpp b/pokemod/Sound.cpp index cdcd480a..e6178c55 100644 --- a/pokemod/Sound.cpp +++ b/pokemod/Sound.cpp @@ -19,6 +19,7 @@ #include "Sound.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" Pokemod::Sound::Sound(const Sound& sound) : @@ -48,10 +49,12 @@ Pokemod::Sound::Sound(const QDomElement& xml, const Pokemod* parent, const int i void Pokemod::Sound::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); if (m_data.isEmpty()) emit(error("Data is empty")); + TEST_END(); } void Pokemod::Sound::load(const QDomElement& xml, int id) diff --git a/pokemod/Species.cpp b/pokemod/Species.cpp index 415936a5..95912f61 100644 --- a/pokemod/Species.cpp +++ b/pokemod/Species.cpp @@ -19,6 +19,7 @@ #include "Species.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" #include "Rules.h" #include "SpeciesAbility.h" @@ -26,7 +27,6 @@ #include "SpeciesMove.h" // Qt includes -#include <QBuffer> #include <QSet> const QStringList Pokemod::Species::StyleStr = QStringList() << "Fluctuating" << "Fading" << "Slow" << "Normal" << "Fast" << "Erratic"; @@ -87,6 +87,7 @@ Pokemod::Species::~Species() void Pokemod::Species::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); TEST_ARRAY(setBaseStat, baseStat, static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? ST_End_GSC : ST_End_RBY); @@ -121,41 +122,27 @@ void Pokemod::Species::validate() QSet<int> valueChecker; if (abilityCount() < static_cast<const Pokemod*>(pokemod())->rules()->maxAbilities()) emit(warning("There are too few abilities")); - foreach (SpeciesAbility* ability, m_abilities) - { - ability->validate(); - if (idChecker.contains(ability->id())) - emit(error(subclass("ability", ability->id()))); - idChecker.insert(ability->id()); - if (valueChecker.contains(ability->ability())) - emit(error(subclass("ability", ability->ability()))); - valueChecker.insert(ability->ability()); - } + TEST_SUB_BEGIN(SpeciesAbility, abilities); + TEST_SUB("ability", id); + TEST_SUB_RAW(value, "ability", ability); + TEST_SUB_END(); idChecker.clear(); valueChecker.clear(); if (static_cast<const Pokemod*>(pokemod())->rules()->maxHeldItems() && !itemCount()) emit(warning("There are no items")); - foreach (SpeciesItem* item, m_items) - { - item->validate(); - if (idChecker.contains(item->id())) - emit(error(subclass("item", item->id()))); - idChecker.insert(item->id()); - if (valueChecker.contains(item->item())) - emit(error(subclass("item", item->item()))); - valueChecker.insert(item->item()); - } + TEST_SUB_BEGIN(SpeciesItem, items); + TEST_SUB("item", id); + TEST_SUB_RAW(value, "item", item); + TEST_SUB_END(); idChecker.clear(); valueChecker.clear(); if (!moveCount()) emit(error("There are no moves")); - foreach (SpeciesMove* move, m_moves) - { - move->validate(); - if (idChecker.contains(move->id())) - emit(error(subclass("move", move->id()))); - idChecker.insert(move->id()); - } + TEST_SUB_BEGIN(SpeciesMove, moves); + TEST_SUB("move", id); + TEST_SUB_RAW(value, "move", move); + TEST_SUB_END(); + TEST_END(); } void Pokemod::Species::load(const QDomElement& xml, int id) diff --git a/pokemod/SpeciesAbility.cpp b/pokemod/SpeciesAbility.cpp index 9a230fb0..f4123ee0 100644 --- a/pokemod/SpeciesAbility.cpp +++ b/pokemod/SpeciesAbility.cpp @@ -19,6 +19,7 @@ #include "SpeciesAbility.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" #include "Species.h" @@ -49,8 +50,10 @@ Pokemod::SpeciesAbility::SpeciesAbility(const QDomElement& xml, const Species* p void Pokemod::SpeciesAbility::validate() { + TEST_BEGIN(); TEST(setAbility, ability); TEST(setWeight, weight); + TEST_END(); } void Pokemod::SpeciesAbility::load(const QDomElement& xml, int id) diff --git a/pokemod/SpeciesItem.cpp b/pokemod/SpeciesItem.cpp index 16682aae..0450df6e 100644 --- a/pokemod/SpeciesItem.cpp +++ b/pokemod/SpeciesItem.cpp @@ -19,6 +19,7 @@ #include "SpeciesItem.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" #include "Species.h" @@ -49,8 +50,10 @@ Pokemod::SpeciesItem::SpeciesItem(const QDomElement& xml, const Species* parent, void Pokemod::SpeciesItem::validate() { + TEST_BEGIN(); TEST(setItem, item); TEST(setWeight, weight); + TEST_END(); } void Pokemod::SpeciesItem::load(const QDomElement& xml, int id) diff --git a/pokemod/SpeciesMove.cpp b/pokemod/SpeciesMove.cpp index e914b2eb..d26a186c 100644 --- a/pokemod/SpeciesMove.cpp +++ b/pokemod/SpeciesMove.cpp @@ -19,6 +19,7 @@ #include "SpeciesMove.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" #include "Rules.h" #include "Species.h" @@ -51,9 +52,11 @@ Pokemod::SpeciesMove::SpeciesMove(const QDomElement& xml, const Species* parent, void Pokemod::SpeciesMove::validate() { + TEST_BEGIN(); TEST(setMove, move); TEST(setLevel, level); TEST(setWild, wild); + TEST_END(); } void Pokemod::SpeciesMove::load(const QDomElement& xml, int id) diff --git a/pokemod/Sprite.cpp b/pokemod/Sprite.cpp index 5b73577f..e497f270 100644 --- a/pokemod/Sprite.cpp +++ b/pokemod/Sprite.cpp @@ -19,11 +19,9 @@ #include "Sprite.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" -// Qt includes -#include <QBuffer> - Pokemod::Sprite::Sprite(const Sprite& sprite) : Object("Sprite", sprite.parent(), sprite.id()) { @@ -55,8 +53,10 @@ Pokemod::Sprite::~Sprite() void Pokemod::Sprite::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); + TEST_END(); } void Pokemod::Sprite::load(const QDomElement& xml, int id) diff --git a/pokemod/Status.cpp b/pokemod/Status.cpp index 86a3ae21..5abc21b7 100644 --- a/pokemod/Status.cpp +++ b/pokemod/Status.cpp @@ -19,6 +19,7 @@ #include "Status.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" #include "Script.h" @@ -53,8 +54,10 @@ Pokemod::Status::~Status() void Pokemod::Status::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); + TEST_END(); } void Pokemod::Status::load(const QDomElement& xml, int id) diff --git a/pokemod/Store.cpp b/pokemod/Store.cpp index 4fb10abe..a8e81b45 100644 --- a/pokemod/Store.cpp +++ b/pokemod/Store.cpp @@ -19,6 +19,7 @@ #include "Store.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" Pokemod::Store::Store(const Store& store) : @@ -47,6 +48,7 @@ Pokemod::Store::Store(const QDomElement& xml, const Pokemod* parent, const int i void Pokemod::Store::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); if (m_item.size()) @@ -55,6 +57,7 @@ void Pokemod::Store::validate() } else emit(error("No items in the store")); + TEST_END(); } void Pokemod::Store::load(const QDomElement& xml, int id) diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp index 4ddb2632..d616dd21 100644 --- a/pokemod/Tile.cpp +++ b/pokemod/Tile.cpp @@ -19,11 +19,9 @@ #include "Tile.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" -// Qt includes -#include <QBuffer> - Pokemod::Tile::Tile(const Tile& tile) : Object("Tile", tile.parent(), tile.id()) { @@ -54,9 +52,11 @@ Pokemod::Tile::Tile(const QDomElement& xml, const Pokemod* parent, const int id) void Pokemod::Tile::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); TEST(setSprite, sprite); + TEST_END(); } void Pokemod::Tile::load(const QDomElement& xml, int id) diff --git a/pokemod/Time.cpp b/pokemod/Time.cpp index 0c2f3fab..13a4235b 100644 --- a/pokemod/Time.cpp +++ b/pokemod/Time.cpp @@ -19,6 +19,7 @@ #include "Time.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" Pokemod::Time::Time(const Time& time) : @@ -49,10 +50,12 @@ Pokemod::Time::Time(const QDomElement& xml, const Pokemod* parent, const int id) void Pokemod::Time::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); TEST(setHour, hour); TEST(setMinute, minute); + TEST_END(); } void Pokemod::Time::load(const QDomElement& xml, int id) diff --git a/pokemod/Trainer.cpp b/pokemod/Trainer.cpp index f5a6ecda..b82dbd1c 100644 --- a/pokemod/Trainer.cpp +++ b/pokemod/Trainer.cpp @@ -19,11 +19,9 @@ #include "Trainer.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" -// Qt includes -#include <QBuffer> - const QStringList Pokemod::Trainer::IntelligenceStr = QStringList() << "Ignorant" << "Remember" << "Deduce" << "Cheating"; Pokemod::Trainer::Trainer(const Trainer& trainer) : @@ -54,10 +52,12 @@ Pokemod::Trainer::Trainer(const QDomElement& xml, const Pokemod* parent, const i void Pokemod::Trainer::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); TEST(setMoneyFactor, moneyFactor); TEST(setSkin, skin); + TEST_END(); } void Pokemod::Trainer::load(const QDomElement& xml, int id) diff --git a/pokemod/Type.cpp b/pokemod/Type.cpp index c6873de1..5a83af34 100644 --- a/pokemod/Type.cpp +++ b/pokemod/Type.cpp @@ -19,6 +19,7 @@ #include "Type.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" Pokemod::Type::Type(const Type& type) : @@ -48,8 +49,10 @@ Pokemod::Type::Type(const QDomElement& xml, const Pokemod* parent, const int id) void Pokemod::Type::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); + TEST_END(); } void Pokemod::Type::load(const QDomElement& xml, int id) diff --git a/pokemod/Weather.cpp b/pokemod/Weather.cpp index 49cd119a..fa080445 100644 --- a/pokemod/Weather.cpp +++ b/pokemod/Weather.cpp @@ -19,6 +19,7 @@ #include "Weather.h" // Pokemod includes +#include "Macros.h" #include "Pokemod.h" #include "Script.h" @@ -53,8 +54,10 @@ Pokemod::Weather::~Weather() void Pokemod::Weather::validate() { + TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); + TEST_END(); } void Pokemod::Weather::load(const QDomElement& xml, int id) diff --git a/pokemod/pokemod.pro b/pokemod/pokemod.pro index 2c4c7b10..ba4421e5 100644 --- a/pokemod/pokemod.pro +++ b/pokemod/pokemod.pro @@ -65,6 +65,7 @@ HEADERS += Ability.h \ Hat.h \ Item.h \ ItemType.h \ + Macros.h \ MapEffect.h \ Map.h \ MapTrainer.h \ diff --git a/pokemodr/ObjectUI.cpp b/pokemodr/ObjectUI.cpp index caef8956..8e96c79e 100644 --- a/pokemodr/ObjectUI.cpp +++ b/pokemodr/ObjectUI.cpp @@ -22,16 +22,30 @@ #include "../pokemod/Object.h" #include "../pokemod/Pokemod.h" +// Qt includes +#include <QLabel> +#include <QTreeWidget> +#include <QVBoxLayout> + // KDE includes +#include <KAction> +#include <KColorScheme> +#include <KDialog> +#include <KMenu> #include <KMessageBox> +#include <KProgressDialog> +// #include <KStatefulBrush> Pokemodr::ObjectUI::ObjectUI(QWidget* parent) : QWidget(parent), m_changed(false), m_object(NULL), - m_object_mod(NULL) + m_object_mod(NULL), + m_valTree(NULL) { + setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(changed(bool)), SLOT(setChanged(bool))); + connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(contextMenu(const QPoint&))); } Pokemodr::ObjectUI::~ObjectUI() @@ -98,6 +112,90 @@ void Pokemodr::ObjectUI::refreshGui() { } +void Pokemodr::ObjectUI::contextMenu(const QPoint& pos) +{ + KMenu* menu = new KMenu; + menu->addAction("&Apply", this, SLOT(apply())); + menu->addAction("&Discard", this, SLOT(discard())); + menu->addSeparator(); + KAction* validate = new KAction("&Validate", this); + connect(validate, SIGNAL(triggered()), this, SLOT(validate())); + validate->setEnabled(!m_changed); + menu->addAction(validate); + menu->popup(mapToGlobal(pos)); +} + +void Pokemodr::ObjectUI::validate() +{ + KProgressDialog* progress = new KProgressDialog(this, "Validating", "Please wait"); + progress->progressBar()->setRange(0, 0); + progress->setAllowCancel(false); + progress->setModal(true); + progress->show(); + if (!m_valTree) + m_valTree = new QTreeWidget; + m_valTree->setHeaderHidden(true); + m_parents.clear(); + m_warnings = 0; + m_errors = 0; + m_valTree->clear(); + connect(m_object, SIGNAL(valMessage(const QString&)), this, SLOT(addMessage(const QString&))); + connect(m_object, SIGNAL(valWarning(const QString&)), this, SLOT(addWarning(const QString&))); + connect(m_object, SIGNAL(valError(const QString&)), this, SLOT(addError(const QString&))); + m_object->validate(); + delete progress; + KDialog* dialog = new KDialog(this); + dialog->setCaption("Validation Messages"); + dialog->setButtons(KDialog::Ok); + QWidget* widget = new QWidget(this); + QVBoxLayout* layout = new QVBoxLayout(widget); + layout->addWidget(new QLabel(QString("Warnings: %1\nErrors: %2").arg(m_warnings).arg(m_errors), widget)); + layout->addWidget(m_valTree); + dialog->setMainWidget(widget); + dialog->exec(); + delete dialog; + m_valTree = NULL; + disconnect(m_object, SIGNAL(valMessage(const QString&)), this, SLOT(addMessage(const QString&))); + disconnect(m_object, SIGNAL(valWarning(const QString&)), this, SLOT(addWarning(const QString&))); + disconnect(m_object, SIGNAL(valError(const QString&)), this, SLOT(addError(const QString&))); +} + +void Pokemodr::ObjectUI::addMessage(const QString& msg) +{ + QTreeWidgetItem* item; + if (msg.startsWith("++")) + { + if (m_parents.size()) + item = new QTreeWidgetItem(m_parents.top(), QStringList(msg.mid(2))); + else + item = new QTreeWidgetItem(m_valTree, QStringList(msg.mid(2))); + m_parents.push(item); + } + else if (msg.startsWith("--")) + m_parents.pop(); + else + { + item = new QTreeWidgetItem(m_parents.top(), QStringList(msg)); + item->setBackground(0, KStatefulBrush(KColorScheme::View, KColorScheme::PositiveBackground).brush(QPalette::Normal)); + } +} + +void Pokemodr::ObjectUI::addWarning(const QString& msg) +{ + ++m_warnings; + QTreeWidgetItem* item; + item = new QTreeWidgetItem(m_parents.top(), QStringList(msg)); + item->setBackground(0, KStatefulBrush(KColorScheme::View, KColorScheme::NeutralBackground).brush(QPalette::Normal)); +} + +void Pokemodr::ObjectUI::addError(const QString& msg) +{ + ++m_errors; + QTreeWidgetItem* item; + item = new QTreeWidgetItem(m_parents.top(), QStringList(msg)); + item->setBackground(0, KStatefulBrush(KColorScheme::View, KColorScheme::NegativeBackground).brush(QPalette::Normal)); +} + void Pokemodr::ObjectUI::setObjects(Pokemod::Object* original, Pokemod::Object* modified) { m_object = original; diff --git a/pokemodr/ObjectUI.h b/pokemodr/ObjectUI.h index fc952dcc..60ae5160 100644 --- a/pokemodr/ObjectUI.h +++ b/pokemodr/ObjectUI.h @@ -19,10 +19,13 @@ #define __POKEMODR_OBJECTUI__ // Qt includes +#include <QStack> #include <QWidget> // Forward declarations class QCloseEvent; +class QTreeWidget; +class QTreeWidgetItem; namespace Pokemod { class Object; @@ -62,6 +65,13 @@ class ObjectUI : public QWidget virtual void initGui(); virtual void refreshGui(); virtual void setGui() = 0; + private slots: + void contextMenu(const QPoint& pos); + + void validate(); + void addMessage(const QString& msg); + void addWarning(const QString& msg); + void addError(const QString& msg); protected: void setObjects(Pokemod::Object* original, Pokemod::Object* modified); @@ -71,6 +81,11 @@ class ObjectUI : public QWidget Pokemod::Object* m_object; Pokemod::Object* m_object_mod; + + QStack<QTreeWidgetItem*> m_parents; + QTreeWidget* m_valTree; + int m_errors; + int m_warnings; }; } diff --git a/pokemodr/PokemodrUI.cpp b/pokemodr/PokemodrUI.cpp index 9d502cec..606392b1 100644 --- a/pokemodr/PokemodrUI.cpp +++ b/pokemodr/PokemodrUI.cpp @@ -357,9 +357,7 @@ void Pokemodr::PokemodrUI::on_treePokemod_customContextMenuRequested(const QPoin menu->addSeparator(); if (!type.isEmpty()) { - KAction* copy = new KAction("&Copy", this); - connect(copy, SIGNAL(triggered()), this, SLOT(copyObject())); - menu->addAction(copy); + menu->addAction("&Copy", this, SLOT(copyObject())); paste->setEnabled(m_clipboard.doctype().name() == type); } menu->addAction(paste); diff --git a/pokemodr/models/AbilityGroupModel.cpp b/pokemodr/models/AbilityGroupModel.cpp index 03a8e65e..becea9d4 100644 --- a/pokemodr/models/AbilityGroupModel.cpp +++ b/pokemodr/models/AbilityGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::AbilityGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Ability", this, SLOT(addObject())); + menu->addAction("&Add Ability", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/AbilityModel.cpp b/pokemodr/models/AbilityModel.cpp index 72bcc35f..71bd11d8 100644 --- a/pokemodr/models/AbilityModel.cpp +++ b/pokemodr/models/AbilityModel.cpp @@ -60,7 +60,7 @@ QVariant Pokemodr::AbilityModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Ability", this, SLOT(deleteSelf())); + menu->addAction("*&Delete Ability", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/AuthorGroupModel.cpp b/pokemodr/models/AuthorGroupModel.cpp index 3e98eb98..ca465f4e 100644 --- a/pokemodr/models/AuthorGroupModel.cpp +++ b/pokemodr/models/AuthorGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::AuthorGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Author", this, SLOT(addObject())); + menu->addAction("&Add Author", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/AuthorModel.cpp b/pokemodr/models/AuthorModel.cpp index 4eddebd4..a80bf81b 100644 --- a/pokemodr/models/AuthorModel.cpp +++ b/pokemodr/models/AuthorModel.cpp @@ -60,7 +60,7 @@ QVariant Pokemodr::AuthorModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Author", this, SLOT(deleteSelf())); + menu->addAction("&Delete Author", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/BadgeGroupModel.cpp b/pokemodr/models/BadgeGroupModel.cpp index 5d06faf9..5f5cc010 100644 --- a/pokemodr/models/BadgeGroupModel.cpp +++ b/pokemodr/models/BadgeGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::BadgeGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Badge", this, SLOT(addObject())); + menu->addAction("&Add Badge", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/BadgeModel.cpp b/pokemodr/models/BadgeModel.cpp index efebe456..39bc8d7b 100644 --- a/pokemodr/models/BadgeModel.cpp +++ b/pokemodr/models/BadgeModel.cpp @@ -60,7 +60,7 @@ QVariant Pokemodr::BadgeModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Badge", this, SLOT(deleteSelf())); + menu->addAction("&Delete Badge", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/CoinListGroupModel.cpp b/pokemodr/models/CoinListGroupModel.cpp index 2de15681..3e944fba 100644 --- a/pokemodr/models/CoinListGroupModel.cpp +++ b/pokemodr/models/CoinListGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::CoinListGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Coin List", this, SLOT(addObject())); + menu->addAction("&Add Coin List", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/CoinListModel.cpp b/pokemodr/models/CoinListModel.cpp index 8f82ccc1..bd874c10 100644 --- a/pokemodr/models/CoinListModel.cpp +++ b/pokemodr/models/CoinListModel.cpp @@ -63,9 +63,9 @@ QVariant Pokemodr::CoinListModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Object", this, SLOT(addObject())); + menu->addAction("&Add Object", this, SLOT(addObject())); menu->addSeparator(); - menu->addAction("Delete Coin List", this, SLOT(deleteSelf())); + menu->addAction("&Delete Coin List", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupObjectModel::data(role); diff --git a/pokemodr/models/CoinListObjectModel.cpp b/pokemodr/models/CoinListObjectModel.cpp index 929dcb69..c2391819 100644 --- a/pokemodr/models/CoinListObjectModel.cpp +++ b/pokemodr/models/CoinListObjectModel.cpp @@ -79,7 +79,7 @@ QVariant Pokemodr::CoinListObjectModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Object", this, SLOT(deleteSelf())); + menu->addAction("&Delete Object", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/EggGroupGroupModel.cpp b/pokemodr/models/EggGroupGroupModel.cpp index 3a6f8dbe..a98472fa 100644 --- a/pokemodr/models/EggGroupGroupModel.cpp +++ b/pokemodr/models/EggGroupGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::EggGroupGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add EggGroup", this, SLOT(addObject())); + menu->addAction("&Add EggGroup", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/EggGroupModel.cpp b/pokemodr/models/EggGroupModel.cpp index c622d59d..51541042 100644 --- a/pokemodr/models/EggGroupModel.cpp +++ b/pokemodr/models/EggGroupModel.cpp @@ -60,7 +60,7 @@ QVariant Pokemodr::EggGroupModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Egg Group", this, SLOT(deleteSelf())); + menu->addAction("&Delete Egg Group", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/GlobalScriptGroupModel.cpp b/pokemodr/models/GlobalScriptGroupModel.cpp index 7f43cea6..1fa93b2d 100644 --- a/pokemodr/models/GlobalScriptGroupModel.cpp +++ b/pokemodr/models/GlobalScriptGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::GlobalScriptGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Global Script", this, SLOT(addObject())); + menu->addAction("&Add Global Script", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/GlobalScriptModel.cpp b/pokemodr/models/GlobalScriptModel.cpp index 4431e508..3e80aee2 100644 --- a/pokemodr/models/GlobalScriptModel.cpp +++ b/pokemodr/models/GlobalScriptModel.cpp @@ -60,7 +60,7 @@ QVariant Pokemodr::GlobalScriptModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Global Script", this, SLOT(deleteSelf())); + menu->addAction("&Delete Global Script", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/ItemGroupModel.cpp b/pokemodr/models/ItemGroupModel.cpp index 521bd9d2..69477a4f 100644 --- a/pokemodr/models/ItemGroupModel.cpp +++ b/pokemodr/models/ItemGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::ItemGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Item", this, SLOT(addObject())); + menu->addAction("&Add Item", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/ItemModel.cpp b/pokemodr/models/ItemModel.cpp index b12827c2..d2e25de0 100644 --- a/pokemodr/models/ItemModel.cpp +++ b/pokemodr/models/ItemModel.cpp @@ -60,7 +60,7 @@ QVariant Pokemodr::ItemModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Item", this, SLOT(deleteSelf())); + menu->addAction("&Delete Item", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/ItemTypeGroupModel.cpp b/pokemodr/models/ItemTypeGroupModel.cpp index 4841322f..c66c975a 100644 --- a/pokemodr/models/ItemTypeGroupModel.cpp +++ b/pokemodr/models/ItemTypeGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::ItemTypeGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Item Type", this, SLOT(addObject())); + menu->addAction("&Add Item Type", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/ItemTypeModel.cpp b/pokemodr/models/ItemTypeModel.cpp index 75d657fe..5dca8937 100644 --- a/pokemodr/models/ItemTypeModel.cpp +++ b/pokemodr/models/ItemTypeModel.cpp @@ -60,7 +60,7 @@ QVariant Pokemodr::ItemTypeModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Item Type", this, SLOT(deleteSelf())); + menu->addAction("&Delete Item Type", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/MapEffectGroupModel.cpp b/pokemodr/models/MapEffectGroupModel.cpp index b3e67dc7..48bee0ae 100644 --- a/pokemodr/models/MapEffectGroupModel.cpp +++ b/pokemodr/models/MapEffectGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::MapEffectGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Effect", this, SLOT(addObject())); + menu->addAction("&Add Effect", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/MapEffectModel.cpp b/pokemodr/models/MapEffectModel.cpp index 79528265..7e30640b 100644 --- a/pokemodr/models/MapEffectModel.cpp +++ b/pokemodr/models/MapEffectModel.cpp @@ -61,7 +61,7 @@ QVariant Pokemodr::MapEffectModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Effect", this, SLOT(deleteSelf())); + menu->addAction("&Delete Effect", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/MapGroupModel.cpp b/pokemodr/models/MapGroupModel.cpp index 5986c47b..291c1fa9 100644 --- a/pokemodr/models/MapGroupModel.cpp +++ b/pokemodr/models/MapGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::MapGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Map", this, SLOT(addObject())); + menu->addAction("&Add Map", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/MapModel.cpp b/pokemodr/models/MapModel.cpp index 67642346..15fe2699 100644 --- a/pokemodr/models/MapModel.cpp +++ b/pokemodr/models/MapModel.cpp @@ -64,7 +64,7 @@ QVariant Pokemodr::MapModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Map", this, SLOT(deleteSelf())); + menu->addAction("&Delete Map", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupObjectModel::data(role); diff --git a/pokemodr/models/MapTrainerGroupModel.cpp b/pokemodr/models/MapTrainerGroupModel.cpp index fcf4d8b5..b6f706a3 100644 --- a/pokemodr/models/MapTrainerGroupModel.cpp +++ b/pokemodr/models/MapTrainerGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::MapTrainerGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Trainer", this, SLOT(addObject())); + menu->addAction("&Add Trainer", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/MapTrainerModel.cpp b/pokemodr/models/MapTrainerModel.cpp index 45281b6e..2cf9a2c9 100644 --- a/pokemodr/models/MapTrainerModel.cpp +++ b/pokemodr/models/MapTrainerModel.cpp @@ -64,9 +64,9 @@ QVariant Pokemodr::MapTrainerModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Team Member", this, SLOT(addObject())); + menu->addAction("&Add Team Member", this, SLOT(addObject())); menu->addSeparator(); - menu->addAction("Delete Trainer", this, SLOT(deleteSelf())); + menu->addAction("&Delete Trainer", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupObjectModel::data(role); diff --git a/pokemodr/models/MapTrainerTeamMemberModel.cpp b/pokemodr/models/MapTrainerTeamMemberModel.cpp index 92e7910c..c4b595f1 100644 --- a/pokemodr/models/MapTrainerTeamMemberModel.cpp +++ b/pokemodr/models/MapTrainerTeamMemberModel.cpp @@ -68,7 +68,7 @@ QVariant Pokemodr::MapTrainerTeamMemberModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Team Member", this, SLOT(deleteSelf())); + menu->addAction("&Delete Team Member", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/MapWarpGroupModel.cpp b/pokemodr/models/MapWarpGroupModel.cpp index a3963958..5d61736c 100644 --- a/pokemodr/models/MapWarpGroupModel.cpp +++ b/pokemodr/models/MapWarpGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::MapWarpGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Warp", this, SLOT(addObject())); + menu->addAction("&Add Warp", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/MapWarpModel.cpp b/pokemodr/models/MapWarpModel.cpp index 941d38ca..d4c4acb6 100644 --- a/pokemodr/models/MapWarpModel.cpp +++ b/pokemodr/models/MapWarpModel.cpp @@ -61,7 +61,7 @@ QVariant Pokemodr::MapWarpModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Warp", this, SLOT(deleteSelf())); + menu->addAction("&Delete Warp", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/MapWildListEncounterModel.cpp b/pokemodr/models/MapWildListEncounterModel.cpp index 43c7bc79..a84af06a 100644 --- a/pokemodr/models/MapWildListEncounterModel.cpp +++ b/pokemodr/models/MapWildListEncounterModel.cpp @@ -68,7 +68,7 @@ QVariant Pokemodr::MapWildListEncounterModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Encounter", this, SLOT(deleteSelf())); + menu->addAction("&Delete Encounter", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/MapWildListGroupModel.cpp b/pokemodr/models/MapWildListGroupModel.cpp index 757c5d61..86a84ec8 100644 --- a/pokemodr/models/MapWildListGroupModel.cpp +++ b/pokemodr/models/MapWildListGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::MapWildListGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Wild List", this, SLOT(addObject())); + menu->addAction("&Add Wild List", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/MapWildListModel.cpp b/pokemodr/models/MapWildListModel.cpp index c3dc26eb..30fcf6b3 100644 --- a/pokemodr/models/MapWildListModel.cpp +++ b/pokemodr/models/MapWildListModel.cpp @@ -66,9 +66,9 @@ QVariant Pokemodr::MapWildListModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Encounter", this, SLOT(addObject())); + menu->addAction("&Add Encounter", this, SLOT(addObject())); menu->addSeparator(); - menu->addAction("Delete Wild List", this, SLOT(deleteSelf())); + menu->addAction("&Delete Wild List", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupObjectModel::data(role); diff --git a/pokemodr/models/MoveGroupModel.cpp b/pokemodr/models/MoveGroupModel.cpp index 15d7f3d2..118fc781 100644 --- a/pokemodr/models/MoveGroupModel.cpp +++ b/pokemodr/models/MoveGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::MoveGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Move", this, SLOT(addObject())); + menu->addAction("&Add Move", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/MoveModel.cpp b/pokemodr/models/MoveModel.cpp index 3d512589..b15ef760 100644 --- a/pokemodr/models/MoveModel.cpp +++ b/pokemodr/models/MoveModel.cpp @@ -60,7 +60,7 @@ QVariant Pokemodr::MoveModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Move", this, SLOT(deleteSelf())); + menu->addAction("&Delete Move", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/NatureGroupModel.cpp b/pokemodr/models/NatureGroupModel.cpp index cc317e33..0507ad82 100644 --- a/pokemodr/models/NatureGroupModel.cpp +++ b/pokemodr/models/NatureGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::NatureGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Nature", this, SLOT(addObject())); + menu->addAction("&Add Nature", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/NatureModel.cpp b/pokemodr/models/NatureModel.cpp index 79098e4b..d287bc76 100644 --- a/pokemodr/models/NatureModel.cpp +++ b/pokemodr/models/NatureModel.cpp @@ -61,7 +61,7 @@ QVariant Pokemodr::NatureModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Nature", this, SLOT(deleteSelf())); + menu->addAction("&Delete Nature", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/SoundGroupModel.cpp b/pokemodr/models/SoundGroupModel.cpp index 90c60a64..8603fc72 100644 --- a/pokemodr/models/SoundGroupModel.cpp +++ b/pokemodr/models/SoundGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::SoundGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Sound", this, SLOT(addObject())); + menu->addAction("&Add Sound", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/SoundModel.cpp b/pokemodr/models/SoundModel.cpp index f4c2f2cc..3fdd8ec2 100644 --- a/pokemodr/models/SoundModel.cpp +++ b/pokemodr/models/SoundModel.cpp @@ -61,7 +61,7 @@ QVariant Pokemodr::SoundModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Sound", this, SLOT(deleteSelf())); + menu->addAction("&Delete Sound", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/SpeciesAbilityGroupModel.cpp b/pokemodr/models/SpeciesAbilityGroupModel.cpp index dc5adb21..12411940 100644 --- a/pokemodr/models/SpeciesAbilityGroupModel.cpp +++ b/pokemodr/models/SpeciesAbilityGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::SpeciesAbilityGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Ability", this, SLOT(addObject())); + menu->addAction("&Add Ability", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/SpeciesAbilityModel.cpp b/pokemodr/models/SpeciesAbilityModel.cpp index edf33b36..b3d84a7d 100644 --- a/pokemodr/models/SpeciesAbilityModel.cpp +++ b/pokemodr/models/SpeciesAbilityModel.cpp @@ -68,7 +68,7 @@ QVariant Pokemodr::SpeciesAbilityModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Ability", this, SLOT(deleteSelf())); + menu->addAction("&Delete Ability", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/SpeciesGroupModel.cpp b/pokemodr/models/SpeciesGroupModel.cpp index 6ac2fe03..d44314ba 100644 --- a/pokemodr/models/SpeciesGroupModel.cpp +++ b/pokemodr/models/SpeciesGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::SpeciesGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Species", this, SLOT(addObject())); + menu->addAction("&Add Species", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/SpeciesItemGroupModel.cpp b/pokemodr/models/SpeciesItemGroupModel.cpp index 79b84b85..b1be67a4 100644 --- a/pokemodr/models/SpeciesItemGroupModel.cpp +++ b/pokemodr/models/SpeciesItemGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::SpeciesItemGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Item", this, SLOT(addObject())); + menu->addAction("&Add Item", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/SpeciesItemModel.cpp b/pokemodr/models/SpeciesItemModel.cpp index 70c281c7..70473b05 100644 --- a/pokemodr/models/SpeciesItemModel.cpp +++ b/pokemodr/models/SpeciesItemModel.cpp @@ -68,7 +68,7 @@ QVariant Pokemodr::SpeciesItemModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Item", this, SLOT(deleteSelf())); + menu->addAction("&Delete Item", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/SpeciesModel.cpp b/pokemodr/models/SpeciesModel.cpp index 9e5fbc9b..1b5fbe2d 100644 --- a/pokemodr/models/SpeciesModel.cpp +++ b/pokemodr/models/SpeciesModel.cpp @@ -65,7 +65,7 @@ QVariant Pokemodr::SpeciesModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Species", this, SLOT(deleteSelf())); + menu->addAction("&Delete Species", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupObjectModel::data(role); diff --git a/pokemodr/models/SpeciesMoveGroupModel.cpp b/pokemodr/models/SpeciesMoveGroupModel.cpp index 63945062..a7031459 100644 --- a/pokemodr/models/SpeciesMoveGroupModel.cpp +++ b/pokemodr/models/SpeciesMoveGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::SpeciesMoveGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Move", this, SLOT(addObject())); + menu->addAction("&Add Move", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/SpeciesMoveModel.cpp b/pokemodr/models/SpeciesMoveModel.cpp index e7e916d8..32081518 100644 --- a/pokemodr/models/SpeciesMoveModel.cpp +++ b/pokemodr/models/SpeciesMoveModel.cpp @@ -68,7 +68,7 @@ QVariant Pokemodr::SpeciesMoveModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Move", this, SLOT(deleteSelf())); + menu->addAction("&Delete Move", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/SpriteGroupModel.cpp b/pokemodr/models/SpriteGroupModel.cpp index f88c1e77..45285432 100644 --- a/pokemodr/models/SpriteGroupModel.cpp +++ b/pokemodr/models/SpriteGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::SpriteGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Sprite", this, SLOT(addObject())); + menu->addAction("&Add Sprite", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/SpriteModel.cpp b/pokemodr/models/SpriteModel.cpp index 492c4718..8b0c4431 100644 --- a/pokemodr/models/SpriteModel.cpp +++ b/pokemodr/models/SpriteModel.cpp @@ -60,7 +60,7 @@ QVariant Pokemodr::SpriteModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Sprite", this, SLOT(deleteSelf())); + menu->addAction("&Delete Sprite", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/StatusGroupModel.cpp b/pokemodr/models/StatusGroupModel.cpp index 567d5f67..b65ba89c 100644 --- a/pokemodr/models/StatusGroupModel.cpp +++ b/pokemodr/models/StatusGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::StatusGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Status", this, SLOT(addObject())); + menu->addAction("&Add Status", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/StatusModel.cpp b/pokemodr/models/StatusModel.cpp index 0dca29fe..a0a7090a 100644 --- a/pokemodr/models/StatusModel.cpp +++ b/pokemodr/models/StatusModel.cpp @@ -60,7 +60,7 @@ QVariant Pokemodr::StatusModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Status", this, SLOT(deleteSelf())); + menu->addAction("&Delete Status", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/StoreGroupModel.cpp b/pokemodr/models/StoreGroupModel.cpp index f7793088..3884633b 100644 --- a/pokemodr/models/StoreGroupModel.cpp +++ b/pokemodr/models/StoreGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::StoreGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Store", this, SLOT(addObject())); + menu->addAction("&Add Store", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/StoreModel.cpp b/pokemodr/models/StoreModel.cpp index b50c03c1..282eb7b5 100644 --- a/pokemodr/models/StoreModel.cpp +++ b/pokemodr/models/StoreModel.cpp @@ -61,7 +61,7 @@ QVariant Pokemodr::StoreModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Store", this, SLOT(deleteSelf())); + menu->addAction("&Delete Store", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/TileGroupModel.cpp b/pokemodr/models/TileGroupModel.cpp index 6d8d4deb..a323c5c2 100644 --- a/pokemodr/models/TileGroupModel.cpp +++ b/pokemodr/models/TileGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::TileGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Tile", this, SLOT(addObject())); + menu->addAction("&Add Tile", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/TileModel.cpp b/pokemodr/models/TileModel.cpp index 3d17a8ad..f1ec8d8d 100644 --- a/pokemodr/models/TileModel.cpp +++ b/pokemodr/models/TileModel.cpp @@ -61,7 +61,7 @@ QVariant Pokemodr::TileModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Tile", this, SLOT(deleteSelf())); + menu->addAction("&Delete Tile", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/TimeGroupModel.cpp b/pokemodr/models/TimeGroupModel.cpp index 016d6bab..26a87e3e 100644 --- a/pokemodr/models/TimeGroupModel.cpp +++ b/pokemodr/models/TimeGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::TimeGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Time", this, SLOT(addObject())); + menu->addAction("&Add Time", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/TimeModel.cpp b/pokemodr/models/TimeModel.cpp index 66f5ed02..25db9644 100644 --- a/pokemodr/models/TimeModel.cpp +++ b/pokemodr/models/TimeModel.cpp @@ -61,7 +61,7 @@ QVariant Pokemodr::TimeModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Time", this, SLOT(deleteSelf())); + menu->addAction("&Delete Time", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/TrainerGroupModel.cpp b/pokemodr/models/TrainerGroupModel.cpp index 9d10460b..7d67d4ac 100644 --- a/pokemodr/models/TrainerGroupModel.cpp +++ b/pokemodr/models/TrainerGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::TrainerGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Trainer", this, SLOT(addObject())); + menu->addAction("&Add Trainer", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/TrainerModel.cpp b/pokemodr/models/TrainerModel.cpp index 1d1aff54..23bb129d 100644 --- a/pokemodr/models/TrainerModel.cpp +++ b/pokemodr/models/TrainerModel.cpp @@ -61,7 +61,7 @@ QVariant Pokemodr::TrainerModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Trainer", this, SLOT(deleteSelf())); + menu->addAction("&Delete Trainer", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/TypeGroupModel.cpp b/pokemodr/models/TypeGroupModel.cpp index 3f2c3b58..eee1c80d 100644 --- a/pokemodr/models/TypeGroupModel.cpp +++ b/pokemodr/models/TypeGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::TypeGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Type", this, SLOT(addObject())); + menu->addAction("&Add Type", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/TypeModel.cpp b/pokemodr/models/TypeModel.cpp index 09ab1739..425fe8f7 100644 --- a/pokemodr/models/TypeModel.cpp +++ b/pokemodr/models/TypeModel.cpp @@ -61,7 +61,7 @@ QVariant Pokemodr::TypeModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Type", this, SLOT(deleteSelf())); + menu->addAction("&Delete Type", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); diff --git a/pokemodr/models/WeatherGroupModel.cpp b/pokemodr/models/WeatherGroupModel.cpp index 26f1c34e..42a29f37 100644 --- a/pokemodr/models/WeatherGroupModel.cpp +++ b/pokemodr/models/WeatherGroupModel.cpp @@ -47,7 +47,7 @@ QVariant Pokemodr::WeatherGroupModel::data(const int role) const if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Add Weather", this, SLOT(addObject())); + menu->addAction("&Add Weather", this, SLOT(addObject())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::GroupModel::data(role); diff --git a/pokemodr/models/WeatherModel.cpp b/pokemodr/models/WeatherModel.cpp index a524d3a4..c0470c9e 100644 --- a/pokemodr/models/WeatherModel.cpp +++ b/pokemodr/models/WeatherModel.cpp @@ -60,7 +60,7 @@ QVariant Pokemodr::WeatherModel::data(int role) const else if (role == Pokemodr::BaseModel::ContextMenuRole) { KMenu* menu = new KMenu; - menu->addAction("Delete Weather", this, SLOT(deleteSelf())); + menu->addAction("&Delete Weather", this, SLOT(deleteSelf())); return QVariant::fromValue(static_cast<void*>(menu)); } return Pokemodr::ObjectModel::data(role); |
