QtMvvm  1.0.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
binding.h
1 #ifndef QTMVVM_BINDING_H
2 #define QTMVVM_BINDING_H
3 
4 #include <QtCore/qobject.h>
5 #include <QtCore/qpointer.h>
6 #include <QtCore/qmetaobject.h>
7 
8 #include "QtMvvmCore/qtmvvmcore_global.h"
9 
10 namespace QtMvvm {
11 
12 class BindingPrivate;
14 class Q_MVVMCORE_EXPORT Binding
15 {
16  Q_GADGET
17 
18 public:
21  SingleInit = 0x01,
22  OneWayToView = (0x02 | SingleInit),
23  OneWayToViewModel = 0x04,
24  TwoWay = (OneWayToView | OneWayToViewModel)
25  };
26  Q_DECLARE_FLAGS(BindingDirection, BindingDirectionFlag)
27  Q_FLAG(BindingDirection)
28 
29  Binding();
32  ~Binding();
33 
35  bool isValid() const;
36 
38  Q_INVOKABLE void unbind();
39 
40 private:
42 };
43 
45 Q_MVVMCORE_EXPORT Binding bind(QObject *viewModel, const char *viewModelProperty,
46  QObject *view, const char *viewProperty,
47  Binding::BindingDirection type = Binding::TwoWay,
48  const char *viewModelChangeSignal = nullptr,
49  const char *viewChangeSignal = nullptr);
51 Q_MVVMCORE_EXPORT Binding bind(QObject *viewModel, const QMetaProperty &viewModelProperty,
52  QObject *view, const QMetaProperty &viewProperty,
53  Binding::BindingDirection type = Binding::TwoWay,
54  const char *viewModelChangeSignal = nullptr,
55  const char *viewChangeSignal = nullptr);
57 Q_MVVMCORE_EXPORT Binding bind(QObject *viewModel, const QMetaProperty &viewModelProperty,
58  QObject *view, const QMetaProperty &viewProperty,
59  Binding::BindingDirection type = Binding::TwoWay,
60  const QMetaMethod &viewModelChangeSignal = {},
61  const QMetaMethod &viewChangeSignal = {});
62 
63 }
64 
65 Q_DECLARE_OPERATORS_FOR_FLAGS(QtMvvm::Binding::BindingDirection)
66 
67 #if defined(QT_BUILD_MVVMCORE_LIB) && defined(Q_MOC_RUN)
68 #include "binding_p.h"
69 #endif
70 
71 #endif // QTMVVM_BINDING_H
Q_MVVMCORE_EXPORT Binding bind(QObject *viewModel, const char *viewModelProperty, QObject *view, const char *viewProperty, Binding::BindingDirection type=Binding::TwoWay, const char *viewModelChangeSignal=nullptr, const char *viewChangeSignal=nullptr)
Create a multidirectional binding between properties.
A handle to a multidirectional binding between properties.
Definition: binding.h:14
BindingDirectionFlag
Flags to control how to bind the properties.
Definition: binding.h:20
All changes on both sides are propagated to the other one.
Definition: binding.h:24
The primary namespace of the QtMvvm library.
Definition: binding.h:10