diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2009-01-10 19:00:07 -0500 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2009-01-10 19:00:07 -0500 |
| commit | b32ca560259df262e4d37a26333e281f8fa68730 (patch) | |
| tree | 66ac6132bb2ed06939e3d94efaa5e96c0a9a0dde | |
| parent | 9834ea2f8f8ea736c53d9686393f50ccc72a982b (diff) | |
Added a script variable to Time
| -rw-r--r-- | sigmod/Time.cpp | 11 | ||||
| -rw-r--r-- | sigmod/Time.h | 9 | ||||
| -rw-r--r-- | sigmod/test/TestTime.cpp | 18 | ||||
| -rw-r--r-- | sigmod/test/TestTime.h | 3 | ||||
| -rw-r--r-- | sigmodr/TimeUI.cpp | 8 | ||||
| -rw-r--r-- | sigmodr/TimeUI.h | 3 | ||||
| -rw-r--r-- | sigmodr/gui/time.ui | 26 | ||||
| -rw-r--r-- | sigscript/TimeWrapper.cpp | 7 | ||||
| -rw-r--r-- | sigscript/TimeWrapper.h | 3 |
9 files changed, 79 insertions, 9 deletions
diff --git a/sigmod/Time.cpp b/sigmod/Time.cpp index f0f34486..f4673758 100644 --- a/sigmod/Time.cpp +++ b/sigmod/Time.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2007-2008 Ben Boeckel <MathStuf@gmail.com> + * Copyright 2007-2009 Ben Boeckel <MathStuf@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,7 +32,8 @@ Sigmod::Time::Time(const Sigmod* parent, const int id) : Object(parent, id), m_name(""), m_hour(0), - m_minute(0) + m_minute(0), + m_script("", "") { } @@ -65,6 +66,7 @@ void Sigmod::Time::load(const QDomElement& xml) LOAD(name); LOAD(hour); LOAD(minute); + LOAD(script); } QDomElement Sigmod::Time::save() const @@ -73,20 +75,24 @@ QDomElement Sigmod::Time::save() const SAVE(name); SAVE(hour); SAVE(minute); + SAVE(script); return xml; } SETTER(Time, QString&, Name, name) SETTER(Time, int, Hour, hour) SETTER(Time, int, Minute, minute) +SETTER(Time, Sigcore::Script&, Script, script) GETTER(Time, QString, name) GETTER(Time, int, hour) GETTER(Time, int, minute) +GETTER(Time, Sigcore::Script, script) CHECK(Time, QString&, name) CHECK_BOUNDS(Time, int, hour, 0, 23) CHECK_BOUNDS(Time, int, minute, 0, 59) +CHECK(Time, Sigcore::Script&, script) Sigmod::Time& Sigmod::Time::operator=(const Time& rhs) { @@ -95,5 +101,6 @@ Sigmod::Time& Sigmod::Time::operator=(const Time& rhs) COPY(name); COPY(hour); COPY(minute); + COPY(script); return *this; } diff --git a/sigmod/Time.h b/sigmod/Time.h index 6027f128..224373cb 100644 --- a/sigmod/Time.h +++ b/sigmod/Time.h @@ -1,5 +1,5 @@ /* - * Copyright 2007-2008 Ben Boeckel <MathStuf@gmail.com> + * Copyright 2007-2009 Ben Boeckel <MathStuf@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,9 @@ #ifndef SIGMOD_TIME #define SIGMOD_TIME +// Sigcore includes +#include "../sigcore/Script.h" + // Sigmod includes #include "Object.h" @@ -44,20 +47,24 @@ class SIGMOD_EXPORT Time : public Object void setName(const QString& name); void setHour(const int hour); void setMinute(const int minutes); + void setScript(const Sigcore::Script& script); QString name() const; int hour() const; int minute() const; + Sigcore::Script script() const; bool nameCheck(const QString& name) const; bool hourCheck(const int hour) const; bool minuteCheck(const int minutes) const; + bool scriptCheck(const Sigcore::Script* script) const; Time& operator=(const Time& rhs); private: QString m_name; int m_hour; int m_minute; + Sigcore::Script m_script; }; } diff --git a/sigmod/test/TestTime.cpp b/sigmod/test/TestTime.cpp index f287060d..53519582 100644 --- a/sigmod/test/TestTime.cpp +++ b/sigmod/test/TestTime.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * Copyright 2008-2009 Ben Boeckel <MathStuf@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -90,6 +90,7 @@ void TestTime::loading() m_time1->setName("Bar"); m_time1->setHour(12); m_time1->setMinute(30); + m_time1->setScript(Sigcore::Script("python", "import os")); QVERIFY(file.open(QIODevice::ReadOnly)); QVERIFY(xml.setContent(&file)); @@ -98,6 +99,7 @@ void TestTime::loading() QCOMPARE(m_time1->name(), QString("Foo")); QCOMPARE(m_time1->hour(), 0); QCOMPARE(m_time1->minute(), 0); + QCOMPARE(m_time1->script(), Sigcore::Script()); } void TestTime::setName() @@ -159,6 +161,19 @@ void TestTime::setMinute() QCOMPARE(m_errors.size(), 2); } +void TestTime::setScript() +{ + m_time2->setScript(Sigcore::Script("python", "import os")); + m_time2->setScript(Sigcore::Script("python", "import os")); + + QCOMPARE(m_time2->script(), Sigcore::Script("python", "import os")); + + QCOMPARE(m_changedCount, 1); + + QCOMPARE(m_warnings.size(), 0); + QCOMPARE(m_errors.size(), 0); +} + void TestTime::assignment() { *m_time3 = *m_time2; @@ -166,6 +181,7 @@ void TestTime::assignment() QCOMPARE(m_time3->name(), QString("Foo")); QCOMPARE(m_time3->hour(), 12); QCOMPARE(m_time3->minute(), 30); + QCOMPARE(m_time1->script(), Sigcore::Script("python", "import os")); } QTEST_APPLESS_MAIN(TestTime) diff --git a/sigmod/test/TestTime.h b/sigmod/test/TestTime.h index 8cde0fdf..e40111e3 100644 --- a/sigmod/test/TestTime.h +++ b/sigmod/test/TestTime.h @@ -1,5 +1,5 @@ /* - * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * Copyright 2008-2009 Ben Boeckel <MathStuf@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,6 +42,7 @@ class TestTime : public TestSigmodObject void setName(); void setHour(); void setMinute(); + void setScript(); void assignment(); private: diff --git a/sigmodr/TimeUI.cpp b/sigmodr/TimeUI.cpp index a7a4d9b7..8af23087 100644 --- a/sigmodr/TimeUI.cpp +++ b/sigmodr/TimeUI.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * Copyright 2008-2009 Ben Boeckel <MathStuf@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,6 +36,7 @@ void Sigmodr::TimeUI::setGui() { varName->setText(qobject_cast<Sigmod::Time*>(modified())->name()); varTime->setTime(QTime(qobject_cast<Sigmod::Time*>(modified())->hour(), qobject_cast<Sigmod::Time*>(modified())->minute())); + varScript->setValue(qobject_cast<Sigmod::Time*>(modified())->script()); } void Sigmodr::TimeUI::apply() @@ -63,3 +64,8 @@ void Sigmodr::TimeUI::on_varTime_timeChanged(const QTime& time) qobject_cast<Sigmod::Time*>(modified())->setHour(time.hour()); qobject_cast<Sigmod::Time*>(modified())->setMinute(time.minute()); } + +void Sigmodr::TimeUI::on_varScript_valueChanged(const Sigcore::Script& script) +{ + qobject_cast<Sigmod::Time*>(modified())->setScript(script); +} diff --git a/sigmodr/TimeUI.h b/sigmodr/TimeUI.h index 6e1edf31..92955b27 100644 --- a/sigmodr/TimeUI.h +++ b/sigmodr/TimeUI.h @@ -1,5 +1,5 @@ /* - * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * Copyright 2008-2009 Ben Boeckel <MathStuf@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,6 +45,7 @@ class TimeUI : public ObjectUI, private Ui::formTime protected slots: void on_varName_textChanged(const QString& n); void on_varTime_timeChanged(const QTime& t); + void on_varScript_valueChanged(const Sigcore::Script& script); private slots: void setGui(); }; diff --git a/sigmodr/gui/time.ui b/sigmodr/gui/time.ui index 196b13fd..c934c6e9 100644 --- a/sigmodr/gui/time.ui +++ b/sigmodr/gui/time.ui @@ -59,6 +59,27 @@ </widget> </item> <item> + <widget class="QGroupBox" name="boxScript" > + <property name="title" > + <string>Script</string> + </property> + <property name="toolTip" > + <string>The script that gets triggered when the time changes</string> + </property> + <property name="statusTip" > + <string>The script that gets triggered when the time changes</string> + </property> + <property name="whatsThis" > + <string>The script that gets triggered when the time changes</string> + </property> + <layout class="QHBoxLayout" > + <item> + <widget class="Sigmodr::ScriptWidget" name="varScript" /> + </item> + </layout> + </widget> + </item> + <item> <spacer> <property name="orientation" > <enum>Qt::Vertical</enum> @@ -79,6 +100,11 @@ <extends>QLineEdit</extends> <header location="global" >KLineEdit</header> </customwidget> + <customwidget> + <class>Sigmodr::ScriptWidget</class> + <extends>QWidget</extends> + <header>ScriptWidget.h</header> + </customwidget> </customwidgets> <resources/> <connections/> diff --git a/sigscript/TimeWrapper.cpp b/sigscript/TimeWrapper.cpp index 36d64237..bf5c3220 100644 --- a/sigscript/TimeWrapper.cpp +++ b/sigscript/TimeWrapper.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * Copyright 2008-2009 Ben Boeckel <MathStuf@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,3 +49,8 @@ int Sigscript::TimeWrapper::TimeWrapper::minute() const { return m_time->minute(); } + +Sigcore::Script Sigscript::TimeWrapper::script() const +{ + return m_time->script(); +} diff --git a/sigscript/TimeWrapper.h b/sigscript/TimeWrapper.h index 33a159a5..564b68e9 100644 --- a/sigscript/TimeWrapper.h +++ b/sigscript/TimeWrapper.h @@ -1,5 +1,5 @@ /* - * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * Copyright 2008-2009 Ben Boeckel <MathStuf@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,6 +36,7 @@ class SIGSCRIPT_EXPORT TimeWrapper : public ObjectWrapper Q_SCRIPTABLE QString name() const; Q_SCRIPTABLE int hour() const; Q_SCRIPTABLE int minute() const; + Q_SCRIPTABLE Sigcore::Script script() const; private: TimeWrapper(const Sigmod::Time* time, SigmodWrapper* parent); TimeWrapper& operator=(const TimeWrapper& rhs); |
