aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlbasicapp/TimeExample2/timemodel.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qmlbasicapp/TimeExample2/timemodel.h')
-rw-r--r--tests/auto/qml/qmlbasicapp/TimeExample2/timemodel.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlbasicapp/TimeExample2/timemodel.h b/tests/auto/qml/qmlbasicapp/TimeExample2/timemodel.h
new file mode 100644
index 0000000000..b42542be31
--- /dev/null
+++ b/tests/auto/qml/qmlbasicapp/TimeExample2/timemodel.h
@@ -0,0 +1,38 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef TIMEMODEL_H
+#define TIMEMODEL_H
+
+#include <QtQml/qqml.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/qbasictimer.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qproperty.h>
+
+class TimeModel : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int hour READ hour BINDABLE hourBindable FINAL)
+ Q_PROPERTY(int minute READ minute BINDABLE minuteBindable FINAL)
+ QML_NAMED_ELEMENT(Time)
+
+public:
+ TimeModel(QObject *parent=nullptr);
+
+ int minute() const { return m_minute.value(); }
+ int hour() const { return m_hour.value(); }
+
+ QBindable<int> hourBindable() { return QBindable<int>(&m_hour); }
+ QBindable<int> minuteBindable() { return QBindable<int>(&m_minute); }
+
+private:
+ void timerEvent(QTimerEvent *) override;
+
+ QProperty<int> m_minute;
+ QProperty<int> m_hour;
+ QProperty<QTime> m_time;
+ QBasicTimer timer;
+};
+
+#endif // TIMEMODEL_H