on xenial help sign in
Range Input filter
bf829ccAlbert Astals Cid
qml/Dash/Filters/FilterRangeInput.qmlnew file+137
@@ -0,0 +1,137 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.4
18+import QtQuick.Layouts 1.1
19+import Ubuntu.Components 1.3
20+
21+/*! Range Input Filter Widget. */
22+
23+FilterWidget {
24+ id: root
25+
26+ implicitHeight: field1.height + units.gu(2)
27+
28+ function setFieldValue(field, hasValue, value) {
29+ if (hasValue) {
30+ // Need this othewise if we are on 4.5 and backspace instead of
31+ // having 4. in the text field we end up with 4 which is confusing
32+ if (field.text != value) {
33+ field.text = value;
34+ }
35+ } else {
36+ field.text = "";
37+ }
38+ }
39+
40+ Connections {
41+ target: widgetData
42+ onStartValueChanged: root.setFieldValue(field1, widgetData.hasStartValue, widgetData.startValue);
43+ onHasStartValueChanged: root.setFieldValue(field1, widgetData.hasStartValue, widgetData.startValue);
44+ onEndValueChanged: root.setFieldValue(field2, widgetData.hasEndValue, widgetData.endValue);
45+ onHasEndValueChanged: root.setFieldValue(field2, widgetData.hasEndValue, widgetData.endValue);
46+ }
47+
48+ onWidgetDataChanged: {
49+ if (widgetData) {
50+ root.setFieldValue(field1, widgetData.hasStartValue, widgetData.startValue);
51+ root.setFieldValue(field2, widgetData.hasEndValue, widgetData.endValue);
52+ } else {
53+ root.setFieldValue(field1, false, -1);
54+ root.setFieldValue(field2, false, -1);
55+ }
56+ }
57+
58+ RowLayout {
59+ anchors {
60+ fill: parent
61+ topMargin: units.gu(1)
62+ bottom: parent.bottom
63+ bottomMargin: units.gu(1)
64+ }
65+
66+ Item {
67+ Layout.fillWidth: true
68+ }
69+
70+ Label {
71+ text: widgetData.startPrefixLabel
72+ verticalAlignment: Text.AlignVCenter
73+ }
74+
75+ TextField {
76+ id: field1
77+ objectName: "startValueField"
78+ implicitWidth: units.gu(9)
79+ verticalAlignment: Text.AlignVCenter
80+ inputMethodHints: Qt.ImhFormattedNumbersOnly
81+ validator: DoubleValidator {
82+ notation: DoubleValidator.StandardNotation
83+ }
84+ onTextChanged: {
85+ if (text === "") widgetData.eraseStartValue();
86+ else widgetData.startValue = text;
87+ }
88+ }
89+
90+ Label {
91+ text: widgetData.startPostfixLabel
92+ verticalAlignment: Text.AlignVCenter
93+ }
94+
95+ Item {
96+ Layout.fillWidth: true
97+ }
98+
99+ Label {
100+ text: widgetData.centralLabel
101+ verticalAlignment: Text.AlignVCenter
102+ }
103+
104+ Item {
105+ Layout.fillWidth: true
106+ }
107+
108+ Label {
109+ text: widgetData.endPrefixLabel
110+ verticalAlignment: Text.AlignVCenter
111+ }
112+
113+ TextField {
114+ id: field2
115+ objectName: "endValueField"
116+ implicitWidth: units.gu(9)
117+ verticalAlignment: Text.AlignVCenter
118+ inputMethodHints: Qt.ImhFormattedNumbersOnly
119+ validator: DoubleValidator {
120+ notation: DoubleValidator.StandardNotation
121+ }
122+ onTextChanged: {
123+ if (text === "") widgetData.eraseEndValue();
124+ else widgetData.endValue = text;
125+ }
126+ }
127+
128+ Label {
129+ text: widgetData.endPostfixLabel
130+ verticalAlignment: Text.AlignVCenter
131+ }
132+
133+ Item {
134+ Layout.fillWidth: true
135+ }
136+ }
137+}
qml/Dash/Filters/FilterWidget.qml+1−1
@@ -23,7 +23,7 @@ Item {
23 property string widgetId
23 property string widgetId
24
24
25 //! Variable used to contain widget's data
25 //! Variable used to contain widget's data
26− property var widgetData
26+ property var widgetData: null
27
27
28 objectName: widgetId
28 objectName: widgetId
29}
29}
qml/Dash/Filters/FilterWidgetFactory.qml+1
@@ -37,6 +37,7 @@ Loader {
37 readonly property url widgetSource: {
37 readonly property url widgetSource: {
38 switch (widgetType) {
38 switch (widgetType) {
39 case Filters.OptionSelectorFilter: return "FilterOptionSelector.qml";
39 case Filters.OptionSelectorFilter: return "FilterOptionSelector.qml";
40+ case Filters.RangeInputFilter: return "FilterRangeInput.qml";
40 default: return "";
41 default: return "";
41 }
42 }
42 }
43 }
tests/mocks/Unity/CMakeLists.txt+2
@@ -32,6 +32,7 @@ set(UnityQML_SOURCES
32 fake_filters.cpp
32 fake_filters.cpp
33 fake_optionselectorfilter.cpp
33 fake_optionselectorfilter.cpp
34 fake_optionselectoroptions.cpp
34 fake_optionselectoroptions.cpp
35+ fake_rangeinputfilter.cpp
35 fake_unity_plugin.cpp
36 fake_unity_plugin.cpp
36 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h
37 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h
37 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/FilterBaseInterface.h
38 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/FilterBaseInterface.h
@@ -42,6 +43,7 @@ set(UnityQML_SOURCES
42 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewModelInterface.h
43 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewModelInterface.h
43 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewStackInterface.h
44 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewStackInterface.h
44 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewWidgetModelInterface.h
45 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewWidgetModelInterface.h
46+ ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/RangeInputFilterInterface.h
45 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ResultsModelInterface.h
47 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ResultsModelInterface.h
46 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopeInterface.h
48 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopeInterface.h
47 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopesInterface.h
49 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopesInterface.h
tests/mocks/Unity/fake_filters.cpp+41−4
@@ -17,6 +17,7 @@
17#include "fake_filters.h"
17#include "fake_filters.h"
18
18
19#include "fake_optionselectorfilter.h"
19#include "fake_optionselectorfilter.h"
20+#include "fake_rangeinputfilter.h"
20#include "fake_scope.h"
21#include "fake_scope.h"
21
22
22Filters::Filters(Scope* parent)
23Filters::Filters(Scope* parent)
@@ -24,11 +25,32 @@ Filters::Filters(Scope* parent)
24{
25{
25 addFilter(new FakeOptionSelectorFilter("OSF1", "Tag1", "Which Cake you like More", false, QStringList() << "cheese" << "carrot" << "chocolate", this));
26 addFilter(new FakeOptionSelectorFilter("OSF1", "Tag1", "Which Cake you like More", false, QStringList() << "cheese" << "carrot" << "chocolate", this));
26 addFilter(new FakeOptionSelectorFilter("OSF2", "Tag2", "Which Countries have you been to?", true, QStringList() << "Germany" << "UK" << "New Zealand", this));
27 addFilter(new FakeOptionSelectorFilter("OSF2", "Tag2", "Which Countries have you been to?", true, QStringList() << "Germany" << "UK" << "New Zealand", this));
28+
29+ FakeRangeInputFilter *rif = new FakeRangeInputFilter("RIF1", "Tag3", this);
30+ rif->setCentralLabel("to");
31+ rif->setStartPostfixLabel("m");
32+ rif->setEndPostfixLabel("m");
33+ addFilter(rif);
27}
34}
28
35
29−void Filters::addFilter(FakeOptionSelectorFilter *f)
36+void Filters::addFilter(unity::shell::scopes::FilterBaseInterface *f)
30{
37{
38+ switch (f->filterType()) {
39+ case FiltersInterface::OptionSelectorFilter: {
40+ FakeOptionSelectorFilter *osf = static_cast<FakeOptionSelectorFilter *>(f);
41+ connect(osf, &FakeOptionSelectorFilter::isActiveChanged, this, &Filters::activeFiltersCountChanged);
42+ }
43+ break;
44+
45+ case FiltersInterface::RangeInputFilter: {
46+ FakeRangeInputFilter *rif = static_cast<FakeRangeInputFilter *>(f);
31− connect(f, &FakeOptionSelectorFilter::isActiveChanged, this, &Filters::activeFiltersCountChanged);
47+ connect(rif, &FakeRangeInputFilter::isActiveChanged, this, &Filters::activeFiltersCountChanged);
48+ }
49+ break;
50+
51+ case Invalid:
52+ break;
53+ }
32 m_filters << f;
54 m_filters << f;
33}
55}
34
56
@@ -63,8 +85,23 @@ QVariant Filters::data(const QModelIndex &index, int role) const
63int Filters::activeFiltersCount() const
85int Filters::activeFiltersCount() const
64{
86{
65 int active = 0;
87 int active = 0;
66− Q_FOREACH(FakeOptionSelectorFilter *f, m_filters) {
88+ Q_FOREACH(unity::shell::scopes::FilterBaseInterface *f, m_filters) {
89+ switch (f->filterType()) {
90+ case FiltersInterface::OptionSelectorFilter: {
91+ FakeOptionSelectorFilter *osf = static_cast<FakeOptionSelectorFilter *>(f);
92+ if (osf->isActive()) ++active;
93+ }
94+ break;
95+
96+ case FiltersInterface::RangeInputFilter: {
97+ FakeRangeInputFilter *rif = static_cast<FakeRangeInputFilter *>(f);
67− if (f->isActive()) ++active;
98+ if (rif->isActive()) ++active;
99+ }
100+ break;
101+
102+ case Invalid:
103+ break;
104+ }
68 }
105 }
69 return active;
106 return active;
70}
107}
tests/mocks/Unity/fake_filters.h+3−3
@@ -18,9 +18,9 @@
18#define FAKE_FILTERS_H
18#define FAKE_FILTERS_H
19
19
20#include <unity/shell/scopes/FiltersInterface.h>
20#include <unity/shell/scopes/FiltersInterface.h>
21+#include <unity/shell/scopes/FilterBaseInterface.h>
21
22
22class Scope;
23class Scope;
23−class FakeOptionSelectorFilter;
24
24
25class Filters : public unity::shell::scopes::FiltersInterface
25class Filters : public unity::shell::scopes::FiltersInterface
26{
26{
@@ -38,9 +38,9 @@ Q_SIGNALS:
38 void activeFiltersCountChanged();
38 void activeFiltersCountChanged();
39
39
40private:
40private:
41− void addFilter(FakeOptionSelectorFilter* f);
41+ void addFilter(unity::shell::scopes::FilterBaseInterface* f);
42
42
43− QVector<FakeOptionSelectorFilter*> m_filters;
43+ QVector<unity::shell::scopes::FilterBaseInterface*> m_filters;
44};
44};
45
45
46#endif
46#endif
tests/mocks/Unity/fake_rangeinputfilter.cppnew file+156
@@ -0,0 +1,156 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "fake_rangeinputfilter.h"
18+
19+FakeRangeInputFilter::FakeRangeInputFilter(const QString &id, const QString &tag, QObject* parent)
20+ : unity::shell::scopes::RangeInputFilterInterface(parent),
21+ m_filterId(id),
22+ m_filterTag(tag),
23+ m_hasStartValue(false),
24+ m_hasEndValue(false),
25+ m_startValue(-1),
26+ m_endValue(-1)
27+{
28+ connect(this, &FakeRangeInputFilter::hasStartValueChanged, this, &FakeRangeInputFilter::isActiveChanged);
29+ connect(this, &FakeRangeInputFilter::hasEndValueChanged, this, &FakeRangeInputFilter::isActiveChanged);
30+}
31+
32+QString FakeRangeInputFilter::filterId() const
33+{
34+ return m_filterId;
35+}
36+
37+QString FakeRangeInputFilter::filterTag() const
38+{
39+ return m_filterTag;
40+}
41+
42+double FakeRangeInputFilter::startValue() const
43+{
44+ return m_startValue;
45+}
46+
47+double FakeRangeInputFilter::endValue() const
48+{
49+ return m_endValue;
50+}
51+
52+void FakeRangeInputFilter::setStartValue(double value)
53+{
54+ if (m_startValue != value) {
55+ m_startValue = value;
56+ Q_EMIT startValueChanged();
57+ }
58+ if (!m_hasStartValue) {
59+ m_hasStartValue = true;
60+ Q_EMIT hasStartValueChanged();
61+ }
62+}
63+
64+void FakeRangeInputFilter::setEndValue(double value)
65+{
66+ if (m_endValue != value) {
67+ m_endValue = value;
68+ Q_EMIT endValueChanged();
69+ }
70+ if (!m_hasEndValue) {
71+ m_hasEndValue = true;
72+ Q_EMIT hasEndValueChanged();
73+ }
74+}
75+
76+QString FakeRangeInputFilter::startPrefixLabel() const
77+{
78+ return m_startPrefixLabel;
79+}
80+
81+QString FakeRangeInputFilter::startPostfixLabel() const
82+{
83+ return m_startPostfixLabel;
84+}
85+
86+QString FakeRangeInputFilter::centralLabel() const
87+{
88+ return m_centralLabel;
89+}
90+
91+QString FakeRangeInputFilter::endPrefixLabel() const
92+{
93+ return m_endPrefixLabel;
94+}
95+
96+QString FakeRangeInputFilter::endPostfixLabel() const
97+{
98+ return m_endPostfixLabel;
99+}
100+
101+bool FakeRangeInputFilter::hasStartValue() const
102+{
103+ return m_hasStartValue;
104+}
105+
106+bool FakeRangeInputFilter::hasEndValue() const
107+{
108+ return m_hasEndValue;
109+}
110+
111+void FakeRangeInputFilter::eraseStartValue()
112+{
113+ m_hasStartValue = false;
114+ Q_EMIT hasStartValueChanged();
115+}
116+
117+void FakeRangeInputFilter::eraseEndValue()
118+{
119+ m_hasEndValue = false;
120+ Q_EMIT hasEndValueChanged();
121+}
122+
123+bool FakeRangeInputFilter::isActive() const
124+{
125+ return hasStartValue() && hasEndValue();
126+}
127+
128+void FakeRangeInputFilter::setStartPrefixLabel(const QString &startPrefixLabel)
129+{
130+ m_startPrefixLabel = startPrefixLabel;
131+ Q_EMIT startPrefixLabelChanged(m_startPrefixLabel);
132+}
133+
134+void FakeRangeInputFilter::setStartPostfixLabel(const QString &startPostfixLabel)
135+{
136+ m_startPostfixLabel = startPostfixLabel;
137+ Q_EMIT startPostfixLabelChanged(m_startPostfixLabel);
138+}
139+
140+void FakeRangeInputFilter::setCentralLabel(const QString &centralLabel)
141+{
142+ m_centralLabel = centralLabel;
143+ Q_EMIT centralLabelChanged(m_centralLabel);
144+}
145+
146+void FakeRangeInputFilter::setEndPrefixLabel(const QString &endPrefixLabel)
147+{
148+ m_endPrefixLabel = endPrefixLabel;
149+ Q_EMIT endPrefixLabelChanged(m_endPrefixLabel);
150+}
151+
152+void FakeRangeInputFilter::setEndPostfixLabel(const QString &endPostfixLabel)
153+{
154+ m_endPostfixLabel = endPostfixLabel;
155+ Q_EMIT endPostfixLabelChanged(m_endPostfixLabel);
156+}
tests/mocks/Unity/fake_rangeinputfilter.hnew file+76
@@ -0,0 +1,76 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef FAKE_RANGEINPUTFILTER_H
18+#define FAKE_RANGEINPUTFILTER_H
19+
20+#include <unity/shell/scopes/RangeInputFilterInterface.h>
21+
22+class FakeRangeInputFilter : public unity::shell::scopes::RangeInputFilterInterface
23+{
24+ Q_OBJECT
25+
26+public:
27+ FakeRangeInputFilter(const QString &id, const QString &tag, QObject* parent);
28+
29+ QString filterId() const override;
30+ QString filterTag() const override;
31+
32+ double startValue() const override;
33+ double endValue() const override;
34+ void setStartValue(double value) override;
35+ void setEndValue(double value) override;
36+ QString startPrefixLabel() const override;
37+ QString startPostfixLabel() const override;
38+ QString centralLabel() const override;
39+ QString endPrefixLabel() const override;
40+ QString endPostfixLabel() const override;
41+ bool hasStartValue() const override;
42+ bool hasEndValue() const override;
43+
44+ void eraseStartValue() override;
45+ void eraseEndValue() override;
46+
47+ // Not part of the iface, for mock/testing purposes
48+ bool isActive() const;
49+
50+ void setStartPrefixLabel(const QString &startPrefixLabel);
51+ void setStartPostfixLabel(const QString &startPostfixLabel);
52+ void setCentralLabel(const QString &centralLabel);
53+ void setEndPrefixLabel(const QString &endPrefixLabel);
54+ void setEndPostfixLabel(const QString &endPostfixLabel);
55+
56+Q_SIGNALS:
57+ void isActiveChanged();
58+
59+private:
60+ QString m_filterId;
61+ QString m_filterTag;
62+
63+ bool m_hasStartValue;
64+ bool m_hasEndValue;
65+
66+ double m_startValue;
67+ double m_endValue;
68+
69+ QString m_startPrefixLabel;
70+ QString m_startPostfixLabel;
71+ QString m_centralLabel;
72+ QString m_endPrefixLabel;
73+ QString m_endPostfixLabel;
74+};
75+
76+#endif
tests/qmltests/CMakeLists.txt+1
@@ -49,6 +49,7 @@ add_unity8_qmltest(Dash/Previews PreviewVideoPlayback)
49add_unity8_qmltest(Dash/Previews PreviewWidgetFactory)
49add_unity8_qmltest(Dash/Previews PreviewWidgetFactory)
50add_unity8_qmltest(Dash/Previews PreviewZoomableImage)
50add_unity8_qmltest(Dash/Previews PreviewZoomableImage)
51add_unity8_qmltest(Dash/Filters FilterOptionSelector)
51add_unity8_qmltest(Dash/Filters FilterOptionSelector)
52+add_unity8_qmltest(Dash/Filters FilterRangeInput)
52add_unity8_qmltest(Dash/Filters FilterWidgetFactory)
53add_unity8_qmltest(Dash/Filters FilterWidgetFactory)
53add_unity8_qmltest(Dash/ScopeSettings ScopeSettingBoolean)
54add_unity8_qmltest(Dash/ScopeSettings ScopeSettingBoolean)
54add_unity8_qmltest(Dash/ScopeSettings ScopeSettingList)
55add_unity8_qmltest(Dash/ScopeSettings ScopeSettingList)
tests/qmltests/Dash/Filters/tst_FilterRangeInput.qmlnew file+232
@@ -0,0 +1,232 @@
1+/*
2+ * Copyright 2015 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.4
18+import QtTest 1.0
19+import Ubuntu.Components 1.3
20+import "../../../../qml/Dash/Filters"
21+import Unity.Test 0.1 as UT
22+import Unity 0.2
23+
24+Rectangle {
25+ id: root
26+ width: units.gu(60)
27+ height: units.gu(80)
28+ color: theme.palette.selected.background
29+
30+ QtObject {
31+ id: widgetData1
32+
33+ property real startValue
34+ property real endValue
35+ property bool hasStartValue
36+ property bool hasEndValue
37+ property string startPrefixLabel
38+ property string startPostfixLabel
39+ property string centralLabel
40+ property string endPrefixLabel
41+ property string endPostfixLabel
42+
43+ onStartValueChanged: {
44+ hasStartValue = true;
45+ }
46+
47+ onEndValueChanged: {
48+ hasEndValue = true;
49+ }
50+
51+ function eraseStartValue() {
52+ hasStartValue = false;
53+ }
54+
55+ function eraseEndValue() {
56+ hasEndValue = false;
57+ }
58+ }
59+
60+ Component.onCompleted: {
61+ generateData();
62+ }
63+
64+ function generateData() {
65+ widgetData1.startValue = startValue.text;
66+ widgetData1.endValue = endValue.text;
67+ widgetData1.hasStartValue = startValueHasValue.checked;
68+ widgetData1.hasEndValue = endValueHasValue.checked;
69+ widgetData1.startPrefixLabel = startValuePrefixLabel.text;
70+ widgetData1.startPostfixLabel = startValuePostfixLabel.text;
71+ widgetData1.centralLabel = centralLabel.text;
72+ widgetData1.endPrefixLabel = endValuePrefixLabel.text;
73+ widgetData1.endPostfixLabel = endValuePostfixLabel.text;
74+
75+ factory.widgetData = widgetData1;
76+ }
77+
78+ FilterWidgetFactory {
79+ id: factory
80+ widgetId: "testRangeInputFilter"
81+ widgetType: Filters.RangeInputFilter
82+ anchors {
83+ left: parent.left
84+ right: parent.right
85+ }
86+ clip: true
87+ }
88+
89+ Column {
90+ anchors.top: factory.bottom
91+ width: parent.width
92+ spacing: units.gu(1)
93+
94+ Text {
95+ text: "Values"
96+ }
97+
98+ Row {
99+ spacing: units.gu(1)
100+ Text {
101+ text: "Start Value Prefix Label"
102+ verticalAlignment: Text.AlignVCenter
103+ height: parent.height
104+ }
105+ TextField {
106+ id: startValuePrefixLabel
107+ text: "Pre1"
108+ }
109+ }
110+
111+ Row {
112+ spacing: units.gu(1)
113+ Text {
114+ text: "Start Value Postfix Label"
115+ verticalAlignment: Text.AlignVCenter
116+ height: parent.height
117+ }
118+ TextField {
119+ id: startValuePostfixLabel
120+ text: "Post1"
121+ }
122+ }
123+
124+ Row {
125+ spacing: units.gu(1)
126+ Text {
127+ text: "Central Label"
128+ verticalAlignment: Text.AlignVCenter
129+ height: parent.height
130+ }
131+ TextField {
132+ id: centralLabel
133+ text: "to"
134+ }
135+ }
136+
137+ Row {
138+ spacing: units.gu(1)
139+ Text {
140+ text: "End Value Prefix Label"
141+ verticalAlignment: Text.AlignVCenter
142+ height: parent.height
143+ }
144+ TextField {
145+ id: endValuePrefixLabel
146+ text: "Pre2"
147+ }
148+ }
149+
150+ Row {
151+ spacing: units.gu(1)
152+ Text {
153+ text: "End Value Postfix Label"
154+ verticalAlignment: Text.AlignVCenter
155+ height: parent.height
156+ }
157+ TextField {
158+ id: endValuePostfixLabel
159+ text: "Post2"
160+ }
161+ }
162+
163+ Row {
164+ spacing: units.gu(1)
165+ Text {
166+ text: "Start Value"
167+ verticalAlignment: Text.AlignVCenter
168+ height: parent.height
169+ }
170+ TextField {
171+ id: startValue
172+ text: "-1"
173+ }
174+ CheckBox {
175+ id: startValueHasValue
176+ }
177+ }
178+
179+
180+ Row {
181+ spacing: units.gu(1)
182+ Text {
183+ text: "End Value"
184+ verticalAlignment: Text.AlignVCenter
185+ height: parent.height
186+ }
187+ TextField {
188+ id: endValue
189+ text: "5"
190+ }
191+ CheckBox {
192+ id: endValueHasValue
193+ checked: true
194+ }
195+ }
196+
197+ Button {
198+ text: "Set Values"
199+ onClicked: root.generateData();
200+ }
201+ }
202+
203+ UT.UnityTestCase {
204+ name: "FilterRangeInput"
205+ when: windowShown
206+
207+ function init() {
208+ root.generateData();
209+ }
210+
211+ function test_initialStatus() {
212+ var startValueField = findChild(factory, "startValueField");
213+ compare(startValueField.text, "");
214+
215+ var endValueField = findChild(factory, "endValueField");
216+ compare(endValueField.text, "5");
217+ }
218+
219+ function test_dotStays() {
220+ var startValueField = findChild(factory, "startValueField");
221+ compare(startValueField.text, "");
222+
223+ startValueField.text = "4.5";
224+ compare(startValueField.text, "4.5");
225+ compare(widgetData1.startValue, 4.5);
226+
227+ startValueField.text = "4.";
228+ compare(startValueField.text, "4.");
229+ compare(widgetData1.startValue, 4);
230+ }
231+ }
232+}