diff options
Diffstat (limited to 'pokemodr/ObjectUI.cpp')
| -rw-r--r-- | pokemodr/ObjectUI.cpp | 89 |
1 files changed, 9 insertions, 80 deletions
diff --git a/pokemodr/ObjectUI.cpp b/pokemodr/ObjectUI.cpp index 2cc7db2f..0cc5609b 100644 --- a/pokemodr/ObjectUI.cpp +++ b/pokemodr/ObjectUI.cpp @@ -18,33 +18,28 @@ // Header include #include "ObjectUI.h" +// Pokemodr includes +#include "ValidationDialog.h" + // Pokemod includes #include "../pokemod/Object.h" #include "../pokemod/Pokemod.h" -// Qt includes -#include <QtGui/QLabel> -#include <QtGui/QTreeWidget> -#include <QtGui/QVBoxLayout> - // KDE includes #include <KAction> -#include <KColorScheme> #include <KDialog> #include <KMenu> #include <KMessageBox> -#include <KProgressDialog> Pokemodr::ObjectUI::ObjectUI(QWidget* parent) : QWidget(parent), m_changed(false), m_object(NULL), - m_object_mod(NULL), - m_valTree(NULL) + m_object_mod(NULL) { setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(changed(bool)), SLOT(setChanged(bool))); - connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(contextMenu(const QPoint&))); + connect(this, SIGNAL(customContextMenuRequested(QPoint)), SLOT(contextMenu(QPoint))); } Pokemodr::ObjectUI::~ObjectUI() @@ -126,73 +121,7 @@ void Pokemodr::ObjectUI::contextMenu(const QPoint& 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)); + new ValidationDialog(m_object, this); } void Pokemodr::ObjectUI::setObjects(Pokemod::Object* original, Pokemod::Object* modified) @@ -201,9 +130,9 @@ void Pokemodr::ObjectUI::setObjects(Pokemod::Object* original, Pokemod::Object* m_object_mod = modified; connect(m_object_mod, SIGNAL(changed()), this, SIGNAL(changed())); connect(m_object_mod, SIGNAL(changed()), this, SLOT(setGui())); - connect(m_object_mod, SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(m_object_mod, SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); - connect(m_object_mod, SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); + connect(m_object_mod, SIGNAL(error(QString)), this, SLOT(setGui())); + connect(m_object_mod, SIGNAL(error(QString)), this, SLOT(errorMessage(QString))); + connect(m_object_mod, SIGNAL(warning(QString)), this, SLOT(warningMessage(QString))); init(); } |
