From 8cbe19a3e1845657ccdfddbd3c4fffcaadb9ff55 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 27 May 2008 14:04:01 +0000 Subject: [FIX] Item widget works better [FIX] FractionWidget value is updated at ctor [FIX] Non-script KTextEdit is now a KLineEdit [FIX] Rules not being set git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@179 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- Changelog | 10 ++++++++++ pokegen.pro | 2 +- pokemod/Object.h | 4 ++-- pokemod/Pokemod.cpp | 1 - pokemodr/AbilityUI.cpp | 8 +++----- pokemodr/AbilityUI.h | 2 +- pokemodr/FractionWidget.cpp | 6 +++--- pokemodr/ItemUI.cpp | 14 +++++++++----- pokemodr/ItemUI.h | 5 ++++- pokemodr/MoveUI.cpp | 9 ++++----- pokemodr/MoveUI.h | 2 +- pokemodr/PokeModrUI.cpp | 4 +++- pokemodr/PokemodTree.h | 2 +- pokemodr/PokemodUI.cpp | 8 +++----- pokemodr/PokemodUI.h | 2 +- pokemodr/ScriptWidget.cpp | 4 ++-- pokemodr/SpeciesUI.cpp | 8 +++----- pokemodr/SpeciesUI.h | 2 +- pokemodr/gui/ability.ui | 7 +------ pokemodr/gui/item.ui | 10 +--------- pokemodr/gui/move.ui | 10 +--------- pokemodr/gui/pokemod.ui | 10 +--------- pokemodr/gui/species.ui | 10 +--------- 23 files changed, 57 insertions(+), 83 deletions(-) diff --git a/Changelog b/Changelog index d43535c3..9070ca49 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,13 @@ +----------------- +Rev: 179 +Date: 27 May 2008 +User: MathStuf +----------------- +[FIX] Item widget works better +[FIX] FractionWidget value is updated at ctor +[FIX] Non-script KTextEdit is now a KLineEdit +[FIX] Rules not being set + ----------------- Rev: 178 Date: 26 May 2008 diff --git a/pokegen.pro b/pokegen.pro index d34c40f9..71555cb1 100755 --- a/pokegen.pro +++ b/pokegen.pro @@ -38,7 +38,7 @@ win32 { } mac { } else { rpm.target = rpm - rpm.commands = su -c "rpmbuild -ta releases/pokegen-$${VERSION}.tar.bz2" + rpm.commands = su -c \"rpmbuild -ta releases/pokegen-$${VERSION}.tar.bz2\" rpm.depends = distsrc ; deb.target = deb ; deb.commands = dpkg -b diff --git a/pokemod/Object.h b/pokemod/Object.h index 0a1cab43..503d562e 100644 --- a/pokemod/Object.h +++ b/pokemod/Object.h @@ -91,7 +91,7 @@ class Object : public QObject // 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 = new Rules(xml.firstChildElement("Rules"), this) +#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"); \ @@ -208,7 +208,7 @@ class Object : public QObject xml.appendChild(sub->save()) #define COPY(variable) m_##variable = rhs.m_##variable -#define COPY_Rules(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]) diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp index 6a76b081..414cb578 100644 --- a/pokemod/Pokemod.cpp +++ b/pokemod/Pokemod.cpp @@ -2440,7 +2440,6 @@ Pokemod& Pokemod::operator=(const Pokemod& rhs) void Pokemod::clear() { - delete m_rules; while (abilityCount()) deleteAbility(0); while (authorCount()) diff --git a/pokemodr/AbilityUI.cpp b/pokemodr/AbilityUI.cpp index 82992136..ff7d76c6 100644 --- a/pokemodr/AbilityUI.cpp +++ b/pokemodr/AbilityUI.cpp @@ -35,7 +35,7 @@ AbilityUI::~AbilityUI() void AbilityUI::setGui() { varName->setText(static_cast(modified())->name()); - varDescription->setPlainText(static_cast(modified())->description()); + varDescription->setText(static_cast(modified())->description()); varScript->setValue(static_cast(modified())->script()); } @@ -59,11 +59,9 @@ void AbilityUI::on_varName_textChanged(const QString& name) varName->setCursorPosition(cursor); } -void AbilityUI::on_varDescription_textChanged() +void AbilityUI::on_varDescription_textChanged(const QString& description) { - QTextCursor cursor = varDescription->textCursor(); - static_cast(modified())->setDescription(varDescription->toPlainText()); - varDescription->setTextCursor(cursor); + static_cast(modified())->setDescription(description); } void AbilityUI::on_varScript_valueChanged(const Script& script) diff --git a/pokemodr/AbilityUI.h b/pokemodr/AbilityUI.h index d9f39dcc..5825e1b2 100644 --- a/pokemodr/AbilityUI.h +++ b/pokemodr/AbilityUI.h @@ -39,7 +39,7 @@ class AbilityUI : public ObjectUI, private Ui::formAbility void discard(); protected slots: void on_varName_textChanged(const QString& name); - void on_varDescription_textChanged(); + void on_varDescription_textChanged(const QString& description); void on_varScript_valueChanged(const Script& script); private slots: void setGui(); diff --git a/pokemodr/FractionWidget.cpp b/pokemodr/FractionWidget.cpp index fa63641f..c1e818ec 100644 --- a/pokemodr/FractionWidget.cpp +++ b/pokemodr/FractionWidget.cpp @@ -20,11 +20,11 @@ FractionWidget::FractionWidget(QWidget* parent, const Fraction& value) : QWidget(parent), - m_behavior(-1), - m_value(value) + m_behavior(-1) { setupUi(this); connect(this, SIGNAL(valueChanged(const Fraction&)), SLOT(updateValue())); + setValue(value); } int FractionWidget::behavior() const @@ -48,7 +48,7 @@ void FractionWidget::setBehavior(const int behavior) void FractionWidget::setValue(const Fraction& value) { - if (m_value == value) + if ((m_value == value) && !varValue->text().isEmpty()) return; m_value = value; varDenominator->setValue(m_value.denominator()); diff --git a/pokemodr/ItemUI.cpp b/pokemodr/ItemUI.cpp index ca2d05b3..ceac9c03 100644 --- a/pokemodr/ItemUI.cpp +++ b/pokemodr/ItemUI.cpp @@ -52,7 +52,8 @@ void ItemUI::setGui() boxSellable->setChecked(static_cast(modified())->sellable() ? Qt::Checked : Qt::Unchecked); varType->setCurrentIndex(varType->findData(static_cast(modified())->type())); varPrice->setValue(static_cast(modified())->price()); - varDescription->setPlainText(static_cast(modified())->description()); + varDescription->setText(static_cast(modified())->description()); + varScript->setValue(static_cast(modified())->script()); } void ItemUI::apply() @@ -90,9 +91,12 @@ void ItemUI::on_varPrice_valueChanged(const int price) static_cast(modified())->setPrice(price); } -void ItemUI::on_varDescription_textChanged() +void ItemUI::on_varDescription_textChanged(const QString& description) { - QTextCursor cursor = varDescription->textCursor(); - static_cast(modified())->setDescription(varDescription->toPlainText()); - varDescription->setTextCursor(cursor); + static_cast(modified())->setDescription(description); +} + +void ItemUI::on_varScript_valueChanged(const Script& script) +{ + static_cast(modified())->setScript(script); } diff --git a/pokemodr/ItemUI.h b/pokemodr/ItemUI.h index 05ed904e..2a7ad62e 100644 --- a/pokemodr/ItemUI.h +++ b/pokemodr/ItemUI.h @@ -42,10 +42,13 @@ class ItemUI : public ObjectUI, private Ui::formItem void on_boxSellable_toggled(const bool sellable); void on_varType_activated(const int type); void on_varPrice_valueChanged(const int price); - void on_varDescription_textChanged(); + void on_varDescription_textChanged(const QString& description); + void on_varScript_valueChanged(const Script& script); private slots: void refreshGui(); void setGui(); + private: + QTextCursor m_cursor; }; #endif diff --git a/pokemodr/MoveUI.cpp b/pokemodr/MoveUI.cpp index e306cfbe..652b2491 100644 --- a/pokemodr/MoveUI.cpp +++ b/pokemodr/MoveUI.cpp @@ -64,7 +64,8 @@ void MoveUI::setGui() varNumTargets->setValue(static_cast(modified())->numTargets()); varSpecial->setChecked(static_cast(modified())->special() ? Qt::Checked : Qt::Unchecked); varOverworld->setChecked(static_cast(modified())->overworld() ? Qt::Checked : Qt::Unchecked); - varDescription->setPlainText(static_cast(modified())->description()); + varDescription->setText(static_cast(modified())->description()); + varScript->setValue(static_cast(modified())->script()); } void MoveUI::apply() @@ -132,11 +133,9 @@ void MoveUI::on_varOverworld_toggled(const bool overworld) static_cast(modified())->setOverworld(overworld); } -void MoveUI::on_varDescription_textChanged() +void MoveUI::on_varDescription_textChanged(const QString& description) { - QTextCursor cursor = varDescription->textCursor(); - static_cast(modified())->setDescription(varDescription->toPlainText()); - varDescription->setTextCursor(cursor); + static_cast(modified())->setDescription(description); } void MoveUI::on_varScript_valueChanged(const Script& script) diff --git a/pokemodr/MoveUI.h b/pokemodr/MoveUI.h index 53745c54..2ac707a5 100644 --- a/pokemodr/MoveUI.h +++ b/pokemodr/MoveUI.h @@ -48,7 +48,7 @@ class MoveUI : public ObjectUI, private Ui::formMove void on_varTargetChoice_activated(const int targetChoice); void on_varSpecial_toggled(const bool special); void on_varOverworld_toggled(const bool overworld); - void on_varDescription_textChanged(); + void on_varDescription_textChanged(const QString& description); void on_varScript_valueChanged(const Script& script); private slots: void initGui(); diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp index 7e007ce5..214eb673 100644 --- a/pokemodr/PokeModrUI.cpp +++ b/pokemodr/PokeModrUI.cpp @@ -102,7 +102,7 @@ void PokeModrUI::setDirty(const bool dirty) void PokeModrUI::newPokemod() { - treePokemod->addPokemod(new Pokemod()); + treePokemod->addPokemod(new Pokemod); } void PokeModrUI::openPokemod() @@ -325,6 +325,7 @@ void PokeModrUI::on_treePokemod_clicked(const QModelIndex& index) connect(widget, SIGNAL(changed(bool)), this, SLOT(setChangedTitle(bool))); connect(widget, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(buttonApply, SIGNAL(clicked()), widget, SLOT(apply())); + connect(buttonApply, SIGNAL(clicked()), treePokemod, SLOT(setDirty())); connect(buttonDiscard, SIGNAL(clicked()), widget, SLOT(discard())); setChangedTitle(false); formPanel->setWidget(widget); @@ -350,6 +351,7 @@ void PokeModrUI::on_treePokemod_customContextMenuRequested(const QPoint& positio paste->setEnabled(m_clipboard.doctype().name() == type); } menu->addAction(paste); + connect(menu, SIGNAL(triggered(QAction*)), treePokemod, SLOT(setDirty())); menu->popup(treePokemod->mapToGlobal(position)); } } diff --git a/pokemodr/PokemodTree.h b/pokemodr/PokemodTree.h index 07a312b1..cfdd151a 100644 --- a/pokemodr/PokemodTree.h +++ b/pokemodr/PokemodTree.h @@ -57,7 +57,7 @@ class PokemodTree : public QTreeView void setUrl(const Pokemod* pokemod, const KUrl& url); bool dirty(const Pokemod* pokemod) const; - void setDirty(const Pokemod*, const bool dirty); + void setDirty(const Pokemod* pokemod, const bool dirty); private slots: void setDirty(); private: diff --git a/pokemodr/PokemodUI.cpp b/pokemodr/PokemodUI.cpp index ddfd101a..88d7111b 100644 --- a/pokemodr/PokemodUI.cpp +++ b/pokemodr/PokemodUI.cpp @@ -68,7 +68,7 @@ void PokemodUI::setGui() const bool resetWarps = (static_cast(modified())->startMap() != m_lastMap); varTitle->setText(static_cast(modified())->title()); varVersion->setText(static_cast(modified())->version()); - varDescription->setPlainText(static_cast(modified())->description()); + varDescription->setText(static_cast(modified())->description()); varMap->setCurrentIndex(varMap->findData(static_cast(modified())->startMap())); m_lastMap = static_cast(modified())->startMap(); if (resetWarps) @@ -120,11 +120,9 @@ void PokemodUI::on_varVersion_textChanged(const QString& version) varVersion->setCursorPosition(cursor); } -void PokemodUI::on_varDescription_textChanged() +void PokemodUI::on_varDescription_textChanged(const QString& description) { - QTextCursor cursor = varDescription->textCursor(); - static_cast(modified())->setDescription(varDescription->toPlainText()); - varDescription->setTextCursor(cursor); + static_cast(modified())->setDescription(description); } void PokemodUI::on_varMap_activated(const int map) diff --git a/pokemodr/PokemodUI.h b/pokemodr/PokemodUI.h index 63038a0b..12f4f913 100644 --- a/pokemodr/PokemodUI.h +++ b/pokemodr/PokemodUI.h @@ -39,7 +39,7 @@ class PokemodUI : public ObjectUI, private Ui::formPokemod protected slots: void on_varTitle_textChanged(const QString& title); void on_varVersion_textChanged(const QString& version); - void on_varDescription_textChanged(); + void on_varDescription_textChanged(const QString& description); void on_varMap_activated(const int map); void on_varWarp_activated(const int warp); void on_varWalkSkin_pressed(); diff --git a/pokemodr/ScriptWidget.cpp b/pokemodr/ScriptWidget.cpp index addb14ba..cdde5c83 100644 --- a/pokemodr/ScriptWidget.cpp +++ b/pokemodr/ScriptWidget.cpp @@ -39,7 +39,9 @@ void ScriptWidget::setValue(const Script& value) return; m_value = value; varInterpreter->setEditText(m_value.interpreter()); + QTextCursor cursor = varScript->textCursor(); varScript->setPlainText(m_value.script()); + varScript->setTextCursor(cursor); emit(valueChanged(m_value)); } @@ -51,8 +53,6 @@ void ScriptWidget::on_varInterpreter_activated(const QString& interpreter) void ScriptWidget::on_varScript_textChanged() { - QTextCursor cursor = varScript->textCursor(); m_value.setScript(varScript->toPlainText()); - varScript->setTextCursor(cursor); emit(valueChanged(m_value)); } diff --git a/pokemodr/SpeciesUI.cpp b/pokemodr/SpeciesUI.cpp index c5f5b4fe..4ba1bc3e 100644 --- a/pokemodr/SpeciesUI.cpp +++ b/pokemodr/SpeciesUI.cpp @@ -112,7 +112,7 @@ void SpeciesUI::setGui() varWeight->setValue(static_cast(modified())->weight()); varHeightFeet->setValue(static_cast(modified())->heightFeet()); varHeightInches->setValue(static_cast(modified())->heightInches()); - varPokedexEntry->setPlainText(static_cast(modified())->pokedexEntry()); + varPokedexEntry->setText(static_cast(modified())->pokedexEntry()); varMaleFront->setIcon(static_cast(modified())->frontMaleSprite()); varMaleBack->setIcon(static_cast(modified())->backMaleSprite()); if (pokemod()->rules()->genderAllowed()) @@ -213,11 +213,9 @@ void SpeciesUI::on_varHeightInches_valueChanged(const int inches) static_cast(modified())->setHeightInches(inches); } -void SpeciesUI::on_varPokedexEntry_textChanged() +void SpeciesUI::on_varPokedexEntry_textChanged(const QString& pokedexEntry) { - QTextCursor cursor = varPokedexEntry->textCursor(); - static_cast(modified())->setPokedexEntry(varPokedexEntry->toPlainText()); - varPokedexEntry->setTextCursor(cursor); + static_cast(modified())->setPokedexEntry(pokedexEntry); } void SpeciesUI::on_varMaleFront_pressed() diff --git a/pokemodr/SpeciesUI.h b/pokemodr/SpeciesUI.h index 53a8877b..dd4aafe8 100644 --- a/pokemodr/SpeciesUI.h +++ b/pokemodr/SpeciesUI.h @@ -50,7 +50,7 @@ class SpeciesUI : public ObjectUI, private Ui::formSpecies void on_varWeight_valueChanged(const int weight); void on_varHeightFeet_valueChanged(const int feet); void on_varHeightInches_valueChanged(const int inches); - void on_varPokedexEntry_textChanged(); + void on_varPokedexEntry_textChanged(const QString& pokedexEntry); void on_varMaleFront_pressed(); void on_varMaleBack_pressed(); void on_varFemaleFront_pressed(); diff --git a/pokemodr/gui/ability.ui b/pokemodr/gui/ability.ui index 3a82d380..12f9cee6 100644 --- a/pokemodr/gui/ability.ui +++ b/pokemodr/gui/ability.ui @@ -28,7 +28,7 @@ - + @@ -53,11 +53,6 @@ QLineEdit
klineedit.h
- - KTextEdit - QTextEdit -
ktextedit.h
-
ScriptWidget QWidget diff --git a/pokemodr/gui/item.ui b/pokemodr/gui/item.ui index e3732693..09113394 100644 --- a/pokemodr/gui/item.ui +++ b/pokemodr/gui/item.ui @@ -76,13 +76,10 @@ - + Description of the item - - false - @@ -131,11 +128,6 @@ QLineEdit
klineedit.h
- - KTextEdit - QTextEdit -
ktextedit.h
-
ScriptWidget QWidget diff --git a/pokemodr/gui/move.ui b/pokemodr/gui/move.ui index 856aca37..3d33571c 100644 --- a/pokemodr/gui/move.ui +++ b/pokemodr/gui/move.ui @@ -175,13 +175,10 @@ - + Description of the move - - false - @@ -217,11 +214,6 @@ QLineEdit
klineedit.h
- - KTextEdit - QTextEdit -
ktextedit.h
-
FractionWidget QWidget diff --git a/pokemodr/gui/pokemod.ui b/pokemodr/gui/pokemod.ui index 1660f9e8..30463316 100644 --- a/pokemodr/gui/pokemod.ui +++ b/pokemodr/gui/pokemod.ui @@ -57,13 +57,10 @@ - + Description of the PokéMod - - false - @@ -468,11 +465,6 @@
ktabwidget.h
1
- - KTextEdit - QTextEdit -
ktextedit.h
-
FractionWidget QWidget diff --git a/pokemodr/gui/species.ui b/pokemodr/gui/species.ui index 30d25a07..79dac9ba 100644 --- a/pokemodr/gui/species.ui +++ b/pokemodr/gui/species.ui @@ -318,13 +318,10 @@ - + Information provided in the PokéDex about the species - - false - @@ -695,11 +692,6 @@
ktabwidget.h
1
- - KTextEdit - QTextEdit -
ktextedit.h
-
FractionWidget QWidget -- cgit