@@ -64,6 +64,35 @@ delegate to set the property.
64
64
InputViewFactory::addDelegateAlias, InputViewFactory::getInputUrl
65
65
*/
66
66
67
+ /*!
68
+ @fn QtMvvm::InputViewFactory::format
69
+
70
+ @param type The type to choose a formatter for
71
+ @param formatString Some kind of format string, depending on what the formatter wants here
72
+ @param value The actual value, packet as a variant
73
+ @param viewProperties Additional properies set on the delegate
74
+ @returns The formatted value text
75
+
76
+ Internally, this method uses the Formatter registered for the given type and then returns
77
+ the result of Formatter::format, invoked with the remaining parameters.
78
+
79
+ If no formatter was registered for the given type, this method simply returns
80
+ `formatString.arg(value.toString());`
81
+
82
+ Currently, the following special formatters are set by default.
83
+
84
+ types | formatString semantics
85
+ ----------------------------|------------------------
86
+ int | A translated string with either `%1`, `%L1` or `%n` as number placeholder. If `%n` is used, "plural-translations" are used
87
+ list, selection, radiolist | A translated string with `%1` as placeholder. If the list element is named, that one is used, otherwise the value itself
88
+ QDateTime, QDate, QTime | Can either be the integer value of one of Qt::DateFormat or a standard date format string (QDateTime::toString). If neither is the case, the date is formatted using Qt::DefaultLocaleShortDate
89
+ double | Uses the SimpleFormatter with double as template argument
90
+
91
+ All other types use the fallback formatting.
92
+
93
+ @sa Formatter::format, InputViewFactory::addFormatter, InputViewFactory::addFormatterAlias
94
+ */
95
+
67
96
/*!
68
97
@fn QtMvvm::InputViewFactory::addSimpleInput(const QUrl &)
69
98
@@ -112,6 +141,30 @@ used as a delegate for a ListView.
112
141
@sa InputViewFactory::getDelegate, InputViewFactory::addDelegateAlias
113
142
*/
114
143
144
+ /*!
145
+ @fn QtMvvm::InputViewFactory::addFormatter(Formatter*)
146
+
147
+ @tparam TType The type to add a formatter for
148
+ @param formatter The formatter instance to be added
149
+
150
+ The formatter must be valid and is registered in the factory. The factory takes ownership of
151
+ the passed formatter. From now on it is used to convert display texts when format() is called.
152
+
153
+ @sa InputViewFactory::format, InputViewFactory::addFormatterAlias, Formatter
154
+ */
155
+
156
+ /*!
157
+ @fn QtMvvm::InputViewFactory::addFormatter(const QByteArray &, Formatter*)
158
+
159
+ @param type The type to add a formatter for
160
+ @param formatter The formatter instance to be added
161
+
162
+ The formatter must be valid and is registered in the factory. The factory takes ownership of
163
+ the passed formatter. From now on it is used to convert display texts when format() is called.
164
+
165
+ @sa InputViewFactory::format, InputViewFactory::addFormatterAlias, Formatter
166
+ */
167
+
115
168
/*!
116
169
@fn QtMvvm::InputViewFactory::addInputAlias()
117
170
@@ -157,3 +210,44 @@ instead.
157
210
158
211
@sa InputViewFactory::getDelegate, InputViewFactory::addSimpleDelegate
159
212
*/
213
+
214
+ /*!
215
+ @fn QtMvvm::InputViewFactory::addFormatterAlias()
216
+
217
+ @tparam TAliasType The type to add as a new alias
218
+ @tparam TTargetType The type the alias should be translated to
219
+
220
+ If a formatter for the alias type is requested for the format() method, the one of the target
221
+ type is used instead.
222
+
223
+ @sa InputViewFactory::format, InputViewFactory::addFormatter
224
+ */
225
+
226
+ /*!
227
+ @fn QtMvvm::InputViewFactory::addFormatterAlias(const QByteArray &, const QByteArray &)
228
+
229
+ @param alias The type to add as a new alias
230
+ @param targetType The type the alias should be translated to
231
+
232
+ If a formatter for the alias type is requested for the format() method, the one of the target
233
+ type is used instead.
234
+
235
+ @sa InputViewFactory::format, InputViewFactory::addFormatter
236
+ */
237
+
238
+
239
+
240
+ /*!
241
+ @fn QtMvvm::Formatter::format
242
+
243
+ @param formatString Some kind of format string, depending on what your formatter wants here
244
+ @param value The actual value, packet as a variant
245
+ @param viewProperties Additional properies set on the delegate
246
+ @return A localized, human readable text, the formatted the value based on formatString
247
+
248
+ formatString can be whatever you need it to be, but typically it is a localized text with a
249
+ placeholder to be replaced with the given value. See InputViewFactory::format for known
250
+ formats.
251
+
252
+ @sa InputViewFactory::format
253
+ */
0 commit comments