summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-08-27 17:21:45 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-08-27 17:21:45 +0000
commite4630543dc17d2a42c27d192518fe3f54e7888bc (patch)
treeeff8bb9a4cbae15fa9989ce2111e0f1d074cd4d3
parent1fe11fc794783370d8a03a93979b27508278b113 (diff)
downloadsigen-e4630543dc17d2a42c27d192518fe3f54e7888bc.tar.gz
sigen-e4630543dc17d2a42c27d192518fe3f54e7888bc.tar.xz
sigen-e4630543dc17d2a42c27d192518fe3f54e7888bc.zip
[FIX] Added KNewStuff2 for Pokémod upload and download
[FIX] ValidationDialog can be used piecemeal now [ADD] Added KNewStuff configuration file [FIX] pokemodr-devel now includes the UI forms for use as well git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@247 6ecfd1a5-f3ed-3746-8530-beee90d26b22
-rw-r--r--CMakeLists.txt4
-rw-r--r--Changelog10
-rw-r--r--pokegen.spec1
-rw-r--r--pokemod.knsrc4
-rw-r--r--pokemodr/CMakeLists.txt8
-rw-r--r--pokemodr/ObjectUI.cpp7
-rw-r--r--pokemodr/ObjectUI.h4
-rw-r--r--pokemodr/PokemodrUI.cpp45
-rw-r--r--pokemodr/PokemodrUI.h3
-rw-r--r--pokemodr/ValidationDialog.cpp70
-rw-r--r--pokemodr/ValidationDialog.h12
-rw-r--r--pokemodr/pokemodrui.rc3
12 files changed, 148 insertions, 23 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d1e96311..d2cc67bd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,3 +77,7 @@ INSTALL(
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/${CMAKE_PROJECT_NAME}-${POKEGEN_VERSION}
COMPONENT documentation
)
+INSTALL(
+ FILES pokemod.knsrc
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/${KDE4_CONFIG_INSTALL_DIR}
+)
diff --git a/Changelog b/Changelog
index 75409942..02a94e55 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,14 @@
-----------------
+Rev: 247
+Date: 27 August 2008
+User: MathStuf
+-----------------
+[FIX] Added KNewStuff2 for Pokémod upload and download
+[FIX] ValidationDialog can be used piecemeal now
+[ADD] Added KNewStuff configuration file
+[FIX] pokemodr-devel now includes the UI forms for use as well
+
+-----------------
Rev: 246
Date: 27 August 2008
User: MathStuf
diff --git a/pokegen.spec b/pokegen.spec
index 36328a2b..d8484940 100644
--- a/pokegen.spec
+++ b/pokegen.spec
@@ -132,6 +132,7 @@ update-mime-database %{_datadir}/mime &> /dev/null || :
%{_datadir}/mimelnk/application/x-pokemod+xml.desktop
%{_datadir}/applications/pokemodr.desktop
%{_kde4_appsdir}/pokemodr/
+%{_kde4_configdir}/pokemod.knsrc
%files devel
diff --git a/pokemod.knsrc b/pokemod.knsrc
new file mode 100644
index 00000000..f8c8a0d9
--- /dev/null
+++ b/pokemod.knsrc
@@ -0,0 +1,4 @@
+[KNewStuff2]
+ProvidersUrl=http://pokegen.sf.net/pokemod_providers.xml
+TargetDir=pokegen/pokemods
+Uncompress=always
diff --git a/pokemodr/CMakeLists.txt b/pokemodr/CMakeLists.txt
index b08e03fc..fdc6f2e3 100644
--- a/pokemodr/CMakeLists.txt
+++ b/pokemodr/CMakeLists.txt
@@ -177,8 +177,8 @@ SET(pokemodr_MAIN_HEADERS
ValidationDialog.h
)
SET(pokemodr_MOC_HEADERS
- ${pokemodr_WIDGET_HEADERS}
${pokemodr_MAIN_HEADERS}
+ ${pokemodr_WIDGET_HEADERS}
${pokemodr_MODEL_HEADERS}
)
QT4_WRAP_CPP(pokemodr_MOC_SRCS ${pokemodr_MOC_HEADERS})
@@ -189,6 +189,7 @@ SET(pokemodr_HEADERS
SET(pokemodr_DEVEL
${pokemodr_MAIN_HEADERS}
${pokemodr_UI_HEADERS}
+ ${pokemodr_FORMS}
)
SET(pokemodr_WIDGET_SRCS
AbilityUI.cpp
@@ -299,8 +300,6 @@ SET(pokemodr_MODEL_SRCS
models/WeatherModel.cpp
)
SET(pokemodr_SRCS
- ${pokemodr_WIDGET_SRCS}
- ${pokemodr_MODEL_SRCS}
FractionWidget.cpp
PointWidget.cpp
PokemodTree.cpp
@@ -310,6 +309,8 @@ SET(pokemodr_SRCS
PokemodrUI.cpp
ScriptWidget.cpp
ValidationDialog.cpp
+ ${pokemodr_WIDGET_SRCS}
+ ${pokemodr_MODEL_SRCS}
)
SET(pokemodr_RC_FILES
pokemodrui.rc
@@ -335,6 +336,7 @@ TARGET_LINK_LIBRARIES(pokemodr
${KDE4_KIO_LIBRARY}
${KDE4_KFILE_LIBRARY}
${KDE4_KTEXTEDITOR_LIBRARY}
+ ${KDE4_KNEWSTUFF2_LIBRARY}
pokemod
)
diff --git a/pokemodr/ObjectUI.cpp b/pokemodr/ObjectUI.cpp
index 0cc5609b..834a31f5 100644
--- a/pokemodr/ObjectUI.cpp
+++ b/pokemodr/ObjectUI.cpp
@@ -34,6 +34,7 @@
Pokemodr::ObjectUI::ObjectUI(QWidget* parent) :
QWidget(parent),
m_changed(false),
+ m_validator(NULL),
m_object(NULL),
m_object_mod(NULL)
{
@@ -121,13 +122,17 @@ void Pokemodr::ObjectUI::contextMenu(const QPoint& pos)
void Pokemodr::ObjectUI::validate()
{
- new ValidationDialog(m_object, this);
+ apply();
+ m_validator->show();
}
void Pokemodr::ObjectUI::setObjects(Pokemod::Object* original, Pokemod::Object* modified)
{
m_object = original;
m_object_mod = modified;
+ if (m_validator)
+ delete m_validator;
+ m_validator = new ValidationDialog(m_object, this);
connect(m_object_mod, SIGNAL(changed()), this, SIGNAL(changed()));
connect(m_object_mod, SIGNAL(changed()), this, SLOT(setGui()));
connect(m_object_mod, SIGNAL(error(QString)), this, SLOT(setGui()));
diff --git a/pokemodr/ObjectUI.h b/pokemodr/ObjectUI.h
index f2259fee..7ccd9103 100644
--- a/pokemodr/ObjectUI.h
+++ b/pokemodr/ObjectUI.h
@@ -30,6 +30,8 @@ class Pokemod;
namespace Pokemodr
{
+class ValidationDialog;
+
class ObjectUI : public QWidget
{
Q_OBJECT
@@ -72,6 +74,8 @@ class ObjectUI : public QWidget
private:
bool m_changed;
+ ValidationDialog* m_validator;
+
Pokemod::Object* m_object;
Pokemod::Object* m_object_mod;
};
diff --git a/pokemodr/PokemodrUI.cpp b/pokemodr/PokemodrUI.cpp
index 1d6dfd8f..3f7532e8 100644
--- a/pokemodr/PokemodrUI.cpp
+++ b/pokemodr/PokemodrUI.cpp
@@ -51,6 +51,7 @@
#include <KUrl>
#include <KXMLGUIFactory>
#include <KIO/NetAccess>
+#include <KNS/Engine>
Pokemodr::PokemodrUI::PokemodrUI(QWidget* parent) :
KXmlGuiWindow(parent),
@@ -247,6 +248,39 @@ void Pokemodr::PokemodrUI::saveAsPokemod(const Pokemod::Pokemod* pokemod)
}
}
+void Pokemodr::PokemodrUI::downloadPokemod()
+{
+ KNS::Engine engine(this);
+ if (engine.init("pokemod.knsrc"))
+ engine.downloadDialogModal();
+}
+
+void Pokemodr::PokemodrUI::uploadPokemod()
+{
+ uploadPokemod(treePokemod->currentPokemod());
+}
+
+void Pokemodr::PokemodrUI::uploadPokemod(const Pokemod::Pokemod* pokemod)
+{
+ KUrl url = treePokemod->url(pokemod);
+ if (url == KUrl())
+ {
+ KMessageBox::error(this, QString::fromUtf8("The Pokémod has not been saved!"), "Upload error");
+ return;
+ }
+ if (!url.isLocalFile())
+ {
+ KMessageBox::error(this, QString::fromUtf8("The Pokémod is not local!"), "Upload error");
+ return;
+ }
+ KNS::Engine engine(this);
+ if (engine.init("pokemod.knsrc"))
+ {
+ if (!engine.uploadDialogModal(url.path()))
+ KMessageBox::error(this, QString::fromUtf8("An error occured attempting to upload!"), "Upload error");
+ }
+}
+
void Pokemodr::PokemodrUI::closePokemod()
{
closePokemod(treePokemod->currentPokemod());
@@ -395,6 +429,17 @@ void Pokemodr::PokemodrUI::setupActions()
KStandardAction::cut(actionCollection());
KStandardAction::copy(actionCollection());
KStandardAction::paste(actionCollection());
+ KAction* download = actionCollection()->addAction("download_pokemod");
+ download->setText(i18n("Download"));
+ download->setIcon(KIcon("arrow-down-double"));
+ download->setShortcut(Qt::CTRL + Qt::Key_D);
+ connect(download, SIGNAL(triggered()), this, SLOT(downloadPokemod()));
+ KAction* upload = actionCollection()->addAction("upload_pokemod");
+ upload->setText(i18n("Upload"));
+ upload->setIcon(KIcon("arrow-up-double"));
+ upload->setShortcut(Qt::CTRL + Qt::Key_U);
+ upload->setEnabled(false);
+ connect(upload, SIGNAL(triggered()), this, SLOT(uploadPokemod()));
KStandardAction::showMenubar(this, SLOT(toggleMenubar()), actionCollection());
KStandardAction::configureToolbars(this, SLOT(configureToolbars()), actionCollection());
createStandardStatusBarAction();
diff --git a/pokemodr/PokemodrUI.h b/pokemodr/PokemodrUI.h
index ce512ef2..d5663f94 100644
--- a/pokemodr/PokemodrUI.h
+++ b/pokemodr/PokemodrUI.h
@@ -63,6 +63,9 @@ class PokemodrUI : public KXmlGuiWindow, private Ui::formPokemodr
bool savePokemod(const Pokemod::Pokemod* pokemod, const KUrl& url);
void saveAsPokemod();
void saveAsPokemod(const Pokemod::Pokemod* pokemod);
+ void downloadPokemod();
+ void uploadPokemod();
+ void uploadPokemod(const Pokemod::Pokemod* pokemod);
void closePokemod();
bool closePokemod(const Pokemod::Pokemod* pokemod, const bool force = false);
bool closeAllPokemods(const bool force = false);
diff --git a/pokemodr/ValidationDialog.cpp b/pokemodr/ValidationDialog.cpp
index a9310c7e..f2b765ec 100644
--- a/pokemodr/ValidationDialog.cpp
+++ b/pokemodr/ValidationDialog.cpp
@@ -33,25 +33,57 @@
Pokemodr::ValidationDialog::ValidationDialog(Pokemod::Object* object, QWidget* parent) :
QWidget(parent),
- m_valTree(new QTreeWidget),
- m_errors(0),
- m_warnings(0)
+ m_processed(false),
+ m_object(object),
+ m_valTree(new QTreeWidget)
{
- KProgressDialog* progress = new KProgressDialog(this, "Validating", "Please wait");
- progress->progressBar()->setRange(0, 0);
- progress->setAllowCancel(false);
- progress->setModal(true);
- progress->show();
m_valTree->setHeaderHidden(true);
- m_parents.push(ObjectErrorCount(m_valTree->invisibleRootItem(), 0));
- connect(object, SIGNAL(valMessage(QString)), this, SLOT(addMessage(QString)));
- connect(object, SIGNAL(valWarning(QString)), this, SLOT(addWarning(QString)));
- connect(object, SIGNAL(valError(QString)), this, SLOT(addError(QString)));
- object->validate();
- delete progress;
- if (m_parents.top().second)
+ connect(m_object, SIGNAL(changed()), this, SLOT(objectChanged()));
+}
+
+int Pokemodr::ValidationDialog::errors() const
+{
+ return m_errors;
+}
+
+int Pokemodr::ValidationDialog::warnings() const
+{
+ return m_warnings;
+}
+
+void Pokemodr::ValidationDialog::process()
+{
+ if (!m_processed)
{
+ m_errors = 0;
+ m_warnings = 0;
+ m_valTree->clear();
+ m_parents.clear();
+ m_parents.push(ObjectErrorCount(m_valTree->invisibleRootItem(), 0));
+ KProgressDialog* progress = new KProgressDialog(this, "Validating", "Please wait");
+ progress->progressBar()->setRange(0, 0);
+ progress->setAllowCancel(false);
+ progress->setModal(true);
+ progress->show();
+ connect(m_object, SIGNAL(valMessage(QString)), this, SLOT(addMessage(QString)));
+ connect(m_object, SIGNAL(valWarning(QString)), this, SLOT(addWarning(QString)));
+ connect(m_object, SIGNAL(valError(QString)), this, SLOT(addError(QString)));
+ m_object->validate();
+ disconnect(m_object, SIGNAL(valMessage(QString)), this, SLOT(addMessage(QString)));
+ disconnect(m_object, SIGNAL(valWarning(QString)), this, SLOT(addWarning(QString)));
+ disconnect(m_object, SIGNAL(valError(QString)), this, SLOT(addError(QString)));
+ delete progress;
m_valTree->addTopLevelItem(m_parents.top().first);
+ }
+ m_processed = true;
+}
+
+void Pokemodr::ValidationDialog::show()
+{
+ if (!m_processed)
+ process();
+ if (m_parents.top().second)
+ {
KDialog* dialog = new KDialog(this);
dialog->setCaption("Validation Messages");
dialog->setButtons(KDialog::Ok);
@@ -65,9 +97,6 @@ Pokemodr::ValidationDialog::ValidationDialog(Pokemod::Object* object, QWidget* p
}
else
KMessageBox::information(this, "No messages", "Validation");
- disconnect(object, SIGNAL(valMessage(QString)), this, SLOT(addMessage(QString)));
- disconnect(object, SIGNAL(valWarning(QString)), this, SLOT(addWarning(QString)));
- disconnect(object, SIGNAL(valError(QString)), this, SLOT(addError(QString)));
}
void Pokemodr::ValidationDialog::insertMessage(const QString& msg, const QBrush& brush)
@@ -105,3 +134,8 @@ void Pokemodr::ValidationDialog::addWarning(const QString& msg)
insertMessage(msg, KStatefulBrush(KColorScheme::View, KColorScheme::NeutralBackground).brush(QPalette::Normal));
++m_warnings;
}
+
+void Pokemodr::ValidationDialog::objectChanged()
+{
+ m_processed = false;
+}
diff --git a/pokemodr/ValidationDialog.h b/pokemodr/ValidationDialog.h
index a0be6685..10a821ca 100644
--- a/pokemodr/ValidationDialog.h
+++ b/pokemodr/ValidationDialog.h
@@ -39,16 +39,26 @@ class ValidationDialog : public QWidget
Q_OBJECT
public:
+ typedef QPair<QTreeWidgetItem*, int> ObjectErrorCount;
+
ValidationDialog(Pokemod::Object* object, QWidget* parent);
- typedef QPair<QTreeWidgetItem*, int> ObjectErrorCount;
+ int errors() const;
+ int warnings() const;
protected:
void insertMessage(const QString& msg, const QBrush& brush);
public slots:
+ void process();
+ void show();
+
void addMessage(const QString& msg);
void addWarning(const QString& msg);
void addError(const QString& msg);
+ private slots:
+ void objectChanged();
private:
+ bool m_processed;
+ Pokemod::Object* m_object;
QStack<ObjectErrorCount> m_parents;
QTreeWidget* m_valTree;
int m_errors;
diff --git a/pokemodr/pokemodrui.rc b/pokemodr/pokemodrui.rc
index 8117ebbb..de073ac9 100644
--- a/pokemodr/pokemodrui.rc
+++ b/pokemodr/pokemodrui.rc
@@ -25,6 +25,9 @@
<text>&amp;Edit</text>
<DefineGroup name="edit_undo_merge" />
<Separator />
+ <Action name="download_pokemod" />
+ <Action name="upload_pokemod" />
+ <Separator />
<Action name="edit_cut" />
<Action name="edit_copy" />
<Action name="edit_paste" />