QtMvvm  1.1.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
qqmlviewplaceholder.h
1 #ifndef QTMVVM_QQMLVIEWPLACEHOLDER_H
2 #define QTMVVM_QQMLVIEWPLACEHOLDER_H
3 
4 #include <QtQuick/QQuickItem>
5 
6 #include <QtMvvmCore/ViewModel>
7 
8 #ifdef DOXYGEN_RUN
10 
58 #else
59 namespace QtMvvm {
60 
61 class QQmlViewPlaceholder : public QQuickItem
62 #endif
63 {
64  Q_OBJECT
65 
81  Q_PROPERTY(bool autoResizeView MEMBER _autoResizeView NOTIFY autoResizeViewChanged)
95  Q_PROPERTY(bool replaceViews MEMBER _replaceViews NOTIFY replaceViewsChanged)
113  Q_PROPERTY(bool closeViewOnAction MEMBER _closeViewOnAction NOTIFY closeViewOnActionChanged)
114 
129  Q_PROPERTY(QQuickItem* loadedView READ loadedView NOTIFY loadedViewChanged)
130 
131 public:
133  explicit QQmlViewPlaceholder(QQuickItem *parent = nullptr);
134 
147  Q_INVOKABLE bool presentItem(QQuickItem *item);
160  Q_INVOKABLE bool closeAction();
161 
163  QQuickItem* loadedView() const;
164 
165 public Q_SLOTS:
167  void discardView();
168 
169 Q_SIGNALS:
177  void loadedViewChanged(QQuickItem* loadedView);
178 
179 private Q_SLOTS:
180  void resizeView();
181 
182  void updateImpHeight();
183  void updateImpWidth();
184 
185 private:
186  bool _autoResizeView = true;
187  bool _replaceViews = false;
188  bool _closeViewOnAction = false;
189 
190  QPointer<QQuickItem> _loadedView = nullptr;
191 
192  bool _isReady = false;
193  QMetaObject::Connection _parentVmCon;
194 
195  void connectSizeChanges();
196  void disconnectSizeChanges(bool resetSize);
197 };
198 
199 }
200 
201 #endif // QTMVVM_QQMLVIEWPLACEHOLDER_H
bool autoResizeView
Specify whether to automatically resize the placeholders content view.
bool closeViewOnAction
Specify whether discarding the contained view is a close action.
void replaceViewsChanged(bool replaceViews)
NOTIFY accessor for ViewPlaceholder::replaceViews.
Q_INVOKABLE bool closeAction()
A close action that propagates to the contained item.
A placeholder item to show a view within another view.
Q_INVOKABLE bool presentItem(QQuickItem *item)
The presenter method to be called from the parent view.
The QML import for the QtMvvmQuick QML module.
Definition: ActionButton.qml:4
void autoResizeViewChanged(bool autoResizeView)
NOTIFY accessor for ViewPlaceholder::autoResizeView.
void discardView()
Closes the currenty contained view by destoying it.
void closeViewOnActionChanged(bool closeViewOnAction)
NOTIFY accessor for ViewPlaceholder::closeViewOnAction.
The primary namespace of the QtMvvm library.
void loadedViewChanged(QQuickItem *loadedView)
NOTIFY accessor for ViewPlaceholder::loadedView.
bool replaceViews
Specify what happens when showing a new viewmodel while one already exists.