Debian Codegraph @

super-macros/QQmlHelpers.cpp

raw
1
2 #include "QQmlEnumClassHelper.h"
3 #include "QQmlListPropertyHelper.h"
4 #include "QQmlVarPropertyHelpers.h"
5 #include "QQmlPtrPropertyHelpers.h"
6 #include "QQmlConstRefPropertyHelpers.h"
7 #include "QQmlAutoPropertyHelpers.h"
8
9 // TODO : rewrite this doc
10
11 /*!
12 \defgroup QT_QML_HELPERS Qt helper macros
13
14 Brings a couple of macros that can help saving development time,
15 by avoiding manual code duplication, often leading to heavy copy-and-paste,
16 which is largely error-prone and not productive at all.
17 */
18
19
20 /*!
21 \def QML_WRITABLE_PROPERTY(type, name)
22 \ingroup QT_QML_HELPERS
23 \hideinitializer
24 \details Creates a \c Q_PROPERTY that will be readable / writable from QML.
25
26 \param type The C++ type of the property
27 \param name The name for the property
28
29 It generates for this goal :
30 \code
31 {type} m_{name}; // private member variable
32 {type} get_{name} () const; // public getter method
33 void set_{name} ({type}); // public setter slot
34 void {name}Changed ({type}); // notifier signal
35 \endcode
36
37 \b Note : Any change from either C++ or QML side will trigger the notification.
38 */
39
40
41 /*!
42 \def QML_READONLY_PROPERTY(type, name)
43 \ingroup QT_QML_HELPERS
44 \hideinitializer
45 \details Creates a \c Q_PROPERTY that will be readable from QML and writable from C++.
46
47 \param type The C++ type of the property
48 \param name The name for the property
49
50 It generates for this goal :
51 \code
52 {type} m_{name}; // private member variable
53 {type} get_{name} () const; // public getter method
54 void update_{name} ({type}); // public setter method
55 void {name}Changed ({type}); // notifier signal
56 \endcode
57
58 \b Note : Any change from C++ side will trigger the notification to QML.
59 */
60
61
62 /*!
63 \def QML_CONSTANT_PROPERTY(type, name)
64 \ingroup QT_QML_HELPERS
65 \hideinitializer
66 \details Creates a \c Q_PROPERTY for a constant value exposed from C++ to QML.
67
68 \param type The C++ type of the property
69 \param name The name for the property
70
71 It generates for this goal :
72 \code
73 {type} m_{name}; // private member variable
74 {type} get_{name} () const; // public getter method
75 \endcode
76
77 \b Note : There is no change notifier because value is constant.
78 */
79
80
81 /*!
82 \def QML_ENUM_CLASS(name, ...)
83 \ingroup QT_QML_HELPERS
84 \hideinitializer
85 \details Creates a class that contains a C++ enum that can be exposed to QML.
86
87 \param name The name for the class
88 \param ... The variadic list of values for the enum (comma-separated)
89
90 It generates for this goal :
91 \li The \c {name} C++ QObject-derived class
92 \li The \c {name}::Type enumeration containing the values list
93 \li The \c Q_ENUMS macro call to allow QML usage
94
95 Example in use :
96 \code
97 QML_ENUM_CLASS (DaysOfWeek, Monday = 1, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday)
98 \endcode
99
100 \b Note : The QML registration using \c qmlRegisterUncreatableType() will still be needed.
101 */