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.
253 lines
9.3 KiB
253 lines
9.3 KiB
/*!
|
|
@class QtMvvm::InputViewFactory
|
|
|
|
The factory is used by the QuickPresenter to create input views and delegates for various
|
|
types. This is used to for example create the edits of input dialogs or for the list delegates
|
|
of a SettingsView.
|
|
|
|
@sa QuickPresenter, QuickPresenter::inputViewFactory, MessageConfig::TypeInputDialog,
|
|
QtMvvm::getInput, SettingsViewModel
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::InputViewFactory::getInputUrl
|
|
|
|
@param type The input type to create a view for
|
|
@param viewProperties A map with extra properties to be set on the edit
|
|
@returns A url to a QML component suitable for editing input of the given type
|
|
|
|
The factory first checks if the given type is registered as alias. If yes, it continues with
|
|
the aliased type. Then it checks for a url registered as simple view exists for the given
|
|
type and uses that one if present. If no simple view is set the default mapping for type to
|
|
urls is used (See MessageConfig::TypeInputDialog for a full table of supported types). If no
|
|
url can be found for a type, an invalid url is returned.
|
|
|
|
The viewProperties are used to setup the created view by settings them as properties on the
|
|
view. For every key-value-pair in the map, QObject::setProperty is called on the view to
|
|
set the property.
|
|
|
|
@sa MessageConfig::TypeInputDialog, InputViewFactory::addSimpleInput,
|
|
InputViewFactory::addInputAlias, InputViewFactory::getDelegate
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::InputViewFactory::getDelegate
|
|
|
|
@param type The input type to create a delegate for
|
|
@param viewProperties A map with extra properties to be set on the delegate
|
|
@returns A url to a QML component suitable for editing input of the given type, as a delegate
|
|
|
|
Delegates can be used to provide "editabel" list items for ListViews. (For example, the
|
|
SettingsView makes use of them). Available roles are:
|
|
- group
|
|
- key
|
|
- type
|
|
- title
|
|
- tooltip
|
|
- delegateUrl
|
|
- inputValue
|
|
- properties
|
|
|
|
The factory first checks if the given type is registered as alias. If yes, it continues with
|
|
the aliased type. Then it checks for a url registered as simple delegate exists for the given
|
|
type and uses that one if present. If no simple delegate is set the default mapping for type
|
|
to urls is used (See MessageConfig::TypeInputDialog for a full table of supported types). If
|
|
no url can be found for a type, the MsgDelegate is returned, which will simply show an input
|
|
of the given type. Thus, for all not explicitly supported delegate types, the getInputUrl() is
|
|
used to find an edit for the dialog.
|
|
|
|
The viewProperties are used to setup the created delegate by settings them as properties on
|
|
the delegate. For every key-value-pair in the map, QObject::setProperty is called on the
|
|
delegate to set the property.
|
|
|
|
@sa MessageConfig::TypeInputDialog, InputViewFactory::addSimpleDelegate,
|
|
InputViewFactory::addDelegateAlias, InputViewFactory::getInputUrl
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::InputViewFactory::format
|
|
|
|
@param type The type to choose a formatter for
|
|
@param formatString Some kind of format string, depending on what the formatter wants here
|
|
@param value The actual value, packet as a variant
|
|
@param viewProperties Additional properies set on the delegate
|
|
@returns The formatted value text
|
|
|
|
Internally, this method uses the Formatter registered for the given type and then returns
|
|
the result of Formatter::format, invoked with the remaining parameters.
|
|
|
|
If no formatter was registered for the given type, this method simply returns
|
|
`formatString.arg(value.toString());`
|
|
|
|
Currently, the following special formatters are set by default.
|
|
|
|
types | formatString semantics
|
|
----------------------------|------------------------
|
|
int | A translated string with either `%1`, `%L1` or `%n` as number placeholder. If `%n` is used, "plural-translations" are used
|
|
list, selection, radiolist | A translated string with `%1` as placeholder. If the list element is named, that one is used, otherwise the value itself
|
|
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
|
|
double | Uses the SimpleFormatter with double as template argument
|
|
|
|
All other types use the fallback formatting.
|
|
|
|
@sa Formatter::format, InputViewFactory::addFormatter, InputViewFactory::addFormatterAlias
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::InputViewFactory::addSimpleInput(const QUrl &)
|
|
|
|
@tparam TType The type to add an input view for
|
|
@param qmlFileUrl The URL of the QML file that contains the component
|
|
|
|
The qmlFileUrl must be a valid URL to a QML file with a displayable quick item. The item must
|
|
have a property named `inputValue` that is used to read and write the edit data.
|
|
|
|
@sa InputViewFactory::getInputUrl, InputViewFactory::addInputAlias
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::InputViewFactory::addSimpleInput(const QByteArray &, const QUrl &)
|
|
|
|
@param type The type to add an input view for
|
|
@param qmlFileUrl The URL of the QML file that contains the component
|
|
|
|
The qmlFileUrl must be a valid URL to a QML file with a displayable quick item. The item must
|
|
have a property named `inputValue` that is used to read and write the edit data.
|
|
|
|
@sa InputViewFactory::getInputUrl, InputViewFactory::addInputAlias
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::InputViewFactory::addSimpleDelegate(const QUrl &)
|
|
|
|
@tparam TType The type to add a delegate view for
|
|
@param qmlFileUrl The URL of the QML file that contains the component
|
|
|
|
The qmlFileUrl must be a valid URL to a QML file with a displayable quick item that can be
|
|
used as a delegate for a ListView.
|
|
|
|
@sa InputViewFactory::getDelegate, InputViewFactory::addDelegateAlias
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::InputViewFactory::addSimpleDelegate(const QByteArray &, const QUrl &)
|
|
|
|
@param type The type to add a delegate view for
|
|
@param qmlFileUrl The URL of the QML file that contains the component
|
|
|
|
The qmlFileUrl must be a valid URL to a QML file with a displayable quick item that can be
|
|
used as a delegate for a ListView.
|
|
|
|
@sa InputViewFactory::getDelegate, InputViewFactory::addDelegateAlias
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::InputViewFactory::addFormatter(Formatter*)
|
|
|
|
@tparam TType The type to add a formatter for
|
|
@param formatter The formatter instance to be added
|
|
|
|
The formatter must be valid and is registered in the factory. The factory takes ownership of
|
|
the passed formatter. From now on it is used to convert display texts when format() is called.
|
|
|
|
@sa InputViewFactory::format, InputViewFactory::addFormatterAlias, Formatter
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::InputViewFactory::addFormatter(const QByteArray &, Formatter*)
|
|
|
|
@param type The type to add a formatter for
|
|
@param formatter The formatter instance to be added
|
|
|
|
The formatter must be valid and is registered in the factory. The factory takes ownership of
|
|
the passed formatter. From now on it is used to convert display texts when format() is called.
|
|
|
|
@sa InputViewFactory::format, InputViewFactory::addFormatterAlias, Formatter
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::InputViewFactory::addInputAlias()
|
|
|
|
@tparam TAliasType The type to add as a new alias
|
|
@tparam TTargetType The type the alias should be translated to
|
|
|
|
If an input view for the alias type is requested, one of the target type is created instead.
|
|
|
|
@sa InputViewFactory::getInputUrl, InputViewFactory::addSimpleInput
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::InputViewFactory::addInputAlias(const QByteArray &, const QByteArray &)
|
|
|
|
@param alias The type to add as a new alias
|
|
@param targetType The type the alias should be translated to
|
|
|
|
If an input view for the alias type is requested, one of the target type is created instead.
|
|
|
|
@sa InputViewFactory::getInputUrl, InputViewFactory::addSimpleInput
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::InputViewFactory::addDelegateAlias()
|
|
|
|
@tparam TAliasType The type to add as a new alias
|
|
@tparam TTargetType The type the alias should be translated to
|
|
|
|
If an delegate view for the alias type is requested, one of the target type is created
|
|
instead.
|
|
|
|
@sa InputViewFactory::getDelegate, InputViewFactory::addSimpleDelegate
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::InputViewFactory::addDelegateAlias(const QByteArray &, const QByteArray &)
|
|
|
|
@param alias The type to add as a new alias
|
|
@param targetType The type the alias should be translated to
|
|
|
|
If an delegate view for the alias type is requested, one of the target type is created
|
|
instead.
|
|
|
|
@sa InputViewFactory::getDelegate, InputViewFactory::addSimpleDelegate
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::InputViewFactory::addFormatterAlias()
|
|
|
|
@tparam TAliasType The type to add as a new alias
|
|
@tparam TTargetType The type the alias should be translated to
|
|
|
|
If a formatter for the alias type is requested for the format() method, the one of the target
|
|
type is used instead.
|
|
|
|
@sa InputViewFactory::format, InputViewFactory::addFormatter
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::InputViewFactory::addFormatterAlias(const QByteArray &, const QByteArray &)
|
|
|
|
@param alias The type to add as a new alias
|
|
@param targetType The type the alias should be translated to
|
|
|
|
If a formatter for the alias type is requested for the format() method, the one of the target
|
|
type is used instead.
|
|
|
|
@sa InputViewFactory::format, InputViewFactory::addFormatter
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
@fn QtMvvm::Formatter::format
|
|
|
|
@param formatString Some kind of format string, depending on what your formatter wants here
|
|
@param value The actual value, packet as a variant
|
|
@param viewProperties Additional properies set on the delegate
|
|
@return A localized, human readable text, the formatted the value based on formatString
|
|
|
|
formatString can be whatever you need it to be, but typically it is a localized text with a
|
|
placeholder to be replaced with the given value. See InputViewFactory::format for known
|
|
formats.
|
|
|
|
@sa InputViewFactory::format
|
|
*/
|
|
|