├── examples
├── CMakeLists.txt
├── orm
│ ├── CMakeLists.txt
│ ├── orm.pro
│ ├── navigationdb
│ │ ├── marker.png
│ │ ├── navigationdb.qrc
│ │ ├── navigationdb-qt6.qrc
│ │ ├── qtorm.json
│ │ ├── navigationdb.qbs
│ │ ├── navigationdb.pro
│ │ ├── CMakeLists.txt
│ │ └── domain
│ │ │ ├── province.h
│ │ │ ├── province.cpp
│ │ │ ├── community.h
│ │ │ └── community.cpp
│ └── orm.qbs
├── examples.pro
└── examples.qbs
├── src
├── src.pro
├── src.qbs
├── orm
│ ├── qormqueryresult.cpp
│ ├── qormabstractprovider.cpp
│ ├── qormorder.cpp
│ ├── doc
│ │ └── qtorm.qdocconf
│ ├── qormfilter.cpp
│ ├── qormmetadata_p.h
│ ├── qormerror.cpp
│ ├── qormorder.h
│ ├── orm.pro
│ ├── qormclassproperty.h
│ ├── qormentitylistmodel.cpp
│ ├── qormerror.h
│ ├── qormrelation.h
│ ├── qormtransactiontoken.h
│ ├── qormclassproperty.cpp
│ ├── qormentityinstancecache.h
│ ├── qormsqliteconfiguration.cpp
│ ├── qormabstractprovider.h
│ ├── qormmetadatacache.h
│ ├── qormsqliteconfiguration.h
│ ├── qormsessionconfiguration.h
│ ├── qormfilter.h
│ ├── qormmetadata.h
│ ├── qormtransactiontoken.cpp
│ ├── qormsqliteprovider.h
│ ├── qormpropertymapping.h
│ ├── qormquery.h
│ ├── qormrelation.cpp
│ ├── qormmetadata.cpp
│ ├── qormentityinstancecache.cpp
│ ├── qormsession.h
│ ├── orm.qbs
│ └── qormquerybuilder.h
└── CMakeLists.txt
├── tests
├── auto
│ ├── qormqueryresult
│ │ ├── domain
│ │ │ ├── person.cpp
│ │ │ └── person.h
│ │ ├── queryresult.qrc
│ │ ├── CMakeLists.txt
│ │ ├── qtorm.json
│ │ └── tst_queryresult.cpp
│ ├── qormentitylistmodel
│ │ ├── resource.qrc
│ │ ├── qtorm.json
│ │ ├── CMakeLists.txt
│ │ ├── qormentitylistmodel.pro
│ │ ├── qormentitylistmodel.qbs
│ │ ├── domain
│ │ │ ├── province.cpp
│ │ │ ├── town.cpp
│ │ │ ├── town.h
│ │ │ └── province.h
│ │ └── tst_qormentitylistmodel.cpp
│ ├── qormfilterexpression
│ │ ├── CMakeLists.txt
│ │ ├── qormfilterexpression.pro
│ │ └── qormfilterexpression.qbs
│ ├── cmake
│ │ ├── cmake.pro
│ │ ├── CMakeLists.txt
│ │ └── qtorm_add_unit_test.cmake
│ ├── domainclasses
│ │ ├── CMakeLists.txt
│ │ ├── domainclasses.qrc
│ │ ├── qtorm.json
│ │ ├── domainclasses.pro
│ │ ├── qtorm_bypass_schema.json
│ │ └── domainclasses.qbs
│ ├── qormsession
│ │ ├── qtorm.json
│ │ ├── qtorm_append_schema.json
│ │ ├── qtorm_bypass_schema.json
│ │ ├── qtorm_update_schema.json
│ │ ├── ormsession.qrc
│ │ ├── CMakeLists.txt
│ │ ├── qormsession.pro
│ │ ├── qormsession.qbs
│ │ └── domain
│ │ │ ├── province.cpp
│ │ │ ├── town.cpp
│ │ │ ├── town.h
│ │ │ ├── province.h
│ │ │ ├── person.cpp
│ │ │ └── person.h
│ ├── auto.pro
│ ├── qormentityinstancecache
│ │ ├── CMakeLists.txt
│ │ ├── qormentityinstancecache.pro
│ │ ├── qormentityinstancecache.qbs
│ │ ├── domain
│ │ │ ├── province.cpp
│ │ │ ├── town.cpp
│ │ │ ├── town.h
│ │ │ └── province.h
│ │ └── tst_entityinstancecache.cpp
│ ├── qormmetadatacache
│ │ ├── CMakeLists.txt
│ │ ├── qormmetadatacache.pro
│ │ ├── qormmetadatacache.qbs
│ │ └── domain
│ │ │ ├── person.cpp
│ │ │ ├── province.cpp
│ │ │ ├── province.h
│ │ │ ├── town.cpp
│ │ │ ├── person.h
│ │ │ ├── town.h
│ │ │ ├── withenum.cpp
│ │ │ └── withenum.h
│ ├── CMakeLists.txt
│ ├── auto.qbs
│ └── qormsqlitestatementgenerator
│ │ ├── CMakeLists.txt
│ │ ├── qormsqlitestatementgenerator.pro
│ │ ├── qormsqlitestatementgenerator.qbs
│ │ └── domain
│ │ ├── community.cpp
│ │ ├── person.cpp
│ │ ├── province.cpp
│ │ ├── withqvariant.cpp
│ │ ├── person.h
│ │ ├── withqvariant.h
│ │ ├── town.cpp
│ │ ├── town.h
│ │ ├── withenum.cpp
│ │ ├── province.h
│ │ ├── withenum.h
│ │ └── community.h
├── tests.pro
├── CMakeLists.txt
└── tests.qbs
├── qws19.pdf
├── sync.profile
├── .qmake.conf
├── qtorm.pro
├── configure.json
├── cmake
├── ExtractClassNames.cmake
├── GetGeneratedHeaders.cmake
└── GenerateHeaders.cmake
├── .gitignore
├── .github
└── workflows
│ ├── qmake.yml
│ ├── qbs-linux.yml
│ ├── cmake-linux.yml
│ └── cmake-windows.yml
├── qtorm.qbs
├── _clang-format
└── CMakeLists.txt
/examples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory(orm)
2 |
--------------------------------------------------------------------------------
/src/src.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = subdirs
2 |
3 | SUBDIRS += orm
--------------------------------------------------------------------------------
/examples/orm/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory(navigationdb)
2 |
--------------------------------------------------------------------------------
/tests/auto/qormqueryresult/domain/person.cpp:
--------------------------------------------------------------------------------
1 | #include "person.h"
--------------------------------------------------------------------------------
/examples/orm/orm.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = subdirs
2 | SUBDIRS += navigationdb
--------------------------------------------------------------------------------
/qws19.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dpurgin/qtorm/HEAD/qws19.pdf
--------------------------------------------------------------------------------
/sync.profile:
--------------------------------------------------------------------------------
1 | %modules = (
2 | "QtOrm" => "$basedir/src/orm",
3 | );
4 |
--------------------------------------------------------------------------------
/tests/tests.pro:
--------------------------------------------------------------------------------
1 | requires(qtHaveModule(orm))
2 |
3 | TEMPLATE = subdirs
4 | SUBDIRS += auto
5 |
--------------------------------------------------------------------------------
/examples/examples.pro:
--------------------------------------------------------------------------------
1 | requires(qtHaveModule(orm))
2 |
3 | TEMPLATE = subdirs
4 | SUBDIRS += orm
5 |
--------------------------------------------------------------------------------
/src/src.qbs:
--------------------------------------------------------------------------------
1 | import qbs
2 |
3 | Project {
4 | references: [
5 | "orm/orm.qbs",
6 | ]
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/examples/examples.qbs:
--------------------------------------------------------------------------------
1 | import qbs
2 |
3 | Project {
4 | references: [
5 | "orm/orm.qbs",
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/examples/orm/navigationdb/marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dpurgin/qtorm/HEAD/examples/orm/navigationdb/marker.png
--------------------------------------------------------------------------------
/tests/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | find_package(Qt${QTORM_QT_VERSION_MAJOR} COMPONENTS Test REQUIRED)
2 |
3 | add_subdirectory(auto)
4 |
--------------------------------------------------------------------------------
/tests/tests.qbs:
--------------------------------------------------------------------------------
1 | import qbs
2 |
3 | Project {
4 | references: [
5 | "auto/auto.qbs",
6 | ]
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/examples/orm/orm.qbs:
--------------------------------------------------------------------------------
1 | import qbs
2 |
3 | Project {
4 | references: [
5 | "navigationdb/navigationdb.qbs",
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/.qmake.conf:
--------------------------------------------------------------------------------
1 | load(qt_build_config)
2 |
3 | CONFIG += warning_clean
4 | DEFINES += QT_NO_FOREACH
5 |
6 | MODULE_VERSION = $${QT_VERSION}
7 |
--------------------------------------------------------------------------------
/tests/auto/qormentitylistmodel/resource.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | qtorm.json
4 |
5 |
6 |
--------------------------------------------------------------------------------
/tests/auto/qormfilterexpression/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | qtorm_add_unit_test(NAME tst_ormfilterexpression SOURCES
2 | tst_ormfilterexpression.cpp
3 | )
4 |
--------------------------------------------------------------------------------
/tests/auto/cmake/cmake.pro:
--------------------------------------------------------------------------------
1 | # Cause make to do nothing.
2 | TEMPLATE = subdirs
3 |
4 | CMAKE_QT_MODULES_UNDER_TEST = orm
5 |
6 | CONFIG += ctest_testcase
7 |
--------------------------------------------------------------------------------
/tests/auto/domainclasses/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | qtorm_add_unit_test(NAME tst_domainclasses SOURCES
2 | tst_domainclasses.cpp
3 |
4 | domainclasses.qrc
5 | )
6 |
--------------------------------------------------------------------------------
/tests/auto/qormqueryresult/queryresult.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | qtorm.json
4 |
5 |
6 |
--------------------------------------------------------------------------------
/tests/auto/domainclasses/domainclasses.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | qtorm.json
4 | qtorm_bypass_schema.json
5 |
6 |
7 |
--------------------------------------------------------------------------------
/tests/auto/qormqueryresult/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | qtorm_add_unit_test(NAME tst_queryresult SOURCES
2 | tst_queryresult.cpp
3 |
4 | domain/person.cpp
5 | domain/person.h
6 |
7 | queryresult.qrc
8 | )
9 |
--------------------------------------------------------------------------------
/examples/orm/navigationdb/navigationdb.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | qtorm.json
4 | main.qml
5 | marker.png
6 |
7 |
8 |
--------------------------------------------------------------------------------
/tests/auto/qormfilterexpression/qormfilterexpression.pro:
--------------------------------------------------------------------------------
1 | QT = core testlib orm
2 |
3 | CONFIG += testcase warn_on silent c++17
4 |
5 | TARGET = tst_ormfilterexpression
6 |
7 | SOURCES += tst_ormfilterexpression.cpp
8 |
9 |
--------------------------------------------------------------------------------
/examples/orm/navigationdb/navigationdb-qt6.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | qtorm.json
4 | main-qt6.qml
5 | marker.png
6 |
7 |
8 |
--------------------------------------------------------------------------------
/tests/auto/qormsession/qtorm.json:
--------------------------------------------------------------------------------
1 | {
2 | "provider": "sqlite",
3 | "verbose": true,
4 | "sqlite": {
5 | "databaseName": "testdb.db",
6 | "schemaMode": "recreate",
7 | "verbose": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/tests/auto/auto.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = subdirs
2 |
3 | SUBDIRS += \
4 | domainclasses \
5 | qormentityinstancecache \
6 | qormmetadatacache \
7 | qormsession \
8 | qormfilterexpression \
9 | qormsqlitestatementgenerator
10 |
--------------------------------------------------------------------------------
/tests/auto/domainclasses/qtorm.json:
--------------------------------------------------------------------------------
1 | {
2 | "provider": "sqlite",
3 | "verbose": true,
4 | "sqlite": {
5 | "databaseName": "testdb.db",
6 | "schemaMode": "recreate",
7 | "verbose": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/tests/auto/qormqueryresult/qtorm.json:
--------------------------------------------------------------------------------
1 | {
2 | "provider": "sqlite",
3 | "verbose": true,
4 | "sqlite": {
5 | "databaseName": "testdb.db",
6 | "schemaMode": "recreate",
7 | "verbose": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/tests/auto/qormentityinstancecache/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | qtorm_add_unit_test(NAME tst_entityinstancecache SOURCES
2 | tst_entityinstancecache.cpp
3 | domain/province.cpp
4 | domain/town.cpp
5 |
6 | domain/province.h
7 | domain/town.h
8 | )
9 |
--------------------------------------------------------------------------------
/tests/auto/qormentitylistmodel/qtorm.json:
--------------------------------------------------------------------------------
1 | {
2 | "provider": "sqlite",
3 | "verbose": true,
4 | "sqlite": {
5 | "databaseName": ":memory:",
6 | "schemaMode": "recreate",
7 | "verbose": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/examples/orm/navigationdb/qtorm.json:
--------------------------------------------------------------------------------
1 | {
2 | "provider": "sqlite",
3 | "verbose": true,
4 | "sqlite": {
5 | "databaseName": "navigationdb.db",
6 | "verbose": true,
7 | "schemaMode": "recreate"
8 | }
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/tests/auto/domainclasses/domainclasses.pro:
--------------------------------------------------------------------------------
1 | QT = core testlib orm orm-private
2 |
3 | CONFIG += testcase warn_on silent c++17
4 |
5 | TARGET = tst_domainclasses
6 |
7 | SOURCES += tst_domainclasses.cpp \
8 |
9 | RESOURCES += domainclasses.qrc
10 |
--------------------------------------------------------------------------------
/tests/auto/domainclasses/qtorm_bypass_schema.json:
--------------------------------------------------------------------------------
1 | {
2 | "provider": "sqlite",
3 | "verbose": true,
4 | "sqlite": {
5 | "databaseName": "testdb.db",
6 | "schemaMode": "bypass",
7 | "verbose": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/tests/auto/qormsession/qtorm_append_schema.json:
--------------------------------------------------------------------------------
1 | {
2 | "provider": "sqlite",
3 | "verbose": true,
4 | "sqlite": {
5 | "databaseName": "testdb.db",
6 | "schemaMode": "append",
7 | "verbose": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/tests/auto/qormsession/qtorm_bypass_schema.json:
--------------------------------------------------------------------------------
1 | {
2 | "provider": "sqlite",
3 | "verbose": true,
4 | "sqlite": {
5 | "databaseName": "testdb.db",
6 | "schemaMode": "bypass",
7 | "verbose": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/tests/auto/qormsession/qtorm_update_schema.json:
--------------------------------------------------------------------------------
1 | {
2 | "provider": "sqlite",
3 | "verbose": true,
4 | "sqlite": {
5 | "databaseName": "testdb.db",
6 | "schemaMode": "update",
7 | "verbose": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/qtorm.pro:
--------------------------------------------------------------------------------
1 | requires(qtHaveModule(sql))
2 |
3 | lessThan(QT_MAJOR_VERSION, 5) {
4 | message("Cannot build current QtOrm sources with Qt version $${QT_VERSION}.")
5 | }
6 |
7 | QTORM_BUILD_PARTS = libs tests examples
8 |
9 | load(configure)
10 | load(qt_parts)
11 |
--------------------------------------------------------------------------------
/tests/auto/cmake/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | cmake_minimum_required(VERSION 2.8)
3 |
4 | project(qmake_cmake_files)
5 |
6 | enable_testing()
7 |
8 | find_package(Qt5Core REQUIRED)
9 |
10 | include("${_Qt5CTestMacros}")
11 |
12 | test_module_includes(
13 | Orm
14 | )
15 |
--------------------------------------------------------------------------------
/tests/auto/qormentitylistmodel/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | qtorm_add_unit_test(NAME tst_ormentitylistmodel SOURCES
2 | tst_qormentitylistmodel.cpp
3 |
4 | domain/province.cpp
5 | domain/town.cpp
6 |
7 | domain/province.h
8 | domain/town.h
9 |
10 | resource.qrc
11 | )
12 |
--------------------------------------------------------------------------------
/tests/auto/qormsession/ormsession.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | qtorm.json
4 | qtorm_bypass_schema.json
5 | qtorm_update_schema.json
6 | qtorm_append_schema.json
7 |
8 |
9 |
--------------------------------------------------------------------------------
/tests/auto/qormmetadatacache/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | qtorm_add_unit_test(NAME tst_metadatacachetest SOURCES
2 | tst_metadatacachetest.cpp
3 |
4 | domain/person.cpp
5 | domain/province.cpp
6 | domain/town.cpp
7 | domain/withenum.cpp
8 |
9 | domain/person.h
10 | domain/province.h
11 | domain/town.h
12 | domain/withenum.h
13 | )
--------------------------------------------------------------------------------
/tests/auto/domainclasses/domainclasses.qbs:
--------------------------------------------------------------------------------
1 | import qbs
2 |
3 | QtApplication {
4 | name: "tst_domainclasses"
5 | type: ["application", "autotest"]
6 | cpp.cxxLanguageVersion: "c++17"
7 | Depends { name: "Qt"; submodules: ["core", "test"] }
8 | Depends { name: "QtOrm" }
9 | files: ["tst_domainclasses.cpp", "domainclasses.qrc"]
10 | }
11 |
--------------------------------------------------------------------------------
/tests/auto/qormfilterexpression/qormfilterexpression.qbs:
--------------------------------------------------------------------------------
1 | import qbs
2 |
3 | QtApplication {
4 | name: "tst_ormfilterexpression"
5 | type: ["application", "autotest"]
6 | cpp.cxxLanguageVersion: "c++17"
7 | Depends { name: "Qt"; submodules: ["core", "test"] }
8 | Depends { name: "QtOrm" }
9 | files: ["tst_ormfilterexpression.cpp"]
10 | }
11 |
--------------------------------------------------------------------------------
/tests/auto/qormsession/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | qtorm_add_unit_test(NAME tst_ormsession SOURCES
2 | tst_ormsession.cpp
3 |
4 | domain/person.cpp
5 | domain/province.cpp
6 | domain/town.cpp
7 |
8 | domain/person.h
9 | domain/province.h
10 | domain/town.h
11 |
12 | ormsession.qrc
13 |
14 | LINK_LIBRARIES Qt${QTORM_QT_VERSION_MAJOR}::Sql
15 | )
16 |
17 |
--------------------------------------------------------------------------------
/tests/auto/qormentitylistmodel/qormentitylistmodel.pro:
--------------------------------------------------------------------------------
1 | QT = core testlib orm
2 |
3 | CONFIG += testcase warn_on silent c++17
4 |
5 | TARGET = tst_ormentitylistmodel
6 |
7 | SOURCES += tst_ormentitylistmodel.cpp \
8 | domain/province.cpp \
9 | domain/town.cpp \
10 |
11 | HEADERS += \
12 | domain/province.h \
13 | domain/town.h \
14 |
15 | RESOURCES += resource.qrc
16 |
--------------------------------------------------------------------------------
/tests/auto/qormentityinstancecache/qormentityinstancecache.pro:
--------------------------------------------------------------------------------
1 | QT += testlib orm
2 | QT -= gui
3 |
4 | CONFIG += qt console warn_on depend_includepath testcase c++17
5 | CONFIG -= app_bundle
6 |
7 | TEMPLATE = app
8 |
9 | SOURCES += tst_entityinstancecache.cpp \
10 | domain/province.cpp \
11 | domain/town.cpp
12 |
13 | HEADERS += \
14 | domain/province.h \
15 | domain/town.h
16 |
--------------------------------------------------------------------------------
/tests/auto/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include(cmake/qtorm_add_unit_test.cmake)
2 |
3 | add_subdirectory(domainclasses)
4 | add_subdirectory(qormentityinstancecache)
5 | add_subdirectory(qormentitylistmodel)
6 | add_subdirectory(qormfilterexpression)
7 | add_subdirectory(qormmetadatacache)
8 | add_subdirectory(qormqueryresult)
9 | add_subdirectory(qormsession)
10 | add_subdirectory(qormsqlitestatementgenerator)
11 |
--------------------------------------------------------------------------------
/tests/auto/qormsession/qormsession.pro:
--------------------------------------------------------------------------------
1 | QT = core testlib orm orm-private
2 |
3 | CONFIG += testcase warn_on silent c++17
4 |
5 | TARGET = tst_ormsession
6 |
7 | SOURCES += tst_ormsession.cpp \
8 | domain/province.cpp \
9 | domain/town.cpp \
10 | domain/person.cpp \
11 |
12 | HEADERS += \
13 | domain/province.h \
14 | domain/town.h \
15 | domain/person.h \
16 |
17 | RESOURCES += ormsession.qrc
18 |
--------------------------------------------------------------------------------
/tests/auto/auto.qbs:
--------------------------------------------------------------------------------
1 | import qbs
2 |
3 | Project {
4 | references: [
5 | "domainclasses/domainclasses.qbs",
6 | "qormentityinstancecache/qormentityinstancecache.qbs",
7 | "qormmetadatacache/qormmetadatacache.qbs",
8 | "qormsession/qormsession.qbs",
9 | "qormfilterexpression/qormfilterexpression.qbs",
10 | "qormsqlitestatementgenerator/qormsqlitestatementgenerator.qbs",
11 | ]
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/examples/orm/navigationdb/navigationdb.qbs:
--------------------------------------------------------------------------------
1 | import qbs
2 |
3 | QtApplication {
4 | name: "navigationdb"
5 | cpp.cxxLanguageVersion: "c++17"
6 | Depends { name: "Qt"; submodules: ["core", "quick"] }
7 | Depends { name: "QtOrm" }
8 | files: [
9 | "domain/province.cpp", "domain/province.h",
10 | "domain/community.cpp", "domain/community.h",
11 | "main.cpp",
12 | "navigationdb.qrc",
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/tests/auto/qormentityinstancecache/qormentityinstancecache.qbs:
--------------------------------------------------------------------------------
1 | import qbs
2 |
3 | QtApplication {
4 | name: "tst_entityinstancecache"
5 | type: ["application", "autotest"]
6 | cpp.cxxLanguageVersion: "c++17"
7 | Depends { name: "Qt"; submodules: ["core", "test"] }
8 | Depends { name: "QtOrm" }
9 | files: [
10 | "tst_entityinstancecache.cpp",
11 | "domain/province.cpp", "domain/province.h",
12 | "domain/town.cpp", "domain/town.h",
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/configure.json:
--------------------------------------------------------------------------------
1 | {
2 | "module": "orm",
3 | "depends": [
4 | "core",
5 | "sql"
6 | ],
7 |
8 | "features": {
9 | "sqlite": {
10 | "label": "SQLite Backend",
11 | "purpose": "Enables OR-mapping to SQLite databases.",
12 | "condition": true
13 | }
14 | },
15 |
16 | "summary": [{
17 | "section": "Qt ORM",
18 | "entries": [
19 | "sqlite"
20 | ]
21 | }]
22 |
23 | }
--------------------------------------------------------------------------------
/tests/auto/qormentitylistmodel/qormentitylistmodel.qbs:
--------------------------------------------------------------------------------
1 | import qbs
2 |
3 | QtApplication {
4 | name: "tst_ormentitylistmodel"
5 | type: ["application", "autotest"]
6 | cpp.cxxLanguageVersion: "c++17"
7 | Depends { name: "Qt"; submodules: ["core", "test"] }
8 | Depends { name: "QtOrm" }
9 | files: [
10 | "domain/province.cpp", "domain/province.h",
11 | "domain/town.cpp", "domain/town.h",
12 | "tst_ormentitylistmodel.cpp",
13 | "resource.qrc"]
14 | }
15 |
--------------------------------------------------------------------------------
/tests/auto/qormmetadatacache/qormmetadatacache.pro:
--------------------------------------------------------------------------------
1 | QT += testlib orm
2 | QT -= gui
3 |
4 | CONFIG += qt console warn_on depend_includepath testcase c++17
5 | CONFIG -= app_bundle
6 |
7 | TEMPLATE = app
8 |
9 | SOURCES += tst_metadatacachetest.cpp \
10 | domain/person.cpp \
11 | domain/province.cpp \
12 | domain/town.cpp \
13 | domain/withenum.cpp
14 |
15 | HEADERS += \
16 | domain/person.h \
17 | domain/province.h \
18 | domain/town.h \
19 | domain/withenum.h
20 |
21 |
--------------------------------------------------------------------------------
/cmake/ExtractClassNames.cmake:
--------------------------------------------------------------------------------
1 | function(ExtractClassNames HEADER OUTPUT_VARIABLE)
2 | set(RESULT "")
3 | get_filename_component(OUTPUT_HEADER "${HEADER}" NAME)
4 |
5 | file(STRINGS ${HEADER} LINES)
6 |
7 | foreach (LINE ${LINES})
8 | if ("${LINE}" MATCHES "class[\t ]+(Q_ORM_EXPORT[\t ]+)?(QOrm[A-Za-z0-9_]+)[^;]*$")
9 | list(APPEND RESULT ${CMAKE_MATCH_2})
10 | endif()
11 | endforeach()
12 |
13 | set("${OUTPUT_VARIABLE}" ${RESULT} PARENT_SCOPE)
14 | endfunction()
15 |
--------------------------------------------------------------------------------
/examples/orm/navigationdb/navigationdb.pro:
--------------------------------------------------------------------------------
1 | QT += orm orm-private # enable the ORM module
2 | QT += quick
3 |
4 | CONFIG += c++17 # required by QtOrm
5 |
6 | TARGET = navigationdb
7 | TEMPLATE = app
8 |
9 | HEADERS += \
10 | domain/province.h \
11 | domain/community.h \
12 |
13 | SOURCES += \
14 | domain/province.cpp \
15 | domain/community.cpp \
16 | main.cpp
17 |
18 | target.path = $$[QT_INSTALL_EXAMPLES]/orm/navigationdb
19 | INSTALLS += target
20 |
21 |
22 | RESOURCES += navigationdb.qrc
23 |
24 |
--------------------------------------------------------------------------------
/tests/auto/qormsession/qormsession.qbs:
--------------------------------------------------------------------------------
1 | import qbs
2 |
3 | QtApplication {
4 | name: "tst_ormsession"
5 | type: ["application", "autotest"]
6 | cpp.cxxLanguageVersion: "c++17"
7 | Depends { name: "Qt"; submodules: ["core", "sql", "test"] }
8 | Depends { name: "QtOrm" }
9 | files: [
10 | "domain/person.cpp", "domain/person.h",
11 | "domain/province.cpp", "domain/province.h",
12 | "domain/town.cpp", "domain/town.h",
13 | "tst_ormsession.cpp",
14 | "ormsession.qrc"]
15 | }
16 |
--------------------------------------------------------------------------------
/tests/auto/qormsqlitestatementgenerator/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | qtorm_add_unit_test(NAME tst_sqlitestatementgenerator SOURCES
2 | tst_sqlitestatementgenerator.cpp
3 |
4 | domain/province.h
5 | domain/province.cpp
6 |
7 | domain/town.h
8 | domain/town.cpp
9 |
10 | domain/person.h
11 | domain/person.cpp
12 |
13 | domain/community.h
14 | domain/community.cpp
15 |
16 | domain/withqvariant.h
17 | domain/withqvariant.cpp
18 |
19 | domain/withenum.h
20 | domain/withenum.cpp
21 | )
22 |
23 |
--------------------------------------------------------------------------------
/tests/auto/qormmetadatacache/qormmetadatacache.qbs:
--------------------------------------------------------------------------------
1 | import qbs
2 |
3 | QtApplication {
4 | name: "tst_metadatacachetest"
5 | type: ["application", "autotest"]
6 | cpp.cxxLanguageVersion: "c++17"
7 | Depends { name: "Qt"; submodules: ["core", "test"] }
8 | Depends { name: "QtOrm" }
9 | files: [
10 | "tst_metadatacachetest.cpp",
11 | "domain/person.cpp", "domain/person.h",
12 | "domain/province.cpp", "domain/province.h",
13 | "domain/town.cpp", "domain/town.h",
14 | "domain/withenum.cpp", "domain/withenum.h"
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/examples/orm/navigationdb/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | find_package(Qt${QTORM_QT_VERSION_MAJOR} COMPONENTS Core Quick REQUIRED)
2 |
3 | if (QTORM_QT_VERSION_MAJOR EQUAL 6)
4 | set(RESOURCES navigationdb-qt6.qrc)
5 | else()
6 | set(RESOURCES navigationdb.qrc)
7 | endif()
8 |
9 | add_executable(navigationdb
10 | domain/province.h
11 | domain/community.h
12 |
13 | domain/province.cpp
14 | domain/community.cpp
15 | main.cpp
16 |
17 | ${RESOURCES}
18 | )
19 |
20 | target_link_libraries(navigationdb PUBLIC qtorm Qt${QTORM_QT_VERSION_MAJOR}::Core Qt${QTORM_QT_VERSION_MAJOR}::Quick)
21 |
--------------------------------------------------------------------------------
/tests/auto/qormsqlitestatementgenerator/qormsqlitestatementgenerator.pro:
--------------------------------------------------------------------------------
1 | QT += testlib orm orm-private
2 | QT -= gui
3 |
4 | CONFIG += qt console warn_on depend_includepath testcase c++17
5 | CONFIG -= app_bundle
6 |
7 | TEMPLATE = app
8 |
9 | SOURCES += tst_sqlitestatementgenerator.cpp \
10 | domain/province.cpp \
11 | domain/town.cpp \
12 | domain/person.cpp \
13 | domain/community.cpp \
14 | domain/withenum.cpp \
15 | domain/withqvariant.cpp
16 |
17 | HEADERS += \
18 | domain/province.h \
19 | domain/town.h \
20 | domain/person.h \
21 | domain/community.h \
22 | domain/withenum.h \
23 | domain/withqvariant.h
24 |
--------------------------------------------------------------------------------
/tests/auto/qormsqlitestatementgenerator/qormsqlitestatementgenerator.qbs:
--------------------------------------------------------------------------------
1 | import qbs
2 |
3 | QtApplication {
4 | name: "tst_sqlitestatementgenerator"
5 | type: ["application", "autotest"]
6 | cpp.cxxLanguageVersion: "c++17"
7 | Depends { name: "Qt"; submodules: ["core", "test"] }
8 | Depends { name: "QtOrm" }
9 | files: [
10 | "domain/person.cpp", "domain/person.h",
11 | "domain/province.cpp", "domain/province.h",
12 | "domain/town.cpp", "domain/town.h",
13 | "domain/community.cpp", "domain/community.h",
14 | "domain/withenum.cpp", "domain/withenum.h",
15 | "domain/withqvariant.cpp", "domain/withqvariant.h",
16 | "tst_sqlitestatementgenerator.cpp"]
17 | }
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # C++ objects and libs
2 | *.slo
3 | *.lo
4 | *.o
5 | *.a
6 | *.la
7 | *.lai
8 | *.so
9 | *.dll
10 | *.dylib
11 |
12 | # Qt-es
13 | object_script.*.Release
14 | object_script.*.Debug
15 | *_plugin_import.cpp
16 | /.qmake.cache
17 | /.qmake.stash
18 | *.pro.user
19 | *.pro.user.*
20 | *.qbs.user
21 | *.qbs.user.*
22 | *.moc
23 | moc_*.cpp
24 | moc_*.h
25 | qrc_*.cpp
26 | ui_*.h
27 | *.qmlc
28 | *.jsc
29 | Makefile*
30 | *build-*
31 |
32 | # Qt unit tests
33 | target_wrapper.*
34 |
35 | # QtCreator
36 | *.autosave
37 |
38 | # QtCreator Qml
39 | *.qmlproject.user
40 | *.qmlproject.user.*
41 |
42 | # QtCreator CMake
43 | CMakeLists.txt.user*
44 |
45 | # QtCreator 4.8< compilation database
46 | compile_commands.json
47 |
48 | # QtCreator local machine specific files for imported projects
49 | *creator.user*
50 |
51 | # QtCreator 14+ build directory
52 | build/
53 |
54 | # CLion directories
55 | .idea/
56 | cmake-build*/
--------------------------------------------------------------------------------
/cmake/GetGeneratedHeaders.cmake:
--------------------------------------------------------------------------------
1 | function(GetGeneratedHeaders OUTPUT_DIRECTORY PUBLIC_HEADERS PRIVATE_HEADERS OUTPUT_VARIABLE)
2 | set(RESULT "${OUTPUT_DIRECTORY}/QtOrm")
3 |
4 | foreach(HEADER ${PUBLIC_HEADERS})
5 | get_filename_component(OUTPUT_HEADER "${HEADER}" NAME)
6 |
7 | list(APPEND RESULT "${OUTPUT_DIRECTORY}/${OUTPUT_HEADER}")
8 | ExtractClassNames(${HEADER} CLASS_NAMES)
9 |
10 | foreach(CLASS_NAME ${CLASS_NAMES})
11 | list(APPEND RESULT "${OUTPUT_DIRECTORY}/${CLASS_NAME}")
12 | endforeach()
13 | endforeach()
14 |
15 | foreach(HEADER ${PRIVATE_HEADERS})
16 | get_filename_component(OUTPUT_HEADER "${HEADER}" NAME)
17 |
18 | list(APPEND RESULT "${OUTPUT_DIRECTORY}/private/${OUTPUT_HEADER}")
19 | endforeach()
20 |
21 | list(REMOVE_DUPLICATES RESULT)
22 |
23 | set("${OUTPUT_VARIABLE}" ${RESULT} PARENT_SCOPE)
24 | endfunction()
25 |
--------------------------------------------------------------------------------
/tests/auto/cmake/qtorm_add_unit_test.cmake:
--------------------------------------------------------------------------------
1 | function(qtorm_add_unit_test)
2 | set(OPTIONS)
3 | set(ONE_VALUE_ARGS NAME)
4 | set(MULTI_VALUE_ARGS SOURCES LINK_LIBRARIES)
5 |
6 | cmake_parse_arguments(QTORM_ADD_UNIT_TEST "${OPTIONS}" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN})
7 |
8 | add_executable(${QTORM_ADD_UNIT_TEST_NAME} ${QTORM_ADD_UNIT_TEST_SOURCES})
9 | target_link_libraries(${QTORM_ADD_UNIT_TEST_NAME} Qt${QTORM_QT_VERSION_MAJOR}::Test qtorm ${QTORM_ADD_UNIT_TEST_LINK_LIBRARIES})
10 |
11 | add_test(NAME ${QTORM_ADD_UNIT_TEST_NAME} COMMAND ${QTORM_ADD_UNIT_TEST_NAME})
12 |
13 | if (WIN32 AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.22.0")
14 | set_tests_properties(${QTORM_ADD_UNIT_TEST_NAME} PROPERTIES
15 | ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:${CMAKE_BINARY_DIR}/src;PATH=path_list_prepend:${_qt5Core_install_prefix}/bin")
16 | endif()
17 | endfunction()
18 |
--------------------------------------------------------------------------------
/tests/auto/qormqueryresult/domain/person.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | class Person : public QObject
6 | {
7 | Q_OBJECT
8 |
9 | Q_PROPERTY(long id READ id WRITE setId NOTIFY idChanged)
10 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
11 |
12 | public:
13 | Q_INVOKABLE Person() = default;
14 |
15 | [[nodiscard]] long id() const { return m_id; }
16 | void setId(long id)
17 | {
18 | if (m_id != id)
19 | {
20 | m_id = id;
21 | emit idChanged();
22 | }
23 | }
24 |
25 | [[nodiscard]] QString name() const { return m_name; }
26 | void setName(QString name)
27 | {
28 | if (m_name != name)
29 | {
30 | m_name = name;
31 | emit nameChanged();
32 | }
33 | }
34 |
35 | signals:
36 | void idChanged();
37 | void nameChanged();
38 |
39 | private:
40 | long m_id{-1};
41 | QString m_name;
42 | };
43 |
--------------------------------------------------------------------------------
/tests/auto/qormsqlitestatementgenerator/domain/community.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 Dmitriy Purgin
3 | *
4 | * This file is part of QtOrm library.
5 | *
6 | * QtOrm is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * QtOrm is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with QtOrm. If not, see .
18 | */
19 |
20 | #include "community.h"
21 |
22 | Community::Community(QObject* parent)
23 | : QObject{parent}
24 | {
25 | }
26 |
--------------------------------------------------------------------------------
/.github/workflows/qmake.yml:
--------------------------------------------------------------------------------
1 | on: [push, pull_request]
2 |
3 | jobs:
4 | build:
5 | strategy:
6 | fail-fast: false
7 | matrix:
8 | qtversion: [ '5.12.*', '5.15.*' ]
9 |
10 | runs-on: ubuntu-latest
11 |
12 | steps:
13 | - uses: actions/checkout@v2
14 |
15 | - name: Install Qt
16 | uses: jurplel/install-qt-action@v3
17 | with:
18 | version: ${{ matrix.qtversion }}
19 | archives: 'qtbase qtdeclarative qtquickcontrols2 icu'
20 |
21 | - name: Create Build Environment
22 | shell: bash
23 | run: mkdir -p ${{runner.workspace}}/build
24 |
25 | - name: Configure QMake
26 | shell: bash
27 | working-directory: ${{runner.workspace}}/build
28 | run: qmake ${GITHUB_WORKSPACE}/qtorm.pro
29 |
30 | - name: Build
31 | working-directory: ${{runner.workspace}}/build
32 | shell: bash
33 | run: make
34 |
35 | - name: Test
36 | working-directory: ${{runner.workspace}}/build
37 | shell: bash
38 | run: make check
39 |
--------------------------------------------------------------------------------
/src/orm/qormqueryresult.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "qormqueryresult.h"
22 | #include "qormerror.h"
23 |
24 | #include
25 |
26 | QT_BEGIN_NAMESPACE
27 |
28 | QT_END_NAMESPACE
29 |
--------------------------------------------------------------------------------
/qtorm.qbs:
--------------------------------------------------------------------------------
1 | import qbs
2 | import qbs.FileInfo
3 |
4 | Project {
5 | name: "qtorm"
6 |
7 | minimumQbsVersion: "1.6"
8 | property bool withDocumentation: true
9 | property bool withExamples: true
10 | property bool withTests: true
11 |
12 | references: [
13 | "src/src.qbs",
14 | ]
15 |
16 | // SubProject {
17 | // filePath: "doc/doc.qbs"
18 | // Properties {
19 | // condition: parent.withDocumentation
20 | // }
21 | // }
22 |
23 | SubProject {
24 | filePath: "examples/examples.qbs"
25 | Properties {
26 | condition: parent.withExamples
27 | }
28 | }
29 | SubProject {
30 | filePath: "tests/tests.qbs"
31 | Properties {
32 | condition: parent.withTests
33 | }
34 | }
35 | AutotestRunner {
36 | Depends { name: "QtOrm" }
37 | environment: {
38 | var path = FileInfo.joinPaths(qbs.installRoot, qbs.installPrefix, "lib");
39 | return base.concat(["LD_LIBRARY_PATH=" + path]);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/orm/qormabstractprovider.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "qormabstractprovider.h"
22 |
23 | QT_BEGIN_NAMESPACE
24 |
25 | QOrmAbstractProvider::~QOrmAbstractProvider() = default;
26 |
27 | QT_END_NAMESPACE
28 |
--------------------------------------------------------------------------------
/tests/auto/qormsqlitestatementgenerator/domain/person.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 Dmitriy Purgin
3 | *
4 | * This file is part of QtOrm library.
5 | *
6 | * QtOrm is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * QtOrm is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with QtOrm. If not, see .
18 | */
19 |
20 |
21 | #include "person.h"
22 |
23 | void Person::setId(long id)
24 | {
25 | if (m_id != id)
26 | {
27 | m_id = id;
28 | emit idChanged();
29 | }
30 | }
31 |
32 | void Person::setName(const QString &name)
33 | {
34 | if (m_name != name)
35 | {
36 | m_name = name;
37 | emit nameChanged();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/.github/workflows/qbs-linux.yml:
--------------------------------------------------------------------------------
1 | on: [push, pull_request]
2 |
3 | jobs:
4 | build:
5 | strategy:
6 | fail-fast: false
7 | matrix:
8 | qtversion: [ '5.15.*' ]
9 |
10 | runs-on: ubuntu-latest
11 |
12 | steps:
13 | - uses: actions/checkout@v2
14 |
15 | - name: Install Qt
16 | uses: jurplel/install-qt-action@v3
17 | with:
18 | version: ${{ matrix.qtversion }}
19 | archives: 'qtbase qtdeclarative qtquickcontrols2 icu'
20 |
21 | - name: Install Qbs
22 | run: |
23 | wget --no-check-certificate --content-disposition https://download.qt.io/official_releases/qbs/1.24.1/qbs-linux-x86_64-1.24.1.tar.gz
24 | tar xzvf qbs-linux-x86_64-1.24.1.tar.gz
25 | QBS_BIN_DIR="${GITHUB_WORKSPACE}/qbs-linux-x86_64-1.24.1/bin"
26 | echo "$QBS_BIN_DIR" >> ${GITHUB_PATH}
27 | shell: bash
28 |
29 | - name: Configure Qbs
30 | run: |
31 | qbs-setup-toolchains $(command -v gcc) gcc
32 | qbs-setup-qt $(command -v qmake) qt5
33 | qbs-config profiles.qt5.baseProfile gcc
34 | shell: bash
35 |
36 | - name: Build
37 | run: qbs build profile:qt5
38 | shell: bash
39 |
40 | - name: Test
41 | run: qbs build profile:qt5 -p autotest-runner
42 | shell: bash
43 |
--------------------------------------------------------------------------------
/src/orm/qormorder.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "qormorder.h"
22 |
23 | #include
24 |
25 | QT_BEGIN_NAMESPACE
26 |
27 | QDebug operator<<(QDebug dbg, const QOrmOrder& order)
28 | {
29 | QDebugStateSaver saver{dbg};
30 | dbg.noquote().nospace() << "QOrmOrder(" << order.mapping().classPropertyName() << ", "
31 | << order.direction() << ")";
32 | return dbg;
33 | }
34 |
35 | QT_END_NAMESPACE
36 |
37 |
--------------------------------------------------------------------------------
/_clang-format:
--------------------------------------------------------------------------------
1 | BasedOnStyle: LLVM
2 | IndentWidth: 4
3 | Language: Cpp
4 | AccessModifierOffset: -4
5 | AlignAfterOpenBracket: Align
6 | AlignOperands: true
7 | # AllowAllConstructorInitializersOnNextLine: false
8 | AllowAllParametersOfDeclarationOnNextLine: false
9 | AllowShortFunctionsOnASingleLine: InlineOnly
10 | #AllowShortIfStatementsOnASingleLine: Never
11 | BreakBeforeBraces: Allman
12 | # BraceWrapping:
13 | # AfterEnum: true
14 | # AfterStruct: true
15 | # AfterClass: true
16 | # AfterControlStatement: true
17 | # AfterEnum: true
18 | # AfterNamespace: true
19 | # AfterStruct: true
20 | # AfterUnion: true
21 | # AfterExternBlock: true
22 | # BeforeCatch: true
23 | # BeforeElse: true
24 | # SplitEmptyFunction: true
25 | # SplitEmptyRecord: true
26 | # SplitEmptyNamespace: true
27 | BreakConstructorInitializers: BeforeComma
28 | ColumnLimit: 100
29 | ConstructorInitializerAllOnOneLineOrOnePerLine: false
30 | IndentCaseLabels: true
31 | # IndentPPDirectives: BeforeHash
32 | NamespaceIndentation: All
33 | PointerAlignment: Left
34 | SortIncludes: true
35 | Standard: Cpp11
36 | BinPackArguments: false
37 | BinPackParameters: false
38 | AlwaysBreakTemplateDeclarations: Yes
39 | SpaceAfterTemplateKeyword: false
40 | ReflowComments: true
41 | PenaltyBreakBeforeFirstCallParameter: 100
42 | PenaltyReturnTypeOnItsOwnLine: 150
43 |
--------------------------------------------------------------------------------
/src/orm/doc/qtorm.qdocconf:
--------------------------------------------------------------------------------
1 | include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
2 |
3 | project = QtOrm
4 | description = Qt ORM Reference Documentation
5 | version = $QT_VERSION
6 |
7 | examplesinstallpath = orm
8 |
9 | qhp.projects = QtOrm
10 |
11 | qhp.QtOrm.file = qtorm.qhp
12 | qhp.QtOrm.namespace = at.sequality.qtorm.$QT_VERSION_TAG
13 | qhp.QtOrm.virtualFolder = qtorm
14 | qhp.QtOrm.indexTitle = Qt ORM
15 | qhp.QtOrm.indexRoot =
16 |
17 | qhp.QtOrm.filterAttributes = qtorm $QT_VERSION qtrefdoc
18 | qhp.QtOrm.customFilters.Qt.name = QtOrm $QT_VERSION
19 | qhp.QtOrm.customFilters.Qt.filterAttributes = qtorm $QT_VERSION
20 |
21 | qhp.QtOrm.subprojects = classes
22 | qhp.QtOrm.subprojects.classes.title = C++ Classes
23 | qhp.QtOrm.subprojects.classes.indexTitle = Qt ORM C++ Classes
24 | qhp.QtOrm.subprojects.classes.selectors = class fake:headerfile
25 | qhp.QtOrm.subprojects.classes.sortPages = true
26 |
27 | tagfile = ../../../doc/qtorm/qtorm.tags
28 |
29 | depends += \
30 | qtcore \
31 | qtdoc \
32 | qtsql
33 |
34 | headerdirs += ..
35 |
36 | sourcedirs += ..
37 |
38 | exampledirs += ../../../examples/orm \
39 | snippets/
40 |
41 | imagedirs += images
42 |
43 | navigation.landingpage = "Qt ORM"
44 | navigation.cppclassespage = "Qt ORM C++ Classes"
--------------------------------------------------------------------------------
/tests/auto/qormmetadatacache/domain/person.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "person.h"
22 |
23 | void Person::setId(int id)
24 | {
25 | if (m_id == id)
26 | return;
27 |
28 | m_id = id;
29 | emit idChanged(m_id);
30 | }
31 |
32 | void Person::setName(QString name)
33 | {
34 | if (m_name == name)
35 | return;
36 |
37 | m_name = name;
38 | emit nameChanged(m_name);
39 | }
40 |
41 | void Person::setTown(Town* town)
42 | {
43 | if (m_town == town)
44 | return;
45 |
46 | m_town = town;
47 | emit townChanged(m_town);
48 | }
49 |
--------------------------------------------------------------------------------
/tests/auto/qormsession/domain/province.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "province.h"
22 |
23 | void Province::setId(int id)
24 | {
25 | if (m_id == id)
26 | return;
27 |
28 | m_id = id;
29 | emit idChanged(m_id);
30 | }
31 |
32 | void Province::setName(QString name)
33 | {
34 | if (m_name == name)
35 | return;
36 |
37 | m_name = name;
38 | emit nameChanged(m_name);
39 | }
40 |
41 | void Province::setTowns(QVector towns)
42 | {
43 | if (m_towns == towns)
44 | return;
45 |
46 | m_towns = towns;
47 | emit townsChanged(m_towns);
48 | }
49 |
--------------------------------------------------------------------------------
/.github/workflows/cmake-linux.yml:
--------------------------------------------------------------------------------
1 | on: [push, pull_request]
2 |
3 | jobs:
4 | build:
5 | strategy:
6 | fail-fast: false
7 | matrix:
8 | include:
9 | - qtversion: '5.15.*'
10 | arch: 'gcc_64'
11 | - qtversion: '5.12.*'
12 | arch: 'gcc_64'
13 | - qtversion: '6.8.*'
14 | arch: 'linux_gcc_64'
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v2
19 |
20 | - name: Install Qt
21 | uses: jurplel/install-qt-action@v3
22 | with:
23 | version: ${{ matrix.qtversion }}
24 | arch: ${{ matrix.arch }}
25 | archives: 'qtbase qtdeclarative qtquickcontrols2 icu'
26 |
27 | - name: Create Build Environment
28 | run: cmake -E make_directory ${{runner.workspace}}/build
29 |
30 | - name: Configure CMake
31 | shell: bash
32 | working-directory: ${{runner.workspace}}/build
33 | run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -DQTORM_BUILD_EXAMPLES=ON -DQTORM_BUILD_TESTS=ON -DQTORM_BUILD_SHARED_LIBS=ON
34 |
35 | - name: Build
36 | working-directory: ${{runner.workspace}}/build
37 | shell: bash
38 | # Execute the build. You can specify a specific target with "--target "
39 | run: cmake --build . --config Debug
40 |
41 | - name: Test
42 | working-directory: ${{runner.workspace}}/build
43 | shell: bash
44 | run: ctest -C Debug --output-on-failure
45 |
--------------------------------------------------------------------------------
/tests/auto/qormentityinstancecache/domain/province.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "province.h"
22 |
23 | void Province::setId(int id)
24 | {
25 | if (m_id == id)
26 | return;
27 |
28 | m_id = id;
29 | emit idChanged(m_id);
30 | }
31 |
32 | void Province::setName(QString name)
33 | {
34 | if (m_name == name)
35 | return;
36 |
37 | m_name = name;
38 | emit nameChanged(m_name);
39 | }
40 |
41 | void Province::setTowns(QVector towns)
42 | {
43 | if (m_towns == towns)
44 | return;
45 |
46 | m_towns = towns;
47 | emit townsChanged(m_towns);
48 | }
49 |
--------------------------------------------------------------------------------
/tests/auto/qormsqlitestatementgenerator/domain/province.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "province.h"
22 |
23 | void Province::setId(int id)
24 | {
25 | if (m_id == id)
26 | return;
27 |
28 | m_id = id;
29 | emit idChanged(m_id);
30 | }
31 |
32 | void Province::setName(QString name)
33 | {
34 | if (m_name == name)
35 | return;
36 |
37 | m_name = name;
38 | emit nameChanged(m_name);
39 | }
40 |
41 | void Province::setTowns(QVector towns)
42 | {
43 | if (m_towns == towns)
44 | return;
45 |
46 | m_towns = towns;
47 | emit townsChanged(m_towns);
48 | }
49 |
--------------------------------------------------------------------------------
/tests/auto/qormsqlitestatementgenerator/domain/withqvariant.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 Dmitriy Purgin
3 | * Copyright (C) 2019-2021 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "withqvariant.h"
22 |
23 | int WithQVariant::id() const
24 | {
25 | return m_id;
26 | }
27 |
28 | void WithQVariant::setId(int id)
29 | {
30 | if (m_id != id)
31 | {
32 | m_id = id;
33 | emit idChanged();
34 | }
35 | }
36 |
37 | QVariant WithQVariant::data() const
38 | {
39 | return m_data;
40 | }
41 |
42 | void WithQVariant::setData(const QVariant& data)
43 | {
44 | if (m_data != data)
45 | {
46 | m_data = data;
47 | emit dataChanged();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/tests/auto/qormsqlitestatementgenerator/domain/person.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 Dmitriy Purgin
3 | *
4 | * This file is part of QtOrm library.
5 | *
6 | * QtOrm is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * QtOrm is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with QtOrm. If not, see .
18 | */
19 |
20 | #pragma once
21 |
22 | #include
23 |
24 | class Person : public QObject
25 | {
26 | Q_OBJECT
27 |
28 | Q_PROPERTY(long id READ id WRITE setId NOTIFY idChanged)
29 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
30 |
31 | long m_id;
32 | QString m_name;
33 |
34 | public:
35 | Q_INVOKABLE Person(QObject* parent = nullptr): QObject{parent}
36 | {}
37 |
38 | long id() const { return m_id; }
39 | void setId(long id);
40 |
41 | QString name() const { return m_name; }
42 | void setName(const QString& name);
43 |
44 | signals:
45 | void idChanged();
46 | void nameChanged();
47 | };
48 |
49 |
--------------------------------------------------------------------------------
/tests/auto/qormmetadatacache/domain/province.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "province.h"
22 |
23 | Province::Province(QObject* parent)
24 | : QObject(parent)
25 | {
26 | }
27 |
28 | int Province::id() const
29 | {
30 | return m_id;
31 | }
32 |
33 | QString Province::name() const
34 | {
35 | return m_name;
36 | }
37 |
38 | void Province::setId(int id)
39 | {
40 | if (m_id == id)
41 | return;
42 |
43 | m_id = id;
44 | emit idChanged(m_id);
45 | }
46 |
47 | void Province::setName(QString name)
48 | {
49 | if (m_name == name)
50 | return;
51 |
52 | m_name = name;
53 | emit nameChanged(m_name);
54 | }
55 |
--------------------------------------------------------------------------------
/.github/workflows/cmake-windows.yml:
--------------------------------------------------------------------------------
1 | on: [push, pull_request]
2 |
3 | jobs:
4 | build:
5 | strategy:
6 | fail-fast: false
7 | matrix:
8 | include:
9 | - qtversion: '5.15.*'
10 | arch: 'win64_msvc2019_64'
11 | - qtversion: '5.12.*'
12 | arch: 'win64_msvc2017_64'
13 | - qtversion: '6.8.*'
14 | arch: 'win64_msvc2022_64'
15 |
16 | runs-on: windows-latest
17 |
18 | steps:
19 | - uses: actions/checkout@v2
20 |
21 | - name: Install Qt
22 | uses: jurplel/install-qt-action@v3
23 | with:
24 | version: ${{ matrix.qtversion }}
25 | arch: ${{ matrix.arch }}
26 | archives: 'qtbase qtdeclarative qtquickcontrols2'
27 |
28 | - name: Create Build Environment
29 | run: cmake -E make_directory ${{runner.workspace}}/build
30 |
31 | - name: Configure CMake
32 | working-directory: ${{runner.workspace}}/build
33 | run: cmake ${env:GITHUB_WORKSPACE} -A x64 -DQTORM_BUILD_EXAMPLES=ON -DQTORM_BUILD_TESTS=ON -DQTORM_BUILD_SHARED_LIBS=ON
34 |
35 | - name: Build
36 | working-directory: ${{runner.workspace}}/build
37 | # Execute the build. You can specify a specific target with "--target "
38 | run: cmake --build . --config Debug
39 |
40 | - name: Test
41 | working-directory: ${{runner.workspace}}/build
42 | run: |
43 | ${env:Path} = "${{runner.workspace}}/build/src/Debug;${env:Path}"
44 | ctest -C Debug --output-on-failure
45 |
--------------------------------------------------------------------------------
/tests/auto/qormentitylistmodel/domain/province.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 Dmitriy Purgin
3 | * Copyright (C) 2019 Dmitriy Purgin
4 | * Copyright (C) 2019 sequality software engineering e.U.
5 | *
6 | * This file is part of QtOrm library.
7 | *
8 | * QtOrm is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation, either version 3 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * QtOrm is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with QtOrm. If not, see .
20 | */
21 |
22 | #include "province.h"
23 |
24 | void Province::setId(int id)
25 | {
26 | if (m_id == id)
27 | return;
28 |
29 | m_id = id;
30 | emit idChanged(m_id);
31 | }
32 |
33 | void Province::setName(QString name)
34 | {
35 | if (m_name == name)
36 | return;
37 |
38 | m_name = name;
39 | emit nameChanged(m_name);
40 | }
41 |
42 | void Province::setTowns(QVector towns)
43 | {
44 | if (m_towns == towns)
45 | return;
46 |
47 | m_towns = towns;
48 | emit townsChanged(m_towns);
49 | }
50 |
--------------------------------------------------------------------------------
/tests/auto/qormmetadatacache/domain/province.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #pragma once
22 |
23 | #include
24 |
25 | class Province : public QObject
26 | {
27 | Q_OBJECT
28 |
29 | Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
30 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
31 |
32 | int m_id;
33 | QString m_name;
34 |
35 | public:
36 | Q_INVOKABLE explicit Province(QObject* parent = nullptr);
37 |
38 | int id() const;
39 | void setId(int id);
40 |
41 | QString name() const;
42 | void setName(QString name);
43 |
44 | signals:
45 | void idChanged(int id);
46 | void nameChanged(QString name);
47 | };
48 |
--------------------------------------------------------------------------------
/src/orm/qormfilter.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "qormfilter.h"
22 |
23 | #include
24 |
25 | QT_BEGIN_NAMESPACE
26 |
27 | QDebug operator<<(QDebug dbg, const QOrmFilter& filter)
28 | {
29 | QDebugStateSaver saver{dbg};
30 |
31 | dbg.nospace().noquote() << "QOrmFilter(" << filter.type();
32 |
33 | switch (filter.type())
34 | {
35 | case QOrm::FilterType::Invokable:
36 | dbg << "Invokable";
37 | break;
38 |
39 | case QOrm::FilterType::Expression:
40 | dbg << "Expression, " << *filter.expression();
41 | break;
42 | }
43 |
44 | dbg << ")";
45 |
46 | return dbg;
47 | }
48 |
49 | QT_END_NAMESPACE
50 |
--------------------------------------------------------------------------------
/tests/auto/qormmetadatacache/domain/town.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "town.h"
22 |
23 | Town::Town(QObject* parent)
24 | : QObject(parent)
25 | {
26 | }
27 |
28 | void Town::setId(int id)
29 | {
30 | if (m_id == id)
31 | return;
32 |
33 | m_id = id;
34 | emit idChanged(m_id);
35 | }
36 |
37 | void Town::setName(QString name)
38 | {
39 | if (m_name == name)
40 | return;
41 |
42 | m_name = name;
43 | emit nameChanged(m_name);
44 | }
45 |
46 | void Town::setPopulation(QVector population)
47 | {
48 | if (m_population == population)
49 | return;
50 |
51 | m_population = population;
52 | emit populationChanged(m_population);
53 | }
54 |
--------------------------------------------------------------------------------
/cmake/GenerateHeaders.cmake:
--------------------------------------------------------------------------------
1 | include(${CMAKE_CURRENT_LIST_DIR}/ExtractClassNames.cmake)
2 |
3 | function(CheckVariable VARIABLE_NAME)
4 | if (NOT DEFINED ${VARIABLE_NAME})
5 | message(FATAL_ERROR "${VARIABLE_NAME} is not defined")
6 | else()
7 | message(STATUS "${VARIABLE_NAME} is ${${VARIABLE_NAME}}")
8 | endif()
9 | endfunction()
10 |
11 | CheckVariable(SOURCE_DIRECTORY)
12 | CheckVariable(OUTPUT_DIRECTORY)
13 | CheckVariable(PUBLIC_HEADERS)
14 | CheckVariable(PRIVATE_HEADERS)
15 |
16 | file(REMOVE_RECURSE "${OUTPUT_DIRECTORY}")
17 |
18 | set(QTORM_MODULE_HEADER "${OUTPUT_DIRECTORY}/QtOrm")
19 | file(WRITE ${QTORM_MODULE_HEADER} "#ifndef QT_QTORM_MODULE_H\n")
20 | file(APPEND ${QTORM_MODULE_HEADER} "#define QT_QTORM_MODULE_H\n")
21 |
22 | foreach(HEADER ${PUBLIC_HEADERS})
23 | message(STATUS "Parsing ${HEADER}...")
24 |
25 | get_filename_component(OUTPUT_HEADER "${HEADER}" NAME)
26 |
27 | file(WRITE
28 | "${OUTPUT_DIRECTORY}/${OUTPUT_HEADER}"
29 | "#include \"${SOURCE_DIRECTORY}/${HEADER}\"")
30 |
31 | ExtractClassNames(${SOURCE_DIRECTORY}/${HEADER} CLASS_NAMES)
32 |
33 | foreach(CLASS_NAME ${CLASS_NAMES})
34 | file(WRITE
35 | "${OUTPUT_DIRECTORY}/${CLASS_NAME}"
36 | "#include \"${SOURCE_DIRECTORY}/${HEADER}\"")
37 | endforeach()
38 |
39 | file(APPEND "${QTORM_MODULE_HEADER}" "#include \"${OUTPUT_HEADER}\"\n")
40 | endforeach()
41 |
42 | foreach(HEADER ${PRIVATE_HEADERS})
43 | get_filename_component(OUTPUT_HEADER "${HEADER}" NAME)
44 |
45 | file(WRITE
46 | "${OUTPUT_DIRECTORY}/private/${OUTPUT_HEADER}"
47 | "#include \"${SOURCE_DIRECTORY}/${HEADER}\"")
48 | endforeach()
49 |
50 | file(APPEND ${QTORM_MODULE_HEADER} "#endif\n")
51 |
52 |
--------------------------------------------------------------------------------
/tests/auto/qormsqlitestatementgenerator/domain/withqvariant.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 Dmitriy Purgin
3 | * Copyright (C) 2019-2021 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #pragma once
22 |
23 | #include
24 | #include
25 |
26 | class WithQVariant : public QObject
27 | {
28 | Q_OBJECT
29 |
30 | Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
31 | Q_PROPERTY(QVariant data READ data WRITE setData NOTIFY dataChanged)
32 |
33 | public:
34 | Q_INVOKABLE WithQVariant(QObject* parent = nullptr)
35 | : QObject{parent}
36 | {
37 | }
38 |
39 | int id() const;
40 | void setId(int id);
41 |
42 | QVariant data() const;
43 | void setData(const QVariant& data);
44 |
45 | signals:
46 | void idChanged();
47 | void dataChanged();
48 |
49 | private:
50 | int m_id{0};
51 | QVariant m_data;
52 | };
53 |
--------------------------------------------------------------------------------
/src/orm/qormmetadata_p.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #ifndef QORMMETADATA_P_H
22 | #define QORMMETADATA_P_H
23 |
24 | #include "QtOrm/qormpropertymapping.h"
25 |
26 | #include
27 |
28 | #include
29 |
30 | class QOrmMetadataPrivate : public QSharedData
31 | {
32 | public:
33 | QOrmMetadataPrivate(const QMetaObject& metaObject)
34 | : m_qMetaObject{metaObject}
35 | {
36 | }
37 |
38 | const QMetaObject& m_qMetaObject;
39 |
40 | QString m_className;
41 | QString m_tableName;
42 | std::vector m_propertyMappings;
43 |
44 | int m_objectIdPropertyMappingIdx{-1};
45 | QHash m_classPropertyMappingIndex;
46 | QHash m_tableFieldMappingIndex;
47 | QOrmUserMetadata m_userMetadata;
48 | };
49 |
50 | #endif
51 |
--------------------------------------------------------------------------------
/src/orm/qormerror.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 Dmitriy Purgin
3 | * Copyright (C) 2019-2021 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "qormerror.h"
22 |
23 | #include
24 |
25 | QT_BEGIN_NAMESPACE
26 |
27 | QOrmError::QOrmError() = default;
28 |
29 | QOrmError::QOrmError(QOrm::ErrorType error, const QString& text)
30 | : m_type{error}
31 | , m_text{text}
32 | {
33 | }
34 |
35 | QOrm::ErrorType QOrmError::type() const
36 | {
37 | return m_type;
38 | }
39 |
40 | QString QOrmError::text() const
41 | {
42 | return m_text;
43 | }
44 |
45 | QDebug operator<<(QDebug dbg, const QOrmError& error)
46 | {
47 | QDebugStateSaver saver{dbg};
48 |
49 | dbg.nospace().noquote() << "QOrmError(" << error.type() << QStringLiteral(", ") << error.text()
50 | << QStringLiteral(")");
51 |
52 | return dbg;
53 | }
54 |
55 | QT_END_NAMESPACE
56 |
--------------------------------------------------------------------------------
/src/orm/qormorder.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #ifndef QORMORDER_H
22 | #define QORMORDER_H
23 |
24 | #include
25 | #include
26 |
27 | QT_BEGIN_NAMESPACE
28 |
29 | class Q_ORM_EXPORT QOrmOrder
30 | {
31 | public:
32 | QOrmOrder(const QOrmPropertyMapping& mapping, Qt::SortOrder direction)
33 | : m_propertyMapping{mapping}
34 | , m_direction{direction}
35 | {
36 | }
37 |
38 | const QOrmPropertyMapping& mapping() const { return m_propertyMapping; }
39 | Qt::SortOrder direction() const { return m_direction; }
40 |
41 | private:
42 | QOrmPropertyMapping m_propertyMapping;
43 | Qt::SortOrder m_direction{Qt::AscendingOrder};
44 | };
45 |
46 | Q_ORM_EXPORT QDebug operator<<(QDebug debug, const QOrmOrder& order);
47 |
48 | QT_END_NAMESPACE
49 |
50 | #endif
51 |
--------------------------------------------------------------------------------
/src/orm/orm.pro:
--------------------------------------------------------------------------------
1 | TARGET = QtOrm
2 |
3 | QT = core sql
4 |
5 | QMAKE_DOCS = $$PWD/doc/qtorm.qdocconf
6 |
7 | PUBLIC_HEADERS += \
8 | qormabstractprovider.h \
9 | qormclassproperty.h \
10 | qormentityinstancecache.h \
11 | qormentitylistmodel.h \
12 | qormerror.h \
13 | qormfilter.h \
14 | qormfilterexpression.h \
15 | qormglobal.h \
16 | qormmetadata.h \
17 | qormmetadatacache.h \
18 | qormorder.h \
19 | qormpropertymapping.h \
20 | qormquery.h \
21 | qormquerybuilder.h \
22 | qormqueryresult.h \
23 | qormrelation.h \
24 | qormsession.h \
25 | qormsessionconfiguration.h \
26 | qormsqliteconfiguration.h \
27 | qormsqliteprovider.h \
28 | qormtransactiontoken.h \
29 |
30 | PRIVATE_HEADERS = \
31 | qormglobal_p.h \
32 | qormmetadata_p.h \
33 | qormsqlitestatementgenerator_p.h \
34 |
35 | SOURCES += \
36 | qormabstractprovider.cpp \
37 | qormclassproperty.cpp \
38 | qormentityinstancecache.cpp \
39 | qormentitylistmodel.cpp \
40 | qormerror.cpp \
41 | qormfilter.cpp \
42 | qormfilterexpression.cpp \
43 | qormglobal.cpp \
44 | qormglobal_p.cpp \
45 | qormmetadata.cpp \
46 | qormmetadatacache.cpp \
47 | qormorder.cpp \
48 | qormpropertymapping.cpp \
49 | qormquery.cpp \
50 | qormquerybuilder.cpp \
51 | qormqueryresult.cpp \
52 | qormrelation.cpp \
53 | qormsession.cpp \
54 | qormsessionconfiguration.cpp \
55 | qormsqliteconfiguration.cpp \
56 | qormsqliteprovider.cpp \
57 | qormsqlitestatementgenerator_p.cpp \
58 | qormtransactiontoken.cpp \
59 |
60 | HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
61 |
62 | load(qt_module)
63 |
64 | CONFIG += c++17
65 |
66 | DEFINES -= QT_ASCII_CAST_WARNINGS
67 |
--------------------------------------------------------------------------------
/src/orm/qormclassproperty.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2022 Dmitriy Purgin
3 | * Copyright (C) 2019-2022 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #ifndef QORMCLASSPROPERTY_H
22 | #define QORMCLASSPROPERTY_H
23 |
24 | #include
25 |
26 | #include
27 |
28 | QT_BEGIN_NAMESPACE
29 |
30 | class QOrmFilterExpression;
31 |
32 | class Q_ORM_EXPORT QOrmClassProperty
33 | {
34 | public:
35 | explicit QOrmClassProperty(const char* descriptor);
36 |
37 | QString descriptor() const;
38 |
39 | QOrmFilterExpression contains(const QVariant& value) const;
40 | QOrmFilterExpression notContains(const QVariant& value) const;
41 |
42 | private:
43 | QString m_descriptor;
44 | };
45 |
46 | extern Q_ORM_EXPORT QDebug operator<<(QDebug dbg, const QOrmClassProperty& classProperty);
47 |
48 | #define Q_ORM_CLASS_PROPERTY(descriptor) (QOrmClassProperty{#descriptor})
49 |
50 | QT_END_NAMESPACE
51 |
52 | #endif // QORMCLASSPROPERTY_H
53 |
--------------------------------------------------------------------------------
/tests/auto/qormsession/domain/town.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "town.h"
22 |
23 | Town::Town(QObject* parent)
24 | : QObject(parent)
25 | {
26 | }
27 |
28 | int Town::id() const
29 | {
30 | return m_id;
31 | }
32 |
33 | QString Town::name() const
34 | {
35 | return m_name;
36 | }
37 |
38 | void Town::setId(int id)
39 | {
40 | if (m_id == id)
41 | return;
42 |
43 | m_id = id;
44 | emit idChanged(m_id);
45 | }
46 |
47 | void Town::setName(QString name)
48 | {
49 | if (m_name == name)
50 | return;
51 |
52 | m_name = name;
53 | emit nameChanged(m_name);
54 | }
55 |
56 | Province* Town::province() const
57 | {
58 | return m_province;
59 | }
60 |
61 | void Town::setProvince(Province* province)
62 | {
63 | if (m_province == province)
64 | return;
65 |
66 | m_province = province;
67 | emit provinceChanged(m_province);
68 | }
69 |
--------------------------------------------------------------------------------
/tests/auto/qormentityinstancecache/domain/town.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "town.h"
22 |
23 | Town::Town(QObject* parent)
24 | : QObject(parent)
25 | {
26 | }
27 |
28 | int Town::id() const
29 | {
30 | return m_id;
31 | }
32 |
33 | QString Town::name() const
34 | {
35 | return m_name;
36 | }
37 |
38 | void Town::setId(int id)
39 | {
40 | if (m_id == id)
41 | return;
42 |
43 | m_id = id;
44 | emit idChanged(m_id);
45 | }
46 |
47 | void Town::setName(QString name)
48 | {
49 | if (m_name == name)
50 | return;
51 |
52 | m_name = name;
53 | emit nameChanged(m_name);
54 | }
55 |
56 | Province* Town::province() const
57 | {
58 | return m_province;
59 | }
60 |
61 | void Town::setProvince(Province* province)
62 | {
63 | if (m_province == province)
64 | return;
65 |
66 | m_province = province;
67 | emit provinceChanged(m_province);
68 | }
69 |
--------------------------------------------------------------------------------
/tests/auto/qormsqlitestatementgenerator/domain/town.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "town.h"
22 |
23 | Town::Town(QObject* parent)
24 | : QObject(parent)
25 | {
26 | }
27 |
28 | int Town::id() const
29 | {
30 | return m_id;
31 | }
32 |
33 | QString Town::name() const
34 | {
35 | return m_name;
36 | }
37 |
38 | void Town::setId(int id)
39 | {
40 | if (m_id == id)
41 | return;
42 |
43 | m_id = id;
44 | emit idChanged(m_id);
45 | }
46 |
47 | void Town::setName(QString name)
48 | {
49 | if (m_name == name)
50 | return;
51 |
52 | m_name = name;
53 | emit nameChanged(m_name);
54 | }
55 |
56 | Province* Town::province() const
57 | {
58 | return m_province;
59 | }
60 |
61 | void Town::setProvince(Province* province)
62 | {
63 | if (m_province == province)
64 | return;
65 |
66 | m_province = province;
67 | emit provinceChanged(m_province);
68 | }
69 |
--------------------------------------------------------------------------------
/src/orm/qormentitylistmodel.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 Dmitriy Purgin
3 | * Copyright (C) 2020 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "qormentitylistmodel.h"
22 |
23 | QT_BEGIN_NAMESPACE
24 |
25 | QOrmEntityListModelBase::QOrmEntityListModelBase(QObject* parent)
26 | : QAbstractListModel{parent}
27 | {
28 | }
29 |
30 | QVariantMap QOrmEntityListModelBase::filter() const
31 | {
32 | return m_filter;
33 | }
34 |
35 | void QOrmEntityListModelBase::setFilter(QVariantMap filter)
36 | {
37 | if (m_filter != filter)
38 | {
39 | m_filter = filter;
40 | Q_EMIT filterChanged();
41 | onFilterChanged();
42 | }
43 | }
44 |
45 | QVariantList QOrmEntityListModelBase::order() const
46 | {
47 | return m_order;
48 | }
49 |
50 | void QOrmEntityListModelBase::setOrder(QVariantList order)
51 | {
52 | if (m_order != order)
53 | {
54 | m_order = order;
55 | Q_EMIT orderChanged();
56 | onOrderChanged();
57 | }
58 | }
59 |
60 | QT_END_NAMESPACE
61 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 |
3 | project(QtOrm LANGUAGES CXX)
4 |
5 | # https://stackoverflow.com/questions/25199677/how-to-detect-if-current-scope-has-a-parent-in-cmake
6 | get_directory_property(hasParent PARENT_DIRECTORY)
7 |
8 | if (hasParent)
9 | option(QTORM_BUILD_EXAMPLES "Build QtOrm examples" OFF)
10 | option(QTORM_BUILD_TESTS "Build QtOrm tests" OFF)
11 | else()
12 | option(QTORM_BUILD_EXAMPLES "Build QtOrm examples" ON)
13 | option(QTORM_BUILD_TESTS "Build QtOrm tests" ON)
14 | endif()
15 |
16 | option(QTORM_BUILD_SHARED_LIBS "Build QtOrm as shared library (LGPLv3)" ON)
17 | set(QTORM_QT_VERSION_HINT "auto" CACHE STRING "Qt version to use (5, 6, or auto)")
18 |
19 | if (QTORM_QT_VERSION_HINT STREQUAL "auto")
20 | find_package(Qt6 COMPONENTS Core QUIET)
21 |
22 | if (Qt6_FOUND)
23 | set(QTORM_QT_VERSION_MAJOR 6)
24 | else()
25 | set(QTORM_QT_VERSION_MAJOR 5)
26 | endif()
27 | else()
28 | set(QTORM_QT_VERSION_MAJOR ${QTORM_QT_VERSION_HINT})
29 | endif()
30 |
31 | message("QtOrm Configuration:")
32 | message(" Examples: ${QTORM_BUILD_EXAMPLES}")
33 | message(" Tests: ${QTORM_BUILD_TESTS}")
34 | message(" Shared libs (LGPLv3): ${QTORM_BUILD_SHARED_LIBS}")
35 | message(" Qt version: ${QTORM_QT_VERSION_HINT}, detected ${QTORM_QT_VERSION_MAJOR}")
36 |
37 | set(CMAKE_AUTOMOC ON)
38 | set(CMAKE_AUTORCC ON)
39 |
40 | find_package(Qt${QTORM_QT_VERSION_MAJOR} COMPONENTS Core Sql REQUIRED)
41 |
42 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
43 |
44 | include(ExtractClassNames)
45 | include(GetGeneratedHeaders)
46 |
47 | add_subdirectory(src)
48 |
49 | if (QTORM_BUILD_EXAMPLES)
50 | add_subdirectory(examples)
51 | endif()
52 |
53 | if (QTORM_BUILD_TESTS)
54 | enable_testing()
55 | add_subdirectory(tests)
56 | endif()
57 |
--------------------------------------------------------------------------------
/src/orm/qormerror.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 Dmitriy Purgin
3 | * Copyright (C) 2019-2021 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #ifndef QORMERROR_H
22 | #define QORMERROR_H
23 |
24 | #include
25 |
26 | #include
27 |
28 | QT_BEGIN_NAMESPACE
29 |
30 | class QDebug;
31 |
32 | class Q_ORM_EXPORT QOrmError
33 | {
34 | public:
35 | QOrmError();
36 | QOrmError(QOrm::ErrorType type, const QString& text);
37 |
38 | [[nodiscard]] QOrm::ErrorType type() const;
39 | [[nodiscard]] QString text() const;
40 |
41 | [[nodiscard]] bool operator==(QOrm::ErrorType errorType) const { return m_type == errorType; }
42 |
43 | [[nodiscard]] bool operator!=(QOrm::ErrorType errorType) const
44 | {
45 | return !operator==(errorType);
46 | }
47 |
48 | private:
49 | QOrm::ErrorType m_type{QOrm::ErrorType::None};
50 | QString m_text;
51 | };
52 |
53 | extern Q_ORM_EXPORT QDebug operator<<(QDebug dbg, const QOrmError& error);
54 |
55 | QT_END_NAMESPACE
56 |
57 | #endif // QORMERROR_H
58 |
--------------------------------------------------------------------------------
/tests/auto/qormentitylistmodel/domain/town.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 Dmitriy Purgin
3 | * Copyright (C) 2019 Dmitriy Purgin
4 | * Copyright (C) 2019 sequality software engineering e.U.
5 | *
6 | * This file is part of QtOrm library.
7 | *
8 | * QtOrm is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation, either version 3 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * QtOrm is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with QtOrm. If not, see .
20 | */
21 |
22 | #include "town.h"
23 |
24 | Town::Town(QObject* parent)
25 | : QObject(parent)
26 | {
27 | }
28 |
29 | int Town::id() const
30 | {
31 | return m_id;
32 | }
33 |
34 | QString Town::name() const
35 | {
36 | return m_name;
37 | }
38 |
39 | void Town::setId(int id)
40 | {
41 | if (m_id == id)
42 | return;
43 |
44 | m_id = id;
45 | emit idChanged(m_id);
46 | }
47 |
48 | void Town::setName(QString name)
49 | {
50 | if (m_name == name)
51 | return;
52 |
53 | m_name = name;
54 | emit nameChanged(m_name);
55 | }
56 |
57 | Province* Town::province() const
58 | {
59 | return m_province;
60 | }
61 |
62 | void Town::setProvince(Province* province)
63 | {
64 | if (m_province == province)
65 | return;
66 |
67 | m_province = province;
68 | emit provinceChanged(m_province);
69 | }
70 |
--------------------------------------------------------------------------------
/tests/auto/qormmetadatacache/domain/person.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2025 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #pragma once
22 |
23 | #include
24 |
25 | #include "town.h"
26 |
27 | class Person : public QObject
28 | {
29 | Q_OBJECT
30 |
31 | Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
32 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
33 | Q_PROPERTY(Town* town READ town WRITE setTown NOTIFY townChanged)
34 |
35 | int m_id;
36 | QString m_name;
37 | Town* m_town{nullptr};
38 |
39 | public:
40 | Q_INVOKABLE Person() = default;
41 | explicit Person(QString name);
42 |
43 | int id() const { return m_id; }
44 | void setId(int id);
45 |
46 | QString name() const { return m_name; }
47 | void setName(QString name);
48 |
49 | Town* town() const { return m_town; }
50 | void setTown(Town* town);
51 |
52 | signals:
53 | void idChanged(int id);
54 | void nameChanged(QString name);
55 | void townChanged(Town* town);
56 | };
57 |
--------------------------------------------------------------------------------
/src/orm/qormrelation.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #ifndef QORMRELATION_H
22 | #define QORMRELATION_H
23 |
24 | #include
25 |
26 | #include
27 |
28 | QT_BEGIN_NAMESPACE
29 |
30 | class QOrmMetadata;
31 | class QOrmQuery;
32 | class QOrmRelationPrivate;
33 |
34 | class Q_ORM_EXPORT QOrmRelation
35 | {
36 | public:
37 | explicit QOrmRelation(const QOrmMetadata& mapping);
38 | explicit QOrmRelation(const QOrmQuery& query);
39 | QOrmRelation(const QOrmRelation&);
40 | QOrmRelation(QOrmRelation&&);
41 | ~QOrmRelation();
42 |
43 | QOrmRelation& operator=(const QOrmRelation&);
44 | QOrmRelation& operator=(QOrmRelation&&);
45 |
46 | QOrm::RelationType type() const;
47 | const QOrmMetadata* mapping() const;
48 | const QOrmQuery* query() const;
49 |
50 | private:
51 | QSharedDataPointer d;
52 | };
53 |
54 | extern Q_ORM_EXPORT QDebug operator<<(QDebug dbg, const QOrmRelation& relation);
55 |
56 | QT_END_NAMESPACE
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/src/orm/qormtransactiontoken.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #ifndef QORMTRANSACTIONTOKEN_H
22 | #define QORMTRANSACTIONTOKEN_H
23 |
24 | #include
25 |
26 | #include
27 |
28 | QT_BEGIN_NAMESPACE
29 |
30 | class QOrmSession;
31 | class QOrmTransactionTokenPrivate;
32 |
33 | class Q_ORM_EXPORT QOrmTransactionToken
34 | {
35 | public:
36 | QOrmTransactionToken(QOrmSession* session, QOrm::TransactionAction finalAction);
37 | QOrmTransactionToken(const QOrmTransactionToken&) = delete;
38 | QOrmTransactionToken(QOrmTransactionToken&&);
39 | ~QOrmTransactionToken();
40 |
41 | QOrmTransactionToken& operator=(const QOrmTransactionToken&) = delete;
42 | QOrmTransactionToken& operator=(QOrmTransactionToken&&);
43 |
44 | Q_REQUIRED_RESULT bool isEngaged() const;
45 | void disengage();
46 |
47 | bool commit();
48 | bool rollback();
49 |
50 | private:
51 | std::unique_ptr d;
52 | };
53 |
54 | QT_END_NAMESPACE
55 |
56 | #endif // QORMTRANSACTIONTOKEN_H
57 |
--------------------------------------------------------------------------------
/src/orm/qormclassproperty.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2022 Dmitriy Purgin
3 | * Copyright (C) 2019-2022 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "qormclassproperty.h"
22 | #include "qormfilterexpression.h"
23 |
24 | #include
25 |
26 | QT_BEGIN_NAMESPACE
27 |
28 | QDebug operator<<(QDebug dbg, const QOrmClassProperty& classProperty)
29 | {
30 | QDebugStateSaver saver{dbg};
31 |
32 | dbg.noquote().nospace() << "QOrmClassProperty(\"" << classProperty.descriptor() << "\")";
33 |
34 | return dbg;
35 | }
36 |
37 | QOrmClassProperty::QOrmClassProperty(const char* descriptor)
38 | : m_descriptor{descriptor}
39 | {
40 | }
41 |
42 | QString QOrmClassProperty::descriptor() const
43 | {
44 | return m_descriptor;
45 | }
46 |
47 | QOrmFilterExpression QOrmClassProperty::contains(const QVariant& value) const
48 | {
49 | return QOrmFilterTerminalPredicate{*this, QOrm::Comparison::Contains, value};
50 | }
51 |
52 | QOrmFilterExpression QOrmClassProperty::notContains(const QVariant& value) const
53 | {
54 | return QOrmFilterTerminalPredicate{*this, QOrm::Comparison::NotContains, value};
55 | }
56 |
57 | QT_END_NAMESPACE
58 |
--------------------------------------------------------------------------------
/src/orm/qormentityinstancecache.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #ifndef QORMENTITYINSTANCECACHE_H
22 | #define QORMENTITYINSTANCECACHE_H
23 |
24 | #include
25 | #include
26 | #include
27 |
28 | QT_BEGIN_NAMESPACE
29 |
30 | class QOrmEntityInstanceCachePrivate;
31 | class QOrmMetadata;
32 |
33 | class Q_ORM_EXPORT QOrmEntityInstanceCache
34 | {
35 | Q_DISABLE_COPY(QOrmEntityInstanceCache)
36 |
37 | public:
38 | QOrmEntityInstanceCache();
39 | ~QOrmEntityInstanceCache();
40 |
41 | QObject* get(const QOrmMetadata& meta, const QVariant& objectId);
42 | bool contains(const QObject* instance) const;
43 | void insert(const QOrmMetadata& meta, QObject* instance);
44 | QObject* take(QObject* instance);
45 |
46 | void finalize(const QOrmMetadata& metadata, QObject* instance);
47 | bool isModified(const QObject* instance) const;
48 | void markUnmodified(const QObject* instance) const;
49 |
50 | private:
51 | QScopedPointer d;
52 | };
53 |
54 | QT_END_NAMESPACE
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/tests/auto/qormsession/domain/town.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #pragma once
22 |
23 | #include
24 |
25 | class Province;
26 |
27 | class Town : public QObject
28 | {
29 | Q_OBJECT
30 |
31 | Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
32 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
33 | Q_PROPERTY(Province* province READ province WRITE setProvince NOTIFY provinceChanged)
34 |
35 | int m_id;
36 | QString m_name;
37 | Province* m_province = nullptr;
38 |
39 | public:
40 | Q_INVOKABLE explicit Town(QObject* parent = nullptr);
41 | Town(const QString& name, Province* province)
42 | : m_name{name}
43 | , m_province{province}
44 | {
45 | }
46 |
47 | int id() const;
48 | void setId(int id);
49 |
50 | QString name() const;
51 | void setName(QString name);
52 |
53 | Province* province() const;
54 | void setProvince(Province* province);
55 |
56 | signals:
57 | void idChanged(int id);
58 | void nameChanged(QString name);
59 | void provinceChanged(Province* province);
60 | };
61 |
--------------------------------------------------------------------------------
/src/orm/qormsqliteconfiguration.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "qormsqliteconfiguration.h"
22 |
23 | QT_BEGIN_NAMESPACE
24 |
25 | QString QOrmSqliteConfiguration::connectOptions() const
26 | {
27 | return m_connectOptions;
28 | }
29 |
30 | void QOrmSqliteConfiguration::setConnectOptions(const QString& connectOptions)
31 | {
32 | m_connectOptions = connectOptions;
33 | }
34 |
35 | QString QOrmSqliteConfiguration::databaseName() const
36 | {
37 | return m_databaseName;
38 | }
39 |
40 | void QOrmSqliteConfiguration::setDatabaseName(const QString& databaseName)
41 | {
42 | m_databaseName = databaseName;
43 | }
44 |
45 | bool QOrmSqliteConfiguration::verbose() const
46 | {
47 | return m_verbose;
48 | }
49 |
50 | void QOrmSqliteConfiguration::setVerbose(bool verbose)
51 | {
52 | m_verbose = verbose;
53 | }
54 |
55 | QOrmSqliteConfiguration::SchemaMode QOrmSqliteConfiguration::schemaMode() const
56 | {
57 | return m_schemaMode;
58 | }
59 |
60 | void QOrmSqliteConfiguration::setSchemaMode(SchemaMode schemaMode)
61 | {
62 | m_schemaMode = schemaMode;
63 | }
64 |
65 | QT_END_NAMESPACE
66 |
--------------------------------------------------------------------------------
/src/orm/qormabstractprovider.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019-2022 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #ifndef QORMABSTRACTPROVIDER_H
22 | #define QORMABSTRACTPROVIDER_H
23 |
24 | #include
25 | #include
26 |
27 | QT_BEGIN_NAMESPACE
28 |
29 | class QObject;
30 | class QOrmEntityInstanceCache;
31 | class QOrmError;
32 | class QOrmMetadataCache;
33 | class QOrmQuery;
34 |
35 | class Q_ORM_EXPORT QOrmAbstractProvider
36 | {
37 | public:
38 | virtual ~QOrmAbstractProvider();
39 |
40 | virtual QOrmError connectToBackend() = 0;
41 | virtual QOrmError disconnectFromBackend() = 0;
42 | virtual bool isConnectedToBackend() = 0;
43 |
44 | virtual QOrmError beginTransaction() = 0;
45 | virtual QOrmError commitTransaction() = 0;
46 | virtual QOrmError rollbackTransaction() = 0;
47 |
48 | virtual QOrmQueryResult execute(const QOrmQuery& query,
49 | QOrmEntityInstanceCache& entityInstanceCache) = 0;
50 |
51 | [[nodiscard]] virtual int capabilities() const = 0;
52 | };
53 |
54 | QT_END_NAMESPACE
55 |
56 | #endif // QORMABSTRACTPROVIDER_H
57 |
--------------------------------------------------------------------------------
/tests/auto/qormmetadatacache/domain/town.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #pragma once
22 |
23 | #include
24 | #include
25 |
26 | class Person;
27 |
28 | class Town : public QObject
29 | {
30 | Q_OBJECT
31 |
32 | Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
33 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
34 | Q_PROPERTY(
35 | QVector population READ population WRITE setPopulation NOTIFY populationChanged)
36 |
37 | int m_id;
38 | QString m_name;
39 | QVector m_population;
40 |
41 | public:
42 | Q_INVOKABLE explicit Town(QObject* parent = nullptr);
43 |
44 | virtual ~Town() {}
45 |
46 | int id() const { return m_id; }
47 | void setId(int id);
48 |
49 | QString name() const { return m_name; }
50 | void setName(QString name);
51 |
52 | QVector population() const { return m_population; }
53 | void setPopulation(QVector population);
54 |
55 | signals:
56 | void idChanged(int id);
57 | void nameChanged(QString name);
58 | void populationChanged(QVector population);
59 | };
60 |
--------------------------------------------------------------------------------
/tests/auto/qormentityinstancecache/domain/town.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #pragma once
22 |
23 | #include
24 |
25 | class Province;
26 |
27 | class Town : public QObject
28 | {
29 | Q_OBJECT
30 |
31 | Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
32 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
33 | Q_PROPERTY(Province* province READ province WRITE setProvince NOTIFY provinceChanged)
34 |
35 | int m_id;
36 | QString m_name;
37 | Province* m_province = nullptr;
38 |
39 | public:
40 | Q_INVOKABLE explicit Town(QObject* parent = nullptr);
41 | Town(int id, const QString& name, Province* province)
42 | : m_id{id}
43 | , m_name{name}
44 | , m_province{province}
45 | {
46 | }
47 |
48 | int id() const;
49 | void setId(int id);
50 |
51 | QString name() const;
52 | void setName(QString name);
53 |
54 | Province* province() const;
55 | void setProvince(Province* province);
56 |
57 | signals:
58 | void idChanged(int id);
59 | void nameChanged(QString name);
60 | void provinceChanged(Province* province);
61 | };
62 |
--------------------------------------------------------------------------------
/src/orm/qormmetadatacache.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #ifndef QORMMETADATACACHE_H
22 | #define QORMMETADATACACHE_H
23 |
24 | #include
25 | #include
26 |
27 | #include
28 |
29 | QT_BEGIN_NAMESPACE
30 |
31 | class QOrmMetadata;
32 | class QOrmMetadataCachePrivate;
33 | class QMetaObject;
34 |
35 | class Q_ORM_EXPORT QOrmMetadataCache
36 | {
37 | Q_DISABLE_COPY(QOrmMetadataCache)
38 |
39 | public:
40 | QOrmMetadataCache();
41 | QOrmMetadataCache(QOrmMetadataCache&&);
42 | ~QOrmMetadataCache();
43 |
44 | QOrmMetadataCache& operator=(QOrmMetadataCache&&);
45 |
46 | Q_REQUIRED_RESULT
47 | const QOrmMetadata& operator[](const QMetaObject& qMetaObject);
48 |
49 | template
50 | Q_REQUIRED_RESULT
51 | const QOrmMetadata& get()
52 | {
53 | return operator[](T::staticMetaObject);
54 | }
55 |
56 | Q_REQUIRED_RESULT
57 | const QOrmMetadata& get(const QMetaObject& qMetaObject) { return operator[](qMetaObject); }
58 |
59 | private:
60 | std::unique_ptr d;
61 | };
62 |
63 | QT_END_NAMESPACE
64 |
65 | #endif // QORMMETADATACACHE_H
66 |
--------------------------------------------------------------------------------
/tests/auto/qormentitylistmodel/domain/town.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 Dmitriy Purgin
3 | * Copyright (C) 2019 Dmitriy Purgin
4 | * Copyright (C) 2019 sequality software engineering e.U.
5 | *
6 | * This file is part of QtOrm library.
7 | *
8 | * QtOrm is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation, either version 3 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * QtOrm is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with QtOrm. If not, see .
20 | */
21 |
22 | #pragma once
23 |
24 | #include
25 |
26 | class Province;
27 |
28 | class Town : public QObject
29 | {
30 | Q_OBJECT
31 |
32 | Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
33 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
34 | Q_PROPERTY(Province* province READ province WRITE setProvince NOTIFY provinceChanged)
35 |
36 | int m_id;
37 | QString m_name;
38 | Province* m_province = nullptr;
39 |
40 | public:
41 | Q_INVOKABLE explicit Town(QObject* parent = nullptr);
42 | Town(const QString& name, Province* province)
43 | : m_name{name}
44 | , m_province{province}
45 | {
46 | }
47 |
48 | int id() const;
49 | void setId(int id);
50 |
51 | QString name() const;
52 | void setName(QString name);
53 |
54 | Province* province() const;
55 | void setProvince(Province* province);
56 |
57 | signals:
58 | void idChanged(int id);
59 | void nameChanged(QString name);
60 | void provinceChanged(Province* province);
61 | };
62 |
--------------------------------------------------------------------------------
/src/orm/qormsqliteconfiguration.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #ifndef QORMSQLCONFIGURATION_H
22 | #define QORMSQLCONFIGURATION_H
23 |
24 | #include
25 | #include
26 |
27 | QT_BEGIN_NAMESPACE
28 |
29 | class Q_ORM_EXPORT QOrmSqliteConfiguration
30 | {
31 | public:
32 | enum class SchemaMode
33 | {
34 | Recreate,
35 | Update,
36 | Validate,
37 | Bypass,
38 | Append
39 | };
40 |
41 | public:
42 | Q_REQUIRED_RESULT
43 | QString connectOptions() const;
44 | void setConnectOptions(const QString& connectOptions);
45 |
46 | Q_REQUIRED_RESULT
47 | QString databaseName() const;
48 | void setDatabaseName(const QString& databaseName);
49 |
50 | Q_REQUIRED_RESULT
51 | bool verbose() const;
52 | void setVerbose(bool verbose);
53 |
54 | Q_REQUIRED_RESULT
55 | SchemaMode schemaMode() const;
56 | void setSchemaMode(SchemaMode schemaMode);
57 |
58 | private:
59 | QString m_connectOptions;
60 | QString m_databaseName;
61 | bool m_verbose{false};
62 | SchemaMode m_schemaMode;
63 | };
64 |
65 | QT_END_NAMESPACE
66 |
67 | #endif // QORMSQLCONFIGURATION_H
68 |
--------------------------------------------------------------------------------
/tests/auto/qormsqlitestatementgenerator/domain/town.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #pragma once
22 |
23 | #include
24 |
25 | class Province;
26 |
27 | class Town : public QObject
28 | {
29 | Q_OBJECT
30 |
31 | Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
32 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
33 | Q_PROPERTY(Province* province READ province WRITE setProvince NOTIFY provinceChanged)
34 |
35 | int m_id;
36 | QString m_name;
37 | Province* m_province = nullptr;
38 |
39 | public:
40 | Q_INVOKABLE explicit Town(QObject* parent = nullptr);
41 | Town(int id, const QString& name, Province* province)
42 | : m_id{id}
43 | , m_name{name}
44 | , m_province{province}
45 | {
46 | }
47 |
48 | Town(const QString& name, Province* province)
49 | : m_name{name}
50 | , m_province{province}
51 | {
52 | }
53 |
54 | int id() const;
55 | void setId(int id);
56 |
57 | QString name() const;
58 | void setName(QString name);
59 |
60 | Province* province() const;
61 | void setProvince(Province* province);
62 |
63 | signals:
64 | void idChanged(int id);
65 | void nameChanged(QString name);
66 | void provinceChanged(Province* province);
67 | };
68 |
--------------------------------------------------------------------------------
/tests/auto/qormmetadatacache/domain/withenum.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2024 Dmitriy Purgin
3 | * Copyright (C) 2019-2024 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "withenum.h"
22 |
23 | int WithEnum::id() const
24 | {
25 | return m_id;
26 | }
27 |
28 | void WithEnum::setId(int id)
29 | {
30 | if (m_id != id)
31 | {
32 | m_id = id;
33 | emit idChanged();
34 | }
35 | }
36 |
37 | MyNamespace::MyEnum WithEnum::myEnum() const
38 | {
39 | return m_myEnum;
40 | }
41 |
42 | void WithEnum::setMyEnum(MyNamespace::MyEnum myEnum)
43 | {
44 | if (m_myEnum != myEnum)
45 | {
46 | m_myEnum = myEnum;
47 | emit myEnumChanged();
48 | }
49 | }
50 |
51 | MyNamespace::MyEnumClass WithEnum::myEnumClass() const
52 | {
53 | return m_myEnumClass;
54 | }
55 |
56 | void WithEnum::setMyEnumClass(MyNamespace::MyEnumClass myEnumClass)
57 | {
58 | if (m_myEnumClass != myEnumClass)
59 | {
60 | m_myEnumClass = myEnumClass;
61 | emit myEnumClassChanged();
62 | }
63 | }
64 |
65 | MyNamespace::WithNamespace* WithEnum::myNamespacedClass() const
66 | {
67 | return m_myNamespacedClass;
68 | }
69 |
70 | void WithEnum::setMyNamespacedClass(MyNamespace::WithNamespace* myNamespacedClass)
71 | {
72 | if (m_myNamespacedClass != myNamespacedClass)
73 | {
74 | m_myNamespacedClass = myNamespacedClass;
75 | emit myNamespacedClassChanged();
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/orm/qormsessionconfiguration.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #ifndef QORMSESSIONCONFIGURATION_H
22 | #define QORMSESSIONCONFIGURATION_H
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | #include
30 |
31 | QT_BEGIN_NAMESPACE
32 |
33 | class QOrmAbstractProvider;
34 | class QOrmSessionConfigurationData;
35 |
36 | class Q_ORM_EXPORT QOrmSessionConfiguration
37 | {
38 | public:
39 | static QOrmSessionConfiguration defaultConfiguration();
40 | static QOrmSessionConfiguration fromFile(const QString& filePath);
41 |
42 | public:
43 | QOrmSessionConfiguration(QOrmAbstractProvider* provider, bool isVerbose);
44 | QOrmSessionConfiguration(const QOrmSessionConfiguration&);
45 | QOrmSessionConfiguration(QOrmSessionConfiguration&&);
46 | ~QOrmSessionConfiguration();
47 |
48 | QOrmSessionConfiguration& operator=(const QOrmSessionConfiguration&);
49 | QOrmSessionConfiguration& operator=(QOrmSessionConfiguration&&);
50 |
51 | Q_REQUIRED_RESULT
52 | QOrmAbstractProvider* provider() const;
53 |
54 | Q_REQUIRED_RESULT
55 | bool isVerbose() const;
56 |
57 | private:
58 | QSharedDataPointer d;
59 | };
60 |
61 | QT_END_NAMESPACE
62 |
63 | #endif // QORMSESSIONCONFIGURATION_H
64 |
--------------------------------------------------------------------------------
/tests/auto/qormentityinstancecache/domain/province.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #pragma once
22 |
23 | #include
24 | #include
25 |
26 | class Town;
27 |
28 | class Province : public QObject
29 | {
30 | Q_OBJECT
31 | Q_DISABLE_COPY(Province)
32 |
33 | Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
34 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
35 | Q_PROPERTY(QVector towns READ towns WRITE setTowns NOTIFY townsChanged)
36 |
37 | int m_id;
38 |
39 | QString m_name;
40 |
41 | QVector m_towns;
42 |
43 | public:
44 | Q_INVOKABLE Province(QObject* parent = nullptr)
45 | : QObject(parent)
46 | {
47 | }
48 | explicit Province(int id, const QString& name, QObject* parent = nullptr)
49 | : QObject{parent}
50 | , m_id{id}
51 | , m_name{name}
52 | {
53 | }
54 |
55 | virtual ~Province() {}
56 | int id() const { return m_id; }
57 | QString name() const { return m_name; }
58 |
59 | QVector towns() const { return m_towns; }
60 |
61 | public slots:
62 | void setId(int id);
63 | void setName(QString name);
64 | void setTowns(QVector towns);
65 |
66 | signals:
67 | void idChanged(int id);
68 | void nameChanged(QString name);
69 | void townsChanged(QVector towns);
70 | };
71 |
--------------------------------------------------------------------------------
/src/orm/qormfilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #ifndef QORMFILTER_H
22 | #define QORMFILTER_H
23 |
24 | #include
25 | #include
26 |
27 | #include
28 |
29 | QT_BEGIN_NAMESPACE
30 |
31 | class Q_ORM_EXPORT QOrmFilter
32 | {
33 | public:
34 | using Predicate = std::function;
35 |
36 | explicit QOrmFilter(QOrmFilterExpression expression)
37 | : m_type{QOrm::FilterType::Expression}
38 | , m_filter{std::move(expression)}
39 | {
40 | }
41 |
42 | explicit QOrmFilter(Predicate invokable)
43 | : m_type{QOrm::FilterType::Invokable}
44 | , m_filter{std::move(invokable)}
45 | {
46 | }
47 |
48 | Q_REQUIRED_RESULT
49 | QOrm::FilterType type() const
50 | {
51 | return m_type;
52 | }
53 |
54 | Q_REQUIRED_RESULT
55 | const QOrmFilterExpression* expression() const
56 | {
57 | return std::get_if(&m_filter);
58 | }
59 |
60 | Q_REQUIRED_RESULT
61 | const Predicate* invokable() const { return std::get_if(&m_filter); }
62 |
63 | private:
64 | QOrm::FilterType m_type;
65 | std::variant m_filter{nullptr};
66 | };
67 |
68 | extern Q_ORM_EXPORT QDebug operator<<(QDebug debug, const QOrmFilter& filter);
69 |
70 | QT_END_NAMESPACE
71 |
72 | #endif
73 |
--------------------------------------------------------------------------------
/tests/auto/qormsqlitestatementgenerator/domain/withenum.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2024 Dmitriy Purgin
3 | * Copyright (C) 2019-2024 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "withenum.h"
22 |
23 | namespace MyNamespace
24 | {
25 | void WithNamespace::setId(int id)
26 | {
27 | if (m_id != id)
28 | {
29 | m_id = id;
30 | emit idChanged();
31 | }
32 | }
33 |
34 | void WithNamespace::setValue(QString value)
35 | {
36 | if (m_value != value)
37 | {
38 | m_value = value;
39 | emit valueChanged();
40 | }
41 | }
42 |
43 | } // namespace MyNamespace
44 |
45 | int WithEnum::id() const
46 | {
47 | return m_id;
48 | }
49 |
50 | void WithEnum::setId(int id)
51 | {
52 | if (m_id != id)
53 | {
54 | m_id = id;
55 | emit idChanged();
56 | }
57 | }
58 |
59 | MyNamespace::MyEnum WithEnum::myEnum() const
60 | {
61 | return m_myEnum;
62 | }
63 |
64 | void WithEnum::setMyEnum(MyNamespace::MyEnum myEnum)
65 | {
66 | if (m_myEnum != myEnum)
67 | {
68 | m_myEnum = myEnum;
69 | emit myEnumChanged();
70 | }
71 | }
72 |
73 | MyNamespace::MyEnumClass WithEnum::myEnumClass() const
74 | {
75 | return m_myEnumClass;
76 | }
77 |
78 | void WithEnum::setMyEnumClass(MyNamespace::MyEnumClass myEnumClass)
79 | {
80 | if (m_myEnumClass != myEnumClass)
81 | {
82 | m_myEnumClass = myEnumClass;
83 | emit myEnumClassChanged();
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/tests/auto/qormsqlitestatementgenerator/domain/province.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #pragma once
22 |
23 | #include
24 | #include
25 |
26 | class Town;
27 |
28 | class Province : public QObject
29 | {
30 | Q_OBJECT
31 | Q_DISABLE_COPY(Province)
32 |
33 | Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
34 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
35 | Q_PROPERTY(QVector towns READ towns WRITE setTowns NOTIFY townsChanged)
36 |
37 | int m_id;
38 | QString m_name;
39 | QVector m_towns;
40 |
41 | public:
42 | Q_INVOKABLE Province(QObject* parent = nullptr)
43 | : QObject(parent)
44 | {
45 | }
46 | explicit Province(const QString& name, QObject* parent = nullptr)
47 | : QObject{parent}
48 | , m_name{name}
49 | {
50 | }
51 | Province(int id, QString name, QObject* parent = nullptr)
52 | : QObject{parent}
53 | , m_id{id}
54 | , m_name{name}
55 | {
56 | }
57 |
58 | virtual ~Province() {}
59 | int id() const { return m_id; }
60 | QString name() const { return m_name; }
61 |
62 | QVector towns() const { return m_towns; }
63 |
64 | public slots:
65 | void setId(int id);
66 | void setName(QString name);
67 | void setTowns(QVector towns);
68 |
69 | signals:
70 | void idChanged(int id);
71 | void nameChanged(QString name);
72 | void townsChanged(QVector towns);
73 | };
74 |
--------------------------------------------------------------------------------
/tests/auto/qormsession/domain/province.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #pragma once
22 |
23 | #include
24 | #include
25 |
26 | class Town;
27 |
28 | class Province : public QObject
29 | {
30 | Q_OBJECT
31 | Q_DISABLE_COPY(Province)
32 |
33 | Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
34 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
35 | Q_PROPERTY(QVector towns READ towns WRITE setTowns NOTIFY townsChanged)
36 |
37 | int m_id;
38 |
39 | QString m_name;
40 |
41 | QVector m_towns;
42 |
43 | public:
44 | Q_INVOKABLE Province(QObject* parent = nullptr)
45 | : QObject(parent)
46 | {
47 | }
48 | explicit Province(const QString& name, QObject* parent = nullptr)
49 | : QObject{parent}
50 | , m_name{name}
51 | {
52 | }
53 | Province(int id, const QString& name, QObject* parent = nullptr)
54 | : QObject{parent}
55 | , m_id{id}
56 | , m_name{name}
57 | {
58 | }
59 |
60 | virtual ~Province() {}
61 | int id() const { return m_id; }
62 | QString name() const { return m_name; }
63 |
64 | QVector towns() const { return m_towns; }
65 |
66 | public slots:
67 | void setId(int id);
68 | void setName(QString name);
69 | void setTowns(QVector towns);
70 |
71 | signals:
72 | void idChanged(int id);
73 | void nameChanged(QString name);
74 | void townsChanged(QVector towns);
75 | };
76 |
--------------------------------------------------------------------------------
/tests/auto/qormentitylistmodel/domain/province.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 Dmitriy Purgin
3 | * Copyright (C) 2019 Dmitriy Purgin
4 | * Copyright (C) 2019 sequality software engineering e.U.
5 | *
6 | * This file is part of QtOrm library.
7 | *
8 | * QtOrm is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation, either version 3 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * QtOrm is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with QtOrm. If not, see .
20 | */
21 |
22 | #pragma once
23 |
24 | #include
25 | #include
26 |
27 | class Town;
28 |
29 | class Province : public QObject
30 | {
31 | Q_OBJECT
32 | Q_DISABLE_COPY(Province)
33 |
34 | Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
35 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
36 | Q_PROPERTY(QVector towns READ towns WRITE setTowns NOTIFY townsChanged)
37 |
38 | int m_id;
39 | QString m_name;
40 | QVector m_towns;
41 |
42 | public:
43 | Q_INVOKABLE Province(QObject* parent = nullptr)
44 | : QObject(parent)
45 | {
46 | }
47 | explicit Province(const QString& name, QObject* parent = nullptr)
48 | : QObject{parent}
49 | , m_name{name}
50 | {
51 | }
52 | Province(int id, const QString& name, QObject* parent = nullptr)
53 | : QObject{parent}
54 | , m_id{id}
55 | , m_name{name}
56 | {
57 | }
58 |
59 | virtual ~Province() {}
60 | int id() const { return m_id; }
61 | QString name() const { return m_name; }
62 |
63 | QVector towns() const { return m_towns; }
64 |
65 | public slots:
66 | void setId(int id);
67 | void setName(QString name);
68 | void setTowns(QVector towns);
69 |
70 | signals:
71 | void idChanged(int id);
72 | void nameChanged(QString name);
73 | void townsChanged(QVector towns);
74 | };
75 |
--------------------------------------------------------------------------------
/src/orm/qormmetadata.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 Dmitriy Purgin
3 | * Copyright (C) 2019-2021 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #ifndef QORMMETADATA_H
22 | #define QORMMETADATA_H
23 |
24 | #include
25 | #include
26 |
27 | #include
28 |
29 | #include
30 | #include
31 |
32 | QT_BEGIN_NAMESPACE
33 |
34 | class QDebug;
35 | class QOrmMetadataPrivate;
36 |
37 | class Q_ORM_EXPORT QOrmMetadata
38 | {
39 | public:
40 | explicit QOrmMetadata(const QOrmMetadataPrivate* data);
41 |
42 | QOrmMetadata(const QOrmMetadata&);
43 | QOrmMetadata(QOrmMetadata&&);
44 | ~QOrmMetadata();
45 |
46 | QOrmMetadata& operator=(const QOrmMetadata&);
47 | QOrmMetadata& operator=(QOrmMetadata&&);
48 |
49 | [[nodiscard]] const QMetaObject& qMetaObject() const;
50 |
51 | [[nodiscard]] QString className() const;
52 | [[nodiscard]] QString tableName() const;
53 |
54 | [[nodiscard]] const std::vector& propertyMappings() const;
55 | [[nodiscard]] const QOrmPropertyMapping* tableFieldMapping(const QString& fieldName) const;
56 | [[nodiscard]] const QOrmPropertyMapping* classPropertyMapping(
57 | const QString& classProperty) const;
58 | [[nodiscard]] const QOrmPropertyMapping* objectIdMapping() const;
59 | [[nodiscard]] const QOrmUserMetadata& userMetadata() const;
60 |
61 | private:
62 | QSharedDataPointer d;
63 | };
64 |
65 | extern Q_ORM_EXPORT QDebug operator<<(QDebug dbg, const QOrmMetadata& metadata);
66 |
67 | QT_END_NAMESPACE
68 |
69 | #endif // QORMMETADATA_H
70 |
--------------------------------------------------------------------------------
/src/orm/qormtransactiontoken.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #include "qormtransactiontoken.h"
22 |
23 | #include
24 |
25 | class QOrmTransactionTokenPrivate
26 | {
27 | friend class QOrmTransactionToken;
28 |
29 | QOrmTransactionTokenPrivate(QOrmSession* session, QOrm::TransactionAction action)
30 | : m_session{session}
31 | , m_action{action}
32 | {
33 | }
34 |
35 | QOrmSession* m_session{nullptr};
36 | QOrm::TransactionAction m_action;
37 | bool m_engaged{true};
38 | };
39 |
40 | QOrmTransactionToken::QOrmTransactionToken(QOrmSession* session, QOrm::TransactionAction action)
41 | : d{new QOrmTransactionTokenPrivate{session, action}}
42 | {
43 | }
44 |
45 | QOrmTransactionToken::QOrmTransactionToken(QOrmTransactionToken&&) = default;
46 |
47 | QOrmTransactionToken& QOrmTransactionToken::operator=(QOrmTransactionToken&&) = default;
48 |
49 | QOrmTransactionToken::~QOrmTransactionToken()
50 | {
51 | if (d->m_engaged)
52 | {
53 | if (d->m_action == QOrm::TransactionAction::Commit)
54 | d->m_session->commitTransaction();
55 | else
56 | d->m_session->rollbackTransaction();
57 | }
58 | }
59 |
60 | bool QOrmTransactionToken::isEngaged() const
61 | {
62 | return d->m_engaged;
63 | }
64 |
65 | void QOrmTransactionToken::disengage()
66 | {
67 | d->m_engaged = false;
68 | }
69 |
70 | bool QOrmTransactionToken::commit()
71 | {
72 | disengage();
73 | return d->m_session->commitTransaction();
74 | }
75 |
76 | bool QOrmTransactionToken::rollback()
77 | {
78 | disengage();
79 | return d->m_session->rollbackTransaction();
80 | }
81 |
--------------------------------------------------------------------------------
/tests/auto/qormsession/domain/person.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021 Dmitriy Purgin
3 | * Copyright (C) 2019 Dmitriy Purgin
4 | * Copyright (C) 2019 sequality software engineering e.U.
5 | *
6 | * This file is part of QtOrm library.
7 | *
8 | * QtOrm is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation, either version 3 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * QtOrm is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with QtOrm. If not, see .
20 | */
21 |
22 | #include "person.h"
23 |
24 | void Person::setId(int id)
25 | {
26 | if (m_id == id)
27 | return;
28 |
29 | m_id = id;
30 | emit idChanged(m_id);
31 | }
32 |
33 | void Person::setFirstName(QString firstName)
34 | {
35 | if (m_firstName == firstName)
36 | return;
37 |
38 | m_firstName = firstName;
39 | emit firstNameChanged(m_firstName);
40 | }
41 |
42 | void Person::setTown(Town* town)
43 | {
44 | if (m_town == town)
45 | return;
46 |
47 | m_town = town;
48 | emit townChanged(m_town);
49 | }
50 |
51 | QString Person::lastName() const
52 | {
53 | return m_lastName;
54 | }
55 |
56 | void Person::setLastName(QString lastName)
57 | {
58 | if (m_lastName == lastName)
59 | return;
60 |
61 | m_lastName = lastName;
62 | emit lastNameChanged(m_lastName);
63 | }
64 |
65 | Person* Person::personParent() const
66 | {
67 | return m_personParent;
68 | }
69 |
70 | void Person::setPersonParent(Person* personParent)
71 | {
72 | if (m_personParent == personParent)
73 | return;
74 |
75 | m_personParent = personParent;
76 | emit personParentChanged(personParent);
77 | }
78 |
79 | const QVector Person::personChildren() const
80 | {
81 | return m_personChildren;
82 | }
83 |
84 | void Person::setPersonChildren(const QVector personChildren)
85 | {
86 | if (m_personChildren == personChildren)
87 | return;
88 |
89 | m_personChildren = personChildren;
90 | emit personChildrenChanged(personChildren);
91 | }
92 |
--------------------------------------------------------------------------------
/src/orm/qormsqliteprovider.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020-2021 Dmitriy Purgin
3 | * Copyright (C) 2019-2022 Dmitriy Purgin
4 | * Copyright (C) 2019-2022 sequality software engineering e.U.
5 | *
6 | * This file is part of QtOrm library.
7 | *
8 | * QtOrm is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation, either version 3 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * QtOrm is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with QtOrm. If not, see .
20 | */
21 |
22 | #ifndef QORMSQLITEPROVIDER_H
23 | #define QORMSQLITEPROVIDER_H
24 |
25 | #include
26 | #include
27 | #include
28 |
29 | QT_BEGIN_NAMESPACE
30 |
31 | class QOrmEntityInstanceCache;
32 | class QOrmSqliteConfiguration;
33 | class QOrmSqliteProviderPrivate;
34 | class QSqlDatabase;
35 |
36 | class Q_ORM_EXPORT QOrmSqliteProvider : public QOrmAbstractProvider
37 | {
38 | public:
39 | enum SqliteCapability
40 | {
41 | NoCapabilities = 0,
42 | SupportsReturningClause = 1
43 | };
44 | Q_DECLARE_FLAGS(SqliteCapabilities, SqliteCapability)
45 |
46 | explicit QOrmSqliteProvider(const QOrmSqliteConfiguration& sqlConfiguration);
47 | ~QOrmSqliteProvider() override;
48 |
49 | QOrmError connectToBackend() override;
50 | QOrmError disconnectFromBackend() override;
51 | bool isConnectedToBackend() override;
52 |
53 | QOrmError beginTransaction() override;
54 | QOrmError commitTransaction() override;
55 | QOrmError rollbackTransaction() override;
56 |
57 | QOrmQueryResult execute(const QOrmQuery& query,
58 | QOrmEntityInstanceCache& entityInstanceCache) override;
59 |
60 | [[nodiscard]] int capabilities() const override;
61 |
62 | QOrmSqliteConfiguration configuration() const;
63 | QSqlDatabase database() const;
64 |
65 | private:
66 | Q_DECLARE_PRIVATE(QOrmSqliteProvider)
67 | QOrmSqliteProviderPrivate* d_ptr{nullptr};
68 | };
69 |
70 | QT_END_NAMESPACE
71 |
72 | #endif // QORMSQLITEPROVIDER_H
73 |
--------------------------------------------------------------------------------
/tests/auto/qormqueryresult/tst_queryresult.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | #include "domain/person.h"
8 |
9 | class QueryResultTest : public QObject
10 | {
11 | Q_OBJECT
12 |
13 | private slots:
14 | void testStlStyleConstIterator();
15 | void testStlStyleMutableIterator();
16 | };
17 |
18 | void QueryResultTest::testStlStyleConstIterator()
19 | {
20 | QOrmSession session;
21 |
22 | for (int i = 0; i < 3; ++i)
23 | {
24 | Person* person = new Person;
25 | person->setName(QString{"Person %1"}.arg(i));
26 |
27 | session.merge(person);
28 | }
29 |
30 | QOrmQueryResult result = session.from().select();
31 |
32 | auto it = std::cbegin(result);
33 | QCOMPARE((*it)->id(), 1);
34 | QCOMPARE((*it)->name(), "Person 0");
35 |
36 | ++it;
37 | QCOMPARE((*it)->id(), 2);
38 | QCOMPARE((*it)->name(), "Person 1");
39 |
40 | ++it;
41 | QCOMPARE((*it)->id(), 3);
42 | QCOMPARE((*it)->name(), "Person 2");
43 |
44 | ++it;
45 | QCOMPARE(it, std::cend(result));
46 | }
47 |
48 | void QueryResultTest::testStlStyleMutableIterator()
49 | {
50 | QOrmSession session;
51 |
52 | for (int i = 0; i < 3; ++i)
53 | {
54 | Person* person = new Person;
55 | person->setName(QString{"Person %1"}.arg(i));
56 |
57 | session.merge(person);
58 | }
59 |
60 | {
61 | QOrmQueryResult result = session.from().select();
62 |
63 | auto it = std::begin(result);
64 | Person* p1 = *it;
65 | QCOMPARE(p1->id(), 1);
66 | QCOMPARE(p1->name(), "Person 0");
67 | p1->setName("Person 00");
68 |
69 | ++it;
70 | Person* p2 = *it;
71 | QCOMPARE(p2->id(), 2);
72 | QCOMPARE(p2->name(), "Person 1");
73 | p2->setName("Person 11");
74 |
75 | ++it;
76 | Person* p3 = *it;
77 | QCOMPARE(p3->id(), 3);
78 | QCOMPARE(p3->name(), "Person 2");
79 | p3->setName("Person 22");
80 |
81 | ++it;
82 | QCOMPARE(it, std::end(result));
83 |
84 | QVERIFY(session.merge(p1, p2, p3));
85 | }
86 |
87 | {
88 | QOrmQueryResult result = session.from().select();
89 |
90 | for (Person* person : result)
91 | {
92 | QVERIFY(person->name().at(person->name().length() - 1) ==
93 | person->name().at(person->name().length() - 2));
94 | }
95 | }
96 | }
97 |
98 | QTEST_GUILESS_MAIN(QueryResultTest)
99 |
100 | #include "tst_queryresult.moc"
101 |
--------------------------------------------------------------------------------
/src/orm/qormpropertymapping.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 Dmitriy Purgin
3 | * Copyright (C) 2019-2021 sequality software engineering e.U.
4 | *
5 | * This file is part of QtOrm library.
6 | *
7 | * QtOrm is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU Lesser General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * QtOrm is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with QtOrm. If not, see .
19 | */
20 |
21 | #ifndef QORMPROPERTYMAPPING_H
22 | #define QORMPROPERTYMAPPING_H
23 |
24 | #include
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 | QT_BEGIN_NAMESPACE
32 |
33 | class QOrmMetadata;
34 | class QOrmPropertyMappingPrivate;
35 |
36 | class Q_ORM_EXPORT QOrmPropertyMapping
37 | {
38 | public:
39 | QOrmPropertyMapping(const QOrmMetadata& enclosingEntity,
40 | QMetaProperty qMetaProperty,
41 | QString classPropertyName,
42 | QString tableFieldName,
43 | bool isObjectId,
44 | bool isAutoGenerated,
45 | QMetaType::Type dataType,
46 | const QOrmMetadata* referencedEntity,
47 | bool isTransient,
48 | QOrmUserMetadata userMetadata);
49 | QOrmPropertyMapping(const QOrmPropertyMapping&);
50 | QOrmPropertyMapping(QOrmPropertyMapping&&);
51 | ~QOrmPropertyMapping();
52 |
53 | QOrmPropertyMapping& operator=(const QOrmPropertyMapping&);
54 | QOrmPropertyMapping& operator=(QOrmPropertyMapping&&);
55 |
56 | [[nodiscard]] const QOrmMetadata& enclosingEntity() const;
57 | [[nodiscard]] const QMetaProperty& qMetaProperty() const;
58 | [[nodiscard]] QString classPropertyName() const;
59 | [[nodiscard]] QString tableFieldName() const;
60 | [[nodiscard]] bool isObjectId() const;
61 | [[nodiscard]] bool isAutogenerated() const;
62 | [[nodiscard]] QMetaType::Type dataType() const;
63 | [[nodiscard]] QString dataTypeName() const;
64 | [[nodiscard]] bool isReference() const;
65 | [[nodiscard]] const QOrmMetadata* referencedEntity() const;
66 | [[nodiscard]] bool isTransient() const;
67 | [[nodiscard]] const QOrmUserMetadata& userMetadata() const;
68 |
69 | private:
70 | QSharedDataPointer d;
71 | };
72 |
73 | extern Q_ORM_EXPORT QDebug operator<<(QDebug dbg, const QOrmPropertyMapping& propertyMapping);
74 |
75 | QT_END_NAMESPACE
76 |
77 | #endif
78 |
--------------------------------------------------------------------------------
/examples/orm/navigationdb/domain/province.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Dmitriy Purgin
3 | * Copyright (C) 2019 sequality software engineering e.U.
4 | * All rights reserved.
5 | *
6 | * This file is part of the examples of the QtOrm library
7 | *
8 | * Redistribution and use in source and binary forms, with or without
9 | * modification, are permitted provided that the following conditions are met:
10 | * * Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | * * Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | * * Neither the name of the sequality software engineering e.U. nor the
16 | * names of its contributors may be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | */
30 |
31 | #ifndef PROVINCE_H
32 | #define PROVINCE_H
33 |
34 | #include
35 | #include
36 |
37 | class Community;
38 |
39 | class Province : public QObject
40 | {
41 | Q_OBJECT
42 |
43 | Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
44 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
45 | Q_PROPERTY(QVector communityList READ communityList WRITE setCommunityList NOTIFY
46 | communityListChanged)
47 |
48 | int m_id;
49 | QString m_name;
50 | QVector m_communityList;
51 |
52 | public:
53 | Q_INVOKABLE explicit Province(QObject* parent = nullptr);
54 | explicit Province(const QString& name, QObject* parent = nullptr);
55 |
56 | int id() const;
57 | void setId(int id);
58 |
59 | QString name() const;
60 | void setName(QString name);
61 |
62 | QVector communityList() const;
63 | void setCommunityList(const QVector& communityList);
64 |
65 | signals:
66 | void idChanged(int id);
67 | void nameChanged(QString name);
68 | void communityListChanged();
69 | };
70 |
71 | extern QDebug operator<<(QDebug dbg, const Province& province);
72 |
73 | #endif // PROVINCE_H
74 |
--------------------------------------------------------------------------------
/tests/auto/qormsession/domain/person.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021-2025 Dmitriy Purgin
3 | * Copyright (C) 2019 Dmitriy Purgin
4 | * Copyright (C) 2019 sequality software engineering e.U.
5 | *
6 | * This file is part of QtOrm library.
7 | *
8 | * QtOrm is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation, either version 3 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * QtOrm is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with QtOrm. If not, see .
20 | */
21 |
22 | #pragma once
23 |
24 | #include
25 | #include
26 |
27 | #include "person.h"
28 | #include "town.h"
29 |
30 | class Person : public QObject
31 | {
32 | Q_OBJECT
33 |
34 | Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
35 | Q_PROPERTY(QString firstName READ firstName WRITE setFirstName NOTIFY firstNameChanged)
36 | Q_PROPERTY(QString lastName READ lastName WRITE setLastName NOTIFY lastNameChanged)
37 | Q_PROPERTY(Town* town READ town WRITE setTown NOTIFY townChanged)
38 | Q_PROPERTY(
39 | Person* personParent READ personParent WRITE setPersonParent NOTIFY personParentChanged)
40 | Q_PROPERTY(QVector personChildren READ personChildren WRITE setPersonChildren NOTIFY
41 | personChildrenChanged)
42 |
43 | int m_id;
44 | QString m_firstName;
45 | QString m_lastName;
46 | Town* m_town{nullptr};
47 | Person* m_personParent{nullptr};
48 | QVector