summaryrefslogtreecommitdiffstats
path: root/sigmodr/widgets/MapWildListUI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sigmodr/widgets/MapWildListUI.cpp')
-rw-r--r--sigmodr/widgets/MapWildListUI.cpp59
1 files changed, 31 insertions, 28 deletions
diff --git a/sigmodr/widgets/MapWildListUI.cpp b/sigmodr/widgets/MapWildListUI.cpp
index cd211819..1cfef19f 100644
--- a/sigmodr/widgets/MapWildListUI.cpp
+++ b/sigmodr/widgets/MapWildListUI.cpp
@@ -17,6 +17,7 @@
// Header include
#include "MapWildListUI.h"
+#include "MapWildListUI_p.h"
// Sigmod includes
#include <sigmod/MapWildList.h>
@@ -24,54 +25,56 @@
// KDE includes
#include <KLineEdit>
-// Qt includes
-#include <QtCore/QFile>
-#include <QtGui/QVBoxLayout>
-#include <QtUiTools/QUiLoader>
-
using namespace Sigmod;
using namespace Sigmodr::Widgets;
MapWildListUI::MapWildListUI(MapWildList* wildList, QWidget* parent) :
- ObjectUI(parent)
+ ObjectUI(wildList, parent),
+ d(new Private(new MapWildList(*wildList)))
{
- setObjects(wildList, new MapWildList(*wildList));
+ setWidget(d->makeWidgets(this));
}
-void MapWildListUI::initGui()
+void MapWildListUI::apply()
{
- QFile file(":/gui/mapwildlist.ui");
- file.open(QFile::ReadOnly);
- QWidget *formWidget = QUiLoader().load(&file, this);
- file.close();
- ui_name = formWidget->findChild<KLineEdit*>("varName");
- connect(ui_name, SIGNAL(textChanged(QString)), this, SLOT(nameChanged(QString)));
- QVBoxLayout* layout = new QVBoxLayout;
- layout->addWidget(formWidget);
- setLayout(layout);
+ *qobject_cast<MapWildList*>(m_object) = *d->m_wildList;
+ ObjectUI::apply();
}
-void MapWildListUI::setGui()
+void MapWildListUI::discard()
{
- ui_name->setText(qobject_cast<MapWildList*>(modified())->name());
+ *d->m_wildList = *qobject_cast<MapWildList*>(m_object);
+ d->resetGui();
+ ObjectUI::discard();
}
-void MapWildListUI::apply()
+MapWildListUI::Private::Private(MapWildList* wildList) :
+ ObjectUIPrivate(wildList),
+ m_wildList(wildList)
{
- *qobject_cast<MapWildList*>(original()) = *qobject_cast<MapWildList*>(modified());
- emit(changed(false));
}
-void MapWildListUI::discard()
+MapWildListUI::Private::~Private()
+{
+ delete m_wildList;
+}
+
+QWidget* MapWildListUI::Private::makeWidgets(ObjectUI* widget)
+{
+ QWidget *form = openUiFile(":/gui/mapwildlist.ui", widget);
+ ui_name = form->findChild<KLineEdit*>("varName");
+ connect(ui_name, SIGNAL(textChanged(QString)), this, SLOT(nameChanged(QString)));
+ return form;
+}
+
+void MapWildListUI::Private::resetGui()
{
- *qobject_cast<MapWildList*>(modified()) = *qobject_cast<MapWildList*>(original());
- setGui();
- emit(changed(false));
+ ui_name->setText(m_wildList->name());
}
-void MapWildListUI::nameChanged(const QString& name)
+void MapWildListUI::Private::nameChanged(const QString& name)
{
const int cursor = ui_name->cursorPosition();
- qobject_cast<MapWildList*>(modified())->setName(name);
+ m_wildList->setName(name);
ui_name->setCursorPosition(cursor);
}