49 | )
50 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | Copyright (c) 2016 Pierre-Yves Siret
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 |
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/SortFilterProxyModel.pri:
--------------------------------------------------------------------------------
1 | !contains( CONFIG, c\+\+1[14] ): warning("SortFilterProxyModel needs at least c++11, add CONFIG += c++11 to your .pro")
2 |
3 | INCLUDEPATH += $$PWD
4 |
5 | HEADERS += $$PWD/qqmlsortfilterproxymodel.h \
6 | $$PWD/filters/filter.h \
7 | $$PWD/filters/filtercontainer.h \
8 | $$PWD/filters/rolefilter.h \
9 | $$PWD/filters/valuefilter.h \
10 | $$PWD/filters/indexfilter.h \
11 | $$PWD/filters/regexpfilter.h \
12 | $$PWD/filters/rangefilter.h \
13 | $$PWD/filters/expressionfilter.h \
14 | $$PWD/filters/filtercontainerfilter.h \
15 | $$PWD/filters/filtersqmltypes.h \
16 | $$PWD/filters/anyoffilter.h \
17 | $$PWD/filters/alloffilter.h \
18 | $$PWD/sorters/sorter.h \
19 | $$PWD/sorters/sortercontainer.h \
20 | $$PWD/sorters/rolesorter.h \
21 | $$PWD/sorters/stringsorter.h \
22 | $$PWD/sorters/expressionsorter.h \
23 | $$PWD/sorters/sortersqmltypes.h \
24 | $$PWD/proxyroles/proxyrole.h \
25 | $$PWD/proxyroles/proxyrolecontainer.h \
26 | $$PWD/proxyroles/joinrole.h \
27 | $$PWD/proxyroles/switchrole.h \
28 | $$PWD/proxyroles/expressionrole.h \
29 | $$PWD/proxyroles/singlerole.h \
30 | $$PWD/proxyroles/regexprole.h \
31 | $$PWD/sorters/filtersorter.h \
32 | $$PWD/proxyroles/filterrole.h \
33 | $$PWD/proxyroles/proxyrolesqmltypes.h
34 |
35 | SOURCES += $$PWD/qqmlsortfilterproxymodel.cpp \
36 | $$PWD/filters/filter.cpp \
37 | $$PWD/filters/filtercontainer.cpp \
38 | $$PWD/filters/rolefilter.cpp \
39 | $$PWD/filters/valuefilter.cpp \
40 | $$PWD/filters/indexfilter.cpp \
41 | $$PWD/filters/regexpfilter.cpp \
42 | $$PWD/filters/rangefilter.cpp \
43 | $$PWD/filters/expressionfilter.cpp \
44 | $$PWD/filters/filtercontainerfilter.cpp \
45 | $$PWD/filters/anyoffilter.cpp \
46 | $$PWD/filters/alloffilter.cpp \
47 | $$PWD/filters/filtersqmltypes.cpp \
48 | $$PWD/sorters/sorter.cpp \
49 | $$PWD/sorters/sortercontainer.cpp \
50 | $$PWD/sorters/rolesorter.cpp \
51 | $$PWD/sorters/stringsorter.cpp \
52 | $$PWD/sorters/expressionsorter.cpp \
53 | $$PWD/sorters/sortersqmltypes.cpp \
54 | $$PWD/proxyroles/proxyrole.cpp \
55 | $$PWD/proxyroles/proxyrolecontainer.cpp \
56 | $$PWD/proxyroles/joinrole.cpp \
57 | $$PWD/proxyroles/switchrole.cpp \
58 | $$PWD/proxyroles/expressionrole.cpp \
59 | $$PWD/proxyroles/proxyrolesqmltypes.cpp \
60 | $$PWD/proxyroles/singlerole.cpp \
61 | $$PWD/proxyroles/regexprole.cpp \
62 | $$PWD/sorters/filtersorter.cpp \
63 | $$PWD/proxyroles/filterrole.cpp
64 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-allof-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for AllOf | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for AllOf
13 | This is the complete list of members for AllOf , including inherited members.
14 | The following members are inherited from Filter .
15 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-allof.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | AllOf QML Type | SortFilterProxyModel
8 |
9 |
10 |
11 |
19 | AllOf QML Type
20 |
21 |
22 | Filter container accepting rows accepted by all its child filters More...
23 |
24 |
25 | Import Statement: import . Inherits: Filter
26 |
29 |
30 |
31 | Detailed Description
32 | The AllOf type is a Filter container that accepts rows if all of its contained (and enabled) filters accept them, or if it has no filter.
33 | Using it as a top level filter has the same effect as putting all its child filters as top level filters. It can however be usefull to use an AllOf filter when nested in an AnyOf filter.
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-anyof-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for AnyOf | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for AnyOf
13 | This is the complete list of members for AnyOf , including inherited members.
14 | The following members are inherited from Filter .
15 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-anyof.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | AnyOf QML Type | SortFilterProxyModel
8 |
9 |
10 |
11 |
19 | AnyOf QML Type
20 |
21 |
22 | Filter container accepting rows accepted by at least one of its child filters More...
23 |
24 |
25 | Import Statement: import . Inherits: Filter
26 |
29 |
30 |
31 | Detailed Description
32 | The AnyOf type is a Filter container that accepts rows if any of its contained (and enabled) filters accept them.
33 | In the following example, only the rows where the firstName
role or the lastName
role match the text entered in the nameTextField
will be accepted :
34 | TextField {
35 | id: nameTextField
36 | }
37 |
38 | SortFilterProxyModel {
39 | sourceModel: contactModel
40 | filters: AnyOf {
41 | RegExpFilter {
42 | roleName: "lastName"
43 | pattern: nameTextField. text
44 | caseSensitivity: Qt . CaseInsensitive
45 | }
46 | RegExpFilter {
47 | roleName: "firstName"
48 | pattern: nameTextField. text
49 | caseSensitivity: Qt . CaseInsensitive
50 | }
51 | }
52 | }
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-expressionfilter-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for ExpressionFilter | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for ExpressionFilter
13 | This is the complete list of members for ExpressionFilter , including inherited members.
14 |
17 | The following members are inherited from Filter .
18 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-expressionrole-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for ExpressionRole | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for ExpressionRole
13 | This is the complete list of members for ExpressionRole , including inherited members.
14 |
17 | The following members are inherited from SingleRole .
18 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-expressionsorter-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for ExpressionSorter | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for ExpressionSorter
13 | This is the complete list of members for ExpressionSorter , including inherited members.
14 |
17 | The following members are inherited from Sorter .
18 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-filter-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for Filter | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for Filter
13 | This is the complete list of members for Filter , including inherited members.
14 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-filterrole-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for FilterRole | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for FilterRole
13 | This is the complete list of members for FilterRole , including inherited members.
14 |
17 | The following members are inherited from SingleRole .
18 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-filterrole.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | FilterRole QML Type | SortFilterProxyModel
8 |
9 |
10 |
11 |
20 | FilterRole QML Type
21 |
22 |
23 | A role resolving to true
for rows matching all its filters More...
24 |
25 |
26 | Import Statement: import . Inherits: SingleRole
27 |
30 |
31 | Properties
32 |
35 |
36 |
37 | Detailed Description
38 | A FilterRole is a ProxyRole that returns true
for rows matching all its filters.
39 | In the following example, the isAdult
role will be equal to true
if the age
role is superior or equal to 18.
40 | SortFilterProxyModel {
41 | sourceModel: personModel
42 | proxyRoles: FilterRole {
43 | name: "isAdult"
44 | RangeFilter { roleName: "age" ; minimumValue: 18 ; minimumInclusive: true }
45 | }
46 | }
47 |
48 | Property Documentation
49 |
50 |
51 |
52 |
53 |
54 | filters : string
55 |
56 |
This property holds the list of filters for this filter role. The data of this role will be equal to the true
if all its filters match the model row, false
otherwise.
57 |
See also Filter .
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-filtersorter-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for FilterSorter | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for FilterSorter
13 | This is the complete list of members for FilterSorter , including inherited members.
14 |
17 | The following members are inherited from Sorter .
18 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-filtersorter.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | FilterSorter QML Type | SortFilterProxyModel
8 |
9 |
10 |
11 |
20 | FilterSorter QML Type
21 |
22 |
23 | Sorts rows based on if they match filters More...
24 |
25 |
26 | Import Statement: import . Inherits: Sorter
27 |
30 |
31 | Properties
32 |
35 |
36 |
37 | Detailed Description
38 | A FilterSorter is a Sorter that orders row matching its filters before the rows not matching the filters.
39 | In the following example, rows with their favorite
role set to true
will be ordered at the beginning :
40 | SortFilterProxyModel {
41 | sourceModel: contactModel
42 | sorters: FilterSorter {
43 | ValueFilter { roleName: "favorite" ; value: true }
44 | }
45 | }
46 |
47 | Property Documentation
48 |
49 |
50 |
51 |
52 |
53 | filters : string
54 |
55 |
This property holds the list of filters for this filter sorter. If a row match all this FilterSorter 's filters, it will be ordered before rows not matching all the filters.
56 |
See also Filter .
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-indexfilter-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for IndexFilter | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for IndexFilter
13 | This is the complete list of members for IndexFilter , including inherited members.
14 |
18 | The following members are inherited from Filter .
19 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-joinrole-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for JoinRole | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for JoinRole
13 | This is the complete list of members for JoinRole , including inherited members.
14 |
18 | The following members are inherited from SingleRole .
19 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-proxyrole-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for ProxyRole | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for ProxyRole
13 | This is the complete list of members for ProxyRole , including inherited members.
14 |
15 |
16 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-proxyrole.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | ProxyRole QML Type | SortFilterProxyModel
8 |
9 |
10 |
11 |
19 | ProxyRole QML Type
20 |
21 |
22 | Base type for the SortFilterProxyModel proxy roles More...
23 |
24 |
29 |
30 |
31 | Detailed Description
32 | The ProxyRole type cannot be used directly in a QML file. It exists to provide a set of common properties and methods, available across all the other proxy role types that inherit from it. Attempting to use the ProxyRole type directly will result in an error.
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-rangefilter-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for RangeFilter | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for RangeFilter
13 | This is the complete list of members for RangeFilter , including inherited members.
14 |
21 | The following members are inherited from Filter .
22 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-regexpfilter-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for RegExpFilter | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for RegExpFilter
13 | This is the complete list of members for RegExpFilter , including inherited members.
14 |
20 | The following members are inherited from Filter .
21 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-regexprole-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for RegExpRole | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for RegExpRole
13 | This is the complete list of members for RegExpRole , including inherited members.
14 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-rolefilter-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for RoleFilter | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for RoleFilter
13 | This is the complete list of members for RoleFilter , including inherited members.
14 |
17 | The following members are inherited from Filter .
18 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-rolefilter.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | RoleFilter QML Type | SortFilterProxyModel
8 |
9 |
10 |
11 |
20 | RoleFilter QML Type
21 |
22 |
23 | Base type for filters based on a source model role More...
24 |
25 |
31 |
32 | Properties
33 |
36 |
37 |
38 | Detailed Description
39 | The RoleFilter type cannot be used directly in a QML file. It exists to provide a set of common properties and methods, available across all the other filter types that inherit from it. Attempting to use the RoleFilter type directly will result in an error.
40 |
41 | Property Documentation
42 |
43 |
44 |
45 |
46 |
47 | roleName : string
48 |
49 |
This property holds the role name that the filter is using to query the source model's data when filtering items.
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-rolesorter-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for RoleSorter | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for RoleSorter
13 | This is the complete list of members for RoleSorter , including inherited members.
14 |
17 | The following members are inherited from Sorter .
18 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-rolesorter.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | RoleSorter QML Type | SortFilterProxyModel
8 |
9 |
10 |
11 |
20 | RoleSorter QML Type
21 |
22 |
23 | Sorts rows based on a source model role More...
24 |
25 |
31 |
32 | Properties
33 |
36 |
37 |
38 | Detailed Description
39 | A RoleSorter is a simple Sorter that sorts rows based on a source model role.
40 | In the following example, rows with be sorted by their lastName
role :
41 | SortFilterProxyModel {
42 | sourceModel: contactModel
43 | sorters: RoleSorter { roleName: "lastName" }
44 | }
45 |
46 | Property Documentation
47 |
48 |
49 |
50 |
51 |
52 | roleName : string
53 |
54 |
This property holds the role name that the sorter is using to query the source model's data when sorting items.
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-singlerole-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for SingleRole | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for SingleRole
13 | This is the complete list of members for SingleRole , including inherited members.
14 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-singlerole.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | SingleRole QML Type | SortFilterProxyModel
8 |
9 |
10 |
11 |
20 | SingleRole QML Type
21 |
22 |
23 | Base type for the SortFilterProxyModel proxy roles defining a single role More...
24 |
25 |
31 |
32 | Properties
33 |
36 |
37 |
38 | Detailed Description
39 | SingleRole is a convenience base class for proxy roles who define a single role. It cannot be used directly in a QML file. It exists to provide a set of common properties and methods, available across all the other proxy role types that inherit from it. Attempting to use the SingleRole type directly will result in an error.
40 |
41 | Property Documentation
42 |
43 |
44 |
45 |
46 |
47 | name : string
48 |
49 |
This property holds the role name of the proxy role.
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-sorter-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for Sorter | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for Sorter
13 | This is the complete list of members for Sorter , including inherited members.
14 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-sortfilterproxymodel-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for SortFilterProxyModel | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for SortFilterProxyModel
13 | This is the complete list of members for SortFilterProxyModel , including inherited members.
14 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-stringsorter-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for StringSorter | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for StringSorter
13 | This is the complete list of members for StringSorter , including inherited members.
14 |
20 | The following members are inherited from RoleSorter .
21 |
24 | The following members are inherited from Sorter .
25 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-switchrole-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for SwitchRole | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for SwitchRole
13 | This is the complete list of members for SwitchRole , including inherited members.
14 |
20 | The following members are inherited from SingleRole .
21 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/docs/qml-valuefilter-members.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of All Members for ValueFilter | SortFilterProxyModel
8 |
9 |
10 |
11 |
12 | List of All Members for ValueFilter
13 | This is the complete list of members for ValueFilter , including inherited members.
14 |
18 | The following members are inherited from Filter .
19 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/alloffilter.cpp:
--------------------------------------------------------------------------------
1 | #include "alloffilter.h"
2 |
3 | namespace qqsfpm {
4 |
5 | /*!
6 | \qmltype AllOf
7 | \inherits Filter
8 | \inqmlmodule SortFilterProxyModel
9 | \brief Filter container accepting rows accepted by all its child filters
10 |
11 | The AllOf type is a \l Filter container that accepts rows if all of its contained (and enabled) filters accept them, or if it has no filter.
12 |
13 | Using it as a top level filter has the same effect as putting all its child filters as top level filters. It can however be usefull to use an AllOf filter when nested in an AnyOf filter.
14 | */
15 | bool AllOfFilter::filterRow(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const
16 | {
17 | //return true if all filters return false, or if there is no filter.
18 | return std::all_of(m_filters.begin(), m_filters.end(),
19 | [&sourceIndex, &proxyModel] (Filter* filter) {
20 | return filter->filterAcceptsRow(sourceIndex, proxyModel);
21 | }
22 | );
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/alloffilter.h:
--------------------------------------------------------------------------------
1 | #ifndef ALLOFFILTER_H
2 | #define ALLOFFILTER_H
3 |
4 | #include "filtercontainerfilter.h"
5 |
6 | namespace qqsfpm {
7 |
8 | class AllOfFilter : public FilterContainerFilter {
9 | Q_OBJECT
10 |
11 | public:
12 | using FilterContainerFilter::FilterContainerFilter;
13 |
14 | protected:
15 | bool filterRow(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const override;
16 | };
17 |
18 | }
19 |
20 | #endif // ALLOFFILTER_H
21 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/anyoffilter.cpp:
--------------------------------------------------------------------------------
1 | #include "anyoffilter.h"
2 |
3 | namespace qqsfpm {
4 |
5 | /*!
6 | \qmltype AnyOf
7 | \inherits Filter
8 | \inqmlmodule SortFilterProxyModel
9 | \brief Filter container accepting rows accepted by at least one of its child filters
10 |
11 | The AnyOf type is a \l Filter container that accepts rows if any of its contained (and enabled) filters accept them.
12 |
13 | In the following example, only the rows where the \c firstName role or the \c lastName role match the text entered in the \c nameTextField will be accepted :
14 | \code
15 | TextField {
16 | id: nameTextField
17 | }
18 |
19 | SortFilterProxyModel {
20 | sourceModel: contactModel
21 | filters: AnyOf {
22 | RegExpFilter {
23 | roleName: "lastName"
24 | pattern: nameTextField.text
25 | caseSensitivity: Qt.CaseInsensitive
26 | }
27 | RegExpFilter {
28 | roleName: "firstName"
29 | pattern: nameTextField.text
30 | caseSensitivity: Qt.CaseInsensitive
31 | }
32 | }
33 | }
34 | \endcode
35 | */
36 | bool AnyOfFilter::filterRow(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const
37 | {
38 | //return true if any of the enabled filters return true
39 | return std::any_of(m_filters.begin(), m_filters.end(),
40 | [&sourceIndex, &proxyModel] (Filter* filter) {
41 | return filter->enabled() && filter->filterAcceptsRow(sourceIndex, proxyModel);
42 | }
43 | );
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/anyoffilter.h:
--------------------------------------------------------------------------------
1 | #ifndef ANYOFFILTER_H
2 | #define ANYOFFILTER_H
3 |
4 | #include "filtercontainerfilter.h"
5 |
6 | namespace qqsfpm {
7 |
8 | class AnyOfFilter : public FilterContainerFilter {
9 | Q_OBJECT
10 |
11 | public:
12 | using FilterContainerFilter::FilterContainerFilter;
13 |
14 | protected:
15 | bool filterRow(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const override;
16 | };
17 |
18 | }
19 |
20 | #endif // ANYOFFILTER_H
21 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/expressionfilter.h:
--------------------------------------------------------------------------------
1 | #ifndef EXPRESSIONFILTER_H
2 | #define EXPRESSIONFILTER_H
3 |
4 | #include "filter.h"
5 | #include
6 |
7 | class QQmlExpression;
8 |
9 | namespace qqsfpm {
10 |
11 | class ExpressionFilter : public Filter
12 | {
13 | Q_OBJECT
14 | Q_PROPERTY(QQmlScriptString expression READ expression WRITE setExpression NOTIFY expressionChanged)
15 |
16 | public:
17 | using Filter::Filter;
18 |
19 | const QQmlScriptString& expression() const;
20 | void setExpression(const QQmlScriptString& scriptString);
21 |
22 | void proxyModelCompleted(const QQmlSortFilterProxyModel& proxyModel) override;
23 |
24 | protected:
25 | bool filterRow(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const override;
26 |
27 | Q_SIGNALS:
28 | void expressionChanged();
29 |
30 | private:
31 | void updateContext(const QQmlSortFilterProxyModel& proxyModel);
32 | void updateExpression();
33 |
34 | QQmlScriptString m_scriptString;
35 | QQmlExpression* m_expression = nullptr;
36 | QQmlContext* m_context = nullptr;
37 | };
38 |
39 | }
40 |
41 | #endif // EXPRESSIONFILTER_H
42 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/filter.cpp:
--------------------------------------------------------------------------------
1 | #include "filter.h"
2 | #include "qqmlsortfilterproxymodel.h"
3 |
4 | namespace qqsfpm {
5 |
6 | /*!
7 | \qmltype Filter
8 | \inqmlmodule SortFilterProxyModel
9 | \brief Base type for the \l SortFilterProxyModel filters
10 |
11 | The Filter type cannot be used directly in a QML file.
12 | It exists to provide a set of common properties and methods,
13 | available across all the other filter types that inherit from it.
14 | Attempting to use the Filter type directly will result in an error.
15 | */
16 |
17 | Filter::Filter(QObject *parent) : QObject(parent)
18 | {
19 | }
20 |
21 | /*!
22 | \qmlproperty bool Filter::enabled
23 |
24 | This property holds whether the filter is enabled.
25 | A disabled filter will accept every rows unconditionally (even if it's inverted).
26 |
27 | By default, filters are enabled.
28 | */
29 | bool Filter::enabled() const
30 | {
31 | return m_enabled;
32 | }
33 |
34 | void Filter::setEnabled(bool enabled)
35 | {
36 | if (m_enabled == enabled)
37 | return;
38 |
39 | m_enabled = enabled;
40 | Q_EMIT enabledChanged();
41 | Q_EMIT invalidated();
42 | }
43 |
44 | /*!
45 | \qmlproperty bool Filter::inverted
46 |
47 | This property holds whether the filter is inverted.
48 | When a filter is inverted, a row normally accepted would be rejected, and vice-versa.
49 |
50 | By default, filters are not inverted.
51 | */
52 | bool Filter::inverted() const
53 | {
54 | return m_inverted;
55 | }
56 |
57 | void Filter::setInverted(bool inverted)
58 | {
59 | if (m_inverted == inverted)
60 | return;
61 |
62 | m_inverted = inverted;
63 | Q_EMIT invertedChanged();
64 | invalidate();
65 | }
66 |
67 | bool Filter::filterAcceptsRow(const QModelIndex &sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const
68 | {
69 | return !m_enabled || filterRow(sourceIndex, proxyModel) ^ m_inverted;
70 | }
71 |
72 | void Filter::proxyModelCompleted(const QQmlSortFilterProxyModel& proxyModel)
73 | {
74 | Q_UNUSED(proxyModel)
75 | }
76 |
77 | void Filter::invalidate()
78 | {
79 | if (m_enabled)
80 | Q_EMIT invalidated();
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/filter.h:
--------------------------------------------------------------------------------
1 | #ifndef FILTER_H
2 | #define FILTER_H
3 |
4 | #include
5 |
6 | namespace qqsfpm {
7 |
8 | class QQmlSortFilterProxyModel;
9 |
10 | class Filter : public QObject
11 | {
12 | Q_OBJECT
13 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
14 | Q_PROPERTY(bool inverted READ inverted WRITE setInverted NOTIFY invertedChanged)
15 |
16 | public:
17 | explicit Filter(QObject *parent = nullptr);
18 | virtual ~Filter() = default;
19 |
20 | bool enabled() const;
21 | void setEnabled(bool enabled);
22 |
23 | bool inverted() const;
24 | void setInverted(bool inverted);
25 |
26 | bool filterAcceptsRow(const QModelIndex &sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const;
27 |
28 | virtual void proxyModelCompleted(const QQmlSortFilterProxyModel& proxyModel);
29 |
30 | Q_SIGNALS:
31 | void enabledChanged();
32 | void invertedChanged();
33 | void invalidated();
34 |
35 | protected:
36 | virtual bool filterRow(const QModelIndex &sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const = 0;
37 | void invalidate();
38 |
39 | private:
40 | bool m_enabled = true;
41 | bool m_inverted = false;
42 | };
43 |
44 | }
45 |
46 | #endif // FILTER_H
47 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/filtercontainer.cpp:
--------------------------------------------------------------------------------
1 | #include "filtercontainer.h"
2 |
3 | namespace qqsfpm {
4 |
5 | FilterContainer::~FilterContainer()
6 | {
7 |
8 | }
9 |
10 | QList FilterContainer::filters() const
11 | {
12 | return m_filters;
13 | }
14 |
15 | void FilterContainer::appendFilter(Filter* filter)
16 | {
17 | m_filters.append(filter);
18 | onFilterAppended(filter);
19 | }
20 |
21 | void FilterContainer::removeFilter(Filter* filter)
22 | {
23 | m_filters.removeOne(filter);
24 | onFilterRemoved(filter);
25 | }
26 |
27 | void FilterContainer::clearFilters()
28 | {
29 | m_filters.clear();
30 | onFiltersCleared();
31 | }
32 |
33 | QQmlListProperty FilterContainer::filtersListProperty()
34 | {
35 | return QQmlListProperty(reinterpret_cast(this), &m_filters,
36 | &FilterContainer::append_filter,
37 | &FilterContainer::count_filter,
38 | &FilterContainer::at_filter,
39 | &FilterContainer::clear_filters);
40 | }
41 |
42 | void FilterContainer::append_filter(QQmlListProperty* list, Filter* filter)
43 | {
44 | if (!filter)
45 | return;
46 |
47 | FilterContainer* that = reinterpret_cast(list->object);
48 | that->appendFilter(filter);
49 | }
50 |
51 | int FilterContainer::count_filter(QQmlListProperty* list)
52 | {
53 | QList* filters = static_cast*>(list->data);
54 | return filters->count();
55 | }
56 |
57 | Filter* FilterContainer::at_filter(QQmlListProperty* list, int index)
58 | {
59 | QList* filters = static_cast*>(list->data);
60 | return filters->at(index);
61 | }
62 |
63 | void FilterContainer::clear_filters(QQmlListProperty *list)
64 | {
65 | FilterContainer* that = reinterpret_cast(list->object);
66 | that->clearFilters();
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/filtercontainer.h:
--------------------------------------------------------------------------------
1 | #ifndef FILTERCONTAINER_H
2 | #define FILTERCONTAINER_H
3 |
4 | #include
5 | #include
6 |
7 | namespace qqsfpm {
8 |
9 | class Filter;
10 | class QQmlSortFilterProxyModel;
11 |
12 | class FilterContainer {
13 | public:
14 | virtual ~FilterContainer();
15 |
16 | QList filters() const;
17 | void appendFilter(Filter* filter);
18 | void removeFilter(Filter* filter);
19 | void clearFilters();
20 |
21 | QQmlListProperty filtersListProperty();
22 |
23 | protected:
24 | QList m_filters;
25 |
26 | private:
27 | virtual void onFilterAppended(Filter* filter) = 0;
28 | virtual void onFilterRemoved(Filter* filter) = 0;
29 | virtual void onFiltersCleared() = 0;
30 |
31 | static void append_filter(QQmlListProperty* list, Filter* filter);
32 | static int count_filter(QQmlListProperty* list);
33 | static Filter* at_filter(QQmlListProperty* list, int index);
34 | static void clear_filters(QQmlListProperty* list);
35 | };
36 |
37 | }
38 |
39 | #define FilterContainer_iid "fr.grecko.SortFilterProxyModel.FilterContainer"
40 | Q_DECLARE_INTERFACE(qqsfpm::FilterContainer, FilterContainer_iid)
41 |
42 | #endif // FILTERCONTAINER_H
43 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/filtercontainerfilter.cpp:
--------------------------------------------------------------------------------
1 | #include "filtercontainerfilter.h"
2 |
3 | namespace qqsfpm {
4 |
5 | void FilterContainerFilter::proxyModelCompleted(const QQmlSortFilterProxyModel& proxyModel)
6 | {
7 | for (Filter* filter : m_filters)
8 | filter->proxyModelCompleted(proxyModel);
9 | }
10 |
11 | void FilterContainerFilter::onFilterAppended(Filter* filter)
12 | {
13 | connect(filter, &Filter::invalidated, this, &FilterContainerFilter::invalidate);
14 | invalidate();
15 | }
16 |
17 | void FilterContainerFilter::onFilterRemoved(Filter* filter)
18 | {
19 | Q_UNUSED(filter)
20 | invalidate();
21 | }
22 |
23 | void qqsfpm::FilterContainerFilter::onFiltersCleared()
24 | {
25 | invalidate();
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/filtercontainerfilter.h:
--------------------------------------------------------------------------------
1 | #ifndef FILTERCONTAINERFILTER_H
2 | #define FILTERCONTAINERFILTER_H
3 |
4 | #include "filter.h"
5 | #include "filtercontainer.h"
6 |
7 | namespace qqsfpm {
8 |
9 | class FilterContainerFilter : public Filter, public FilterContainer {
10 | Q_OBJECT
11 | Q_INTERFACES(qqsfpm::FilterContainer)
12 | Q_PROPERTY(QQmlListProperty filters READ filtersListProperty NOTIFY filtersChanged)
13 | Q_CLASSINFO("DefaultProperty", "filters")
14 |
15 | public:
16 | using Filter::Filter;
17 |
18 | void proxyModelCompleted(const QQmlSortFilterProxyModel& proxyModel) override;
19 |
20 | Q_SIGNALS:
21 | void filtersChanged();
22 |
23 | private:
24 | void onFilterAppended(Filter* filter) override;
25 | void onFilterRemoved(Filter* filter) override;
26 | void onFiltersCleared() override;
27 | };
28 |
29 | }
30 |
31 | #endif // FILTERCONTAINERFILTER_H
32 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/filtersqmltypes.cpp:
--------------------------------------------------------------------------------
1 | #include "filter.h"
2 | #include "valuefilter.h"
3 | #include "indexfilter.h"
4 | #include "regexpfilter.h"
5 | #include "rangefilter.h"
6 | #include "expressionfilter.h"
7 | #include "anyoffilter.h"
8 | #include "alloffilter.h"
9 | #include
10 | #include
11 |
12 | namespace qqsfpm {
13 |
14 | void registerFiltersTypes() {
15 | qmlRegisterUncreatableType("SortFilterProxyModel", 0, 2, "Filter", "Filter is an abstract class");
16 | qmlRegisterType("SortFilterProxyModel", 0, 2, "ValueFilter");
17 | qmlRegisterType("SortFilterProxyModel", 0, 2, "IndexFilter");
18 | qmlRegisterType("SortFilterProxyModel", 0, 2, "RegExpFilter");
19 | qmlRegisterType("SortFilterProxyModel", 0, 2, "RangeFilter");
20 | qmlRegisterType("SortFilterProxyModel", 0, 2, "ExpressionFilter");
21 | qmlRegisterType("SortFilterProxyModel", 0, 2, "AnyOf");
22 | qmlRegisterType("SortFilterProxyModel", 0, 2, "AllOf");
23 | }
24 |
25 | Q_COREAPP_STARTUP_FUNCTION(registerFiltersTypes)
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/filtersqmltypes.h:
--------------------------------------------------------------------------------
1 | #ifndef FILTERSQMLTYPES_H
2 | #define FILTERSQMLTYPES_H
3 |
4 | namespace qqsfpm {
5 |
6 | void registerFiltersTypes();
7 |
8 | }
9 |
10 | #endif // FILTERSQMLTYPES_H
11 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/indexfilter.h:
--------------------------------------------------------------------------------
1 | #ifndef INDEXFILTER_H
2 | #define INDEXFILTER_H
3 |
4 | #include "filter.h"
5 | #include
6 |
7 | namespace qqsfpm {
8 |
9 | class IndexFilter: public Filter {
10 | Q_OBJECT
11 | Q_PROPERTY(QVariant minimumIndex READ minimumIndex WRITE setMinimumIndex NOTIFY minimumIndexChanged)
12 | Q_PROPERTY(QVariant maximumIndex READ maximumIndex WRITE setMaximumIndex NOTIFY maximumIndexChanged)
13 |
14 | public:
15 | using Filter::Filter;
16 |
17 | const QVariant& minimumIndex() const;
18 | void setMinimumIndex(const QVariant& minimumIndex);
19 |
20 | const QVariant& maximumIndex() const;
21 | void setMaximumIndex(const QVariant& maximumIndex);
22 |
23 | protected:
24 | bool filterRow(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const override;
25 |
26 | Q_SIGNALS:
27 | void minimumIndexChanged();
28 | void maximumIndexChanged();
29 |
30 | private:
31 | QVariant m_minimumIndex;
32 | QVariant m_maximumIndex;
33 | };
34 |
35 | }
36 |
37 | #endif // INDEXFILTER_H
38 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/rangefilter.h:
--------------------------------------------------------------------------------
1 | #ifndef RANGEFILTER_H
2 | #define RANGEFILTER_H
3 |
4 | #include "rolefilter.h"
5 | #include
6 |
7 | namespace qqsfpm {
8 |
9 | class RangeFilter : public RoleFilter
10 | {
11 | Q_OBJECT
12 | Q_PROPERTY(QVariant minimumValue READ minimumValue WRITE setMinimumValue NOTIFY minimumValueChanged)
13 | Q_PROPERTY(bool minimumInclusive READ minimumInclusive WRITE setMinimumInclusive NOTIFY minimumInclusiveChanged)
14 | Q_PROPERTY(QVariant maximumValue READ maximumValue WRITE setMaximumValue NOTIFY maximumValueChanged)
15 | Q_PROPERTY(bool maximumInclusive READ maximumInclusive WRITE setMaximumInclusive NOTIFY maximumInclusiveChanged)
16 |
17 | public:
18 | using RoleFilter::RoleFilter;
19 |
20 | QVariant minimumValue() const;
21 | void setMinimumValue(QVariant minimumValue);
22 | bool minimumInclusive() const;
23 | void setMinimumInclusive(bool minimumInclusive);
24 |
25 | QVariant maximumValue() const;
26 | void setMaximumValue(QVariant maximumValue);
27 | bool maximumInclusive() const;
28 | void setMaximumInclusive(bool maximumInclusive);
29 |
30 | protected:
31 | bool filterRow(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const override;
32 |
33 | Q_SIGNALS:
34 | void minimumValueChanged();
35 | void minimumInclusiveChanged();
36 | void maximumValueChanged();
37 | void maximumInclusiveChanged();
38 |
39 | private:
40 | QVariant m_minimumValue;
41 | bool m_minimumInclusive = true;
42 | QVariant m_maximumValue;
43 | bool m_maximumInclusive = true;
44 | };
45 |
46 | }
47 |
48 | #endif // RANGEFILTER_H
49 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/regexpfilter.h:
--------------------------------------------------------------------------------
1 | #ifndef REGEXPFILTER_H
2 | #define REGEXPFILTER_H
3 |
4 | #include "rolefilter.h"
5 |
6 | namespace qqsfpm {
7 |
8 | class RegExpFilter : public RoleFilter {
9 | Q_OBJECT
10 | Q_PROPERTY(QString pattern READ pattern WRITE setPattern NOTIFY patternChanged)
11 | Q_PROPERTY(PatternSyntax syntax READ syntax WRITE setSyntax NOTIFY syntaxChanged)
12 | Q_PROPERTY(Qt::CaseSensitivity caseSensitivity READ caseSensitivity WRITE setCaseSensitivity NOTIFY caseSensitivityChanged)
13 |
14 | public:
15 | enum PatternSyntax {
16 | RegExp = QRegExp::RegExp,
17 | Wildcard = QRegExp::Wildcard,
18 | FixedString = QRegExp::FixedString,
19 | RegExp2 = QRegExp::RegExp2,
20 | WildcardUnix = QRegExp::WildcardUnix,
21 | W3CXmlSchema11 = QRegExp::W3CXmlSchema11 };
22 | Q_ENUMS(PatternSyntax)
23 |
24 | using RoleFilter::RoleFilter;
25 |
26 | QString pattern() const;
27 | void setPattern(const QString& pattern);
28 |
29 | PatternSyntax syntax() const;
30 | void setSyntax(PatternSyntax syntax);
31 |
32 | Qt::CaseSensitivity caseSensitivity() const;
33 | void setCaseSensitivity(Qt::CaseSensitivity caseSensitivity);
34 |
35 | protected:
36 | bool filterRow(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const override;
37 |
38 | Q_SIGNALS:
39 | void patternChanged();
40 | void syntaxChanged();
41 | void caseSensitivityChanged();
42 |
43 | private:
44 | QRegExp m_regExp;
45 | Qt::CaseSensitivity m_caseSensitivity = m_regExp.caseSensitivity();
46 | PatternSyntax m_syntax = static_cast(m_regExp.patternSyntax());
47 | QString m_pattern = m_regExp.pattern();
48 | };
49 |
50 | }
51 |
52 | #endif // REGEXPFILTER_H
53 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/rolefilter.cpp:
--------------------------------------------------------------------------------
1 | #include "rolefilter.h"
2 | #include "qqmlsortfilterproxymodel.h"
3 |
4 | namespace qqsfpm {
5 |
6 | /*!
7 | \qmltype RoleFilter
8 | \qmlabstract
9 | \inherits Filter
10 | \inqmlmodule SortFilterProxyModel
11 | \brief Base type for filters based on a source model role
12 |
13 | The RoleFilter type cannot be used directly in a QML file.
14 | It exists to provide a set of common properties and methods,
15 | available across all the other filter types that inherit from it.
16 | Attempting to use the RoleFilter type directly will result in an error.
17 | */
18 |
19 | /*!
20 | \qmlproperty string RoleFilter::roleName
21 |
22 | This property holds the role name that the filter is using to query the source model's data when filtering items.
23 | */
24 | const QString& RoleFilter::roleName() const
25 | {
26 | return m_roleName;
27 | }
28 |
29 | void RoleFilter::setRoleName(const QString& roleName)
30 | {
31 | if (m_roleName == roleName)
32 | return;
33 |
34 | m_roleName = roleName;
35 | Q_EMIT roleNameChanged();
36 | invalidate();
37 | }
38 |
39 | QVariant RoleFilter::sourceData(const QModelIndex &sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const
40 | {
41 | return proxyModel.sourceData(sourceIndex, m_roleName);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/rolefilter.h:
--------------------------------------------------------------------------------
1 | #ifndef ROLEFILTER_H
2 | #define ROLEFILTER_H
3 |
4 | #include "filter.h"
5 |
6 | namespace qqsfpm {
7 |
8 | class RoleFilter : public Filter
9 | {
10 | Q_OBJECT
11 | Q_PROPERTY(QString roleName READ roleName WRITE setRoleName NOTIFY roleNameChanged)
12 |
13 | public:
14 | using Filter::Filter;
15 |
16 | const QString& roleName() const;
17 | void setRoleName(const QString& roleName);
18 |
19 | Q_SIGNALS:
20 | void roleNameChanged();
21 |
22 | protected:
23 | QVariant sourceData(const QModelIndex &sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const;
24 |
25 | private:
26 | QString m_roleName;
27 | };
28 |
29 | }
30 |
31 | #endif // ROLEFILTER_H
32 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/valuefilter.cpp:
--------------------------------------------------------------------------------
1 | #include "valuefilter.h"
2 |
3 | namespace qqsfpm {
4 |
5 | /*!
6 | \qmltype ValueFilter
7 | \inherits RoleFilter
8 | \inqmlmodule SortFilterProxyModel
9 | \brief Filters rows matching exactly a value
10 |
11 | A ValueFilter is a simple \l RoleFilter that accepts rows matching exactly the filter's value
12 |
13 | In the following example, only rows with their \c favorite role set to \c true will be accepted when the checkbox is checked :
14 | \code
15 | CheckBox {
16 | id: showOnlyFavoriteCheckBox
17 | }
18 |
19 | SortFilterProxyModel {
20 | sourceModel: contactModel
21 | filters: ValueFilter {
22 | roleName: "favorite"
23 | value: true
24 | enabled: showOnlyFavoriteCheckBox.checked
25 | }
26 | }
27 | \endcode
28 |
29 | */
30 |
31 | /*!
32 | \qmlproperty variant ValueFilter::value
33 |
34 | This property holds the value used to filter the contents of the source model.
35 | */
36 | const QVariant &ValueFilter::value() const
37 | {
38 | return m_value;
39 | }
40 |
41 | void ValueFilter::setValue(const QVariant& value)
42 | {
43 | if (m_value == value)
44 | return;
45 |
46 | m_value = value;
47 | Q_EMIT valueChanged();
48 | invalidate();
49 | }
50 |
51 | bool ValueFilter::filterRow(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const
52 | {
53 | return !m_value.isValid() || m_value == sourceData(sourceIndex, proxyModel);
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/filters/valuefilter.h:
--------------------------------------------------------------------------------
1 | #ifndef VALUEFILTER_H
2 | #define VALUEFILTER_H
3 |
4 | #include "rolefilter.h"
5 | #include
6 |
7 | namespace qqsfpm {
8 |
9 | class ValueFilter : public RoleFilter {
10 | Q_OBJECT
11 | Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
12 |
13 | public:
14 | using RoleFilter::RoleFilter;
15 |
16 | const QVariant& value() const;
17 | void setValue(const QVariant& value);
18 |
19 | protected:
20 | bool filterRow(const QModelIndex &sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const override;
21 |
22 | Q_SIGNALS:
23 | void valueChanged();
24 |
25 | private:
26 | QVariant m_value;
27 | };
28 |
29 | }
30 |
31 | #endif // VALUEFILTER_H
32 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/proxyroles/expressionrole.h:
--------------------------------------------------------------------------------
1 | #ifndef EXPRESSIONROLE_H
2 | #define EXPRESSIONROLE_H
3 |
4 | #include "singlerole.h"
5 | #include
6 |
7 | class QQmlExpression;
8 |
9 | namespace qqsfpm {
10 |
11 | class ExpressionRole : public SingleRole
12 | {
13 | Q_OBJECT
14 | Q_PROPERTY(QQmlScriptString expression READ expression WRITE setExpression NOTIFY expressionChanged)
15 |
16 | public:
17 | using SingleRole::SingleRole;
18 |
19 | const QQmlScriptString& expression() const;
20 | void setExpression(const QQmlScriptString& scriptString);
21 |
22 | void proxyModelCompleted(const QQmlSortFilterProxyModel& proxyModel) override;
23 |
24 | Q_SIGNALS:
25 | void expressionChanged();
26 |
27 | private:
28 | QVariant data(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) override;
29 | void updateContext(const QQmlSortFilterProxyModel& proxyModel);
30 | void updateExpression();
31 |
32 | QQmlScriptString m_scriptString;
33 | QQmlExpression* m_expression = nullptr;
34 | QQmlContext* m_context = nullptr;
35 | };
36 |
37 | }
38 |
39 | #endif // EXPRESSIONROLE_H
40 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/proxyroles/filterrole.cpp:
--------------------------------------------------------------------------------
1 | #include "filterrole.h"
2 | #include "filters/filter.h"
3 |
4 | namespace qqsfpm {
5 |
6 | /*!
7 | \qmltype FilterRole
8 | \inherits SingleRole
9 | \inqmlmodule SortFilterProxyModel
10 | \brief A role resolving to \c true for rows matching all its filters
11 |
12 | A FilterRole is a \l ProxyRole that returns \c true for rows matching all its filters.
13 |
14 | In the following example, the \c isAdult role will be equal to \c true if the \c age role is superior or equal to 18.
15 | \code
16 | SortFilterProxyModel {
17 | sourceModel: personModel
18 | proxyRoles: FilterRole {
19 | name: "isAdult"
20 | RangeFilter { roleName: "age"; minimumValue: 18; minimumInclusive: true }
21 | }
22 | }
23 | \endcode
24 | */
25 |
26 | /*!
27 | \qmlproperty string FilterRole::filters
28 |
29 | This property holds the list of filters for this filter role.
30 | The data of this role will be equal to the \c true if all its filters match the model row, \c false otherwise.
31 |
32 | \sa Filter
33 | */
34 |
35 | void FilterRole::onFilterAppended(Filter* filter)
36 | {
37 | connect(filter, &Filter::invalidated, this, &FilterRole::invalidate);
38 | invalidate();
39 | }
40 |
41 | void FilterRole::onFilterRemoved(Filter* filter)
42 | {
43 | disconnect(filter, &Filter::invalidated, this, &FilterRole::invalidate);
44 | invalidate();
45 | }
46 |
47 | void FilterRole::onFiltersCleared()
48 | {
49 | invalidate();
50 | }
51 |
52 | QVariant FilterRole::data(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel)
53 | {
54 | return std::all_of(m_filters.begin(), m_filters.end(),
55 | [&] (Filter* filter) {
56 | return filter->filterAcceptsRow(sourceIndex, proxyModel);
57 | }
58 | );
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/proxyroles/filterrole.h:
--------------------------------------------------------------------------------
1 | #ifndef FILTERROLE_H
2 | #define FILTERROLE_H
3 |
4 | #include "singlerole.h"
5 | #include "filters/filtercontainer.h"
6 |
7 | namespace qqsfpm {
8 |
9 | class FilterRole : public SingleRole, public FilterContainer
10 | {
11 | Q_OBJECT
12 | Q_INTERFACES(qqsfpm::FilterContainer)
13 | Q_PROPERTY(QQmlListProperty filters READ filtersListProperty)
14 | Q_CLASSINFO("DefaultProperty", "filters")
15 |
16 | public:
17 | using SingleRole::SingleRole;
18 |
19 | private:
20 | void onFilterAppended(Filter* filter) override;
21 | void onFilterRemoved(Filter* filter) override;
22 | void onFiltersCleared() override;
23 |
24 | QVariant data(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) override;
25 | };
26 |
27 | }
28 |
29 | #endif // FILTERROLE_H
30 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/proxyroles/joinrole.cpp:
--------------------------------------------------------------------------------
1 | #include "joinrole.h"
2 | #include "qqmlsortfilterproxymodel.h"
3 |
4 | namespace qqsfpm {
5 |
6 | /*!
7 | \qmltype JoinRole
8 | \inherits SingleRole
9 | \inqmlmodule SortFilterProxyModel
10 | \brief a role made from concatenating other roles
11 |
12 | A JoinRole is a simple \l ProxyRole that concatenates other roles.
13 |
14 | In the following example, the \c fullName role is computed by the concatenation of the \c firstName role and the \c lastName role separated by a space :
15 | \code
16 | SortFilterProxyModel {
17 | sourceModel: contactModel
18 | proxyRoles: JoinRole {
19 | name: "fullName"
20 | roleNames: ["firstName", "lastName"]
21 | }
22 | }
23 | \endcode
24 |
25 | */
26 |
27 | /*!
28 | \qmlproperty list JoinRole::roleNames
29 |
30 | This property holds the role names that are joined by this role.
31 | */
32 | QStringList JoinRole::roleNames() const
33 | {
34 | return m_roleNames;
35 | }
36 |
37 | void JoinRole::setRoleNames(const QStringList& roleNames)
38 | {
39 | if (m_roleNames == roleNames)
40 | return;
41 |
42 | m_roleNames = roleNames;
43 | Q_EMIT roleNamesChanged();
44 | invalidate();
45 | }
46 |
47 | /*!
48 | \qmlproperty string JoinRole::separator
49 |
50 | This property holds the separator that is used to join the roles specified in \l roleNames.
51 |
52 | By default, it's a space.
53 | */
54 | QString JoinRole::separator() const
55 | {
56 | return m_separator;
57 | }
58 |
59 | void JoinRole::setSeparator(const QString& separator)
60 | {
61 | if (m_separator == separator)
62 | return;
63 |
64 | m_separator = separator;
65 | Q_EMIT separatorChanged();
66 | invalidate();
67 | }
68 |
69 | QVariant JoinRole::data(const QModelIndex &sourceIndex, const QQmlSortFilterProxyModel& proxyModel)
70 | {
71 | QString result;
72 |
73 | for (const QString& roleName : m_roleNames)
74 | result += proxyModel.sourceData(sourceIndex, roleName).toString() + m_separator;
75 |
76 | if (!m_roleNames.isEmpty())
77 | result.chop(m_separator.length());
78 |
79 | return result;
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/proxyroles/joinrole.h:
--------------------------------------------------------------------------------
1 | #ifndef JOINROLE_H
2 | #define JOINROLE_H
3 |
4 | #include "singlerole.h"
5 |
6 | namespace qqsfpm {
7 |
8 | class JoinRole : public SingleRole
9 | {
10 | Q_OBJECT
11 | Q_PROPERTY(QStringList roleNames READ roleNames WRITE setRoleNames NOTIFY roleNamesChanged)
12 | Q_PROPERTY(QString separator READ separator WRITE setSeparator NOTIFY separatorChanged)
13 |
14 | public:
15 | using SingleRole::SingleRole;
16 |
17 | QStringList roleNames() const;
18 | void setRoleNames(const QStringList& roleNames);
19 |
20 | QString separator() const;
21 | void setSeparator(const QString& separator);
22 |
23 | Q_SIGNALS:
24 | void roleNamesChanged();
25 |
26 | void separatorChanged();
27 |
28 | private:
29 | QStringList m_roleNames;
30 | QVariant data(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) override;
31 | QString m_separator = " ";
32 | };
33 |
34 | }
35 |
36 | #endif // JOINROLE_H
37 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/proxyroles/proxyrole.cpp:
--------------------------------------------------------------------------------
1 | #include "proxyrole.h"
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include "filters/filter.h"
9 | #include "qqmlsortfilterproxymodel.h"
10 |
11 | namespace qqsfpm {
12 |
13 | /*!
14 | \qmltype ProxyRole
15 | \inqmlmodule SortFilterProxyModel
16 | \brief Base type for the \l SortFilterProxyModel proxy roles
17 |
18 | The ProxyRole type cannot be used directly in a QML file.
19 | It exists to provide a set of common properties and methods,
20 | available across all the other proxy role types that inherit from it.
21 | Attempting to use the ProxyRole type directly will result in an error.
22 | */
23 |
24 | QVariant ProxyRole::roleData(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel, const QString &name)
25 | {
26 | if (m_mutex.tryLock()) {
27 | QVariant result = data(sourceIndex, proxyModel, name);
28 | m_mutex.unlock();
29 | return result;
30 | } else {
31 | return {};
32 | }
33 | }
34 |
35 | void ProxyRole::proxyModelCompleted(const QQmlSortFilterProxyModel &proxyModel)
36 | {
37 | Q_UNUSED(proxyModel)
38 | }
39 |
40 | void ProxyRole::invalidate()
41 | {
42 | Q_EMIT invalidated();
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/proxyroles/proxyrole.h:
--------------------------------------------------------------------------------
1 | #ifndef PROXYROLE_H
2 | #define PROXYROLE_H
3 |
4 | #include
5 | #include
6 |
7 | namespace qqsfpm {
8 |
9 | class QQmlSortFilterProxyModel;
10 |
11 | class ProxyRole : public QObject
12 | {
13 | Q_OBJECT
14 |
15 | public:
16 | using QObject::QObject;
17 | virtual ~ProxyRole() = default;
18 |
19 | QVariant roleData(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel, const QString& name);
20 | virtual void proxyModelCompleted(const QQmlSortFilterProxyModel& proxyModel);
21 |
22 | virtual QStringList names() = 0;
23 |
24 | protected:
25 | void invalidate();
26 |
27 | Q_SIGNALS:
28 | void invalidated();
29 | void namesAboutToBeChanged();
30 | void namesChanged();
31 |
32 | private:
33 | virtual QVariant data(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel, const QString& name) = 0;
34 |
35 | QMutex m_mutex;
36 | };
37 |
38 | }
39 |
40 | #endif // PROXYROLE_H
41 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/proxyroles/proxyrolecontainer.cpp:
--------------------------------------------------------------------------------
1 | #include "proxyrolecontainer.h"
2 |
3 | namespace qqsfpm {
4 |
5 | ProxyRoleContainer::~ProxyRoleContainer()
6 | {
7 |
8 | }
9 |
10 | QList ProxyRoleContainer::proxyRoles() const
11 | {
12 | return m_proxyRoles;
13 | }
14 |
15 | void ProxyRoleContainer::appendProxyRole(ProxyRole* proxyRole)
16 | {
17 | m_proxyRoles.append(proxyRole);
18 | onProxyRoleAppended(proxyRole);
19 | }
20 |
21 | void ProxyRoleContainer::removeProxyRole(ProxyRole* proxyRole)
22 | {
23 | m_proxyRoles.removeOne(proxyRole);
24 | onProxyRoleRemoved(proxyRole);
25 | }
26 |
27 | void ProxyRoleContainer::clearProxyRoles()
28 | {
29 | m_proxyRoles.clear();
30 | onProxyRolesCleared();
31 | }
32 |
33 | QQmlListProperty ProxyRoleContainer::proxyRolesListProperty()
34 | {
35 | return QQmlListProperty(reinterpret_cast(this), &m_proxyRoles,
36 | &ProxyRoleContainer::append_proxyRole,
37 | &ProxyRoleContainer::count_proxyRole,
38 | &ProxyRoleContainer::at_proxyRole,
39 | &ProxyRoleContainer::clear_proxyRoles);
40 | }
41 |
42 | void ProxyRoleContainer::append_proxyRole(QQmlListProperty* list, ProxyRole* proxyRole)
43 | {
44 | if (!proxyRole)
45 | return;
46 |
47 | ProxyRoleContainer* that = reinterpret_cast(list->object);
48 | that->appendProxyRole(proxyRole);
49 | }
50 |
51 | int ProxyRoleContainer::count_proxyRole(QQmlListProperty* list)
52 | {
53 | QList* ProxyRoles = static_cast*>(list->data);
54 | return ProxyRoles->count();
55 | }
56 |
57 | ProxyRole* ProxyRoleContainer::at_proxyRole(QQmlListProperty* list, int index)
58 | {
59 | QList* ProxyRoles = static_cast*>(list->data);
60 | return ProxyRoles->at(index);
61 | }
62 |
63 | void ProxyRoleContainer::clear_proxyRoles(QQmlListProperty *list)
64 | {
65 | ProxyRoleContainer* that = reinterpret_cast(list->object);
66 | that->clearProxyRoles();
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/proxyroles/proxyrolecontainer.h:
--------------------------------------------------------------------------------
1 | #ifndef PROXYROLECONTAINER_H
2 | #define PROXYROLECONTAINER_H
3 |
4 | #include
5 | #include
6 |
7 | namespace qqsfpm {
8 |
9 | class ProxyRole;
10 | class QQmlSortFilterProxyModel;
11 |
12 | class ProxyRoleContainer {
13 | public:
14 | virtual ~ProxyRoleContainer();
15 |
16 | QList proxyRoles() const;
17 | void appendProxyRole(ProxyRole* proxyRole);
18 | void removeProxyRole(ProxyRole* proxyRole);
19 | void clearProxyRoles();
20 |
21 | QQmlListProperty proxyRolesListProperty();
22 |
23 | protected:
24 | QList m_proxyRoles;
25 |
26 | private:
27 | virtual void onProxyRoleAppended(ProxyRole* proxyRole) = 0;
28 | virtual void onProxyRoleRemoved(ProxyRole* proxyRole) = 0;
29 | virtual void onProxyRolesCleared() = 0;
30 |
31 | static void append_proxyRole(QQmlListProperty* list, ProxyRole* proxyRole);
32 | static int count_proxyRole(QQmlListProperty* list);
33 | static ProxyRole* at_proxyRole(QQmlListProperty* list, int index);
34 | static void clear_proxyRoles(QQmlListProperty* list);
35 | };
36 |
37 | }
38 |
39 | #define ProxyRoleContainer_iid "fr.grecko.SortFilterProxyModel.ProxyRoleContainer"
40 | Q_DECLARE_INTERFACE(qqsfpm::ProxyRoleContainer, ProxyRoleContainer_iid)
41 |
42 | #endif // PROXYROLECONTAINER_H
43 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/proxyroles/proxyrolesqmltypes.cpp:
--------------------------------------------------------------------------------
1 | #include "proxyrole.h"
2 | #include "joinrole.h"
3 | #include "switchrole.h"
4 | #include "expressionrole.h"
5 | #include "regexprole.h"
6 | #include "filterrole.h"
7 | #include
8 | #include
9 |
10 | namespace qqsfpm {
11 |
12 | void registerProxyRoleTypes() {
13 | qmlRegisterUncreatableType("SortFilterProxyModel", 0, 2, "ProxyRole", "ProxyRole is an abstract class");
14 | qmlRegisterType("SortFilterProxyModel", 0, 2, "JoinRole");
15 | qmlRegisterType("SortFilterProxyModel", 0, 2, "SwitchRole");
16 | qmlRegisterType("SortFilterProxyModel", 0, 2, "ExpressionRole");
17 | qmlRegisterType("SortFilterProxyModel", 0, 2, "RegExpRole");
18 | qmlRegisterType("SortFilterProxyModel", 0, 2, "FilterRole");
19 | }
20 |
21 | Q_COREAPP_STARTUP_FUNCTION(registerProxyRoleTypes)
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/proxyroles/proxyrolesqmltypes.h:
--------------------------------------------------------------------------------
1 | #ifndef PROXYROLESQMLTYPES_H
2 | #define PROXYROLESQMLTYPES_H
3 |
4 | namespace qqsfpm {
5 |
6 | void registerProxyRoleTypes();
7 |
8 | }
9 |
10 | #endif // PROXYROLESQMLTYPES_H
11 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/proxyroles/regexprole.h:
--------------------------------------------------------------------------------
1 | #ifndef REGEXPROLE_H
2 | #define REGEXPROLE_H
3 |
4 | #include "proxyrole.h"
5 | #include
6 |
7 | namespace qqsfpm {
8 |
9 | class RegExpRole : public ProxyRole
10 | {
11 | Q_OBJECT
12 | Q_PROPERTY(QString roleName READ roleName WRITE setRoleName NOTIFY roleNameChanged)
13 | Q_PROPERTY(QString pattern READ pattern WRITE setPattern NOTIFY patternChanged)
14 | Q_PROPERTY(Qt::CaseSensitivity caseSensitivity READ caseSensitivity WRITE setCaseSensitivity NOTIFY caseSensitivityChanged)
15 |
16 | public:
17 | using ProxyRole::ProxyRole;
18 |
19 | QString roleName() const;
20 | void setRoleName(const QString& roleName);
21 |
22 | QString pattern() const;
23 | void setPattern(const QString& pattern);
24 |
25 | Qt::CaseSensitivity caseSensitivity() const;
26 | void setCaseSensitivity(Qt::CaseSensitivity caseSensitivity);
27 |
28 | QStringList names() override;
29 |
30 | Q_SIGNALS:
31 | void roleNameChanged();
32 | void patternChanged();
33 | void caseSensitivityChanged();
34 |
35 | private:
36 | QString m_roleName;
37 | QRegularExpression m_regularExpression;
38 | QVariant data(const QModelIndex &sourceIndex, const QQmlSortFilterProxyModel &proxyModel, const QString &name) override;
39 | };
40 |
41 | }
42 |
43 | #endif // REGEXPROLE_H
44 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/proxyroles/singlerole.cpp:
--------------------------------------------------------------------------------
1 | #include "singlerole.h"
2 | #include
3 |
4 | namespace qqsfpm {
5 |
6 | /*!
7 | \qmltype SingleRole
8 | \inherits ProxyRole
9 | \inqmlmodule SortFilterProxyModel
10 | \brief Base type for the \l SortFilterProxyModel proxy roles defining a single role
11 |
12 | SingleRole is a convenience base class for proxy roles who define a single role.
13 | It cannot be used directly in a QML file.
14 | It exists to provide a set of common properties and methods,
15 | available across all the other proxy role types that inherit from it.
16 | Attempting to use the SingleRole type directly will result in an error.
17 | */
18 | /*!
19 | \qmlproperty string SingleRole::name
20 |
21 | This property holds the role name of the proxy role.
22 | */
23 | QString SingleRole::name() const
24 | {
25 | return m_name;
26 | }
27 |
28 | void SingleRole::setName(const QString& name)
29 | {
30 | if (m_name == name)
31 | return;
32 |
33 | Q_EMIT namesAboutToBeChanged();
34 | m_name = name;
35 | Q_EMIT nameChanged();
36 | Q_EMIT namesChanged();
37 | }
38 |
39 | QStringList SingleRole::names()
40 | {
41 | return QStringList { m_name };
42 | }
43 |
44 | QVariant SingleRole::data(const QModelIndex &sourceIndex, const QQmlSortFilterProxyModel &proxyModel, const QString &name)
45 | {
46 | Q_UNUSED(name);
47 | return data(sourceIndex, proxyModel);
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/proxyroles/singlerole.h:
--------------------------------------------------------------------------------
1 | #ifndef SINGLEROLE_H
2 | #define SINGLEROLE_H
3 |
4 | #include "proxyrole.h"
5 |
6 | namespace qqsfpm {
7 |
8 | class SingleRole : public ProxyRole
9 | {
10 | Q_OBJECT
11 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
12 |
13 | public:
14 | using ProxyRole::ProxyRole;
15 |
16 | QString name() const;
17 | void setName(const QString& name);
18 |
19 | QStringList names() override;
20 |
21 | Q_SIGNALS:
22 | void nameChanged();
23 |
24 | private:
25 | QString m_name;
26 |
27 | private:
28 | QVariant data(const QModelIndex &sourceIndex, const QQmlSortFilterProxyModel &proxyModel, const QString &name) final;
29 | virtual QVariant data(const QModelIndex &sourceIndex, const QQmlSortFilterProxyModel &proxyModel) = 0;
30 | };
31 |
32 | }
33 |
34 | #endif // SINGLEROLE_H
35 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/proxyroles/switchrole.h:
--------------------------------------------------------------------------------
1 | #ifndef SWITCHROLE_H
2 | #define SWITCHROLE_H
3 |
4 | #include "singlerole.h"
5 | #include "filters/filtercontainer.h"
6 | #include
7 |
8 | namespace qqsfpm {
9 |
10 | class SwitchRoleAttached : public QObject
11 | {
12 | Q_OBJECT
13 | Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
14 | public:
15 | SwitchRoleAttached(QObject* parent);
16 |
17 | QVariant value() const;
18 | void setValue(QVariant value);
19 |
20 | Q_SIGNALS:
21 | void valueChanged();
22 |
23 | private:
24 | QVariant m_value;
25 | };
26 |
27 | class SwitchRole : public SingleRole, public FilterContainer
28 | {
29 | Q_OBJECT
30 | Q_INTERFACES(qqsfpm::FilterContainer)
31 | Q_PROPERTY(QString defaultRoleName READ defaultRoleName WRITE setDefaultRoleName NOTIFY defaultRoleNameChanged)
32 | Q_PROPERTY(QVariant defaultValue READ defaultValue WRITE setDefaultValue NOTIFY defaultValueChanged)
33 | Q_PROPERTY(QQmlListProperty filters READ filtersListProperty)
34 | Q_CLASSINFO("DefaultProperty", "filters")
35 |
36 | public:
37 | using SingleRole::SingleRole;
38 |
39 | QString defaultRoleName() const;
40 | void setDefaultRoleName(const QString& defaultRoleName);
41 |
42 | QVariant defaultValue() const;
43 | void setDefaultValue(const QVariant& defaultValue);
44 |
45 | void proxyModelCompleted(const QQmlSortFilterProxyModel& proxyModel) override;
46 |
47 | static SwitchRoleAttached* qmlAttachedProperties(QObject* object);
48 |
49 | Q_SIGNALS:
50 | void defaultRoleNameChanged();
51 | void defaultValueChanged();
52 |
53 | private:
54 | QVariant data(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) override;
55 |
56 | void onFilterAppended(Filter *filter) override;
57 | void onFilterRemoved(Filter *filter) override;
58 | void onFiltersCleared() override;
59 |
60 | QString m_defaultRoleName;
61 | QVariant m_defaultValue;
62 | };
63 |
64 | }
65 |
66 | QML_DECLARE_TYPEINFO(qqsfpm::SwitchRole, QML_HAS_ATTACHED_PROPERTIES)
67 |
68 | #endif // SWITCHROLE_H
69 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/qpm.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fr.grecko.sortfilterproxymodel",
3 | "description": "A nicely exposed QSortFilterProxyModel for QML",
4 | "author": {
5 | "name": "Pierre-Yves Siret",
6 | "email": "gr3cko@gmail.com"
7 | },
8 | "repository": {
9 | "type": "GITHUB",
10 | "url": "https://github.com/oKcerG/SortFilterProxyModel.git"
11 | },
12 | "version": {
13 | "label": "0.1.0",
14 | "revision": "",
15 | "fingerprint": ""
16 | },
17 | "dependencies": [
18 | ],
19 | "license": "MIT",
20 | "pri_filename": "SortFilterProxyModel.pri",
21 | "webpage": ""
22 | }
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/sorters/expressionsorter.h:
--------------------------------------------------------------------------------
1 | #ifndef EXPRESSIONSORTER_H
2 | #define EXPRESSIONSORTER_H
3 |
4 | #include "sorter.h"
5 | #include
6 |
7 | class QQmlExpression;
8 |
9 | namespace qqsfpm {
10 |
11 | class QQmlSortFilterProxyModel;
12 |
13 | class ExpressionSorter : public Sorter
14 | {
15 | Q_OBJECT
16 | Q_PROPERTY(QQmlScriptString expression READ expression WRITE setExpression NOTIFY expressionChanged)
17 |
18 | public:
19 | using Sorter::Sorter;
20 |
21 | const QQmlScriptString& expression() const;
22 | void setExpression(const QQmlScriptString& scriptString);
23 |
24 | void proxyModelCompleted(const QQmlSortFilterProxyModel& proxyModel) override;
25 |
26 | Q_SIGNALS:
27 | void expressionChanged();
28 |
29 | protected:
30 | int compare(const QModelIndex& sourceLeft, const QModelIndex& sourceRight, const QQmlSortFilterProxyModel& proxyModel) const override;
31 |
32 | private:
33 | void updateContext(const QQmlSortFilterProxyModel& proxyModel);
34 | void updateExpression();
35 |
36 | QQmlScriptString m_scriptString;
37 | QQmlExpression* m_expression = nullptr;
38 | QQmlContext* m_context = nullptr;
39 | };
40 |
41 | }
42 |
43 | #endif // EXPRESSIONSORTER_H
44 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/sorters/filtersorter.cpp:
--------------------------------------------------------------------------------
1 | #include "filtersorter.h"
2 | #include "filters/filter.h"
3 |
4 | namespace qqsfpm {
5 |
6 | /*!
7 | \qmltype FilterSorter
8 | \inherits Sorter
9 | \inqmlmodule SortFilterProxyModel
10 | \brief Sorts rows based on if they match filters
11 |
12 | A FilterSorter is a \l Sorter that orders row matching its filters before the rows not matching the filters.
13 |
14 | In the following example, rows with their \c favorite role set to \c true will be ordered at the beginning :
15 | \code
16 | SortFilterProxyModel {
17 | sourceModel: contactModel
18 | sorters: FilterSorter {
19 | ValueFilter { roleName: "favorite"; value: true }
20 | }
21 | }
22 | \endcode
23 | */
24 |
25 | /*!
26 | \qmlproperty string FilterSorter::filters
27 |
28 | This property holds the list of filters for this filter sorter.
29 | If a row match all this FilterSorter's filters, it will be ordered before rows not matching all the filters.
30 |
31 | \sa Filter
32 | */
33 |
34 | int FilterSorter::compare(const QModelIndex& sourceLeft, const QModelIndex& sourceRight, const QQmlSortFilterProxyModel &proxyModel) const
35 | {
36 | bool leftIsAccepted = indexIsAccepted(sourceLeft, proxyModel);
37 | bool rightIsAccepted = indexIsAccepted(sourceRight, proxyModel);
38 |
39 | if (leftIsAccepted == rightIsAccepted)
40 | return 0;
41 |
42 | return leftIsAccepted ? -1 : 1;
43 | }
44 |
45 | void FilterSorter::proxyModelCompleted(const QQmlSortFilterProxyModel& proxyModel)
46 | {
47 | for (Filter* filter : m_filters)
48 | filter->proxyModelCompleted(proxyModel);
49 | }
50 |
51 | void FilterSorter::onFilterAppended(Filter* filter)
52 | {
53 | connect(filter, &Filter::invalidated, this, &FilterSorter::invalidate);
54 | invalidate();
55 | }
56 |
57 | void FilterSorter::onFilterRemoved(Filter* filter)
58 | {
59 | disconnect(filter, &Filter::invalidated, this, &FilterSorter::invalidate);
60 | invalidate();
61 | }
62 |
63 | void FilterSorter::onFiltersCleared()
64 | {
65 | invalidate();
66 | }
67 |
68 | bool FilterSorter::indexIsAccepted(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const
69 | {
70 | return std::all_of(m_filters.begin(), m_filters.end(),
71 | [&] (Filter* filter) {
72 | return filter->filterAcceptsRow(sourceIndex, proxyModel);
73 | }
74 | );
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/sorters/filtersorter.h:
--------------------------------------------------------------------------------
1 | #ifndef FILTERSORTER_H
2 | #define FILTERSORTER_H
3 |
4 | #include "sorter.h"
5 | #include "filters/filtercontainer.h"
6 |
7 | namespace qqsfpm {
8 |
9 | class FilterSorter : public Sorter, public FilterContainer
10 | {
11 | Q_OBJECT
12 | Q_INTERFACES(qqsfpm::FilterContainer)
13 | Q_PROPERTY(QQmlListProperty filters READ filtersListProperty)
14 | Q_CLASSINFO("DefaultProperty", "filters")
15 |
16 | public:
17 | using Sorter::Sorter;
18 |
19 | protected:
20 | int compare(const QModelIndex &sourceLeft, const QModelIndex &sourceRight, const QQmlSortFilterProxyModel &proxyModel) const override;
21 |
22 | private:
23 | void proxyModelCompleted(const QQmlSortFilterProxyModel& proxyModel) override;
24 | void onFilterAppended(Filter *filter) override;
25 | void onFilterRemoved(Filter *filter) override;
26 | void onFiltersCleared() override;
27 |
28 | bool indexIsAccepted(const QModelIndex &sourceIndex, const QQmlSortFilterProxyModel &proxyModel) const;
29 | };
30 |
31 | }
32 |
33 | #endif // FILTERSORTER_H
34 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/sorters/rolesorter.cpp:
--------------------------------------------------------------------------------
1 | #include "rolesorter.h"
2 | #include "qqmlsortfilterproxymodel.h"
3 |
4 | namespace qqsfpm {
5 |
6 | /*!
7 | \qmltype RoleSorter
8 | \inherits Sorter
9 | \inqmlmodule SortFilterProxyModel
10 | \brief Sorts rows based on a source model role
11 |
12 | A RoleSorter is a simple \l Sorter that sorts rows based on a source model role.
13 |
14 | In the following example, rows with be sorted by their \c lastName role :
15 | \code
16 | SortFilterProxyModel {
17 | sourceModel: contactModel
18 | sorters: RoleSorter { roleName: "lastName" }
19 | }
20 | \endcode
21 | */
22 |
23 | /*!
24 | \qmlproperty string RoleSorter::roleName
25 |
26 | This property holds the role name that the sorter is using to query the source model's data when sorting items.
27 | */
28 | const QString& RoleSorter::roleName() const
29 | {
30 | return m_roleName;
31 | }
32 |
33 | void RoleSorter::setRoleName(const QString& roleName)
34 | {
35 | if (m_roleName == roleName)
36 | return;
37 |
38 | m_roleName = roleName;
39 | Q_EMIT roleNameChanged();
40 | invalidate();
41 | }
42 |
43 | QPair RoleSorter::sourceData(const QModelIndex &sourceLeft, const QModelIndex& sourceRight, const QQmlSortFilterProxyModel& proxyModel) const
44 | {
45 | QPair pair;
46 | int role = proxyModel.roleForName(m_roleName);
47 |
48 | if (role == -1)
49 | return pair;
50 |
51 | pair.first = proxyModel.sourceData(sourceLeft, role);
52 | pair.second = proxyModel.sourceData(sourceRight, role);
53 | return pair;
54 | }
55 |
56 | int RoleSorter::compare(const QModelIndex &sourceLeft, const QModelIndex& sourceRight, const QQmlSortFilterProxyModel& proxyModel) const
57 | {
58 | QPair pair = sourceData(sourceLeft, sourceRight, proxyModel);
59 | QVariant leftValue = pair.first;
60 | QVariant rightValue = pair.second;
61 | if (leftValue < rightValue)
62 | return -1;
63 | if (leftValue > rightValue)
64 | return 1;
65 | return 0;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/sorters/rolesorter.h:
--------------------------------------------------------------------------------
1 | #ifndef ROLESORTER_H
2 | #define ROLESORTER_H
3 |
4 | #include "sorter.h"
5 |
6 | namespace qqsfpm {
7 |
8 | class RoleSorter : public Sorter
9 | {
10 | Q_OBJECT
11 | Q_PROPERTY(QString roleName READ roleName WRITE setRoleName NOTIFY roleNameChanged)
12 |
13 | public:
14 | using Sorter::Sorter;
15 |
16 | const QString& roleName() const;
17 | void setRoleName(const QString& roleName);
18 |
19 | Q_SIGNALS:
20 | void roleNameChanged();
21 |
22 | protected:
23 | QPair sourceData(const QModelIndex &sourceLeft, const QModelIndex& sourceRight, const QQmlSortFilterProxyModel& proxyModel) const;
24 | int compare(const QModelIndex& sourceLeft, const QModelIndex& sourceRight, const QQmlSortFilterProxyModel& proxyModel) const override;
25 |
26 | private:
27 | QString m_roleName;
28 | };
29 |
30 | }
31 |
32 | #endif // ROLESORTER_H
33 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/sorters/sorter.h:
--------------------------------------------------------------------------------
1 | #ifndef SORTER_H
2 | #define SORTER_H
3 |
4 | #include
5 |
6 | namespace qqsfpm {
7 |
8 | class QQmlSortFilterProxyModel;
9 |
10 | class Sorter : public QObject
11 | {
12 | Q_OBJECT
13 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
14 | Q_PROPERTY(bool ascendingOrder READ ascendingOrder WRITE setAscendingOrder NOTIFY sortOrderChanged)
15 | Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder NOTIFY sortOrderChanged)
16 |
17 | public:
18 | Sorter(QObject* parent = nullptr);
19 | virtual ~Sorter() = 0;
20 |
21 | bool enabled() const;
22 | void setEnabled(bool enabled);
23 |
24 | bool ascendingOrder() const;
25 | void setAscendingOrder(bool ascendingOrder);
26 |
27 | Qt::SortOrder sortOrder() const;
28 | void setSortOrder(Qt::SortOrder sortOrder);
29 |
30 | int compareRows(const QModelIndex& source_left, const QModelIndex& source_right, const QQmlSortFilterProxyModel& proxyModel) const;
31 |
32 | virtual void proxyModelCompleted(const QQmlSortFilterProxyModel& proxyModel);
33 |
34 | Q_SIGNALS:
35 | void enabledChanged();
36 | void sortOrderChanged();
37 |
38 | void invalidated();
39 |
40 | protected:
41 | virtual int compare(const QModelIndex& sourceLeft, const QModelIndex& sourceRight, const QQmlSortFilterProxyModel& proxyModel) const;
42 | virtual bool lessThan(const QModelIndex& sourceLeft, const QModelIndex& sourceRight, const QQmlSortFilterProxyModel& proxyModel) const;
43 | void invalidate();
44 |
45 | private:
46 | bool m_enabled = true;
47 | Qt::SortOrder m_sortOrder = Qt::AscendingOrder;
48 | };
49 |
50 | }
51 |
52 | #endif // SORTER_H
53 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/sorters/sortercontainer.cpp:
--------------------------------------------------------------------------------
1 | #include "sortercontainer.h"
2 |
3 | namespace qqsfpm {
4 |
5 | SorterContainer::~SorterContainer()
6 | {
7 |
8 | }
9 |
10 | QList SorterContainer::sorters() const
11 | {
12 | return m_sorters;
13 | }
14 |
15 | void SorterContainer::appendSorter(Sorter* sorter)
16 | {
17 | m_sorters.append(sorter);
18 | onSorterAppended(sorter);
19 | }
20 |
21 | void SorterContainer::removeSorter(Sorter *sorter)
22 | {
23 | m_sorters.removeOne(sorter);
24 | onSorterRemoved(sorter);
25 | }
26 |
27 | void SorterContainer::clearSorters()
28 | {
29 | m_sorters.clear();
30 | onSortersCleared();
31 | }
32 |
33 | QQmlListProperty SorterContainer::sortersListProperty()
34 | {
35 | return QQmlListProperty(reinterpret_cast(this), &m_sorters,
36 | &SorterContainer::append_sorter,
37 | &SorterContainer::count_sorter,
38 | &SorterContainer::at_sorter,
39 | &SorterContainer::clear_sorters);
40 | }
41 |
42 | void SorterContainer::append_sorter(QQmlListProperty* list, Sorter* sorter)
43 | {
44 | if (!sorter)
45 | return;
46 |
47 | SorterContainer* that = reinterpret_cast(list->object);
48 | that->appendSorter(sorter);
49 | }
50 |
51 | int SorterContainer::count_sorter(QQmlListProperty* list)
52 | {
53 | QList* sorters = static_cast*>(list->data);
54 | return sorters->count();
55 | }
56 |
57 | Sorter* SorterContainer::at_sorter(QQmlListProperty* list, int index)
58 | {
59 | QList* sorters = static_cast*>(list->data);
60 | return sorters->at(index);
61 | }
62 |
63 | void SorterContainer::clear_sorters(QQmlListProperty *list)
64 | {
65 | SorterContainer* that = reinterpret_cast(list->object);
66 | that->clearSorters();
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/sorters/sortercontainer.h:
--------------------------------------------------------------------------------
1 | #ifndef SORTERSSORTERCONTAINER_H
2 | #define SORTERSSORTERCONTAINER_H
3 |
4 | #include
5 | #include
6 |
7 | namespace qqsfpm {
8 |
9 | class Sorter;
10 | class QQmlSortFilterProxyModel;
11 |
12 | class SorterContainer {
13 | public:
14 | virtual ~SorterContainer();
15 |
16 | QList sorters() const;
17 | void appendSorter(Sorter* sorter);
18 | void removeSorter(Sorter* sorter);
19 | void clearSorters();
20 |
21 | QQmlListProperty sortersListProperty();
22 |
23 | protected:
24 | QList m_sorters;
25 |
26 | private:
27 | virtual void onSorterAppended(Sorter* sorter) = 0;
28 | virtual void onSorterRemoved(Sorter* sorter) = 0;
29 | virtual void onSortersCleared() = 0;
30 |
31 | static void append_sorter(QQmlListProperty* list, Sorter* sorter);
32 | static int count_sorter(QQmlListProperty* list);
33 | static Sorter* at_sorter(QQmlListProperty* list, int index);
34 | static void clear_sorters(QQmlListProperty* list);
35 | };
36 |
37 | }
38 |
39 | #define SorterContainer_iid "fr.grecko.SortFilterProxyModel.SorterContainer"
40 | Q_DECLARE_INTERFACE(qqsfpm::SorterContainer, SorterContainer_iid)
41 |
42 | #endif // SORTERSSORTERCONTAINER_H
43 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/sorters/sortersqmltypes.cpp:
--------------------------------------------------------------------------------
1 | #include "sorter.h"
2 | #include "rolesorter.h"
3 | #include "stringsorter.h"
4 | #include "filtersorter.h"
5 | #include "expressionsorter.h"
6 | #include
7 | #include
8 |
9 | namespace qqsfpm {
10 |
11 | void registerSorterTypes() {
12 | qmlRegisterUncreatableType("SortFilterProxyModel", 0, 2, "Sorter", "Sorter is an abstract class");
13 | qmlRegisterType("SortFilterProxyModel", 0, 2, "RoleSorter");
14 | qmlRegisterType("SortFilterProxyModel", 0, 2, "StringSorter");
15 | qmlRegisterType("SortFilterProxyModel", 0, 2, "FilterSorter");
16 | qmlRegisterType("SortFilterProxyModel", 0, 2, "ExpressionSorter");
17 | }
18 |
19 | Q_COREAPP_STARTUP_FUNCTION(registerSorterTypes)
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/sorters/sortersqmltypes.h:
--------------------------------------------------------------------------------
1 | #ifndef SORTERSQMLTYPES_H
2 | #define SORTERSQMLTYPES_H
3 |
4 | namespace qqsfpm {
5 |
6 | void registerSorterTypes();
7 |
8 | }
9 |
10 | #endif // SORTERSQMLTYPES_H
11 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/sorters/stringsorter.h:
--------------------------------------------------------------------------------
1 | #ifndef STRINGSORTER_H
2 | #define STRINGSORTER_H
3 |
4 | #include "rolesorter.h"
5 | #include
6 |
7 | namespace qqsfpm {
8 |
9 | class StringSorter : public RoleSorter
10 | {
11 | Q_OBJECT
12 | Q_PROPERTY(Qt::CaseSensitivity caseSensitivity READ caseSensitivity WRITE setCaseSensitivity NOTIFY caseSensitivityChanged)
13 | Q_PROPERTY(bool ignorePunctation READ ignorePunctation WRITE setIgnorePunctation NOTIFY ignorePunctationChanged)
14 | Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged)
15 | Q_PROPERTY(bool numericMode READ numericMode WRITE setNumericMode NOTIFY numericModeChanged)
16 |
17 | public:
18 | using RoleSorter::RoleSorter;
19 |
20 | Qt::CaseSensitivity caseSensitivity() const;
21 | void setCaseSensitivity(Qt::CaseSensitivity caseSensitivity);
22 |
23 | bool ignorePunctation() const;
24 | void setIgnorePunctation(bool ignorePunctation);
25 |
26 | QLocale locale() const;
27 | void setLocale(const QLocale& locale);
28 |
29 | bool numericMode() const;
30 | void setNumericMode(bool numericMode);
31 |
32 | Q_SIGNALS:
33 | void caseSensitivityChanged();
34 | void ignorePunctationChanged();
35 | void localeChanged();
36 | void numericModeChanged();
37 |
38 | protected:
39 | int compare(const QModelIndex& sourceLeft, const QModelIndex& sourceRight, const QQmlSortFilterProxyModel& proxyModel) const override;
40 |
41 | private:
42 | QCollator m_collator;
43 | };
44 |
45 | }
46 |
47 | #endif // STRINGSORTER_H
48 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/sortfilterproxymodel.qdocconf:
--------------------------------------------------------------------------------
1 | project = SortFilterProxyModel
2 | description = lol
3 |
4 | sourcedirs = .
5 |
6 | sources.fileextensions = "*.cpp *.qdoc *.qml"
7 | headers.fileextensions = "*.h"
8 |
9 | outputdir = docs/
10 |
11 | HTML.templatedir = .
12 | HTML.stylesheets = "D:\\coding\\Qt\\Docs\\Qt-5.8\\global\\template\\style\\offline.css"
13 |
14 | HTML.headerstyles = \
15 | " \n"
16 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/tests/SortFilterProxyModel.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = app
2 | TARGET = tst_sortfilterproxymodel
3 | QT += qml quick
4 | CONFIG += c++11 warn_on qmltestcase qml_debug no_keywords
5 |
6 | include(../SortFilterProxyModel.pri)
7 |
8 | HEADERS += \
9 | indexsorter.h \
10 | testroles.h
11 |
12 | SOURCES += \
13 | tst_sortfilterproxymodel.cpp \
14 | indexsorter.cpp \
15 | testroles.cpp
16 |
17 | OTHER_FILES += \
18 | tst_rangefilter.qml \
19 | tst_indexfilter.qml \
20 | tst_sourceroles.qml \
21 | tst_sorters.qml \
22 | tst_helpers.qml \
23 | tst_builtins.qml \
24 | tst_rolesorter.qml \
25 | tst_stringsorter.qml \
26 | tst_proxyroles.qml \
27 | tst_joinrole.qml \
28 | tst_switchrole.qml \
29 | tst_expressionrole.qml
30 |
31 | DISTFILES += \
32 | tst_filtercontainers.qml \
33 | tst_regexprole.qml \
34 | tst_filtersorter.qml \
35 | tst_filterrole.qml
36 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/tests/indexsorter.cpp:
--------------------------------------------------------------------------------
1 | #include "indexsorter.h"
2 | #include
3 |
4 | int IndexSorter::compare(const QModelIndex &sourceLeft, const QModelIndex &sourceRight, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) const
5 | {
6 | Q_UNUSED(proxyModel)
7 | return sourceLeft.row() - sourceRight.row();
8 | }
9 |
10 | int ReverseIndexSorter::compare(const QModelIndex &sourceLeft, const QModelIndex &sourceRight, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) const
11 | {
12 | Q_UNUSED(proxyModel)
13 | return sourceRight.row() - sourceLeft.row();
14 | }
15 |
16 | void registerIndexSorterTypes() {
17 | qmlRegisterType("SortFilterProxyModel.Test", 0, 2, "IndexSorter");
18 | qmlRegisterType("SortFilterProxyModel.Test", 0, 2, "ReverseIndexSorter");
19 | }
20 |
21 | Q_COREAPP_STARTUP_FUNCTION(registerIndexSorterTypes)
22 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/tests/indexsorter.h:
--------------------------------------------------------------------------------
1 | #ifndef INDEXSORTER_H
2 | #define INDEXSORTER_H
3 |
4 | #include "sorters/sorter.h"
5 |
6 | class IndexSorter : public qqsfpm::Sorter
7 | {
8 | public:
9 | using qqsfpm::Sorter::Sorter;
10 | int compare(const QModelIndex& sourceLeft, const QModelIndex& sourceRight, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) const override;
11 | };
12 |
13 | class ReverseIndexSorter : public qqsfpm::Sorter
14 | {
15 | public:
16 | using qqsfpm::Sorter::Sorter;
17 | int compare(const QModelIndex& sourceLeft, const QModelIndex& sourceRight, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) const override;
18 | };
19 |
20 | #endif // INDEXSORTER_H
21 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/tests/testroles.cpp:
--------------------------------------------------------------------------------
1 | #include "testroles.h"
2 | #include
3 |
4 | QVariant StaticRole::value() const
5 | {
6 | return m_value;
7 | }
8 |
9 | void StaticRole::setValue(const QVariant& value)
10 | {
11 | if (m_value == value)
12 | return;
13 |
14 | m_value = value;
15 | Q_EMIT valueChanged();
16 | invalidate();
17 | }
18 |
19 | QVariant StaticRole::data(const QModelIndex& sourceIndex, const qqsfpm::QQmlSortFilterProxyModel& proxyModel)
20 | {
21 | Q_UNUSED(sourceIndex)
22 | Q_UNUSED(proxyModel)
23 | return m_value;
24 | }
25 |
26 | QVariant SourceIndexRole::data(const QModelIndex& sourceIndex, const qqsfpm::QQmlSortFilterProxyModel& proxyModel)
27 | {
28 | Q_UNUSED(proxyModel)
29 | return sourceIndex.row();
30 | }
31 |
32 | QStringList MultiRole::names()
33 | {
34 | return {"role1", "role2"};
35 | }
36 |
37 | QVariant MultiRole::data(const QModelIndex&, const qqsfpm::QQmlSortFilterProxyModel&, const QString& name)
38 | {
39 | return "data for " + name;
40 | }
41 |
42 | void registerTestRolesTypes() {
43 | qmlRegisterType("SortFilterProxyModel.Test", 0, 2, "StaticRole");
44 | qmlRegisterType("SortFilterProxyModel.Test", 0, 2, "SourceIndexRole");
45 | qmlRegisterType("SortFilterProxyModel.Test", 0, 2, "MultiRole");
46 | }
47 |
48 | Q_COREAPP_STARTUP_FUNCTION(registerTestRolesTypes)
49 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/tests/testroles.h:
--------------------------------------------------------------------------------
1 | #ifndef TESTROLES_H
2 | #define TESTROLES_H
3 |
4 | #include "proxyroles/singlerole.h"
5 | #include
6 |
7 | class StaticRole : public qqsfpm::SingleRole
8 | {
9 | Q_OBJECT
10 | Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
11 | public:
12 | using qqsfpm::SingleRole::SingleRole;
13 |
14 | QVariant value() const;
15 | void setValue(const QVariant& value);
16 |
17 | Q_SIGNALS:
18 | void valueChanged();
19 |
20 | protected:
21 |
22 | private:
23 | QVariant data(const QModelIndex& sourceIndex, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) override;
24 | QVariant m_value;
25 | };
26 |
27 | class SourceIndexRole : public qqsfpm::SingleRole
28 | {
29 | public:
30 | using qqsfpm::SingleRole::SingleRole;
31 |
32 | private:
33 | QVariant data(const QModelIndex& sourceIndex, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) override;
34 | };
35 |
36 | class MultiRole : public qqsfpm::ProxyRole
37 | {
38 | public:
39 | using qqsfpm::ProxyRole::ProxyRole;
40 |
41 | QStringList names() override;
42 |
43 | private:
44 | QVariant data(const QModelIndex &sourceIndex, const qqsfpm::QQmlSortFilterProxyModel &proxyModel, const QString &name) override;
45 | };
46 |
47 | #endif // TESTROLES_H
48 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/tests/tst_builtins.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.0
2 | import QtQml 2.2
3 | import QtTest 1.1
4 | import SortFilterProxyModel 0.2
5 |
6 | Item {
7 | ListModel {
8 | id: testModel
9 | ListElement{role1: 1; role2: 1}
10 | ListElement{role1: 2; role2: 1}
11 | ListElement{role1: 3; role2: 2}
12 | ListElement{role1: 4; role2: 2}
13 | }
14 | ListModel {
15 | id: noRolesFirstTestModel
16 | function initModel() {
17 | noRolesFirstTestModel.append({role1: 1, role2: 1 })
18 | noRolesFirstTestModel.append({role1: 2, role2: 1 })
19 | noRolesFirstTestModel.append({role1: 3, role2: 2 })
20 | noRolesFirstTestModel.append({role1: 4, role2: 2 })
21 | }
22 | }
23 | SortFilterProxyModel {
24 | id: testProxyModel
25 | property string tag: "testProxyModel"
26 | sourceModel: testModel
27 | filterRoleName: "role2"
28 | filterValue: 2
29 | property var expectedData: ([{role1: 3, role2: 2}, {role1: 4, role2: 2}])
30 | }
31 | SortFilterProxyModel {
32 | id: noRolesFirstTestProxyModel
33 | property string tag: "noRolesFirstTestProxyModel"
34 | sourceModel: noRolesFirstTestModel
35 | filterRoleName: "role2"
36 | filterValue: 2
37 | property var expectedData: ([{role1: 3, role2: 2}, {role1: 4, role2: 2}])
38 | }
39 | TestCase {
40 | name: "BuiltinsFilterTests"
41 | function test_filterValue_data() {
42 | return [testProxyModel, noRolesFirstTestProxyModel];
43 | }
44 |
45 | function test_filterValue(proxyModel) {
46 | if (proxyModel.sourceModel.initModel)
47 | proxyModel.sourceModel.initModel()
48 | var data = [];
49 | for (var i = 0; i < proxyModel.count; i++)
50 | data.push(proxyModel.get(i));
51 | compare(data, proxyModel.expectedData);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/tests/tst_expressionrole.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.0
2 | import QtQml 2.2
3 | import QtTest 1.1
4 | import SortFilterProxyModel 0.2
5 | import QtQml 2.2
6 |
7 | Item {
8 | property int c: 0
9 | ListModel {
10 | id: listModel
11 | ListElement { a: 1; b: 2 }
12 | }
13 |
14 | SortFilterProxyModel {
15 | id: testModel
16 | sourceModel: listModel
17 |
18 | proxyRoles: ExpressionRole {
19 | name: "expressionRole"
20 | expression: a + model.b + c
21 | }
22 | }
23 |
24 | Instantiator {
25 | id: instantiator
26 | model: testModel
27 | QtObject {
28 | property string expressionRole: model.expressionRole
29 | }
30 | }
31 |
32 | TestCase {
33 | name: "ExpressionRole"
34 |
35 | function test_expressionRole() {
36 | fuzzyCompare(instantiator.object.expressionRole, 3, 1e-7);
37 | listModel.setProperty(0, "b", 9);
38 | fuzzyCompare(instantiator.object.expressionRole, 10, 1e-7);
39 | c = 1327;
40 | fuzzyCompare(instantiator.object.expressionRole, 1337, 1e-7);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/tests/tst_filterrole.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.0
2 | import QtQml 2.2
3 | import QtTest 1.1
4 | import SortFilterProxyModel 0.2
5 | import QtQml 2.2
6 |
7 | Item {
8 | ListModel {
9 | id: listModel
10 | ListElement { name: "1"; age: 18 }
11 | ListElement { name: "2"; age: 22 }
12 | ListElement { name: "3"; age: 45 }
13 | ListElement { name: "4"; age: 10 }
14 | }
15 |
16 | SortFilterProxyModel {
17 | id: testModel
18 | sourceModel: listModel
19 |
20 | proxyRoles: FilterRole {
21 | name: "isOldEnough"
22 | RangeFilter {
23 | id: ageFilter
24 | roleName: "age"
25 | minimumInclusive: true
26 | minimumValue: 18
27 | }
28 | }
29 | }
30 | TestCase {
31 | name: "FilterRole"
32 |
33 | function test_filterRole() {
34 | compare(testModel.get(0, "isOldEnough"), true);
35 | compare(testModel.get(1, "isOldEnough"), true);
36 | compare(testModel.get(2, "isOldEnough"), true);
37 | compare(testModel.get(3, "isOldEnough"), false);
38 |
39 | ageFilter.minimumValue = 21;
40 |
41 | compare(testModel.get(0, "isOldEnough"), false);
42 | compare(testModel.get(1, "isOldEnough"), true);
43 | compare(testModel.get(2, "isOldEnough"), true);
44 | compare(testModel.get(3, "isOldEnough"), false);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/tests/tst_filtersorter.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.0
2 | import QtQml 2.2
3 | import QtTest 1.1
4 | import SortFilterProxyModel 0.2
5 | import QtQml 2.2
6 |
7 | Item {
8 | ListModel {
9 | id: listModel
10 | ListElement { name: "1"; favorite: true }
11 | ListElement { name: "2"; favorite: false }
12 | ListElement { name: "3"; favorite: false }
13 | ListElement { name: "4"; favorite: true }
14 | }
15 |
16 | SortFilterProxyModel {
17 | id: testModel
18 | sourceModel: listModel
19 |
20 | sorters: FilterSorter {
21 | ValueFilter {
22 | id: favoriteFilter
23 | roleName: "favorite"
24 | value: true
25 | }
26 | }
27 | }
28 | TestCase {
29 | name: "FilterSorter"
30 |
31 | function test_filterSorter() {
32 | compare(testModel.get(0, "name"), "1");
33 | compare(testModel.get(1, "name"), "4");
34 | compare(testModel.get(2, "name"), "2");
35 | compare(testModel.get(3, "name"), "3");
36 |
37 | favoriteFilter.value = false;
38 |
39 | compare(testModel.get(0, "name"), "2");
40 | compare(testModel.get(1, "name"), "3");
41 | compare(testModel.get(2, "name"), "1");
42 | compare(testModel.get(3, "name"), "4");
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/tests/tst_joinrole.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.0
2 | import QtQml 2.2
3 | import QtTest 1.1
4 | import SortFilterProxyModel 0.2
5 | import QtQml 2.2
6 |
7 | Item {
8 | ListModel {
9 | id: listModel
10 | ListElement { firstName: "Justin"; lastName: "Timberlake" }
11 | }
12 |
13 | SortFilterProxyModel {
14 | id: testModel
15 | sourceModel: listModel
16 |
17 | proxyRoles: JoinRole {
18 | id: joinRole
19 | name: "fullName"
20 | roleNames: ["firstName", "lastName"]
21 | }
22 | }
23 |
24 | Instantiator {
25 | id: instantiator
26 | model: testModel
27 | QtObject {
28 | property string fullName: model.fullName
29 | }
30 | }
31 |
32 | TestCase {
33 | name: "JoinRole"
34 |
35 | function test_joinRole() {
36 | compare(instantiator.object.fullName, "Justin Timberlake");
37 | listModel.setProperty(0, "lastName", "Bieber");
38 | compare(instantiator.object.fullName, "Justin Bieber");
39 | joinRole.roleNames = ["lastName", "firstName"];
40 | compare(instantiator.object.fullName, "Bieber Justin");
41 | joinRole.separator = " - ";
42 | compare(instantiator.object.fullName, "Bieber - Justin");
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/tests/tst_proxyroles.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.0
2 | import QtQml 2.2
3 | import QtTest 1.1
4 | import SortFilterProxyModel 0.2
5 | import SortFilterProxyModel.Test 0.2
6 | import QtQml 2.2
7 |
8 | Item {
9 | ListModel {
10 | id: listModel
11 | ListElement { test: "first"; keep: true }
12 | ListElement { test: "second"; keep: true }
13 | ListElement { test: "third"; keep: true }
14 | }
15 |
16 | SortFilterProxyModel {
17 | id: testModel
18 | sourceModel: listModel
19 | filters: [
20 | ValueFilter {
21 | roleName: "keep"
22 | value: true
23 | },
24 | ValueFilter {
25 | inverted: true
26 | roleName: "staticRole"
27 | value: "filterMe"
28 | }
29 | ]
30 |
31 | proxyRoles: [
32 | StaticRole {
33 | id: staticRole
34 | name: "staticRole"
35 | value: "foo"
36 | },
37 | StaticRole {
38 | id: renameRole
39 | name: "renameMe"
40 | value: "test"
41 | },
42 | SourceIndexRole {
43 | name: "sourceIndexRole"
44 | },
45 | MultiRole {}
46 | ]
47 | }
48 |
49 | Instantiator {
50 | id: instantiator
51 | model: testModel
52 | QtObject {
53 | property string staticRole: model.staticRole
54 | property int sourceIndexRole: model.sourceIndexRole
55 | }
56 | }
57 |
58 | TestCase {
59 | name: "ProxyRoles"
60 |
61 | function test_resetAfterNameChange() {
62 | var oldObject = instantiator.object;
63 | renameRole.name = "foobarRole";
64 | var newObject = instantiator.object;
65 | verify(newObject !== oldObject, "Instantiator object should have been reinstantiated");
66 | }
67 |
68 | function test_proxyRoleInvalidation() {
69 | compare(instantiator.object.staticRole, "foo");
70 | staticRole.value = "bar";
71 | compare(instantiator.object.staticRole, "bar");
72 | }
73 |
74 | function test_proxyRoleGetDataFromSource() {
75 | compare(instantiator.object.sourceIndexRole, 0);
76 | compare(testModel.get(1, "sourceIndexRole"), 1);
77 | listModel.setProperty(1, "keep", false);
78 | compare(testModel.get(1, "sourceIndexRole"), 2);
79 | }
80 |
81 | function test_filterFromProxyRole() {
82 | staticRole.value = "filterMe";
83 | compare(testModel.count, 0);
84 | staticRole.value = "foo";
85 | }
86 |
87 | function test_multiRole() {
88 | compare(testModel.get(0, "role1"), "data for role1");
89 | compare(testModel.get(0, "role2"), "data for role2");
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/tests/tst_regexprole.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.0
2 | import QtQml 2.2
3 | import QtTest 1.1
4 | import SortFilterProxyModel 0.2
5 | import QtQml 2.2
6 |
7 | Item {
8 | ListModel {
9 | id: listModel
10 | ListElement { dummyRole: false; compoundRole: "0 - zero"; unusedRole: "" }
11 | ListElement { dummyRole: false; compoundRole: "1 - one"; unusedRole: "" }
12 | ListElement { dummyRole: false; compoundRole: "2 - two"; unusedRole: "" }
13 | ListElement { dummyRole: false; compoundRole: "3 - three"; unusedRole: "" }
14 | ListElement { dummyRole: false; compoundRole: "four"; unusedRole: "" }
15 | }
16 |
17 | SortFilterProxyModel {
18 | id: testModel
19 | sourceModel: listModel
20 |
21 | proxyRoles: [
22 | RegExpRole {
23 | id: regExpRole
24 | roleName: "compoundRole"
25 | pattern: "(?\\d+) - (?.+)"
26 | },
27 | RegExpRole {
28 | id: caseSensitiveRole
29 | roleName: "compoundRole"
30 | pattern: "\\d+ - (?[A-Z]+)"
31 | caseSensitivity: Qt.CaseSensitive
32 | },
33 | RegExpRole {
34 | id: caseInsensitiveRole
35 | roleName: "compoundRole"
36 | pattern: "\\d+ - (?[A-Z]+)"
37 | caseSensitivity: Qt.CaseInsensitive
38 | }
39 | ]
40 | }
41 |
42 | TestCase {
43 | name: "RegExpRole"
44 |
45 | function test_regExpRole() {
46 | compare(testModel.get(0, "id"), "0");
47 | compare(testModel.get(1, "id"), "1");
48 | compare(testModel.get(0, "name"), "zero");
49 | compare(testModel.get(4, "id"), undefined);
50 | compare(testModel.get(0, "nameCS"), undefined);
51 | compare(testModel.get(0, "nameCIS"), "zero");
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/tests/tst_rolesorter.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.0
2 | import SortFilterProxyModel 0.2
3 | import QtQml.Models 2.2
4 | import QtTest 1.1
5 |
6 | Item {
7 | property list sorters: [
8 | RoleSorter {
9 | property string tag: "intRole"
10 | property var expectedValues: [1, 2, 3, 4, 5]
11 | roleName: "intRole"
12 | },
13 | RoleSorter {
14 | property string tag: "intRoleDescending"
15 | property var expectedValues: [5, 4, 3, 2, 1]
16 | roleName: "intRole"
17 | sortOrder: Qt.DescendingOrder
18 | },
19 | RoleSorter {
20 | property string tag: "stringRole"
21 | property var expectedValues: ["a", "b", "c", "d", "e"]
22 | roleName: "stringRole"
23 | },
24 | RoleSorter {
25 | property string tag: "stringRoleDescending"
26 | property var expectedValues: ["e", "d", "c", "b", "a"]
27 | roleName: "stringRole"
28 | sortOrder: Qt.DescendingOrder
29 | },
30 | RoleSorter {
31 | property string tag: "mixedCaseStringRole"
32 | property var expectedValues: ["A", "b", "C", "D", "e"]
33 | roleName: "mixedCaseStringRole"
34 | }
35 | ]
36 |
37 | ListModel {
38 | id: dataModel
39 | ListElement { intRole: 5; stringRole: "c"; mixedCaseStringRole: "C" }
40 | ListElement { intRole: 3; stringRole: "e"; mixedCaseStringRole: "e" }
41 | ListElement { intRole: 1; stringRole: "d"; mixedCaseStringRole: "D" }
42 | ListElement { intRole: 2; stringRole: "a"; mixedCaseStringRole: "A" }
43 | ListElement { intRole: 4; stringRole: "b"; mixedCaseStringRole: "b" }
44 | }
45 |
46 | SortFilterProxyModel {
47 | id: testModel
48 | sourceModel: dataModel
49 | }
50 |
51 | TestCase {
52 | name: "RoleSorterTests"
53 |
54 | function test_roleSorters_data() {
55 | return sorters;
56 | }
57 |
58 | function test_roleSorters(sorter) {
59 | testModel.sorters = sorter;
60 |
61 | verify(testModel.count === sorter.expectedValues.length,
62 | "Expected count " + sorter.expectedValues.length + ", actual count: " + testModel.count);
63 | for (var i = 0; i < testModel.count; i++)
64 | {
65 | var modelValue = testModel.get(i, sorter.roleName);
66 | verify(modelValue === sorter.expectedValues[i],
67 | "Expected testModel value " + sorter.expectedValues[i] + ", actual: " + modelValue);
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/tests/tst_sortfilterproxymodel.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | QUICK_TEST_MAIN(SortFilterProxyModel)
3 |
--------------------------------------------------------------------------------
/thirdparty/SortFilterProxyModel/tests/tst_sourceroles.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.0
2 | import QtTest 1.1
3 | import QtQml 2.2
4 | import SortFilterProxyModel 0.2
5 |
6 | Item {
7 | ListModel {
8 | id: nonEmptyFirstModel
9 | ListElement {
10 | test: "test"
11 | }
12 | }
13 | SortFilterProxyModel {
14 | id: nonEmptyFirstProxyModel
15 | sourceModel: nonEmptyFirstModel
16 | }
17 | Instantiator {
18 | id: nonEmptyFirstInstantiator
19 | model: nonEmptyFirstProxyModel
20 | QtObject { property var test: model.test }
21 | }
22 |
23 | ListModel {
24 | id: emptyFirstModel
25 | }
26 | SortFilterProxyModel {
27 | id: emptyFirstProxyModel
28 | sourceModel: emptyFirstModel
29 | }
30 | Instantiator {
31 | id: emptyFirstInstantiator
32 | model: emptyFirstProxyModel
33 | QtObject { property var test: model.test }
34 | }
35 |
36 | TestCase {
37 | name: "RoleTests"
38 |
39 | function test_nonEmptyFirst() {
40 | compare(nonEmptyFirstInstantiator.object.test, "test");
41 | }
42 |
43 | function test_emptyFirst() {
44 | emptyFirstModel.append({test: "test"});
45 | compare(emptyFirstProxyModel.get(0), {test: "test"});
46 | compare(emptyFirstInstantiator.object.test, "test");
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/thirdparty/thirdparty.pri:
--------------------------------------------------------------------------------
1 | INCLUDEPATH += $$PWD
2 |
3 | include(QtQmlTricks/QtQmlTricks.pri)
4 | include(SortFilterProxyModel/SortFilterProxyModel.pri)
5 |
--------------------------------------------------------------------------------