summaryrefslogtreecommitdiffstats
path: root/sigmodr/widgets/ObjectUI.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-03-01 15:42:07 -0500
committerBen Boeckel <MathStuf@gmail.com>2009-03-01 15:42:07 -0500
commita75acf8bcd1ff96d3dbb978b292efda61163255c (patch)
treedbedd34d9e685fca163c7fb500976e9460f92fa5 /sigmodr/widgets/ObjectUI.cpp
parent3301f60ce09331d688ba367011b1a552ef6e1393 (diff)
downloadsigen-a75acf8bcd1ff96d3dbb978b292efda61163255c.tar.gz
sigen-a75acf8bcd1ff96d3dbb978b292efda61163255c.tar.xz
sigen-a75acf8bcd1ff96d3dbb978b292efda61163255c.zip
Split out ObjectUIPrivate from ObjectUI
Diffstat (limited to 'sigmodr/widgets/ObjectUI.cpp')
-rw-r--r--sigmodr/widgets/ObjectUI.cpp85
1 files changed, 21 insertions, 64 deletions
diff --git a/sigmodr/widgets/ObjectUI.cpp b/sigmodr/widgets/ObjectUI.cpp
index 59be2321..c26a6b73 100644
--- a/sigmodr/widgets/ObjectUI.cpp
+++ b/sigmodr/widgets/ObjectUI.cpp
@@ -22,91 +22,59 @@
#include "ValidationDialog.h"
// Sigmod includes
-#include <sigmod/Game.h>
#include <sigmod/Object.h>
// KDE includes
#include <KAction>
-#include <KDialog>
#include <KMenu>
-#include <KMessageBox>
+
+// KDE includes
+#include <QtGui/QVBoxLayout>
using namespace Sigmod;
using namespace Sigmodr::Widgets;
-ObjectUI::ObjectUI(QWidget* parent) :
+ObjectUI::ObjectUI(Object* object, QWidget* parent) :
QWidget(parent),
- m_changed(false),
- m_validator(NULL),
- m_object(NULL),
- m_object_mod(NULL)
+ m_object(object),
+ m_validator(NULL)
{
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(changed(bool)), SLOT(setChanged(bool)));
connect(this, SIGNAL(customContextMenuRequested(QPoint)), SLOT(contextMenu(QPoint)));
+ emit(changed(false));
}
ObjectUI::~ObjectUI()
{
- delete m_object_mod;
-}
-
-void ObjectUI::reload()
-{
- refreshGui();
- setGui();
-}
-
-bool ObjectUI::isChanged() const
-{
- return m_changed;
}
-const Game* ObjectUI::game() const
-{
- return m_object->game();
-}
-
-const Object* ObjectUI::original() const
+const Object* ObjectUI::object() const
{
return m_object;
}
-Object* ObjectUI::original()
+Object* ObjectUI::object()
{
return m_object;
}
-const Object* ObjectUI::modified() const
-{
- return m_object_mod;
-}
-
-Object* ObjectUI::modified()
+void ObjectUI::apply()
{
- return m_object_mod;
+ emit(changed(false));
+ emit(saved());
}
-void ObjectUI::setObjects(Object* original, Object* modified)
+void ObjectUI::discard()
{
- 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()));
- connect(m_object_mod, SIGNAL(error(QString)), this, SLOT(errorMessage(QString)));
- connect(m_object_mod, SIGNAL(warning(QString)), this, SLOT(warningMessage(QString)));
- init();
+ emit(changed(false));
}
-void ObjectUI::init()
+void ObjectUI::setWidget(QWidget* widget)
{
- initGui();
- reload();
- emit(changed(false));
+ QVBoxLayout* layout = new QVBoxLayout;
+ layout->addWidget(widget);
+ setLayout(layout);
}
void ObjectUI::setChanged(const bool changed)
@@ -114,20 +82,6 @@ void ObjectUI::setChanged(const bool changed)
m_changed = changed;
}
-void ObjectUI::errorMessage(const QString& message)
-{
- KMessageBox::error(this, message, "Error");
-}
-
-void ObjectUI::warningMessage(const QString& message)
-{
- KMessageBox::warningContinueCancel(this, message, "Warning");
-}
-
-void ObjectUI::refreshGui()
-{
-}
-
void ObjectUI::contextMenu(const QPoint& pos)
{
KMenu* menu = new KMenu;
@@ -145,5 +99,8 @@ void ObjectUI::validate()
{
if (m_changed)
apply();
+ if (m_validator)
+ delete m_validator;
+ m_validator = new ValidationDialog(m_object, this);
m_validator->show();
}