on e4400a2 help sign in
unity8/tests/mocks/Unity/fake_rangeinputfilter.cpp
167 lines 3.9 kB history raw
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 */
17#include "fake_rangeinputfilter.h"
19FakeRangeInputFilter::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)
28 connect(this, &FakeRangeInputFilter::hasStartValueChanged, this, &FakeRangeInputFilter::isActiveChanged);
29 connect(this, &FakeRangeInputFilter::hasEndValueChanged, this, &FakeRangeInputFilter::isActiveChanged);
32QString FakeRangeInputFilter::filterId() const
34 return m_filterId;
37QString FakeRangeInputFilter::filterTag() const
39 return m_filterTag;
42QString FakeRangeInputFilter::title() const
44 return m_title;
47double FakeRangeInputFilter::startValue() const
49 return m_startValue;
52double FakeRangeInputFilter::endValue() const
54 return m_endValue;
57void FakeRangeInputFilter::setStartValue(double value)
59 if (m_startValue != value) {
60 m_startValue = value;
61 Q_EMIT startValueChanged();
62 }
63 if (!m_hasStartValue) {
64 m_hasStartValue = true;
65 Q_EMIT hasStartValueChanged();
66 }
69void FakeRangeInputFilter::setEndValue(double value)
71 if (m_endValue != value) {
72 m_endValue = value;
73 Q_EMIT endValueChanged();
74 }
75 if (!m_hasEndValue) {
76 m_hasEndValue = true;
77 Q_EMIT hasEndValueChanged();
78 }
81QString FakeRangeInputFilter::startPrefixLabel() const
83 return m_startPrefixLabel;
86QString FakeRangeInputFilter::startPostfixLabel() const
88 return m_startPostfixLabel;
91QString FakeRangeInputFilter::centralLabel() const
93 return m_centralLabel;
96QString FakeRangeInputFilter::endPrefixLabel() const
98 return m_endPrefixLabel;
101QString FakeRangeInputFilter::endPostfixLabel() const
103 return m_endPostfixLabel;
106bool FakeRangeInputFilter::hasStartValue() const
108 return m_hasStartValue;
111bool FakeRangeInputFilter::hasEndValue() const
113 return m_hasEndValue;
116void FakeRangeInputFilter::eraseStartValue()
118 m_hasStartValue = false;
119 Q_EMIT hasStartValueChanged();
122void FakeRangeInputFilter::eraseEndValue()
124 m_hasEndValue = false;
125 Q_EMIT hasEndValueChanged();
128bool FakeRangeInputFilter::isActive() const
130 return hasStartValue() && hasEndValue();
133void FakeRangeInputFilter::setTitle(const QString &title)
135 m_title = title;
136 Q_EMIT titleChanged();
139void FakeRangeInputFilter::setStartPrefixLabel(const QString &startPrefixLabel)
141 m_startPrefixLabel = startPrefixLabel;
142 Q_EMIT startPrefixLabelChanged();
145void FakeRangeInputFilter::setStartPostfixLabel(const QString &startPostfixLabel)
147 m_startPostfixLabel = startPostfixLabel;
148 Q_EMIT startPostfixLabelChanged();
151void FakeRangeInputFilter::setCentralLabel(const QString &centralLabel)
153 m_centralLabel = centralLabel;
154 Q_EMIT centralLabelChanged();
157void FakeRangeInputFilter::setEndPrefixLabel(const QString &endPrefixLabel)
159 m_endPrefixLabel = endPrefixLabel;
160 Q_EMIT endPrefixLabelChanged();
163void FakeRangeInputFilter::setEndPostfixLabel(const QString &endPostfixLabel)
165 m_endPostfixLabel = endPostfixLabel;
166 Q_EMIT endPostfixLabelChanged();