From 8c20a67cfad34368efb995c45cf5e485fad5ae44 Mon Sep 17 00:00:00 2001 From: Mortie Date: Mon, 29 Aug 2022 12:21:09 +0430 Subject: [PATCH] migrated the codebase to Qt6 and fixed some compatibility issues * used a Qt6 ported version of SortFilterProxyModel * used an updated Qt6 compatible version of QXZing * added a flag to windows linker to avoid WinMain problem of MSVCRTD * renamed utils.cpp to utilities.cpp for avoiding confusion with the same file name in SortFilterProxyModel --- client/3rd/QtSsh/src/ssh/sshpacket.cpp | 2 +- .../3rd/QtSsh/src/ssh/sshx11inforetriever.cpp | 2 +- .../3rd/SortFilterProxyModel/CMakeLists.txt | 28 +- .../SortFilterProxyModel.pri | 8 +- .../SortFilterProxyModel.qbs | 65 ++ .../3rd/SortFilterProxyModel/docs/index.html | 65 ++ ...ml-sortfilterproxymodel-allof-members.html | 19 + .../docs/qml-sortfilterproxymodel-allof.html | 67 ++ ...ml-sortfilterproxymodel-anyof-members.html | 19 + .../docs/qml-sortfilterproxymodel-anyof.html | 86 ++ ...erproxymodel-expressionfilter-members.html | 20 + ...sortfilterproxymodel-expressionfilter.html | 78 ++ ...lterproxymodel-expressionrole-members.html | 19 + ...l-sortfilterproxymodel-expressionrole.html | 73 ++ ...erproxymodel-expressionsorter-members.html | 21 + ...sortfilterproxymodel-expressionsorter.html | 101 +++ ...l-sortfilterproxymodel-filter-members.html | 19 + .../docs/qml-sortfilterproxymodel-filter.html | 65 ++ ...terproxymodel-filtercontainer-members.html | 18 + ...-sortfilterproxymodel-filtercontainer.html | 61 ++ ...rtfilterproxymodel-filterrole-members.html | 19 + .../qml-sortfilterproxymodel-filterrole.html | 73 ++ ...filterproxymodel-filtersorter-members.html | 21 + ...qml-sortfilterproxymodel-filtersorter.html | 101 +++ ...tfilterproxymodel-indexfilter-members.html | 21 + .../qml-sortfilterproxymodel-indexfilter.html | 104 +++ ...sortfilterproxymodel-joinrole-members.html | 20 + .../qml-sortfilterproxymodel-joinrole.html | 83 ++ ...ortfilterproxymodel-proxyrole-members.html | 15 + .../qml-sortfilterproxymodel-proxyrole.html | 35 + ...tfilterproxymodel-rangefilter-members.html | 24 + .../qml-sortfilterproxymodel-rangefilter.html | 141 +++ ...filterproxymodel-regexpfilter-members.html | 23 + ...qml-sortfilterproxymodel-regexpfilter.html | 132 +++ ...rtfilterproxymodel-regexprole-members.html | 20 + .../qml-sortfilterproxymodel-regexprole.html | 82 ++ ...rtfilterproxymodel-rolefilter-members.html | 20 + .../qml-sortfilterproxymodel-rolefilter.html | 77 ++ ...rtfilterproxymodel-rolesorter-members.html | 21 + .../qml-sortfilterproxymodel-rolesorter.html | 98 +++ ...rtfilterproxymodel-singlerole-members.html | 18 + .../qml-sortfilterproxymodel-singlerole.html | 53 ++ ...l-sortfilterproxymodel-sorter-members.html | 20 + .../docs/qml-sortfilterproxymodel-sorter.html | 81 ++ ...terproxymodel-sortercontainer-members.html | 18 + ...-sortfilterproxymodel-sortercontainer.html | 56 ++ ...oxymodel-sortfilterproxymodel-members.html | 31 + ...filterproxymodel-sortfilterproxymodel.html | 206 +++++ ...filterproxymodel-stringsorter-members.html | 28 + ...qml-sortfilterproxymodel-stringsorter.html | 90 ++ ...rtfilterproxymodel-switchrole-members.html | 22 + .../qml-sortfilterproxymodel-switchrole.html | 117 +++ ...tfilterproxymodel-valuefilter-members.html | 21 + .../qml-sortfilterproxymodel-valuefilter.html | 100 +++ .../docs/sortfilterproxymodel-qmlmodule.html | 44 + .../docs/sortfilterproxymodel.index | 156 ++++ .../docs/style/offline.css | 805 ++++++++++++++++++ .../filters/filtercontainer.cpp | 4 +- .../filters/filtercontainer.h | 4 +- .../filters/rangefilter.cpp | 3 +- .../filters/regexpfilter.cpp | 47 +- .../filters/regexpfilter.h | 23 +- .../proxyroles/proxyrolecontainer.cpp | 4 +- .../proxyroles/proxyrolecontainer.h | 4 +- client/3rd/SortFilterProxyModel/qpm.json | 22 + .../qqmlsortfilterproxymodel.cpp | 23 +- .../qqmlsortfilterproxymodel.h | 16 +- .../sorters/rolesorter.cpp | 11 +- .../sorters/sortercontainer.cpp | 4 +- .../sorters/sortercontainer.h | 4 +- .../3rd/SortFilterProxyModel/tests/BLACKLIST | 2 + .../tests/SortFilterProxyModel.pro | 36 + .../tests/indexsorter.cpp | 21 + .../SortFilterProxyModel/tests/indexsorter.h | 20 + .../SortFilterProxyModel/tests/testroles.cpp | 48 ++ .../SortFilterProxyModel/tests/testroles.h | 47 + .../tests/tst_builtins.qml | 54 ++ .../tests/tst_delayed.qml | 209 +++++ .../tests/tst_expressionrole.qml | 43 + .../tests/tst_filtercontainerattached.qml | 57 ++ .../tests/tst_filtercontainers.qml | 103 +++ .../tests/tst_filterrole.qml | 47 + .../tests/tst_filtersorter.qml | 45 + .../tests/tst_helpers.qml | 111 +++ .../tests/tst_indexfilter.qml | 104 +++ .../tests/tst_joinrole.qml | 45 + .../tests/tst_proxyroles.qml | 126 +++ .../tests/tst_rangefilter.qml | 99 +++ .../tests/tst_regexprole.qml | 54 ++ .../tests/tst_rolesorter.qml | 70 ++ .../tests/tst_sortercontainerattached.qml | 131 +++ .../tests/tst_sorters.qml | 158 ++++ .../tests/tst_sortfilterproxymodel.cpp | 2 + .../tests/tst_sourceroles.qml | 49 ++ .../tests/tst_stringsorter.qml | 85 ++ .../tests/tst_switchrole.qml | 99 +++ .../3rd/SortFilterProxyModel/utils/utils.cpp | 59 ++ client/3rd/SortFilterProxyModel/utils/utils.h | 17 + client/client.pro | 19 +- client/configurators/ikev2_configurator.cpp | 2 +- client/configurators/openvpn_configurator.cpp | 2 +- client/configurators/ssh_configurator.cpp | 4 +- client/configurators/vpn_configurator.cpp | 2 +- .../configurators/wireguard_configurator.cpp | 2 +- client/core/servercontroller.cpp | 4 +- client/debug.cpp | 4 +- client/logger.h | 2 + client/loghandler.cpp | 17 +- client/loghandler.h | 18 +- .../protocols/ikev2_vpn_protocol_windows.cpp | 2 +- client/protocols/openvpnovercloakprotocol.cpp | 2 +- client/protocols/openvpnprotocol.cpp | 6 +- client/protocols/shadowsocksvpnprotocol.cpp | 2 +- client/protocols/wireguardprotocol.cpp | 6 +- client/settings.cpp | 2 +- client/ui/framelesswindow.cpp | 6 +- .../ui/pages_logic/NetworkSettingsLogic.cpp | 6 +- client/ui/pages_logic/NetworkSettingsLogic.h | 2 +- .../ui/pages_logic/ShareConnectionLogic.cpp | 2 +- client/ui/pages_logic/SitesLogic.cpp | 4 +- client/ui/pages_logic/StartPageLogic.cpp | 4 +- client/ui/pages_logic/StartPageLogic.h | 4 +- .../protocols/OtherProtocolsLogic.cpp | 4 +- client/ui/qml/main.qml | 10 +- client/ui/uilogic.cpp | 2 +- client/ui/uilogic.h | 2 +- client/{utils.cpp => utilities.cpp} | 8 +- client/{utils.h => utilities.h} | 14 +- client/vpnconnection.cpp | 2 +- service/server/localserver.cpp | 2 +- service/server/log.cpp | 4 +- service/server/main.cpp | 2 +- service/server/router_linux.cpp | 2 +- service/server/router_mac.cpp | 2 +- service/server/router_win.cpp | 2 +- service/server/server.pro | 4 +- service/server/tapcontroller_win.cpp | 4 +- service/src/qtservice.cpp | 2 +- service/src/qtservice.h | 2 +- service/src/qtservice_win.cpp | 4 +- 140 files changed, 5924 insertions(+), 214 deletions(-) create mode 100644 client/3rd/SortFilterProxyModel/SortFilterProxyModel.qbs create mode 100644 client/3rd/SortFilterProxyModel/docs/index.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-allof-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-allof.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-anyof-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-anyof.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionfilter-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionfilter.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionrole-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionrole.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionsorter-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionsorter.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filter-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filter.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtercontainer-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtercontainer.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filterrole-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filterrole.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtersorter-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtersorter.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-indexfilter-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-indexfilter.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-joinrole-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-joinrole.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-proxyrole-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-proxyrole.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rangefilter-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rangefilter.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexpfilter-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexpfilter.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexprole-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexprole.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolefilter-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolefilter.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolesorter-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolesorter.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-singlerole-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-singlerole.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sorter-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sorter.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortercontainer-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortercontainer.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortfilterproxymodel-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortfilterproxymodel.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-stringsorter-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-stringsorter.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-switchrole-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-switchrole.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-valuefilter-members.html create mode 100644 client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-valuefilter.html create mode 100644 client/3rd/SortFilterProxyModel/docs/sortfilterproxymodel-qmlmodule.html create mode 100644 client/3rd/SortFilterProxyModel/docs/sortfilterproxymodel.index create mode 100644 client/3rd/SortFilterProxyModel/docs/style/offline.css create mode 100644 client/3rd/SortFilterProxyModel/qpm.json create mode 100644 client/3rd/SortFilterProxyModel/tests/BLACKLIST create mode 100644 client/3rd/SortFilterProxyModel/tests/SortFilterProxyModel.pro create mode 100644 client/3rd/SortFilterProxyModel/tests/indexsorter.cpp create mode 100644 client/3rd/SortFilterProxyModel/tests/indexsorter.h create mode 100644 client/3rd/SortFilterProxyModel/tests/testroles.cpp create mode 100644 client/3rd/SortFilterProxyModel/tests/testroles.h create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_builtins.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_delayed.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_expressionrole.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_filtercontainerattached.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_filtercontainers.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_filterrole.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_filtersorter.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_helpers.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_indexfilter.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_joinrole.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_proxyroles.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_rangefilter.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_regexprole.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_rolesorter.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_sortercontainerattached.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_sorters.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_sortfilterproxymodel.cpp create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_sourceroles.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_stringsorter.qml create mode 100644 client/3rd/SortFilterProxyModel/tests/tst_switchrole.qml create mode 100644 client/3rd/SortFilterProxyModel/utils/utils.cpp create mode 100644 client/3rd/SortFilterProxyModel/utils/utils.h rename client/{utils.cpp => utilities.cpp} (96%) rename client/{utils.h => utilities.h} (81%) diff --git a/client/3rd/QtSsh/src/ssh/sshpacket.cpp b/client/3rd/QtSsh/src/ssh/sshpacket.cpp index 94238ffd..e75ab4a4 100644 --- a/client/3rd/QtSsh/src/ssh/sshpacket.cpp +++ b/client/3rd/QtSsh/src/ssh/sshpacket.cpp @@ -151,7 +151,7 @@ quint32 AbstractSshPacket::minPacketSize() const void AbstractSshPacket::setLengthField(QByteArray &data) { const quint32 length = qToBigEndian(data.size() - 4); - data.replace(0, 4, reinterpret_cast(&length), 4); + data.replace(qsizetype(0), 4, reinterpret_cast(&length), 4); } } // namespace Internal diff --git a/client/3rd/QtSsh/src/ssh/sshx11inforetriever.cpp b/client/3rd/QtSsh/src/ssh/sshx11inforetriever.cpp index de5505c9..5abfae4e 100644 --- a/client/3rd/QtSsh/src/ssh/sshx11inforetriever.cpp +++ b/client/3rd/QtSsh/src/ssh/sshx11inforetriever.cpp @@ -107,7 +107,7 @@ SshX11InfoRetriever::SshX11InfoRetriever(const QString &displayName, QObject *pa return; } if (dotIndex != -1) { - displayInfo.screen = m_displayName.midRef(dotIndex + 1).toInt(&ok); + displayInfo.screen = m_displayName.mid(dotIndex + 1).toInt(&ok); if (!ok) { emitFailure(tr("Invalid display name \"%1\"").arg(m_displayName)); return; diff --git a/client/3rd/SortFilterProxyModel/CMakeLists.txt b/client/3rd/SortFilterProxyModel/CMakeLists.txt index 3d3bf2bb..8095071f 100644 --- a/client/3rd/SortFilterProxyModel/CMakeLists.txt +++ b/client/3rd/SortFilterProxyModel/CMakeLists.txt @@ -1,11 +1,11 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.14) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) -find_package(Qt5 REQUIRED +find_package(Qt6 REQUIRED COMPONENTS Core Qml - ) +) set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) # This is to find generated *.moc and *.h files in build dir @@ -40,10 +40,22 @@ add_library(SortFilterProxyModel OBJECT proxyroles/regexprole.cpp sorters/filtersorter.cpp proxyroles/filterrole.cpp - ) + utils/utils.cpp + utils/utils.h +) + +target_link_libraries(SortFilterProxyModel + PRIVATE + Qt6::Core + Qt6::Qml +) + +if ((MSVC) AND (MSVC_VERSION GREATER_EQUAL 1914)) + target_compile_options(SortFilterProxyModel PUBLIC "/Zc:__cplusplus") +endif() target_include_directories(SortFilterProxyModel PUBLIC ${CMAKE_CURRENT_LIST_DIR} - $ - $ - ) + $ + $ +) diff --git a/client/3rd/SortFilterProxyModel/SortFilterProxyModel.pri b/client/3rd/SortFilterProxyModel/SortFilterProxyModel.pri index 24a01c4c..5c42037c 100644 --- a/client/3rd/SortFilterProxyModel/SortFilterProxyModel.pri +++ b/client/3rd/SortFilterProxyModel/SortFilterProxyModel.pri @@ -1,3 +1,5 @@ +!contains( CONFIG, c\+\+1[14] ): warning("SortFilterProxyModel needs at least c++11, add CONFIG += c++11 to your .pro") + INCLUDEPATH += $$PWD HEADERS += $$PWD/qqmlsortfilterproxymodel.h \ @@ -25,7 +27,8 @@ HEADERS += $$PWD/qqmlsortfilterproxymodel.h \ $$PWD/proxyroles/singlerole.h \ $$PWD/proxyroles/regexprole.h \ $$PWD/sorters/filtersorter.h \ - $$PWD/proxyroles/filterrole.h + $$PWD/proxyroles/filterrole.h \ + $$PWD/utils/utils.h SOURCES += $$PWD/qqmlsortfilterproxymodel.cpp \ $$PWD/filters/filter.cpp \ @@ -55,4 +58,5 @@ SOURCES += $$PWD/qqmlsortfilterproxymodel.cpp \ $$PWD/proxyroles/singlerole.cpp \ $$PWD/proxyroles/regexprole.cpp \ $$PWD/sorters/filtersorter.cpp \ - $$PWD/proxyroles/filterrole.cpp + $$PWD/proxyroles/filterrole.cpp \ + $$PWD/utils/utils.cpp diff --git a/client/3rd/SortFilterProxyModel/SortFilterProxyModel.qbs b/client/3rd/SortFilterProxyModel/SortFilterProxyModel.qbs new file mode 100644 index 00000000..23ec8472 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/SortFilterProxyModel.qbs @@ -0,0 +1,65 @@ +import qbs + +Group { + name: "SortFilterProxyModel" + prefix: path + "/" + files: [ + "filters/alloffilter.cpp", + "filters/alloffilter.h", + "filters/anyoffilter.cpp", + "filters/anyoffilter.h", + "filters/expressionfilter.cpp", + "filters/expressionfilter.h", + "filters/filter.cpp", + "filters/filter.h", + "filters/filtercontainer.cpp", + "filters/filtercontainer.h", + "filters/filtercontainerfilter.cpp", + "filters/filtercontainerfilter.h", + "filters/filtersqmltypes.cpp", + "filters/indexfilter.cpp", + "filters/indexfilter.h", + "filters/rangefilter.cpp", + "filters/rangefilter.h", + "filters/regexpfilter.cpp", + "filters/regexpfilter.h", + "filters/rolefilter.cpp", + "filters/rolefilter.h", + "filters/valuefilter.cpp", + "filters/valuefilter.h", + "proxyroles/expressionrole.cpp", + "proxyroles/expressionrole.h", + "proxyroles/filterrole.cpp", + "proxyroles/filterrole.h", + "proxyroles/joinrole.cpp", + "proxyroles/joinrole.h", + "proxyroles/proxyrole.cpp", + "proxyroles/proxyrole.h", + "proxyroles/proxyrolecontainer.cpp", + "proxyroles/proxyrolecontainer.h", + "proxyroles/proxyrolesqmltypes.cpp", + "proxyroles/regexprole.cpp", + "proxyroles/regexprole.h", + "proxyroles/singlerole.cpp", + "proxyroles/singlerole.h", + "proxyroles/switchrole.cpp", + "proxyroles/switchrole.h", + "sorters/expressionsorter.cpp", + "sorters/expressionsorter.h", + "sorters/filtersorter.cpp", + "sorters/filtersorter.h", + "sorters/rolesorter.cpp", + "sorters/rolesorter.h", + "sorters/sorter.cpp", + "sorters/sorter.h", + "sorters/sortercontainer.cpp", + "sorters/sortercontainer.h", + "sorters/sortersqmltypes.cpp", + "sorters/stringsorter.cpp", + "sorters/stringsorter.h", + "utils/utils.cpp", + "utils/utils.h", + "qqmlsortfilterproxymodel.cpp", + "qqmlsortfilterproxymodel.h" + ] +} diff --git a/client/3rd/SortFilterProxyModel/docs/index.html b/client/3rd/SortFilterProxyModel/docs/index.html new file mode 100644 index 00000000..ae3901ef --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/index.html @@ -0,0 +1,65 @@ + + + + + + + SortFilterProxyModel QML Module | SortFilterProxyModel + + + +

SortFilterProxyModel QML Module

+ + +
+

SortFilterProxyModel is an implementation of QSortFilterProxyModel conveniently exposed for QML.

+ +

SortFilterProxyModel

Filters and sorts data coming from a source QAbstractItemModel

+

+ +

Filters

+
+ + + + + + + + + +

AllOf

Filter container accepting rows accepted by all its child filters

AnyOf

Filter container accepting rows accepted by at least one of its child filters

ExpressionFilter

Filters row with a custom filtering

Filter

Base type for the SortFilterProxyModel filters

IndexFilter

Filters rows based on their source index

RangeFilter

Filters rows between boundary values

RegExpFilter

Filters rows matching a regular expression

RoleFilter

Base type for filters based on a source model role

ValueFilter

Filters rows matching exactly a value

+ + +
+ +

FilterContainer

Abstract interface for types containing Filters

+ +

Sorters

+
+ + + + + +

ExpressionSorter

Sorts row with a custom javascript expression

FilterSorter

Sorts rows based on if they match filters

RoleSorter

Sorts rows based on a source model role

Sorter

Base type for the SortFilterProxyModel sorters

StringSorter

Sorts rows based on a source model string role

+ + +
+ +

SorterContainer

Abstract interface for types containing Sorters

+ +

ProxyRoles

+
+ + + + + + + +

ExpressionRole

A custom role computed from a javascript expression

FilterRole

A role resolving to true for rows matching all its filters

JoinRole

Role made from concatenating other roles

ProxyRole

Base type for the SortFilterProxyModel proxy roles

RegExpRole

A ProxyRole extracting data from a source role via a regular expression

SingleRole

Base type for the SortFilterProxyModel proxy roles defining a single role

SwitchRole

A role using Filter to conditionnaly compute its data

+
+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-allof-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-allof-members.html new file mode 100644 index 00000000..a6b613ef --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-allof-members.html @@ -0,0 +1,19 @@ + + + + + + + List of All Members for AllOf | SortFilterProxyModel + + + + +

List of All Members for AllOf

+

This is the complete list of members for AllOf, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-allof.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-allof.html new file mode 100644 index 00000000..551442ab --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-allof.html @@ -0,0 +1,67 @@ + + + + + + + AllOf QML Type | SortFilterProxyModel + + + + +

AllOf QML Type

+ + +

Filter container accepting rows accepted by all its child filters. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

Filter

+
+ +

Properties

+ + + +

Detailed Description

+

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.

+

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.

+

See also FilterContainer.

+ +

Property Documentation

+ +
+
+ + +

+enabled : bool

+

This property holds whether the filter is enabled. A disabled filter will accept every rows unconditionally (even if it's inverted).

+

By default, filters are enabled.

+
+
+ +
+
+ + +

+inverted : bool

+

This property holds whether the filter is inverted. When a filter is inverted, a row normally accepted would be rejected, and vice-versa.

+

By default, filters are not inverted.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-anyof-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-anyof-members.html new file mode 100644 index 00000000..955d1b25 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-anyof-members.html @@ -0,0 +1,19 @@ + + + + + + + List of All Members for AnyOf | SortFilterProxyModel + + + + +

List of All Members for AnyOf

+

This is the complete list of members for AnyOf, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-anyof.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-anyof.html new file mode 100644 index 00000000..1e269e72 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-anyof.html @@ -0,0 +1,86 @@ + + + + + + + AnyOf QML Type | SortFilterProxyModel + + + + +

AnyOf QML Type

+ + +

Filter container accepting rows accepted by at least one of its child filters. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

Filter

+
+ +

Properties

+ + + +

Detailed Description

+

The AnyOf type is a Filter container that accepts rows if any of its contained (and enabled) filters accept them.

+

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 :

+
TextField {
+  id: nameTextField
+}
+
+SortFilterProxyModel {
+  sourceModel: contactModel
+  filters: AnyOf {
+      RegExpFilter {
+          roleName: "lastName"
+          pattern: nameTextField.text
+          caseSensitivity: Qt.CaseInsensitive
+      }
+      RegExpFilter {
+          roleName: "firstName"
+          pattern: nameTextField.text
+          caseSensitivity: Qt.CaseInsensitive
+      }
+  }
+}
+

See also FilterContainer.

+ +

Property Documentation

+ +
+
+ + +

+enabled : bool

+

This property holds whether the filter is enabled. A disabled filter will accept every rows unconditionally (even if it's inverted).

+

By default, filters are enabled.

+
+
+ +
+
+ + +

+inverted : bool

+

This property holds whether the filter is inverted. When a filter is inverted, a row normally accepted would be rejected, and vice-versa.

+

By default, filters are not inverted.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionfilter-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionfilter-members.html new file mode 100644 index 00000000..4233a817 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionfilter-members.html @@ -0,0 +1,20 @@ + + + + + + + List of All Members for ExpressionFilter | SortFilterProxyModel + + + + +

List of All Members for ExpressionFilter

+

This is the complete list of members for ExpressionFilter, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionfilter.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionfilter.html new file mode 100644 index 00000000..46bb745f --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionfilter.html @@ -0,0 +1,78 @@ + + + + + + + ExpressionFilter QML Type | SortFilterProxyModel + + + + +

ExpressionFilter QML Type

+ + +

Filters row with a custom filtering. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

Filter

+
+ +

Properties

+ + + +

Detailed Description

+

An ExpressionFilter is a Filter allowing to implement custom filtering based on a javascript expression.

+ +

Property Documentation

+ +
+
+ + +

+enabled : bool

+

This property holds whether the filter is enabled. A disabled filter will accept every rows unconditionally (even if it's inverted).

+

By default, filters are enabled.

+
+
+ +
+
+ + +

+expression : expression

+

An expression to implement custom filtering, it must evaluate to a boolean. It has the same syntax has a Property Binding except it will be evaluated for each of the source model's rows. Rows that have their expression evaluating to true will be accepted by the model. Data for each row is exposed like for a delegate of a QML View.

+

This expression is reevaluated for a row every time its model data changes. When an external property (not index or in model) the expression depends on changes, the expression is reevaluated for every row of the source model. To capture the properties the expression depends on, the expression is first executed with invalid data and each property access is detected by the QML engine. This means that if a property is not accessed because of a conditional, it won't be captured and the expression won't be reevaluted when this property changes.

+

A workaround to this problem is to access all the properties the expressions depends unconditionally at the beggining of the expression.

+
+
+ +
+
+ + +

+inverted : bool

+

This property holds whether the filter is inverted. When a filter is inverted, a row normally accepted would be rejected, and vice-versa.

+

By default, filters are not inverted.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionrole-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionrole-members.html new file mode 100644 index 00000000..8b6eeca8 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionrole-members.html @@ -0,0 +1,19 @@ + + + + + + + List of All Members for ExpressionRole | SortFilterProxyModel + + + + +

List of All Members for ExpressionRole

+

This is the complete list of members for ExpressionRole, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionrole.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionrole.html new file mode 100644 index 00000000..0ef4acbe --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionrole.html @@ -0,0 +1,73 @@ + + + + + + + ExpressionRole QML Type | SortFilterProxyModel + + + + +

ExpressionRole QML Type

+ + +

A custom role computed from a javascript expression. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

SingleRole

+
+ +

Properties

+ + + +

Detailed Description

+

An ExpressionRole is a ProxyRole allowing to implement a custom role based on a javascript expression.

+

In the following example, the c role is computed by adding the a role and b role of the model :

+
SortFilterProxyModel {
+   sourceModel: numberModel
+   proxyRoles: ExpressionRole {
+       name: "c"
+       expression: model.a + model.b
+  }
+}
+ +

Property Documentation

+ +
+
+ + +

+expression : expression

+

An expression to implement a custom role. It has the same syntax has a Property Binding except it will be evaluated for each of the source model's rows. The data for this role will be the retuned valued of the expression. Data for each row is exposed like for a delegate of a QML View.

+

This expression is reevaluated for a row every time its model data changes. When an external property (not index or in model) the expression depends on changes, the expression is reevaluated for every row of the source model. To capture the properties the expression depends on, the expression is first executed with invalid data and each property access is detected by the QML engine. This means that if a property is not accessed because of a conditional, it won't be captured and the expression won't be reevaluted when this property changes.

+

A workaround to this problem is to access all the properties the expressions depends unconditionally at the beggining of the expression.

+
+
+ +
+
+ + +

+name : string

+

This property holds the role name of the proxy role.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionsorter-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionsorter-members.html new file mode 100644 index 00000000..b32c15c6 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionsorter-members.html @@ -0,0 +1,21 @@ + + + + + + + List of All Members for ExpressionSorter | SortFilterProxyModel + + + + +

List of All Members for ExpressionSorter

+

This is the complete list of members for ExpressionSorter, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionsorter.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionsorter.html new file mode 100644 index 00000000..09292347 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-expressionsorter.html @@ -0,0 +1,101 @@ + + + + + + + ExpressionSorter QML Type | SortFilterProxyModel + + + + +

ExpressionSorter QML Type

+ + +

Sorts row with a custom javascript expression. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

Sorter

+
+ +

Properties

+ + + +

Detailed Description

+

An ExpressionSorter is a Sorter allowing to implement custom sorting based on a javascript expression.

+ +

Property Documentation

+ +
+
+ + +

+enabled : bool

+

This property holds whether the sorter is enabled. A disabled sorter will not change the order of the rows.

+

By default, sorters are enabled.

+
+
+ +
+
+ + +

+expression : expression

+

An expression to implement custom sorting. It must evaluate to a bool. It has the same syntax has a Property Binding, except that it will be evaluated for each of the source model's rows. Model data is accessible for both rows with the modelLeft, and modelRight properties:

+
sorters: ExpressionSorter {
+    expression: {
+        return modelLeft.someRole < modelRight.someRole;
+    }
+}
+

The index of the row is also available through modelLeft and modelRight.

+

The expression should return true if the value of the left item is less than the value of the right item, otherwise returns false.

+

This expression is reevaluated for a row every time its model data changes. When an external property (not index* or in model*) the expression depends on changes, the expression is reevaluated for every row of the source model. To capture the properties the expression depends on, the expression is first executed with invalid data and each property access is detected by the QML engine. This means that if a property is not accessed because of a conditional, it won't be captured and the expression won't be reevaluted when this property changes.

+

A workaround to this problem is to access all the properties the expressions depends unconditionally at the beggining of the expression.

+
+
+ +
+
+ + +

+priority : int

+

This property holds the sort priority of this sorter. Sorters with a higher priority are applied first. In case of equal priority, Sorters are ordered by their insertion order.

+

By default, the priority is 0.

+
+
+ +
+
+ + +

+sortOrder : Qt::SortOrder

+

This property holds the sort order of this sorter.

+
+ + +
ConstantDescription
Qt.AscendingOrderThe items are sorted ascending e.g. starts with 'AAA' ends with 'ZZZ' in Latin-1 locales
Qt.DescendingOrderThe items are sorted descending e.g. starts with 'ZZZ' ends with 'AAA' in Latin-1 locales
+

By default, sorting is in ascending order.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filter-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filter-members.html new file mode 100644 index 00000000..b309030a --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filter-members.html @@ -0,0 +1,19 @@ + + + + + + + List of All Members for Filter | SortFilterProxyModel + + + + +

List of All Members for Filter

+

This is the complete list of members for Filter, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filter.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filter.html new file mode 100644 index 00000000..03cc3476 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filter.html @@ -0,0 +1,65 @@ + + + + + + + Filter QML Type | SortFilterProxyModel + + + + +

Filter QML Type

+ + +

Base type for the SortFilterProxyModel filters. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherited By:

AllOf, AnyOf, ExpressionFilter, IndexFilter, and RoleFilter

+
+ +

Properties

+ + + +

Detailed Description

+

The Filter 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 Filter type directly will result in an error.

+ +

Property Documentation

+ +
+
+ + +

+enabled : bool

+

This property holds whether the filter is enabled. A disabled filter will accept every rows unconditionally (even if it's inverted).

+

By default, filters are enabled.

+
+
+ +
+
+ + +

+inverted : bool

+

This property holds whether the filter is inverted. When a filter is inverted, a row normally accepted would be rejected, and vice-versa.

+

By default, filters are not inverted.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtercontainer-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtercontainer-members.html new file mode 100644 index 00000000..9fe2f4bd --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtercontainer-members.html @@ -0,0 +1,18 @@ + + + + + + + List of All Members for FilterContainer | SortFilterProxyModel + + + + +

List of All Members for FilterContainer

+

This is the complete list of members for FilterContainer, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtercontainer.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtercontainer.html new file mode 100644 index 00000000..2545a718 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtercontainer.html @@ -0,0 +1,61 @@ + + + + + + + FilterContainer QML Type | SortFilterProxyModel + + + + +

FilterContainer QML Type

+ + +

Abstract interface for types containing Filters. More...

+ +
+
Import Statement: import SortFilterProxyModel .
+ +

Attached Properties

+ + + +

Detailed Description

+ +

Types implementing this interface:

+
+ + + + + + +

AllOf

Filter container accepting rows accepted by all its child filters

AnyOf

Filter container accepting rows accepted by at least one of its child filters

FilterRole

A role resolving to true for rows matching all its filters

FilterSorter

Sorts rows based on if they match filters

SortFilterProxyModel

Filters and sorts data coming from a source QAbstractItemModel

SwitchRole

A role using Filter to conditionnaly compute its data

+ +

Attached Property Documentation

+ +
+
+ + +

+FilterContainer.container : bool

+

This attached property allows you to include in a FilterContainer a Filter that has been instantiated outside of the FilterContainer, for example in an Instantiator.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filterrole-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filterrole-members.html new file mode 100644 index 00000000..f4bb0d11 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filterrole-members.html @@ -0,0 +1,19 @@ + + + + + + + List of All Members for FilterRole | SortFilterProxyModel + + + + +

List of All Members for FilterRole

+

This is the complete list of members for FilterRole, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filterrole.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filterrole.html new file mode 100644 index 00000000..9d022cf5 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filterrole.html @@ -0,0 +1,73 @@ + + + + + + + FilterRole QML Type | SortFilterProxyModel + + + + +

FilterRole QML Type

+ + +

A role resolving to true for rows matching all its filters. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

SingleRole

+
+ +

Properties

+ + + +

Detailed Description

+

A FilterRole is a ProxyRole that returns true for rows matching all its filters.

+

In the following example, the isAdult role will be equal to true if the age role is superior or equal to 18.

+
SortFilterProxyModel {
+    sourceModel: personModel
+    proxyRoles: FilterRole {
+        name: "isAdult"
+        RangeFilter { roleName: "age"; minimumValue: 18; minimumInclusive: true }
+    }
+}
+

See also FilterContainer.

+ +

Property Documentation

+ +
+
+ + +

+[default] filters : list<Filter>

+

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.

+

See also Filter and FilterContainer.

+
+
+ +
+
+ + +

+name : string

+

This property holds the role name of the proxy role.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtersorter-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtersorter-members.html new file mode 100644 index 00000000..6a3961a4 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtersorter-members.html @@ -0,0 +1,21 @@ + + + + + + + List of All Members for FilterSorter | SortFilterProxyModel + + + + +

List of All Members for FilterSorter

+

This is the complete list of members for FilterSorter, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtersorter.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtersorter.html new file mode 100644 index 00000000..4d495b80 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-filtersorter.html @@ -0,0 +1,101 @@ + + + + + + + FilterSorter QML Type | SortFilterProxyModel + + + + +

FilterSorter QML Type

+ + +

Sorts rows based on if they match filters. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

Sorter

+
+ +

Properties

+ + + +

Detailed Description

+

A FilterSorter is a Sorter that orders row matching its filters before the rows not matching the filters.

+

In the following example, rows with their favorite role set to true will be ordered at the beginning :

+
SortFilterProxyModel {
+    sourceModel: contactModel
+    sorters: FilterSorter {
+        ValueFilter { roleName: "favorite"; value: true }
+    }
+}
+

See also FilterContainer.

+ +

Property Documentation

+ +
+
+ + +

+enabled : bool

+

This property holds whether the sorter is enabled. A disabled sorter will not change the order of the rows.

+

By default, sorters are enabled.

+
+
+ +
+
+ + +

+[default] filters : list<Filter>

+

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.

+

See also Filter and FilterContainer.

+
+
+ +
+
+ + +

+priority : int

+

This property holds the sort priority of this sorter. Sorters with a higher priority are applied first. In case of equal priority, Sorters are ordered by their insertion order.

+

By default, the priority is 0.

+
+
+ +
+
+ + +

+sortOrder : Qt::SortOrder

+

This property holds the sort order of this sorter.

+
+ + +
ConstantDescription
Qt.AscendingOrderThe items are sorted ascending e.g. starts with 'AAA' ends with 'ZZZ' in Latin-1 locales
Qt.DescendingOrderThe items are sorted descending e.g. starts with 'ZZZ' ends with 'AAA' in Latin-1 locales
+

By default, sorting is in ascending order.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-indexfilter-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-indexfilter-members.html new file mode 100644 index 00000000..bc766441 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-indexfilter-members.html @@ -0,0 +1,21 @@ + + + + + + + List of All Members for IndexFilter | SortFilterProxyModel + + + + +

List of All Members for IndexFilter

+

This is the complete list of members for IndexFilter, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-indexfilter.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-indexfilter.html new file mode 100644 index 00000000..e88806f0 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-indexfilter.html @@ -0,0 +1,104 @@ + + + + + + + IndexFilter QML Type | SortFilterProxyModel + + + + +

IndexFilter QML Type

+ + +

Filters rows based on their source index. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

Filter

+
+ +

Properties

+ + + +

Detailed Description

+

An IndexFilter is a filter allowing contents to be filtered based on their source model index.

+

In the following example, only the first row of the source model will be accepted:

+
SortFilterProxyModel {
+   sourceModel: contactModel
+   filters: IndexFilter {
+       maximumIndex: 0
+   }
+}
+ +

Property Documentation

+ +
+
+ + +

+enabled : bool

+

This property holds whether the filter is enabled. A disabled filter will accept every rows unconditionally (even if it's inverted).

+

By default, filters are enabled.

+
+
+ +
+
+ + +

+inverted : bool

+

This property holds whether the filter is inverted. When a filter is inverted, a row normally accepted would be rejected, and vice-versa.

+

By default, filters are not inverted.

+
+
+ +
+
+ + +

+maximumIndex : int

+

This property holds the maximumIndex of the filter. Rows with a source index higher than maximumIndex will be rejected.

+

If maximumIndex is negative, it is counted from the end of the source model, meaning that:

+
maximumIndex: -1
+

is equivalent to :

+
maximumIndex: sourceModel.count - 1
+

By default, no value is set.

+
+
+ +
+
+ + +

+minimumIndex : int

+

This property holds the minimumIndex of the filter. Rows with a source index lower than minimumIndex will be rejected.

+

If minimumIndex is negative, it is counted from the end of the source model, meaning that :

+
minimumIndex: -1
+

is equivalent to :

+
minimumIndex: sourceModel.count - 1
+

By default, no value is set.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-joinrole-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-joinrole-members.html new file mode 100644 index 00000000..f697e9a1 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-joinrole-members.html @@ -0,0 +1,20 @@ + + + + + + + List of All Members for JoinRole | SortFilterProxyModel + + + + +

List of All Members for JoinRole

+

This is the complete list of members for JoinRole, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-joinrole.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-joinrole.html new file mode 100644 index 00000000..1a17d3f1 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-joinrole.html @@ -0,0 +1,83 @@ + + + + + + + JoinRole QML Type | SortFilterProxyModel + + + + +

JoinRole QML Type

+ + +

a role made from concatenating other roles. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

SingleRole

+
+ +

Properties

+ + + +

Detailed Description

+

A JoinRole is a simple ProxyRole that concatenates other roles.

+

In the following example, the fullName role is computed by the concatenation of the firstName role and the lastName role separated by a space :

+
SortFilterProxyModel {
+   sourceModel: contactModel
+   proxyRoles: JoinRole {
+       name: "fullName"
+       roleNames: ["firstName", "lastName"]
+  }
+}
+ +

Property Documentation

+ +
+
+ + +

+name : string

+

This property holds the role name of the proxy role.

+
+
+ +
+
+ + +

+roleNames : list<string>

+

This property holds the role names that are joined by this role.

+
+
+ +
+
+ + +

+separator : string

+

This property holds the separator that is used to join the roles specified in roleNames.

+

By default, it's a space.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-proxyrole-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-proxyrole-members.html new file mode 100644 index 00000000..c4bb9cb6 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-proxyrole-members.html @@ -0,0 +1,15 @@ + + + + + + + List of All Members for ProxyRole | SortFilterProxyModel + + + + +

List of All Members for ProxyRole

+

This is the complete list of members for ProxyRole, including inherited members.

+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-proxyrole.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-proxyrole.html new file mode 100644 index 00000000..7408f0c9 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-proxyrole.html @@ -0,0 +1,35 @@ + + + + + + + ProxyRole QML Type | SortFilterProxyModel + + + + +

ProxyRole QML Type

+ + +

Base type for the SortFilterProxyModel proxy roles. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherited By:

RegExpRole and SingleRole

+
+ + +

Detailed Description

+

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.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rangefilter-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rangefilter-members.html new file mode 100644 index 00000000..7898ac61 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rangefilter-members.html @@ -0,0 +1,24 @@ + + + + + + + List of All Members for RangeFilter | SortFilterProxyModel + + + + +

List of All Members for RangeFilter

+

This is the complete list of members for RangeFilter, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rangefilter.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rangefilter.html new file mode 100644 index 00000000..0d431541 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rangefilter.html @@ -0,0 +1,141 @@ + + + + + + + RangeFilter QML Type | SortFilterProxyModel + + + + +

RangeFilter QML Type

+ + +

Filters rows between boundary values. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

RoleFilter

+
+ +

Properties

+ + + +

Detailed Description

+

A RangeFilter is a RoleFilter that accepts rows if their data is between the filter's minimum and maximum value.

+

In the following example, only rows with their price role set to a value between the tow boundary of the slider will be accepted :

+
RangeSlider {
+   id: priceRangeSlider
+}
+
+SortFilterProxyModel {
+   sourceModel: priceModel
+   filters: RangeFilter {
+       roleName: "price"
+       minimumValue: priceRangeSlider.first.value
+       maximumValue: priceRangeSlider.second.value
+   }
+}
+ +

Property Documentation

+ +
+
+ + +

+enabled : bool

+

This property holds whether the filter is enabled. A disabled filter will accept every rows unconditionally (even if it's inverted).

+

By default, filters are enabled.

+
+
+ +
+
+ + +

+inverted : bool

+

This property holds whether the filter is inverted. When a filter is inverted, a row normally accepted would be rejected, and vice-versa.

+

By default, filters are not inverted.

+
+
+ +
+
+ + +

+maximumInclusive : int

+

This property holds whether the minimumValue is inclusive.

+

By default, the minimumValue is inclusive.

+

See also minimumValue.

+
+
+ +
+
+ + +

+maximumValue : int

+

This property holds the maximumValue of the filter. Rows with a value higher than maximumValue will be rejected.

+

By default, no value is set.

+

See also maximumInclusive.

+
+
+ +
+
+ + +

+minimumInclusive : int

+

This property holds whether the minimumValue is inclusive.

+

By default, the minimumValue is inclusive.

+

See also minimumValue.

+
+
+ +
+
+ + +

+minimumValue : int

+

This property holds the minimumValue of the filter. Rows with a value lower than minimumValue will be rejected.

+

By default, no value is set.

+

See also minimumInclusive.

+
+
+ +
+
+ + +

+roleName : string

+

This property holds the role name that the filter is using to query the source model's data when filtering items.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexpfilter-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexpfilter-members.html new file mode 100644 index 00000000..c771d0b5 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexpfilter-members.html @@ -0,0 +1,23 @@ + + + + + + + List of All Members for RegExpFilter | SortFilterProxyModel + + + + +

List of All Members for RegExpFilter

+

This is the complete list of members for RegExpFilter, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexpfilter.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexpfilter.html new file mode 100644 index 00000000..bd0c9f17 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexpfilter.html @@ -0,0 +1,132 @@ + + + + + + + RegExpFilter QML Type | SortFilterProxyModel + + + + +

RegExpFilter QML Type

+ + +

Filters rows matching a regular expression. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

RoleFilter

+
+ +

Properties

+ + + +

Detailed Description

+

A RegExpFilter is a RoleFilter that accepts rows matching a regular rexpression.

+

In the following example, only rows with their lastName role beggining with the content of textfield the will be accepted:

+
TextField {
+   id: nameTextField
+}
+
+SortFilterProxyModel {
+   sourceModel: contactModel
+   filters: RegExpFilter {
+       roleName: "lastName"
+       pattern: "^" + nameTextField.displayText
+   }
+}
+ +

Property Documentation

+ +
+
+ + +

+caseSensitivity : Qt::CaseSensitivity

+

This property holds the caseSensitivity of the filter.

+
+
+ +
+
+ + +

+enabled : bool

+

This property holds whether the filter is enabled. A disabled filter will accept every rows unconditionally (even if it's inverted).

+

By default, filters are enabled.

+
+
+ +
+
+ + +

+inverted : bool

+

This property holds whether the filter is inverted. When a filter is inverted, a row normally accepted would be rejected, and vice-versa.

+

By default, filters are not inverted.

+
+
+ +
+
+ + +

+pattern : bool

+

The pattern used to filter the contents of the source model.

+

See also syntax.

+
+
+ +
+
+ + +

+roleName : string

+

This property holds the role name that the filter is using to query the source model's data when filtering items.

+
+
+ +
+
+ + +

+syntax : enum

+

The pattern used to filter the contents of the source model.

+

Only the source model's value having their RoleFilter::roleName data matching this pattern with the specified syntax will be kept.

+
+ + + + + + +
ConstantDescription
RegExpFilter.RegExpA rich Perl-like pattern matching syntax. This is the default.
RegExpFilter.WildcardThis provides a simple pattern matching syntax similar to that used by shells (command interpreters) for "file globbing".
RegExpFilter.FixedStringThe pattern is a fixed string. This is equivalent to using the RegExp pattern on a string in which all metacharacters are escaped.
RegExpFilter.RegExp2Like RegExp, but with greedy quantifiers.
RegExpFilter.WildcardUnixThis is similar to Wildcard but with the behavior of a Unix shell. The wildcard characters can be escaped with the character "".
RegExpFilter.W3CXmlSchema11The pattern is a regular expression as defined by the W3C XML Schema 1.1 specification.
+

See also pattern.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexprole-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexprole-members.html new file mode 100644 index 00000000..79a007df --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexprole-members.html @@ -0,0 +1,20 @@ + + + + + + + List of All Members for RegExpRole | SortFilterProxyModel + + + + +

List of All Members for RegExpRole

+

This is the complete list of members for RegExpRole, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexprole.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexprole.html new file mode 100644 index 00000000..504216fc --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-regexprole.html @@ -0,0 +1,82 @@ + + + + + + + RegExpRole QML Type | SortFilterProxyModel + + + + +

RegExpRole QML Type

+ + +

A ProxyRole extracting data from a source role via a regular expression. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

ProxyRole

+
+ +

Properties

+ + + +

Detailed Description

+

A RegExpRole is a ProxyRole that provides a role for each named capture group of its regular expression pattern.

+

In the following example, the date role of the source model will be extracted in 3 roles in the proxy moodel: year, month and day.

+
SortFilterProxyModel {
+    sourceModel: eventModel
+    proxyRoles: RegExpRole {
+        roleName: "date"
+        pattern: "(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})"
+    }
+}
+ +

Property Documentation

+ +
+
+ + +

+caseSensitivity : Qt::CaseSensitivity

+

This property holds the caseSensitivity of the regular expression.

+
+
+ +
+
+ + +

+pattern : QString

+

This property holds the pattern of the regular expression of this RegExpRole. The RegExpRole will expose a role for each of the named capture group of the pattern.

+
+
+ +
+
+ + +

+roleName : QString

+

This property holds the role name that the RegExpRole is using to query the source model's data to extract new roles from.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolefilter-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolefilter-members.html new file mode 100644 index 00000000..d21124b4 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolefilter-members.html @@ -0,0 +1,20 @@ + + + + + + + List of All Members for RoleFilter | SortFilterProxyModel + + + + +

List of All Members for RoleFilter

+

This is the complete list of members for RoleFilter, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolefilter.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolefilter.html new file mode 100644 index 00000000..86a499d4 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolefilter.html @@ -0,0 +1,77 @@ + + + + + + + RoleFilter QML Type | SortFilterProxyModel + + + + +

RoleFilter QML Type

+ + +

Base type for filters based on a source model role. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

Filter

+
Inherited By:

RangeFilter, RegExpFilter, and ValueFilter

+
+ +

Properties

+ + + +

Detailed Description

+

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.

+ +

Property Documentation

+ +
+
+ + +

+enabled : bool

+

This property holds whether the filter is enabled. A disabled filter will accept every rows unconditionally (even if it's inverted).

+

By default, filters are enabled.

+
+
+ +
+
+ + +

+inverted : bool

+

This property holds whether the filter is inverted. When a filter is inverted, a row normally accepted would be rejected, and vice-versa.

+

By default, filters are not inverted.

+
+
+ +
+
+ + +

+roleName : string

+

This property holds the role name that the filter is using to query the source model's data when filtering items.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolesorter-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolesorter-members.html new file mode 100644 index 00000000..d714d532 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolesorter-members.html @@ -0,0 +1,21 @@ + + + + + + + List of All Members for RoleSorter | SortFilterProxyModel + + + + +

List of All Members for RoleSorter

+

This is the complete list of members for RoleSorter, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolesorter.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolesorter.html new file mode 100644 index 00000000..8fed71d1 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-rolesorter.html @@ -0,0 +1,98 @@ + + + + + + + RoleSorter QML Type | SortFilterProxyModel + + + + +

RoleSorter QML Type

+ + +

Sorts rows based on a source model role. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

Sorter

+
Inherited By:

StringSorter

+
+ +

Properties

+ + + +

Detailed Description

+

A RoleSorter is a simple Sorter that sorts rows based on a source model role.

+

In the following example, rows with be sorted by their lastName role :

+
SortFilterProxyModel {
+   sourceModel: contactModel
+   sorters: RoleSorter { roleName: "lastName" }
+}
+ +

Property Documentation

+ +
+
+ + +

+enabled : bool

+

This property holds whether the sorter is enabled. A disabled sorter will not change the order of the rows.

+

By default, sorters are enabled.

+
+
+ +
+
+ + +

+priority : int

+

This property holds the sort priority of this sorter. Sorters with a higher priority are applied first. In case of equal priority, Sorters are ordered by their insertion order.

+

By default, the priority is 0.

+
+
+ +
+
+ + +

+roleName : string

+

This property holds the role name that the sorter is using to query the source model's data when sorting items.

+
+
+ +
+
+ + +

+sortOrder : Qt::SortOrder

+

This property holds the sort order of this sorter.

+
+ + +
ConstantDescription
Qt.AscendingOrderThe items are sorted ascending e.g. starts with 'AAA' ends with 'ZZZ' in Latin-1 locales
Qt.DescendingOrderThe items are sorted descending e.g. starts with 'ZZZ' ends with 'AAA' in Latin-1 locales
+

By default, sorting is in ascending order.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-singlerole-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-singlerole-members.html new file mode 100644 index 00000000..a62df06a --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-singlerole-members.html @@ -0,0 +1,18 @@ + + + + + + + List of All Members for SingleRole | SortFilterProxyModel + + + + +

List of All Members for SingleRole

+

This is the complete list of members for SingleRole, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-singlerole.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-singlerole.html new file mode 100644 index 00000000..e1d8727b --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-singlerole.html @@ -0,0 +1,53 @@ + + + + + + + SingleRole QML Type | SortFilterProxyModel + + + + +

SingleRole QML Type

+ + +

Base type for the SortFilterProxyModel proxy roles defining a single role. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

ProxyRole

+
Inherited By:

ExpressionRole, FilterRole, JoinRole, and SwitchRole

+
+ +

Properties

+ + + +

Detailed Description

+

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.

+ +

Property Documentation

+ +
+
+ + +

+name : string

+

This property holds the role name of the proxy role.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sorter-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sorter-members.html new file mode 100644 index 00000000..80328bd2 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sorter-members.html @@ -0,0 +1,20 @@ + + + + + + + List of All Members for Sorter | SortFilterProxyModel + + + + +

List of All Members for Sorter

+

This is the complete list of members for Sorter, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sorter.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sorter.html new file mode 100644 index 00000000..bbcfe668 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sorter.html @@ -0,0 +1,81 @@ + + + + + + + Sorter QML Type | SortFilterProxyModel + + + + +

Sorter QML Type

+ + +

Base type for the SortFilterProxyModel sorters. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherited By:

ExpressionSorter, FilterSorter, and RoleSorter

+
+ +

Properties

+ + + +

Detailed Description

+

The Sorter 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 sorters types that inherit from it. Attempting to use the Sorter type directly will result in an error.

+ +

Property Documentation

+ +
+
+ + +

+enabled : bool

+

This property holds whether the sorter is enabled. A disabled sorter will not change the order of the rows.

+

By default, sorters are enabled.

+
+
+ +
+
+ + +

+priority : int

+

This property holds the sort priority of this sorter. Sorters with a higher priority are applied first. In case of equal priority, Sorters are ordered by their insertion order.

+

By default, the priority is 0.

+
+
+ +
+
+ + +

+sortOrder : Qt::SortOrder

+

This property holds the sort order of this sorter.

+
+ + +
ConstantDescription
Qt.AscendingOrderThe items are sorted ascending e.g. starts with 'AAA' ends with 'ZZZ' in Latin-1 locales
Qt.DescendingOrderThe items are sorted descending e.g. starts with 'ZZZ' ends with 'AAA' in Latin-1 locales
+

By default, sorting is in ascending order.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortercontainer-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortercontainer-members.html new file mode 100644 index 00000000..9b87117f --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortercontainer-members.html @@ -0,0 +1,18 @@ + + + + + + + List of All Members for SorterContainer | SortFilterProxyModel + + + + +

List of All Members for SorterContainer

+

This is the complete list of members for SorterContainer, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortercontainer.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortercontainer.html new file mode 100644 index 00000000..b8dff10e --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortercontainer.html @@ -0,0 +1,56 @@ + + + + + + + SorterContainer QML Type | SortFilterProxyModel + + + + +

SorterContainer QML Type

+ + +

Abstract interface for types containing Sorters. More...

+ +
+
Import Statement: import SortFilterProxyModel .
+ +

Attached Properties

+ + + +

Detailed Description

+ +

Types implementing this interface:

+
+ +

SortFilterProxyModel

Filters and sorts data coming from a source QAbstractItemModel

+ +

Attached Property Documentation

+ +
+
+ + +

+SorterContainer.container : bool

+

This attached property allows you to include in a SorterContainer a Sorter that has been instantiated outside of the SorterContainer, for example in an Instantiator.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortfilterproxymodel-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortfilterproxymodel-members.html new file mode 100644 index 00000000..d44b931c --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortfilterproxymodel-members.html @@ -0,0 +1,31 @@ + + + + + + + List of All Members for SortFilterProxyModel | SortFilterProxyModel + + + + +

List of All Members for SortFilterProxyModel

+

This is the complete list of members for SortFilterProxyModel, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortfilterproxymodel.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortfilterproxymodel.html new file mode 100644 index 00000000..b57df588 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-sortfilterproxymodel.html @@ -0,0 +1,206 @@ + + + + + + + SortFilterProxyModel QML Type | SortFilterProxyModel + + + + +

SortFilterProxyModel QML Type

+ + +

Filters and sorts data coming from a source QAbstractItemModel. More...

+ +
+
Import Statement: import SortFilterProxyModel .
+ +

Properties

+ + +

Methods

+ + + +

Detailed Description

+

The SortFilterProxyModel type provides support for filtering and sorting data coming from a source model.

+

See also FilterContainer and SorterContainer.

+ +

Property Documentation

+ +
+
+ + +

+count : int

+

The number of rows in the proxy model (not filtered out the source model)

+
+
+ +
+
+ + +

+delayed : bool

+

Delay the execution of filters, sorters and proxyRoles until the next event loop. This can be used as an optimization when multiple filters, sorters or proxyRoles are changed in a single event loop. They will be executed once in a single batch at the next event loop instead of being executed in multiple sequential batches.

+

By default, the SortFilterProxyModel is not delayed, unless the SFPM_DELAYED environment variable is defined at compile time.

+
+
+ +
+
+ + +

+filters : list<Filter>

+

This property holds the list of filters for this proxy model. To be included in the model, a row of the source model has to be accepted by all the top level filters of this list.

+

See also Filter and FilterContainer.

+
+
+ +
+
+ + +

+proxyRoles : list<ProxyRole>

+

This property holds the list of proxy roles for this proxy model. Each proxy role adds a new custom role to the model.

+

See also ProxyRole.

+
+
+ +
+
+ + +

+sortRoleName : string

+

The role name of the source model's data used for the sorting.

+

See also sortRole and roleForName.

+
+
+ +
+
+ + +

+sorters : list<Sorter>

+

This property holds the list of sorters for this proxy model. The rows of the source model are sorted by the sorters of this list, in their order of insertion.

+

See also Sorter and SorterContainer.

+
+
+ +
+
+ + +

+sourceModel : QAbstractItemModel*

+

The source model of this proxy model

+
+
+

Method Documentation

+ +
+
+ + +

+variant get(row, string roleName)

+

Return the data for the given roleName of the item at row in the proxy model. This allows the role data to be read (not modified) from JavaScript. This equivalent to calling data(index(row, 0), roleForName(roleName)).

+
+
+ +
+
+ + +

+object get(row)

+

Return the item at row in the proxy model as a map of all its roles. This allows the item data to be read (not modified) from JavaScript.

+
+
+ +
+
+ + +

+int mapFromSource(sourceRow)

+

Returns the row in the SortFilterProxyModel given the sourceRow from the source model. Returns -1 if there is no corresponding row.

+
+
+ +
+
+ + +

+QModelIndex mapFromSource(sourceIndex)

+

Returns the model index in the SortFilterProxyModel given the sourceIndex from the source model.

+
+
+ +
+
+ + +

+int mapToSource(proxyRow)

+

Returns the source model row corresponding to the given proxyRow from the SortFilterProxyModel. Returns -1 if there is no corresponding row.

+
+
+ +
+
+ + +

+index mapToSource(proxyIndex)

+

Returns the source model index corresponding to the given proxyIndex from the SortFilterProxyModel.

+
+
+ +
+
+ + +

+int roleForName(roleName)

+

Returns the role number for the given roleName. If no role is found for this roleName, -1 is returned.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-stringsorter-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-stringsorter-members.html new file mode 100644 index 00000000..0fd29abf --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-stringsorter-members.html @@ -0,0 +1,28 @@ + + + + + + + List of All Members for StringSorter | SortFilterProxyModel + + + + +

List of All Members for StringSorter

+

This is the complete list of members for StringSorter, including inherited members.

+ +

The following members are inherited from RoleSorter.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-stringsorter.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-stringsorter.html new file mode 100644 index 00000000..3ab8462a --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-stringsorter.html @@ -0,0 +1,90 @@ + + + + + + + StringSorter QML Type | SortFilterProxyModel + + + + +

StringSorter QML Type

+ + +

Sorts rows based on a source model string role. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

RoleSorter

+
+ +

Properties

+ + + +

Detailed Description

+

StringSorter is a specialized RoleSorter that sorts rows based on a source model string role. StringSorter compares strings according to a localized collation algorithm.

+

In the following example, rows with be sorted by their lastName role :

+
SortFilterProxyModel {
+   sourceModel: contactModel
+   sorters: StringSorter { roleName: "lastName" }
+}
+ +

Property Documentation

+ +
+
+ + +

+caseSensitivity : Qt.CaseSensitivity

+

This property holds the case sensitivity of the sorter.

+
+
+ +
+
+ + +

+ignorePunctation : bool

+

This property holds whether the sorter ignores punctation. if ignorePunctuation is true, punctuation characters and symbols are ignored when determining sort order.

+

Note: This property is not currently supported on Apple platforms or if Qt is configured to not use ICU on Linux.

+
+ +
+
+ + +

+locale : Locale

+

This property holds the locale of the sorter.

+
+
+ +
+
+ + +

+numericMode : bool

+

This property holds whether the numeric mode of the sorter is enabled. This will enable proper sorting of numeric digits, so that e.g. 100 sorts after 99. By default this mode is off.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-switchrole-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-switchrole-members.html new file mode 100644 index 00000000..755a2ea7 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-switchrole-members.html @@ -0,0 +1,22 @@ + + + + + + + List of All Members for SwitchRole | SortFilterProxyModel + + + + +

List of All Members for SwitchRole

+

This is the complete list of members for SwitchRole, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-switchrole.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-switchrole.html new file mode 100644 index 00000000..dc72484a --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-switchrole.html @@ -0,0 +1,117 @@ + + + + + + + SwitchRole QML Type | SortFilterProxyModel + + + + +

SwitchRole QML Type

+ + +

A role using Filter to conditionnaly compute its data. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

SingleRole

+
+ +

Properties

+ + +

Attached Properties

+ + + +

Detailed Description

+

A SwitchRole is a ProxyRole that computes its data with the help of Filter. Each top level filters specified in the SwitchRole is evaluated on the rows of the model, if a Filter evaluates to true, the data of the SwitchRole for this row will be the one of the attached SwitchRole.value property. If no top level filters evaluate to true, the data will default to the one of the defaultRoleName (or the defaultValue if no defaultRoleName is specified).

+

In the following example, the favoriteOrFirstNameSection role is equal to * if the favorite role of a row is true, otherwise it's the same as the firstName role :

+
SortFilterProxyModel {
+   sourceModel: contactModel
+   proxyRoles: SwitchRole {
+       name: "favoriteOrFirstNameSection"
+       filters: ValueFilter {
+           roleName: "favorite"
+           value: true
+           SwitchRole.value: "*"
+       }
+       defaultRoleName: "firstName"
+    }
+}
+

See also FilterContainer.

+ +

Property Documentation

+ +
+
+ + +

+defaultRoleName : string

+

This property holds the default role name of the role. If no filter match a row, the data of this role will be the data of the role whose name is defaultRoleName.

+
+
+ +
+
+ + +

+defaultValue : var

+

This property holds the default value of the role. If no filter match a row, and no defaultRoleName is set, the data of this role will be defaultValue.

+
+
+ +
+
+ + +

+[default] filters : list<Filter>

+

This property holds the list of filters for this proxy role. The data of this role will be equal to the attached SwitchRole.value property of the first filter that matches the model row.

+

See also Filter and FilterContainer.

+
+
+ +
+
+ + +

+name : string

+

This property holds the role name of the proxy role.

+
+
+

Attached Property Documentation

+ +
+
+ + +

+SwitchRole.value : var

+

This property attaches a value to a Filter.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-valuefilter-members.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-valuefilter-members.html new file mode 100644 index 00000000..5c2d43e3 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-valuefilter-members.html @@ -0,0 +1,21 @@ + + + + + + + List of All Members for ValueFilter | SortFilterProxyModel + + + + +

List of All Members for ValueFilter

+

This is the complete list of members for ValueFilter, including inherited members.

+ + + diff --git a/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-valuefilter.html b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-valuefilter.html new file mode 100644 index 00000000..5681bd64 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/qml-sortfilterproxymodel-valuefilter.html @@ -0,0 +1,100 @@ + + + + + + + ValueFilter QML Type | SortFilterProxyModel + + + + +

ValueFilter QML Type

+ + +

Filters rows matching exactly a value. More...

+ +
+
Import Statement: import SortFilterProxyModel .
Inherits:

RoleFilter

+
+ +

Properties

+ + + +

Detailed Description

+

A ValueFilter is a simple RoleFilter that accepts rows matching exactly the filter's value

+

In the following example, only rows with their favorite role set to true will be accepted when the checkbox is checked :

+
CheckBox {
+   id: showOnlyFavoriteCheckBox
+}
+
+SortFilterProxyModel {
+   sourceModel: contactModel
+   filters: ValueFilter {
+       roleName: "favorite"
+       value: true
+       enabled: showOnlyFavoriteCheckBox.checked
+   }
+}
+ +

Property Documentation

+ +
+
+ + +

+enabled : bool

+

This property holds whether the filter is enabled. A disabled filter will accept every rows unconditionally (even if it's inverted).

+

By default, filters are enabled.

+
+
+ +
+
+ + +

+inverted : bool

+

This property holds whether the filter is inverted. When a filter is inverted, a row normally accepted would be rejected, and vice-versa.

+

By default, filters are not inverted.

+
+
+ +
+
+ + +

+roleName : string

+

This property holds the role name that the filter is using to query the source model's data when filtering items.

+
+
+ +
+
+ + +

+value : variant

+

This property holds the value used to filter the contents of the source model.

+
+
+ + diff --git a/client/3rd/SortFilterProxyModel/docs/sortfilterproxymodel-qmlmodule.html b/client/3rd/SortFilterProxyModel/docs/sortfilterproxymodel-qmlmodule.html new file mode 100644 index 00000000..d0709b56 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/sortfilterproxymodel-qmlmodule.html @@ -0,0 +1,44 @@ + + + + + + + SortFilterProxyModel + + + + + + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +

AllOf

Filter container accepting rows accepted by all its child filters

AnyOf

Filter container accepting rows accepted by at least one of its child filters

ExpressionFilter

Filters row with a custom filtering

ExpressionRole

A custom role computed from a javascript expression

ExpressionSorter

Sorts row with a custom javascript expression

Filter

Base type for the SortFilterProxyModel filters

FilterContainer

Abstract interface for types containing Filters

FilterRole

A role resolving to true for rows matching all its filters

FilterSorter

Sorts rows based on if they match filters

IndexFilter

Filters rows based on their source index

JoinRole

Role made from concatenating other roles

ProxyRole

Base type for the SortFilterProxyModel proxy roles

RangeFilter

Filters rows between boundary values

RegExpFilter

Filters rows matching a regular expression

RegExpRole

A ProxyRole extracting data from a source role via a regular expression

RoleFilter

Base type for filters based on a source model role

RoleSorter

Sorts rows based on a source model role

SingleRole

Base type for the SortFilterProxyModel proxy roles defining a single role

SortFilterProxyModel

Filters and sorts data coming from a source QAbstractItemModel

Sorter

Base type for the SortFilterProxyModel sorters

SorterContainer

Abstract interface for types containing Sorters

StringSorter

Sorts rows based on a source model string role

SwitchRole

A role using Filter to conditionnaly compute its data

ValueFilter

Filters rows matching exactly a value

+ + diff --git a/client/3rd/SortFilterProxyModel/docs/sortfilterproxymodel.index b/client/3rd/SortFilterProxyModel/docs/sortfilterproxymodel.index new file mode 100644 index 00000000..b80adc99 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/sortfilterproxymodel.index @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/3rd/SortFilterProxyModel/docs/style/offline.css b/client/3rd/SortFilterProxyModel/docs/style/offline.css new file mode 100644 index 00000000..13c94270 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/docs/style/offline.css @@ -0,0 +1,805 @@ +body { + font: normal 400 14px/1.2 Arial; + margin-top: 85px; + font-family: Arial, Helvetica; + text-align: left; + margin-left: 5px; + margin-right: 5px; + background-color: #fff; +} + +p { + line-height: 20px +} + +img { + margin-left: 0px; + max-width: 800px; + height: auto; +} + +.content .border img { + box-shadow:3px 3px 8px 3px rgba(200,200,200,0.5) +} + +.content .border .player { + box-shadow:3px 3px 8px 3px rgba(200,200,200,0.5) +} + +.content .indexboxcont li { + font: normal bold 13px/1 Verdana + } + +.content .normallist li { + font: normal 13px/1 Verdana + } + +.descr { + margin-top: 35px; + margin-bottom: 45px; + margin-left: 5px; + text-align: left; + vertical-align: top; +} + +.name { + max-width: 75%; + font-weight: 100; +} + +tt { + text-align: left +} + +/* +----------- +links +----------- +*/ + +a:link { + color: #007330; + text-decoration: none; + text-align: left; +} + +a.qa-mark:target:before { + content: "***"; + color: #ff0000; +} + +a:hover { + color: #44a51c; + text-align: left; +} + +a:visited { + color: #007330; + text-align: left; +} + +a:visited:hover { + color: #44a51c; + text-align: left; +} + +/* +----------- +offline viewing: HTML links display an icon +----------- +*/ + +a[href*="http://"], a[href*="ftp://"], a[href*="https://"] { + text-decoration: none; + background-image: url(../images/ico_out.png); + background-repeat: no-repeat; + background-position: left; + padding-left: 20px; + text-align: left; +} + +.flags { + text-decoration: none; + text-height: 24px; +} + +.flags:target { + background-color: #FFFFD6; +} + +/* +------------------------------- +NOTE styles +------------------------------- +*/ + +.notetitle, .tiptitle, .fastpathtitle { + font-weight: bold +} + +.attentiontitle, .cautiontitle, .dangertitle, .importanttitle, .remembertitle, .restrictiontitle { + font-weight: bold +} + +.note, .tip, .fastpath { + background: #F2F2F2 url(../images/ico_note.png); + background-repeat: no-repeat; + background-position: top left; + padding: 5px; + padding-left: 40px; + padding-bottom: 10px; + border: #999 1px dotted; + color: #666666; + margin: 5px; +} + +.attention, .caution, .danger, .important, .remember, .restriction { + background: #F2F2F2 url(../images/ico_note_attention.png); + background-repeat: no-repeat; + background-position: top left; + padding: 5px; + padding-left: 40px; + padding-bottom: 10px; + border: #999 1px dotted; + color: #666666; + margin: 5px; +} + +/* +------------------------------- +Top navigation +------------------------------- +*/ + +.qtref { + display: block; + position: relative; + height: 15px; + z-index: 1; + font-size: 11px; + padding-right: 10px; + float: right; +} + +.naviNextPrevious { + clear: both; + display: block; + position: relative; + text-align: right; + top: -47px; + float: right; + height: 20px; + z-index: 1; + padding-right: 10px; + padding-top: 2px; + vertical-align: top; + margin: 0px; +} + +.naviNextPrevious > a:first-child { + background-image: url(../images/btn_prev.png); + background-repeat: no-repeat; + background-position: left; + padding-left: 20px; + height: 20px; + padding-left: 20px; + } + +.naviNextPrevious > a:last-child { + background-image: url(../images/btn_next.png); + background-repeat: no-repeat; + background-position: right; + padding-right: 20px; + height: 20px; + margin-left: 30px; + } + +.naviSeparator { display: none } +/* +----------- +footer and license +----------- +*/ + +.footer { + text-align: left; + padding-top: 45px; + padding-left: 5px; + margin-top: 45px; + margin-bottom: 45px; + font-size: 10px; + border-top: 1px solid #999; +} + +.footer p { + line-height: 14px; + font-size: 11px; + padding: 0; + margin: 0; +} + +.footer a[href*="http://"], a[href*="ftp://"], a[href*="https://"] { + font-weight: bold; +} + +.footerNavi { + width: auto; + text-align: right; + margin-top: 50px; + z-index: 1; +} + +.navigationbar { + display: block; + position: relative; + top: -20px; + border-top: 1px solid #cecece; + border-bottom: 1px solid #cecece; + background-color: #F2F2F2; + z-index: 1; + height: 20px; + padding-left: 7px; + margin: 0px; + padding-top: 2px; + margin-left: -5px; + margin-right: -5px; +} + +.navigationbar .first { + background: url(../images/home.png); + background-position: left; + background-repeat: no-repeat; + padding-left: 20px; + } + +.navigationbar ul { + margin: 0px; + padding: 0px; + } + + .navigationbar ul li { + list-style-type: none; + padding-top: 2px; + padding-left: 4px; + margin: 0; + height: 20px; + } + +.navigationbar li { + float: left + } + + .navigationbar li a, .navigationbar td a { + display: block; + text-decoration: none; + background: url(../images/arrow_bc.png); + background-repeat: no-repeat; + background-position: right; + padding-right: 17px; + } + +table.buildversion { + float: right; + margin-top: -18px !important; +} + +.navigationbar table { + border-radius: 0; + border: 0 none; + background-color: #F2F2F2; + margin: 0; +} + +.navigationbar table td { + padding: 0; + border: 0 none; +} + +#buildversion { + font-style: italic; + font-size: small; + float: right; + margin-right: 5px; +} + +/* + +/* table of content +no display +*/ + +/* +----------- +headers +----------- +*/ + +@media screen { + .title { + color: #313131; + font-size: 24px; + font-weight: normal; + left: 0; + padding-bottom: 20px; + padding-left: 10px; + padding-top: 20px; + position: absolute; + right: 0; + top: 0; + background-color: #E6E6E6; + border-bottom: 1px #CCC solid; + border-top: 2px #CCC solid; + font-weight: bold; + margin-left: 0px; + margin-right: 0px; + } + .subtitle, .small-subtitle { + display: block; + clear: left; + } +} + +h1 { + margin: 0 +} + +h2, p.h2 { + font: 500 16px/1.2 Arial; + font-weight: 100; + background-color: #F2F3F4; + padding: 4px; + margin-bottom: 30px; + margin-top: 30px; + border-top: #E0E0DE 1px solid; + border-bottom: #E0E0DE 1px solid; + max-width: 99%; +} + +h2:target { + background-color: #F2F3D4; +} + +h3 { + font: 500 14px/1.2 Arial; + font-weight: 100; + text-decoration: underline; + margin-bottom: 30px; + margin-top: 30px; +} + +h3.fn, span.fn { + border-width: 1px; + border-style: solid; + border-color: #E6E6E6; + -moz-border-radius: 7px 7px 7px 7px; + -webkit-border-radius: 7px 7px 7px 7px; + border-radius: 7px 7px 7px 7px; + background-color: #F6F6F6; + word-spacing: 3px; + padding: 5px 5px; + text-decoration: none; + font-weight: bold; + max-width: 75%; + font-size: 14px; + margin: 0px; + margin-top: 45px; +} +.fngroup h3.fngroupitem { + margin-bottom: 5px; +} +h3.fn code { + float: right; +} +h3.fn:target { + background-color: #F6F6D6; +} + +.name { + color: #1A1A1A +} + +.type { + color: #808080 +} + +@media print { + .title { + color: #0066CB; + font-family: Arial, Helvetica; + font-size: 32px; + font-weight: normal; + left: 0; + position: absolute; + right: 0; + top: 0; + } +} + +/* +----------------- +table styles +----------------- +*/ + +.table img { + border: none; + margin-left: 0px; + -moz-box-shadow: 0px 0px 0px #fff; + -webkit-box-shadow: 0px 0px 0px #fff; + box-shadow: 0px 0px 0px #fff; +} + +/* table with border alternative colours*/ + +table, pre, .LegaleseLeft { + -moz-border-radius: 7px 7px 7px 7px; + -webkit-border-radius: 7px 7px 7px 7px; + border-radius: 7px 7px 7px 7px; + background-color: #F6F6F6; + border: 1px solid #E6E6E6; + border-collapse: separate; + margin-bottom: 25px; + margin-left: 15px; + font-size: 12px; + line-height: 1.2; +} + + table tr.even { + background-color: white; + color: #66666E; + } + + table tr.odd { + background-color: #F6F6F6; + color: #66666E; + } + + table tr:target { + background-color: #F6F6D6; + } + + table thead { + text-align: left; + padding-left: 20px; + background-color: #e1e0e0; + border-left: none; + border-right: none; + } + + table thead th { + padding-top: 5px; + padding-left: 10px; + padding-bottom: 5px; + border-bottom: 2px solid #D1D1D1; + padding-right: 10px; + } + + table th { + text-align: left; + padding-left: 20px; + } + + table td { + padding: 3px 15px 3px 20px; + border-bottom: #CCC dotted 1px; + } + + table p { + margin: 0px + } + +.LegaleseLeft { + font-family: monospace; + white-space: pre-wrap; +} +/* table bodless & white*/ + +.borderless { + border-radius: 0px 0px 0px 0px; + background-color: #fff; + border: 1px solid #fff; +} + +.borderless tr { + background-color: #FFF; + color: #66666E; + } + +.borderless td { + border: none; + border-bottom: #fff dotted 1px; + } + +/* +----------- +List +----------- +*/ + +ul { + margin-top: 10px; +} + +li { + margin-bottom: 10px; + padding-left: 8px; + list-style: outside; + text-align: left; +} + + ul > li { + list-style-type: square; + } + +ol { + margin: 10px; + padding: 0; +} + +ol.A > li { + list-style-type: upper-alpha; +} + +ol.a > li{ + list-style-type: lower-alpha; +} + + ol > li { + margin-left: 30px; + padding-left: 8px; + list-style: decimal; + } + +.centerAlign { + text-align: left +} + +.cpp, .LegaleseLeft { + display: block; + margin: 10px; + overflow: auto; + padding: 20px 20px 20px 20px; +} + +.js { + display: block; + margin: 10px; + overflow: auto; + padding: 20px 20px 20px 20px; +} + +.memItemLeft { + padding-right: 3px +} + +.memItemRight { + padding: 3px 15px 3px 0 +} + +.qml { + display: block; + margin: 10px; + overflow: auto; + padding: 20px 20px 20px 20px; +} + +.qmldefault { + padding-left: 5px; + float: right; + color: red; +} + +.qmlreadonly { + padding-left: 5px; + float: right; + color: #254117; +} + +.rightAlign { + padding: 3px 5px 3px 10px; + text-align: right; +} + +.qmldoc { + margin-left: 15px +} + +.flowList { + padding: 25px +} +.flowList dd { + display: inline-block; + margin-left: 10px; + width: 255px; + line-height: 1.15em; + overflow-x: hidden; + text-overflow: ellipsis +} +.alphaChar { + font-size: 2em; + position: relative +} +/* +----------- +Content table +----------- +*/ + +@media print { + .toc { + float: right; + clear: right; + padding-bottom: 10px; + padding-top: 50px; + width: 100%; + background-image: url(../images/bgrContent.png); + background-position: top; + background-repeat: no-repeat; + } +} + +@media screen { + .toc { + float: right; + clear: right; + vertical-align: top; + -moz-border-radius: 7px 7px 7px 7px; + -webkit-border-radius: 7px 7px 7px 7px; + border-radius: 7px 7px 7px 7px; + background: #FFF url('../images/bgrContent.png'); + background-position: top; + background-repeat: repeat-x; + border: 1px solid #E6E6E6; + padding-left: 5px; + padding-bottom: 10px; + height: auto; + width: 200px; + text-align: left; + margin-left: 20px; + } +} + + +.toc h3 { + text-decoration: none +} + +.toc h3 { + font: 500 14px/1.2 Arial; + font-weight: 100; + padding: 0px; + margin: 0px; + padding-top: 5px; + padding-left: 5px; +} + +.toc ul { + padding-left: 10px; + padding-right: 5px; +} + +.toc ul li { + margin-left: 15px; + list-style-image: url(../images/bullet_dn.png); + marker-offset: 0px; + margin-bottom: 8px; + padding-left: 0px; + } + +.toc .level1 { + border: none +} + +.toc .level2 { + border: none; + margin-left: 25px; +} + +.level3 { + border: none; + margin-left: 30px; +} + +.clearfix { + clear: both +} + +/* +----------- +Landing page +----------- +*/ + +.col-group { + white-space: nowrap; + vertical-align: top; +} + + +.landing h2 { + background-color: transparent; + border: none; + margin-bottom: 0px; + font-size: 18px; +} + +.landing a, .landing li { + font-size: 13px; + font-weight: bold !important; +} + +.col-1 { + display: inline-block; + white-space: normal; + width: 70%; + height: 100%; + float: left; +} + +.col-2 { + display: inline-block; + white-space: normal; + width: 20%; + margin-left: 5%; + position: relative; + top: -20px; +} + +.col-1 h1 { + margin: 20px 0 0 0; + } + +.col-1 h2 { + font-size: 18px; + font-weight: bold !important; +} + +.landingicons { + display: inline-block; + width: 100%; +} + +.icons1of3 { + display: inline-block; + width: 33.3333%; + float: left; +} + +.icons1of3 h2, .doc-column h2 { + font-size: 15px; + margin: 0px; + padding: 0px; +} + +div.multi-column { + position: relative; +} + +div.multi-column div { + display: -moz-inline-box; + display: inline-block; + vertical-align: top; + margin-top: 1em; + margin-right: 4em; + width: 24em; +} + +.mainContent .video { + width:40%; + max-width:640px; + margin: 15px 0 0 15px; + position:relative; + display:table +} + +.mainContent .video > .vspan { + padding-top:60%; + display:block +} +.mainContent .video iframe { + width:100%; + height:100%; + position:absolute; + top:0; + left:0 +} diff --git a/client/3rd/SortFilterProxyModel/filters/filtercontainer.cpp b/client/3rd/SortFilterProxyModel/filters/filtercontainer.cpp index 5bba02d9..ad955e14 100644 --- a/client/3rd/SortFilterProxyModel/filters/filtercontainer.cpp +++ b/client/3rd/SortFilterProxyModel/filters/filtercontainer.cpp @@ -56,13 +56,13 @@ void FilterContainer::append_filter(QQmlListProperty* list, Filter* filt that->appendFilter(filter); } -int FilterContainer::count_filter(QQmlListProperty* list) +qsizetype FilterContainer::count_filter(QQmlListProperty* list) { QList* filters = static_cast*>(list->data); return filters->count(); } -Filter* FilterContainer::at_filter(QQmlListProperty* list, int index) +Filter* FilterContainer::at_filter(QQmlListProperty* list, qsizetype index) { QList* filters = static_cast*>(list->data); return filters->at(index); diff --git a/client/3rd/SortFilterProxyModel/filters/filtercontainer.h b/client/3rd/SortFilterProxyModel/filters/filtercontainer.h index 4fc06f37..9adf41fa 100644 --- a/client/3rd/SortFilterProxyModel/filters/filtercontainer.h +++ b/client/3rd/SortFilterProxyModel/filters/filtercontainer.h @@ -31,8 +31,8 @@ private: virtual void onFiltersCleared() = 0; static void append_filter(QQmlListProperty* list, Filter* filter); - static int count_filter(QQmlListProperty* list); - static Filter* at_filter(QQmlListProperty* list, int index); + static qsizetype count_filter(QQmlListProperty* list); + static Filter* at_filter(QQmlListProperty* list, qsizetype index); static void clear_filters(QQmlListProperty* list); }; diff --git a/client/3rd/SortFilterProxyModel/filters/rangefilter.cpp b/client/3rd/SortFilterProxyModel/filters/rangefilter.cpp index 2a6fde2c..b36adba6 100644 --- a/client/3rd/SortFilterProxyModel/filters/rangefilter.cpp +++ b/client/3rd/SortFilterProxyModel/filters/rangefilter.cpp @@ -1,4 +1,5 @@ #include "rangefilter.h" +#include "../utils/utils.h" namespace qqsfpm { @@ -128,7 +129,7 @@ void RangeFilter::setMaximumInclusive(bool maximumInclusive) bool RangeFilter::filterRow(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const { - QVariant value = sourceData(sourceIndex, proxyModel); + const QVariant value = sourceData(sourceIndex, proxyModel); bool lessThanMin = m_minimumValue.isValid() && (m_minimumInclusive ? value < m_minimumValue : value <= m_minimumValue); bool moreThanMax = m_maximumValue.isValid() && diff --git a/client/3rd/SortFilterProxyModel/filters/regexpfilter.cpp b/client/3rd/SortFilterProxyModel/filters/regexpfilter.cpp index f308765e..7c6b6f02 100644 --- a/client/3rd/SortFilterProxyModel/filters/regexpfilter.cpp +++ b/client/3rd/SortFilterProxyModel/filters/regexpfilter.cpp @@ -35,6 +35,12 @@ namespace qqsfpm { \sa syntax */ +RegExpFilter::RegExpFilter() : + m_caseSensitivity(m_regExp.patternOptions().testFlag( + QRegularExpression::CaseInsensitiveOption) ? Qt::CaseInsensitive : Qt::CaseSensitive) +{ +} + QString RegExpFilter::pattern() const { return m_pattern; @@ -51,38 +57,6 @@ void RegExpFilter::setPattern(const QString& pattern) invalidate(); } -/*! - \qmlproperty enum RegExpFilter::syntax - - The pattern used to filter the contents of the source model. - - Only the source model's value having their \l RoleFilter::roleName data matching this \l pattern with the specified \l syntax will be kept. - - \value RegExpFilter.RegExp A rich Perl-like pattern matching syntax. This is the default. - \value RegExpFilter.Wildcard This provides a simple pattern matching syntax similar to that used by shells (command interpreters) for "file globbing". - \value RegExpFilter.FixedString The pattern is a fixed string. This is equivalent to using the RegExp pattern on a string in which all metacharacters are escaped. - \value RegExpFilter.RegExp2 Like RegExp, but with greedy quantifiers. - \value RegExpFilter.WildcardUnix This is similar to Wildcard but with the behavior of a Unix shell. The wildcard characters can be escaped with the character "\". - \value RegExpFilter.W3CXmlSchema11 The pattern is a regular expression as defined by the W3C XML Schema 1.1 specification. - - \sa pattern -*/ -RegExpFilter::PatternSyntax RegExpFilter::syntax() const -{ - return m_syntax; -} - -void RegExpFilter::setSyntax(RegExpFilter::PatternSyntax syntax) -{ - if (m_syntax == syntax) - return; - - m_syntax = syntax; - m_regExp.setPatternSyntax(static_cast(syntax)); - Q_EMIT syntaxChanged(); - invalidate(); -} - /*! \qmlproperty Qt::CaseSensitivity RegExpFilter::caseSensitivity @@ -99,15 +73,18 @@ void RegExpFilter::setCaseSensitivity(Qt::CaseSensitivity caseSensitivity) return; m_caseSensitivity = caseSensitivity; - m_regExp.setCaseSensitivity(caseSensitivity); + QRegularExpression::PatternOptions patternOptions = m_regExp.patternOptions(); + if (caseSensitivity == Qt::CaseInsensitive) + patternOptions.setFlag(QRegularExpression::CaseInsensitiveOption); + m_regExp.setPatternOptions(patternOptions); Q_EMIT caseSensitivityChanged(); invalidate(); } bool RegExpFilter::filterRow(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) const { - QString string = sourceData(sourceIndex, proxyModel).toString(); - return m_regExp.indexIn(string) != -1; + const QString string = sourceData(sourceIndex, proxyModel).toString(); + return m_regExp.match(string).hasMatch(); } } diff --git a/client/3rd/SortFilterProxyModel/filters/regexpfilter.h b/client/3rd/SortFilterProxyModel/filters/regexpfilter.h index 2c20a6a8..65945649 100644 --- a/client/3rd/SortFilterProxyModel/filters/regexpfilter.h +++ b/client/3rd/SortFilterProxyModel/filters/regexpfilter.h @@ -3,32 +3,23 @@ #include "rolefilter.h" +#include + namespace qqsfpm { class RegExpFilter : public RoleFilter { Q_OBJECT Q_PROPERTY(QString pattern READ pattern WRITE setPattern NOTIFY patternChanged) - Q_PROPERTY(PatternSyntax syntax READ syntax WRITE setSyntax NOTIFY syntaxChanged) Q_PROPERTY(Qt::CaseSensitivity caseSensitivity READ caseSensitivity WRITE setCaseSensitivity NOTIFY caseSensitivityChanged) public: - enum PatternSyntax { - RegExp = QRegExp::RegExp, - Wildcard = QRegExp::Wildcard, - FixedString = QRegExp::FixedString, - RegExp2 = QRegExp::RegExp2, - WildcardUnix = QRegExp::WildcardUnix, - W3CXmlSchema11 = QRegExp::W3CXmlSchema11 }; - Q_ENUMS(PatternSyntax) - using RoleFilter::RoleFilter; + RegExpFilter(); + QString pattern() const; void setPattern(const QString& pattern); - PatternSyntax syntax() const; - void setSyntax(PatternSyntax syntax); - Qt::CaseSensitivity caseSensitivity() const; void setCaseSensitivity(Qt::CaseSensitivity caseSensitivity); @@ -37,13 +28,11 @@ protected: Q_SIGNALS: void patternChanged(); - void syntaxChanged(); void caseSensitivityChanged(); private: - QRegExp m_regExp; - Qt::CaseSensitivity m_caseSensitivity = m_regExp.caseSensitivity(); - PatternSyntax m_syntax = static_cast(m_regExp.patternSyntax()); + QRegularExpression m_regExp; + Qt::CaseSensitivity m_caseSensitivity; QString m_pattern = m_regExp.pattern(); }; diff --git a/client/3rd/SortFilterProxyModel/proxyroles/proxyrolecontainer.cpp b/client/3rd/SortFilterProxyModel/proxyroles/proxyrolecontainer.cpp index f8ea6652..8418fec7 100644 --- a/client/3rd/SortFilterProxyModel/proxyroles/proxyrolecontainer.cpp +++ b/client/3rd/SortFilterProxyModel/proxyroles/proxyrolecontainer.cpp @@ -43,13 +43,13 @@ void ProxyRoleContainer::append_proxyRole(QQmlListProperty* list, Pro that->appendProxyRole(proxyRole); } -int ProxyRoleContainer::count_proxyRole(QQmlListProperty* list) +qsizetype ProxyRoleContainer::count_proxyRole(QQmlListProperty* list) { QList* ProxyRoles = static_cast*>(list->data); return ProxyRoles->count(); } -ProxyRole* ProxyRoleContainer::at_proxyRole(QQmlListProperty* list, int index) +ProxyRole* ProxyRoleContainer::at_proxyRole(QQmlListProperty* list, qsizetype index) { QList* ProxyRoles = static_cast*>(list->data); return ProxyRoles->at(index); diff --git a/client/3rd/SortFilterProxyModel/proxyroles/proxyrolecontainer.h b/client/3rd/SortFilterProxyModel/proxyroles/proxyrolecontainer.h index bcd932e4..415b8c0b 100644 --- a/client/3rd/SortFilterProxyModel/proxyroles/proxyrolecontainer.h +++ b/client/3rd/SortFilterProxyModel/proxyroles/proxyrolecontainer.h @@ -29,8 +29,8 @@ private: virtual void onProxyRolesCleared() = 0; static void append_proxyRole(QQmlListProperty* list, ProxyRole* proxyRole); - static int count_proxyRole(QQmlListProperty* list); - static ProxyRole* at_proxyRole(QQmlListProperty* list, int index); + static qsizetype count_proxyRole(QQmlListProperty* list); + static ProxyRole* at_proxyRole(QQmlListProperty* list, qsizetype index); static void clear_proxyRoles(QQmlListProperty* list); }; diff --git a/client/3rd/SortFilterProxyModel/qpm.json b/client/3rd/SortFilterProxyModel/qpm.json new file mode 100644 index 00000000..f1b15388 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/qpm.json @@ -0,0 +1,22 @@ +{ + "name": "fr.grecko.sortfilterproxymodel", + "description": "A nicely exposed QSortFilterProxyModel for QML", + "author": { + "name": "Pierre-Yves Siret", + "email": "gr3cko@gmail.com" + }, + "repository": { + "type": "GITHUB", + "url": "https://github.com/oKcerG/SortFilterProxyModel.git" + }, + "version": { + "label": "0.1.0", + "revision": "", + "fingerprint": "" + }, + "dependencies": [ + ], + "license": "MIT", + "pri_filename": "SortFilterProxyModel.pri", + "webpage": "" +} \ No newline at end of file diff --git a/client/3rd/SortFilterProxyModel/qqmlsortfilterproxymodel.cpp b/client/3rd/SortFilterProxyModel/qqmlsortfilterproxymodel.cpp index bd064357..6a3e77cf 100644 --- a/client/3rd/SortFilterProxyModel/qqmlsortfilterproxymodel.cpp +++ b/client/3rd/SortFilterProxyModel/qqmlsortfilterproxymodel.cpp @@ -92,37 +92,20 @@ void QQmlSortFilterProxyModel::setFilterRoleName(const QString& filterRoleName) QString QQmlSortFilterProxyModel::filterPattern() const { - return filterRegExp().pattern(); + return filterRegularExpression().pattern(); } void QQmlSortFilterProxyModel::setFilterPattern(const QString& filterPattern) { - QRegExp regExp = filterRegExp(); + QRegularExpression regExp = filterRegularExpression(); if (regExp.pattern() == filterPattern) return; regExp.setPattern(filterPattern); - QSortFilterProxyModel::setFilterRegExp(regExp); + QSortFilterProxyModel::setFilterRegularExpression(regExp); Q_EMIT filterPatternChanged(); } -QQmlSortFilterProxyModel::PatternSyntax QQmlSortFilterProxyModel::filterPatternSyntax() const -{ - return static_cast(filterRegExp().patternSyntax()); -} - -void QQmlSortFilterProxyModel::setFilterPatternSyntax(QQmlSortFilterProxyModel::PatternSyntax patternSyntax) -{ - QRegExp regExp = filterRegExp(); - QRegExp::PatternSyntax patternSyntaxTmp = static_cast(patternSyntax); - if (regExp.patternSyntax() == patternSyntaxTmp) - return; - - regExp.setPatternSyntax(patternSyntaxTmp); - QSortFilterProxyModel::setFilterRegExp(regExp); - Q_EMIT filterPatternSyntaxChanged(); -} - const QVariant& QQmlSortFilterProxyModel::filterValue() const { return m_filterValue; diff --git a/client/3rd/SortFilterProxyModel/qqmlsortfilterproxymodel.h b/client/3rd/SortFilterProxyModel/qqmlsortfilterproxymodel.h index dbe0229b..bf4f32e0 100644 --- a/client/3rd/SortFilterProxyModel/qqmlsortfilterproxymodel.h +++ b/client/3rd/SortFilterProxyModel/qqmlsortfilterproxymodel.h @@ -26,7 +26,6 @@ class QQmlSortFilterProxyModel : public QSortFilterProxyModel, Q_PROPERTY(QString filterRoleName READ filterRoleName WRITE setFilterRoleName NOTIFY filterRoleNameChanged) Q_PROPERTY(QString filterPattern READ filterPattern WRITE setFilterPattern NOTIFY filterPatternChanged) - Q_PROPERTY(PatternSyntax filterPatternSyntax READ filterPatternSyntax WRITE setFilterPatternSyntax NOTIFY filterPatternSyntaxChanged) Q_PROPERTY(QVariant filterValue READ filterValue WRITE setFilterValue NOTIFY filterValueChanged) Q_PROPERTY(QString sortRoleName READ sortRoleName WRITE setSortRoleName NOTIFY sortRoleNameChanged) @@ -37,15 +36,6 @@ class QQmlSortFilterProxyModel : public QSortFilterProxyModel, Q_PROPERTY(QQmlListProperty proxyRoles READ proxyRolesListProperty) public: - enum PatternSyntax { - RegExp = QRegExp::RegExp, - Wildcard = QRegExp::Wildcard, - FixedString = QRegExp::FixedString, - RegExp2 = QRegExp::RegExp2, - WildcardUnix = QRegExp::WildcardUnix, - W3CXmlSchema11 = QRegExp::W3CXmlSchema11 }; - Q_ENUMS(PatternSyntax) - QQmlSortFilterProxyModel(QObject* parent = 0); int count() const; @@ -59,9 +49,6 @@ public: QString filterPattern() const; void setFilterPattern(const QString& filterPattern); - PatternSyntax filterPatternSyntax() const; - void setFilterPatternSyntax(PatternSyntax patternSyntax); - const QVariant& filterValue() const; void setFilterValue(const QVariant& filterValue); @@ -97,7 +84,6 @@ Q_SIGNALS: void delayedChanged(); void filterRoleNameChanged(); - void filterPatternSyntaxChanged(); void filterPatternChanged(); void filterValueChanged(); @@ -109,7 +95,7 @@ protected: bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const override; protected Q_SLOTS: - void resetInternalData(); + void resetInternalData() override; private Q_SLOTS: void queueInvalidateFilter(); diff --git a/client/3rd/SortFilterProxyModel/sorters/rolesorter.cpp b/client/3rd/SortFilterProxyModel/sorters/rolesorter.cpp index db2d4464..d98e9b14 100644 --- a/client/3rd/SortFilterProxyModel/sorters/rolesorter.cpp +++ b/client/3rd/SortFilterProxyModel/sorters/rolesorter.cpp @@ -1,5 +1,6 @@ #include "rolesorter.h" #include "qqmlsortfilterproxymodel.h" +#include "../utils/utils.h" namespace qqsfpm { @@ -56,14 +57,8 @@ QPair RoleSorter::sourceData(const QModelIndex &sourceLeft, int RoleSorter::compare(const QModelIndex &sourceLeft, const QModelIndex& sourceRight, const QQmlSortFilterProxyModel& proxyModel) const { - QPair pair = sourceData(sourceLeft, sourceRight, proxyModel); - QVariant leftValue = pair.first; - QVariant rightValue = pair.second; - if (leftValue < rightValue) - return -1; - if (leftValue > rightValue) - return 1; - return 0; + const QPair pair = sourceData(sourceLeft, sourceRight, proxyModel); + return compareVariants(pair.first, pair.second); } } diff --git a/client/3rd/SortFilterProxyModel/sorters/sortercontainer.cpp b/client/3rd/SortFilterProxyModel/sorters/sortercontainer.cpp index f986e371..5255e294 100644 --- a/client/3rd/SortFilterProxyModel/sorters/sortercontainer.cpp +++ b/client/3rd/SortFilterProxyModel/sorters/sortercontainer.cpp @@ -56,13 +56,13 @@ void SorterContainer::append_sorter(QQmlListProperty* list, Sorter* sort that->appendSorter(sorter); } -int SorterContainer::count_sorter(QQmlListProperty* list) +qsizetype SorterContainer::count_sorter(QQmlListProperty* list) { QList* sorters = static_cast*>(list->data); return sorters->count(); } -Sorter* SorterContainer::at_sorter(QQmlListProperty* list, int index) +Sorter* SorterContainer::at_sorter(QQmlListProperty* list, qsizetype index) { QList* sorters = static_cast*>(list->data); return sorters->at(index); diff --git a/client/3rd/SortFilterProxyModel/sorters/sortercontainer.h b/client/3rd/SortFilterProxyModel/sorters/sortercontainer.h index 016cc6db..c60a067c 100644 --- a/client/3rd/SortFilterProxyModel/sorters/sortercontainer.h +++ b/client/3rd/SortFilterProxyModel/sorters/sortercontainer.h @@ -31,8 +31,8 @@ private: virtual void onSortersCleared() = 0; static void append_sorter(QQmlListProperty* list, Sorter* sorter); - static int count_sorter(QQmlListProperty* list); - static Sorter* at_sorter(QQmlListProperty* list, int index); + static qsizetype count_sorter(QQmlListProperty* list); + static Sorter* at_sorter(QQmlListProperty* list, qsizetype index); static void clear_sorters(QQmlListProperty* list); }; diff --git a/client/3rd/SortFilterProxyModel/tests/BLACKLIST b/client/3rd/SortFilterProxyModel/tests/BLACKLIST new file mode 100644 index 00000000..f881ba04 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/BLACKLIST @@ -0,0 +1,2 @@ +[StringSorterTests::test_stringSorters:doNotIgnorePunctuation] +macos diff --git a/client/3rd/SortFilterProxyModel/tests/SortFilterProxyModel.pro b/client/3rd/SortFilterProxyModel/tests/SortFilterProxyModel.pro new file mode 100644 index 00000000..69fd5834 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/SortFilterProxyModel.pro @@ -0,0 +1,36 @@ +TEMPLATE = app +TARGET = tst_sortfilterproxymodel +QT += qml quick +CONFIG += c++11 warn_on qmltestcase qml_debug no_keywords + +include(../SortFilterProxyModel.pri) + +HEADERS += \ + indexsorter.h \ + testroles.h + +SOURCES += \ + tst_sortfilterproxymodel.cpp \ + indexsorter.cpp \ + testroles.cpp + +OTHER_FILES += \ + tst_rangefilter.qml \ + tst_indexfilter.qml \ + tst_sourceroles.qml \ + tst_sorters.qml \ + tst_helpers.qml \ + tst_builtins.qml \ + tst_rolesorter.qml \ + tst_stringsorter.qml \ + tst_proxyroles.qml \ + tst_joinrole.qml \ + tst_switchrole.qml \ + tst_expressionrole.qml \ + tst_filtercontainerattached.qml \ + tst_filtercontainers.qml \ + tst_regexprole.qml \ + tst_filtersorter.qml \ + tst_filterrole.qml \ + tst_delayed.qml \ + tst_sortercontainerattached.qml diff --git a/client/3rd/SortFilterProxyModel/tests/indexsorter.cpp b/client/3rd/SortFilterProxyModel/tests/indexsorter.cpp new file mode 100644 index 00000000..38c295c2 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/indexsorter.cpp @@ -0,0 +1,21 @@ +#include "indexsorter.h" +#include + +int IndexSorter::compare(const QModelIndex &sourceLeft, const QModelIndex &sourceRight, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) const +{ + Q_UNUSED(proxyModel) + return sourceLeft.row() - sourceRight.row(); +} + +int ReverseIndexSorter::compare(const QModelIndex &sourceLeft, const QModelIndex &sourceRight, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) const +{ + Q_UNUSED(proxyModel) + return sourceRight.row() - sourceLeft.row(); +} + +void registerIndexSorterTypes() { + qmlRegisterType("SortFilterProxyModel.Test", 0, 2, "IndexSorter"); + qmlRegisterType("SortFilterProxyModel.Test", 0, 2, "ReverseIndexSorter"); +} + +Q_COREAPP_STARTUP_FUNCTION(registerIndexSorterTypes) diff --git a/client/3rd/SortFilterProxyModel/tests/indexsorter.h b/client/3rd/SortFilterProxyModel/tests/indexsorter.h new file mode 100644 index 00000000..2169df29 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/indexsorter.h @@ -0,0 +1,20 @@ +#ifndef INDEXSORTER_H +#define INDEXSORTER_H + +#include "sorters/sorter.h" + +class IndexSorter : public qqsfpm::Sorter +{ +public: + using qqsfpm::Sorter::Sorter; + int compare(const QModelIndex& sourceLeft, const QModelIndex& sourceRight, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) const override; +}; + +class ReverseIndexSorter : public qqsfpm::Sorter +{ +public: + using qqsfpm::Sorter::Sorter; + int compare(const QModelIndex& sourceLeft, const QModelIndex& sourceRight, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) const override; +}; + +#endif // INDEXSORTER_H diff --git a/client/3rd/SortFilterProxyModel/tests/testroles.cpp b/client/3rd/SortFilterProxyModel/tests/testroles.cpp new file mode 100644 index 00000000..18c0c2c8 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/testroles.cpp @@ -0,0 +1,48 @@ +#include "testroles.h" +#include + +QVariant StaticRole::value() const +{ + return m_value; +} + +void StaticRole::setValue(const QVariant& value) +{ + if (m_value == value) + return; + + m_value = value; + Q_EMIT valueChanged(); + invalidate(); +} + +QVariant StaticRole::data(const QModelIndex& sourceIndex, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) +{ + Q_UNUSED(sourceIndex) + Q_UNUSED(proxyModel) + return m_value; +} + +QVariant SourceIndexRole::data(const QModelIndex& sourceIndex, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) +{ + Q_UNUSED(proxyModel) + return sourceIndex.row(); +} + +QStringList MultiRole::names() +{ + return {"role1", "role2"}; +} + +QVariant MultiRole::data(const QModelIndex&, const qqsfpm::QQmlSortFilterProxyModel&, const QString& name) +{ + return "data for " + name; +} + +void registerTestRolesTypes() { + qmlRegisterType("SortFilterProxyModel.Test", 0, 2, "StaticRole"); + qmlRegisterType("SortFilterProxyModel.Test", 0, 2, "SourceIndexRole"); + qmlRegisterType("SortFilterProxyModel.Test", 0, 2, "MultiRole"); +} + +Q_COREAPP_STARTUP_FUNCTION(registerTestRolesTypes) diff --git a/client/3rd/SortFilterProxyModel/tests/testroles.h b/client/3rd/SortFilterProxyModel/tests/testroles.h new file mode 100644 index 00000000..4fec59a1 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/testroles.h @@ -0,0 +1,47 @@ +#ifndef TESTROLES_H +#define TESTROLES_H + +#include "proxyroles/singlerole.h" +#include + +class StaticRole : public qqsfpm::SingleRole +{ + Q_OBJECT + Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) +public: + using qqsfpm::SingleRole::SingleRole; + + QVariant value() const; + void setValue(const QVariant& value); + +Q_SIGNALS: + void valueChanged(); + +protected: + +private: + QVariant data(const QModelIndex& sourceIndex, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) override; + QVariant m_value; +}; + +class SourceIndexRole : public qqsfpm::SingleRole +{ +public: + using qqsfpm::SingleRole::SingleRole; + +private: + QVariant data(const QModelIndex& sourceIndex, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) override; +}; + +class MultiRole : public qqsfpm::ProxyRole +{ +public: + using qqsfpm::ProxyRole::ProxyRole; + + QStringList names() override; + +private: + QVariant data(const QModelIndex &sourceIndex, const qqsfpm::QQmlSortFilterProxyModel &proxyModel, const QString &name) override; +}; + +#endif // TESTROLES_H diff --git a/client/3rd/SortFilterProxyModel/tests/tst_builtins.qml b/client/3rd/SortFilterProxyModel/tests/tst_builtins.qml new file mode 100644 index 00000000..855e33f3 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_builtins.qml @@ -0,0 +1,54 @@ +import QtQuick 2.0 +import QtQml 2.2 +import QtTest 1.1 +import SortFilterProxyModel 0.2 + +Item { + ListModel { + id: testModel + ListElement{role1: 1; role2: 1} + ListElement{role1: 2; role2: 1} + ListElement{role1: 3; role2: 2} + ListElement{role1: 4; role2: 2} + } + ListModel { + id: noRolesFirstTestModel + function initModel() { + noRolesFirstTestModel.append({role1: 1, role2: 1 }) + noRolesFirstTestModel.append({role1: 2, role2: 1 }) + noRolesFirstTestModel.append({role1: 3, role2: 2 }) + noRolesFirstTestModel.append({role1: 4, role2: 2 }) + } + } + SortFilterProxyModel { + id: testProxyModel + property string tag: "testProxyModel" + sourceModel: testModel + filterRoleName: "role2" + filterValue: 2 + property var expectedData: ([{role1: 3, role2: 2}, {role1: 4, role2: 2}]) + } + SortFilterProxyModel { + id: noRolesFirstTestProxyModel + property string tag: "noRolesFirstTestProxyModel" + sourceModel: noRolesFirstTestModel + filterRoleName: "role2" + filterValue: 2 + property var expectedData: ([{role1: 3, role2: 2}, {role1: 4, role2: 2}]) + } + TestCase { + name: "BuiltinsFilterTests" + function test_filterValue_data() { + return [testProxyModel, noRolesFirstTestProxyModel]; + } + + function test_filterValue(proxyModel) { + if (proxyModel.sourceModel.initModel) + proxyModel.sourceModel.initModel() + var data = []; + for (var i = 0; i < proxyModel.count; i++) + data.push(proxyModel.get(i)); + compare(data, proxyModel.expectedData); + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_delayed.qml b/client/3rd/SortFilterProxyModel/tests/tst_delayed.qml new file mode 100644 index 00000000..0264ce7d --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_delayed.qml @@ -0,0 +1,209 @@ +import QtQuick 2.0 +import QtQml 2.2 +import QtTest 1.1 +import SortFilterProxyModel 0.2 +import SortFilterProxyModel.Test 0.2 + +Item { + ListModel { + id: testModel1 + ListElement{ role1: 1 } + } + SortFilterProxyModel { + id: testFilterProxyModel + sourceModel: testModel1 + property int foo: 1 + filters: [ + ExpressionFilter { + id: expressionFilter + property var w: ({count : 0}) // wrap count in a js object so modifying it doesn't bind it in the expression + expression: { + ++w.count; + testFilterProxyModel.foo; + return true; + } + }, + ValueFilter { + roleName: "role1" + value: testFilterProxyModel.foo + }, + ValueFilter { + roleName: "role1" + value: testFilterProxyModel.foo + } + ] + sorters: RoleSorter { + roleName: "role1" + sortOrder: testFilterProxyModel.foo === 1 ? Qt.AscendingOrder : Qt.DescendingOrder + } + } + + ListModel { + id: testModel2 + ListElement{ role1: 1 } + ListElement{ role1: 2 } + } + SortFilterProxyModel { + id: testSorterProxyModel + sourceModel: testModel2 + property bool foo: true + sorters: [ + ExpressionSorter { + id: expressionSorter + property var w: ({count : 0}) // wrap count in a js object so modifying it doesn't bind it in the expression + expression: { + ++w.count; + testSorterProxyModel.foo; + return false; + } + }, + RoleSorter { + roleName: "role1" + sortOrder: testSorterProxyModel.foo ? Qt.AscendingOrder : Qt.DescendingOrder + }, + RoleSorter { + roleName: "role1" + sortOrder: testSorterProxyModel.foo ? Qt.AscendingOrder : Qt.DescendingOrder + } + ] + } + + SortFilterProxyModel { + id: testRolesProxyModel + sourceModel: testModel1 + property bool foo: true + proxyRoles: [ + StaticRole { + name: "display" + value: 5 + }, + ExpressionRole { + id: expressionRole + name: "expressionRole" + property var w: ({count : 0}) // wrap count in a js object so modifying it doesn't bind it in the expression + expression: { + ++w.count; + return testRolesProxyModel.foo; + } + }, + StaticRole { + name: "role1" + value: testRolesProxyModel.foo + }, + StaticRole { + name: "role2" + value: testRolesProxyModel.foo + } + ] + } + + SignalSpy { + id: dataChangedSpy + target: testRolesProxyModel + signalName: "dataChanged" + } + + Instantiator { + id: instantiator + model: testRolesProxyModel + delegate: QtObject { property bool foo: model.expressionRole; property bool foo2: model.expressionRole } + } + + TestCase { + name: "DelayedTest" + + function test_directFilters() { + testFilterProxyModel.delayed = false; + expressionFilter.w.count = 0; + testFilterProxyModel.foo = 2; + compare(testFilterProxyModel.count, 0); + verify(expressionFilter.w.count > 1); + var lastEvaluationCount = expressionFilter.w.count; + wait(0); + compare(testFilterProxyModel.count, 0); + compare(expressionFilter.w.count, lastEvaluationCount); + } + + function test_delayedFilters() { + testFilterProxyModel.delayed = false; + testFilterProxyModel.foo = 2; + compare(testFilterProxyModel.count, 0); + testFilterProxyModel.delayed = true; + expressionFilter.w.count = 0; + testFilterProxyModel.foo = 0; + testFilterProxyModel.foo = 1; + compare(testFilterProxyModel.count, 0); + compare(expressionFilter.w.count, 0); + wait(0); + compare(testFilterProxyModel.count, 1); + compare(expressionFilter.w.count, 1); + } + + function test_directSorters() { + testSorterProxyModel.delayed = false; + testSorterProxyModel.foo = true; + compare(testSorterProxyModel.get(0).role1, 1); + expressionSorter.w.count = 0; + testSorterProxyModel.foo = false; + compare(testSorterProxyModel.get(0).role1, 2); + verify(expressionSorter.w.count > 1); + var lastEvaluationCount = expressionSorter.w.count + wait(0); + compare(testSorterProxyModel.get(0).role1, 2); + compare(expressionSorter.w.count, lastEvaluationCount); + } + + function test_delayedSorters() { + testSorterProxyModel.delayed = false; + testSorterProxyModel.foo = true; + compare(testSorterProxyModel.get(0).role1, 1); + testSorterProxyModel.delayed = true; + expressionSorter.w.count = 0; + testSorterProxyModel.foo = false; + testSorterProxyModel.foo = true; + testSorterProxyModel.foo = false; + compare(testSorterProxyModel.get(0).role1, 1); + compare(expressionSorter.w.count, 0); + wait(0); + compare(testSorterProxyModel.get(0).role1, 2); + compare(expressionSorter.w.count, 2); + } + + function test_proxyRoles() { + // init not delayed + testRolesProxyModel.delayed = false; + testRolesProxyModel.foo = true; + compare(instantiator.object.foo, true); + expressionRole.w.count = 0; + dataChangedSpy.clear(); + + // test not delayed + testRolesProxyModel.foo = false; + compare(instantiator.object.foo, false); + compare(dataChangedSpy.count, 3); + var notDelayedCount = expressionRole.w.count; // why is it 12 and not just 3 ? + wait(0); + compare(instantiator.object.foo, false); + compare(dataChangedSpy.count, 3); + compare(expressionRole.w.count, notDelayedCount); + + // init delayed + testRolesProxyModel.delayed = true; + expressionRole.w.count = 0; + dataChangedSpy.clear(); + + // test delayed + testRolesProxyModel.foo = true; + testRolesProxyModel.foo = false; + testRolesProxyModel.foo = true; + compare(instantiator.object.foo, false); + compare(dataChangedSpy.count, 0); + compare(expressionRole.w.count, 0); + wait(0); + compare(instantiator.object.foo, true); + compare(dataChangedSpy.count, 1); + var expectedDelayedCount = notDelayedCount / 3; + compare(expressionRole.w.count, expectedDelayedCount); + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_expressionrole.qml b/client/3rd/SortFilterProxyModel/tests/tst_expressionrole.qml new file mode 100644 index 00000000..8bc0856f --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_expressionrole.qml @@ -0,0 +1,43 @@ +import QtQuick 2.0 +import QtQml 2.2 +import QtTest 1.1 +import SortFilterProxyModel 0.2 +import QtQml 2.2 + +Item { + property int c: 0 + ListModel { + id: listModel + ListElement { a: 1; b: 2 } + } + + SortFilterProxyModel { + id: testModel + sourceModel: listModel + + proxyRoles: ExpressionRole { + name: "expressionRole" + expression: a + model.b + c + } + } + + Instantiator { + id: instantiator + model: testModel + QtObject { + property string expressionRole: model.expressionRole + } + } + + TestCase { + name: "ExpressionRole" + + function test_expressionRole() { + fuzzyCompare(instantiator.object.expressionRole, 3, 1e-7); + listModel.setProperty(0, "b", 9); + fuzzyCompare(instantiator.object.expressionRole, 10, 1e-7); + c = 1327; + fuzzyCompare(instantiator.object.expressionRole, 1337, 1e-7); + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_filtercontainerattached.qml b/client/3rd/SortFilterProxyModel/tests/tst_filtercontainerattached.qml new file mode 100644 index 00000000..03ac0fad --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_filtercontainerattached.qml @@ -0,0 +1,57 @@ +import QtQuick 2.0 +import SortFilterProxyModel 0.2 +import QtQml.Models 2.2 +import QtQml 2.2 +import QtTest 1.1 + +Item { + + ListModel { + id: dataModel + ListElement { a: 0; b: 0; c: 0 } + ListElement { a: 0; b: 0; c: 1 } + ListElement { a: 0; b: 1; c: 0 } + ListElement { a: 0; b: 1; c: 1 } + ListElement { a: 1; b: 0; c: 0 } + ListElement { a: 1; b: 0; c: 1 } + ListElement { a: 1; b: 1; c: 0 } + ListElement { a: 1; b: 1; c: 1 } + } + + SortFilterProxyModel { + id: testModel + sourceModel: dataModel + } + + Instantiator { + id: filterInstantiator + model: ["a", "b", "c"] + delegate: ValueFilter { + FilterContainer.container: testModel + roleName: modelData + value: 1 + } + } + + TestCase { + name: "FilterContainerAttached" + + function modelValues() { + var modelValues = []; + + for (var i = 0; i < testModel.count; i++) + modelValues.push(testModel.get(i)); + + return modelValues; + } + + function test_filterContainers() { + compare(filterInstantiator.count, 3); + compare(modelValues(), [ { a: 1, b: 1, c: 1 }]); + filterInstantiator.model = ["a", "b"]; + wait(0); + compare(filterInstantiator.count, 2) + compare(modelValues(), [ { a: 1, b: 1, c: 0 }, { a: 1, b: 1, c: 1 }]); + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_filtercontainers.qml b/client/3rd/SortFilterProxyModel/tests/tst_filtercontainers.qml new file mode 100644 index 00000000..baff55f3 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_filtercontainers.qml @@ -0,0 +1,103 @@ +import QtQuick 2.0 +import SortFilterProxyModel 0.2 +import QtQml.Models 2.2 +import QtTest 1.1 + +Item { + property list filters: [ + AllOf { + property string tag: "allOf" + property var expectedValues: [{a: 0, b: false}] + ValueFilter { + roleName: "a" + value: "0" + } + ValueFilter { + roleName: "b" + value: false + } + }, + AllOf { + property string tag: "allOfOneDisabled" + property var expectedValues: [{a: 0, b: true}, {a: 0, b: false}] + ValueFilter { + roleName: "a" + value: "0" + } + ValueFilter { + enabled: false + roleName: "b" + value: false + } + }, + AnyOf { + property string tag: "anyOf" + property var expectedValues: [{a: 0, b: true}, {a: 0, b: false}, {a: 1, b: false}] + ValueFilter { + roleName: "a" + value: "0" + } + ValueFilter { + roleName: "b" + value: false + } + } + ] + + AllOf { + id: outerFilter + ValueFilter { + roleName: "a" + value: "0" + } + ValueFilter { + id: innerFilter + roleName: "b" + value: false + } + } + + ListModel { + id: dataModel + ListElement { a: 0; b: true } + ListElement { a: 0; b: false } + ListElement { a: 1; b: true } + ListElement { a: 1; b: false } + } + + SortFilterProxyModel { + id: testModel + sourceModel: dataModel + } + + TestCase { + name:"RangeFilterTests" + + function modelValues() { + var modelValues = []; + + for (var i = 0; i < testModel.count; i++) + modelValues.push(testModel.get(i)); + + return modelValues; + } + + function test_filterContainers_data() { + return filters; + } + + function test_filterContainers(filter) { + testModel.filters = filter; + compare(JSON.stringify(modelValues()), JSON.stringify(filter.expectedValues)); + } + + function test_changeInnerFilter() { + testModel.filters = outerFilter; + compare(JSON.stringify(modelValues()), JSON.stringify([{a: 0, b: false}])); + innerFilter.value = true; + compare(JSON.stringify(modelValues()), JSON.stringify([{a: 0, b: true}])); + innerFilter.enabled = false; + compare(JSON.stringify(modelValues()), JSON.stringify([{a: 0, b: true}, {a: 0, b: false}])); + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_filterrole.qml b/client/3rd/SortFilterProxyModel/tests/tst_filterrole.qml new file mode 100644 index 00000000..38ba3947 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_filterrole.qml @@ -0,0 +1,47 @@ +import QtQuick 2.0 +import QtQml 2.2 +import QtTest 1.1 +import SortFilterProxyModel 0.2 +import QtQml 2.2 + +Item { + ListModel { + id: listModel + ListElement { name: "1"; age: 18 } + ListElement { name: "2"; age: 22 } + ListElement { name: "3"; age: 45 } + ListElement { name: "4"; age: 10 } + } + + SortFilterProxyModel { + id: testModel + sourceModel: listModel + + proxyRoles: FilterRole { + name: "isOldEnough" + RangeFilter { + id: ageFilter + roleName: "age" + minimumInclusive: true + minimumValue: 18 + } + } + } + TestCase { + name: "FilterRole" + + function test_filterRole() { + compare(testModel.get(0, "isOldEnough"), true); + compare(testModel.get(1, "isOldEnough"), true); + compare(testModel.get(2, "isOldEnough"), true); + compare(testModel.get(3, "isOldEnough"), false); + + ageFilter.minimumValue = 21; + + compare(testModel.get(0, "isOldEnough"), false); + compare(testModel.get(1, "isOldEnough"), true); + compare(testModel.get(2, "isOldEnough"), true); + compare(testModel.get(3, "isOldEnough"), false); + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_filtersorter.qml b/client/3rd/SortFilterProxyModel/tests/tst_filtersorter.qml new file mode 100644 index 00000000..2b19691c --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_filtersorter.qml @@ -0,0 +1,45 @@ +import QtQuick 2.0 +import QtQml 2.2 +import QtTest 1.1 +import SortFilterProxyModel 0.2 +import QtQml 2.2 + +Item { + ListModel { + id: listModel + ListElement { name: "1"; favorite: true } + ListElement { name: "2"; favorite: false } + ListElement { name: "3"; favorite: false } + ListElement { name: "4"; favorite: true } + } + + SortFilterProxyModel { + id: testModel + sourceModel: listModel + + sorters: FilterSorter { + ValueFilter { + id: favoriteFilter + roleName: "favorite" + value: true + } + } + } + TestCase { + name: "FilterSorter" + + function test_filterSorter() { + compare(testModel.get(0, "name"), "1"); + compare(testModel.get(1, "name"), "4"); + compare(testModel.get(2, "name"), "2"); + compare(testModel.get(3, "name"), "3"); + + favoriteFilter.value = false; + + compare(testModel.get(0, "name"), "2"); + compare(testModel.get(1, "name"), "3"); + compare(testModel.get(2, "name"), "1"); + compare(testModel.get(3, "name"), "4"); + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_helpers.qml b/client/3rd/SortFilterProxyModel/tests/tst_helpers.qml new file mode 100644 index 00000000..5610d3dc --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_helpers.qml @@ -0,0 +1,111 @@ +import QtQuick 2.0 +import QtQml 2.2 +import QtTest 1.1 +import SortFilterProxyModel 0.2 +import SortFilterProxyModel.Test 0.2 + +Item { + ListModel { + id: dataModel + ListElement { + firstName: "Tupac" + lastName: "Shakur" + } + ListElement { + firstName: "Charles" + lastName: "Aznavour" + } + ListElement { + firstName: "Frank" + lastName: "Sinatra" + } + ListElement { + firstName: "Laurent" + lastName: "Garnier" + } + ListElement { + firstName: "Phillipe" + lastName: "Risoli" + } + } + SortFilterProxyModel { + id: testModel + sourceModel: dataModel + } + SortFilterProxyModel { + id: testModel2 + sourceModel: dataModel + filters: ValueFilter { + inverted: true + roleName: "lastName" + value: "Sinatra" + } + sorters: [ + RoleSorter { roleName: "lastName"}, + RoleSorter { roleName: "firstName"} + ] + } + + TestCase { + name: "Helper functions" + + function test_getWithRoleName() { + compare(testModel.get(0, "lastName"), "Shakur"); + } + + function test_getWithoutRoleName() { + compare(testModel.get(1), { firstName: "Charles", lastName: "Aznavour"}); + } + + function test_roleForName() { + compare(testModel.data(testModel.index(0, 0), testModel.roleForName("firstName")), "Tupac"); + compare(testModel.data(testModel.index(1, 0), testModel.roleForName("lastName")), "Aznavour"); + } + + function test_mapToSource() { + compare(testModel2.mapToSource(3), 0); + compare(testModel2.mapToSource(4), -1); + } + + function test_mapToSourceLoop() { + for (var i = 0; i < testModel2.count; ++i) { + var sourceRow = testModel2.mapToSource(i); + compare(testModel2.get(i).lastName, dataModel.get(sourceRow).lastName); + } + } + + function test_mapToSourceLoop_index() { + for (var i = 0; i < testModel2.count; ++i) { + var proxyIndex = testModel2.index(i, 0); + var sourceIndex = testModel2.mapToSource(proxyIndex); + var roleNumber = testModel2.roleForName("lastName"); + compare(testModel2.data(proxyIndex, roleNumber), dataModel.data(sourceIndex, roleNumber)); + } + } + + function test_mapFromSource() { + compare(testModel2.mapFromSource(1), 0); + compare(testModel2.mapFromSource(2), -1); + } + + function test_mapFromSourceLoop() { + for (var i = 0; i < dataModel.count; ++i) { + var proxyRow = testModel2.mapFromSource(i); + if (proxyRow !== -1) { + compare(dataModel.get(i).lastName, testModel2.get(proxyRow).lastName); + } + } + } + + function test_mapFromSourceLoop_index() { + for (var i = 0; i < dataModel.count; ++i) { + var sourceIndex = dataModel.index(i, 0); + var proxyIndex = testModel2.mapFromSource(sourceIndex); + var roleNumber = testModel2.roleForName("lastName"); + if (proxyIndex.valid) + compare(testModel2.data(proxyIndex, roleNumber), dataModel.data(sourceIndex, roleNumber)); + } + } + + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_indexfilter.qml b/client/3rd/SortFilterProxyModel/tests/tst_indexfilter.qml new file mode 100644 index 00000000..b275c59a --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_indexfilter.qml @@ -0,0 +1,104 @@ +import QtQuick 2.0 +import SortFilterProxyModel 0.2 +import QtQml.Models 2.2 +import QtTest 1.1 + +Item { + property list filters: [ + IndexFilter { + property string tag: "basicUsage" + property var expectedValues: [3, 1, 2] + minimumIndex: 1; maximumIndex: 3 + }, + IndexFilter { + property string tag: "outOfBounds" + property var expectedValues: [] + minimumIndex: 3; maximumIndex: 1 + }, + IndexFilter { + property string tag: "0to0Inverted" + property var expectedValues: [3,1,2,4] + minimumIndex: 0; maximumIndex: 0; inverted: true + }, + IndexFilter { + property string tag: "0to0" // bug / issue #15 + property var expectedValues: [5] + minimumIndex: 0; maximumIndex: 0 + }, + IndexFilter { + property string tag: "basicUsageInverted" + property var expectedValues: [5,4] + minimumIndex: 1; maximumIndex: 3; inverted: true + }, + IndexFilter { + property string tag: "last" + property var expectedValues: [4] + minimumIndex: -1 + }, + IndexFilter { + property string tag: "fromEnd" + property var expectedValues: [2, 4] + minimumIndex: -2 + }, + IndexFilter { + property string tag: "fromEndRange" + property var expectedValues: [1, 2] + minimumIndex: -3 + maximumIndex: -2 + }, + IndexFilter { + property string tag: "mixedSignRange" + property var expectedValues: [3, 1, 2] + minimumIndex: 1 + maximumIndex: -2 + }, + IndexFilter { + property string tag: "toBigFilter" + property var expectedValues: [] + minimumIndex: 5 + }, + IndexFilter { + property string tag: "noFilter" + property var expectedValues: [5, 3, 1, 2, 4] + }, + IndexFilter { + property string tag: "undefinedFilter" + property var expectedValues: [5, 3, 1, 2, 4] + minimumIndex: undefined + maximumIndex: null + } + ] + + ListModel { + id: dataModel + ListElement { value: 5 } + ListElement { value: 3 } + ListElement { value: 1 } + ListElement { value: 2 } + ListElement { value: 4 } + } + + SortFilterProxyModel { + id: testModel + // FIXME: Crashes/fails with error if I define ListModel directly within sourceModel + sourceModel: dataModel + } + + TestCase { + name: "IndexFilterTests" + + function test_minMax_data() { + return filters; + } + + function test_minMax(filter) { + testModel.filters = filter; + + var actualValues = []; + for (var i = 0; i < testModel.count; i++) + actualValues.push(testModel.data(testModel.index(i, 0))); + + compare(actualValues, filter.expectedValues); + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_joinrole.qml b/client/3rd/SortFilterProxyModel/tests/tst_joinrole.qml new file mode 100644 index 00000000..c7a3bbe0 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_joinrole.qml @@ -0,0 +1,45 @@ +import QtQuick 2.0 +import QtQml 2.2 +import QtTest 1.1 +import SortFilterProxyModel 0.2 +import QtQml 2.2 + +Item { + ListModel { + id: listModel + ListElement { firstName: "Justin"; lastName: "Timberlake" } + } + + SortFilterProxyModel { + id: testModel + sourceModel: listModel + + proxyRoles: JoinRole { + id: joinRole + name: "fullName" + roleNames: ["firstName", "lastName"] + } + } + + Instantiator { + id: instantiator + model: testModel + QtObject { + property string fullName: model.fullName + } + } + + TestCase { + name: "JoinRole" + + function test_joinRole() { + compare(instantiator.object.fullName, "Justin Timberlake"); + listModel.setProperty(0, "lastName", "Bieber"); + compare(instantiator.object.fullName, "Justin Bieber"); + joinRole.roleNames = ["lastName", "firstName"]; + compare(instantiator.object.fullName, "Bieber Justin"); + joinRole.separator = " - "; + compare(instantiator.object.fullName, "Bieber - Justin"); + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_proxyroles.qml b/client/3rd/SortFilterProxyModel/tests/tst_proxyroles.qml new file mode 100644 index 00000000..c9746211 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_proxyroles.qml @@ -0,0 +1,126 @@ +import QtQuick 2.0 +import QtQml 2.2 +import QtTest 1.1 +import SortFilterProxyModel 0.2 +import SortFilterProxyModel.Test 0.2 +import QtQml 2.2 + +Item { + ListModel { + id: listModel + ListElement { test: "first"; keep: true } + ListElement { test: "second"; keep: true } + ListElement { test: "third"; keep: true } + } + + SortFilterProxyModel { + id: testModel + sourceModel: listModel + filters: [ + ValueFilter { + roleName: "keep" + value: true + }, + ValueFilter { + inverted: true + roleName: "staticRole" + value: "filterMe" + } + ] + + proxyRoles: [ + StaticRole { + id: staticRole + name: "staticRole" + value: "foo" + }, + StaticRole { + id: renameRole + name: "renameMe" + value: "test" + }, + SourceIndexRole { + name: "sourceIndexRole" + }, + MultiRole {} + ] + } + + Instantiator { + id: instantiator + model: testModel + QtObject { + property string staticRole: model.staticRole + property int sourceIndexRole: model.sourceIndexRole + } + } + + ListModel { + id: singleRowModel + ListElement { + changingRole: "Change me" + otherRole: "I don't change" + } + } + + SortFilterProxyModel { + id: noProxyRolesProxyModel + sourceModel: singleRowModel + } + + Instantiator { + id: outerInstantiator + model: noProxyRolesProxyModel + QtObject { + property var counter: ({ count : 0 }) + property string changingRole: model.changingRole + property string otherRole: { + ++counter.count; + return model.otherRole; + } + } + } + + TestCase { + name: "ProxyRoles" + + function test_resetAfterNameChange() { + var oldObject = instantiator.object; + renameRole.name = "foobarRole"; + var newObject = instantiator.object; + verify(newObject !== oldObject, "Instantiator object should have been reinstantiated"); + } + + function test_proxyRoleInvalidation() { + compare(instantiator.object.staticRole, "foo"); + staticRole.value = "bar"; + compare(instantiator.object.staticRole, "bar"); + } + + function test_proxyRoleGetDataFromSource() { + compare(instantiator.object.sourceIndexRole, 0); + compare(testModel.get(1, "sourceIndexRole"), 1); + listModel.setProperty(1, "keep", false); + compare(testModel.get(1, "sourceIndexRole"), 2); + } + + function test_filterFromProxyRole() { + staticRole.value = "filterMe"; + compare(testModel.count, 0); + staticRole.value = "foo"; + compare(testModel.count, 3); + } + + function test_multiRole() { + compare(testModel.get(0, "role1"), "data for role1"); + compare(testModel.get(0, "role2"), "data for role2"); + } + + function test_ProxyRolesDataChanged() { + outerInstantiator.object.counter.count = 0; + singleRowModel.setProperty(0, "changingRole", "Changed") + compare(outerInstantiator.object.changingRole, "Changed"); + compare(outerInstantiator.object.counter.count, 0); + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_rangefilter.qml b/client/3rd/SortFilterProxyModel/tests/tst_rangefilter.qml new file mode 100644 index 00000000..d5dfe99e --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_rangefilter.qml @@ -0,0 +1,99 @@ +import QtQuick 2.0 +import SortFilterProxyModel 0.2 +import QtQml.Models 2.2 +import QtTest 1.1 + +Item { + property list filters: [ + RangeFilter { + property string tag: "inclusive" + property int expectedModelCount: 3 + property var expectedValues: [3, 2, 4] + property QtObject dataModel: dataModel0 + roleName: "value"; minimumValue: 2; maximumValue: 4 + }, + RangeFilter { + property string tag: "explicitInclusive" + property int expectedModelCount: 3 + property var expectedValues: [3, 2, 4] + property QtObject dataModel: dataModel0 + roleName: "value"; minimumValue: 2; maximumValue: 4; minimumInclusive: true; maximumInclusive: true + }, + RangeFilter { + property string tag: "inclusiveMinExclusiveMax" + property int expectedModelCount: 2 + property var expectedValues: [2, 3] + property QtObject dataModel: dataModel1 + roleName: "value"; minimumValue: 2; maximumValue: 4; minimumInclusive: true; maximumInclusive: false + }, + RangeFilter { + property string tag: "exclusiveMinInclusiveMax" + property int expectedModelCount: 2 + property var expectedValues: [3, 4] + property QtObject dataModel: dataModel1 + roleName: "value"; minimumValue: 2; maximumValue: 4; minimumInclusive: false; maximumInclusive: true + }, + RangeFilter { + property string tag: "exclusive" + property int expectedModelCount: 1 + property var expectedValues: [3] + property QtObject dataModel: dataModel1 + roleName: "value"; minimumValue: 2; maximumValue: 4; minimumInclusive: false; maximumInclusive: false + }, + RangeFilter { + property string tag: "outOfBoundsRange" + property var expectedValues: [] + property QtObject dataModel: dataModel1 + roleName: "value"; minimumValue: 4; maximumValue: 2 + }, + RangeFilter { + objectName: tag + property string tag: "noMinimum" + property var expectedValues: [3, 1, 2] + property QtObject dataModel: dataModel0 + roleName: "value"; maximumValue: 3 + } + ] + + ListModel { + id: dataModel0 + ListElement { value: 5 } + ListElement { value: 3 } + ListElement { value: 1 } + ListElement { value: 2 } + ListElement { value: 4 } + } + + ListModel { + id: dataModel1 + ListElement { value: 5 } + ListElement { value: 2 } + ListElement { value: 3 } + ListElement { value: 1 } + ListElement { value: 4 } + } + + SortFilterProxyModel { id: testModel } + + TestCase { + name:"RangeFilterTests" + + function test_minMax_data() { + return filters; + } + + function test_minMax(filter) { + testModel.sourceModel = filter.dataModel; + testModel.filters = filter; + + verify(testModel.count === filter.expectedValues.length, + "Expected count " + filter.expectedValues.length + ", actual count: " + testModel.count); + for (var i = 0; i < testModel.count; i++) + { + var modelValue = testModel.get(i, filter.roleName); + verify(modelValue === filter.expectedValues[i], + "Expected testModel value " + filter.expectedValues[i] + ", actual: " + modelValue); + } + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_regexprole.qml b/client/3rd/SortFilterProxyModel/tests/tst_regexprole.qml new file mode 100644 index 00000000..be4290b2 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_regexprole.qml @@ -0,0 +1,54 @@ +import QtQuick 2.0 +import QtQml 2.2 +import QtTest 1.1 +import SortFilterProxyModel 0.2 +import QtQml 2.2 + +Item { + ListModel { + id: listModel + ListElement { dummyRole: false; compoundRole: "0 - zero"; unusedRole: "" } + ListElement { dummyRole: false; compoundRole: "1 - one"; unusedRole: "" } + ListElement { dummyRole: false; compoundRole: "2 - two"; unusedRole: "" } + ListElement { dummyRole: false; compoundRole: "3 - three"; unusedRole: "" } + ListElement { dummyRole: false; compoundRole: "four"; unusedRole: "" } + } + + SortFilterProxyModel { + id: testModel + sourceModel: listModel + + proxyRoles: [ + RegExpRole { + id: regExpRole + roleName: "compoundRole" + pattern: "(?\\d+) - (?.+)" + }, + RegExpRole { + id: caseSensitiveRole + roleName: "compoundRole" + pattern: "\\d+ - (?[A-Z]+)" + caseSensitivity: Qt.CaseSensitive + }, + RegExpRole { + id: caseInsensitiveRole + roleName: "compoundRole" + pattern: "\\d+ - (?[A-Z]+)" + caseSensitivity: Qt.CaseInsensitive + } + ] + } + + TestCase { + name: "RegExpRole" + + function test_regExpRole() { + compare(testModel.get(0, "id"), "0"); + compare(testModel.get(1, "id"), "1"); + compare(testModel.get(0, "name"), "zero"); + compare(testModel.get(4, "id"), undefined); + compare(testModel.get(0, "nameCS"), undefined); + compare(testModel.get(0, "nameCIS"), "zero"); + } + } + } diff --git a/client/3rd/SortFilterProxyModel/tests/tst_rolesorter.qml b/client/3rd/SortFilterProxyModel/tests/tst_rolesorter.qml new file mode 100644 index 00000000..19bfde23 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_rolesorter.qml @@ -0,0 +1,70 @@ +import QtQuick 2.0 +import SortFilterProxyModel 0.2 +import QtQml.Models 2.2 +import QtTest 1.1 + +Item { + property list sorters: [ + RoleSorter { + property string tag: "intRole" + property var expectedValues: [1, 2, 3, 4, 5] + roleName: "intRole" + }, + RoleSorter { + property string tag: "intRoleDescending" + property var expectedValues: [5, 4, 3, 2, 1] + roleName: "intRole" + sortOrder: Qt.DescendingOrder + }, + RoleSorter { + property string tag: "stringRole" + property var expectedValues: ["a", "b", "c", "d", "e"] + roleName: "stringRole" + }, + RoleSorter { + property string tag: "stringRoleDescending" + property var expectedValues: ["e", "d", "c", "b", "a"] + roleName: "stringRole" + sortOrder: Qt.DescendingOrder + }, + RoleSorter { + property string tag: "mixedCaseStringRole" + property var expectedValues: ["A", "b", "C", "D", "e"] + roleName: "mixedCaseStringRole" + } + ] + + ListModel { + id: dataModel + ListElement { intRole: 5; stringRole: "c"; mixedCaseStringRole: "C" } + ListElement { intRole: 3; stringRole: "e"; mixedCaseStringRole: "e" } + ListElement { intRole: 1; stringRole: "d"; mixedCaseStringRole: "D" } + ListElement { intRole: 2; stringRole: "a"; mixedCaseStringRole: "A" } + ListElement { intRole: 4; stringRole: "b"; mixedCaseStringRole: "b" } + } + + SortFilterProxyModel { + id: testModel + sourceModel: dataModel + } + + TestCase { + name: "RoleSorterTests" + + function test_roleSorters_data() { + return sorters; + } + + function test_roleSorters(sorter) { + testModel.sorters = sorter; + + verify(testModel.count === sorter.expectedValues.length, + "Expected count " + sorter.expectedValues.length + ", actual count: " + testModel.count); + let actualValues = []; + for (var i = 0; i < testModel.count; i++) { + actualValues.push(testModel.get(i, sorter.roleName)); + } + compare(actualValues, sorter.expectedValues); + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_sortercontainerattached.qml b/client/3rd/SortFilterProxyModel/tests/tst_sortercontainerattached.qml new file mode 100644 index 00000000..a0d46d19 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_sortercontainerattached.qml @@ -0,0 +1,131 @@ +import QtQuick 2.0 +import SortFilterProxyModel 0.2 +import QtQml.Models 2.2 +import QtQml 2.2 +import QtTest 1.1 + +Item { + + ListModel { + id: dataModel + ListElement { a: 3; b: 2; c: 9 } + ListElement { a: 3; b: 5; c: 0 } + ListElement { a: 3; b: 2; c: 8 } + ListElement { a: 2; b: 9; c: 1 } + ListElement { a: 2; b: 1; c: 7 } + ListElement { a: 2; b: 6; c: 2 } + ListElement { a: 1; b: 8; c: 6 } + ListElement { a: 1; b: 7; c: 3 } + ListElement { a: 1; b: 8; c: 5 } + } + + SortFilterProxyModel { + id: testModel + sourceModel: dataModel + } + ListModel { + id: sorterRoleModel + ListElement { roleName: "a" } + ListElement { roleName: "b" } + ListElement { roleName: "c" } + } + Instantiator { + id: sorterInstantiator + model: sorterRoleModel + delegate: RoleSorter { + SorterContainer.container: testModel + roleName: model.roleName + } + } + + SortFilterProxyModel { + id: testModelPriority + sourceModel: dataModel + } + ListModel { + id: sorterRoleModelPriority + ListElement { roleName: "a" } + ListElement { roleName: "b" } + ListElement { roleName: "c" } + } + Instantiator { + id: sorterInstantiatorPriority + model: sorterRoleModelPriority + delegate: RoleSorter { + SorterContainer.container: testModelPriority + roleName: model.roleName + priority: -model.index + } + } + + TestCase { + name: "SorterContainerAttached" + + function modelValues(model) { + var modelValues = []; + + for (var i = 0; i < model.count; i++) + modelValues.push(model.get(i)); + + return modelValues; + } + + function test_sorterContainers() { + compare(sorterInstantiator.count, 3); + compare(modelValues(testModel), [ + { a: 1, b: 7, c: 3 }, + { a: 1, b: 8, c: 5 }, + { a: 1, b: 8, c: 6 }, + { a: 2, b: 1, c: 7 }, + { a: 2, b: 6, c: 2 }, + { a: 2, b: 9, c: 1 }, + { a: 3, b: 2, c: 8 }, + { a: 3, b: 2, c: 9 }, + { a: 3, b: 5, c: 0 } + ]); + sorterRoleModel.remove(0); // a, b, c --> b, c + wait(0); + compare(sorterInstantiator.count, 2); + compare(JSON.stringify(modelValues(testModel)), JSON.stringify([ + { a: 2, b: 1, c: 7 }, + { a: 3, b: 2, c: 8 }, + { a: 3, b: 2, c: 9 }, + { a: 3, b: 5, c: 0 }, + { a: 2, b: 6, c: 2 }, + { a: 1, b: 7, c: 3 }, + { a: 1, b: 8, c: 5 }, + { a: 1, b: 8, c: 6 }, + { a: 2, b: 9, c: 1 }, + ])); + } + + function test_sorterContainersPriority() { + compare(sorterInstantiatorPriority.count, 3); + compare(JSON.stringify(modelValues(testModelPriority)), JSON.stringify([ + { a: 1, b: 7, c: 3 }, + { a: 1, b: 8, c: 5 }, + { a: 1, b: 8, c: 6 }, + { a: 2, b: 1, c: 7 }, + { a: 2, b: 6, c: 2 }, + { a: 2, b: 9, c: 1 }, + { a: 3, b: 2, c: 8 }, + { a: 3, b: 2, c: 9 }, + { a: 3, b: 5, c: 0 } + ])); + sorterRoleModelPriority.move(0, 1, 1); // a, b, c --> b, a, c + wait(0); + compare(sorterInstantiatorPriority.count, 3); + compare(JSON.stringify(modelValues(testModelPriority)), JSON.stringify([ + { a: 2, b: 1, c: 7 }, + { a: 3, b: 2, c: 8 }, + { a: 3, b: 2, c: 9 }, + { a: 3, b: 5, c: 0 }, + { a: 2, b: 6, c: 2 }, + { a: 1, b: 7, c: 3 }, + { a: 1, b: 8, c: 5 }, + { a: 1, b: 8, c: 6 }, + { a: 2, b: 9, c: 1 } + ])); + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_sorters.qml b/client/3rd/SortFilterProxyModel/tests/tst_sorters.qml new file mode 100644 index 00000000..23a21d9e --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_sorters.qml @@ -0,0 +1,158 @@ +import QtQuick 2.0 +import QtQml 2.2 +import QtTest 1.1 +import SortFilterProxyModel 0.2 +import SortFilterProxyModel.Test 0.2 + +Item { + ListModel { + id: listModel + ListElement { test: "first"; test2: "c"; test3: 1 } + ListElement { test: "second"; test2: "a"; test3: 0 } + ListElement { test: "third"; test2: "b"; test3: 2} + ListElement { test: "fourth"; test2: "b"; test3: 3 } + } + + ListModel { + id: noRolesFirstListModel + } + + property list sorters: [ + QtObject { + property string tag: "no sorter" + property bool notASorter: true + property var expectedValues: ["first", "second", "third", "fourth"] + }, + IndexSorter { + property string tag: "Dummy IndexSorter" + property var expectedValues: ["first", "second", "third", "fourth"] + }, + ReverseIndexSorter { + property string tag: "Dummy ReverseIndexSorter" + property var expectedValues: ["fourth", "third", "second", "first"] + }, + IndexSorter { + property string tag: "Disabled dummy IndexSorter" + enabled: false + property var expectedValues: ["first", "second", "third", "fourth"] + }, + ReverseIndexSorter { + property string tag: "Disabled dummy ReverseIndexSorter" + enabled: false + property var expectedValues: ["first", "second", "third", "fourth"] + }, + IndexSorter { + property string tag: "Descending dummy IndexSorter" + ascendingOrder: false + property var expectedValues: ["fourth", "third", "second", "first"] + }, + ReverseIndexSorter { + property string tag: "Descending dummy ReverseIndexSorter" + ascendingOrder: false + property var expectedValues: ["first", "second", "third", "fourth"] + }, + IndexSorter { + property string tag: "Disabled descending dummy IndexSorter" + enabled: false + ascendingOrder: false + property var expectedValues: ["first", "second", "third", "fourth"] + }, + ReverseIndexSorter { + property string tag: "Disabled descending dummy ReverseIndexSorter" + enabled: false + ascendingOrder: false + property var expectedValues: ["first", "second", "third", "fourth"] + } + ] + + ReverseIndexSorter { + id: reverseIndexSorter + } + + property list tieSorters: [ + RoleSorter { roleName: "test2" }, + RoleSorter { roleName: "test" } + ] + + property list sortersWithPriority: [ + RoleSorter { roleName: "test3" }, + RoleSorter { roleName: "test" }, + RoleSorter { roleName: "test2"; priority: 1 } + ] + + SortFilterProxyModel { + id: testModel + sourceModel: listModel + } + + SortFilterProxyModel { + id: noRolesFirstProxyModel + sourceModel: noRolesFirstListModel + sorters: RoleSorter { roleName: "test" } + } + + TestCase { + name: "SortersTests" + + function test_indexOrder_data() { + return sorters; + } + + function test_indexOrder(sorter) { + testModel.sorters = sorter; + verifyModelValues(testModel, sorter.expectedValues); + } + + function test_enablingSorter() { + reverseIndexSorter.enabled = false; + testModel.sorters = reverseIndexSorter; + var expectedValuesBeforeEnabling = ["first", "second", "third", "fourth"]; + var expectedValuesAfterEnabling = ["fourth", "third", "second", "first"]; + verifyModelValues(testModel, expectedValuesBeforeEnabling); + reverseIndexSorter.enabled = true; + verifyModelValues(testModel, expectedValuesAfterEnabling); + } + + function test_disablingSorter() { + reverseIndexSorter.enabled = true; + testModel.sorters = reverseIndexSorter; + var expectedValuesBeforeDisabling = ["fourth", "third", "second", "first"]; + var expectedValuesAfterDisabling = ["first", "second", "third", "fourth"]; + verifyModelValues(testModel, expectedValuesBeforeDisabling); + reverseIndexSorter.enabled = false; + verifyModelValues(testModel, expectedValuesAfterDisabling); + } + + function test_tieSorters() { + testModel.sorters = tieSorters; + var expectedValues = ["second", "fourth", "third", "first"]; + verifyModelValues(testModel, expectedValues); + } + + function test_sortersWithPriority() { + testModel.sorters = sortersWithPriority; + var expectedValues = ["second", "third", "fourth", "first"]; + verifyModelValues(testModel, expectedValues); + testModel.sorters[0].priority = 2; + expectedValues = ["second", "first", "third", "fourth"]; + verifyModelValues(testModel, expectedValues); + } + + function test_noRolesFirstModel() { + noRolesFirstListModel.append([{test: "b"}, {test: "a"}]); + var expectedValues = ["a", "b"]; + verifyModelValues(noRolesFirstProxyModel, expectedValues); + } + + function verifyModelValues(model, expectedValues) { + verify(model.count === expectedValues.length, + "Expected count " + expectedValues.length + ", actual count: " + model.count); + for (var i = 0; i < model.count; i++) + { + var modelValue = model.get(i, "test"); + verify(modelValue === expectedValues[i], + "Expected testModel value " + expectedValues[i] + ", actual: " + modelValue); + } + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_sortfilterproxymodel.cpp b/client/3rd/SortFilterProxyModel/tests/tst_sortfilterproxymodel.cpp new file mode 100644 index 00000000..90f5a6ba --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_sortfilterproxymodel.cpp @@ -0,0 +1,2 @@ +#include +QUICK_TEST_MAIN(SortFilterProxyModel) diff --git a/client/3rd/SortFilterProxyModel/tests/tst_sourceroles.qml b/client/3rd/SortFilterProxyModel/tests/tst_sourceroles.qml new file mode 100644 index 00000000..ff747cc2 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_sourceroles.qml @@ -0,0 +1,49 @@ +import QtQuick 2.0 +import QtTest 1.1 +import QtQml 2.2 +import SortFilterProxyModel 0.2 + +Item { + ListModel { + id: nonEmptyFirstModel + ListElement { + test: "test" + } + } + SortFilterProxyModel { + id: nonEmptyFirstProxyModel + sourceModel: nonEmptyFirstModel + } + Instantiator { + id: nonEmptyFirstInstantiator + model: nonEmptyFirstProxyModel + QtObject { property var test: model.test } + } + + ListModel { + id: emptyFirstModel + } + SortFilterProxyModel { + id: emptyFirstProxyModel + sourceModel: emptyFirstModel + } + Instantiator { + id: emptyFirstInstantiator + model: emptyFirstProxyModel + QtObject { property var test: model.test } + } + + TestCase { + name: "RoleTests" + + function test_nonEmptyFirst() { + compare(nonEmptyFirstInstantiator.object.test, "test"); + } + + function test_emptyFirst() { + emptyFirstModel.append({test: "test"}); + compare(emptyFirstProxyModel.get(0), {test: "test"}); + compare(emptyFirstInstantiator.object.test, "test"); + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_stringsorter.qml b/client/3rd/SortFilterProxyModel/tests/tst_stringsorter.qml new file mode 100644 index 00000000..3e22c65b --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_stringsorter.qml @@ -0,0 +1,85 @@ +import QtQuick 2.0 +import SortFilterProxyModel 0.2 +import QtQml.Models 2.2 +import QtTest 1.1 + +Item { + property list sorters: [ + StringSorter { + property string tag: "normal" + property var expectedValues: ["haha", "hähä", "hehe", "héhé", "hihi", "huhu"] + roleName: "accentRole" + }, + StringSorter { + property string tag: "numericMode" + property var expectedValues: ["a1", "a20", "a30", "a99", "a100", "a1000"] + roleName: "numericRole" + numericMode: true + }, + StringSorter { + property string tag: "nonNumericMode" + property var expectedValues: ["a1", "a100", "a1000", "a20", "a30", "a99"] + roleName: "numericRole" + numericMode: false + }, + StringSorter { + property string tag: "caseSensitive" + property var expectedValues: ["a", "A", "b", "c", "z", "Z"] + roleName: "caseRole" + caseSensitivity: Qt.CaseSensitive + }, + StringSorter { + property string tag: "nonCaseSensitive" + property var expectedValues: ["A", "a", "b", "c", "Z", "z"] + roleName: "caseRole" + caseSensitivity: Qt.CaseInsensitive + }, + StringSorter { + property string tag: "ignorePunctuation" + property var expectedValues: ["a-a", "aa", "b-b", "b-c", "b.c", "bc"] + roleName: "punctuationRole" + ignorePunctation: true + }, + StringSorter { + property string tag: "doNotIgnorePunctuation" + property var expectedValues: ["aa", "a-a", "b.c", "b-b", "bc", "b-c"] + roleName: "punctuationRole" + ignorePunctation: false + } + ] + + ListModel { + id: dataModel + ListElement { accentRole: "héhé"; numericRole: "a20"; caseRole: "b"; punctuationRole: "a-a"} + ListElement { accentRole: "hehe"; numericRole: "a1"; caseRole: "A"; punctuationRole: "aa"} + ListElement { accentRole: "haha"; numericRole: "a100"; caseRole: "a"; punctuationRole: "b-c"} + ListElement { accentRole: "huhu"; numericRole: "a99"; caseRole: "c"; punctuationRole: "b.c"} + ListElement { accentRole: "hihi"; numericRole: "a30"; caseRole: "Z"; punctuationRole: "bc"} + ListElement { accentRole: "hähä"; numericRole: "a1000"; caseRole: "z"; punctuationRole: "b-b"} + } + + SortFilterProxyModel { + id: testModel + sourceModel: dataModel + } + + TestCase { + name: "StringSorterTests" + + function test_stringSorters_data() { + return sorters; + } + + function test_stringSorters(sorter) { + testModel.sorters = sorter; + + verify(testModel.count === sorter.expectedValues.length, + "Expected count " + sorter.expectedValues.length + ", actual count: " + testModel.count); + let actualValues = []; + for (var i = 0; i < testModel.count; i++) { + actualValues.push(testModel.get(i, sorter.roleName)); + } + compare(actualValues, sorter.expectedValues); + } + } +} diff --git a/client/3rd/SortFilterProxyModel/tests/tst_switchrole.qml b/client/3rd/SortFilterProxyModel/tests/tst_switchrole.qml new file mode 100644 index 00000000..e8721f10 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/tests/tst_switchrole.qml @@ -0,0 +1,99 @@ +import QtQuick 2.0 +import QtQml 2.2 +import QtTest 1.1 +import SortFilterProxyModel 0.2 +import QtQml 2.2 + +Item { + ListModel { + id: listModel + ListElement { name: "1"; favorite: true } + ListElement { name: "2"; favorite: false } + ListElement { name: "3"; favorite: false } + ListElement { name: "4"; favorite: true } + } + + SortFilterProxyModel { + id: testModel + sourceModel: listModel + + proxyRoles: SwitchRole { + id: switchRole + name: "switchRole" + ValueFilter { + id: valueFilter + roleName: "favorite" + value: true + SwitchRole.value: "*" + } + ValueFilter { + id: secondValueFilter + roleName: "favorite" + value: true + SwitchRole.value: "%" + } + ValueFilter { + id: thirdValueFilter + roleName: "name" + value: 3 + SwitchRole.value: "three" + } + defaultRoleName: "name" + defaultValue: "foo" + } + } + + Instantiator { + id: instantiator + model: testModel + QtObject { + property var switchRole: model.switchRole + } + } + + TestCase { + name: "SwitchRole" + + function test_role() { + compare(testModel.get(0, "switchRole"), "*"); + compare(testModel.get(1, "switchRole"), "2"); + compare(testModel.get(2, "switchRole"), "three"); + compare(testModel.get(3, "switchRole"), "*"); + } + + function test_valueChange() { + compare(instantiator.object.switchRole, "*"); + valueFilter.SwitchRole.value = "test"; + compare(instantiator.object.switchRole, "test"); + valueFilter.SwitchRole.value = "*"; + } + + function test_filterChange() { + compare(instantiator.object.switchRole, "*"); + valueFilter.enabled = false; + compare(instantiator.object.switchRole, "%"); + valueFilter.enabled = true; + } + + function test_defaultSourceChange() { + compare(instantiator.object.switchRole, "*"); + listModel.setProperty(0, "favorite", false); + compare(instantiator.object.switchRole, "1"); + compare(instantiator.objectAt(1).switchRole, "2"); + listModel.setProperty(1, "name", "test"); + compare(instantiator.objectAt(1).switchRole, "test"); + + listModel.setProperty(1, "name", "2"); + listModel.setProperty(0, "favorite", true); + } + + function test_defaultValue() { + switchRole.defaultRoleName = ""; + compare(instantiator.objectAt(1).switchRole, "foo"); + switchRole.defaultValue = "bar"; + compare(instantiator.objectAt(1).switchRole, "bar"); + switchRole.defaultRoleName = "name"; + switchRole.defaultValue = "foo"; + } + } +} diff --git a/client/3rd/SortFilterProxyModel/utils/utils.cpp b/client/3rd/SortFilterProxyModel/utils/utils.cpp new file mode 100644 index 00000000..e32f5094 --- /dev/null +++ b/client/3rd/SortFilterProxyModel/utils/utils.cpp @@ -0,0 +1,59 @@ +#include "utils.h" + +#include + +namespace qqsfpm { + +int compareVariants(const QVariant &lhs, const QVariant &rhs) +{ + // Do the QString check first because otherwise the canConvert check will get hit for strings. + if (lhs.typeId() == QMetaType::QString && rhs.typeId() == QMetaType::QString) { + const auto lhsValue = lhs.toString(); + const auto rhsValue = rhs.toString(); + if (lhsValue == rhsValue) + return 0; + return lhsValue.compare(rhsValue, Qt::CaseInsensitive); + } else if (lhs.typeId() == QMetaType::Bool && rhs.typeId() == QMetaType::Bool) { + const auto lhsValue = lhs.toBool(); + const auto rhsValue = rhs.toBool(); + if (lhsValue == rhsValue) + return 0; + // false < true. + return !lhsValue ? -1 : 1; + } else if (lhs.typeId() == QMetaType::QDate && rhs.typeId() == QMetaType::QDate) { + const auto lhsValue = lhs.toDate(); + const auto rhsValue = rhs.toDate(); + if (lhsValue == rhsValue) + return 0; + return lhsValue < rhsValue ? -1 : 1; + } else if (lhs.typeId() == QMetaType::QDateTime && rhs.typeId() == QMetaType::QDateTime) { + const auto lhsValue = lhs.toDateTime(); + const auto rhsValue = rhs.toDateTime(); + if (lhsValue == rhsValue) + return 0; + return lhsValue < rhsValue ? -1 : 1; + } else if (lhs.typeId() == QMetaType::QStringList && rhs.typeId() == QMetaType::QStringList) { + const auto lhsValue = lhs.toStringList(); + const auto rhsValue = rhs.toStringList(); + if (lhsValue == rhsValue) + return 0; + return lhsValue < rhsValue ? -1 : 1; + } else if (lhs.canConvert() && rhs.canConvert()) { + const auto lhsValue = lhs.toInt(); + const auto rhsValue = rhs.toInt(); + if (lhsValue == rhsValue) + return 0; + return lhsValue < rhsValue ? -1 : 1; + } else if (lhs.canConvert() && rhs.canConvert()) { + const auto lhsValue = lhs.toReal(); + const auto rhsValue = rhs.toReal(); + if (qFuzzyCompare(lhsValue, rhsValue)) + return 0; + return lhsValue < rhsValue ? -1 : 1; + } + + qWarning() << "Don't know how to compare" << lhs << "against" << rhs << "- returning 0"; + return 0; +} + +} diff --git a/client/3rd/SortFilterProxyModel/utils/utils.h b/client/3rd/SortFilterProxyModel/utils/utils.h new file mode 100644 index 00000000..199c57be --- /dev/null +++ b/client/3rd/SortFilterProxyModel/utils/utils.h @@ -0,0 +1,17 @@ +#ifndef UTILS_H +#define UTILS_H + +#include + +namespace qqsfpm { + +int compareVariants(const QVariant &lhs, const QVariant &rhs); + +inline bool operator<(const QVariant &lhs, const QVariant &rhs) { return compareVariants(lhs, rhs) < 0; } +inline bool operator<=(const QVariant &lhs, const QVariant &rhs) { return compareVariants(lhs, rhs) <= 0; } +inline bool operator>(const QVariant &lhs, const QVariant &rhs) { return compareVariants(lhs, rhs) > 0; } +inline bool operator>=(const QVariant &lhs, const QVariant &rhs) { return compareVariants(lhs, rhs) >= 0; } + +} + +#endif // UTILS_H diff --git a/client/client.pro b/client/client.pro index 3c1468d5..472f477d 100644 --- a/client/client.pro +++ b/client/client.pro @@ -74,7 +74,7 @@ HEADERS += \ ui/uilogic.h \ ui/qautostart.h \ ui/models/sites_model.h \ - utils.h \ + utilities.h \ vpnconnection.h \ protocols/vpnprotocol.h \ logger.h \ @@ -130,7 +130,7 @@ SOURCES += \ ui/uilogic.cpp \ ui/qautostart.cpp \ ui/models/sites_model.cpp \ - utils.cpp \ + utilities.cpp \ vpnconnection.cpp \ protocols/vpnprotocol.cpp \ logger.cpp \ @@ -171,6 +171,7 @@ win32 { -liphlpapi \ -lgdi32 + QMAKE_LFLAGS_WINDOWS += /entry:mainCRTStartup !contains(QMAKE_TARGET.arch, x86_64) { message("Windows x86 build") @@ -339,15 +340,15 @@ ios { QMAKE_PROVISIONING_PROFILE = f2fefb59-14aa-4aa9-ac14-1d5531b06dcc QMAKE_XCODE_CODE_SIGN_IDENTITY = "Apple Distribution" QMAKE_INFO_PLIST = $$PWD/ios/app/Info.plist - + XCODEBUILD_FLAGS += -allowProvisioningUpdates - + DEFINES += iphoneos - + contains(QT_ARCH, arm64) { message("Building for iOS/ARM v8 64-bit architecture") ARCH_TAG = "ios_armv8_64" - + LIBS += $$PWD/3rd/OpenSSL/lib/ios/iphone/libcrypto.a LIBS += $$PWD/3rd/OpenSSL/lib/ios/iphone/libssl.a } else { @@ -356,15 +357,15 @@ ios { } } # } - + # CONFIG(iphonesimulator, iphoneos|iphonesimulator) { # iphonesimulator { # message("Building for iPhone Simulator") # ARCH_TAG = "ios_x86_64" -# +# # DEFINES += iphonesimulator -# +# # LIBS += $$PWD/3rd/OpenSSL/lib/ios/simulator/libcrypto.a # LIBS += $$PWD/3rd/OpenSSL/lib/ios/simulator/libssl.a # } diff --git a/client/configurators/ikev2_configurator.cpp b/client/configurators/ikev2_configurator.cpp index de9f0e82..c3ee19a1 100644 --- a/client/configurators/ikev2_configurator.cpp +++ b/client/configurators/ikev2_configurator.cpp @@ -13,7 +13,7 @@ #include "core/server_defs.h" #include "containers/containers_defs.h" #include "core/scripts_registry.h" -#include "utils.h" +#include "utilities.h" Ikev2Configurator::ConnectionData Ikev2Configurator::prepareIkev2Config(const ServerCredentials &credentials, DockerContainer container, ErrorCode *errorCode) diff --git a/client/configurators/openvpn_configurator.cpp b/client/configurators/openvpn_configurator.cpp index 3ebfefcc..19d352fc 100644 --- a/client/configurators/openvpn_configurator.cpp +++ b/client/configurators/openvpn_configurator.cpp @@ -10,7 +10,7 @@ #include "core/server_defs.h" #include "containers/containers_defs.h" #include "core/scripts_registry.h" -#include "utils.h" +#include "utilities.h" #include #include diff --git a/client/configurators/ssh_configurator.cpp b/client/configurators/ssh_configurator.cpp index fdece1d6..4a206779 100644 --- a/client/configurators/ssh_configurator.cpp +++ b/client/configurators/ssh_configurator.cpp @@ -12,7 +12,7 @@ #include #include "core/server_defs.h" -#include "utils.h" +#include "utilities.h" using namespace QSsh; @@ -59,7 +59,7 @@ void SshConfigurator::openSshTerminal(const ServerCredentials &credentials) { #ifndef Q_OS_IOS QProcess *p = new QProcess(); - p->setReadChannelMode(QProcess::SeparateChannels); + p->setProcessChannelMode(QProcess::SeparateChannels); #ifdef Q_OS_WIN p->setProcessEnvironment(prepareEnv()); diff --git a/client/configurators/vpn_configurator.cpp b/client/configurators/vpn_configurator.cpp index c2b128f0..edc13c90 100644 --- a/client/configurators/vpn_configurator.cpp +++ b/client/configurators/vpn_configurator.cpp @@ -10,7 +10,7 @@ #include #include "containers/containers_defs.h" -#include "utils.h" +#include "utilities.h" Settings &VpnConfigurator::m_settings() { diff --git a/client/configurators/wireguard_configurator.cpp b/client/configurators/wireguard_configurator.cpp index c7b29ef5..5096f67d 100644 --- a/client/configurators/wireguard_configurator.cpp +++ b/client/configurators/wireguard_configurator.cpp @@ -16,7 +16,7 @@ #include "core/server_defs.h" #include "containers/containers_defs.h" #include "core/scripts_registry.h" -#include "utils.h" +#include "utilities.h" WireguardConfigurator::ConnectionData WireguardConfigurator::genClientKeys() { diff --git a/client/core/servercontroller.cpp b/client/core/servercontroller.cpp index 638e1253..0d2e13f7 100644 --- a/client/core/servercontroller.cpp +++ b/client/core/servercontroller.cpp @@ -19,7 +19,7 @@ #include "containers/containers_defs.h" #include "server_defs.h" #include "scripts_registry.h" -#include "utils.h" +#include "utilities.h" #include @@ -51,7 +51,7 @@ ErrorCode ServerController::runScript(const ServerCredentials &credentials, QStr qDebug() << "Run script"; QString totalLine; - const QStringList &lines = script.split("\n", QString::SkipEmptyParts); + const QStringList &lines = script.split("\n", Qt::SkipEmptyParts); for (int i = 0; i < lines.count(); i++) { QString currentLine = lines.at(i); QString nextLine; diff --git a/client/debug.cpp b/client/debug.cpp index dfdb15dd..f4d6e5e5 100644 --- a/client/debug.cpp +++ b/client/debug.cpp @@ -9,7 +9,7 @@ #include "debug.h" #include "defines.h" -#include "utils.h" +#include "utilities.h" #ifdef AMNEZIA_DESKTOP #include @@ -30,7 +30,7 @@ void debugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons return; } - Debug::m_textStream << qFormatLogMessage(type, context, msg) << endl << flush; + Debug::m_textStream << qFormatLogMessage(type, context, msg) << Qt::endl << Qt::flush; Debug::appendAllLog(qFormatLogMessage(type, context, msg)); std::cout << qFormatLogMessage(type, context, msg).toStdString() << std::endl << std::flush; diff --git a/client/logger.h b/client/logger.h index 87bae4ce..19aeb6f3 100644 --- a/client/logger.h +++ b/client/logger.h @@ -8,6 +8,8 @@ #include "loglevel.h" #include +#include +#include #include constexpr const char* LOG_CAPTIVEPORTAL = "captiveportal"; diff --git a/client/loghandler.cpp b/client/loghandler.cpp index cce3c234..1302f1ca 100644 --- a/client/loghandler.cpp +++ b/client/loghandler.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -74,7 +73,7 @@ void LogHandler::messageHandler(LogLevel logLevel, const QStringList& modules, } // static -LogHandler* LogHandler::maybeCreate(const QMutexLocker& proofOfLock) { +LogHandler* LogHandler::maybeCreate(const QMutexLocker& proofOfLock) { if (!s_instance) { LogLevel minLogLevel = Debug; // TODO: in prod, we should log >= warning QStringList modules; @@ -164,7 +163,7 @@ void LogHandler::enableDebug() { } LogHandler::LogHandler(LogLevel minLogLevel, const QStringList& modules, - const QMutexLocker& proofOfLock) + const QMutexLocker& proofOfLock) : m_minLogLevel(minLogLevel), m_modules(modules) { Q_UNUSED(proofOfLock); @@ -177,7 +176,7 @@ LogHandler::LogHandler(LogLevel minLogLevel, const QStringList& modules, } } -void LogHandler::addLog(const Log& log, const QMutexLocker& proofOfLock) { +void LogHandler::addLog(const Log& log, const QMutexLocker& proofOfLock) { if (!matchLogLevel(log, proofOfLock)) { return; } @@ -212,7 +211,7 @@ void LogHandler::addLog(const Log& log, const QMutexLocker& proofOfLock) { } bool LogHandler::matchModule(const Log& log, - const QMutexLocker& proofOfLock) const { + const QMutexLocker& proofOfLock) const { Q_UNUSED(proofOfLock); // Let's include QT logs always. @@ -235,7 +234,7 @@ bool LogHandler::matchModule(const Log& log, } bool LogHandler::matchLogLevel(const Log& log, - const QMutexLocker& proofOfLock) const { + const QMutexLocker& proofOfLock) const { Q_UNUSED(proofOfLock); return log.m_logLevel >= m_minLogLevel; } @@ -270,7 +269,7 @@ void LogHandler::cleanupLogs() { } // static -void LogHandler::cleanupLogFile(const QMutexLocker& proofOfLock) { +void LogHandler::cleanupLogFile(const QMutexLocker& proofOfLock) { if (!s_instance || !s_instance->m_logFile) { return; } @@ -296,7 +295,7 @@ void LogHandler::setLocation(const QString& path) { } } -void LogHandler::openLogFile(const QMutexLocker& proofOfLock) { +void LogHandler::openLogFile(const QMutexLocker& proofOfLock) { Q_UNUSED(proofOfLock); Q_ASSERT(!m_logFile); Q_ASSERT(!m_output); @@ -333,7 +332,7 @@ void LogHandler::openLogFile(const QMutexLocker& proofOfLock) { proofOfLock); } -void LogHandler::closeLogFile(const QMutexLocker& proofOfLock) { +void LogHandler::closeLogFile(const QMutexLocker& proofOfLock) { Q_UNUSED(proofOfLock); if (m_logFile) { diff --git a/client/loghandler.h b/client/loghandler.h index 653027c8..d853a808 100644 --- a/client/loghandler.h +++ b/client/loghandler.h @@ -10,9 +10,9 @@ #include #include #include +#include class QFile; -class QMutexLocker; class QTextStream; class LogHandler final : public QObject { @@ -76,20 +76,20 @@ class LogHandler final : public QObject { private: LogHandler(LogLevel m_minLogLevel, const QStringList& modules, - const QMutexLocker& proofOfLock); + const QMutexLocker& proofOfLock); - static LogHandler* maybeCreate(const QMutexLocker& proofOfLock); + static LogHandler* maybeCreate(const QMutexLocker& proofOfLock); - void addLog(const Log& log, const QMutexLocker& proofOfLock); + void addLog(const Log& log, const QMutexLocker& proofOfLock); - bool matchLogLevel(const Log& log, const QMutexLocker& proofOfLock) const; - bool matchModule(const Log& log, const QMutexLocker& proofOfLock) const; + bool matchLogLevel(const Log& log, const QMutexLocker& proofOfLock) const; + bool matchModule(const Log& log, const QMutexLocker& proofOfLock) const; - void openLogFile(const QMutexLocker& proofOfLock); + void openLogFile(const QMutexLocker& proofOfLock); - void closeLogFile(const QMutexLocker& proofOfLock); + void closeLogFile(const QMutexLocker& proofOfLock); - static void cleanupLogFile(const QMutexLocker& proofOfLock); + static void cleanupLogFile(const QMutexLocker& proofOfLock); const LogLevel m_minLogLevel; const QStringList m_modules; diff --git a/client/protocols/ikev2_vpn_protocol_windows.cpp b/client/protocols/ikev2_vpn_protocol_windows.cpp index 5e4e5b14..5697776f 100644 --- a/client/protocols/ikev2_vpn_protocol_windows.cpp +++ b/client/protocols/ikev2_vpn_protocol_windows.cpp @@ -8,7 +8,7 @@ #include "debug.h" #include "ikev2_vpn_protocol_windows.h" -#include "utils.h" +#include "utilities.h" static Ikev2Protocol* self = nullptr; static std::mutex rasDialFuncMutex; diff --git a/client/protocols/openvpnovercloakprotocol.cpp b/client/protocols/openvpnovercloakprotocol.cpp index 2e9d77e8..59fc359a 100644 --- a/client/protocols/openvpnovercloakprotocol.cpp +++ b/client/protocols/openvpnovercloakprotocol.cpp @@ -1,7 +1,7 @@ #include "openvpnovercloakprotocol.h" #include "core/servercontroller.h" -#include "utils.h" +#include "utilities.h" #include "containers/containers_defs.h" #include diff --git a/client/protocols/openvpnprotocol.cpp b/client/protocols/openvpnprotocol.cpp index 6adabfb3..6fe20f28 100644 --- a/client/protocols/openvpnprotocol.cpp +++ b/client/protocols/openvpnprotocol.cpp @@ -6,7 +6,7 @@ #include "debug.h" #include "defines.h" -#include "utils.h" +#include "utilities.h" #include "openvpnprotocol.h" @@ -125,9 +125,9 @@ void OpenVpnProtocol::sendManagementCommand(const QString& command) void OpenVpnProtocol::updateRouteGateway(QString line) { // TODO: fix for macos - line = line.split("ROUTE_GATEWAY", QString::SkipEmptyParts).at(1); + line = line.split("ROUTE_GATEWAY", Qt::SkipEmptyParts).at(1); if (!line.contains("/")) return; - m_routeGateway = line.split("/", QString::SkipEmptyParts).first(); + m_routeGateway = line.split("/", Qt::SkipEmptyParts).first(); m_routeGateway.replace(" ", ""); qDebug() << "Set VPN route gateway" << m_routeGateway; } diff --git a/client/protocols/shadowsocksvpnprotocol.cpp b/client/protocols/shadowsocksvpnprotocol.cpp index bc494777..5db84145 100644 --- a/client/protocols/shadowsocksvpnprotocol.cpp +++ b/client/protocols/shadowsocksvpnprotocol.cpp @@ -2,7 +2,7 @@ #include "core/servercontroller.h" #include "debug.h" -#include "utils.h" +#include "utilities.h" #include "containers/containers_defs.h" #include diff --git a/client/protocols/wireguardprotocol.cpp b/client/protocols/wireguardprotocol.cpp index d650cb3f..215f81ae 100644 --- a/client/protocols/wireguardprotocol.cpp +++ b/client/protocols/wireguardprotocol.cpp @@ -7,7 +7,7 @@ #include "debug.h" #include "wireguardprotocol.h" -#include "utils.h" +#include "utilities.h" WireguardProtocol::WireguardProtocol(const QJsonObject &configuration, QObject* parent) : VpnProtocol(configuration, parent) @@ -110,9 +110,9 @@ QString WireguardProtocol::configPath() const void WireguardProtocol::updateRouteGateway(QString line) { // TODO: fix for macos - line = line.split("ROUTE_GATEWAY", QString::SkipEmptyParts).at(1); + line = line.split("ROUTE_GATEWAY", Qt::SkipEmptyParts).at(1); if (!line.contains("/")) return; - m_routeGateway = line.split("/", QString::SkipEmptyParts).first(); + m_routeGateway = line.split("/", Qt::SkipEmptyParts).first(); m_routeGateway.replace(" ", ""); qDebug() << "Set VPN route gateway" << m_routeGateway; } diff --git a/client/settings.cpp b/client/settings.cpp index 317df740..9dea8cc3 100644 --- a/client/settings.cpp +++ b/client/settings.cpp @@ -1,6 +1,6 @@ #include "defines.h" #include "settings.h" -#include "utils.h" +#include "utilities.h" #include #include "containers/containers_defs.h" diff --git a/client/ui/framelesswindow.cpp b/client/ui/framelesswindow.cpp index 7f62df9a..489ea134 100644 --- a/client/ui/framelesswindow.cpp +++ b/client/ui/framelesswindow.cpp @@ -104,7 +104,7 @@ void CFramelessWindow::addIgnoreWidget(QWidget* widget) bool CFramelessWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) { if (QOperatingSystemVersion::current() <= QOperatingSystemVersion::Windows7) { - return QMainWindow::nativeEvent(eventType, message, result); + return QMainWindow::nativeEvent(eventType, message, reinterpret_cast(result)); } //Workaround for known bug -> check Qt forum : https://forum.qt.io/topic/93141/qtablewidget-itemselectionchanged/13 @@ -252,7 +252,7 @@ bool CFramelessWindow::nativeEvent(const QByteArray &eventType, void *message, l return false; } default: - return QMainWindow::nativeEvent(eventType, message, result); + return QMainWindow::nativeEvent(eventType, message, reinterpret_cast(result)); } } @@ -280,7 +280,7 @@ QMargins CFramelessWindow::contentsMargins() const } void CFramelessWindow::getContentsMargins(int *left, int *top, int *right, int *bottom) const { - QMainWindow::getContentsMargins(left,top,right,bottom); + getContentsMargins(left,top,right,bottom); if (!(left&&top&&right&&bottom)) return; if (isMaximized()) { diff --git a/client/ui/pages_logic/NetworkSettingsLogic.cpp b/client/ui/pages_logic/NetworkSettingsLogic.cpp index bd593e3a..6b85b89a 100644 --- a/client/ui/pages_logic/NetworkSettingsLogic.cpp +++ b/client/ui/pages_logic/NetworkSettingsLogic.cpp @@ -1,7 +1,7 @@ #include "NetworkSettingsLogic.h" #include "defines.h" -#include "utils.h" +#include "utilities.h" NetworkSettingsLogic::NetworkSettingsLogic(UiLogic *logic, QObject *parent): PageLogicBase(logic, parent), @@ -21,14 +21,14 @@ void NetworkSettingsLogic::onUpdatePage() void NetworkSettingsLogic::onLineEditDns1EditFinished(const QString &text) { - if (ipAddressRegex().exactMatch(text)) { + if (ipAddressRegex().match(text).hasMatch()) { m_settings.setPrimaryDns(text); } } void NetworkSettingsLogic::onLineEditDns2EditFinished(const QString &text) { - if (ipAddressRegex().exactMatch(text)) { + if (ipAddressRegex().match(text).hasMatch()) { m_settings.setSecondaryDns(text); } } diff --git a/client/ui/pages_logic/NetworkSettingsLogic.h b/client/ui/pages_logic/NetworkSettingsLogic.h index b70bc143..b1a32275 100644 --- a/client/ui/pages_logic/NetworkSettingsLogic.h +++ b/client/ui/pages_logic/NetworkSettingsLogic.h @@ -13,7 +13,7 @@ class NetworkSettingsLogic : public PageLogicBase AUTO_PROPERTY(QString, lineEditDns1Text) AUTO_PROPERTY(QString, lineEditDns2Text) - READONLY_PROPERTY(QRegExp, ipAddressRegex) + READONLY_PROPERTY(QRegularExpression, ipAddressRegex) public: Q_INVOKABLE void onUpdatePage() override; diff --git a/client/ui/pages_logic/ShareConnectionLogic.cpp b/client/ui/pages_logic/ShareConnectionLogic.cpp index 038b3891..80d98dc4 100644 --- a/client/ui/pages_logic/ShareConnectionLogic.cpp +++ b/client/ui/pages_logic/ShareConnectionLogic.cpp @@ -6,7 +6,7 @@ #include "QZXing.h" #include "QZXingImageProvider.h" -#include "QZXingFilter.h" +//#include "QZXingFilter.h" #include "ShareConnectionLogic.h" diff --git a/client/ui/pages_logic/SitesLogic.cpp b/client/ui/pages_logic/SitesLogic.cpp index 8b94155f..83f712ea 100644 --- a/client/ui/pages_logic/SitesLogic.cpp +++ b/client/ui/pages_logic/SitesLogic.cpp @@ -5,7 +5,7 @@ #include "SitesLogic.h" #include "VpnLogic.h" -#include "utils.h" +#include "utilities.h" #include "vpnconnection.h" #include @@ -56,7 +56,7 @@ void SitesLogic::onPushButtonAddCustomSitesClicked() newSite.replace("http://", ""); newSite.replace("ftp://", ""); - newSite = newSite.split("/", QString::SkipEmptyParts).first(); + newSite = newSite.split("/", Qt::SkipEmptyParts).first(); } const auto &cbProcess = [this, mode](const QString &newSite, const QString &ip) { diff --git a/client/ui/pages_logic/StartPageLogic.cpp b/client/ui/pages_logic/StartPageLogic.cpp index e8b3f269..57966fb1 100644 --- a/client/ui/pages_logic/StartPageLogic.cpp +++ b/client/ui/pages_logic/StartPageLogic.cpp @@ -2,7 +2,7 @@ #include "core/errorstrings.h" #include "configurators/ssh_configurator.h" #include "../uilogic.h" -#include "utils.h" +#include "utilities.h" #include #include @@ -200,7 +200,7 @@ bool StartPageLogic::importConnectionFromCode(QString code) return importConnection(o); } - o = QJsonDocument::fromBinaryData(ba).object(); + o = QJsonDocument::fromJson(ba).object(); if (!o.isEmpty()) { return importConnection(o); } diff --git a/client/ui/pages_logic/StartPageLogic.h b/client/ui/pages_logic/StartPageLogic.h index f5f132f8..49e95047 100644 --- a/client/ui/pages_logic/StartPageLogic.h +++ b/client/ui/pages_logic/StartPageLogic.h @@ -3,6 +3,8 @@ #include "PageLogicBase.h" +#include + class UiLogic; class StartPageLogic : public PageLogicBase @@ -22,7 +24,7 @@ class StartPageLogic : public PageLogicBase AUTO_PROPERTY(bool, pushButtonBackFromStartVisible) AUTO_PROPERTY(bool, pushButtonConnectVisible) - READONLY_PROPERTY(QRegExp, ipAddressPortRegex) + READONLY_PROPERTY(QRegularExpression, ipAddressPortRegex) public: Q_INVOKABLE void onUpdatePage() override; diff --git a/client/ui/pages_logic/protocols/OtherProtocolsLogic.cpp b/client/ui/pages_logic/protocols/OtherProtocolsLogic.cpp index 8cf3949f..908be509 100644 --- a/client/ui/pages_logic/protocols/OtherProtocolsLogic.cpp +++ b/client/ui/pages_logic/protocols/OtherProtocolsLogic.cpp @@ -8,7 +8,7 @@ #include "core/servercontroller.h" #include #include "../../uilogic.h" -#include "utils.h" +#include "utilities.h" #ifdef Q_OS_WINDOWS #include @@ -147,7 +147,7 @@ void OtherProtocolsLogic::onPushButtonSftpMountDriveClicked() //#ifndef Q_OS_WIN // args.replace("reconnect-orellinks", ""); //#endif - p->setArguments(args.split(" ", QString::SkipEmptyParts)); + p->setArguments(args.split(" ", Qt::SkipEmptyParts)); p->start(); p->waitForStarted(50); if (p->state() != QProcess::Running) { diff --git a/client/ui/qml/main.qml b/client/ui/qml/main.qml index 11b9d26a..50bc9c21 100644 --- a/client/ui/qml/main.qml +++ b/client/ui/qml/main.qml @@ -7,7 +7,7 @@ import PageEnum 1.0 import PageType 1.0 import Qt.labs.platform 1.1 import Qt.labs.folderlistmodel 2.12 -import QtQuick.Dialogs 1.1 +import QtQuick.Dialogs import "./" import "Controls" import "Pages" @@ -263,10 +263,10 @@ Window { // y: (root.height - height) / 2 title: qsTr("Exit") text: qsTr("Do you really want to quit?") - standardButtons: StandardButton.Yes | StandardButton.No - onYes: { - Qt.quit() - } +// standardButtons: StandardButton.Yes | StandardButton.No +// onYesClicked: { +// Qt.quit() +// } visible: false } MessageDialog { diff --git a/client/ui/uilogic.cpp b/client/ui/uilogic.cpp index fe2d541d..39fbc50b 100644 --- a/client/ui/uilogic.cpp +++ b/client/ui/uilogic.cpp @@ -36,7 +36,7 @@ #include "debug.h" #include "defines.h" #include "uilogic.h" -#include "utils.h" +#include "utilities.h" #include "vpnconnection.h" #include diff --git a/client/ui/uilogic.h b/client/ui/uilogic.h index 4e818bcc..7a535270 100644 --- a/client/ui/uilogic.h +++ b/client/ui/uilogic.h @@ -1,7 +1,7 @@ #ifndef UILOGIC_H #define UILOGIC_H -#include +#include #include #include #include diff --git a/client/utils.cpp b/client/utilities.cpp similarity index 96% rename from client/utils.cpp rename to client/utilities.cpp index 046d582c..4223014e 100644 --- a/client/utils.cpp +++ b/client/utilities.cpp @@ -5,10 +5,11 @@ #include #include #include +#include #include #include "defines.h" -#include "utils.h" +#include "utilities.h" QString Utils::getRandomString(int len) { @@ -86,7 +87,7 @@ bool Utils::processIsRunning(const QString& fileName) process.waitForStarted(); process.waitForFinished(); QString processData(process.readAll()); - QStringList processList = processData.split(QRegExp("[\r\n]"),QString::SkipEmptyParts); + QStringList processList = processData.split(QRegularExpression("[\r\n]"),Qt::SkipEmptyParts); foreach (const QString& rawLine, processList) { const QString line = rawLine.simplified(); if (line.isEmpty()) { @@ -115,7 +116,7 @@ bool Utils::processIsRunning(const QString& fileName) QString Utils::getIPAddress(const QString& host) { - if (ipAddressRegExp().exactMatch(host)) { + if (ipAddressRegExp().match(host).hasMatch()) { return host; } @@ -165,6 +166,7 @@ bool Utils::checkIpSubnetFormat(const QString &ip) void Utils::killProcessByName(const QString &name) { qDebug().noquote() << "Kill process" << name; + qDebug() << "Hello"; #ifdef Q_OS_WIN QProcess::execute(QString("taskkill /im %1 /f").arg(name)); #elif defined Q_OS_IOS diff --git a/client/utils.h b/client/utilities.h similarity index 81% rename from client/utils.h rename to client/utilities.h index ff5c5e8c..43c7d2fb 100644 --- a/client/utils.h +++ b/client/utilities.h @@ -1,14 +1,16 @@ -#ifndef UTILS_H -#define UTILS_H +#ifndef UTILITIES_H +#define UTILITIES_H #include #include +#include #ifdef Q_OS_WIN #include "Windows.h" #endif -class Utils { +class Utils : public QObject { + Q_OBJECT public: static QString getRandomString(int len); @@ -23,8 +25,8 @@ public: static QString getStringBetween(const QString& s, const QString& a, const QString& b); static bool checkIPv4Format(const QString& ip); static bool checkIpSubnetFormat(const QString& ip); - static QRegExp ipAddressRegExp() { return QRegExp("^((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\\.(?!$)|$)){4}$"); } - static QRegExp ipAddressPortRegExp() { return QRegExp("^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}" + static QRegularExpression ipAddressRegExp() { return QRegularExpression("^((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\\.(?!$)|$)){4}$"); } + static QRegularExpression ipAddressPortRegExp() { return QRegularExpression("^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}" "(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])(\\:[0-9]{1,5}){0,1}$"); } static QRegExp ipAddressWithSubnetRegExp() { return QRegExp("(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}" @@ -49,4 +51,4 @@ public: #endif }; -#endif // UTILS_H +#endif // UTILITIES_H diff --git a/client/vpnconnection.cpp b/client/vpnconnection.cpp index d2461b07..d848f4c2 100644 --- a/client/vpnconnection.cpp +++ b/client/vpnconnection.cpp @@ -26,7 +26,7 @@ #include #endif -#include "utils.h" +#include "utilities.h" #include "vpnconnection.h" VpnConnection::VpnConnection(QObject* parent) : QObject(parent), diff --git a/service/server/localserver.cpp b/service/server/localserver.cpp index f94d2dca..9971ad43 100644 --- a/service/server/localserver.cpp +++ b/service/server/localserver.cpp @@ -5,7 +5,7 @@ #include "ipc.h" #include "localserver.h" -#include "utils.h" +#include "utilities.h" #include "router.h" diff --git a/service/server/log.cpp b/service/server/log.cpp index 978a6aff..a5d56ae5 100644 --- a/service/server/log.cpp +++ b/service/server/log.cpp @@ -5,7 +5,7 @@ #include "log.h" #include "defines.h" -#include "utils.h" +#include "utilities.h" QFile Log::m_file; QTextStream Log::m_textStream; @@ -17,7 +17,7 @@ void debugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons return; } - Log::m_textStream << qFormatLogMessage(type, context, msg) << endl << flush; + Log::m_textStream << qFormatLogMessage(type, context, msg) << Qt::endl << Qt::flush; std::cout << qFormatLogMessage(type, context, msg).toStdString() << std::endl << std::flush; } diff --git a/service/server/main.cpp b/service/server/main.cpp index 9f15195c..6908a9d8 100644 --- a/service/server/main.cpp +++ b/service/server/main.cpp @@ -4,7 +4,7 @@ #include "localserver.h" #include "log.h" #include "systemservice.h" -#include "utils.h" +#include "utilities.h" int runApplication(int argc, char** argv) diff --git a/service/server/router_linux.cpp b/service/server/router_linux.cpp index 0ec6250f..169e9475 100644 --- a/service/server/router_linux.cpp +++ b/service/server/router_linux.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include diff --git a/service/server/router_mac.cpp b/service/server/router_mac.cpp index 13b9d448..6de6b99d 100644 --- a/service/server/router_mac.cpp +++ b/service/server/router_mac.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include RouterMac &RouterMac::Instance() { diff --git a/service/server/router_win.cpp b/service/server/router_win.cpp index df431805..0c771f7c 100644 --- a/service/server/router_win.cpp +++ b/service/server/router_win.cpp @@ -1,5 +1,5 @@ #include "router_win.h" -#include "../client/utils.h" +#include "../client/utilities.h" #include #include diff --git a/service/server/server.pro b/service/server/server.pro index e34eb8f4..0d3ecd2a 100644 --- a/service/server/server.pro +++ b/service/server/server.pro @@ -5,7 +5,7 @@ QT += core network remoteobjects equals(QT_MAJOR_VERSION, 6): QT += core5compat HEADERS = \ - ../../client/utils.h \ + ../../client/utilities.h \ ../../ipc/ipc.h \ ../../ipc/ipcserver.h \ ../../ipc/ipcserverprocess.h \ @@ -15,7 +15,7 @@ HEADERS = \ systemservice.h SOURCES = \ - ../../client/utils.cpp \ + ../../client/utilities.cpp \ ../../ipc/ipcserver.cpp \ ../../ipc/ipcserverprocess.cpp \ localserver.cpp \ diff --git a/service/server/tapcontroller_win.cpp b/service/server/tapcontroller_win.cpp index b388997a..fca86d71 100644 --- a/service/server/tapcontroller_win.cpp +++ b/service/server/tapcontroller_win.cpp @@ -87,12 +87,12 @@ QStringList TapController::getTapList() return QStringList(); } - QStringList l = output.split("\n", QString::SkipEmptyParts); + QStringList l = output.split("\n", Qt::SkipEmptyParts); if (l.size() > 0) l.removeLast(); QStringList tapList; for (QString s : l) { - if (s.contains(" ")) tapList.append(s.split(" ", QString::SkipEmptyParts).first()); + if (s.contains(" ")) tapList.append(s.split(" ", Qt::SkipEmptyParts).first()); else tapList.append(s); } diff --git a/service/src/qtservice.cpp b/service/src/qtservice.cpp index 5eae058e..fcae9a12 100644 --- a/service/src/qtservice.cpp +++ b/service/src/qtservice.cpp @@ -663,7 +663,7 @@ QtServiceBase::QtServiceBase(int argc, char **argv, const QString &name) d_ptr = new QtServiceBasePrivate(nm); d_ptr->q_ptr = this; - d_ptr->serviceFlags = 0; + d_ptr->serviceFlags = QtServiceBase::Default; d_ptr->sysd = 0; for (int i = 0; i < argc; ++i) d_ptr->args.append(QString::fromLocal8Bit(argv[i])); diff --git a/service/src/qtservice.h b/service/src/qtservice.h index 01d5b07f..4fb3c3c4 100644 --- a/service/src/qtservice.h +++ b/service/src/qtservice.h @@ -59,7 +59,7 @@ # define QT_QTSERVICE_EXPORT #endif -class QStringList; +//class QStringList; class QtServiceControllerPrivate; class QT_QTSERVICE_EXPORT QtServiceController diff --git a/service/src/qtservice_win.cpp b/service/src/qtservice_win.cpp index e5b7ecc5..c48194b2 100644 --- a/service/src/qtservice_win.cpp +++ b/service/src/qtservice_win.cpp @@ -737,10 +737,10 @@ class QtServiceAppEventFilter : public QAbstractNativeEventFilter { public: QtServiceAppEventFilter() {} - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result); + bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result); }; -bool QtServiceAppEventFilter::nativeEventFilter(const QByteArray &, void *message, long *result) +bool QtServiceAppEventFilter::nativeEventFilter(const QByteArray &, void *message, qintptr *result) { MSG *winMessage = (MSG*)message; if (winMessage->message == WM_ENDSESSION && (winMessage->lParam & ENDSESSION_LOGOFF)) {