PdQmlWidgets  2.0.0
VectorVariant.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * Copyright (C) 2018 Wilhelm Hagemeister <hm@igh.de>
4  * Florian Pose <fp@igh.de>
5  *
6  * This file is part of the PdQmlWidgets library.
7  *
8  * The PdQmlWidgets library is free software: you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License as
10  * published by the Free Software Foundation, either version 3 of the License,
11  * or (at your option) any later version.
12  *
13  * The PdQmlWidgets library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with the PdQmlWidgets Library. If not, see
20  * <http://www.gnu.org/licenses/>.
21  *
22  ****************************************************************************/
23 
24 #ifndef PD_VECTORVARIANT_H
25 #define PD_VECTORVARIANT_H
26 
27 #include <QtPdCom1/Process.h>
28 
29 #include <QObject>
30 #include <QVariant>
31 
32 #include <chrono>
33 
34 #if QT_VERSION < 0x050000
35 #define Q_NULLPTR NULL
36 #endif
37 
38 namespace PdQmlWidgets {
39 
40 /****************************************************************************/
41 
44 class Q_DECL_EXPORT VectorVariant:
45  public QObject
46 {
47  Q_OBJECT
48 
51  Q_PROPERTY(QString path READ getPath WRITE setPath NOTIFY pathChanged)
52 
53 
59  Q_PROPERTY(QVariant connection READ getConnection WRITE setConnection
60  NOTIFY connectionUpdated)
61 
62 
64  Q_PROPERTY(bool connected READ getDataPresent NOTIFY dataPresentChanged)
65 
68  Q_PROPERTY(QVariant value READ getValue WRITE setValue
69  NOTIFY valueChanged)
70 
73  Q_PROPERTY(QString text READ getValueAsString WRITE setValueAsString
74  NOTIFY valueChanged)
75 
78  Q_PROPERTY(QVariant mtime READ getMTimeToDouble
79  NOTIFY valueUpdated)
80 
81  public:
82  VectorVariant(QObject * = Q_NULLPTR);
83  ~VectorVariant();
84 
85  void clearVariable();
86  bool hasVariable() const;
87  void clearData();
88 
89  QVariant getValue() const;
90  Q_INVOKABLE void setValue(const QVariant &);
91  QString getValueAsString() const;
92  Q_INVOKABLE void setValueAsString(const QString &);
93  bool getDataPresent();
94 
95  std::chrono::nanoseconds getMTime() const;
96  double getMTimeToDouble() const;
97 
98  QString getPath();
99  void setPath(QString &);
100  QVariant getConnection();
101  void setConnection(QVariant);
102  void updateConnection();
103  void setProcess(QtPdCom::Process *);
104 
105  private slots:
106  void processConnected();
107  void processDisconnected();
108  void processError();
109 
110  signals:
111  void valueChanged();
113  void valueUpdated(std::chrono::nanoseconds mtime);
119  void pathChanged(QString &);
120  void connectionUpdated();
121  void dataPresentChanged(bool);
122 
123  private:
124  class Q_DECL_HIDDEN Impl;
125  QtPdCom::Process *process;
126  std::unique_ptr<Impl> impl;
127 };
128 
129 /****************************************************************************/
130 
131 } // namespace
132 
133 
134 #endif
#define Q_NULLPTR
Definition: VectorVariant.h:35
Vector Variant to be used in QML applications.
Definition: VectorVariant.h:44
Definition: LiveSvg.h:18