QtMvvm  1.1.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;
37  operator bool() const;
38 
40  Q_INVOKABLE void unbind();
41 
42 private:
44 };
45 
47 Q_MVVMCORE_EXPORT Binding bind(QObject *viewModel, const char *viewModelProperty,
48  QObject *view, const char *viewProperty,
49  Binding::BindingDirection type = Binding::TwoWay,
50  const char *viewModelChangeSignal = nullptr,
51  const char *viewChangeSignal = nullptr);
53 Q_MVVMCORE_EXPORT Binding bind(QObject *viewModel, const QMetaProperty &viewModelProperty,
54  QObject *view, const QMetaProperty &viewProperty,
55  Binding::BindingDirection type = Binding::TwoWay,
56  const char *viewModelChangeSignal = nullptr,
57  const char *viewChangeSignal = nullptr);
59 Q_MVVMCORE_EXPORT Binding bind(QObject *viewModel, const QMetaProperty &viewModelProperty,
60  QObject *view, const QMetaProperty &viewProperty,
61  Binding::BindingDirection type = Binding::TwoWay,
62  const QMetaMethod &viewModelChangeSignal = {},
63  const QMetaMethod &viewChangeSignal = {});
64 
65 }
66 
67 Q_DECLARE_OPERATORS_FOR_FLAGS(QtMvvm::Binding::BindingDirection)
68 
69 #if defined(QT_BUILD_MVVMCORE_LIB) && defined(Q_MOC_RUN)
70 #include "binding_p.h"
71 #endif
72 
73 #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.