From 6ffec6899f70ecffe5f1584adbf680f43d6ea662 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 30 May 2008 20:38:35 +0000 Subject: [FIX] Fixed up some FractionWidget code [FIX] Got rid of more unneeded enumerations [FIX] MoveUI fixed up a bit git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@186 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- Changelog | 9 +++++++++ pokemod/Pokemod.cpp | 1 - pokemod/Pokemod.h | 12 ------------ pokemodr/FractionWidget.cpp | 33 +++++++++++++++------------------ pokemodr/FractionWidget.h | 3 +++ pokemodr/MoveUI.cpp | 2 ++ pokemodr/PokeModrUI.cpp | 2 +- pokemodr/gui/badge.ui | 8 ++++---- pokemodr/gui/item.ui | 2 +- pokemodr/gui/mapeffect.ui | 4 ++-- pokemodr/gui/nature.ui | 2 +- pokemodr/gui/pokemod.ui | 41 ++++++++++++++--------------------------- pokemodr/gui/species.ui | 26 +++++++++++++------------- pokemodr/gui/sprite.ui | 4 ++-- pokemodr/gui/tile.ui | 4 ++-- pokemodr/gui/trainer.ui | 4 ++-- pokemodr/gui/type.ui | 2 +- 17 files changed, 72 insertions(+), 87 deletions(-) diff --git a/Changelog b/Changelog index 2f5cd306..6815c631 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,12 @@ +----------------- +Rev: 186 +Date: 28 May 2008 +User: MathStuf +----------------- +[FIX] Fixed up some FractionWidget code +[FIX] Got rid of more unneeded enumerations +[FIX] MoveUI fixed up a bit + ----------------- Rev: 185 Date: 28 May 2008 diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp index dd342ce7..88d244dc 100644 --- a/pokemod/Pokemod.cpp +++ b/pokemod/Pokemod.cpp @@ -49,7 +49,6 @@ const QStringList Pokemod::StatRBYStr = QStringList() << "HP" << "Attack" << "Defense" << "Speed" << "Special" << "Special" << "Accuracy" << "Evasion"; const QStringList Pokemod::StatGSCStr = QStringList() << "HP" << "Attack" << "Defense" << "Speed" << "Special Attack" << "Special Defense" << "Accuracy" << "Evasion"; const QStringList Pokemod::DirectionStr = QStringList() << "Up" << "Down" << "Left" << "Right" << "None"; -const QStringList Pokemod::RelativeStr = QStringList() << "Less" << "Less or Equal" << "Greater or Equal" << "Greater" << "Equal" << "Not Equal"; Pokemod::Pokemod() : Object("Pokemod", NULL, 0), diff --git a/pokemod/Pokemod.h b/pokemod/Pokemod.h index 522f5a49..3ebcb746 100644 --- a/pokemod/Pokemod.h +++ b/pokemod/Pokemod.h @@ -90,18 +90,6 @@ class Pokemod : public Object }; static const QStringList DirectionStr; - enum Relative - { - REL_Less = 0, - REL_LessOrEqual = 1, - REL_GreaterOrEqual = 2, - REL_Greater = 3, - REL_Equal = 4, - REL_NotEqual = 5, - REL_End = 6 - }; - static const QStringList RelativeStr; - Pokemod(); Pokemod(const Pokemod& pokemod); Pokemod(const QDomElement& xml); diff --git a/pokemodr/FractionWidget.cpp b/pokemodr/FractionWidget.cpp index 371af316..1b9171f3 100644 --- a/pokemodr/FractionWidget.cpp +++ b/pokemodr/FractionWidget.cpp @@ -23,6 +23,7 @@ FractionWidget::FractionWidget(QWidget* parent, const Fraction& value) : { setupUi(this); connect(this, SIGNAL(valueChanged(const Fraction&)), SLOT(updateValue())); + connect(this, SIGNAL(valueChanged(const Fraction&)), SLOT(resetRanges())); setValue(value); } @@ -49,38 +50,34 @@ void FractionWidget::setValue(const Fraction& value) m_value = value; varDenominator->setValue(m_value.denominator()); varNumerator->setValue(m_value.numerator()); - if (-1 < m_behavior) - varNumerator->setMaximum(INT_MAX); - else - varNumerator->setMaximum(m_value.denominator()); - if (m_behavior < 1) - varDenominator->setMaximum(INT_MAX); - else - varDenominator->setMaximum(m_value.numerator()); emit(valueChanged(m_value)); } +void FractionWidget::updateValue() +{ + varValue->setText(QString::number(m_value, 'g', 7)); +} + void FractionWidget::on_varNumerator_valueChanged(const int numerator) { m_value.setNumerator(numerator); - if (m_behavior < 1) - varDenominator->setMaximum(INT_MAX); - else - varDenominator->setMaximum(m_value.numerator()); emit(valueChanged(m_value)); } void FractionWidget::on_varDenominator_valueChanged(const int denominator) { m_value.setDenominator(denominator); - if (-1 < m_behavior) - varNumerator->setMaximum(INT_MAX); - else - varNumerator->setMaximum(m_value.denominator()); emit(valueChanged(m_value)); } -void FractionWidget::updateValue() +void FractionWidget::resetRanges() { - varValue->setText(QString::number(m_value, 'g', 7)); + if (-1 < m_behavior) + varNumerator->setMaximum(INT_MAX); + else + varNumerator->setMaximum(m_value.denominator()); + if (m_behavior < 1) + varDenominator->setMaximum(INT_MAX); + else + varDenominator->setMaximum(m_value.numerator()); } diff --git a/pokemodr/FractionWidget.h b/pokemodr/FractionWidget.h index f20e8dc9..b989d1c3 100644 --- a/pokemodr/FractionWidget.h +++ b/pokemodr/FractionWidget.h @@ -30,6 +30,7 @@ class FractionWidget : public QWidget, private Ui::formFraction { Q_OBJECT + Q_PROPERTY(int behavior READ behavior WRITE setBehavior) public: FractionWidget(QWidget* parent, const Fraction& value = Fraction(1, 1)); @@ -46,6 +47,8 @@ class FractionWidget : public QWidget, private Ui::formFraction protected slots: void on_varNumerator_valueChanged(const int numerator); void on_varDenominator_valueChanged(const int denominator); + + void resetRanges(); private: int m_behavior; Fraction m_value; diff --git a/pokemodr/MoveUI.cpp b/pokemodr/MoveUI.cpp index 4ce9216c..921ec34b 100644 --- a/pokemodr/MoveUI.cpp +++ b/pokemodr/MoveUI.cpp @@ -109,7 +109,9 @@ void MoveUI::on_varOverworld_toggled(const bool overworld) void MoveUI::on_varDescription_textChanged(const QString& description) { + const int cursor = varDescription->cursorPosition(); static_cast(modified())->setDescription(description); + varName->setCursorPosition(cursor); } void MoveUI::on_varScript_valueChanged(const Script& script) diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp index fd1ed594..debb95bf 100644 --- a/pokemodr/PokeModrUI.cpp +++ b/pokemodr/PokeModrUI.cpp @@ -186,7 +186,7 @@ bool PokeModrUI::savePokemod(const Pokemod* pokemod, const KUrl& url) if (url.isLocalFile()) { QFile file(url.path()); - if (file.open(QIODevice::ReadWrite)) + if (file.open(QIODevice::WriteOnly)) { file.write(Object::xml(pokemod).toByteArray()); treePokemod->setDirty(pokemod, false); diff --git a/pokemodr/gui/badge.ui b/pokemodr/gui/badge.ui index 85ebad21..60568d39 100644 --- a/pokemodr/gui/badge.ui +++ b/pokemodr/gui/badge.ui @@ -51,7 +51,7 @@ Qt::Horizontal - + 20 40 @@ -74,7 +74,7 @@ Qt::Horizontal - + 20 40 @@ -97,7 +97,7 @@ Qt::Horizontal - + 20 40 @@ -132,7 +132,7 @@ The multiplier to the stat in-game battles - + 1 diff --git a/pokemodr/gui/item.ui b/pokemodr/gui/item.ui index 09113394..989fe497 100644 --- a/pokemodr/gui/item.ui +++ b/pokemodr/gui/item.ui @@ -102,7 +102,7 @@ Qt::Vertical - + 20 40 diff --git a/pokemodr/gui/mapeffect.ui b/pokemodr/gui/mapeffect.ui index a4c4375a..f5beb3bd 100644 --- a/pokemodr/gui/mapeffect.ui +++ b/pokemodr/gui/mapeffect.ui @@ -51,7 +51,7 @@ Qt::Horizontal - + 20 40 @@ -77,7 +77,7 @@ Qt::Horizontal - + 20 40 diff --git a/pokemodr/gui/nature.ui b/pokemodr/gui/nature.ui index 13271169..98aeb4f2 100644 --- a/pokemodr/gui/nature.ui +++ b/pokemodr/gui/nature.ui @@ -42,7 +42,7 @@ The multiplier of the stat - + 1 diff --git a/pokemodr/gui/pokemod.ui b/pokemodr/gui/pokemod.ui index 5e173383..7d54564f 100644 --- a/pokemodr/gui/pokemod.ui +++ b/pokemodr/gui/pokemod.ui @@ -103,7 +103,7 @@ Qt::Vertical - + 20 40 @@ -129,7 +129,7 @@ Qt::Horizontal - + 0 0 @@ -152,7 +152,7 @@ Qt::Horizontal - + 0 0 @@ -174,7 +174,7 @@ Qt::Horizontal - + 0 0 @@ -197,7 +197,7 @@ Qt::Horizontal - + 0 0 @@ -219,7 +219,7 @@ Qt::Horizontal - + 0 0 @@ -242,7 +242,7 @@ Qt::Horizontal - + 0 0 @@ -264,7 +264,7 @@ Qt::Horizontal - + 0 0 @@ -287,7 +287,7 @@ Qt::Horizontal - + 0 0 @@ -309,7 +309,7 @@ Qt::Horizontal - + 0 0 @@ -332,7 +332,7 @@ Qt::Horizontal - + 0 0 @@ -354,7 +354,7 @@ Qt::Horizontal - + 0 0 @@ -377,7 +377,7 @@ Qt::Horizontal - + 0 0 @@ -393,7 +393,7 @@ Qt::Vertical - + 20 40 @@ -430,19 +430,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/pokemodr/gui/species.ui b/pokemodr/gui/species.ui index 79dac9ba..c57fa0d3 100644 --- a/pokemodr/gui/species.ui +++ b/pokemodr/gui/species.ui @@ -103,7 +103,7 @@ Qt::Vertical - + 20 40 @@ -232,7 +232,7 @@ Qt::Vertical - + 20 40 @@ -332,7 +332,7 @@ Qt::Vertical - + 20 40 @@ -444,7 +444,7 @@ Qt::Vertical - + 20 40 @@ -470,7 +470,7 @@ Qt::Horizontal - + 0 0 @@ -493,7 +493,7 @@ Qt::Horizontal - + 0 0 @@ -516,7 +516,7 @@ Qt::Horizontal - + 0 0 @@ -538,7 +538,7 @@ Qt::Horizontal - + 0 0 @@ -561,7 +561,7 @@ Qt::Horizontal - + 0 0 @@ -584,7 +584,7 @@ Qt::Horizontal - + 0 0 @@ -606,7 +606,7 @@ Qt::Horizontal - + 0 0 @@ -629,7 +629,7 @@ Qt::Horizontal - + 0 0 @@ -645,7 +645,7 @@ Qt::Vertical - + 20 40 diff --git a/pokemodr/gui/sprite.ui b/pokemodr/gui/sprite.ui index 94630b76..b47564d0 100644 --- a/pokemodr/gui/sprite.ui +++ b/pokemodr/gui/sprite.ui @@ -32,7 +32,7 @@ Qt::Horizontal - + 20 40 @@ -48,7 +48,7 @@ Qt::Horizontal - + 20 40 diff --git a/pokemodr/gui/tile.ui b/pokemodr/gui/tile.ui index fbb52ba7..d078db82 100644 --- a/pokemodr/gui/tile.ui +++ b/pokemodr/gui/tile.ui @@ -32,7 +32,7 @@ Qt::Horizontal - + 20 40 @@ -58,7 +58,7 @@ Qt::Horizontal - + 20 40 diff --git a/pokemodr/gui/trainer.ui b/pokemodr/gui/trainer.ui index 7a6ef271..d95a72d5 100644 --- a/pokemodr/gui/trainer.ui +++ b/pokemodr/gui/trainer.ui @@ -45,7 +45,7 @@ Qt::Horizontal - + 20 40 @@ -71,7 +71,7 @@ Qt::Horizontal - + 20 40 diff --git a/pokemodr/gui/type.ui b/pokemodr/gui/type.ui index 8327759b..34bba667 100644 --- a/pokemodr/gui/type.ui +++ b/pokemodr/gui/type.ui @@ -32,7 +32,7 @@ Multiplier for species with this type for using a move of this type - + 1 -- cgit