You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
948 B
42 lines
948 B
7 years ago
|
#ifndef QTMVVM_INPUTWIDGETFACTORY_H
|
||
|
#define QTMVVM_INPUTWIDGETFACTORY_H
|
||
7 years ago
|
|
||
|
#include <functional>
|
||
|
|
||
|
#include <QtCore/qscopedpointer.h>
|
||
|
|
||
|
#include <QtWidgets/qwidget.h>
|
||
|
|
||
|
#include "QtMvvmWidgets/qtmvvmwidgets_global.h"
|
||
|
|
||
|
namespace QtMvvm {
|
||
|
|
||
7 years ago
|
class InputWidgetFactoryPrivate;
|
||
|
class InputWidgetFactory
|
||
7 years ago
|
{
|
||
|
public:
|
||
7 years ago
|
InputWidgetFactory();
|
||
|
virtual ~InputWidgetFactory();
|
||
7 years ago
|
|
||
|
virtual QWidget *createInput(const QByteArray &type, QWidget *parent, const QVariantMap &viewProperties);
|
||
|
|
||
|
virtual void addSimpleWidget(const QByteArray &type, const std::function<QWidget*(QWidget*)> &creator);
|
||
|
template <typename TType, typename TWidget>
|
||
|
void addSimpleWidget();
|
||
|
|
||
|
private:
|
||
7 years ago
|
QScopedPointer<InputWidgetFactoryPrivate> d;
|
||
7 years ago
|
};
|
||
|
|
||
|
template<typename TType, typename TWidget>
|
||
7 years ago
|
void InputWidgetFactory::addSimpleWidget()
|
||
7 years ago
|
{
|
||
|
addSimpleWidget(QMetaType::typeName(qMetaTypeId<TType>()), [](QWidget *parent){
|
||
|
return new TWidget(parent);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
7 years ago
|
#endif // QTMVVM_INPUTWIDGETFACTORY_H
|