#ifndef QTMVVM_QQMLQUICKPRESENTER_H #define QTMVVM_QQMLQUICKPRESENTER_H #include #include #include #include #include #include #include #include #include namespace QtMvvm { class QQmlQuickPresenter : public QObject { Q_OBJECT Q_PROPERTY(QString currentStyle READ currentStyle CONSTANT) Q_PROPERTY(QObject* qmlPresenter MEMBER _qmlPresenter NOTIFY qmlPresenterChanged) Q_PROPERTY(bool viewLoading READ isViewLoading NOTIFY viewLoadingChanged) Q_PROPERTY(qreal loadingProgress READ loadingProgress NOTIFY loadingProgressChanged) public: explicit QQmlQuickPresenter(QQmlEngine *engine); QString currentStyle() const; bool isViewLoading() const; qreal loadingProgress() const; Q_SIGNALS: void qmlPresenterChanged(QObject* qmlPresenter); void viewLoadingChanged(bool viewLoading); void loadingProgressChanged(qreal loadingProgress); private Q_SLOTS: void present(QtMvvm::ViewModel *viewModel, const QVariantHash ¶ms, const QUrl &viewUrl, QPointer parent); void showDialog(const QtMvvm::MessageConfig &config, QtMvvm::MessageResult *result); void statusChanged(QQmlComponent::Status status); private: typedef std::tuple> PresentTuple; QQmlEngine *_engine; QPointer _qmlPresenter; QPointer _latestComponent; QCache _componentCache; QHash _loadCache; void addObject(QQmlComponent *component, ViewModel *viewModel, const QVariantHash ¶ms, QPointer parent); }; } #endif // QTMVVM_QQMLQUICKPRESENTER_H