doc: Add doc for RegExpRole
small changes to SwitchRole and RegExpFilter doc
This commit is contained in:
parent
a15a86be81
commit
fd147bbb57
|
@ -55,7 +55,7 @@ void RegExpFilter::setPattern(const QString& pattern)
|
|||
|
||||
The pattern used to filter the contents of the source model.
|
||||
|
||||
Only the source model's value having their \l roleName data matching this \l pattern with the specified \l syntax will be kept.
|
||||
Only the source model's value having their \l RoleFilter::roleName data matching this \l pattern with the specified \l syntax will be kept.
|
||||
|
||||
\value RegExpFilter.RegExp A rich Perl-like pattern matching syntax. This is the default.
|
||||
\value RegExpFilter.Wildcard This provides a simple pattern matching syntax similar to that used by shells (command interpreters) for "file globbing".
|
||||
|
|
|
@ -4,6 +4,30 @@
|
|||
|
||||
namespace qqsfpm {
|
||||
|
||||
/*!
|
||||
\qmltype RegExpRole
|
||||
\inherits ProxyRole
|
||||
\inqmlmodule SortFilterProxyModel
|
||||
\brief A ProxyRole extracting data from a source role via a regular expression.
|
||||
|
||||
A RegExpRole is a \l ProxyRole that provides a role for each named capture group of its regular expression \l pattern.
|
||||
|
||||
In the following example, the \c date role of the source model will be extracted in 3 roles in the proxy moodel: \c year, \c month and \c day.
|
||||
SortFilterProxyModel {
|
||||
sourceModel: eventModel
|
||||
proxyRoles: RegExpRole {
|
||||
roleName: "date"
|
||||
pattern: "(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})"
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty QString RegExpRole::roleName
|
||||
|
||||
This property holds the role name that the RegExpRole is using to query the source model's data to extract new roles from.
|
||||
*/
|
||||
QString RegExpRole::roleName() const
|
||||
{
|
||||
return m_roleName;
|
||||
|
@ -18,6 +42,12 @@ void RegExpRole::setRoleName(const QString& roleName)
|
|||
Q_EMIT roleNameChanged();
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlproperty QString RegExpRole::pattern
|
||||
|
||||
This property holds the pattern of the regular expression of this RegExpRole.
|
||||
The RegExpRole will expose a role for each of the named capture group of the pattern.
|
||||
*/
|
||||
QString RegExpRole::pattern() const
|
||||
{
|
||||
return m_regularExpression.pattern();
|
||||
|
@ -35,6 +65,11 @@ void RegExpRole::setPattern(const QString& pattern)
|
|||
Q_EMIT namesChanged();
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlproperty Qt::CaseSensitivity RegExpRole::caseSensitivity
|
||||
|
||||
This property holds the caseSensitivity of the regular expression.
|
||||
*/
|
||||
Qt::CaseSensitivity RegExpRole::caseSensitivity() const
|
||||
{
|
||||
return m_regularExpression.patternOptions() & QRegularExpression::CaseInsensitiveOption ?
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace qqsfpm {
|
|||
\qmltype SwitchRole
|
||||
\inherits SingleRole
|
||||
\inqmlmodule SortFilterProxyModel
|
||||
\brief a role using \l Filter to conditionnaly compute its data
|
||||
\brief A role using \l Filter to conditionnaly compute its data
|
||||
|
||||
A SwitchRole is a \l ProxyRole that computes its data with the help of \l Filter.
|
||||
Each top level filters specified in the \l SwitchRole is evaluated on the rows of the model, if a \l Filter evaluates to true, the data of the \l SwitchRole for this row will be the one of the attached \l {value} {SwitchRole.value} property.
|
||||
|
|
Loading…
Reference in New Issue