|
| 1 | +/*! |
| 2 | +@class QtMvvm::WidgetsPresenter |
| 3 | + |
| 4 | +This presenter is automatically registered as the default presenter for the IPresenter |
| 5 | +interface with the ServiceRegistry, but as weak service, in order to make it possible to |
| 6 | +overwrite it. |
| 7 | + |
| 8 | +The class handles all the logic required for presenting widget based views. You can extend |
| 9 | +this class and reimplement it's virtual methods if you need to adjust how certain views or |
| 10 | +dialogs are presented, or if you want to support custom stuff |
| 11 | +*/ |
| 12 | + |
| 13 | +/*! |
| 14 | +@property QtMvvm::WidgetsPresenter::inputWidgetFactory |
| 15 | + |
| 16 | +@default{<i>Injected</i>} |
| 17 | + |
| 18 | +Do not set this property yourself. It is automatically injected when showing the viewmodel. |
| 19 | +You can use the ServiceRegistry::registerInterface if you need to use a factory different from |
| 20 | +the default one. |
| 21 | + |
| 22 | +@accessors{ |
| 23 | + @readAc{inputWidgetFactory()} |
| 24 | + @writeAc{setInputWidgetFactory()} |
| 25 | +} |
| 26 | + |
| 27 | +@sa #QTMVVM_INJECT |
| 28 | +*/ |
| 29 | + |
| 30 | +/*! |
| 31 | +@fn QtMvvm::WidgetsPresenter::registerView() |
| 32 | + |
| 33 | +@tparam TView The widget type register within the presenter. Must extend QWidget |
| 34 | + |
| 35 | +The widget is registered with the current presenter. It is registered implicitly, which means |
| 36 | +that it's name will be used to find it when a viewmodel is presented for it. Thus, it must be |
| 37 | +named after the viewmodel. If the viewmodel is for example named `MyViewModel`, then the view |
| 38 | +must start with `My` too. For example it can be named `MyWidget`, `MyDialog`, `MyWindow`, |
| 39 | +`MyView`, ... |
| 40 | + |
| 41 | +@note Implicit detection of views for viewmodels can sometimes lead to ambiguities and thus a |
| 42 | +wrong view beeing found. In such cases, use registerViewExplicitly() instead. |
| 43 | + |
| 44 | +@sa WidgetsPresenter::registerViewExplicitly |
| 45 | +*/ |
| 46 | + |
| 47 | +/*! |
| 48 | +@fn QtMvvm::WidgetsPresenter::registerView(const QMetaObject *) |
| 49 | + |
| 50 | +@param viewType The widget type register within the presenter. Must extend QWidget |
| 51 | + |
| 52 | +The widget is registered with the current presenter. It is registered implicitly, which means |
| 53 | +that it's name will be used to find it when a viewmodel is presented for it. Thus, it must be |
| 54 | +named after the viewmodel. If the viewmodel is for example named `MyViewModel`, then the view |
| 55 | +must start with `My` too. For example it can be named `MyWidget`, `MyDialog`, `MyWindow`, |
| 56 | +`MyView`, ... |
| 57 | + |
| 58 | +@note Implicit detection of views for viewmodels can sometimes lead to ambiguities and thus a |
| 59 | +wrong view beeing found. In such cases, use registerViewExplicitly() instead. |
| 60 | + |
| 61 | +@sa WidgetsPresenter::registerViewExplicitly |
| 62 | +*/ |
| 63 | + |
| 64 | +/*! |
| 65 | +@fn QtMvvm::WidgetsPresenter::registerViewExplicitly() |
| 66 | + |
| 67 | +@tparam TViewModel The viewmodel to to register the view for |
| 68 | +@tparam TView The widget type register within the presenter. Must extend QWidget |
| 69 | + |
| 70 | +The widget is registered with the current presenter. It is registered explicitly, which means |
| 71 | +that whenever the given viewmodel is beeing presented, this exact view will be used. Explicit |
| 72 | +registration have precedence over implicit ones. |
| 73 | + |
| 74 | +@sa WidgetsPresenter::registerView |
| 75 | +*/ |
| 76 | + |
| 77 | +/*! |
| 78 | +@fn QtMvvm::WidgetsPresenter::registerViewExplicitly(const QMetaObject *, const QMetaObject *) |
| 79 | + |
| 80 | +@param viewModelType The viewmodel to to register the view for |
| 81 | +@param viewType The widget type register within the presenter. Must extend QWidget |
| 82 | + |
| 83 | +The widget is registered with the current presenter. It is registered explicitly, which means |
| 84 | +that whenever the given viewmodel is beeing presented, this exact view will be used. Explicit |
| 85 | +registration have precedence over implicit ones. |
| 86 | + |
| 87 | +@sa WidgetsPresenter::registerView |
| 88 | +*/ |
| 89 | + |
| 90 | +/*! |
| 91 | +@fn QtMvvm::WidgetsPresenter::findWidgetMetaObject |
| 92 | + |
| 93 | +@param viewModelMetaObject The metobject of the viewmodel to find a view for |
| 94 | +@returns The metaobject of the view to used, or `nullptr` if none was found |
| 95 | + |
| 96 | +The default implementation simply check all explicitly registered views and then tries to |
| 97 | +match the name with the implicitly registered ones. If no match if found, the same is tried |
| 98 | +for the parent viewmodel type recursively, until the ViewModel base is reached. |
| 99 | +*/ |
| 100 | + |
| 101 | +/*! |
| 102 | +@fn QtMvvm::WidgetsPresenter::tryPresent |
| 103 | + |
| 104 | +@param view The view to be presented |
| 105 | +@param parentView The parent view to present the view to |
| 106 | +@returns `true` if successfully presented, `false` if not |
| 107 | + |
| 108 | +This method is called to perform the actual presentation (i.e. the parenting and how to show) |
| 109 | +the view. The default implementation first checks if the parent implements IPresentingView and |
| 110 | +if yes if it is able to present the view. If not, a bunch of standard widget types are checked |
| 111 | +for special presentation methods. QDialogs are presented via QDialog::open. QDockWidgets that |
| 112 | +are presented to a QMainWindow are added as dock widget (QMainWindow::addDockWidget). If the |
| 113 | +parent or its central widget are a QMdiArea, and the views class name ends with `MdiWindow`, |
| 114 | +it is presented as QMdiSubWindow. For all other cases, showForeground() is called. |
| 115 | + |
| 116 | +@sa WidgetsPresenter::showForeground, QDialog, QMainWindow, QDockWidget, QMdiArea |
| 117 | +*/ |
0 commit comments