QtMvvm  1.0.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
inputviewfactory.h
1 #ifndef QTMVVM_INPUTVIEWFACTORY_H
2 #define QTMVVM_INPUTVIEWFACTORY_H
3 
4 #include <QtCore/qurl.h>
5 #include <QtCore/qvariant.h>
6 #include <QtCore/qscopedpointer.h>
7 #include <QtCore/qobject.h>
8 
9 #include "QtMvvmQuick/qtmvvmquick_global.h"
10 
11 namespace QtMvvm {
12 
13 class InputViewFactoryPrivate;
15 class Q_MVVMQUICK_EXPORT InputViewFactory : public QObject
16 {
17  Q_OBJECT
18 
19 public:
21  Q_INVOKABLE InputViewFactory(QObject *parent = nullptr);
22  virtual ~InputViewFactory();
23 
25  Q_INVOKABLE virtual QUrl getInputUrl(const QByteArray &type, const QVariantMap &viewProperties);
27  Q_INVOKABLE virtual QUrl getDelegate(const QByteArray &type, const QVariantMap &viewProperties);
28 
30  template <typename TType>
31  inline void addSimpleInput(const QUrl &qmlFileUrl);
33  Q_INVOKABLE virtual void addSimpleInput(const QByteArray &type, const QUrl &qmlFileUrl);
34 
36  template <typename TType>
37  inline void addSimpleDelegate(const QUrl &qmlFileUrl);
39  Q_INVOKABLE virtual void addSimpleDelegate(const QByteArray &type, const QUrl &qmlFileUrl);
40 
42  template <typename TAliasType, typename TTargetType>
43  inline void addInputAlias();
45  Q_INVOKABLE virtual void addInputAlias(const QByteArray &alias, const QByteArray &targetType);
46 
48  template <typename TAliasType, typename TTargetType>
49  inline void addDelegateAlias();
51  Q_INVOKABLE virtual void addDelegateAlias(const QByteArray &alias, const QByteArray &targetType);
52 
53 private:
55 };
56 
57 template<typename TType>
58 inline void InputViewFactory::addSimpleInput(const QUrl &qmlFileUrl)
59 {
60  addSimpleInput(QMetaType::typeName(qMetaTypeId<TType>()), qmlFileUrl);
61 }
62 
63 template<typename TType>
65 {
66  addSimpleDelegate(QMetaType::typeName(qMetaTypeId<TType>()), qmlFileUrl);
67 }
68 
69 template<typename TAliasType, typename TTargetType>
71 {
72  addInputAlias(QMetaType::typeName(qMetaTypeId<TAliasType>()), QMetaType::typeName(qMetaTypeId<TTargetType>()));
73 }
74 
75 template<typename TAliasType, typename TTargetType>
77 {
78  addDelegateAlias(QMetaType::typeName(qMetaTypeId<TAliasType>()), QMetaType::typeName(qMetaTypeId<TTargetType>()));
79 }
80 
81 }
82 
83 #endif // QTMVVM_INPUTVIEWFACTORY_H
A factory class to generate input edit views by their type names.
void addSimpleInput(const QUrl &qmlFileUrl)
Adds a new QML file to create views for the given type.
void addInputAlias()
Adds a type name alias for views.
void addDelegateAlias()
Adds a type name alias for delegates.
const char * typeName(int typeId)
void addSimpleDelegate(const QUrl &qmlFileUrl)
Adds a new QML file to create delegates for the given type.
The primary namespace of the QtMvvm library.
Definition: binding.h:10