summaryrefslogtreecommitdiffstats
path: root/sigmodr/widgets/WeatherUI.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-02-24 03:02:23 -0500
committerBen Boeckel <MathStuf@gmail.com>2009-02-24 03:02:23 -0500
commit4453d587364e38c11f218c46db482f0b2ebe93ae (patch)
treec1035338d94298316b2de0eb88e6f39ceef86210 /sigmodr/widgets/WeatherUI.cpp
parentc076cd60d8dc8b4a8f9636e5b8ce828f9aee3f7c (diff)
downloadsigen-4453d587364e38c11f218c46db482f0b2ebe93ae.tar.gz
sigen-4453d587364e38c11f218c46db482f0b2ebe93ae.tar.xz
sigen-4453d587364e38c11f218c46db482f0b2ebe93ae.zip
Converted some classes to load from the resource instead of using inheritence for forms
Diffstat (limited to 'sigmodr/widgets/WeatherUI.cpp')
-rw-r--r--sigmodr/widgets/WeatherUI.cpp33
1 files changed, 25 insertions, 8 deletions
diff --git a/sigmodr/widgets/WeatherUI.cpp b/sigmodr/widgets/WeatherUI.cpp
index 1b03281f..38ab41a8 100644
--- a/sigmodr/widgets/WeatherUI.cpp
+++ b/sigmodr/widgets/WeatherUI.cpp
@@ -18,24 +18,41 @@
// Header include
#include "WeatherUI.h"
+// Sigmodr widget includes
+#include "ScriptWidget.h"
+
// Sigmod includes
#include <sigmod/Weather.h>
+// KDE includes
+#include <KLineEdit>
+
+// Qt includes
+#include <QtCore/QFile>
+#include <QtUiTools/QUiLoader>
+
Sigmodr::Widgets::WeatherUI::WeatherUI(Sigmod::Weather* weather, QWidget* parent) :
ObjectUI(parent)
{
- setupUi(this);
setObjects(weather, new Sigmod::Weather(*weather));
}
-Sigmodr::Widgets::WeatherUI::~WeatherUI()
+void Sigmodr::Widgets::WeatherUI::initGui()
{
+ QFile file(":/gui/weather.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(scriptChanged(Sigcore::Script)), this, SLOT(scriptChanged(Sigcore::Script)));
}
void Sigmodr::Widgets::WeatherUI::setGui()
{
- varName->setText(qobject_cast<Sigmod::Weather*>(modified())->name());
- varScript->setValue(qobject_cast<Sigmod::Weather*>(modified())->script());
+ ui_name->setText(qobject_cast<Sigmod::Weather*>(modified())->name());
+ ui_script->setValue(qobject_cast<Sigmod::Weather*>(modified())->script());
}
void Sigmodr::Widgets::WeatherUI::apply()
@@ -51,14 +68,14 @@ void Sigmodr::Widgets::WeatherUI::discard()
emit(changed(false));
}
-void Sigmodr::Widgets::WeatherUI::on_varName_textChanged(const QString& name)
+void Sigmodr::Widgets::WeatherUI::nameChanged(const QString& name)
{
- const int cursor = varName->cursorPosition();
+ const int cursor = ui_name->cursorPosition();
qobject_cast<Sigmod::Weather*>(modified())->setName(name);
- varName->setCursorPosition(cursor);
+ ui_name->setCursorPosition(cursor);
}
-void Sigmodr::Widgets::WeatherUI::on_varScript_valueChanged(const Sigcore::Script& script)
+void Sigmodr::Widgets::WeatherUI::scriptChanged(const Sigcore::Script& script)
{
qobject_cast<Sigmod::Weather*>(modified())->setScript(script);
}