-
Notifications
You must be signed in to change notification settings - Fork 114
Library can now also be compiled as a qml plugin / module #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,3 +75,5 @@ build-SortFilterProxyModel-* | |
| *.dll | ||
| *.exe | ||
|
|
||
| # QtCreator cmake profile | ||
| CMakeLists.txt.user | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,20 @@ | ||
| cmake_minimum_required(VERSION 3.1) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 11) | ||
| project(SortFilterProxyModel LANGUAGES CXX) | ||
|
|
||
| find_package(Qt5 REQUIRED | ||
| Core | ||
| Qml | ||
| ) | ||
|
|
||
| # Module version | ||
| set(SFP_MAJOR 0) | ||
| set(SFP_MINOR 2) | ||
|
|
||
| set(CMAKE_AUTOMOC ON) | ||
| set(CMAKE_INCLUDE_CURRENT_DIR ON) # This is to find generated *.moc and *.h files in build dir | ||
|
|
||
| add_library(SortFilterProxyModel OBJECT | ||
| set(SOURCES | ||
| qqmlsortfilterproxymodel.cpp | ||
| filters/filter.cpp | ||
| filters/filtercontainer.cpp | ||
|
|
@@ -35,15 +39,89 @@ add_library(SortFilterProxyModel OBJECT | |
| proxyroles/joinrole.cpp | ||
| proxyroles/switchrole.cpp | ||
| proxyroles/expressionrole.cpp | ||
| proxyroles/proxyrolesqmltypes.cpp | ||
| proxyroles/singlerole.cpp | ||
| proxyroles/proxyrolesqmltypes.cpp | ||
| proxyroles/singlerole.cpp | ||
| proxyroles/regexprole.cpp | ||
| sorters/filtersorter.cpp | ||
| proxyroles/filterrole.cpp | ||
| ) | ||
|
|
||
| target_include_directories(SortFilterProxyModel PUBLIC | ||
| ${CMAKE_CURRENT_LIST_DIR} | ||
| $<TARGET_PROPERTY:Qt5::Core,INTERFACE_INCLUDE_DIRECTORIES> | ||
| $<TARGET_PROPERTY:Qt5::Qml,INTERFACE_INCLUDE_DIRECTORIES> | ||
| # --- Object library to link directly with the application | ||
| add_library(SortFilterProxyModel OBJECT ${SOURCES}) | ||
| set_target_properties(SortFilterProxyModel | ||
| PROPERTIES | ||
| CXX_STANDARD 11 | ||
| EXCLUDE_FROM_ALL TRUE | ||
| ) | ||
| target_link_libraries(SortFilterProxyModel PUBLIC | ||
| Qt5::Core | ||
| Qt5::Qml | ||
| ) | ||
|
|
||
| # --- Plugin library | ||
| add_library(SortFilterProxyModelPlugin SHARED | ||
| ${SOURCES} | ||
| sortfilterproxymodelplugin.cpp | ||
| ) | ||
| target_link_libraries(SortFilterProxyModelPlugin PUBLIC | ||
| Qt5::Core | ||
| Qt5::Qml | ||
| ) | ||
|
|
||
| target_compile_definitions(SortFilterProxyModelPlugin | ||
| PRIVATE | ||
| QML_PLUGIN | ||
| QML_IMPORT_MAJOR_VERSION=${SFP_MAJOR} | ||
| QML_IMPORT_MINOR_VERSION=${SFP_MINOR} | ||
| ) | ||
| set_target_properties(SortFilterProxyModelPlugin | ||
| PROPERTIES | ||
| CXX_STANDARD 11 | ||
| OUTPUT_NAME sortfilterproxymodel | ||
| DEBUG_POSTFIX d | ||
| EXCLUDE_FROM_ALL TRUE | ||
| ) | ||
|
|
||
| # --- Create installed package | ||
| include(CMakePackageConfigHelpers) | ||
| include(GNUInstallDirs) | ||
| set(PACKAGE_NAME ${CMAKE_PROJECT_NAME}) | ||
|
|
||
| set(QML_MODULE_PATH qml_module) | ||
| configure_package_config_file( | ||
| cmake/SortFilterProxyModelConfig.cmake.in | ||
| ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}Config.cmake | ||
| INSTALL_DESTINATION | ||
| ${CMAKE_INSTALL_LIBDIR}/cmake/${PACKAGE_NAME} | ||
| PATH_VARS | ||
| QML_MODULE_PATH | ||
| ) | ||
|
|
||
| write_basic_package_version_file( | ||
| ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}ConfigVersion.cmake | ||
| VERSION | ||
| "${SFP_MAJOR}.${SFP_MINOR}" | ||
| COMPATIBILITY | ||
| SameMajorVersion | ||
| ) | ||
|
|
||
| set(SFP_INSTALL_PATH "${QML_MODULE_PATH}/QmlSortFilterProxyModel") | ||
|
|
||
| # qml module | ||
| install(TARGETS SortFilterProxyModelPlugin | ||
| RUNTIME DESTINATION ${SFP_INSTALL_PATH} | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On Linux,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not really an ordinary plugin but a qml module. I just checked on my windows installation, Qt itself installs qml modules like this: |
||
| COMPONENT sortfilterproxymodel | ||
| ) | ||
| install( | ||
| FILES module/qmldir module/plugins.qmltypes | ||
| DESTINATION ${SFP_INSTALL_PATH} | ||
| COMPONENT sortfilterproxymodel | ||
| ) | ||
|
|
||
| # cmake package config | ||
| install( | ||
| FILES | ||
| ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}Config.cmake | ||
| ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}ConfigVersion.cmake | ||
| DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PACKAGE_NAME} | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| @PACKAGE_INIT@ | ||
|
|
||
| set_and_check(${CMAKE_FIND_PACKAGE_NAME}_QML_MODULE_PATH "@PACKAGE_QML_MODULE_PATH@") | ||
|
|
||
| set(${CMAKE_FIND_PACKAGE_NAME}_QML_MODULE_NAME QmlSortFilterProxyModel) | ||
|
|
||
| check_required_components(SortFilterProxyModel) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #ifndef FILTERSQMLTYPES_H | ||
| #define FILTERSQMLTYPES_H | ||
|
|
||
| namespace qqsfpm { | ||
|
|
||
| void registerFiltersTypes(const char *uri, int major, int minor); | ||
|
|
||
| } // namespace qqsfpm | ||
|
|
||
| #endif // FILTERSQMLTYPES_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why QmlSortFilterProxyModel and not SortFilterProxyModel as already used?
I would prefer SortFilterProxyModel as the default and optionally changeable if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also prefer that, however as stated in my comment, I had a namespace conflict while generating the qmltypes file. That is why I had to change the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact
qmlplugindumpused for generating the *.qmltypes file is the program where I experienced the namespace conflict. Maybe after generating the types file I can change the module name back to SortFilterProxyModel.