summaryrefslogtreecommitdiffstats
path: root/sigmodr/widgets/CoinListUI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sigmodr/widgets/CoinListUI.cpp')
-rw-r--r--sigmodr/widgets/CoinListUI.cpp69
1 files changed, 36 insertions, 33 deletions
diff --git a/sigmodr/widgets/CoinListUI.cpp b/sigmodr/widgets/CoinListUI.cpp
index c4ee59a4..a2905d83 100644
--- a/sigmodr/widgets/CoinListUI.cpp
+++ b/sigmodr/widgets/CoinListUI.cpp
@@ -17,6 +17,7 @@
// Header include
#include "CoinListUI.h"
+#include "CoinListUI_p.h"
// Sigmodr core widget includes
#include <sigmodr/corewidgets/ScriptWidget.h>
@@ -28,64 +29,66 @@
// KDE includes
#include <KLineEdit>
-// Qt includes
-#include <QtCore/QFile>
-#include <QtGui/QVBoxLayout>
-#include <QtUiTools/QUiLoader>
-
using namespace Sigcore;
using namespace Sigmod;
using namespace Sigmodr::CoreWidgets;
using namespace Sigmodr::Widgets;
CoinListUI::CoinListUI(CoinList* coinList, QWidget* parent) :
- ObjectUI(parent)
+ ObjectUI(coinList, parent),
+ d(new Private(new CoinList(*coinList)))
{
- setObjects(coinList, new CoinList(*coinList));
+ setWidget(d->makeWidgets(this));
}
-void CoinListUI::initGui()
+void CoinListUI::apply()
{
- QFile file(":/gui/coinlist.ui");
- file.open(QFile::ReadOnly);
- QWidget *formWidget = QUiLoader().load(&file, this);
- file.close();
- ui_name = formWidget->findChild<KLineEdit*>("varName");
- ui_script = formWidget->findChild<ScriptWidget*>("varScript");
- connect(ui_name, SIGNAL(textChanged(QString)), this, SLOT(nameChanged(QString)));
- connect(ui_script, SIGNAL(valueChanged(Sigcore::Script)), this, SLOT(scriptChanged(Sigcore::Script)));
- QVBoxLayout* layout = new QVBoxLayout;
- layout->addWidget(formWidget);
- setLayout(layout);
+ *qobject_cast<CoinList*>(m_object) = *d->m_coinList;
+ ObjectUI::apply();
}
-void CoinListUI::setGui()
+void CoinListUI::discard()
{
- ui_name->setText(qobject_cast<CoinList*>(modified())->name());
- ui_script->setValue(qobject_cast<CoinList*>(modified())->script());
+ *d->m_coinList = *qobject_cast<CoinList*>(m_object);
+ d->resetGui();
+ ObjectUI::discard();
}
-void CoinListUI::apply()
+CoinListUI::Private::Private(CoinList* coinList) :
+ ObjectUIPrivate(coinList),
+ m_coinList(coinList)
{
- *qobject_cast<CoinList*>(original()) = *qobject_cast<CoinList*>(modified());
- emit(changed(false));
}
-void CoinListUI::discard()
+CoinListUI::Private::~Private()
+{
+ delete m_coinList;
+}
+
+QWidget* CoinListUI::Private::makeWidgets(ObjectUI* widget)
+{
+ QWidget *form = openUiFile(":/gui/coinlist.ui", widget);
+ ui_name = form->findChild<KLineEdit*>("varName");
+ ui_script = form->findChild<ScriptWidget*>("varScript");
+ connect(ui_name, SIGNAL(textChanged(QString)), this, SLOT(nameChanged(QString)));
+ connect(ui_script, SIGNAL(valueChanged(Sigcore::Script)), this, SLOT(scriptChanged(Sigcore::Script)));
+ return form;
+}
+
+void CoinListUI::Private::resetGui()
{
- *qobject_cast<CoinList*>(modified()) = *qobject_cast<CoinList*>(original());
- setGui();
- emit(changed(false));
+ ui_name->setText(m_coinList->name());
+ ui_script->setValue(m_coinList->script());
}
-void CoinListUI::nameChanged(const QString& name)
+void CoinListUI::Private::nameChanged(const QString& name)
{
const int cursor = ui_name->cursorPosition();
- qobject_cast<CoinList*>(modified())->setName(name);
+ m_coinList->setName(name);
ui_name->setCursorPosition(cursor);
}
-void CoinListUI::scriptChanged(const Script& script)
+void CoinListUI::Private::scriptChanged(const Script& script)
{
- qobject_cast<CoinList*>(modified())->setScript(script);
+ m_coinList->setScript(script);
}