Compare commits

..

28 Commits

Author SHA1 Message Date
75b3bb46ac Merge pull request 'fix QCodeEdit code complete popup size' (#69) from master into release
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
Reviewed-on: https://git.shs.tools/SHS/libs/pulls/69
2020-09-07 10:12:23 +03:00
75c6b5abcc fix QCodeEdit code complete popup size 2020-09-04 18:06:52 +03:00
97c6ddeaea Merge pull request 'master' (#68) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
Reviewed-on: https://git.shs.tools/SHS/libs/pulls/68
2020-08-31 18:53:02 +03:00
235eb2acb8 remove graphic expand buttons, update pip 2020-08-31 18:35:32 +03:00
bd5579b8f1 qrc refactoring 2020-08-27 14:29:02 +03:00
7f820c8f67 new Graphic feature - floatingAxisType: Free, TraceX/Y
qpicalculator moved to PIEvaluator
2020-08-26 23:44:50 +03:00
9130496887 restore my error 2020-08-25 22:38:34 +03:00
cca2e0f2d7 moved qpicalculator 2020-08-25 22:29:59 +03:00
b92a1fa558 moved to shstk 2020-08-25 22:24:02 +03:00
d4f1c78a6e pip 2020-08-24 13:23:50 +03:00
274fb20103 microchange 2020-08-22 01:04:46 +03:00
acef4db1db QAD and PIQt overall messages (as at recent PIP) 2020-08-22 00:58:46 +03:00
9f84e5c3df new "qt_generate_export_header" macro 2020-08-21 22:13:06 +03:00
aa009c36b0 work with QGL* 2020-08-21 20:16:02 +03:00
5ae5034145 Merge pull request 'master' (#67) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
Reviewed-on: https://git.shs.tools/SHS/libs/pulls/67
2020-08-20 13:47:31 +03:00
e4340a7215 qglengine/CMakeLists.txt fix 2020-08-20 13:25:37 +03:00
f7eabd1a85 export headers for QAD, PIQt and cd_utils 2020-08-19 22:42:37 +03:00
3ca32f4972 Merge branch 'master' of https://git.shs.tools/SHS/libs 2020-08-19 19:55:42 +03:00
68512b6c08 move qpiconnection 2020-08-19 19:55:32 +03:00
016753fb4d Merge pull request 'master' (#65) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
Reviewed-on: https://git.shs.tools/SHS/libs/pulls/65
2020-08-18 17:09:38 +03:00
b71db0530f Merge pull request 'pip' (#64) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
Reviewed-on: https://git.shs.tools/SHS/libs/pulls/64
2020-08-14 19:55:38 +03:00
bb645bd71b Merge pull request 'master' (#63) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
Reviewed-on: https://git.shs.tools/SHS/libs/pulls/63
2020-08-14 15:25:41 +03:00
12664842c7 Merge pull request 'master' (#62) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
Reviewed-on: https://git.shs.tools/SHS/libs/pulls/62
2020-08-13 18:09:20 +03:00
c41e92a9f5 Merge pull request 'master' (#61) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
Reviewed-on: https://git.shs.tools/SHS/libs/pulls/61
2020-08-13 14:44:37 +03:00
6e4cdccc94 Merge pull request 'binlog user header' (#60) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
Reviewed-on: https://git.shs.tools/SHS/libs/pulls/60
2020-08-12 20:02:12 +03:00
e59bf65294 Merge pull request 'pip' (#59) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
Reviewed-on: https://git.shs.tools/SHS/libs/pulls/59
2020-08-11 21:19:15 +03:00
2e5d64f258 Merge pull request 'pip' (#58) from master into release
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
Reviewed-on: https://git.shs.tools/SHS/libs/pulls/58
2020-08-11 20:59:41 +03:00
5382c54d6a Merge pull request 'PIP 2.0.0' (#57) from master into release
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
Reviewed-on: https://git.shs.tools/SHS/libs/pulls/57
2020-08-11 20:21:17 +03:00
175 changed files with 11031 additions and 10972 deletions

View File

@@ -9,17 +9,81 @@ project(libs)
set(PIP_CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pip/cmake") set(PIP_CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pip/cmake")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" "${PIP_CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/qad/cmake") set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" "${PIP_CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/qad/cmake")
set(LIBPROJECT 1) set(LIBPROJECT 1)
set(_qt_libs )
set(_qt_apps )
set(_qt_plugs)
include(GenerateExportHeader)
include(SDKMacros) include(SDKMacros)
include(QADMacros)
include(DeployMacros) include(DeployMacros)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
if(NOT DEFINED BUILD_NUMBER) if(NOT DEFINED BUILD_NUMBER)
set(BUILD_NUMBER 9999) set(BUILD_NUMBER 9999)
endif() endif()
if("x${BUILD_NUMBER}" STREQUAL "x") if("x${BUILD_NUMBER}" STREQUAL "x")
set(BUILD_NUMBER 0) set(BUILD_NUMBER 0)
endif() endif()
set(_COMPANY SHS)
set(_DOMAIN org.SHS)
if(STATIC_LIB)
set(QAD_LIB_TYPE STATIC)
add_definitions(-DQAD_STATIC_DEFINE)
set(QAD_LIB_TYPE_MSG "Static")
else()
set(QAD_LIB_TYPE SHARED)
set(QAD_LIB_TYPE_MSG "Shared")
endif()
set(_QAD_MAJOR 1)
set(_QAD_MINOR 9)
set(_QAD_REVISION 0)
set(_QAD_SUFFIX )
set(_QAD_COMPANY SHS)
set(_QAD_DOMAIN org.SHS)
set(QAD_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/qad/qad_version.h")
set_version(QAD
MAJOR "${_QAD_MAJOR}"
MINOR "${_QAD_MINOR}"
REVISION "${_QAD_REVISION}"
BUILD "${BUILD_NUMBER}"
SUFFIX "${_QAD_SUFFIX}"
OUTPUT "${QAD_VERSION_FILE}")
set_deploy_property(QAD ${QAD_LIB_TYPE}
FULLNAME "${_QAD_DOMAIN}.*"
COMPANY "${_QAD_COMPANY}")
if(STATIC_LIB)
set(PIQt_LIB_TYPE STATIC)
add_definitions(-DPIQt_STATIC_DEFINE)
set(PIQt_LIB_TYPE_MSG "Static")
else()
set(PIQt_LIB_TYPE SHARED)
set(PIQt_LIB_TYPE_MSG "Shared")
endif()
set(_PIQt_MAJOR 1)
set(_PIQt_MINOR 0)
set(_PIQt_REVISION 0)
set(_PIQt_SUFFIX )
set(_PIQt_COMPANY SHS)
set(_PIQt_DOMAIN org.SHS)
if(NOT DEFINED BUILD_NUMBER)
set(BUILD_NUMBER 9999)
endif()
set(PIQt_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/piqt/piqt_version.h")
set_version(PIQt
MAJOR "${_PIQt_MAJOR}"
MINOR "${_PIQt_MINOR}"
REVISION "${_PIQt_REVISION}"
BUILD "${BUILD_NUMBER}"
SUFFIX "${_PIQt_SUFFIX}"
OUTPUT "${PIQt_VERSION_FILE}")
set_deploy_property(PIQt ${_PIQt_LIB_TYPE}
FULLNAME "${_PIQt_DOMAIN}.*"
COMPANY "${_PIQt_COMPANY}")
include_directories(${CMAKE_CURRENT_BINARY_DIR}/pip) include_directories(${CMAKE_CURRENT_BINARY_DIR}/pip)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/qad) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/qad)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/piqt) include_directories(${CMAKE_CURRENT_BINARY_DIR}/piqt)
@@ -47,21 +111,22 @@ if (DEFINED ANDROID_PLATFORM)
#message("${ANDROID_NDK}/sysroot/usr/include") #message("${ANDROID_NDK}/sysroot/usr/include")
endif() endif()
set(INSTALL_PREFIX "") set(INSTALL_PREFIX "")
set(_plugins_default_ 1) set(_plugins_default_ ON)
if(CMAKE_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING)
if (DEFINED ANDROID_PLATFORM) if (DEFINED ANDROID_PLATFORM)
set(_plugins_default_ 0) set(_plugins_default_ OFF)
set(INSTALL_PREFIX "${CMAKE_FIND_ROOT_PATH}/") set(INSTALL_PREFIX "${CMAKE_FIND_ROOT_PATH}/")
else() else()
set(INSTALL_PREFIX "${CMAKE_STAGING_PREFIX}") set(INSTALL_PREFIX "${CMAKE_STAGING_PREFIX}")
endif() endif()
endif() endif()
option(CROSSTOOLS "Crosstools minimal build" 0) option(CROSSTOOLS "Crosstools minimal build" OFF)
option(LIB "System install" 1) option(LIB "System install" ON)
option(QGLVIEW "Build QGLview library and utils" 0) option(QGLVIEW "Build QGLview library and utils" OFF)
option(QGLENGINE "Build QGLENGINE library and utils" 0) option(QGLENGINE "Build QGLENGINE library and utils" OFF)
option(UTILS "Build various utils" ${_plugins_default_}) option(UTILS "Build various utils" ${_plugins_default_})
option(DESIGNER_PLUGINS "Build qt designer plugins" ${_plugins_default_}) option(DESIGNER_PLUGINS "Build qt designer plugins" ${_plugins_default_})
option(STATIC_LIB OFF)
if (CROSSTOOLS) if (CROSSTOOLS)
set(LIB 1) set(LIB 1)
set(QGLVIEW 0) set(QGLVIEW 0)
@@ -142,20 +207,21 @@ else()
endif() endif()
endforeach() endforeach()
if(UTILS) #if(UTILS)
message(STATUS "Building with utils") # message(STATUS "Building with utils")
else() #else()
message(STATUS "Building only libraries") # message(STATUS "Building only libraries")
endif() #endif()
add_subdirectory(pip) add_subdirectory(pip)
foreach(F ${PIP_MAIN_FOLDERS}) foreach(F ${PIP_MAIN_FOLDERS})
list(APPEND PIP_INCLUDES "${F}") list(APPEND PIP_INCLUDES "${F}")
endforeach(F) endforeach(F)
add_subdirectory(cd_utils) add_subdirectory(cd_utils)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/cd_utils" "${CMAKE_CURRENT_BINARY_DIR}/cd_utils")
set(_DIRS) set(_DIRS)
if (SomeQtFound) if (SomeQtFound)
message(STATUS "Building Qt-derived targets for ${QtVersions}") #message(STATUS "Building Qt-derived targets for ${QtVersions}")
add_subdirectory(qad) add_subdirectory(qad)
include_directories(${qad_includes}) include_directories(${qad_includes})
add_subdirectory(piqt) add_subdirectory(piqt)
@@ -173,6 +239,52 @@ else()
list(APPEND QT_MULTILIB_LIST ${_D}) list(APPEND QT_MULTILIB_LIST ${_D})
add_subdirectory(${_D}) add_subdirectory(${_D})
endforeach(_D) endforeach(_D)
macro(align_list _list _out)
set(_max_len 0)
foreach(_m ${_list})
string(LENGTH "${_m}" _clen)
if (_clen GREATER _max_len)
set(_max_len ${_clen})
endif()
endforeach()
set(${_out})
foreach(_m ${_list})
set(_am "${_m}")
while(TRUE)
string(LENGTH "${_am}" _clen)
if (_clen GREATER_EQUAL ${_max_len})
break()
endif()
string(APPEND _am " ")
endwhile()
list(APPEND ${_out} "${_am}")
endforeach()
endmacro()
macro(print_list _list _name)
if (NOT "x${_list}" STREQUAL "x")
message("")
message(" ${_name}:")
#align_list("${_list}" _alist)
foreach(_m ${_list})
message(" * ${_m}")
endforeach()
endif()
endmacro()
message("----------QAD-----------")
message(" Build for ${QtVersions}")
message(" QAD Version: ${QAD_VERSION}")
message(" QAD Linkage: ${QAD_LIB_TYPE_MSG}")
message(" PIQt Version: ${PIQt_VERSION}")
message(" PIQt Linkage: ${PIQt_LIB_TYPE_MSG}")
print_list("${_qt_libs}" "Libraries")
print_list("${_qt_apps}" "Applications")
print_list("${_qt_plugs}" "Plugins")
message("-----------------------")
message("")
else() else()
message(STATUS "None of Qt found, skip Qt-derived targets") message(STATUS "None of Qt found, skip Qt-derived targets")
endif() endif()

View File

@@ -1,96 +1,107 @@
macro(sdk_install _DIR IS_APP _TARGET _H_FILES _QM_FILES) macro(sdk_install _DIR IS_APP _TARGET _H_FILES _QM_FILES)
#message("QM=${_QM_FILES}") #message("QM=${_QM_FILES}")
if(LIB) if((NOT ${IS_APP}) AND (NOT "${_H_FILES}" STREQUAL ""))
if(WIN32) if(LIB)
if (${IS_APP}) if(WIN32)
qt_install(TARGETS ${_TARGET} DESTINATION ${MINGW_BIN}) install(FILES ${_H_FILES} DESTINATION ${MINGW_INCLUDE}/${_DIR})
qt_install(TARGETS ${_TARGET} DESTINATION QtBin) else()
else() install(FILES ${_H_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${_DIR})
if(NOT "x${_H_FILES}" STREQUAL "x") endif()
install(FILES ${_H_FILES} DESTINATION ${MINGW_INCLUDE}/${_DIR}) else()
endif() install(FILES ${_H_FILES} DESTINATION include/${_DIR})
qt_install(TARGETS ${_TARGET} ARCHIVE DESTINATION ${MINGW_LIB}) endif()
qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION ${MINGW_BIN}) endif()
qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION QtBin) if (NOT "${_TARGET}" STREQUAL "")
endif() if(LIB)
else() if(WIN32)
if (${IS_APP}) if (${IS_APP})
qt_install(TARGETS ${_TARGET} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) qt_install(TARGETS ${_TARGET} DESTINATION ${MINGW_BIN})
else() qt_install(TARGETS ${_TARGET} DESTINATION QtBin)
if (NOT "x${_H_FILES}" STREQUAL "x") else()
install(FILES ${_H_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${_DIR}) qt_install(TARGETS ${_TARGET} ARCHIVE DESTINATION ${MINGW_LIB})
endif() qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION ${MINGW_BIN})
qt_install(TARGETS ${_TARGET} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION QtBin)
endif() endif()
endif() else()
if(NOT "x${_QM_FILES}" STREQUAL "x") if (${IS_APP})
qt_install(LANG ${_QM_FILES} DESTINATION QtLang) qt_install(TARGETS ${_TARGET} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
endif() else()
else() qt_install(TARGETS ${_TARGET} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
if(${IS_APP}) endif()
qt_install(TARGETS ${_TARGET} DESTINATION bin) endif()
else() if(NOT "x${_QM_FILES}" STREQUAL "x")
if(NOT "x${_H_FILES}" STREQUAL "x") qt_install(LANG ${_QM_FILES} DESTINATION QtLang)
install(FILES ${_H_FILES} DESTINATION include/${_DIR}) endif()
endif() else()
if(WIN32) if(${IS_APP})
qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION bin) qt_install(TARGETS ${_TARGET} DESTINATION bin)
qt_install(TARGETS ${_TARGET} ARCHIVE DESTINATION lib) else()
else() if(WIN32)
qt_install(TARGETS ${_TARGET} DESTINATION lib) qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION bin)
endif() qt_install(TARGETS ${_TARGET} ARCHIVE DESTINATION lib)
endif() else()
if(NOT "x${_QM_FILES}" STREQUAL "x") qt_install(TARGETS ${_TARGET} DESTINATION lib)
qt_install(LANG ${_QM_FILES} DESTINATION lang) endif()
endif() endif()
endif() if(NOT "x${_QM_FILES}" STREQUAL "x")
endmacro() qt_install(LANG ${_QM_FILES} DESTINATION lang)
endif()
endif()
macro(add_directories_with_include multilib_prefix) endif()
set(DIRS) endmacro()
file(GLOB _dl "[^.]*")
foreach(_d ${_dl})
if(IS_DIRECTORY ${_d}) macro(copy_to_parent _inc_var)
list(APPEND DIRS ${_d}) set(QT_MULTILIB_LIST ${QT_MULTILIB_LIST} PARENT_SCOPE)
endif() set(_qt_libs ${_qt_libs} PARENT_SCOPE)
endforeach() set(_qt_apps ${_qt_apps} PARENT_SCOPE)
set(_qt_plugs ${_qt_plugs} PARENT_SCOPE)
set(inc_var ${multilib_prefix}includes) if (NOT "x${_inc_var}" STREQUAL "x")
set(${inc_var}) set(${_inc_var} ${${_inc_var}} PARENT_SCOPE)
foreach(_d ${DIRS}) endif()
get_filename_component(_dname "${_d}" NAME) if (LIB)
list(APPEND QT_MULTILIB_LIST ${multilib_prefix}${_dname}) set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
list(APPEND ${inc_var} "${_d}") endif()
endforeach() endmacro()
foreach(_d ${DIRS})
include_directories(${_d}) macro(add_directories_with_include multilib_prefix)
endforeach() set(DIRS)
foreach(_d ${DIRS}) file(GLOB _dl "[^.]*")
add_subdirectory(${_d}) foreach(_d ${_dl})
endforeach() if(IS_DIRECTORY ${_d})
list(APPEND DIRS ${_d})
set(QT_MULTILIB_LIST ${QT_MULTILIB_LIST} PARENT_SCOPE) endif()
set(${inc_var} ${${inc_var}} PARENT_SCOPE) endforeach()
if (LIB)
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE) set(inc_var ${multilib_prefix}includes)
endif() set(${inc_var})
endmacro() foreach(_d ${DIRS})
get_filename_component(_dname "${_d}" NAME)
list(APPEND QT_MULTILIB_LIST ${multilib_prefix}${_dname})
macro(add_directories multilib_prefix) list(APPEND ${inc_var} "${_d}")
include_directories(${${multilib_prefix}includes}) list(APPEND ${inc_var} "${CMAKE_CURRENT_BINARY_DIR}/${_dname}")
file(GLOB _dl "[^.]*") endforeach()
foreach(_d ${_dl})
if(IS_DIRECTORY ${_d}) include_directories(${${inc_var}})
add_subdirectory(${_d}) foreach(_d ${DIRS})
endif() add_subdirectory(${_d})
endforeach() endforeach()
if (LIB) copy_to_parent(${inc_var})
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE) endmacro()
endif()
endmacro()
macro(add_directories multilib_prefix)
include_directories(${${multilib_prefix}includes})
file(GLOB _dl "[^.]*")
foreach(_d ${_dl})
if(IS_DIRECTORY ${_d})
add_subdirectory(${_d})
endif()
endforeach()
copy_to_parent(${multilib_prefix}includes)
endmacro()

View File

@@ -1,35 +1,37 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(cd_utils) project(cd_utils)
find_package(MinGW REQUIRED) find_package(MinGW REQUIRED)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES}) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES})
file(GLOB CPPS_UTILS "cdutils_*.cpp") file(GLOB CPPS_UTILS "cdutils_*.cpp")
file(GLOB HDRS_UTILS "cdutils_*.h") file(GLOB HDRS_UTILS "cdutils_*.h")
add_library(${PROJECT_NAME} SHARED ${CPPS_UTILS} ${HDRS_UTILS}) add_library(${PROJECT_NAME} SHARED ${CPPS_UTILS} ${HDRS_UTILS})
target_link_libraries(${PROJECT_NAME} ${PIP_LIBRARY}) target_link_libraries(${PROJECT_NAME} ${PIP_LIBRARY})
generate_export_header(${PROJECT_NAME})
add_executable(cdutilstest "cdutilstest.cpp" "cdtest.h") list(APPEND HDRS_UTILS "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_export.h")
target_link_libraries(cdutilstest ${PIP_LIBRARY} ${PROJECT_NAME})
message(STATUS "Building ${PROJECT_NAME}") add_executable(cdutilstest "cdutilstest.cpp" "cdtest.h")
target_link_libraries(cdutilstest ${PIP_LIBRARY} ${PROJECT_NAME})
if(LIB) message(STATUS "Building ${PROJECT_NAME}")
list(APPEND _ALL_TARGETS ${PROJECT_NAME})
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE) if(LIB)
if(WIN32) list(APPEND _ALL_TARGETS ${PROJECT_NAME})
install(FILES ${HDRS_UTILS} DESTINATION ${MINGW_INCLUDE}) set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${MINGW_LIB}) if(WIN32)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${MINGW_BIN}) install(FILES ${HDRS_UTILS} DESTINATION ${MINGW_INCLUDE})
else() install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${MINGW_LIB})
install(FILES ${HDRS_UTILS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${MINGW_BIN})
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) else()
endif() install(FILES ${HDRS_UTILS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
#message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"") install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
else() endif()
if(WIN32) #message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) else()
install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib) if(WIN32)
else() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
install(TARGETS ${PROJECT_NAME} DESTINATION lib) install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib)
endif() else()
install(FILES ${HDRS_UTILS} DESTINATION include) install(TARGETS ${PROJECT_NAME} DESTINATION lib)
#message(STATUS "Install ${PROJECT_NAME} to local \"bin\"") endif()
endif() install(FILES ${HDRS_UTILS} DESTINATION include)
#message(STATUS "Install ${PROJECT_NAME} to local \"bin\"")
endif()

View File

@@ -1,10 +1,10 @@
#ifndef CDTEST_H #ifndef CDTEST_H
#define CDTEST_H #define CDTEST_H
enum KDescription { enum KDescription {
First, //f Первый First, //f Первый
Second, //b Второй Second, //b Второй
}; };
#endif // CDTEST_H #endif // CDTEST_H

View File

@@ -1,41 +1,41 @@
#include "cdutils_c.h" #include "cdutils_c.h"
#include "cdutils_core.h" #include "cdutils_core.h"
using namespace CDUtils; using namespace CDUtils;
CInterface C; CInterface C;
CInterface::CInterface(): Interface(CDType::cdC) { CInterface::CInterface(): Interface(CDType::cdC) {
} }
void CInterface::sendCommand(const CDType & c) { void CInterface::sendCommand(const CDType & c) {
core->sendCommand(c); core->sendCommand(c);
} }
void CInterface::connect(const CDType & c, PIObject * o, Handler eh) { void CInterface::connect(const CDType & c, PIObject * o, Handler eh) {
core->registerCHandler(c, o, eh); core->registerCHandler(c, o, eh);
} }
void CInterface::autoConnect(PIObject * o, const PIString & prefix) { void CInterface::autoConnect(PIObject * o, const PIString & prefix) {
if (!o) return; if (!o) return;
uint cid = o->classNameID(); uint cid = o->classNameID();
if (!PIObject::__meta_data().contains(cid)) return; if (!PIObject::__meta_data().contains(cid)) return;
PIMap<PIString, Handler> eh_map; PIMap<PIString, Handler> eh_map;
PIObject::__MetaData & md(PIObject::__meta_data()[cid]); PIObject::__MetaData & md(PIObject::__meta_data()[cid]);
PIMap<const void * , __MetaFunc>::const_iterator it; PIMap<const void * , __MetaFunc>::const_iterator it;
for (it = md.eh_func.constBegin(); it != md.eh_func.constEnd(); ++it) { for (it = md.eh_func.constBegin(); it != md.eh_func.constEnd(); ++it) {
eh_map[it.value().func_name] = (Handler)it.value().addr; eh_map[it.value().func_name] = (Handler)it.value().addr;
//piCout << "func" << it.value().func_name; //piCout << "func" << it.value().func_name;
} }
PIVector<CDType * > cl = C.root().children(); PIVector<CDType * > cl = C.root().children();
piForeachC (CDType * c, cl) { piForeachC (CDType * c, cl) {
PIString cp = prefix + c->pathString().join("_"); PIString cp = prefix + c->pathString().join("_");
if (cp.isEmpty()) continue; if (cp.isEmpty()) continue;
if (!eh_map.contains(cp)) continue; if (!eh_map.contains(cp)) continue;
connect(*c, o, eh_map[cp]); connect(*c, o, eh_map[cp]);
} }
} }

View File

@@ -1,45 +1,46 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_C_H #ifndef CDUTILS_C_H
#define CDUTILS_C_H #define CDUTILS_C_H
#include "cdutils_interface.h" #include "cdutils_interface.h"
#include "cd_utils_export.h"
namespace CDUtils {
namespace CDUtils {
class CInterface: public Interface
{ class CD_UTILS_EXPORT CInterface: public Interface
PIOBJECT_SUBCLASS(CInterface, Interface) {
public: PIOBJECT_SUBCLASS(CInterface, Interface)
CInterface(); public:
CInterface();
void sendCommand(const CDType & c);
void connect(const CDType & c, PIObject * o, Handler eh); void sendCommand(const CDType & c);
void autoConnect(PIObject * o, const PIString & prefix = PIStringAscii("c_")); void connect(const CDType & c, PIObject * o, Handler eh);
void autoConnect(PIObject * o, const PIString & prefix = PIStringAscii("c_"));
};
};
}
}
extern CDUtils::CInterface C;
extern CD_UTILS_EXPORT CDUtils::CInterface C;
#endif // CDUTILS_C_H
#endif // CDUTILS_C_H

View File

@@ -1,606 +1,606 @@
#include "cdutils_core.h" #include "cdutils_core.h"
#include "cdutils_parser.h" #include "cdutils_parser.h"
#include "piconfig.h" #include "piconfig.h"
#include "piiobytearray.h" #include "piiobytearray.h"
#include "piiostring.h" #include "piiostring.h"
#include "pifile.h" #include "pifile.h"
using namespace CDUtils; using namespace CDUtils;
const char CDCore::app_config[] = const char CDCore::app_config[] =
"include = cd_ip.conf\n\ "include = cd_ip.conf\n\
port_rec = 2\n\ port_rec = 2\n\
port_send = 1\n\ port_send = 1\n\
[connection]\n\ [connection]\n\
device.cd = peer://cd_app:cd_pult #s\n\ device.cd = peer://cd_app:cd_pult #s\n\
[]\n\ []\n\
connectionmodel = AAAM2Xja7VXLTttAFD12QpsikKjUSixYlLbKEpIUtVIlVEfqhk2FWuiGRRolUYtoHgrmpYiv6IItf8AveMMH9E/YsG6Ph3sde5hGoQoblLGuPHfunTPjc49nADxDA110+LTYC7FrPCAPeAO+vZu+aX7c/8PGd45WCJC0OGcfT6FDnmfSTPtwhZFt3HjgDs/Qtu5jPbZHtI/x50XfIzMQbdwEolbg9INP4ku++myPaUtCHYRaT2j1ldIh3VP60/Qff8vSfXLu9BP6JX9K/0TVH6jqVe22P1X/fao/oddWu/paDs1vBf9Jv/EZ91clbyHqv7BL6sscDOd4v4WTqs6jzaHGJ8QJerxlpJSpdZ7IWFJvDW7I2JxZqIM62k6A57RZmMQGmlyrxdV+WGBnmR01mXPI267hBKwp4FeBeo9VPtssxyb7rzHg1B7T9nCMU45U8BZlWuVWtIcD/CRGOqtsbW09851tXsHN0UTlLIAdASjSXnLyLn+H7L2+xbGYvC63Ezqg543egkLmn8qnRF6USbM4Qp9godkhzI777Ne5bCIt/5UtGz2o/yGby0nKpjqmbOa1ynkjmyzIrzvIZUeBPjvlUmbh32EFJbGyJZhR8YcvlS+3TpjhqeWSyvUkpbI9plSWtcKLcsK05beOJVEnhaEFfHEH+RwpeMcpn1JKGqWMNOL+G6wZyahlpdVOtufKfbDS+guLke9O\n\ connectionmodel = AAAM2Xja7VXLTttAFD12QpsikKjUSixYlLbKEpIUtVIlVEfqhk2FWuiGRRolUYtoHgrmpYiv6IItf8AveMMH9E/YsG6Ph3sde5hGoQoblLGuPHfunTPjc49nADxDA110+LTYC7FrPCAPeAO+vZu+aX7c/8PGd45WCJC0OGcfT6FDnmfSTPtwhZFt3HjgDs/Qtu5jPbZHtI/x50XfIzMQbdwEolbg9INP4ku++myPaUtCHYRaT2j1ldIh3VP60/Qff8vSfXLu9BP6JX9K/0TVH6jqVe22P1X/fao/oddWu/paDs1vBf9Jv/EZ91clbyHqv7BL6sscDOd4v4WTqs6jzaHGJ8QJerxlpJSpdZ7IWFJvDW7I2JxZqIM62k6A57RZmMQGmlyrxdV+WGBnmR01mXPI267hBKwp4FeBeo9VPtssxyb7rzHg1B7T9nCMU45U8BZlWuVWtIcD/CRGOqtsbW09851tXsHN0UTlLIAdASjSXnLyLn+H7L2+xbGYvC63Ezqg543egkLmn8qnRF6USbM4Qp9godkhzI777Ne5bCIt/5UtGz2o/yGby0nKpjqmbOa1ynkjmyzIrzvIZUeBPjvlUmbh32EFJbGyJZhR8YcvlS+3TpjhqeWSyvUkpbI9plSWtcKLcsK05beOJVEnhaEFfHEH+RwpeMcpn1JKGqWMNOL+G6wZyahlpdVOtufKfbDS+guLke9O\n\
"; ";
const char CDCore::pult_config[] = const char CDCore::pult_config[] =
"include = cd_ip.conf\n\ "include = cd_ip.conf\n\
port_rec = 1\n\ port_rec = 1\n\
port_send = 2\n\ port_send = 2\n\
[connection]\n\ [connection]\n\
device.cd = peer://cd_pult:cd_app #s\n\ device.cd = peer://cd_pult:cd_app #s\n\
[]\n\ []\n\
connectionmodel = AAAM2Xja7VXLTttAFD12QpsikKjUSixYlLbKEpIUtVIlVEfqhk2FWuiGRRolUYtoHgrmpYiv6IItf8AveMMH9E/YsG6Ph3sde5hGoQoblLGuPHfunTPjc49nADxDA110+LTYC7FrPCAPeAO+vZu+aX7c/8PGd45WCJC0OGcfT6FDnmfSTPtwhZFt3HjgDs/Qtu5jPbZHtI/x50XfIzMQbdwEolbg9INP4ku++myPaUtCHYRaT2j1ldIh3VP60/Qff8vSfXLu9BP6JX9K/0TVH6jqVe22P1X/fao/oddWu/paDs1vBf9Jv/EZ91clbyHqv7BL6sscDOd4v4WTqs6jzaHGJ8QJerxlpJSpdZ7IWFJvDW7I2JxZqIM62k6A57RZmMQGmlyrxdV+WGBnmR01mXPI267hBKwp4FeBeo9VPtssxyb7rzHg1B7T9nCMU45U8BZlWuVWtIcD/CRGOqtsbW09851tXsHN0UTlLIAdASjSXnLyLn+H7L2+xbGYvC63Ezqg543egkLmn8qnRF6USbM4Qp9godkhzI777Ne5bCIt/5UtGz2o/yGby0nKpjqmbOa1ynkjmyzIrzvIZUeBPjvlUmbh32EFJbGyJZhR8YcvlS+3TpjhqeWSyvUkpbI9plSWtcKLcsK05beOJVEnhaEFfHEH+RwpeMcpn1JKGqWMNOL+G6wZyahlpdVOtufKfbDS+guLke9O\n\ connectionmodel = AAAM2Xja7VXLTttAFD12QpsikKjUSixYlLbKEpIUtVIlVEfqhk2FWuiGRRolUYtoHgrmpYiv6IItf8AveMMH9E/YsG6Ph3sde5hGoQoblLGuPHfunTPjc49nADxDA110+LTYC7FrPCAPeAO+vZu+aX7c/8PGd45WCJC0OGcfT6FDnmfSTPtwhZFt3HjgDs/Qtu5jPbZHtI/x50XfIzMQbdwEolbg9INP4ku++myPaUtCHYRaT2j1ldIh3VP60/Qff8vSfXLu9BP6JX9K/0TVH6jqVe22P1X/fao/oddWu/paDs1vBf9Jv/EZ91clbyHqv7BL6sscDOd4v4WTqs6jzaHGJ8QJerxlpJSpdZ7IWFJvDW7I2JxZqIM62k6A57RZmMQGmlyrxdV+WGBnmR01mXPI267hBKwp4FeBeo9VPtssxyb7rzHg1B7T9nCMU45U8BZlWuVWtIcD/CRGOqtsbW09851tXsHN0UTlLIAdASjSXnLyLn+H7L2+xbGYvC63Ezqg543egkLmn8qnRF6USbM4Qp9godkhzI777Ne5bCIt/5UtGz2o/yGby0nKpjqmbOa1ynkjmyzIrzvIZUeBPjvlUmbh32EFJbGyJZhR8YcvlS+3TpjhqeWSyvUkpbI9plSWtcKLcsK05beOJVEnhaEFfHEH+RwpeMcpn1JKGqWMNOL+G6wZyahlpdVOtufKfbDS+guLke9O\n\
"; ";
int __Core_Initializer__::count_(0); int __Core_Initializer__::count_(0);
CDCore * __Core_Initializer__::__instance__(0); CDCore * __Core_Initializer__::__instance__(0);
const uchar header_direct = 0x80; const uchar header_direct = 0x80;
const uchar header_transfer = 0x81; const uchar header_transfer = 0x81;
__Core_Initializer__::__Core_Initializer__() { __Core_Initializer__::__Core_Initializer__() {
count_++; count_++;
if (count_ > 1) return; if (count_ > 1) return;
__instance__ = new CDCore(); __instance__ = new CDCore();
} }
__Core_Initializer__::~__Core_Initializer__() { __Core_Initializer__::~__Core_Initializer__() {
count_--; count_--;
if (count_ < 0) { if (count_ < 0) {
count_ = 0; count_ = 0;
return; return;
} }
if (count_ > 0) return; if (count_ > 0) return;
if (__instance__) { if (__instance__) {
delete __instance__; delete __instance__;
__instance__ = 0; __instance__ = 0;
} }
} }
CDCore::CDCore() { CDCore::CDCore() {
setName("CDCore"); setName("CDCore");
x_timer.setName("__S__.CDCore.x_timer"); x_timer.setName("__S__.CDCore.x_timer");
datatr.setPacketSize(960); datatr.setPacketSize(960);
CONNECTU(&connection, dataReceivedEvent, this, dataReceived); CONNECTU(&connection, dataReceivedEvent, this, dataReceived);
CONNECTU(PICout::Notifier::object(), finished, this, piCoutFinished); CONNECTU(PICout::Notifier::object(), finished, this, piCoutFinished);
/*PIString s(app_config); /*PIString s(app_config);
connection.configureFromString(&s); connection.configureFromString(&s);
connection.start();*/ connection.start();*/
need_rebuild_x = x_pult_side = false; need_rebuild_x = x_pult_side = false;
k_.cd_type_ = CDType::cdK; k_.cd_type_ = CDType::cdK;
x_.cd_type_ = CDType::cdX; x_.cd_type_ = CDType::cdX;
c_.cd_type_ = CDType::cdC; c_.cd_type_ = CDType::cdC;
m_.cd_type_ = CDType::cdM; m_.cd_type_ = CDType::cdM;
initRoot(&k_); initRoot(&k_);
initRoot(&x_); initRoot(&x_);
initRoot(&c_); initRoot(&c_);
initRoot(&m_); initRoot(&m_);
CONNECTU(&sendt, started, this, sendThread) CONNECTU(&sendt, started, this, sendThread)
CONNECTU(&datatr, sendRequest, this, dtSendRequest) CONNECTU(&datatr, sendRequest, this, dtSendRequest)
CONNECTU(&datatr, receiveFinished, this, dtReceiveFinished) CONNECTU(&datatr, receiveFinished, this, dtReceiveFinished)
CONNECTU(&x_timer, tickEvent, this, xTimerTick) CONNECTU(&x_timer, tickEvent, this, xTimerTick)
/*k_[1] = KType(1, "123", "120+3", "comment"); /*k_[1] = KType(1, "123", "120+3", "comment");
k_[2] = KType(2, "1", "2", "comm"); k_[2] = KType(2, "1", "2", "comm");
k_[4] = KType(4, "-0.6", "-6/10", "mment"); k_[4] = KType(4, "-0.6", "-6/10", "mment");
k_.section(10)[5] = KType(5, "8", "2*2*2", "88"); k_.section(10)[5] = KType(5, "8", "2*2*2", "88");
k_.section(10).section(50)[100] = KType(100, "8", "2*2*2", "88"); k_.section(10).section(50)[100] = KType(100, "8", "2*2*2", "88");
k_.section(11)[3] = KType(3, "1", "1", "88"); k_.section(11)[3] = KType(3, "1", "1", "88");
k_.section(11)[4] = KType(4, "0", "0", "88"); k_.section(11)[4] = KType(4, "0", "0", "88");
k_.section(11)[6] = KType(6, "0", "0", "88");*/ k_.section(11)[6] = KType(6, "0", "0", "88");*/
//piCout << s; //piCout << s;
} }
CDCore::~CDCore() { CDCore::~CDCore() {
x_timer.stop(true); x_timer.stop(true);
datatr.stop(); datatr.stop();
sendt.stop(); sendt.stop();
sendt.waitForFinish(10); sendt.waitForFinish(10);
connection.stop(); connection.stop();
} }
void CDCore::cd_write(CDSection * cd, PIIODevice * d) { void CDCore::cd_write(CDSection * cd, PIIODevice * d) {
cd->write(d, PIString()); cd->write(d, PIString());
} }
void CDCore::cd_read(CDSection * cd, PIIODevice * d) { void CDCore::cd_read(CDSection * cd, PIIODevice * d) {
PIConfig conf(d, PIIODevice::ReadOnly); PIConfig conf(d, PIIODevice::ReadOnly);
cd->read(&(conf.rootEntry())); cd->read(&(conf.rootEntry()));
if (cd->cd_type_ == CDType::cdX) if (cd->cd_type_ == CDType::cdX)
x_selected = cd->collectX(); x_selected = cd->collectX();
initRoot(cd); initRoot(cd);
raiseChangedGlobal(cd->cd_type_); raiseChangedGlobal(cd->cd_type_);
/*PIVector<PIIODevice * > ds = connection.allDevices(); /*PIVector<PIIODevice * > ds = connection.allDevices();
piForeach(PIIODevice * d, ds) { piForeach(PIIODevice * d, ds) {
if (d) if (d)
piCoutObj << d->constructFullPath() << d->isOpened(); piCoutObj << d->constructFullPath() << d->isOpened();
}*/ }*/
} }
void CDCore::cd_parse(CDSection * cd, PIIODevice * d) { void CDCore::cd_parse(CDSection * cd, PIIODevice * d) {
*cd = CDParser::parse(d, cd->cd_type_); *cd = CDParser::parse(d, cd->cd_type_);
initRoot(cd); initRoot(cd);
raiseChangedGlobal(cd->cd_type_); raiseChangedGlobal(cd->cd_type_);
} }
void CDCore::cd_update(CDSection * cd, PIIODevice * d, UpdateModeFlags mode) { void CDCore::cd_update(CDSection * cd, PIIODevice * d, UpdateModeFlags mode) {
CDSection ucd = *cd; CDSection ucd = *cd;
cd_parse(cd, d); cd_parse(cd, d);
/*bool kn = true; /*bool kn = true;
if (!ucd.isEmpty()) if (!ucd.isEmpty())
if (!ucd.isSameStructure(k_)) { if (!ucd.isSameStructure(k_)) {
piCout << "ask for save names"; piCout << "ask for save names";
K_KeepNamesRequest(&kn); K_KeepNamesRequest(&kn);
}*/ }*/
ucd.update(*cd, mode); ucd.update(*cd, mode);
//piCout << k_.count() << ucd.count(); //piCout << k_.count() << ucd.count();
*cd = ucd; *cd = ucd;
initRoot(cd); initRoot(cd);
raiseChangedGlobal(cd->cd_type_); raiseChangedGlobal(cd->cd_type_);
} }
void CDCore::cd_calculate(CDSection * cd) { void CDCore::cd_calculate(CDSection * cd) {
cd->calculate(); cd->calculate();
raiseChangedGlobal(cd->cd_type_); raiseChangedGlobal(cd->cd_type_);
} }
void CDCore::cd_send(CDSection * cd, CDPacketType pt, bool direct) { void CDCore::cd_send(CDSection * cd, CDPacketType pt, bool direct) {
if (!cd) return; if (!cd) return;
PIByteArray ba, sba; PIByteArray ba, sba;
PIIOByteArray iob(&ba, PIIODevice::ReadWrite); PIIOByteArray iob(&ba, PIIODevice::ReadWrite);
cd_write(cd, &iob); cd_write(cd, &iob);
//piCoutObj << PIString(ba); //piCoutObj << PIString(ba);
sba = makeHeader(pt, 0); sba = makeHeader(pt, 0);
sba << ba; sba << ba;
if (direct) if (direct)
sendDirect(sba); sendDirect(sba);
else else
sendThreaded(sba); sendThreaded(sba);
} }
void CDCore::send(CDType::cdT cdt) { void CDCore::send(CDType::cdT cdt) {
CDPacketType pt = CD_Ping; CDPacketType pt = CD_Ping;
switch (cdt) { switch (cdt) {
case CDType::cdK: pt = CD_KSend; break; case CDType::cdK: pt = CD_KSend; break;
case CDType::cdX: pt = CD_XSend; break; case CDType::cdX: pt = CD_XSend; break;
case CDType::cdC: pt = CD_CSend; break; case CDType::cdC: pt = CD_CSend; break;
case CDType::cdM: pt = CD_MSend; break; case CDType::cdM: pt = CD_MSend; break;
default: break; default: break;
} }
piCoutObj << "send" << typeLetter(cdt); piCoutObj << "send" << typeLetter(cdt);
cd_send(root(cdt), pt); cd_send(root(cdt), pt);
} }
void CDCore::request(CDType::cdT cdt) { void CDCore::request(CDType::cdT cdt) {
CDPacketType pt = CD_Ping; CDPacketType pt = CD_Ping;
switch (cdt) { switch (cdt) {
case CDType::cdK: pt = CD_KQuery; break; case CDType::cdK: pt = CD_KQuery; break;
case CDType::cdX: pt = CD_XQuery; break; case CDType::cdX: pt = CD_XQuery; break;
case CDType::cdC: pt = CD_CQuery; break; case CDType::cdC: pt = CD_CQuery; break;
case CDType::cdM: pt = CD_MQuery; break; case CDType::cdM: pt = CD_MQuery; break;
default: break; default: break;
} }
piCoutObj << "request" << typeLetter(cdt); piCoutObj << "request" << typeLetter(cdt);
PIByteArray sba = makeHeader(pt, 0); PIByteArray sba = makeHeader(pt, 0);
sendThreaded(sba); sendThreaded(sba);
} }
void CDCore::initApp() { void CDCore::initApp() {
init(appConfig(), false); init(appConfig(), false);
} }
void CDCore::initPult() { void CDCore::initPult() {
init(pultConfig(), true); init(pultConfig(), true);
} }
void CDCore::init(const PIString & configuration, bool pult) { void CDCore::init(const PIString & configuration, bool pult) {
PIString c = configuration; PIString c = configuration;
//piCoutObj << "init" << c; //piCoutObj << "init" << c;
connection.stop(); connection.stop();
connection.removeAllDevices(); connection.removeAllDevices();
connection.configureFromString(&c); connection.configureFromString(&c);
connection.start(); connection.start();
x_pult_side = pult; x_pult_side = pult;
} }
void CDCore::stop() { void CDCore::stop() {
x_timer.stop(); x_timer.stop();
x_timer.waitForFinish(1000); x_timer.waitForFinish(1000);
connection.stop(); connection.stop();
} }
void CDCore::release() { void CDCore::release() {
stop(); stop();
connection.removeAllDevices(); connection.removeAllDevices();
} }
void CDCore::startX(double freq) { void CDCore::startX(double freq) {
//piCout << "start x" << x_timer.isRunning() << freq; //piCout << "start x" << x_timer.isRunning() << freq;
if (!x_timer.isRunning()) if (!x_timer.isRunning())
x_timer.start(1000. / piMaxd(freq, 0.01)); x_timer.start(1000. / piMaxd(freq, 0.01));
} }
void CDCore::stopX() { void CDCore::stopX() {
x_timer.stop(); x_timer.stop();
x_timer.waitForFinish(1000); x_timer.waitForFinish(1000);
} }
void CDCore::sendCommand(const CDType & c) { void CDCore::sendCommand(const CDType & c) {
//piCoutObj << "C_sendCommand" << c; //piCoutObj << "C_sendCommand" << c;
PIByteArray sba = makeHeader(CD_Command, 0); PIByteArray sba = makeHeader(CD_Command, 0);
sba << c.path(); sba << c.path();
sendDirect(sba); sendDirect(sba);
} }
void CDCore::registerCHandler(const CDType & c, PIObject * o, Handler h) { void CDCore::registerCHandler(const CDType & c, PIObject * o, Handler h) {
PIString sp = pathToString(c.path()); PIString sp = pathToString(c.path());
if (sp.isEmpty() || !h) return; if (sp.isEmpty() || !h) return;
//piCout << "register" << sp; //piCout << "register" << sp;
c_handlers[sp] = OHPair(o, h); c_handlers[sp] = OHPair(o, h);
} }
void CDCore::sendMessage(const CDType & m, MessageType mt, const PIString & msg) { void CDCore::sendMessage(const CDType & m, MessageType mt, const PIString & msg) {
if (msg.isEmpty() || (m.cd_type() != CDType::cdM)) return; if (msg.isEmpty() || (m.cd_type() != CDType::cdM)) return;
PIByteArray sba = makeHeader(CD_Message, 0); PIByteArray sba = makeHeader(CD_Message, 0);
sba << m.path() << int(mt) << msg; sba << m.path() << int(mt) << msg;
sendDirect(sba); sendDirect(sba);
} }
CDSection * CDCore::root(CDType::cdT cdt) { CDSection * CDCore::root(CDType::cdT cdt) {
switch (cdt) { switch (cdt) {
case CDType::cdK: return &k_; break; case CDType::cdK: return &k_; break;
case CDType::cdX: return &x_; break; case CDType::cdX: return &x_; break;
case CDType::cdC: return &c_; break; case CDType::cdC: return &c_; break;
case CDType::cdM: return &m_; break; case CDType::cdM: return &m_; break;
default: break; default: break;
} }
return 0; return 0;
} }
PIString CDCore::typeLetter(CDType::cdT cdt) { PIString CDCore::typeLetter(CDType::cdT cdt) {
switch (cdt) { switch (cdt) {
case CDType::cdK: return PIStringAscii("k"); break; case CDType::cdK: return PIStringAscii("k"); break;
case CDType::cdX: return PIStringAscii("x"); break; case CDType::cdX: return PIStringAscii("x"); break;
case CDType::cdC: return PIStringAscii("c"); break; case CDType::cdC: return PIStringAscii("c"); break;
case CDType::cdM: return PIStringAscii("m"); break; case CDType::cdM: return PIStringAscii("m"); break;
default: break; default: break;
} }
return PIString(); return PIString();
} }
CDCore * CDCore::instance() { CDCore * CDCore::instance() {
/*static CDCore * ret = new CDCore(); /*static CDCore * ret = new CDCore();
return ret;*/ return ret;*/
return __Core_Initializer__::__instance__; return __Core_Initializer__::__instance__;
} }
bool CDCore::destroy() { bool CDCore::destroy() {
if (!__Core_Initializer__::__instance__) return false; if (!__Core_Initializer__::__instance__) return false;
// piCout << "delete Core ..."; // piCout << "delete Core ...";
delete __Core_Initializer__::__instance__; delete __Core_Initializer__::__instance__;
// piCout << "delete Core ok"; // piCout << "delete Core ok";
__Core_Initializer__::__instance__ = 0; __Core_Initializer__::__instance__ = 0;
__Core_Initializer__::count_ = 0; __Core_Initializer__::count_ = 0;
return true; return true;
} }
void CDUtils::CDCore::K_DirectChange(PIDeque<int> path, PIString value) { void CDUtils::CDCore::K_DirectChange(PIDeque<int> path, PIString value) {
// piCoutObj << "K_DirectChange"; // piCoutObj << "K_DirectChange";
PacketKDirectChange p; PacketKDirectChange p;
p.path = path; p.path = path;
p.value = value; p.value = value;
PIByteArray sba = makeHeader(CD_KDirectChange, 0); PIByteArray sba = makeHeader(CD_KDirectChange, 0);
sba << p; sba << p;
sendDirect(sba); sendDirect(sba);
} }
void CDCore::sendThread() { void CDCore::sendThread() {
if (send_data.size_s() < 4) return; if (send_data.size_s() < 4) return;
PacketHeader h; PacketHeader h;
memcpy(&h, send_data.data(), sizeof(h)); memcpy(&h, send_data.data(), sizeof(h));
bool ok = datatr.send(send_data); bool ok = datatr.send(send_data);
switch (h.type) { switch (h.type) {
case CD_KSend: case CD_KSend:
if (ok) K_Sended(); if (ok) K_Sended();
else K_SendFail(); else K_SendFail();
break; break;
case CD_KQuery: case CD_KQuery:
if (!ok) K_ReceiveFail(); if (!ok) K_ReceiveFail();
break; break;
case CD_XSend: case CD_XSend:
if (ok) X_Sended(); if (ok) X_Sended();
else X_SendFail(); else X_SendFail();
break; break;
case CD_XQuery: case CD_XQuery:
if (!ok) X_ReceiveFail(); if (!ok) X_ReceiveFail();
break; break;
case CD_CSend: case CD_CSend:
if (ok) C_Sended(); if (ok) C_Sended();
else C_SendFail(); else C_SendFail();
break; break;
case CD_CQuery: case CD_CQuery:
if (!ok) C_ReceiveFail(); if (!ok) C_ReceiveFail();
break; break;
case CD_MSend: case CD_MSend:
if (ok) M_Sended(); if (ok) M_Sended();
else M_SendFail(); else M_SendFail();
break; break;
case CD_MQuery: case CD_MQuery:
if (!ok) M_ReceiveFail(); if (!ok) M_ReceiveFail();
break; break;
default: break; default: break;
} }
} }
void CDCore::xTimerTick() { void CDCore::xTimerTick() {
//piCout << "x tick" << x_pult_side; //piCout << "x tick" << x_pult_side;
PIByteArray ba; PIByteArray ba;
x_mutex.lock(); x_mutex.lock();
if (x_pult_side) { if (x_pult_side) {
ba = makeHeader(CD_XRequest, 0); ba = makeHeader(CD_XRequest, 0);
if (need_rebuild_x) { if (need_rebuild_x) {
x_selected = x_.collectX(); x_selected = x_.collectX();
//piCout << "collectX" << x_selected.size(); //piCout << "collectX" << x_selected.size();
need_rebuild_x = false; need_rebuild_x = false;
} }
ba << x_selected; ba << x_selected;
//piCout << "x pult send" << x_selected.size(); //piCout << "x pult send" << x_selected.size();
} else { } else {
ba = makeHeader(CD_XValues, 0); ba = makeHeader(CD_XValues, 0);
ba << x_selected; ba << x_selected;
piForeachC (PIDeque<int> & p, x_selected) { piForeachC (PIDeque<int> & p, x_selected) {
x_[p].writeX(ba); x_[p].writeX(ba);
} }
//piCout << "x app" << x_selected.size(); //piCout << "x app" << x_selected.size();
} }
x_mutex.unlock(); x_mutex.unlock();
sendDirect(ba); sendDirect(ba);
} }
void CDCore::piCoutFinished(int id, PIString * buffer) { void CDCore::piCoutFinished(int id, PIString * buffer) {
if (!buffer || !(id == 1)) return; if (!buffer || !(id == 1)) return;
PIString sp = buffer->takeRange("[", "]"); PIString sp = buffer->takeRange("[", "]");
PIDeque<int> p = CDCore::stringToPath(sp); PIDeque<int> p = CDCore::stringToPath(sp);
sendMessage(m_[p], Log, *buffer); sendMessage(m_[p], Log, *buffer);
delete buffer; delete buffer;
} }
void CDCore::initRoot(CDSection * r) { void CDCore::initRoot(CDSection * r) {
r->name = "__root__"; r->name = "__root__";
r->alias = "root"; r->alias = "root";
r->makePath(); r->makePath();
r->calculate(); r->calculate();
} }
PIByteArray CDCore::makeHeader(CDPacketType type, int session_id) const { PIByteArray CDCore::makeHeader(CDPacketType type, int session_id) const {
PacketHeader h; PacketHeader h;
h.type = type; h.type = type;
h.session_id = session_id; h.session_id = session_id;
PIByteArray ret; ret << h; PIByteArray ret; ret << h;
return ret; return ret;
} }
void CDCore::sendDirect(PIByteArray & ba) { void CDCore::sendDirect(PIByteArray & ba) {
ba.push_front(header_direct); ba.push_front(header_direct);
connection.writeByName("cd", ba); connection.writeByName("cd", ba);
} }
void CDCore::sendThreaded(PIByteArray & ba) { void CDCore::sendThreaded(PIByteArray & ba) {
if (sendt.isRunning()) { if (sendt.isRunning()) {
piCoutObj << "Send in process, abort"; piCoutObj << "Send in process, abort";
return; return;
} }
send_data = ba; send_data = ba;
sendt.startOnce(); sendt.startOnce();
} }
void CDCore::procReceivedPacket(PIByteArray & ba) { void CDCore::procReceivedPacket(PIByteArray & ba) {
PacketHeader h; PacketHeader h;
ba >> h; ba >> h;
switch(h.type) { switch(h.type) {
case CD_Ping: case CD_Ping:
//piCoutObj << "ping"; //piCoutObj << "ping";
break; break;
case CD_KQuery: case CD_KQuery:
send(CDType::cdK); send(CDType::cdK);
break; break;
case CD_KSend: { case CD_KSend: {
PIByteArray k; PIByteArray k;
ba >> k; ba >> k;
k << uchar(0); k << uchar(0);
PIString s = PIString::fromUTF8((const char *)k.data()); PIString s = PIString::fromUTF8((const char *)k.data());
PIIOString ios(&s); PIIOString ios(&s);
cd_read(&k_, &ios); cd_read(&k_, &ios);
K_Received(); K_Received();
piCoutObj << "K received"; piCoutObj << "K received";
} break; } break;
case CD_KDirectChange: { case CD_KDirectChange: {
PacketKDirectChange p; PacketKDirectChange p;
ba >> p; ba >> p;
k_[p.path].setValue(p.value); k_[p.path].setValue(p.value);
} break; } break;
case CD_XQuery: case CD_XQuery:
send(CDType::cdX); send(CDType::cdX);
break; break;
case CD_XSend: { case CD_XSend: {
PIByteArray x; PIByteArray x;
ba >> x; ba >> x;
x << uchar(0); x << uchar(0);
PIString s = PIString::fromUTF8((const char *)x.data()); PIString s = PIString::fromUTF8((const char *)x.data());
PIIOString ios(&s); PIIOString ios(&s);
cd_read(&x_, &ios); cd_read(&x_, &ios);
x_selected = x_.collectX(); x_selected = x_.collectX();
X_Received(); X_Received();
piCoutObj << "X received"; piCoutObj << "X received";
} break; } break;
case CD_XRequest: { case CD_XRequest: {
if (x_pult_side) break; if (x_pult_side) break;
//break; //break;
x_mutex.lock(); x_mutex.lock();
x_selected.clear(); x_selected.clear();
ba >> x_selected; ba >> x_selected;
//piCout << "X req" << x_selected.size(); //piCout << "X req" << x_selected.size();
x_.setSelectedX(false); x_.setSelectedX(false);
piForeachC (PIDeque<int> & p, x_selected) { piForeachC (PIDeque<int> & p, x_selected) {
x_[p].x_enabled = true; x_[p].x_enabled = true;
} }
x_mutex.unlock(); x_mutex.unlock();
} break; } break;
case CD_XValues: { case CD_XValues: {
if (!x_pult_side) break; if (!x_pult_side) break;
PIVector<PIDeque<int> > x_vals; PIVector<PIDeque<int> > x_vals;
ba >> x_vals; ba >> x_vals;
x_mutex.lock(); x_mutex.lock();
piForeachC (PIDeque<int> & p, x_vals) { piForeachC (PIDeque<int> & p, x_vals) {
x_[p].readX(ba); x_[p].readX(ba);
} }
x_mutex.unlock(); x_mutex.unlock();
X_ReceivedX(x_vals); X_ReceivedX(x_vals);
} break; } break;
case CD_CQuery: case CD_CQuery:
send(CDType::cdC); send(CDType::cdC);
break; break;
case CD_CSend: { case CD_CSend: {
piCoutObj << "C received"; piCoutObj << "C received";
PIByteArray c; PIByteArray c;
ba >> c; ba >> c;
c << uchar(0); c << uchar(0);
PIString s = PIString::fromUTF8((const char *)c.data()); PIString s = PIString::fromUTF8((const char *)c.data());
PIIOString ios(&s); PIIOString ios(&s);
cd_read(&c_, &ios); cd_read(&c_, &ios);
C_Received(); C_Received();
} break; } break;
case CD_Command: { case CD_Command: {
piCoutObj << "C command"; piCoutObj << "C command";
PIDeque<int> p; PIDeque<int> p;
ba >> p; ba >> p;
if (p.isEmpty()) return; if (p.isEmpty()) return;
PIString sp = pathToString(p); PIString sp = pathToString(p);
OHPair h = c_handlers.value(sp, OHPair(0, 0)); OHPair h = c_handlers.value(sp, OHPair(0, 0));
//piCoutObj << "found" << sp << h.first; //piCoutObj << "found" << sp << h.first;
if (h.first && h.second) h.second(h.first); if (h.first && h.second) h.second(h.first);
} break; } break;
case CD_MQuery: case CD_MQuery:
send(CDType::cdM); send(CDType::cdM);
break; break;
case CD_MSend: { case CD_MSend: {
piCoutObj << "M received"; piCoutObj << "M received";
PIByteArray c; PIByteArray c;
ba >> c; ba >> c;
c << uchar(0); c << uchar(0);
PIString s = PIString::fromUTF8((const char *)c.data()); PIString s = PIString::fromUTF8((const char *)c.data());
PIIOString ios(&s); PIIOString ios(&s);
cd_read(&m_, &ios); cd_read(&m_, &ios);
M_Received(); M_Received();
} break; } break;
case CD_Message: { case CD_Message: {
PIDeque<int> p; PIDeque<int> p;
ba >> p; ba >> p;
piCoutObj << "M message" << p; piCoutObj << "M message" << p;
if (p.isEmpty()) return; if (p.isEmpty()) return;
int t = 0; int t = 0;
PIString msg; PIString msg;
ba >> t >> msg; ba >> t >> msg;
//piCoutObj << "found" << sp << h.first; //piCoutObj << "found" << sp << h.first;
//piCoutObj << "M message invoke"; //piCoutObj << "M message invoke";
M_Message(p, t, msg); M_Message(p, t, msg);
} break; } break;
default: break; default: break;
} }
} }
void CDCore::raiseChangedGlobal(CDType::cdT cdt) { void CDCore::raiseChangedGlobal(CDType::cdT cdt) {
switch (cdt) { switch (cdt) {
case CDType::cdK: K_ChangedGlobal(); break; case CDType::cdK: K_ChangedGlobal(); break;
case CDType::cdX: X_ChangedGlobal(); break; case CDType::cdX: X_ChangedGlobal(); break;
case CDType::cdC: C_ChangedGlobal(); break; case CDType::cdC: C_ChangedGlobal(); break;
case CDType::cdM: M_ChangedGlobal(); break; case CDType::cdM: M_ChangedGlobal(); break;
default: break; default: break;
} }
} }
PIString CDCore::pathToString(const PIDeque<int> & p) { PIString CDCore::pathToString(const PIDeque<int> & p) {
PIString ret; PIString ret;
for (int i = 0; i < p.size_s(); ++i) { for (int i = 0; i < p.size_s(); ++i) {
if (!ret.isEmpty()) ret += "."; if (!ret.isEmpty()) ret += ".";
ret << p[i]; ret << p[i];
} }
return ret; return ret;
} }
PIDeque<int> CDCore::stringToPath(const PIString & p) { PIDeque<int> CDCore::stringToPath(const PIString & p) {
PIDeque<int> ret; PIDeque<int> ret;
PIStringList sl = p.split("."); PIStringList sl = p.split(".");
piForeachC (PIString & s, sl) piForeachC (PIString & s, sl)
ret << s.toInt(); ret << s.toInt();
return ret; return ret;
} }
void CDUtils::CDCore::dataReceived(const PIString & from, const PIByteArray & data) { void CDUtils::CDCore::dataReceived(const PIString & from, const PIByteArray & data) {
//piCoutObj << "dataReceived" << from << data.size(); //piCoutObj << "dataReceived" << from << data.size();
PIIODevice * d = connection.deviceByName("cd"); PIIODevice * d = connection.deviceByName("cd");
if (d && d == connection.deviceByFullPath(from)) { if (d && d == connection.deviceByFullPath(from)) {
if (data.size() >= sizeof(4)) { if (data.size() >= sizeof(4)) {
PIByteArray ba = data; PIByteArray ba = data;
uchar header = ba.take_front(); uchar header = ba.take_front();
if (header == header_transfer) { if (header == header_transfer) {
datatr.received(ba); datatr.received(ba);
} }
if (header == header_direct) { if (header == header_direct) {
procReceivedPacket(ba); procReceivedPacket(ba);
} }
} }
} }
} }
void CDCore::dtSendRequest(PIByteArray & data) { void CDCore::dtSendRequest(PIByteArray & data) {
data.push_front(header_transfer); data.push_front(header_transfer);
connection.writeByName("cd", data); connection.writeByName("cd", data);
//piCoutObj << "send" << data.size() << ret; //piCoutObj << "send" << data.size() << ret;
} }
void CDCore::dtReceiveFinished(bool ok) { void CDCore::dtReceiveFinished(bool ok) {
if (!ok) return; if (!ok) return;
PIByteArray ba = datatr.data(); PIByteArray ba = datatr.data();
procReceivedPacket(ba); procReceivedPacket(ba);
} }

View File

@@ -1,146 +1,147 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_CORE_H #ifndef CDUTILS_CORE_H
#define CDUTILS_CORE_H #define CDUTILS_CORE_H
#include "cdutils_types.h" #include "cdutils_types.h"
#include "cdutils_protocol.h" #include "cdutils_protocol.h"
#include "piconnection.h" #include "piconnection.h"
#include "pidatatransfer.h" #include "pidatatransfer.h"
#include "cd_utils_export.h"
namespace CDUtils {
namespace CDUtils {
class CDCore;
class CDCore;
class __Core_Initializer__ {
public: class CD_UTILS_EXPORT __Core_Initializer__ {
__Core_Initializer__(); public:
~__Core_Initializer__(); __Core_Initializer__();
static int count_; ~__Core_Initializer__();
static CDCore * __instance__; static int count_;
}; static CDCore * __instance__;
};
class CDCore: public PIObject
{ class CD_UTILS_EXPORT CDCore: public PIObject
PIOBJECT(CDUtils::CDCore) {
friend class __Core_Initializer__; PIOBJECT(CDUtils::CDCore)
friend class CDSection; friend class __Core_Initializer__;
friend class Interface; friend class CDSection;
friend class XInterface; friend class Interface;
public: friend class XInterface;
static CDCore * instance(); public:
static bool destroy(); static CDCore * instance();
static bool destroy();
EVENT(K_Sended)
EVENT(K_SendFail) EVENT(K_Sended)
EVENT(K_Received) EVENT(K_SendFail)
EVENT(K_ReceiveFail) EVENT(K_Received)
EVENT(K_ChangedGlobal) EVENT(K_ReceiveFail)
EVENT_HANDLER2(void, K_DirectChange, PIDeque<int>, path, PIString, value); EVENT(K_ChangedGlobal)
EVENT_HANDLER2(void, K_DirectChange, PIDeque<int>, path, PIString, value);
EVENT(X_Sended)
EVENT(X_SendFail) EVENT(X_Sended)
EVENT(X_Received) EVENT(X_SendFail)
EVENT(X_ReceiveFail) EVENT(X_Received)
EVENT(X_ChangedGlobal) EVENT(X_ReceiveFail)
EVENT1(X_ReceivedX, PIVector<PIDeque<int> >, pathes) EVENT(X_ChangedGlobal)
EVENT1(X_ReceivedX, PIVector<PIDeque<int> >, pathes)
EVENT(C_Sended)
EVENT(C_SendFail) EVENT(C_Sended)
EVENT(C_Received) EVENT(C_SendFail)
EVENT(C_ReceiveFail) EVENT(C_Received)
EVENT(C_ChangedGlobal) EVENT(C_ReceiveFail)
EVENT(C_ChangedGlobal)
EVENT(M_Sended)
EVENT(M_SendFail) EVENT(M_Sended)
EVENT(M_Received) EVENT(M_SendFail)
EVENT(M_ReceiveFail) EVENT(M_Received)
EVENT(M_ChangedGlobal) EVENT(M_ReceiveFail)
EVENT3(M_Message, PIDeque<int>, path, int, type, PIString, msg) EVENT(M_ChangedGlobal)
EVENT3(M_Message, PIDeque<int>, path, int, type, PIString, msg)
void cd_write (CDSection * cd, PIIODevice * d);
void cd_read (CDSection * cd, PIIODevice * d); void cd_write (CDSection * cd, PIIODevice * d);
void cd_parse (CDSection * cd, PIIODevice * d); void cd_read (CDSection * cd, PIIODevice * d);
void cd_update (CDSection * cd, PIIODevice * d, UpdateModeFlags mode); void cd_parse (CDSection * cd, PIIODevice * d);
void cd_calculate(CDSection * cd); void cd_update (CDSection * cd, PIIODevice * d, UpdateModeFlags mode);
void cd_send (CDSection * cd, CDPacketType pt, bool direct = false); void cd_calculate(CDSection * cd);
void send(CDType::cdT cdt); void cd_send (CDSection * cd, CDPacketType pt, bool direct = false);
void request(CDType::cdT cdt); void send(CDType::cdT cdt);
void initApp(); void request(CDType::cdT cdt);
void initPult(); void initApp();
void init(const PIString & configuration, bool pult = false); void initPult();
void stop(); void init(const PIString & configuration, bool pult = false);
void release(); void stop();
void startX(double freq = 20.); void release();
void stopX(); void startX(double freq = 20.);
void sendCommand(const CDType & c); void stopX();
void registerCHandler(const CDType & c, PIObject * o, Handler h); void sendCommand(const CDType & c);
bool inProgress() {return sendt.isRunning();} void registerCHandler(const CDType & c, PIObject * o, Handler h);
void sendMessage(const CDType & m, MessageType mt, const PIString & msg); bool inProgress() {return sendt.isRunning();}
void sendMessage(const CDType & m, MessageType mt, const PIString & msg);
CDSection * root(CDType::cdT cdt);
PIString typeLetter(CDType::cdT cdt); CDSection * root(CDType::cdT cdt);
static PIString pathToString(const PIDeque<int> & p); PIString typeLetter(CDType::cdT cdt);
static PIDeque<int> stringToPath(const PIString & p); static PIString pathToString(const PIDeque<int> & p);
static PIDeque<int> stringToPath(const PIString & p);
static PIString pultConfig() {return PIString(pult_config);}
static PIString appConfig() {return PIString(app_config);} static PIString pultConfig() {return PIString(pult_config);}
static PIString appConfig() {return PIString(app_config);}
private:
CDCore(); private:
~CDCore(); CDCore();
EVENT_HANDLER2(void, dataReceived, const PIString &, from, const PIByteArray &, data); ~CDCore();
EVENT_HANDLER1(void, dtSendRequest, PIByteArray &, data); EVENT_HANDLER2(void, dataReceived, const PIString &, from, const PIByteArray &, data);
EVENT_HANDLER1(void, dtReceiveFinished, bool, ok); EVENT_HANDLER1(void, dtSendRequest, PIByteArray &, data);
EVENT_HANDLER(void, sendThread); EVENT_HANDLER1(void, dtReceiveFinished, bool, ok);
EVENT_HANDLER(void, xTimerTick); EVENT_HANDLER(void, sendThread);
EVENT_HANDLER2(void, piCoutFinished, int, id, PIString*, buffer); EVENT_HANDLER(void, xTimerTick);
void initRoot(CDSection * r); EVENT_HANDLER2(void, piCoutFinished, int, id, PIString*, buffer);
PIByteArray makeHeader(CDPacketType type, int session_id = 0) const; void initRoot(CDSection * r);
void sendDirect(PIByteArray & ba); PIByteArray makeHeader(CDPacketType type, int session_id = 0) const;
void sendThreaded(PIByteArray & ba); void sendDirect(PIByteArray & ba);
void procReceivedPacket(PIByteArray & ba); void sendThreaded(PIByteArray & ba);
void raiseChangedGlobal(CDType::cdT cdt); void procReceivedPacket(PIByteArray & ba);
void raiseChangedGlobal(CDType::cdT cdt);
typedef PIPair<PIObject * , Handler> OHPair;
typedef PIPair<PIObject * , Handler> OHPair;
static const char app_config[], pult_config[];
PIConnection connection; static const char app_config[], pult_config[];
PIDataTransfer datatr; PIConnection connection;
PIByteArray send_data; PIDataTransfer datatr;
PIThread sendt; PIByteArray send_data;
PITimer x_timer; PIThread sendt;
CDSection k_, x_, c_, m_; PITimer x_timer;
PIMutex x_mutex; CDSection k_, x_, c_, m_;
PIVector<PIDeque<int> > x_selected; PIMutex x_mutex;
PIMap<PIString, OHPair> c_handlers; PIVector<PIDeque<int> > x_selected;
bool need_rebuild_x, x_pult_side; PIMap<PIString, OHPair> c_handlers;
bool need_rebuild_x, x_pult_side;
};
};
static __Core_Initializer__ __Core_initializer__;
static __Core_Initializer__ __Core_initializer__;
}
}
#endif // CDUTILS_CORE_H
#endif // CDUTILS_CORE_H

View File

@@ -1,217 +1,217 @@
#include "cdutils_interface.h" #include "cdutils_interface.h"
#include "cdutils_core.h" #include "cdutils_core.h"
#include "piconfig.h" #include "piconfig.h"
#include "pifile.h" #include "pifile.h"
using namespace CDUtils; using namespace CDUtils;
Interface::Interface(CDType::cdT type_) { Interface::Interface(CDType::cdT type_) {
core = CDCore::instance(); core = CDCore::instance();
s = core->root(type_); s = core->root(type_);
type = type_; type = type_;
//piCoutObj << (void*)this << core; //piCoutObj << (void*)this << core;
file_ = core->typeLetter(type_) + PIStringAscii(".dat"); file_ = core->typeLetter(type_) + PIStringAscii(".dat");
file_size = 0; file_size = 0;
switch (type) { switch (type) {
case CDType::cdK: case CDType::cdK:
CONNECTU(core, K_Sended, this, sended); CONNECTU(core, K_Sended, this, sended);
CONNECTU(core, K_SendFail, this, sendFailed); CONNECTU(core, K_SendFail, this, sendFailed);
CONNECTU(core, K_Received, this, received); CONNECTU(core, K_Received, this, received);
CONNECTU(core, K_ReceiveFail, this, receiveFailed); CONNECTU(core, K_ReceiveFail, this, receiveFailed);
CONNECTU(core, K_ChangedGlobal, this, changedGlobal); CONNECTU(core, K_ChangedGlobal, this, changedGlobal);
break; break;
case CDType::cdX: case CDType::cdX:
CONNECTU(core, X_Sended, this, sended); CONNECTU(core, X_Sended, this, sended);
CONNECTU(core, X_SendFail, this, sendFailed); CONNECTU(core, X_SendFail, this, sendFailed);
CONNECTU(core, X_Received, this, received); CONNECTU(core, X_Received, this, received);
CONNECTU(core, X_ReceiveFail, this, receiveFailed); CONNECTU(core, X_ReceiveFail, this, receiveFailed);
CONNECTU(core, X_ChangedGlobal, this, changedGlobal); CONNECTU(core, X_ChangedGlobal, this, changedGlobal);
break; break;
case CDType::cdC: case CDType::cdC:
CONNECTU(core, C_Sended, this, sended); CONNECTU(core, C_Sended, this, sended);
CONNECTU(core, C_SendFail, this, sendFailed); CONNECTU(core, C_SendFail, this, sendFailed);
CONNECTU(core, C_Received, this, received); CONNECTU(core, C_Received, this, received);
CONNECTU(core, C_ReceiveFail, this, receiveFailed); CONNECTU(core, C_ReceiveFail, this, receiveFailed);
CONNECTU(core, C_ChangedGlobal, this, changedGlobal); CONNECTU(core, C_ChangedGlobal, this, changedGlobal);
break; break;
case CDType::cdM: case CDType::cdM:
CONNECTU(core, M_Sended, this, sended); CONNECTU(core, M_Sended, this, sended);
CONNECTU(core, M_SendFail, this, sendFailed); CONNECTU(core, M_SendFail, this, sendFailed);
CONNECTU(core, M_Received, this, received); CONNECTU(core, M_Received, this, received);
CONNECTU(core, M_ReceiveFail, this, receiveFailed); CONNECTU(core, M_ReceiveFail, this, receiveFailed);
CONNECTU(core, M_ChangedGlobal, this, changedGlobal); CONNECTU(core, M_ChangedGlobal, this, changedGlobal);
break; break;
default: break; default: break;
} }
} }
bool Interface::test(int v) { bool Interface::test(int v) {
return s->test(v); return s->test(v);
} }
CDType & Interface::operator [](const PIString & name_) { CDType & Interface::operator [](const PIString & name_) {
return (*s)[name_]; return (*s)[name_];
} }
const CDType Interface::operator [](const PIString & name_) const { const CDType Interface::operator [](const PIString & name_) const {
return (*s)[name_]; return (*s)[name_];
} }
CDType & Interface::operator [](const PIDeque<int> & path_) { CDType & Interface::operator [](const PIDeque<int> & path_) {
return (*s)[path_]; return (*s)[path_];
} }
const CDType Interface::operator [](const PIDeque<int> & path_) const { const CDType Interface::operator [](const PIDeque<int> & path_) const {
return (*s)[path_]; return (*s)[path_];
} }
CDType & Interface::operator [](int v) { CDType & Interface::operator [](int v) {
//piCout << (void*)this << "[]" << core; //piCout << (void*)this << "[]" << core;
return (*s)[v]; return (*s)[v];
} }
const CDType Interface::operator [](int v) const { const CDType Interface::operator [](int v) const {
//piCout << (void*)this << "[]" << core; //piCout << (void*)this << "[]" << core;
return (*s)[v]; return (*s)[v];
} }
CDSection & Interface::section(int v) { CDSection & Interface::section(int v) {
// CDSection & ret = s->section(v); // CDSection & ret = s->section(v);
// piCout << "[get section]" << v << ret.name; // piCout << "[get section]" << v << ret.name;
return s->section(v); return s->section(v);
} }
const CDSection Interface::section(int v) const { const CDSection Interface::section(int v) const {
return s->section(v); return s->section(v);
} }
CDSection & Interface::section(const PIDeque<int> &path) { CDSection & Interface::section(const PIDeque<int> &path) {
PIDeque<int> spath = path; PIDeque<int> spath = path;
CDSection * rs = s; CDSection * rs = s;
while (!spath.isEmpty()) { while (!spath.isEmpty()) {
rs = &(rs->section(spath.take_front())); rs = &(rs->section(spath.take_front()));
} }
return *rs; return *rs;
} }
CDSection & Interface::root() { CDSection & Interface::root() {
return *s; return *s;
} }
const CDSection & Interface::root() const { const CDSection & Interface::root() const {
return *s; return *s;
} }
int Interface::count(bool recursive) const { int Interface::count(bool recursive) const {
return s->count(recursive); return s->count(recursive);
} }
bool Interface::exists(PIDeque<int> path) const { bool Interface::exists(PIDeque<int> path) const {
return s->exists(path); return s->exists(path);
} }
void Interface::setFileName(const PIString & _file) { void Interface::setFileName(const PIString & _file) {
file_ = _file; file_ = _file;
} }
bool Interface::configure(const PIString & config) { bool Interface::configure(const PIString & config) {
PIConfig conf(config, PIIODevice::ReadOnly); PIConfig conf(config, PIIODevice::ReadOnly);
PIConfig::Entry & e(conf.getValue(core->typeLetter(s->cd_type_))); PIConfig::Entry & e(conf.getValue(core->typeLetter(s->cd_type_)));
bool ret = false; bool ret = false;
setFileName(e.getValue("file", file(), &ret).toString()); setFileName(e.getValue("file", file(), &ret).toString());
return ret; return ret;
} }
void Interface::reinitConnection(const PIString & configuration) { void Interface::reinitConnection(const PIString & configuration) {
core->init(configuration); core->init(configuration);
} }
void Interface::releaseConnection() { void Interface::releaseConnection() {
core->release(); core->release();
} }
void Interface::write(PIIODevice * d) { void Interface::write(PIIODevice * d) {
core->cd_write(s, d); core->cd_write(s, d);
} }
void Interface::read(PIIODevice * d) { void Interface::read(PIIODevice * d) {
core->cd_read(s, d); core->cd_read(s, d);
} }
void Interface::parse(PIIODevice * d) { void Interface::parse(PIIODevice * d) {
core->cd_parse(s, d); core->cd_parse(s, d);
} }
void Interface::update(PIIODevice * d, UpdateModeFlags mode) { void Interface::update(PIIODevice * d, UpdateModeFlags mode) {
core->cd_update(s, d, mode); core->cd_update(s, d, mode);
} }
void Interface::calculate() { void Interface::calculate() {
core->cd_calculate(s); core->cd_calculate(s);
} }
PIString Interface::appConfig() { PIString Interface::appConfig() {
return core->appConfig(); return core->appConfig();
} }
PIString Interface::pultConfig() { PIString Interface::pultConfig() {
return core->pultConfig(); return core->pultConfig();
} }
void Interface::readFile() { void Interface::readFile() {
if (file_.isEmpty()) return; if (file_.isEmpty()) return;
PIFile f(file_, PIIODevice::ReadOnly); PIFile f(file_, PIIODevice::ReadOnly);
read(&f); read(&f);
file_size = f.size(); file_size = f.size();
} }
void Interface::writeFile() { void Interface::writeFile() {
if (file_.isEmpty()) return; if (file_.isEmpty()) return;
PIFile f(file_, PIIODevice::ReadWrite); PIFile f(file_, PIIODevice::ReadWrite);
f.clear(); f.clear();
write(&f); write(&f);
file_size = f.size(); file_size = f.size();
} }
bool Interface::inProgress() { bool Interface::inProgress() {
return core->inProgress(); return core->inProgress();
} }
void Interface::send() { void Interface::send() {
core->send(type); core->send(type);
} }
void Interface::request() { void Interface::request() {
core->request(type); core->request(type);
} }

View File

@@ -1,95 +1,96 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_INTERFACE_H #ifndef CDUTILS_INTERFACE_H
#define CDUTILS_INTERFACE_H #define CDUTILS_INTERFACE_H
#include "cdutils_types.h" #include "cdutils_types.h"
#include "piobject.h" #include "piobject.h"
#include "cd_utils_export.h"
namespace CDUtils {
namespace CDUtils {
class CDCore;
class CDCore;
class Interface: public PIObject
{ class CD_UTILS_EXPORT Interface: public PIObject
PIOBJECT(CDUtils::Interface) {
public: PIOBJECT(CDUtils::Interface)
Interface(CDType::cdT type_); public:
Interface(CDType::cdT type_);
bool test(int v);
CDType & operator [](int v); bool test(int v);
const CDType operator [](int v) const; CDType & operator [](int v);
CDType & operator [](const PIString & name_); const CDType operator [](int v) const;
const CDType operator [](const PIString & name_) const; CDType & operator [](const PIString & name_);
CDType & operator [](const PIDeque<int> & path_); const CDType operator [](const PIString & name_) const;
const CDType operator [](const PIDeque<int> & path_) const; CDType & operator [](const PIDeque<int> & path_);
CDSection & section(int v); const CDType operator [](const PIDeque<int> & path_) const;
const CDSection section(int v) const; CDSection & section(int v);
CDSection & section(const PIDeque<int> & path); const CDSection section(int v) const;
CDSection & root(); CDSection & section(const PIDeque<int> & path);
const CDSection & root() const; CDSection & root();
const CDSection & root() const;
int count(bool recursive = true) const;
const PIString file() const {return file_;} int count(bool recursive = true) const;
int fileSize() const {return file_size;} const PIString file() const {return file_;}
CDType::cdT cdType() const {return type;} int fileSize() const {return file_size;}
bool exists(PIDeque<int> path) const; CDType::cdT cdType() const {return type;}
bool exists(PIDeque<int> path) const;
void setFileName(const PIString & _file);
bool configure(const PIString & config); void setFileName(const PIString & _file);
void reinitConnection(const PIString & configuration); bool configure(const PIString & config);
void releaseConnection(); void reinitConnection(const PIString & configuration);
void write(PIIODevice * d); void releaseConnection();
void read(PIIODevice * d); void write(PIIODevice * d);
void parse(PIIODevice * d); void read(PIIODevice * d);
void update(PIIODevice * d, UpdateModeFlags mode = SaveByName); void parse(PIIODevice * d);
void calculate(); void update(PIIODevice * d, UpdateModeFlags mode = SaveByName);
void calculate();
PIString appConfig();
PIString pultConfig(); PIString appConfig();
PIString pultConfig();
void readFile();
void writeFile(); void readFile();
bool inProgress(); void writeFile();
bool inProgress();
EVENT(sended)
EVENT(sendFailed) EVENT(sended)
EVENT(received) EVENT(sendFailed)
EVENT(receiveFailed) EVENT(received)
EVENT(changedGlobal) EVENT(receiveFailed)
EVENT_HANDLER(void, send); EVENT(changedGlobal)
EVENT_HANDLER(void, request); EVENT_HANDLER(void, send);
EVENT_HANDLER(void, request);
protected:
CDCore * core; protected:
CDSection * s; CDCore * core;
CDType::cdT type; CDSection * s;
PIString file_; CDType::cdT type;
int file_size; PIString file_;
int file_size;
};
};
}
}
#endif // CDUTILS_INTERFACE_H
#endif // CDUTILS_INTERFACE_H

View File

@@ -1,20 +1,20 @@
#include "cdutils_k.h" #include "cdutils_k.h"
#include "cdutils_core.h" #include "cdutils_core.h"
using namespace CDUtils; using namespace CDUtils;
KInterface K; KInterface K;
KInterface::KInterface(): Interface(CDType::cdK) { KInterface::KInterface(): Interface(CDType::cdK) {
} }
void KInterface::directChange(const CDType & k) { void KInterface::directChange(const CDType & k) {
core->K_DirectChange(k.path(), k.value()); core->K_DirectChange(k.path(), k.value());
} }
void KInterface::directChange(const CDType & k, double v) { void KInterface::directChange(const CDType & k, double v) {
core->K_DirectChange(k.path(), PIString::fromNumber(v)); core->K_DirectChange(k.path(), PIString::fromNumber(v));
} }

View File

@@ -1,46 +1,47 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_K_H #ifndef CDUTILS_K_H
#define CDUTILS_K_H #define CDUTILS_K_H
#include "cdutils_interface.h" #include "cdutils_interface.h"
#include "cd_utils_export.h"
namespace CDUtils {
namespace CDUtils {
class KInterface: public Interface
{ class CD_UTILS_EXPORT KInterface: public Interface
PIOBJECT_SUBCLASS(KInterface, Interface) {
public: PIOBJECT_SUBCLASS(KInterface, Interface)
KInterface(); public:
KInterface();
EVENT1(keepNamesRequest, bool*, kn)
EVENT1(keepNamesRequest, bool*, kn)
void directChange(const CDType & k);
void directChange(const CDType & k, double v); void directChange(const CDType & k);
void directChange(const CDType & k, double v);
};
};
}
}
extern CDUtils::KInterface K;
extern CD_UTILS_EXPORT CDUtils::KInterface K;
#endif // CDUTILS_K_H
#endif // CDUTILS_K_H

View File

@@ -1,22 +1,22 @@
#include "cdutils_m.h" #include "cdutils_m.h"
#include "cdutils_core.h" #include "cdutils_core.h"
using namespace CDUtils; using namespace CDUtils;
MInterface M; MInterface M;
MInterface::MInterface(): Interface(CDType::cdM) { MInterface::MInterface(): Interface(CDType::cdM) {
CONNECTU(core, M_Message, this, messageReceived); CONNECTU(core, M_Message, this, messageReceived);
} }
void MInterface::messageBox(const CDType & m, const PIString & msg) { void MInterface::messageBox(const CDType & m, const PIString & msg) {
core->sendMessage(m, MessageBox, msg); core->sendMessage(m, MessageBox, msg);
} }
PICout MInterface::createPICout(const CDType & m) const { PICout MInterface::createPICout(const CDType & m) const {
PIString * buff = new PIString("[" + CDCore::pathToString(m.path()) + "]"); PIString * buff = new PIString("[" + CDCore::pathToString(m.path()) + "]");
return PICout(buff, 1); return PICout(buff, 1);
} }

View File

@@ -1,55 +1,56 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_M_H #ifndef CDUTILS_M_H
#define CDUTILS_M_H #define CDUTILS_M_H
#include "cdutils_interface.h" #include "cdutils_interface.h"
#include "cd_utils_export.h"
namespace CDUtils {
namespace CDUtils {
class MInterface: public Interface
{ class CD_UTILS_EXPORT MInterface: public Interface
PIOBJECT_SUBCLASS(MInterface, Interface) {
public: PIOBJECT_SUBCLASS(MInterface, Interface)
MInterface(); public:
MInterface();
PICout operator [](int v) {return createPICout((*s)[v]);}
PICout operator [](int v) const {return createPICout((*s)[v]);} PICout operator [](int v) {return createPICout((*s)[v]);}
PICout operator [](const PIString & name_) {return createPICout((*s)[name_]);} PICout operator [](int v) const {return createPICout((*s)[v]);}
PICout operator [](const PIString & name_) const {return createPICout((*s)[name_]);} PICout operator [](const PIString & name_) {return createPICout((*s)[name_]);}
PICout operator [](const PIDeque<int> & path_) {return createPICout((*s)[path_]);} PICout operator [](const PIString & name_) const {return createPICout((*s)[name_]);}
PICout operator [](const PIDeque<int> & path_) const {return createPICout((*s)[path_]);} PICout operator [](const PIDeque<int> & path_) {return createPICout((*s)[path_]);}
PICout operator [](const PIDeque<int> & path_) const {return createPICout((*s)[path_]);}
void messageBox(const CDType & m, const PIString & msg);
void messageBox(const CDType & m, const PIString & msg);
EVENT3(messageReceived, PIDeque<int>, path, int, type, PIString, msg)
EVENT3(messageReceived, PIDeque<int>, path, int, type, PIString, msg)
private:
PICout createPICout(const CDType & m) const; private:
PICout createPICout(const CDType & m) const;
};
};
}
}
extern CDUtils::MInterface M;
extern CD_UTILS_EXPORT CDUtils::MInterface M;
#endif // CDUTILS_M_H
#endif // CDUTILS_M_H

View File

@@ -1,196 +1,196 @@
#include "cdutils_parser.h" #include "cdutils_parser.h"
#include "cdutils_types.h" #include "cdutils_types.h"
#include "piiostring.h" #include "piiostring.h"
#include "piiobytearray.h" #include "piiobytearray.h"
#include "pifile.h" #include "pifile.h"
using namespace CDUtils; using namespace CDUtils;
enum Phase { enum Phase {
eName = 1, eName = 1,
eBracketOpen, eBracketOpen,
eBracketClose, eBracketClose,
eMemberName, eMemberName,
eMemberEqual, eMemberEqual,
eMemberValue, eMemberValue,
eMemberComma, eMemberComma,
eComment, eComment,
eMultiComment eMultiComment
}; };
void removeComment(PIString & line, PIString * type, PIString * comment) { void removeComment(PIString & line, PIString * type, PIString * comment) {
int ci = line.find("//"); int ci = line.find("//");
if (ci >= 0) { if (ci >= 0) {
if (comment) *comment = line.right(line.size_s() - ci - 2); if (comment) *comment = line.right(line.size_s() - ci - 2);
line.cutRight(line.size_s() - ci).trim(); line.cutRight(line.size_s() - ci).trim();
if (type && comment && !line.isEmpty()) { if (type && comment && !line.isEmpty()) {
*type = comment->takeLeft(1); *type = comment->takeLeft(1);
comment->trim(); comment->trim();
} }
} }
} }
void parseEnumLine(PIString & line, int * value, PIString * type, PIString * comment) { void parseEnumLine(PIString & line, int * value, PIString * type, PIString * comment) {
removeComment(line, type, comment); removeComment(line, type, comment);
int ci = line.find("="); int ci = line.find("=");
if (ci >= 0) { if (ci >= 0) {
if (value) *value = line.right(line.size_s() - ci - 1).trim().toInt(); if (value) *value = line.right(line.size_s() - ci - 1).trim().toInt();
line.cutRight(line.size_s() - ci).trim(); line.cutRight(line.size_s() - ci).trim();
} }
if (line.trim().endsWith(",")) line.cutRight(1); if (line.trim().endsWith(",")) line.cutRight(1);
} }
void parseInsert(PIString line, PIString & alias, PIStringList & out) { void parseInsert(PIString line, PIString & alias, PIStringList & out) {
out.clear(); out.clear();
int ci = line.find("="); int ci = line.find("=");
if (ci < 0) return; if (ci < 0) return;
alias = line.right(line.size_s() - ci - 1).trim(); alias = line.right(line.size_s() - ci - 1).trim();
line.cutRight(line.size_s() - ci).trim(); line.cutRight(line.size_s() - ci).trim();
while (line.find("[") > 0) { while (line.find("[") > 0) {
int is = line.find("["), ie = line.find("]"); int is = line.find("["), ie = line.find("]");
PIString arr = line.mid(is + 1, ie - is - 1); PIString arr = line.mid(is + 1, ie - is - 1);
out << arr; out << arr;
line.cutMid(is, ie - is + 1); line.cutMid(is, ie - is + 1);
} }
if (!line.isEmpty()) out.insert(0, line); if (!line.isEmpty()) out.insert(0, line);
} }
PIVector<int> enumValues(const PIString & e, const PIMap<PIString, CDSection> & sections, PIStringList & enames) { PIVector<int> enumValues(const PIString & e, const PIMap<PIString, CDSection> & sections, PIStringList & enames) {
PIVector<int> ret; PIVector<int> ret;
enames.clear(); enames.clear();
if (sections.contains(e)) { if (sections.contains(e)) {
ret = sections[e].indexes(); ret = sections[e].indexes();
enames = sections[e].index_names(); enames = sections[e].index_names();
} else { } else {
int v = e.toInt(); int v = e.toInt();
if (v < 2) return ret; if (v < 2) return ret;
for (int i = 0; i < v; ++i) { for (int i = 0; i < v; ++i) {
ret << i; ret << i;
enames << "";//PIString::fromNumber(i); enames << "";//PIString::fromNumber(i);
} }
} }
return ret; return ret;
} }
CDSection CDParser::parse(PIIODevice * d, int cdsection_type) { CDSection CDParser::parse(PIIODevice * d, int cdsection_type) {
CDType::cdT et = (CDType::cdT)cdsection_type; CDType::cdT et = (CDType::cdT)cdsection_type;
if (!d) return CDSection(et); if (!d) return CDSection(et);
if (!d->canRead()) return CDSection(et); if (!d->canRead()) return CDSection(et);
//piCout << "[CDSection] parse start"; //piCout << "[CDSection] parse start";
CDSection cs(et); CDSection cs(et);
CDType ck; CDType ck;
PIMap<PIString, CDSection> sections; PIMap<PIString, CDSection> sections;
PIMap<PIString, int> enum_values; PIMap<PIString, int> enum_values;
PIString content, line, alias, type, comment; PIString content, line, alias, type, comment;
PIStringList iarr; PIStringList iarr;
if (PIStringAscii(d->className()) == PIStringAscii("PIFile")) { if (PIStringAscii(d->className()) == PIStringAscii("PIFile")) {
PIByteArray c = ((PIFile*)d)->readAll(); PIByteArray c = ((PIFile*)d)->readAll();
c << uchar(0); c << uchar(0);
content = PIString::fromUTF8((const char *)c.data()); content = PIString::fromUTF8((const char *)c.data());
} }
if (PIStringAscii(d->className()) == PIStringAscii("PIIOString")) content = *(((PIIOString*)d)->string()); if (PIStringAscii(d->className()) == PIStringAscii("PIIOString")) content = *(((PIIOString*)d)->string());
if (PIStringAscii(d->className()) == PIStringAscii("PIIOByteArray")) content = PIString(*(((PIIOByteArray*)d)->byteArray())); if (PIStringAscii(d->className()) == PIStringAscii("PIIOByteArray")) content = PIString(*(((PIIOByteArray*)d)->byteArray()));
PIIOString ios(&content); PIIOString ios(&content);
//int phase = 0; //int phase = 0;
int cind = -1; int cind = -1;
while ((cind = content.find("enum", cind)) >= 0) { while ((cind = content.find("enum", cind)) >= 0) {
ios.seek(cind); ios.seek(cind);
line = ios.readLine().trim(); line = ios.readLine().trim();
type.clear(); type.clear();
comment.clear(); comment.clear();
removeComment(line, &type, &comment); removeComment(line, &type, &comment);
if (line.find("{") < 0) { if (line.find("{") < 0) {
cind += 4; cind += 4;
continue; continue;
} }
line.cutLeft(line.find("enum") + 4).trim(); line.cutLeft(line.find("enum") + 4).trim();
line.cutRight(line.size_s() - line.find("{")).trim(); line.cutRight(line.size_s() - line.find("{")).trim();
if (line.isEmpty()) { if (line.isEmpty()) {
cind += 4; cind += 4;
continue; continue;
} }
cs = CDSection(et); cs = CDSection(et);
cs.name = line; cs.name = line;
//piCout << "enum" << cs.name; //piCout << "enum" << cs.name;
int cev = 0; int cev = 0;
// cevalues.clear(); // cevalues.clear();
while (!ios.isEnd()) { while (!ios.isEnd()) {
line = ios.readLine().trim(); line = ios.readLine().trim();
comment.clear(); comment.clear();
removeComment(line, &type, &comment); removeComment(line, &type, &comment);
if (line.find("}") >= 0) break; if (line.find("}") >= 0) break;
if (line.isEmpty()) { if (line.isEmpty()) {
if (comment.find("=") >= 0) { if (comment.find("=") >= 0) {
parseInsert(comment, alias, iarr); parseInsert(comment, alias, iarr);
if (!iarr.isEmpty()) { if (!iarr.isEmpty()) {
// piCout << "#" << enum_values; // piCout << "#" << enum_values;
if (!enum_values.contains(alias)) { if (!enum_values.contains(alias)) {
piCout << "Parse error: can`t find section alias \"" << alias << "\"!"; piCout << "Parse error: can`t find section alias \"" << alias << "\"!";
return CDSection(et); return CDSection(et);
} }
if (!sections.contains(iarr.front())) { if (!sections.contains(iarr.front())) {
piCout << "Parse error: can`t find section \"" << iarr.front() << "\"!"; piCout << "Parse error: can`t find section \"" << iarr.front() << "\"!";
return CDSection(et); return CDSection(et);
} }
//piCout << "insert" << alias << iarr; //piCout << "insert" << alias << iarr;
int aval = enum_values.value(alias); int aval = enum_values.value(alias);
CDSection is = sections.value(iarr.take_front()), ts; CDSection is = sections.value(iarr.take_front()), ts;
int ibpos = is.name.size_s(); int ibpos = is.name.size_s();
piForeachRC (PIString & a, iarr) { piForeachRC (PIString & a, iarr) {
PIStringList enames; PIStringList enames;
PIVector<int> evals = enumValues(a, sections, enames); PIVector<int> evals = enumValues(a, sections, enames);
//piCout << a << evals; //piCout << a << evals;
for (int i = 0; i < evals.size_s(); ++i) { for (int i = 0; i < evals.size_s(); ++i) {
ts.section(evals[i]) = is; ts.section(evals[i]) = is;
ts.section(evals[i]).alias = enames[i]; ts.section(evals[i]).alias = enames[i];
} }
ts.name = is.name; ts.name = is.name;
ts.name.insert(ibpos, PIString("[") << a << "]"); ts.name.insert(ibpos, PIString("[") << a << "]");
is = ts; is = ts;
ts = CDSection(et); ts = CDSection(et);
} }
is.alias = alias; is.alias = alias;
cs.section(aval) = is; cs.section(aval) = is;
} }
} }
} else { } else {
parseEnumLine(line, &cev, &type, &comment); parseEnumLine(line, &cev, &type, &comment);
//piCout << line << "=" << cev << "//" << type << comment; //piCout << line << "=" << cev << "//" << type << comment;
ck = CDType(cev, line, type, "", "", comment, et); ck = CDType(cev, line, type, "", "", comment, et);
if (type == "e") { if (type == "e") {
if (comment.startsWith("${")) { if (comment.startsWith("${")) {
comment.cutLeft(1); comment.cutLeft(1);
PIString en = comment.inBrackets('{', '}'); PIString en = comment.inBrackets('{', '}');
comment.cutLeft(en.size_s() + 2).trim(); comment.cutLeft(en.size_s() + 2).trim();
ck.setEnumValues(sections.value(en).enumValues()); ck.setEnumValues(sections.value(en).enumValues());
ck.setComment(comment); ck.setComment(comment);
//piCout << "enum" << en << ck.enumValues(); //piCout << "enum" << en << ck.enumValues();
} }
} }
cs[cev] = ck; cs[cev] = ck;
//cevalues[line] = cev; //cevalues[line] = cev;
enum_values[line] = cev; enum_values[line] = cev;
++cev; ++cev;
} }
} }
//piCout << cs.name << cs.k; //piCout << cs.name << cs.k;
sections[cs.name] = cs; sections[cs.name] = cs;
// piCout << "#" << cevalues; // piCout << "#" << cevalues;
// enum_values << cevalues; // enum_values << cevalues;
cind += 4; cind += 4;
} }
// piCout << "[CDSection] parse end"; // piCout << "[CDSection] parse end";
switch (et) { switch (et) {
case CDType::cdK: return sections.value("KDescription"); case CDType::cdK: return sections.value("KDescription");
case CDType::cdX: return sections.value("XDescription"); case CDType::cdX: return sections.value("XDescription");
case CDType::cdC: return sections.value("CDescription"); case CDType::cdC: return sections.value("CDescription");
case CDType::cdM: return sections.value("MDescription"); case CDType::cdM: return sections.value("MDescription");
default: return CDSection(et); default: return CDSection(et);
} }
return CDSection(et); return CDSection(et);
} }

View File

@@ -1,38 +1,39 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_PARSER_H #ifndef CDUTILS_PARSER_H
#define CDUTILS_PARSER_H #define CDUTILS_PARSER_H
#include "cd_utils_export.h"
class PIIODevice;
class PIIODevice;
namespace CDUtils {
namespace CDUtils {
class CDSection;
class CDSection;
namespace CDParser {
namespace CDParser {
CDSection parse(PIIODevice * d, int cdsection_type);
CD_UTILS_EXPORT CDSection parse(PIIODevice * d, int cdsection_type);
}
}
}
}
#endif // CDUTILS_PARSER_H
#endif // CDUTILS_PARSER_H

View File

@@ -1,72 +1,73 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_PROTOCOL_H #ifndef CDUTILS_PROTOCOL_H
#define CDUTILS_PROTOCOL_H #define CDUTILS_PROTOCOL_H
#include "pibytearray.h" #include "pistring.h"
#include "cd_utils_export.h"
namespace CDUtils {
namespace CDUtils {
enum CDPacketType {
CD_Ping, enum CDPacketType {
CD_Pong, CD_Ping,
CD_Pong,
CD_KQuery,
CD_KSend, CD_KQuery,
CD_KDirectChange, CD_KSend,
CD_KDirectChange,
CD_XQuery,
CD_XSend, CD_XQuery,
CD_XRequest, CD_XSend,
CD_XValues, CD_XRequest,
CD_XValues,
CD_CQuery,
CD_CSend, CD_CQuery,
CD_Command, CD_CSend,
CD_Command,
CD_MQuery,
CD_MSend, CD_MQuery,
CD_Message, CD_MSend,
}; CD_Message,
};
# pragma pack(push,1)
# pragma pack(push,1)
struct PacketHeader {
int type; // CDPacketType struct CD_UTILS_EXPORT PacketHeader {
int session_id; int type; // CDPacketType
}; int session_id;
};
struct PacketKDirectChange {
PIDeque<int> path; struct CD_UTILS_EXPORT PacketKDirectChange {
PIString value; PIDeque<int> path;
}; PIString value;
};
# pragma pack(pop)
# pragma pack(pop)
inline PIByteArray & operator <<(PIByteArray & s, const PacketHeader & v) {s << v.type << v.session_id; return s;}
inline PIByteArray & operator >>(PIByteArray & s, PacketHeader & v) {s >> v.type >> v.session_id; return s;} inline PIByteArray & operator <<(PIByteArray & s, const PacketHeader & v) {s << v.type << v.session_id; return s;}
inline PIByteArray & operator >>(PIByteArray & s, PacketHeader & v) {s >> v.type >> v.session_id; return s;}
inline PIByteArray & operator <<(PIByteArray & s, const PacketKDirectChange & v) {s << v.path << v.value; return s;}
inline PIByteArray & operator >>(PIByteArray & s, PacketKDirectChange & v) {s >> v.path >> v.value; return s;} inline PIByteArray & operator <<(PIByteArray & s, const PacketKDirectChange & v) {s << v.path << v.value; return s;}
inline PIByteArray & operator >>(PIByteArray & s, PacketKDirectChange & v) {s >> v.path >> v.value; return s;}
}
}
#endif // CDUTILS_PROTOCOL_H
#endif // CDUTILS_PROTOCOL_H

View File

@@ -1,762 +1,762 @@
#include "cdutils_types.h" #include "cdutils_types.h"
#include "piconfig.h" #include "piconfig.h"
#include "pifile.h" #include "pifile.h"
#include "pievaluator.h" #include "pievaluator.h"
#include "cdutils_core.h" #include "cdutils_core.h"
using namespace CDUtils; using namespace CDUtils;
//int cdtype_debug_cnt = 1; //int cdtype_debug_cnt = 1;
const int cd_x_history_max_size = 4000; const int cd_x_history_max_size = 4000;
CDType::CDType() { CDType::CDType() {
index_ = -1; index_ = -1;
value_d = 0.; value_d = 0.;
value_i = 0; value_i = 0;
value_b = calculated = x_enabled = false; value_b = calculated = x_enabled = false;
cd_type_ = cdNull; cd_type_ = cdNull;
parent = 0; parent = 0;
avg_size = 1; avg_size = 1;
mode_ = rmode_ = X_Current; mode_ = rmode_ = X_Current;
// debug_cnt = cdtype_debug_cnt; // debug_cnt = cdtype_debug_cnt;
// cdtype_debug_cnt++; // cdtype_debug_cnt++;
// piCout << "[CDType]" << "create Null" << debug_cnt; // piCout << "[CDType]" << "create Null" << debug_cnt;
} }
CDType::CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t) { CDType::CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t) {
index_ = i; index_ = i;
name_ = n.trimmed(); name_ = n.trimmed();
type_ = t.trimmed(); type_ = t.trimmed();
value_s = v.trimmed(); value_s = v.trimmed();
formula_ = f.trimmed(); formula_ = f.trimmed();
comment_ = c.trimmed(); comment_ = c.trimmed();
value_d = v.toDouble(); value_d = v.toDouble();
value_i = v.toInt(); value_i = v.toInt();
value_b = v.toBool(); value_b = v.toBool();
cd_type_ = cd_t; cd_type_ = cd_t;
calculated = x_enabled = false; calculated = x_enabled = false;
parent = 0; parent = 0;
avg_size = 1; avg_size = 1;
mode_ = rmode_ = X_Current; mode_ = rmode_ = X_Current;
if (type_ == "e") { if (type_ == "e") {
enum_values = parseEnumComment(comment_); enum_values = parseEnumComment(comment_);
// piCout << enum_values.size() << enum_values; // piCout << enum_values.size() << enum_values;
} }
// piCout << type_.size() << type_.toUTF8(); // piCout << type_.size() << type_.toUTF8();
// piCout << formula_.size() << formula_.toUTF8(); // piCout << formula_.size() << formula_.toUTF8();
// piCout << comment_.size() << comment_.toUTF8(); // piCout << comment_.size() << comment_.toUTF8();
// debug_cnt = cdtype_debug_cnt; // debug_cnt = cdtype_debug_cnt;
// cdtype_debug_cnt++; // cdtype_debug_cnt++;
// piCout << "[CDType] create" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK); // piCout << "[CDType] create" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK);
} }
CDType & CDType::operator =(double x) { CDType & CDType::operator =(double x) {
value_d = x; value_d = x;
value_i = x; value_i = x;
value_b = x > 0.; value_b = x > 0.;
if (mode_ == X_All_Avg) { if (mode_ == X_All_Avg) {
avg_h << x; avg_h << x;
double val = 0; double val = 0;
if (avg_h.size_s() >= avg_size) { if (avg_h.size_s() >= avg_size) {
for (int i = 0; i < avg_h.size_s(); i++) for (int i = 0; i < avg_h.size_s(); i++)
val += avg_h[i]; val += avg_h[i];
val /= avg_h.size(); val /= avg_h.size();
avg_h.clear(); avg_h.clear();
if (history.size() < cd_x_history_max_size) if (history.size() < cd_x_history_max_size)
history << val; history << val;
} }
} }
return *this; return *this;
} }
PIString CDType::type() const { PIString CDType::type() const {
if (type_.trimmed().isEmpty()) return "f"; if (type_.trimmed().isEmpty()) return "f";
// piCout << "type =" << type_.trimmed() << ";" << type_ << "#"; // piCout << "type =" << type_.trimmed() << ";" << type_ << "#";
return type_; return type_;
} }
PIString CDType::value() const { PIString CDType::value() const {
if (type_ == "b") return PIString::fromBool(value_b); if (type_ == "b") return PIString::fromBool(value_b);
return value_s; return value_s;
} }
PIVariant CDType::variantValue() const { PIVariant CDType::variantValue() const {
if (type_.isEmpty()) return PIVariant(value()); if (type_.isEmpty()) return PIVariant(value());
switch (type_[0].toAscii()) { switch (type_[0].toAscii()) {
case 'b': return PIVariant(toBool()); break; case 'b': return PIVariant(toBool()); break;
case 'n': return PIVariant(toInt()); break; case 'n': return PIVariant(toInt()); break;
case 'f': return PIVariant(toDouble()); break; case 'f': return PIVariant(toDouble()); break;
case 'c': return PIVariant(PIVariantTypes::Color(toInt())); break; case 'c': return PIVariant(PIVariantTypes::Color(toInt())); break;
case 'e': { case 'e': {
PIVariantTypes::Enum e = enum_values; PIVariantTypes::Enum e = enum_values;
e.selectValue(toInt()); e.selectValue(toInt());
return PIVariant(e); return PIVariant(e);
break; break;
} }
default: break; default: break;
} }
return PIVariant(value()); return PIVariant(value());
} }
void CDType::setValue(const PIString & value_) { void CDType::setValue(const PIString & value_) {
formula_ = value_; formula_ = value_;
value_d = formula_.toDouble(); value_d = formula_.toDouble();
value_i = formula_.toInt(); value_i = formula_.toInt();
value_b = formula_.toBool(); value_b = formula_.toBool();
} }
void CDType::setVariantValue(const PIVariant & value_) { void CDType::setVariantValue(const PIVariant & value_) {
setValue(PIString::fromNumber(value_.toDouble())); setValue(PIString::fromNumber(value_.toDouble()));
} }
void CDType::setFormula(const PIString & f) { void CDType::setFormula(const PIString & f) {
formula_ = f; formula_ = f;
calculated = false; calculated = false;
//PIEvaluator e; //PIEvaluator e;
//calculate(&e); //calculate(&e);
} }
PIStringList CDType::pathString() const { PIStringList CDType::pathString() const {
PIStringList ret; PIStringList ret;
CDSection * ps = CDCore::instance()->root(cd_type_); CDSection * ps = CDCore::instance()->root(cd_type_);
if (!ps) return ret; if (!ps) return ret;
for (int i = 0; i < path_.size_s() - 1; ++i) { for (int i = 0; i < path_.size_s() - 1; ++i) {
ps = &(ps->section(path_[i])); ps = &(ps->section(path_[i]));
if (!ps->alias.isEmpty()) ret << ps->alias; if (!ps->alias.isEmpty()) ret << ps->alias;
else ret << PIString::fromNumber(path_[i]); else ret << PIString::fromNumber(path_[i]);
} }
if (!name_.isEmpty()) ret << name_; if (!name_.isEmpty()) ret << name_;
else ret << PIString::fromNumber(index_); else ret << PIString::fromNumber(index_);
return ret; return ret;
} }
void CDType::readX(PIByteArray & ba) { void CDType::readX(PIByteArray & ba) {
if (ba.size() < 5) return; if (ba.size() < 5) return;
uchar t(0); ba >> t; uchar t(0); ba >> t;
rmode_ = (XMode)t; rmode_ = (XMode)t;
switch (rmode_) { switch (rmode_) {
case X_Current: case X_Current:
ba >> value_d; ba >> value_d;
break; break;
case X_All_Avg: { case X_All_Avg: {
PIVector<double> ah; PIVector<double> ah;
ba >> ah; ba >> ah;
history << ah; history << ah;
if (!history.isEmpty()) if (!history.isEmpty())
value_d = history.back(); value_d = history.back();
} break; } break;
default: break; default: break;
} }
value_i = value_d; value_i = value_d;
value_b = value_d > 0.; value_b = value_d > 0.;
} }
void CDType::writeX(PIByteArray & ba) { void CDType::writeX(PIByteArray & ba) {
ba << uchar(mode_); ba << uchar(mode_);
switch (mode_) { switch (mode_) {
case X_Current: case X_Current:
ba << value_d; ba << value_d;
break; break;
case X_All_Avg: case X_All_Avg:
ba << history; ba << history;
history.clear(); history.clear();
break; break;
default: break; default: break;
} }
} }
bool CDType::calculate(PIEvaluator * e, PIVector<const CDType * > stack) { bool CDType::calculate(PIEvaluator * e, PIVector<const CDType * > stack) {
if (stack.contains(this)) { if (stack.contains(this)) {
error_ = "Circular dependencies: "; error_ = "Circular dependencies: ";
piForeachC (CDType * k, stack) piForeachC (CDType * k, stack)
error_ << k->name() << " -> "; error_ << k->name() << " -> ";
error_ << name(); error_ << name();
//piCout << error_; //piCout << error_;
return false; return false;
} }
stack << this; stack << this;
if (calculated) return true; if (calculated) return true;
calculated = true; calculated = true;
error_.clear(); error_.clear();
if (!parent) return true; if (!parent) return true;
//piCout << "calc" << name_ << (parent ? parent->alias : "root"); //piCout << "calc" << name_ << (parent ? parent->alias : "root");
value_s = formula_.trimmed(); value_s = formula_.trimmed();
for (;;) { for (;;) {
int ki = value_s.find("K["); int ki = value_s.find("K[");
if (ki < 0) break; if (ki < 0) break;
int ke = value_s.find("]", ki + 2); int ke = value_s.find("]", ki + 2);
if (ke < 0) break; if (ke < 0) break;
PIString kp = value_s.mid(ki + 2, ke - ki - 2); PIString kp = value_s.mid(ki + 2, ke - ki - 2);
//piCout << kp; //piCout << kp;
CDType & k((*parent)[kp]); CDType & k((*parent)[kp]);
k.calculate(e, stack); k.calculate(e, stack);
value_s.replace(ki, ke - ki + 1, PIString::fromNumber(k.value_d)); value_s.replace(ki, ke - ki + 1, PIString::fromNumber(k.value_d));
} }
value_d = formula_.toDouble(); value_d = formula_.toDouble();
value_i = formula_.toInt(); value_i = formula_.toInt();
value_b = formula_.toBool(); value_b = formula_.toBool();
double ev = 0.; double ev = 0.;
if (!e->check(value_s) && value_d == 0. && value_i == 0 && !value_b) { if (!e->check(value_s) && value_d == 0. && value_i == 0 && !value_b) {
PIString f = formula_.trimmed().toLowerCase(); PIString f = formula_.trimmed().toLowerCase();
if (f != "off" && f != "false" && f != "no" && !value_b) { if (f != "off" && f != "false" && f != "no" && !value_b) {
error_ = e->error(); error_ = e->error();
return false; return false;
} }
} else } else
if (e->isCorrect()) if (e->isCorrect())
ev = e->evaluate().real(); ev = e->evaluate().real();
//piCout << value_s << value_i << value_d << ev; //piCout << value_s << value_i << value_d << ev;
//if ((value_d == 0.) || (piAbsd(value_d) < piAbsd(ev))) value_d = ev; //if ((value_d == 0.) || (piAbsd(value_d) < piAbsd(ev))) value_d = ev;
//if ((value_i == 0) || (piAbsd(value_i) < piAbsd(ev))) value_i = int(ev); //if ((value_i == 0) || (piAbsd(value_i) < piAbsd(ev))) value_i = int(ev);
if ((value_d == 0.) || (ev != 0.)) value_d = ev; if ((value_d == 0.) || (ev != 0.)) value_d = ev;
if ((value_i == 0) || (ev != 0.)) value_i = int(ev); if ((value_i == 0) || (ev != 0.)) value_i = int(ev);
value_b = value_b || (ev > 0.); value_b = value_b || (ev > 0.);
if (value_i != 0) { if (value_i != 0) {
if (value_d == 0.) value_d = value_i; if (value_d == 0.) value_d = value_i;
value_b = value_i > 0; value_b = value_i > 0;
} }
if (value_d != 0.) { if (value_d != 0.) {
if (value_i == 0) value_i = value_d; if (value_i == 0) value_i = value_d;
value_b = value_d > 0.; value_b = value_d > 0.;
} }
if (value_b) { if (value_b) {
if (value_d == 0.) value_d = 1.; if (value_d == 0.) value_d = 1.;
if (value_i == 0) value_i = 1; if (value_i == 0) value_i = 1;
} }
value_s = PIString::fromNumber(value_d); value_s = PIString::fromNumber(value_d);
return true; return true;
} }
PIVariantTypes::Enum CDType::parseEnumComment(PIString c) { PIVariantTypes::Enum CDType::parseEnumComment(PIString c) {
PIVariantTypes::Enum ret; PIVariantTypes::Enum ret;
if (c.isEmpty()) return ret; if (c.isEmpty()) return ret;
if (type_ == "e") { if (type_ == "e") {
PIStringList sl = c.inBrackets('{', '}').split(","); PIStringList sl = c.inBrackets('{', '}').split(",");
int cval = 0; int cval = 0;
piForeach (PIString & s, sl) { piForeach (PIString & s, sl) {
s.trim(); s.trim();
if (s.isEmpty()) continue; if (s.isEmpty()) continue;
if (s[0].isDigit()) { if (s[0].isDigit()) {
int ind = s.find("-"); int ind = s.find("-");
if (ind > 0) { if (ind > 0) {
cval = s.left(ind).toInt(); cval = s.left(ind).toInt();
s.cutLeft(ind + 1).trim(); s.cutLeft(ind + 1).trim();
} }
} }
ret << PIVariantTypes::Enumerator(cval, s); ret << PIVariantTypes::Enumerator(cval, s);
++cval; ++cval;
} }
} }
//piCout << c << "=" << ret; //piCout << c << "=" << ret;
return ret; return ret;
} }
//CDType::CDType(const CDType &cdt) { //CDType::CDType(const CDType &cdt) {
// index_ = cdt.index_; // index_ = cdt.index_;
// name_ = cdt.name_; // name_ = cdt.name_;
// type_ = cdt.type_; // type_ = cdt.type_;
// value_s = cdt.value_s; // value_s = cdt.value_s;
// formula_ = cdt.formula_; // formula_ = cdt.formula_;
// comment_ = cdt.comment_; // comment_ = cdt.comment_;
// value_d = cdt.value_d; // value_d = cdt.value_d;
// value_i = cdt.value_i; // value_i = cdt.value_i;
// value_b = cdt.value_b; // value_b = cdt.value_b;
// cd_type_ = cdt.cd_type_; // cd_type_ = cdt.cd_type_;
// debug_cnt = cdtype_debug_cnt; // debug_cnt = cdtype_debug_cnt;
// cdtype_debug_cnt++; // cdtype_debug_cnt++;
// piCout << "[CDType] copy" << debug_cnt << "->" << cdt.debug_cnt << index_ << ":" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK); // piCout << "[CDType] copy" << debug_cnt << "->" << cdt.debug_cnt << index_ << ":" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK);
//} //}
//CDType &CDType::operator =(const CDType &cdt) { //CDType &CDType::operator =(const CDType &cdt) {
// index_ = cdt.index_; // index_ = cdt.index_;
// name_ = cdt.name_; // name_ = cdt.name_;
// type_ = cdt.type_; // type_ = cdt.type_;
// value_s = cdt.value_s; // value_s = cdt.value_s;
// formula_ = cdt.formula_; // formula_ = cdt.formula_;
// comment_ = cdt.comment_; // comment_ = cdt.comment_;
// value_d = cdt.value_d; // value_d = cdt.value_d;
// value_i = cdt.value_i; // value_i = cdt.value_i;
// value_b = cdt.value_b; // value_b = cdt.value_b;
// cd_type_ = cdt.cd_type_; // cd_type_ = cdt.cd_type_;
// piCout << "[CDType] assign" << debug_cnt << "=" << cdt.debug_cnt << index_ << ":" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK); // piCout << "[CDType] assign" << debug_cnt << "=" << cdt.debug_cnt << index_ << ":" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK);
// //debug_cnt = cdt.debug_cnt; // //debug_cnt = cdt.debug_cnt;
// return *this; // return *this;
//} //}
//CDType::~CDType() { //CDType::~CDType() {
// piCout << "[CDType] delete" << debug_cnt << index_ << ":" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK); // piCout << "[CDType] delete" << debug_cnt << index_ << ":" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK);
//} //}
CDSection::CDSection(CDType::cdT type_) { CDSection::CDSection(CDType::cdT type_) {
cd_type_ = type_; cd_type_ = type_;
null.cd_type_ = type_; null.cd_type_ = type_;
} }
CDSection & CDSection::section(int v) { CDSection & CDSection::section(int v) {
CDSection & ret(s[v]); CDSection & ret(s[v]);
ret.cd_type_ = cd_type_; ret.cd_type_ = cd_type_;
return ret; return ret;
} }
const CDSection CDSection::section(int v) const { const CDSection CDSection::section(int v) const {
CDSection & ret(s[v]); CDSection & ret(s[v]);
ret.cd_type_ = cd_type_; ret.cd_type_ = cd_type_;
return s[v]; return s[v];
} }
bool CDSection::exists(PIDeque<int> path) const { bool CDSection::exists(PIDeque<int> path) const {
if (path.isEmpty()) return false; if (path.isEmpty()) return false;
if (path.size_s() == 1) return cd.contains(path[0]); if (path.size_s() == 1) return cd.contains(path[0]);
int si = path[0]; int si = path[0];
if (!s.contains(si)) return false; if (!s.contains(si)) return false;
path.remove(0, 1); path.remove(0, 1);
return s[si].exists(path); return s[si].exists(path);
} }
int CDSection::count(bool recursive) const { int CDSection::count(bool recursive) const {
int ret = cd.size_s(); int ret = cd.size_s();
if (recursive) { if (recursive) {
PIMap<int, CDSection>::const_iterator i; PIMap<int, CDSection>::const_iterator i;
for (i = s.constBegin(); i != s.constEnd(); ++i) for (i = s.constBegin(); i != s.constEnd(); ++i)
ret += i->second.count(recursive); ret += i->second.count(recursive);
} }
return ret; return ret;
} }
int CDSection::sectionsCount() const { int CDSection::sectionsCount() const {
return s.size(); return s.size();
} }
PIStringList CDSection::index_names() const { PIStringList CDSection::index_names() const {
PIStringList ret; PIStringList ret;
auto i = cd.makeIterator(); auto i = cd.makeIterator();
while (i.next()) while (i.next())
ret << i.value().name(); ret << i.value().name();
return ret; return ret;
} }
void CDSection::calculate() { void CDSection::calculate() {
prepareCalculate(); prepareCalculate();
if (cd_type_ != CDType::cdK) return; if (cd_type_ != CDType::cdK) return;
PIEvaluator e; PIEvaluator e;
calculateRecursive(&e); calculateRecursive(&e);
} }
CDType & CDSection::getByName(const PIString & name_) { CDType & CDSection::getByName(const PIString & name_) {
PIStringList np = name_.split("."); PIStringList np = name_.split(".");
if (np.isEmpty()) return null; if (np.isEmpty()) return null;
//piCout << np; //piCout << np;
CDSection * cs = this, * ns = 0; CDSection * cs = this, * ns = 0;
if (np.front().isEmpty()) { if (np.front().isEmpty()) {
if (np.size_s() < 2) return null; if (np.size_s() < 2) return null;
cs = CDCore::instance()->root(cd_type_); cs = CDCore::instance()->root(cd_type_);
np.pop_front(); np.pop_front();
} }
for (int i = 0; i < np.size_s() - 1; ++i) { for (int i = 0; i < np.size_s() - 1; ++i) {
if (np[i].isEmpty()) return null; if (np[i].isEmpty()) return null;
bool isd = np[i][0].isDigit() || (np[i][0] == '-'); bool isd = np[i][0].isDigit() || (np[i][0] == '-');
int dv = 0; int dv = 0;
if (isd) dv = np[i].toInt(); if (isd) dv = np[i].toInt();
ns = 0; ns = 0;
auto it = cs->s.makeIterator(); auto it = cs->s.makeIterator();
while (it.next()) { while (it.next()) {
bool f = false; bool f = false;
if (isd) f = (dv == it.key()); if (isd) f = (dv == it.key());
else f = (np[i] == it.value().alias); else f = (np[i] == it.value().alias);
//piCout << "s..." << it.key() << it.value().alias << f; //piCout << "s..." << it.key() << it.value().alias << f;
if (f) { if (f) {
ns = &(it.valueRef()); ns = &(it.valueRef());
break; break;
} }
} }
//piCout << ns; //piCout << ns;
if (!ns) return null; if (!ns) return null;
cs = ns; cs = ns;
} }
if (np.back().isEmpty()) return null; if (np.back().isEmpty()) return null;
bool isd = np.back()[0].isDigit() || (np.back()[0] == '-'); bool isd = np.back()[0].isDigit() || (np.back()[0] == '-');
int dv = 0; int dv = 0;
if (isd) dv = np.back().toInt(); if (isd) dv = np.back().toInt();
//piCout << np.back() << isd << dv; //piCout << np.back() << isd << dv;
auto it = cs->cd.makeIterator(); auto it = cs->cd.makeIterator();
while (it.next()) { while (it.next()) {
bool f = false; bool f = false;
if (isd) f = (dv == it.key()); if (isd) f = (dv == it.key());
else f = (np.back() == it.value().name()); else f = (np.back() == it.value().name());
//piCout << "k..." << it.key() << it.value().name() << f; //piCout << "k..." << it.key() << it.value().name() << f;
if (f) if (f)
return cs->cd[it.key()]; return cs->cd[it.key()];
} }
return null; return null;
} }
CDType & CDSection::getByPath(const PIDeque<int> & path_) { CDType & CDSection::getByPath(const PIDeque<int> & path_) {
if (path_.isEmpty()) return null; if (path_.isEmpty()) return null;
CDSection * s = this; CDSection * s = this;
for (int i = 0; i < path_.size_s() - 1; ++i) for (int i = 0; i < path_.size_s() - 1; ++i)
s = &(s->section(path_[i])); s = &(s->section(path_[i]));
if (!s) return null; if (!s) return null;
return (*s)[path_.back()]; return (*s)[path_.back()];
} }
void CDSection::write(PIIODevice * d, const PIString & prefix) { void CDSection::write(PIIODevice * d, const PIString & prefix) {
if (!d) return; if (!d) return;
if (cd.isEmpty() && s.isEmpty()) return; if (cd.isEmpty() && s.isEmpty()) return;
// piCout << "[CDSection] write start"; // piCout << "[CDSection] write start";
PIString l; PIString l;
PIStringList cdtl; PIStringList cdtl;
cdtl << "null" << "k" << "x" << "c" << "m"; cdtl << "null" << "k" << "x" << "c" << "m";
if (prefix.isEmpty()) l = "[" + cdtl[cd_type_] + "]"; if (prefix.isEmpty()) l = "[" + cdtl[cd_type_] + "]";
else l = "[" + prefix + "." + cdtl[cd_type_] + "]"; else l = "[" + prefix + "." + cdtl[cd_type_] + "]";
l += "\n"; l += "\n";
d->write(l.toUTF8()); d->write(l.toUTF8());
l = "name = " + name + " \n"; l = "name = " + name + " \n";
d->write(l.toUTF8()); d->write(l.toUTF8());
l = "alias = " + alias + " \n"; l = "alias = " + alias + " \n";
d->write(l.toUTF8()); d->write(l.toUTF8());
auto i = cd.makeIterator(); auto i = cd.makeIterator();
while (i.next()) { while (i.next()) {
const CDType & ck(i.value()); const CDType & ck(i.value());
if (ck.cd_type() != cd_type_) continue; if (ck.cd_type() != cd_type_) continue;
switch (cd_type_) { switch (cd_type_) {
case CDType::cdNull: break; case CDType::cdNull: break;
case CDType::cdK: case CDType::cdK:
l.clear(); l << ck.index() << ".f = " << ck.formula() << " #s " << ck.comment() << " \n"; l.clear(); l << ck.index() << ".f = " << ck.formula() << " #s " << ck.comment() << " \n";
d->write(l.toUTF8()); d->write(l.toUTF8());
l.clear(); l << ck.index() << ".v = " << ck.value() << " #" << ck.type() << " " << ck.name() << " \n"; l.clear(); l << ck.index() << ".v = " << ck.value() << " #" << ck.type() << " " << ck.name() << " \n";
d->write(l.toUTF8()); d->write(l.toUTF8());
if (!ck.enumValues().enum_list.isEmpty()) { if (!ck.enumValues().enum_list.isEmpty()) {
l.clear(); l << ck.index() << ".ev = {"; l.clear(); l << ck.index() << ".ev = {";
//PIVector<CDType::Enumerator> el = ck.enumValues(); //PIVector<CDType::Enumerator> el = ck.enumValues();
piForeachC (PIVariantTypes::Enumerator & e, ck.enumValues().enum_list) piForeachC (PIVariantTypes::Enumerator & e, ck.enumValues().enum_list)
l << e.value << " - " << e.name << ", "; l << e.value << " - " << e.name << ", ";
l.cutRight(2); l.cutRight(2);
l << "} \n"; l << "} \n";
d->write(l.toUTF8()); d->write(l.toUTF8());
} }
break; break;
case CDType::cdX: case CDType::cdX:
l.clear(); l << ck.index() << ".name = " << ck.name() << " #s " << ck.comment() << " \n"; l.clear(); l << ck.index() << ".name = " << ck.name() << " #s " << ck.comment() << " \n";
d->write(l.toUTF8()); d->write(l.toUTF8());
l.clear(); l << ck.index() << ".mode = " << ck.xmode() << " #e (0 - cur, 1 - all_avg) " << "\n"; l.clear(); l << ck.index() << ".mode = " << ck.xmode() << " #e (0 - cur, 1 - all_avg) " << "\n";
d->write(l.toUTF8()); d->write(l.toUTF8());
l.clear(); l << ck.index() << ".avg = " << ck.avg() << " #n " << "\n"; l.clear(); l << ck.index() << ".avg = " << ck.avg() << " #n " << "\n";
d->write(l.toUTF8()); d->write(l.toUTF8());
l.clear(); l << ck.index() << ".sel = " << (ck.isSelectedX() ? "1" : "0") << " #n " << "\n"; l.clear(); l << ck.index() << ".sel = " << (ck.isSelectedX() ? "1" : "0") << " #n " << "\n";
d->write(l.toUTF8()); d->write(l.toUTF8());
break; break;
case CDType::cdC: case CDType::cdC:
case CDType::cdM: case CDType::cdM:
l.clear(); l << ck.index() << ".name = " << ck.name() << " #s " << ck.comment() << " \n"; l.clear(); l << ck.index() << ".name = " << ck.name() << " #s " << ck.comment() << " \n";
d->write(l.toUTF8()); d->write(l.toUTF8());
break; break;
} }
} }
if (!s.isEmpty()) { if (!s.isEmpty()) {
if (prefix.isEmpty()) l = "s"; if (prefix.isEmpty()) l = "s";
else l = prefix + ".s"; else l = prefix + ".s";
auto j = s.makeIterator(); auto j = s.makeIterator();
while (j.next()) { while (j.next()) {
j.valueRef().write(d, l + "." + PIString::fromNumber(j.key())); j.valueRef().write(d, l + "." + PIString::fromNumber(j.key()));
} }
} }
if (prefix.isEmpty()) { if (prefix.isEmpty()) {
l = "[]\n"; l = "[]\n";
d->write(l.toUTF8()); d->write(l.toUTF8());
} }
// piCout << "[CDSection] write end"; // piCout << "[CDSection] write end";
} }
void CDSection::read(const void * ep) { void CDSection::read(const void * ep) {
// piCout << "[CDSection] read start"; // piCout << "[CDSection] read start";
PIStringList cdtl; PIStringList cdtl;
cdtl << "null" << "k" << "x" << "c" << "m"; cdtl << "null" << "k" << "x" << "c" << "m";
cd.clear(); cd.clear();
s.clear(); s.clear();
PIConfig::Entry & e(*(PIConfig::Entry*)ep); PIConfig::Entry & e(*(PIConfig::Entry*)ep);
name = e.getValue(cdtl[cd_type_] + ".name").value(); name = e.getValue(cdtl[cd_type_] + ".name").value();
alias = e.getValue(cdtl[cd_type_] + ".alias").value(); alias = e.getValue(cdtl[cd_type_] + ".alias").value();
PIConfig::Entry & cdl = e.getValue(cdtl[cd_type_]); PIConfig::Entry & cdl = e.getValue(cdtl[cd_type_]);
for (int i = 0; i < cdl.childCount(); ++i) { for (int i = 0; i < cdl.childCount(); ++i) {
const PIConfig::Entry * e(cdl.child(i)); const PIConfig::Entry * e(cdl.child(i));
bool ok = false; bool ok = false;
int id = e->name().toInt(-1, &ok); int id = e->name().toInt(-1, &ok);
// piCout << "[read]" << ke->name() << ke->value() << ok; // piCout << "[read]" << ke->name() << ke->value() << ok;
// PIString n = ke->getValue("v").comment(); // PIString n = ke->getValue("v").comment();
// PIString t = n.takeLeft(1); // PIString t = n.takeLeft(1);
if (ok) { if (ok) {
CDType c; CDType c;
PIString ev; PIString ev;
switch (cd_type_) { switch (cd_type_) {
case CDType::cdNull: break; case CDType::cdNull: break;
case CDType::cdK: case CDType::cdK:
c = CDType(id, e->getValue("v").comment(), e->getValue("v").type(), e->getValue("v").value(), e->getValue("f").value(), e->getValue("f").comment(), cd_type_); c = CDType(id, e->getValue("v").comment(), e->getValue("v").type(), e->getValue("v").value(), e->getValue("f").value(), e->getValue("f").comment(), cd_type_);
ev = e->getValue("ev", "").value(); ev = e->getValue("ev", "").value();
if (!ev.isEmpty()) if (!ev.isEmpty())
c.enum_values = c.parseEnumComment(ev); c.enum_values = c.parseEnumComment(ev);
break; break;
case CDType::cdX: case CDType::cdX:
c = CDType(id, e->getValue("name").value(), PIString(), PIString(), PIString() , e->getValue("name").comment(), cd_type_); c = CDType(id, e->getValue("name").value(), PIString(), PIString(), PIString() , e->getValue("name").comment(), cd_type_);
c.setXMode((CDType::XMode)e->getValue("mode", int(CDType::X_Current)).value().toInt()); c.setXMode((CDType::XMode)e->getValue("mode", int(CDType::X_Current)).value().toInt());
c.setAvg((CDType::XMode)e->getValue("avg", 1).value().toInt()); c.setAvg((CDType::XMode)e->getValue("avg", 1).value().toInt());
c.x_enabled = e->getValue("sel", false).value().toBool(); c.x_enabled = e->getValue("sel", false).value().toBool();
break; break;
case CDType::cdC: case CDType::cdC:
case CDType::cdM: case CDType::cdM:
c = CDType(id, e->getValue("name").value(), PIString(), PIString(), PIString() , e->getValue("name").comment(), cd_type_); c = CDType(id, e->getValue("name").value(), PIString(), PIString(), PIString() , e->getValue("name").comment(), cd_type_);
break; break;
} }
cd[id] = c; cd[id] = c;
} }
} }
PIConfig::Entry & sl = e.getValue("s"); PIConfig::Entry & sl = e.getValue("s");
for (int i = 0; i < sl.childCount(); ++i) { for (int i = 0; i < sl.childCount(); ++i) {
const PIConfig::Entry * se(sl.child(i)); const PIConfig::Entry * se(sl.child(i));
int sid = se->name().toInt(); int sid = se->name().toInt();
CDSection & rs(s[sid]); CDSection & rs(s[sid]);
rs.cd_type_ = cd_type_; rs.cd_type_ = cd_type_;
rs.read(se); rs.read(se);
} }
// piCout << "[CDSection] read end"; // piCout << "[CDSection] read end";
} }
void CDSection::update(CDSection & v, UpdateModeFlags mode) { void CDSection::update(CDSection & v, UpdateModeFlags mode) {
if (mode[SaveByIndex] && mode[SaveByName]) { if (mode[SaveByIndex] && mode[SaveByName]) {
piCout << "[CDSection] update error: SaveByIndex | SaveByName mode is denied!"; piCout << "[CDSection] update error: SaveByIndex | SaveByName mode is denied!";
return; return;
} }
//piCout << "[CDSection] update start"; //piCout << "[CDSection] update start";
//piCout << "before" << k.size() << v.k.size(); //piCout << "before" << k.size() << v.k.size();
PIMap<int, PIString> prev_cd_f_bi; PIMap<int, PIString> prev_cd_f_bi;
PIMap<PIString, PIString> prev_cd_f_bn; PIMap<PIString, PIString> prev_cd_f_bn;
PIMap<int, CDType>::iterator i; PIMap<int, CDType>::iterator i;
if (mode[SaveByIndex]) { if (mode[SaveByIndex]) {
for (i = cd.begin(); i != cd.end(); ++i) for (i = cd.begin(); i != cd.end(); ++i)
prev_cd_f_bi[i.key()] = i.value().formula(); prev_cd_f_bi[i.key()] = i.value().formula();
} }
if (mode[SaveByName]) { if (mode[SaveByName]) {
for (i = cd.begin(); i != cd.end(); ++i) for (i = cd.begin(); i != cd.end(); ++i)
prev_cd_f_bn[i.value().name_] = i.value().formula(); prev_cd_f_bn[i.value().name_] = i.value().formula();
} }
if (!mode[Merge]) if (!mode[Merge])
cd.clear(); cd.clear();
for (i = v.cd.begin(); i != v.cd.end(); ++i) { for (i = v.cd.begin(); i != v.cd.end(); ++i) {
int id = i.key(); int id = i.key();
PIString n = i.value().name(); PIString n = i.value().name();
cd[id] = i.value(); cd[id] = i.value();
if (mode[SaveByIndex]) { if (mode[SaveByIndex]) {
if (prev_cd_f_bi.contains(id)) if (prev_cd_f_bi.contains(id))
cd[id].setFormula(prev_cd_f_bi[id]); cd[id].setFormula(prev_cd_f_bi[id]);
} }
if (mode[SaveByName]) { if (mode[SaveByName]) {
if (prev_cd_f_bn.contains(n)) if (prev_cd_f_bn.contains(n))
cd[id].setFormula(prev_cd_f_bn[n]); cd[id].setFormula(prev_cd_f_bn[n]);
} }
} }
PIMap<int, CDSection> prev_s_bi; PIMap<int, CDSection> prev_s_bi;
PIMap<PIString, CDSection> prev_s_bn; PIMap<PIString, CDSection> prev_s_bn;
PIMap<int, CDSection>::iterator j; PIMap<int, CDSection>::iterator j;
if (mode[SaveByIndex]) { if (mode[SaveByIndex]) {
for (j = s.begin(); j != s.end(); ++j) for (j = s.begin(); j != s.end(); ++j)
prev_s_bi[j.key()] = j.value(); prev_s_bi[j.key()] = j.value();
} }
if (mode[SaveByName]) { if (mode[SaveByName]) {
for (j = s.begin(); j != s.end(); ++j) for (j = s.begin(); j != s.end(); ++j)
prev_s_bn[j.value().alias] = j.value(); prev_s_bn[j.value().alias] = j.value();
} }
if (!mode[Merge]) if (!mode[Merge])
s.clear(); s.clear();
for (j = v.s.begin(); j != v.s.end(); ++j) { for (j = v.s.begin(); j != v.s.end(); ++j) {
int id = j.key(); int id = j.key();
PIString n = j.value().alias; PIString n = j.value().alias;
s[id] = j.value(); s[id] = j.value();
if (mode[SaveByIndex]) { if (mode[SaveByIndex]) {
if (prev_s_bi.contains(id)) if (prev_s_bi.contains(id))
s[id] = prev_s_bi[id]; s[id] = prev_s_bi[id];
} }
if (mode[SaveByName]) { if (mode[SaveByName]) {
if (prev_s_bn.contains(n)) if (prev_s_bn.contains(n))
s[id] = prev_s_bn[n]; s[id] = prev_s_bn[n];
} }
s[id].update(j.value(), mode); s[id].update(j.value(), mode);
} }
/*PISet<int> used; /*PISet<int> used;
for (i = k.begin(); i != k.end(); ++i) { for (i = k.begin(); i != k.end(); ++i) {
if (v.k.contains(i.key())) { if (v.k.contains(i.key())) {
PIString f = k[i.key()].formula_; PIString f = k[i.key()].formula_;
CDType & cdt = v.k[i.key()]; CDType & cdt = v.k[i.key()];
cdt.formula_ = f; cdt.formula_ = f;
k[i.key()] = cdt; k[i.key()] = cdt;
used << i.key(); used << i.key();
} }
if (mode) { if (mode) {
CDType & ck(k[i.key()]); CDType & ck(k[i.key()]);
if (prev_k_f_bn.contains(ck.name_)) if (prev_k_f_bn.contains(ck.name_))
ck.setFormula(prev_k_f_bn[ck.name_]); ck.setFormula(prev_k_f_bn[ck.name_]);
} }
} }
//piCout << " after" << k.size(); //piCout << " after" << k.size();
for (i = v.k.begin(); i != v.k.end(); ++i) { for (i = v.k.begin(); i != v.k.end(); ++i) {
if (!used.contains(i.key())) if (!used.contains(i.key()))
k[i.key()] = i.value(); k[i.key()] = i.value();
CDType & ck(k[i.key()]); CDType & ck(k[i.key()]);
ck.setFormula(prev_k_f_bn.value(ck.name_)); ck.setFormula(prev_k_f_bn.value(ck.name_));
} }
used.clear(); used.clear();
PIMap<int, CDSection>::iterator j; PIMap<int, CDSection>::iterator j;
for (j = s.begin(); j != s.end(); ++j) { for (j = s.begin(); j != s.end(); ++j) {
if (v.s.contains(j.key())) if (v.s.contains(j.key()))
j.value().update(v.s[j.key()], mode); j.value().update(v.s[j.key()], mode);
used << j.key(); used << j.key();
} }
for (j = v.s.begin(); j != v.s.end(); ++j) { for (j = v.s.begin(); j != v.s.end(); ++j) {
if (!used.contains(j.key())) if (!used.contains(j.key()))
s[j.key()] = j.value(); s[j.key()] = j.value();
}*/ }*/
// piCout << "[CDSection] update end"; // piCout << "[CDSection] update end";
} }
bool CDSection::isSameStructure(CDSection & v) { bool CDSection::isSameStructure(CDSection & v) {
PIMap<PIString, int> cd_ids; PIMap<PIString, int> cd_ids;
PIMap<int, CDType>::iterator i; PIMap<int, CDType>::iterator i;
for (i = cd.begin(); i != cd.end(); ++i) for (i = cd.begin(); i != cd.end(); ++i)
cd_ids[i.value().name()] = i.key(); cd_ids[i.value().name()] = i.key();
for (i = v.cd.begin(); i != v.cd.end(); ++i) { for (i = v.cd.begin(); i != v.cd.end(); ++i) {
if (!cd_ids.contains(i.value().name())) continue; if (!cd_ids.contains(i.value().name())) continue;
//piCout << i.key() << k[i.key()].name() << i.value().name(); //piCout << i.key() << k[i.key()].name() << i.value().name();
if (cd[cd_ids[i.value().name()]].index() != i.key()) if (cd[cd_ids[i.value().name()]].index() != i.key())
return false; return false;
} }
PIMap<int, CDSection>::iterator j; PIMap<int, CDSection>::iterator j;
for (j = v.s.begin(); j != v.s.end(); ++j) { for (j = v.s.begin(); j != v.s.end(); ++j) {
if (!s.contains(j.key())) continue; if (!s.contains(j.key())) continue;
if (!s[j.key()].isSameStructure(j.value())) if (!s[j.key()].isSameStructure(j.value()))
return false; return false;
} }
return true; return true;
} }
void CDSection::prepareCalculate() { void CDSection::prepareCalculate() {
PIMap<int, CDType>::iterator i; PIMap<int, CDType>::iterator i;
for (i = cd.begin(); i != cd.end(); ++i) { for (i = cd.begin(); i != cd.end(); ++i) {
i.value().parent = this; i.value().parent = this;
i.value().calculated = false; i.value().calculated = false;
} }
PIMap<int, CDSection>::iterator j; PIMap<int, CDSection>::iterator j;
for (j = s.begin(); j != s.end(); ++j) for (j = s.begin(); j != s.end(); ++j)
j.value().prepareCalculate(); j.value().prepareCalculate();
} }
void CDSection::calculateRecursive(PIEvaluator * e) { void CDSection::calculateRecursive(PIEvaluator * e) {
PIMap<int, CDType>::iterator i; PIMap<int, CDType>::iterator i;
for (i = cd.begin(); i != cd.end(); ++i) for (i = cd.begin(); i != cd.end(); ++i)
i.value().calculate(e); i.value().calculate(e);
PIMap<int, CDSection>::iterator j; PIMap<int, CDSection>::iterator j;
for (j = s.begin(); j != s.end(); ++j) for (j = s.begin(); j != s.end(); ++j)
j.value().calculateRecursive(e); j.value().calculateRecursive(e);
} }
void CDSection::setSelectedX(bool yes) { void CDSection::setSelectedX(bool yes) {
PIMap<int, CDType>::iterator i; PIMap<int, CDType>::iterator i;
for (i = cd.begin(); i != cd.end(); ++i) for (i = cd.begin(); i != cd.end(); ++i)
i.value().x_enabled = yes; i.value().x_enabled = yes;
PIMap<int, CDSection>::iterator j; PIMap<int, CDSection>::iterator j;
for (j = s.begin(); j != s.end(); ++j) for (j = s.begin(); j != s.end(); ++j)
j.value().setSelectedX(yes); j.value().setSelectedX(yes);
} }
PIVector<PIDeque<int> > CDSection::collectX() const { PIVector<PIDeque<int> > CDSection::collectX() const {
PIVector<PIDeque<int> > ret; PIVector<PIDeque<int> > ret;
PIMap<int, CDType>::const_iterator i; PIMap<int, CDType>::const_iterator i;
for (i = cd.begin(); i != cd.end(); ++i) { for (i = cd.begin(); i != cd.end(); ++i) {
if (i.value().x_enabled) if (i.value().x_enabled)
ret << i.value().path(); ret << i.value().path();
} }
PIMap<int, CDSection>::const_iterator j; PIMap<int, CDSection>::const_iterator j;
for (j = s.constBegin(); j != s.constEnd(); ++j) for (j = s.constBegin(); j != s.constEnd(); ++j)
ret << j.value().collectX(); ret << j.value().collectX();
return ret; return ret;
} }
void CDSection::makePath(PIDeque<int> p) { void CDSection::makePath(PIDeque<int> p) {
PIDeque<int> tp; PIDeque<int> tp;
PIMap<int, CDType>::iterator i; PIMap<int, CDType>::iterator i;
for (i = cd.begin(); i != cd.end(); ++i) { for (i = cd.begin(); i != cd.end(); ++i) {
tp = p; tp = p;
tp << i.key(); tp << i.key();
i.value().path_ = tp; i.value().path_ = tp;
//piCout << "path for" << i.value().name() << tp; //piCout << "path for" << i.value().name() << tp;
} }
PIMap<int, CDSection>::iterator j; PIMap<int, CDSection>::iterator j;
for (j = s.begin(); j != s.end(); ++j) { for (j = s.begin(); j != s.end(); ++j) {
tp = p; tp = p;
tp << j.key(); tp << j.key();
j.value().makePath(tp); j.value().makePath(tp);
} }
} }
PIVector<CDType * > CDSection::children(bool recursive) const { PIVector<CDType * > CDSection::children(bool recursive) const {
PIVector<CDType * > ret; PIVector<CDType * > ret;
PIMap<int, CDType>::const_iterator i; PIMap<int, CDType>::const_iterator i;
for (i = cd.begin(); i != cd.end(); ++i) for (i = cd.begin(); i != cd.end(); ++i)
ret << const_cast<CDType * >(&(i.value())); ret << const_cast<CDType * >(&(i.value()));
if (!recursive) return ret; if (!recursive) return ret;
PIMap<int, CDSection>::const_iterator j; PIMap<int, CDSection>::const_iterator j;
for (j = s.constBegin(); j != s.constEnd(); ++j) for (j = s.constBegin(); j != s.constEnd(); ++j)
ret << j.value().children(true); ret << j.value().children(true);
return ret; return ret;
} }
PIVariantTypes::Enum CDSection::enumValues() const { PIVariantTypes::Enum CDSection::enumValues() const {
PIVariantTypes::Enum ret; PIVariantTypes::Enum ret;
PIMap<int, CDType>::const_iterator i; PIMap<int, CDType>::const_iterator i;
for (i = cd.constBegin(); i != cd.constEnd(); ++i) for (i = cd.constBegin(); i != cd.constEnd(); ++i)
ret << PIVariantTypes::Enumerator(i.key(), i.value().name()); ret << PIVariantTypes::Enumerator(i.key(), i.value().name());
return ret; return ret;
} }

View File

@@ -1,192 +1,193 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_TYPES_H #ifndef CDUTILS_TYPES_H
#define CDUTILS_TYPES_H #define CDUTILS_TYPES_H
#include "pistring.h" #include "pistring.h"
#include "pimap.h" #include "pimap.h"
#include "pivariant.h" #include "pivariant.h"
#include "cd_utils_export.h"
class PIIODevice;
class PIEvaluator; class PIIODevice;
class CD_Pult; class PIEvaluator;
class CDItem; class CD_Pult;
class CDItemModel; class CDItem;
class CDItemModel;
namespace CDUtils {
namespace CDUtils {
class CDSection;
class CDSection;
enum UpdateMode {
SaveByIndex = 0x01, enum UpdateMode {
SaveByName = 0x02, SaveByIndex = 0x01,
Merge = 0x04 SaveByName = 0x02,
}; Merge = 0x04
};
enum MessageType {
Log = 1, enum MessageType {
MessageBox, Log = 1,
}; MessageBox,
};
typedef PIFlags<UpdateMode> UpdateModeFlags;
typedef PIFlags<UpdateMode> UpdateModeFlags;
class CDType {
friend class CDSection; class CD_UTILS_EXPORT CDType {
friend class CDCore; friend class CDSection;
friend class Interface; friend class CDCore;
friend class XInterface; friend class Interface;
public: friend class XInterface;
enum cdT {cdNull, cdK, cdX, cdC, cdM}; public:
enum XMode {X_Current, X_All_Avg}; enum cdT {cdNull, cdK, cdX, cdC, cdM};
enum XMode {X_Current, X_All_Avg};
CDType();
CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t); CDType();
CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t);
CDType & operator =(double x);
int index() const {return index_;} CDType & operator =(double x);
PIString name() const {return name_;} int index() const {return index_;}
PIString type() const; PIString name() const {return name_;}
PIString value() const; PIString type() const;
PIVariant variantValue() const; PIString value() const;
PIString formula() const {return formula_;} PIVariant variantValue() const;
PIString comment() const {return comment_;} PIString formula() const {return formula_;}
double toDouble() const {return value_d;} PIString comment() const {return comment_;}
int toInt() const {return value_i;} double toDouble() const {return value_d;}
bool toBool() const {return value_b;} int toInt() const {return value_i;}
cdT cd_type() const {return cd_type_;} bool toBool() const {return value_b;}
void setValue(const PIString & value_); cdT cd_type() const {return cd_type_;}
void setVariantValue(const PIVariant & value_); void setValue(const PIString & value_);
void setFormula(const PIString & formula); void setVariantValue(const PIVariant & value_);
void setComment(const PIString & comment) {comment_ = comment;} void setFormula(const PIString & formula);
operator double() const {return value_d;} void setComment(const PIString & comment) {comment_ = comment;}
const PIVariantTypes::Enum & enumValues() const {return enum_values;} operator double() const {return value_d;}
void setEnumValues(const PIVariantTypes::Enum & ev) {enum_values = ev;} const PIVariantTypes::Enum & enumValues() const {return enum_values;}
const PIString & errorString() const {return error_;} void setEnumValues(const PIVariantTypes::Enum & ev) {enum_values = ev;}
PIDeque<int> path() const {return path_;} const PIString & errorString() const {return error_;}
PIStringList pathString() const; PIDeque<int> path() const {return path_;}
PIStringList pathString() const;
void setXMode(XMode mode) {mode_ = mode;}
void setAvg(int avg) {avg_size = avg;} void setXMode(XMode mode) {mode_ = mode;}
XMode xmode() const {return mode_;} void setAvg(int avg) {avg_size = avg;}
XMode xmode_rec() const {return rmode_;} XMode xmode() const {return mode_;}
int avg() const {return avg_size;} XMode xmode_rec() const {return rmode_;}
bool isSelectedX() const {return x_enabled;} int avg() const {return avg_size;}
void readX(PIByteArray & ba); bool isSelectedX() const {return x_enabled;}
void writeX(PIByteArray & ba); void readX(PIByteArray & ba);
void writeX(PIByteArray & ba);
PIVector<double> history;
PIVector<double> history;
protected:
bool calculate(PIEvaluator * e, PIVector<const CDType * > stack = PIVector<const CDType * >()); protected:
PIVariantTypes::Enum parseEnumComment(PIString c); bool calculate(PIEvaluator * e, PIVector<const CDType * > stack = PIVector<const CDType * >());
cdT cd_type_; PIVariantTypes::Enum parseEnumComment(PIString c);
int index_; cdT cd_type_;
PIString name_, type_; int index_;
PIString value_s, formula_, comment_, error_; PIString name_, type_;
PIVariantTypes::Enum enum_values; PIString value_s, formula_, comment_, error_;
CDSection * parent; PIVariantTypes::Enum enum_values;
PIDeque<int> path_; CDSection * parent;
double value_d; PIDeque<int> path_;
int value_i; double value_d;
bool value_b, calculated, x_enabled; int value_i;
PIVector<double> avg_h; bool value_b, calculated, x_enabled;
int avg_size; PIVector<double> avg_h;
XMode mode_, rmode_; int avg_size;
}; XMode mode_, rmode_;
};
class CDSection {
friend class CDCore; class CD_UTILS_EXPORT CDSection {
friend class Interface; friend class CDCore;
friend class XInterface; friend class Interface;
friend class ::CD_Pult; friend class XInterface;
friend class ::CDItem; friend class ::CD_Pult;
friend class ::CDItemModel; friend class ::CDItem;
public: friend class ::CDItemModel;
public:
CDSection(CDType::cdT type_ = CDType::cdNull);
CDSection(CDType::cdT type_ = CDType::cdNull);
bool test(int v) {return cd.value(v).toBool();}
// CDType & operator [](int v) {if (!k.contains(v)) k[v].index_ = v; return k[v];} bool test(int v) {return cd.value(v).toBool();}
CDType & operator [](int v) {return cd[v];} // CDType & operator [](int v) {if (!k.contains(v)) k[v].index_ = v; return k[v];}
const CDType operator [](int v) const {return cd[v];} CDType & operator [](int v) {return cd[v];}
CDType & operator [](const PIString & name_) {return getByName(name_);} const CDType operator [](int v) const {return cd[v];}
const CDType operator [](const PIString & name_) const {return const_cast<CDSection*>(this)->getByName(name_);} CDType & operator [](const PIString & name_) {return getByName(name_);}
CDType & operator [](const PIDeque<int> & path_) {return getByPath(path_);} const CDType operator [](const PIString & name_) const {return const_cast<CDSection*>(this)->getByName(name_);}
const CDType operator [](const PIDeque<int> & path_) const {return const_cast<CDSection*>(this)->getByPath(path_);} CDType & operator [](const PIDeque<int> & path_) {return getByPath(path_);}
CDSection & section(int v); const CDType operator [](const PIDeque<int> & path_) const {return const_cast<CDSection*>(this)->getByPath(path_);}
const CDSection section(int v) const; CDSection & section(int v);
const CDSection section(int v) const;
bool isEmpty() const {return cd.isEmpty() && s.isEmpty();}
bool exists(PIDeque<int> path) const; bool isEmpty() const {return cd.isEmpty() && s.isEmpty();}
int count(bool recursive = true) const; bool exists(PIDeque<int> path) const;
int sectionsCount() const; int count(bool recursive = true) const;
PIVector<int> indexes() const {return cd.keys();} int sectionsCount() const;
PIStringList index_names() const; PIVector<int> indexes() const {return cd.keys();}
void calculate(); PIStringList index_names() const;
void makePath(PIDeque<int> p = PIDeque<int>()); void calculate();
PIVector<CDType * > children(bool recursive = true) const; void makePath(PIDeque<int> p = PIDeque<int>());
PIVariantTypes::Enum enumValues() const; PIVector<CDType * > children(bool recursive = true) const;
PIVariantTypes::Enum enumValues() const;
PIString name;
PIString alias; PIString name;
PIString alias;
protected:
CDSection(PIMap<int, CDType> k_, PIMap<int, CDSection> s_) { protected:
cd = k_; CDSection(PIMap<int, CDType> k_, PIMap<int, CDSection> s_) {
s = s_; cd = k_;
} s = s_;
CDType & getByName(const PIString & name_); }
CDType & getByPath(const PIDeque<int> & path_); CDType & getByName(const PIString & name_);
void write(PIIODevice * d, const PIString & prefix = PIString()); CDType & getByPath(const PIDeque<int> & path_);
void read(const void * ep); void write(PIIODevice * d, const PIString & prefix = PIString());
void update(CDSection & v, UpdateModeFlags mode = SaveByName); void read(const void * ep);
bool isSameStructure(CDSection & v); void update(CDSection & v, UpdateModeFlags mode = SaveByName);
void prepareCalculate(); bool isSameStructure(CDSection & v);
void calculateRecursive(PIEvaluator * e); void prepareCalculate();
void setSelectedX(bool yes); void calculateRecursive(PIEvaluator * e);
PIVector<PIDeque<int> > collectX() const; void setSelectedX(bool yes);
PIVector<PIDeque<int> > collectX() const;
PIMap<int, CDType> cd;
mutable PIMap<int, CDSection> s; PIMap<int, CDType> cd;
CDType null; mutable PIMap<int, CDSection> s;
CDType::cdT cd_type_; CDType null;
}; CDType::cdT cd_type_;
};
}
}
inline PICout operator <<(PICout s, const CDUtils::CDType & v) {
s.space(); inline PICout operator <<(PICout s, const CDUtils::CDType & v) {
s.setControl(0, true); s.space();
switch (v.cd_type()) { s.setControl(0, true);
case CDUtils::CDType::cdK : s << "K["; break; switch (v.cd_type()) {
case CDUtils::CDType::cdX : s << "X["; break; case CDUtils::CDType::cdK : s << "K["; break;
case CDUtils::CDType::cdC : s << "C["; break; case CDUtils::CDType::cdX : s << "X["; break;
case CDUtils::CDType::cdM : s << "M["; break; case CDUtils::CDType::cdC : s << "C["; break;
default : s << "Null["; break; case CDUtils::CDType::cdM : s << "M["; break;
} default : s << "Null["; break;
s << v.name() << "(" << v.index() << ")] = " << v.value(); }
s.restoreControl(); s << v.name() << "(" << v.index() << ")] = " << v.value();
return s; s.restoreControl();
} return s;
}
#endif // CDUTILS_TYPES_H
#endif // CDUTILS_TYPES_H

View File

@@ -1,55 +1,55 @@
#include "cdutils_x.h" #include "cdutils_x.h"
#include "cdutils_core.h" #include "cdutils_core.h"
using namespace CDUtils; using namespace CDUtils;
XInterface X; XInterface X;
XInterface::XInterface(): Interface(CDType::cdX) { XInterface::XInterface(): Interface(CDType::cdX) {
CONNECTU(core, X_ReceivedX, this, receivedX); CONNECTU(core, X_ReceivedX, this, receivedX);
} }
void XInterface::setEnabled(const CDType & x, bool en) { void XInterface::setEnabled(const CDType & x, bool en) {
core->x_mutex.lock(); core->x_mutex.lock();
CDType & t((*s)[x.path()]); CDType & t((*s)[x.path()]);
if (t.cd_type() != CDType::cdX) { if (t.cd_type() != CDType::cdX) {
core->x_mutex.unlock(); core->x_mutex.unlock();
return; return;
} }
t.x_enabled = en; t.x_enabled = en;
//piCout << t << "x_enabled" << en; //piCout << t << "x_enabled" << en;
core->need_rebuild_x = true; core->need_rebuild_x = true;
core->x_mutex.unlock(); core->x_mutex.unlock();
} }
PIVector<PIDeque<int> > XInterface::enabledList() const { PIVector<PIDeque<int> > XInterface::enabledList() const {
return CDCore::instance()->x_selected; return CDCore::instance()->x_selected;
} }
void XInterface::setEnabledList(const PIVector<PIDeque<int> > & l) { void XInterface::setEnabledList(const PIVector<PIDeque<int> > & l) {
CDCore::instance()->x_selected = l; CDCore::instance()->x_selected = l;
} }
void XInterface::lock() { void XInterface::lock() {
CDCore::instance()->x_mutex.lock(); CDCore::instance()->x_mutex.lock();
} }
void XInterface::unlock() { void XInterface::unlock() {
CDCore::instance()->x_mutex.unlock(); CDCore::instance()->x_mutex.unlock();
} }
void XInterface::start(double freq) { void XInterface::start(double freq) {
core->startX(freq); core->startX(freq);
} }
void XInterface::stop() { void XInterface::stop() {
core->stopX(); core->stopX();
} }

View File

@@ -1,56 +1,57 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_X_H #ifndef CDUTILS_X_H
#define CDUTILS_X_H #define CDUTILS_X_H
#include "cdutils_interface.h" #include "cdutils_interface.h"
#include "cd_utils_export.h"
namespace CDUtils {
namespace CDUtils {
class XInterface: public Interface
{ class CD_UTILS_EXPORT XInterface: public Interface
PIOBJECT_SUBCLASS(XInterface, Interface) {
public: PIOBJECT_SUBCLASS(XInterface, Interface)
XInterface(); public:
XInterface();
EVENT1(keepNamesRequest, bool*, xn)
EVENT1(receivedX, PIVector<PIDeque<int> >, pathes) EVENT1(keepNamesRequest, bool*, xn)
EVENT1(receivedX, PIVector<PIDeque<int> >, pathes)
void enable(const CDType & x) {setEnabled(x, true);}
void disable(const CDType & x) {setEnabled(x, false);} void enable(const CDType & x) {setEnabled(x, true);}
void setEnabled(const CDType & x, bool en); void disable(const CDType & x) {setEnabled(x, false);}
void setDisabled(const CDType & x, bool dis) {setEnabled(x, !dis);} void setEnabled(const CDType & x, bool en);
PIVector<PIDeque<int> > enabledList() const; void setDisabled(const CDType & x, bool dis) {setEnabled(x, !dis);}
void setEnabledList(const PIVector<PIDeque<int> > & l); PIVector<PIDeque<int> > enabledList() const;
void lock(); void setEnabledList(const PIVector<PIDeque<int> > & l);
void unlock(); void lock();
void unlock();
void start(double freq = 20.);
void stop(); void start(double freq = 20.);
void stop();
};
};
}
}
extern CDUtils::XInterface X;
extern CD_UTILS_EXPORT CDUtils::XInterface X;
#endif // CDUTILS_X_H
#endif // CDUTILS_X_H

View File

@@ -1,97 +1,97 @@
#include "cdutils_k.h" #include "cdutils_k.h"
#include "cdutils_x.h" #include "cdutils_x.h"
#include "cdutils_c.h" #include "cdutils_c.h"
#include "cdutils_m.h" #include "cdutils_m.h"
#include "cdutils_core.h" #include "cdutils_core.h"
#include "cdtest.h" #include "cdtest.h"
#include "pip.h" #include "pip.h"
#include "k_description.h" #include "k_description.h"
using namespace CDUtils; using namespace CDUtils;
class Core : public PIObject class Core : public PIObject
{ {
PIOBJECT(Core) PIOBJECT(Core)
public: public:
Core() { Core() {
CDCore::instance()->initApp(); CDCore::instance()->initApp();
// piCout << "testCore"; // piCout << "testCore";
CONNECTU(&timer, tickEvent, this, timerDone); CONNECTU(&timer, tickEvent, this, timerDone);
CONNECTU(&X, received, this, xrecv); CONNECTU(&X, received, this, xrecv);
CONNECTU(&C, received, this, crecv); CONNECTU(&C, received, this, crecv);
t = 0.; t = 0.;
} }
void load() { void load() {
rf.open("k.dat", PIIODevice::ReadWrite); rf.open("k.dat", PIIODevice::ReadWrite);
K.read(&rf); K.read(&rf);
rf.close(); rf.close();
} }
void save() { void save() {
rf.open("k_out.txt", PIIODevice::ReadWrite); rf.open("k_out.txt", PIIODevice::ReadWrite);
rf.resize(0); rf.resize(0);
K.write(&rf); K.write(&rf);
rf.close(); rf.close();
// rf.open("k_out.txt", PIIODevice::ReadWrite); // rf.open("k_out.txt", PIIODevice::ReadWrite);
// K.read(&rf); // K.read(&rf);
// rf.close(); // rf.close();
// rf.open("k_out2.txt", PIIODevice::ReadWrite); // rf.open("k_out2.txt", PIIODevice::ReadWrite);
// rf.resize(0); // rf.resize(0);
// K.write(&rf); // K.write(&rf);
// rf.close(); // rf.close();
// rf.open("k_out2.txt", PIIODevice::ReadWrite); // rf.open("k_out2.txt", PIIODevice::ReadWrite);
// K.read(&rf); // K.read(&rf);
// rf.close(); // rf.close();
// rf.open("k_out3.txt", PIIODevice::ReadWrite); // rf.open("k_out3.txt", PIIODevice::ReadWrite);
// rf.resize(0); // rf.resize(0);
// K.write(&rf); // K.write(&rf);
// rf.close(); // rf.close();
} }
void test() { void test() {
X.lock(); X.lock();
X[KD::Frequency] = 100; X[KD::Frequency] = 100;
X.section(KD::Spectrometer)[KD::Temperature_default] = sin(t); X.section(KD::Spectrometer)[KD::Temperature_default] = sin(t);
t += 0.01; t += 0.01;
X.unlock(); X.unlock();
/*piCout << "count" << K.count(); /*piCout << "count" << K.count();
piCout << K[First]; piCout << K[First];
piCout << K[Second];*/ piCout << K[Second];*/
} }
EVENT_HANDLER(void, ksend) {piCout << "sended k";} EVENT_HANDLER(void, ksend) {piCout << "sended k";}
EVENT_HANDLER(void, crecv) { EVENT_HANDLER(void, crecv) {
piCout << "received c"; piCout << "received c";
C.connect(C.section(KD::Logs).section(KD::Spec).section(KD::Formats)[KD::Binary], this, HANDLER(cmd)); C.connect(C.section(KD::Logs).section(KD::Spec).section(KD::Formats)[KD::Binary], this, HANDLER(cmd));
C.autoConnect(this); C.autoConnect(this);
} }
EVENT_HANDLER(void, xrecv) { EVENT_HANDLER(void, xrecv) {
piCout << "received x"; piCout << "received x";
if (!timer.isRunning()) timer.start(10); if (!timer.isRunning()) timer.start(10);
X.start(); X.start();
} }
EVENT_HANDLER(void, timerDone) {test();} EVENT_HANDLER(void, timerDone) {test();}
EVENT_HANDLER(void, cmd) {piCout << "command cmd";} EVENT_HANDLER(void, cmd) {piCout << "command cmd";}
EVENT_HANDLER(void, c_Pause) { EVENT_HANDLER(void, c_Pause) {
piCout << "command pause"; piCout << "command pause";
M[KD::Main] << "rec command" << C[KD::Pause]; M[KD::Main] << "rec command" << C[KD::Pause];
M.messageBox(M.root()[KD::Core], "init successfull"); M.messageBox(M.root()[KD::Core], "init successfull");
} }
EVENT_HANDLER(void, c_Spectrometer_Connection) {piCout << "command spec_conn";} EVENT_HANDLER(void, c_Spectrometer_Connection) {piCout << "command spec_conn";}
private: private:
PIFile rf; PIFile rf;
PITimer timer; PITimer timer;
double t; double t;
}; };
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
X.start(); X.start();
piSleep(1); piSleep(1);
//CDCore::instance()->destroy(); //CDCore::instance()->destroy();
piCout << "DELETED"; piCout << "DELETED";
return 0; return 0;
} }

0
cmake_android.sh Executable file → Normal file
View File

View File

@@ -1,76 +1,76 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(kx_utils) project(kx_utils)
if (POLICY CMP0017) if (POLICY CMP0017)
cmake_policy(SET CMP0017 NEW) cmake_policy(SET CMP0017 NEW)
endif() endif()
if (NOT LIBPROJECT) if (NOT LIBPROJECT)
find_package(PIP REQUIRED) find_package(PIP REQUIRED)
endif () endif ()
if (MINGW) if (MINGW)
find_package(MinGW REQUIRED) find_package(MinGW REQUIRED)
endif() endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES}) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES})
set(KX_PULT_NAME "kx_pult") set(KX_PULT_NAME "kx_pult")
option(KX_PULT "Build ${KX_PULT_NAME}" 1) option(KX_PULT "Build ${KX_PULT_NAME}" 1)
option(LIB "System install" 1) option(LIB "System install" 1)
option(DEBUG "Build with -g3" 0) option(DEBUG "Build with -g3" 0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall")
if (DEBUG) if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
endif() endif()
set(CPPS_UTILS "kx_coeffs.cpp" "piprotocol.cpp") set(CPPS_UTILS "kx_coeffs.cpp" "piprotocol.cpp")
set(HDRS_UTILS "kx_coeffs.h" "kx_protocol_x.h" "kx_protocol_c.h" "piprotocol.h") set(HDRS_UTILS "kx_coeffs.h" "kx_protocol_x.h" "kx_protocol_c.h" "piprotocol.h")
if (DEFINED ENV{QNX_HOST}) if (DEFINED ENV{QNX_HOST})
add_library(${PROJECT_NAME} STATIC ${CPPS_UTILS}) add_library(${PROJECT_NAME} STATIC ${CPPS_UTILS})
else() else()
add_library(${PROJECT_NAME} SHARED ${CPPS_UTILS}) add_library(${PROJECT_NAME} SHARED ${CPPS_UTILS})
endif() endif()
target_link_libraries(${PROJECT_NAME} ${PIP_LIBRARY}) target_link_libraries(${PROJECT_NAME} ${PIP_LIBRARY})
message(STATUS "Building ${PROJECT_NAME}") message(STATUS "Building ${PROJECT_NAME}")
if (NOT DEFINED ENV{QNX_HOST}) if (NOT DEFINED ENV{QNX_HOST})
if (KX_PULT) if (KX_PULT)
find_package(Qt4 REQUIRED) find_package(Qt4 REQUIRED)
find_package(QAD REQUIRED) find_package(QAD REQUIRED)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
include_directories(${QT_INCLUDES} ${QAD_INCLUDES}) include_directories(${QT_INCLUDES} ${QAD_INCLUDES})
set(CPPS "kx_pult.cpp" "kx_pult.h" "kx_pult.ui" "main_kx_pult.cpp") set(CPPS "kx_pult.cpp" "kx_pult.h" "kx_pult.ui" "main_kx_pult.cpp")
set(MOCS "kx_pult.h") set(MOCS "kx_pult.h")
file(GLOB UIS "*.ui") file(GLOB UIS "*.ui")
file(GLOB RES "*.qrc") file(GLOB RES "*.qrc")
qt4_wrap_cpp(CMOCS ${MOCS} OPTIONS -nw) qt4_wrap_cpp(CMOCS ${MOCS} OPTIONS -nw)
qt4_wrap_ui(CUIS ${UIS}) qt4_wrap_ui(CUIS ${UIS})
qt4_add_resources(RESS ${RES}) qt4_add_resources(RESS ${RES})
add_executable(${KX_PULT_NAME} WIN32 ${CPPS} ${CMOCS} ${CUIS} ${RESS} ${MOCS}) add_executable(${KX_PULT_NAME} WIN32 ${CPPS} ${CMOCS} ${CUIS} ${RESS} ${MOCS})
set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${OPENGL_LIBRARIES} ${PIP_LIBRARY} qad_graphic4 qad_utils4 qad_widgets4) set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${OPENGL_LIBRARIES} ${PIP_LIBRARY} qad_graphic4 qad_utils4 qad_widgets4)
target_link_libraries(${KX_PULT_NAME} ${LIBS} ${PROJECT_NAME}) target_link_libraries(${KX_PULT_NAME} ${LIBS} ${PROJECT_NAME})
endif() endif()
endif() endif()
if (LIB) if (LIB)
list(APPEND _ALL_TARGETS ${PROJECT_NAME}) list(APPEND _ALL_TARGETS ${PROJECT_NAME})
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE) set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
if (WIN32) if (WIN32)
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR}) set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
install(FILES ${HDRS_UTILS} DESTINATION ${MINGW_INCLUDE}) install(FILES ${HDRS_UTILS} DESTINATION ${MINGW_INCLUDE})
install(TARGETS ${PROJECT_NAME} DESTINATION ${MINGW_LIB}) install(TARGETS ${PROJECT_NAME} DESTINATION ${MINGW_LIB})
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${MINGW_BIN}) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${MINGW_BIN})
else() else()
if (DEFINED ANDROID_PLATFORM) if (DEFINED ANDROID_PLATFORM)
set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr) set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr)
else() else()
set(CMAKE_INSTALL_PREFIX /usr/local) set(CMAKE_INSTALL_PREFIX /usr/local)
endif() endif()
install(FILES ${HDRS_UTILS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) install(FILES ${HDRS_UTILS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif() endif()
message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"") message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
else() else()
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
install(TARGETS ${PROJECT_NAME} DESTINATION lib) install(TARGETS ${PROJECT_NAME} DESTINATION lib)
install(FILES ${HDRS_UTILS} DESTINATION include) install(FILES ${HDRS_UTILS} DESTINATION include)
message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"") message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"")
endif() endif()
if (NOT DEFINED ENV{QNX_HOST}) if (NOT DEFINED ENV{QNX_HOST})
if (KX_PULT) if (KX_PULT)
install(TARGETS ${KX_PULT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) install(TARGETS ${KX_PULT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
endif() endif()
endif() endif()

View File

@@ -1,848 +1,848 @@
#include <QScrollBar> #include <QScrollBar>
#include <QMessageBox> #include <QMessageBox>
#include <math.h> #include <math.h>
#include "kx_pult.h" #include "kx_pult.h"
#include "ui_kx_pult.h" #include "ui_kx_pult.h"
#include "piqt.h" #include "piqt.h"
#include "qpiconfig.h" #include "qpiconfig.h"
bool isNormalDouble(const double & v) { bool isNormalDouble(const double & v) {
#ifdef WINDOWS #ifdef WINDOWS
return true; return true;
#else #else
return !isnan(v) && !isinf(v); return !isnan(v) && !isinf(v);
#endif #endif
} }
XCheck::XCheck(int index): QWidget() { XCheck::XCheck(int index): QWidget() {
index_ = index; index_ = index;
setProperty("index", index); setProperty("index", index);
setMouseTracking(true); setMouseTracking(true);
check.setText(QString::number(index + 1) + " "); check.setText(QString::number(index + 1) + " ");
check.setAutoFillBackground(true); check.setAutoFillBackground(true);
spin.setMaximum(KX_X_COUNT - 1); spin.setMaximum(KX_X_COUNT - 1);
QBoxLayout * l = new QBoxLayout(QBoxLayout::LeftToRight); QBoxLayout * l = new QBoxLayout(QBoxLayout::LeftToRight);
l->setMargin(0); l->setMargin(0);
l->setSpacing(2); l->setSpacing(2);
l->addWidget(&check); l->addWidget(&check);
l->addWidget(&spin); l->addWidget(&spin);
setLayout(l); setLayout(l);
//check.installEventFilter(this); //check.installEventFilter(this);
//spin.installEventFilter(this); //spin.installEventFilter(this);
connect(&spin, SIGNAL(valueChanged(int)), this, SLOT(spinChanged(int))); connect(&spin, SIGNAL(valueChanged(int)), this, SLOT(spinChanged(int)));
connect(&check, SIGNAL(toggled(bool)), this, SLOT(checkChanged_(bool))); connect(&check, SIGNAL(toggled(bool)), this, SLOT(checkChanged_(bool)));
} }
bool XCheck::eventFilter(QObject * o, QEvent * e) { bool XCheck::eventFilter(QObject * o, QEvent * e) {
if (e->type() == QEvent::Enter) if (e->type() == QEvent::Enter)
qApp->postEvent(this, new QEvent(e->type())); qApp->postEvent(this, new QEvent(e->type()));
return QWidget::eventFilter(o, e); return QWidget::eventFilter(o, e);
} }
KX_Pult::KX_Pult(): QMainWindow(), config_("kx_pult.conf"), name_x("x"), name_c("c"), KX_Pult::KX_Pult(): QMainWindow(), config_("kx_pult.conf"), name_x("x"), name_c("c"),
config(piqt(config_), QIODevice::ReadWrite), coeffs(config_, "k", true) { config(piqt(config_), QIODevice::ReadWrite), coeffs(config_, "k", true) {
//cout << sizeof(coeffsK.k_protocol->to_k) << endl; //cout << sizeof(coeffsK.k_protocol->to_k) << endl;
ui = new Ui::KX_Pult(); ui = new Ui::KX_Pult();
ui->setupUi(this); ui->setupUi(this);
ui->configWidget->setQPIConfig(&config); ui->configWidget->setQPIConfig(&config);
ui->configWidget->expandAll(); ui->configWidget->expandAll();
ui->list->viewport()->installEventFilter(this); ui->list->viewport()->installEventFilter(this);
ui->treeK->viewport()->installEventFilter(this); ui->treeK->viewport()->installEventFilter(this);
ui->scrollArea->setAutoFillBackground(false); ui->scrollArea->setAutoFillBackground(false);
ui->scrollAreaWidgetContents->setAutoFillBackground(false); ui->scrollAreaWidgetContents->setAutoFillBackground(false);
ui->widget->setAutoFillBackground(false); ui->widget->setAutoFillBackground(false);
ui->label_17->setFixedSize(preferredIconSize(1.25, this)); ui->label_17->setFixedSize(preferredIconSize(1.25, this));
log_menu.addAction(ui->actionClear); log_menu.addAction(ui->actionClear);
prot_x = 0; prot_x = 0;
prot_c = 0; prot_c = 0;
show_x = config.getValue("show_x", true); show_x = config.getValue("show_x", true);
if (!show_x) if (!show_x)
ui->tabWidget->removeTab(1); ui->tabWidget->removeTab(1);
session.setFile("session_KX_Pult.conf"); session.setFile("session_KX_Pult.conf");
session.addEntry(this); session.addEntry(this);
session.addEntry(ui->tabWidget); session.addEntry(ui->tabWidget);
session.addEntry(ui->checkKHideEmpty); session.addEntry(ui->checkKHideEmpty);
session.addEntry(ui->checkKHideNormal); session.addEntry(ui->checkKHideNormal);
session.addEntry(ui->checkKHideExpressions); session.addEntry(ui->checkKHideExpressions);
session.addEntry(ui->checkKAutoCalculate); session.addEntry(ui->checkKAutoCalculate);
needWrite = isPause = false; needWrite = isPause = false;
timer = 0; timer = 0;
//x.resize(KX_X_PACKET_NUM); //x.resize(KX_X_PACKET_NUM);
//k.resize(K_NUM); //k.resize(K_NUM);
QPalette pal = palette(); QPalette pal = palette();
QColor col; QColor col;
ui->graphic->setGraphicsCount(0); ui->graphic->setGraphicsCount(0);
for (int i = 0; i < KX_X_PACKET_NUM; ++i) { for (int i = 0; i < KX_X_PACKET_NUM; ++i) {
XCheck * xc = new XCheck(i); XCheck * xc = new XCheck(i);
xc->installEventFilter(this); xc->installEventFilter(this);
connect(xc, SIGNAL(valueChanged(int, int)), this, SLOT(changedX(int,int))); connect(xc, SIGNAL(valueChanged(int, int)), this, SLOT(changedX(int,int)));
connect(xc, SIGNAL(checkChanged(int, bool)), this, SLOT(toggledX(int, bool))); connect(xc, SIGNAL(checkChanged(int, bool)), this, SLOT(toggledX(int, bool)));
col = QColor::fromHsv(360 / KX_X_PACKET_NUM * i, 255, 200); col = QColor::fromHsv(360 / KX_X_PACKET_NUM * i, 255, 200);
pal.setColor(QPalette::Button, col); pal.setColor(QPalette::Button, col);
pal.setColor(QPalette::Window, col); pal.setColor(QPalette::Window, col);
pal.setColor(QPalette::WindowText, invertColor(col)); pal.setColor(QPalette::WindowText, invertColor(col));
xc->check.setPalette(pal); xc->check.setPalette(pal);
ui->graphic->addGraphic(QString::number(i), col); ui->graphic->addGraphic(QString::number(i), col);
ui->graphic->setGraphicVisible(false, i); ui->graphic->setGraphicVisible(false, i);
checks << xc; checks << xc;
((QGridLayout * )(ui->widgetChecks->layout()))->addWidget(xc, (i / 10) * 2, i % 10); ((QGridLayout * )(ui->widgetChecks->layout()))->addWidget(xc, (i / 10) * 2, i % 10);
QLabel * lbl = new QLabel("0"); lbl->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); QLabel * lbl = new QLabel("0"); lbl->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
values << lbl; values << lbl;
((QGridLayout * )(ui->widgetChecks->layout()))->addWidget(lbl, (i / 10) * 2 + 1, i % 10); ((QGridLayout * )(ui->widgetChecks->layout()))->addWidget(lbl, (i / 10) * 2 + 1, i % 10);
//xc->show(); //xc->show();
} }
renew(); renew();
icon_record = QIcon(":/icons/media-record.png"); icon_record = QIcon(":/icons/media-record.png");
icon_stop = QIcon(":/icons/media-playback-stop.png"); icon_stop = QIcon(":/icons/media-playback-stop.png");
outdir = dir.absolutePath(); outdir = dir.absolutePath();
if (!dir.exists()) dir.mkdir(outdir); if (!dir.exists()) dir.mkdir(outdir);
outdir += "/"; outdir += "/";
ui->treeK->setColumnWidth(0, 60); ui->treeK->setColumnWidth(0, 60);
ui->treeK->setColumnWidth(1, 250); ui->treeK->setColumnWidth(1, 250);
ui->treeK->setColumnWidth(3, 100); ui->treeK->setColumnWidth(3, 100);
ui->treeK->setColumnWidth(4, 100); ui->treeK->setColumnWidth(4, 100);
//ui->table->setK(coeffsK.k()->data(), coeffsK.count()); //ui->table->setK(coeffsK.k()->data(), coeffsK.count());
ui->spinSize->setValue(K.size_s()); ui->spinSize->setValue(K.size_s());
addToList(trUtf8("Read K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta); addToList(trUtf8("Read K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta);
CONNECT(void, &coeffs, sendFailed, this, pip_sendFailed); CONNECT(void, &coeffs, sendFailed, this, pip_sendFailed);
CONNECT(void, &coeffs, sendSucceed, this, pip_sendSucceed); CONNECT(void, &coeffs, sendSucceed, this, pip_sendSucceed);
CONNECT(void, &coeffs, receiveFailed, this, pip_receiveFailed); CONNECT(void, &coeffs, receiveFailed, this, pip_receiveFailed);
CONNECT(void, &coeffs, receiveSucceed, this, pip_receiveSucceed); CONNECT(void, &coeffs, receiveSucceed, this, pip_receiveSucceed);
connect(this, SIGNAL(q_k_sendFailed()), this, SLOT(k_sendFailed()), Qt::QueuedConnection); connect(this, SIGNAL(q_k_sendFailed()), this, SLOT(k_sendFailed()), Qt::QueuedConnection);
connect(this, SIGNAL(q_k_sendSucceed()), this, SLOT(k_sendSucceed()), Qt::QueuedConnection); connect(this, SIGNAL(q_k_sendSucceed()), this, SLOT(k_sendSucceed()), Qt::QueuedConnection);
connect(this, SIGNAL(q_k_receiveFailed()), this, SLOT(k_receiveFailed()), Qt::QueuedConnection); connect(this, SIGNAL(q_k_receiveFailed()), this, SLOT(k_receiveFailed()), Qt::QueuedConnection);
connect(this, SIGNAL(q_k_receiveSucceed()), this, SLOT(k_receiveSucceed()), Qt::QueuedConnection); connect(this, SIGNAL(q_k_receiveSucceed()), this, SLOT(k_receiveSucceed()), Qt::QueuedConnection);
connect(&timer_diag, SIGNAL(timeout()), this, SLOT(updateDiag())); connect(&timer_diag, SIGNAL(timeout()), this, SLOT(updateDiag()));
connect(&session, SIGNAL(loading(QPIConfig&)), this, SLOT(loading(QPIConfig&))); connect(&session, SIGNAL(loading(QPIConfig&)), this, SLOT(loading(QPIConfig&)));
connect(&session, SIGNAL(saving(QPIConfig&)), this, SLOT(saving(QPIConfig&))); connect(&session, SIGNAL(saving(QPIConfig&)), this, SLOT(saving(QPIConfig&)));
connect(ui->checkKHideEmpty, SIGNAL(toggled(bool)), this, SLOT(filterTree())); connect(ui->checkKHideEmpty, SIGNAL(toggled(bool)), this, SLOT(filterTree()));
connect(ui->checkKHideNormal, SIGNAL(toggled(bool)), this, SLOT(filterTree())); connect(ui->checkKHideNormal, SIGNAL(toggled(bool)), this, SLOT(filterTree()));
connect(ui->checkKHideExpressions, SIGNAL(toggled(bool)), this, SLOT(filterTree())); connect(ui->checkKHideExpressions, SIGNAL(toggled(bool)), this, SLOT(filterTree()));
connect(ui->lineKSearch, SIGNAL(textChanged(QString)), this, SLOT(filterTree())); connect(ui->lineKSearch, SIGNAL(textChanged(QString)), this, SLOT(filterTree()));
session.load(); session.load();
updateKDesc(); updateKDesc();
updateCDesc(); updateCDesc();
timer_diag.start(40); timer_diag.start(40);
timer_update = startTimer(25); timer_update = startTimer(25);
} }
KX_Pult::~KX_Pult() { KX_Pult::~KX_Pult() {
session.save(); session.save();
} }
void KX_Pult::loading(QPIConfig & conf) { void KX_Pult::loading(QPIConfig & conf) {
kdesc_file = conf.getValue("kdesc_file").stringValue(); kdesc_file = conf.getValue("kdesc_file").stringValue();
cdesc_file = conf.getValue("cdesc_file").stringValue(); cdesc_file = conf.getValue("cdesc_file").stringValue();
} }
void KX_Pult::saving(QPIConfig & conf) { void KX_Pult::saving(QPIConfig & conf) {
conf.setValue("kdesc_file", kdesc_file); conf.setValue("kdesc_file", kdesc_file);
conf.setValue("cdesc_file", cdesc_file); conf.setValue("cdesc_file", cdesc_file);
} }
bool KX_Pult::eventFilter(QObject * o, QEvent * e) { bool KX_Pult::eventFilter(QObject * o, QEvent * e) {
if (o == ui->list->viewport()) { if (o == ui->list->viewport()) {
if (e->type() == QEvent::ContextMenu) { if (e->type() == QEvent::ContextMenu) {
clear_target = 0; clear_target = 0;
log_menu.popup(((QContextMenuEvent*)e)->globalPos()); log_menu.popup(((QContextMenuEvent*)e)->globalPos());
} }
return QMainWindow::eventFilter(o, e); return QMainWindow::eventFilter(o, e);
} }
if (o == ui->treeK->viewport()) { if (o == ui->treeK->viewport()) {
if (e->type() == QEvent::ContextMenu) { if (e->type() == QEvent::ContextMenu) {
clear_target = 1; clear_target = 1;
log_menu.popup(((QContextMenuEvent*)e)->globalPos()); log_menu.popup(((QContextMenuEvent*)e)->globalPos());
} }
return QMainWindow::eventFilter(o, e); return QMainWindow::eventFilter(o, e);
} }
int ind = o->property("index").toInt(); int ind = o->property("index").toInt();
//qDebug() << "event" << i << e->type(); //qDebug() << "event" << i << e->type();
switch (e->type()) { switch (e->type()) {
case QEvent::Enter: case QEvent::Enter:
ui->graphic->setAutoUpdate(false); ui->graphic->setAutoUpdate(false);
for (int i = 0; i < KX_X_PACKET_NUM; ++i) for (int i = 0; i < KX_X_PACKET_NUM; ++i)
ui->graphic->setGraphicLineWidth(ind == i ? 3. : 1., i); ui->graphic->setGraphicLineWidth(ind == i ? 3. : 1., i);
ui->graphic->setAutoUpdate(true); ui->graphic->setAutoUpdate(true);
ui->graphic->update(); ui->graphic->update();
break; break;
case QEvent::Leave: case QEvent::Leave:
ui->graphic->setAutoUpdate(false); ui->graphic->setAutoUpdate(false);
for (int i = 0; i < KX_X_PACKET_NUM; ++i) for (int i = 0; i < KX_X_PACKET_NUM; ++i)
ui->graphic->setGraphicLineWidth(1., i); ui->graphic->setGraphicLineWidth(1., i);
ui->graphic->setAutoUpdate(true); ui->graphic->setAutoUpdate(true);
ui->graphic->update(); ui->graphic->update();
break; break;
default: break; default: break;
} }
return QMainWindow::eventFilter(o, e); return QMainWindow::eventFilter(o, e);
} }
void KX_Pult::timerEvent(QTimerEvent * e) { void KX_Pult::timerEvent(QTimerEvent * e) {
if (e->timerId() == timer_update) { if (e->timerId() == timer_update) {
if (need_update) { if (need_update) {
need_update = false; need_update = false;
ui->graphic->updateGraphics(); ui->graphic->updateGraphics();
} }
} }
if (e->timerId() == timer) { if (e->timerId() == timer) {
static QString sPI = QString::number(atan(1) * 4., 'f', 14).leftJustified(14); static QString sPI = QString::number(atan(1) * 4., 'f', 14).leftJustified(14);
static int cnt = 0; static int cnt = 0;
int si = qMax<int>(cnt - 6, 0); int si = qMax<int>(cnt - 6, 0);
++cnt; ++cnt;
cnt %= 23; cnt %= 23;
ui->labelWait->setText(QString(si, QChar(' ')) + sPI.mid(cnt - 6, 6).trimmed()); ui->labelWait->setText(QString(si, QChar(' ')) + sPI.mid(cnt - 6, 6).trimmed());
if (!coeffs.isReady()) return; if (!coeffs.isReady()) return;
//ui->table->setK(coeffsK.k()->data(), coeffsK.count()); //ui->table->setK(coeffsK.k()->data(), coeffsK.count());
//ui->table->showK(); //ui->table->showK();
} }
} }
void KX_Pult::setControlsEnable(bool enable) { void KX_Pult::setControlsEnable(bool enable) {
foreach (XCheck * i, checks) foreach (XCheck * i, checks)
i->setEnabled(enable); i->setEnabled(enable);
ui->buttonShowAll->setEnabled(enable); ui->buttonShowAll->setEnabled(enable);
ui->buttonHideAll->setEnabled(enable); ui->buttonHideAll->setEnabled(enable);
} }
void KX_Pult::setX(const KX_X_Data & data) { void KX_Pult::setX(const KX_X_Data & data) {
if (!show_x) return; if (!show_x) return;
//ui->graphic->lock(); //ui->graphic->lock();
for (int i = 0; i < KX_X_PACKET_NUM; ++i) { for (int i = 0; i < KX_X_PACKET_NUM; ++i) {
if (!isNormalDouble(data.x_data[i])) continue; if (!isNormalDouble(data.x_data[i])) continue;
ui->graphic->addPoint(data.x_data[i], i, false); ui->graphic->addPoint(data.x_data[i], i, false);
values[i]->setText(QString("(%1): %2").arg(data.x_num[i]).arg(data.x_data[i])); values[i]->setText(QString("(%1): %2").arg(data.x_num[i]).arg(data.x_data[i]));
} }
//ui->graphic->unlock(); //ui->graphic->unlock();
if (!isPause) { if (!isPause) {
need_update = true; need_update = true;
} }
if (!needWrite) return; if (!needWrite) return;
stream << QString::number(tm.elapsed() / 1000., 'f', 3) << " " << QTime::currentTime().toString("hh:mm:ss") << " " << wcnt++; stream << QString::number(tm.elapsed() / 1000., 'f', 3) << " " << QTime::currentTime().toString("hh:mm:ss") << " " << wcnt++;
for (int i = 0; i < KX_X_PACKET_NUM; ++i) for (int i = 0; i < KX_X_PACKET_NUM; ++i)
stream << " " << QString::number(data.x_data[i], 'f', 4); stream << " " << QString::number(data.x_data[i], 'f', 4);
stream << "\n"; stream << "\n";
} }
void KX_Pult::addToList(const QString & s, const QColor & c) { void KX_Pult::addToList(const QString & s, const QColor & c) {
ui->list->addItem(QDateTime::currentDateTime().toString("dd/MM/yyyy hh:ss - ") + s); ui->list->addItem(QDateTime::currentDateTime().toString("dd/MM/yyyy hh:ss - ") + s);
ui->list->item(ui->list->count() - 1)->setTextColor(c); ui->list->item(ui->list->count() - 1)->setTextColor(c);
ui->list->scrollToBottom(); ui->list->scrollToBottom();
} }
void KX_Pult::on_buttonRecord_clicked() { void KX_Pult::on_buttonRecord_clicked() {
static bool isRec = false; static bool isRec = false;
int cinc = 0; int cinc = 0;
QString str; QString str;
isRec = !isRec; isRec = !isRec;
setControlsEnable(!isRec); setControlsEnable(!isRec);
if (isRec) { if (isRec) {
tm.restart(); tm.restart();
file.close(); file.close();
file.setFileName(outdir + getNewFileName(cinc)); file.setFileName(outdir + getNewFileName(cinc));
while (file.exists()) while (file.exists())
file.setFileName(outdir + getNewFileName(cinc++)); file.setFileName(outdir + getNewFileName(cinc++));
file.open(QIODevice::ReadWrite); file.open(QIODevice::ReadWrite);
stream.setDevice(&file); stream.setDevice(&file);
stream << "T V C"; stream << "T V C";
for (int i = 0; i < KX_X_PACKET_NUM; ++i) for (int i = 0; i < KX_X_PACKET_NUM; ++i)
stream << " X" + QString::number(checks[i]->spin.value()); stream << " X" + QString::number(checks[i]->spin.value());
stream << "\n"; stream << "\n";
wcnt = 0; wcnt = 0;
needWrite = true; needWrite = true;
ui->buttonRecord->setText(trUtf8("Finish record")); ui->buttonRecord->setText(trUtf8("Finish record"));
ui->buttonRecord->setIcon(icon_stop); ui->buttonRecord->setIcon(icon_stop);
emit recordStarted(QFileInfo(file).completeBaseName()); emit recordStarted(QFileInfo(file).completeBaseName());
} else { } else {
needWrite = false; needWrite = false;
stream.setDevice(0); stream.setDevice(0);
file.close(); file.close();
ui->buttonRecord->setText(trUtf8("Start record")); ui->buttonRecord->setText(trUtf8("Start record"));
ui->buttonRecord->setIcon(icon_record); ui->buttonRecord->setIcon(icon_record);
emit recordStopped(QFileInfo(file).completeBaseName()); emit recordStopped(QFileInfo(file).completeBaseName());
} }
} }
void KX_Pult::on_actionClear_triggered() { void KX_Pult::on_actionClear_triggered() {
switch (clear_target) { switch (clear_target) {
case 0: case 0:
ui->list->clear(); ui->list->clear();
break; break;
case 1: case 1:
clearSelected(); clearSelected();
break; break;
default: break; default: break;
} }
} }
void KX_Pult::clearSelected() { void KX_Pult::clearSelected() {
QList<QTreeWidgetItem * > si = ui->treeK->selectedItems(); QList<QTreeWidgetItem * > si = ui->treeK->selectedItems();
ui->treeK->setUpdatesEnabled(false); ui->treeK->setUpdatesEnabled(false);
ui->treeK->blockSignals(true); ui->treeK->blockSignals(true);
foreach (QTreeWidgetItem * i, si) { foreach (QTreeWidgetItem * i, si) {
int ki = i->text(0).toInt(); int ki = i->text(0).toInt();
i->setText(2, ""); i->setText(2, "");
coeffs.setFormula(ki, ""); coeffs.setFormula(ki, "");
} }
ui->treeK->blockSignals(false); ui->treeK->blockSignals(false);
ui->treeK->setUpdatesEnabled(true); ui->treeK->setUpdatesEnabled(true);
if (ui->checkKAutoCalculate->isChecked()) { if (ui->checkKAutoCalculate->isChecked()) {
QApplication::processEvents(); QApplication::processEvents();
calculate(); calculate();
} }
} }
QString KX_Pult::typeName(const QString & n) const { QString KX_Pult::typeName(const QString & n) const {
if (n.isEmpty()) return ""; if (n.isEmpty()) return "";
switch (n[0].toLatin1()) { switch (n[0].toLatin1()) {
case 'l': return trUtf8("list"); break; case 'l': return trUtf8("list"); break;
case 'b': return trUtf8("bool"); break; case 'b': return trUtf8("bool"); break;
case 'n': return trUtf8("int"); break; case 'n': return trUtf8("int"); break;
case 'f': return trUtf8("double"); break; case 'f': return trUtf8("double"); break;
case 'c': return trUtf8("color"); break; case 'c': return trUtf8("color"); break;
case 'r': return trUtf8("rect"); break; case 'r': return trUtf8("rect"); break;
case 'a': return trUtf8("rect"); break; case 'a': return trUtf8("rect"); break;
case 'p': return trUtf8("point"); break; case 'p': return trUtf8("point"); break;
case 'v': return trUtf8("vector"); break; case 'v': return trUtf8("vector"); break;
case 'i': return trUtf8("IP"); break; case 'i': return trUtf8("IP"); break;
case 'e': return trUtf8("enum"); break; case 'e': return trUtf8("enum"); break;
case 'F': return trUtf8("file"); break; case 'F': return trUtf8("file"); break;
case 'D': return trUtf8("dir"); break; case 'D': return trUtf8("dir"); break;
} }
return ""; return "";
} }
void KX_Pult::received(bool ok) { void KX_Pult::received(bool ok) {
if (!ok) return; if (!ok) return;
setX(prot_x->from_x); setX(prot_x->from_x);
} }
void KX_Pult::on_treeK_itemClicked(QTreeWidgetItem * item, int column) { void KX_Pult::on_treeK_itemClicked(QTreeWidgetItem * item, int column) {
Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable; Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
if (column == 2) f |= Qt::ItemIsEditable; if (column == 2) f |= Qt::ItemIsEditable;
item->setFlags(f); item->setFlags(f);
} }
void KX_Pult::on_treeK_itemChanged(QTreeWidgetItem * item, int column) { void KX_Pult::on_treeK_itemChanged(QTreeWidgetItem * item, int column) {
if (column != 2) return; if (column != 2) return;
int ki = item->text(0).toInt(); int ki = item->text(0).toInt();
coeffs.setFormula(ki, piqt(item->text(column))); coeffs.setFormula(ki, piqt(item->text(column)));
if (ui->checkKAutoCalculate->isChecked()) if (ui->checkKAutoCalculate->isChecked())
calculate(); calculate();
} }
QString KX_Pult::getNewFileName(int inc) { QString KX_Pult::getNewFileName(int inc) {
dir.refresh(); dir.refresh();
dir.setNameFilters(QStringList("Experiment_*.txt")); dir.setNameFilters(QStringList("Experiment_*.txt"));
return "Experiment_" + QDateTime::currentDateTime().toString("dd_MM_yy__hh_mm_ss") + "__" + return "Experiment_" + QDateTime::currentDateTime().toString("dd_MM_yy__hh_mm_ss") + "__" +
QString::number(dir.entryList().count() + inc) + ".txt"; QString::number(dir.entryList().count() + inc) + ".txt";
} }
void KX_Pult::on_buttonSendK_clicked() { void KX_Pult::on_buttonSendK_clicked() {
on_buttonWrite_clicked(); on_buttonWrite_clicked();
coeffs.sendCoeffs(); coeffs.sendCoeffs();
if (timer != 0) killTimer(timer); if (timer != 0) killTimer(timer);
timer = startTimer(100); timer = startTimer(100);
} }
void KX_Pult::on_buttonReceiveK_clicked() { void KX_Pult::on_buttonReceiveK_clicked() {
coeffs.receiveCoeffs(); coeffs.receiveCoeffs();
if (timer != 0) killTimer(timer); if (timer != 0) killTimer(timer);
timer = startTimer(100); timer = startTimer(100);
} }
void KX_Pult::on_buttonShowAll_clicked() { void KX_Pult::on_buttonShowAll_clicked() {
for (int i = 0; i < KX_X_PACKET_NUM; ++i) { for (int i = 0; i < KX_X_PACKET_NUM; ++i) {
checks[i]->check.setChecked(true); checks[i]->check.setChecked(true);
//ui->graphic->setGraphicVisible(true, i); //ui->graphic->setGraphicVisible(true, i);
} }
} }
void KX_Pult::on_buttonHideAll_clicked() { void KX_Pult::on_buttonHideAll_clicked() {
for (int i = 0; i < KX_X_PACKET_NUM; ++i) { for (int i = 0; i < KX_X_PACKET_NUM; ++i) {
checks[i]->check.setChecked(false); checks[i]->check.setChecked(false);
//ui->graphic->setGraphicVisible(false, i); //ui->graphic->setGraphicVisible(false, i);
} }
} }
void KX_Pult::on_buttonRead_clicked() { void KX_Pult::on_buttonRead_clicked() {
coeffs.readCoeffs(); coeffs.readCoeffs();
addToList(trUtf8("Read K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta); addToList(trUtf8("Read K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta);
updateTree(); updateTree();
} }
void KX_Pult::on_buttonWrite_clicked() { void KX_Pult::on_buttonWrite_clicked() {
coeffs.writeCoeffs(); coeffs.writeCoeffs();
addToList(trUtf8("Write K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta); addToList(trUtf8("Write K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta);
} }
void KX_Pult::on_buttonResize_clicked() { void KX_Pult::on_buttonResize_clicked() {
K.resize(ui->spinSize->value()); K.resize(ui->spinSize->value());
coeffs.formulas.resize(ui->spinSize->value()); coeffs.formulas.resize(ui->spinSize->value());
ui->spinSize->setStyleSheet(""); ui->spinSize->setStyleSheet("");
updateTree(); updateTree();
} }
void KX_Pult::on_buttonSetKDesc_clicked() { void KX_Pult::on_buttonSetKDesc_clicked() {
QString ret = QFileDialog::getOpenFileName(this, trUtf8("Select *.h file with K description"), kdesc_file, "C/C++ header files(*.h *.hpp);;All files(*)"); QString ret = QFileDialog::getOpenFileName(this, trUtf8("Select *.h file with K description"), kdesc_file, "C/C++ header files(*.h *.hpp);;All files(*)");
if (ret.isEmpty()) return; if (ret.isEmpty()) return;
kdesc_file = QDir::current().relativeFilePath(ret); kdesc_file = QDir::current().relativeFilePath(ret);
updateKDesc(true); updateKDesc(true);
} }
void KX_Pult::on_buttonSetCDesc_clicked() { void KX_Pult::on_buttonSetCDesc_clicked() {
QString ret = QFileDialog::getOpenFileName(this, trUtf8("Select *.h file with C description"), cdesc_file, "C/C++ header files(*.h *.hpp);;All files(*)"); QString ret = QFileDialog::getOpenFileName(this, trUtf8("Select *.h file with C description"), cdesc_file, "C/C++ header files(*.h *.hpp);;All files(*)");
if (ret.isEmpty()) return; if (ret.isEmpty()) return;
cdesc_file = QDir::current().relativeFilePath(ret); cdesc_file = QDir::current().relativeFilePath(ret);
updateCDesc(); updateCDesc();
} }
void KX_Pult::on_spinSize_valueChanged(int) { void KX_Pult::on_spinSize_valueChanged(int) {
ui->spinSize->setStyleSheet(""); ui->spinSize->setStyleSheet("");
} }
void KX_Pult::k_sendFailed() { void KX_Pult::k_sendFailed() {
stopWait(); stopWait();
addToList(trUtf8("K not sended"), Qt::darkRed); addToList(trUtf8("K not sended"), Qt::darkRed);
} }
void KX_Pult::k_sendSucceed() { void KX_Pult::k_sendSucceed() {
stopWait(); stopWait();
addToList(trUtf8("K sended"), Qt::darkGreen); addToList(trUtf8("K sended"), Qt::darkGreen);
} }
void KX_Pult::k_receiveFailed() { void KX_Pult::k_receiveFailed() {
stopWait(); stopWait();
addToList(trUtf8("K not received"), Qt::darkRed); addToList(trUtf8("K not received"), Qt::darkRed);
} }
void KX_Pult::k_receiveSucceed() { void KX_Pult::k_receiveSucceed() {
stopWait(); stopWait();
addToList(trUtf8("K received"), Qt::darkGreen); addToList(trUtf8("K received"), Qt::darkGreen);
addToList(trUtf8("Write K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta); addToList(trUtf8("Write K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta);
ui->spinSize->setValue(K.size_s()); ui->spinSize->setValue(K.size_s());
updateTree(); updateTree();
//ui->table->setK(coeffsK.k()->data(), coeffsK.count()); //ui->table->setK(coeffsK.k()->data(), coeffsK.count());
} }
void KX_Pult::on_spinBuffer_editingFinished() { void KX_Pult::on_spinBuffer_editingFinished() {
ui->graphic->setHistorySize(ui->spinBuffer->value()); ui->graphic->setHistorySize(ui->spinBuffer->value());
} }
void KX_Pult::stopWait() { void KX_Pult::stopWait() {
killTimer(timer); killTimer(timer);
timer = 0; timer = 0;
ui->labelWait->setText(" "); ui->labelWait->setText(" ");
} }
void KX_Pult::updateGraph() { void KX_Pult::updateGraph() {
ui->graphic->updateGraphics(); ui->graphic->updateGraphics();
} }
void KX_Pult::updateDiag() { void KX_Pult::updateDiag() {
ui->labelKReceiver->setText(piqt(coeffs.k_protocol->receiverDeviceName() + " - " + coeffs.k_protocol->receiverDeviceState())); ui->labelKReceiver->setText(piqt(coeffs.k_protocol->receiverDeviceName() + " - " + coeffs.k_protocol->receiverDeviceState()));
ui->labelKSender->setText(piqt(coeffs.k_protocol->senderDeviceName())); ui->labelKSender->setText(piqt(coeffs.k_protocol->senderDeviceName()));
ui->spinKSended->setValue(coeffs.k_protocol->sendCount()); ui->spinKSended->setValue(coeffs.k_protocol->sendCount());
ui->spinKReceived->setValue(coeffs.k_protocol->receiveCount()); ui->spinKReceived->setValue(coeffs.k_protocol->receiveCount());
ui->spinKWrong->setValue(coeffs.k_protocol->wrongCount()); ui->spinKWrong->setValue(coeffs.k_protocol->wrongCount());
ui->spinKMissed->setValue(coeffs.k_protocol->missedCount()); ui->spinKMissed->setValue(coeffs.k_protocol->missedCount());
ui->labelKType->setText("0x" + QString::number(coeffs.k_protocol->from_k.type, 16).toUpper().rightJustified(2, '0')); ui->labelKType->setText("0x" + QString::number(coeffs.k_protocol->from_k.type, 16).toUpper().rightJustified(2, '0'));
ui->labelKAddrPult->setText("0x" + QString::number(coeffs.k_protocol->from_k.addr_to, 16).toUpper().rightJustified(2, '0')); ui->labelKAddrPult->setText("0x" + QString::number(coeffs.k_protocol->from_k.addr_to, 16).toUpper().rightJustified(2, '0'));
ui->labelKAddr->setText("0x" + QString::number(coeffs.k_protocol->to_k.addr_to, 16).toUpper().rightJustified(2, '0')); ui->labelKAddr->setText("0x" + QString::number(coeffs.k_protocol->to_k.addr_to, 16).toUpper().rightJustified(2, '0'));
ui->labelXReceiver->setText(piqt(prot_x->receiverDeviceName() + " - " + prot_x->receiverDeviceState())); ui->labelXReceiver->setText(piqt(prot_x->receiverDeviceName() + " - " + prot_x->receiverDeviceState()));
ui->labelXSender->setText(piqt(prot_x->senderDeviceName())); ui->labelXSender->setText(piqt(prot_x->senderDeviceName()));
ui->spinXSended->setValue(prot_x->sendCount()); ui->spinXSended->setValue(prot_x->sendCount());
ui->spinXReceived->setValue(prot_x->receiveCount()); ui->spinXReceived->setValue(prot_x->receiveCount());
ui->spinXWrong->setValue(prot_x->wrongCount()); ui->spinXWrong->setValue(prot_x->wrongCount());
ui->spinXMissed->setValue(prot_x->missedCount()); ui->spinXMissed->setValue(prot_x->missedCount());
ui->labelXType->setText("0x" + QString::number(prot_x->from_x.type, 16).toUpper().rightJustified(2, '0')); ui->labelXType->setText("0x" + QString::number(prot_x->from_x.type, 16).toUpper().rightJustified(2, '0'));
ui->labelXAddrPult->setText("0x" + QString::number(prot_x->from_x.addr_to, 16).toUpper().rightJustified(2, '0')); ui->labelXAddrPult->setText("0x" + QString::number(prot_x->from_x.addr_to, 16).toUpper().rightJustified(2, '0'));
ui->labelXAddr->setText("0x" + QString::number(prot_x->to_x.addr_to, 16).toUpper().rightJustified(2, '0')); ui->labelXAddr->setText("0x" + QString::number(prot_x->to_x.addr_to, 16).toUpper().rightJustified(2, '0'));
ui->labelCReceiver->setText(piqt(prot_c->receiverDeviceName() + " - " + prot_c->receiverDeviceState())); ui->labelCReceiver->setText(piqt(prot_c->receiverDeviceName() + " - " + prot_c->receiverDeviceState()));
ui->labelCSender->setText(piqt(prot_c->senderDeviceName())); ui->labelCSender->setText(piqt(prot_c->senderDeviceName()));
ui->spinCSended->setValue(prot_c->sendCount()); ui->spinCSended->setValue(prot_c->sendCount());
ui->spinCReceived->setValue(prot_c->receiveCount()); ui->spinCReceived->setValue(prot_c->receiveCount());
ui->spinCWrong->setValue(prot_c->wrongCount()); ui->spinCWrong->setValue(prot_c->wrongCount());
ui->spinCMissed->setValue(prot_c->missedCount()); ui->spinCMissed->setValue(prot_c->missedCount());
ui->labelCType->setText("0x" + QString::number(prot_c->from_c.type, 16).toUpper().rightJustified(2, '0')); ui->labelCType->setText("0x" + QString::number(prot_c->from_c.type, 16).toUpper().rightJustified(2, '0'));
ui->labelCAddrPult->setText("0x" + QString::number(prot_c->from_c.addr_to, 16).toUpper().rightJustified(2, '0')); ui->labelCAddrPult->setText("0x" + QString::number(prot_c->from_c.addr_to, 16).toUpper().rightJustified(2, '0'));
ui->labelCAddr->setText("0x" + QString::number(prot_c->to_c.addr_to, 16).toUpper().rightJustified(2, '0')); ui->labelCAddr->setText("0x" + QString::number(prot_c->to_c.addr_to, 16).toUpper().rightJustified(2, '0'));
} }
int KX_Pult::parseHeader(const QString & file, QMap<int, KX_Pult::KDesc> & map) { int KX_Pult::parseHeader(const QString & file, QMap<int, KX_Pult::KDesc> & map) {
map.clear(); map.clear();
QFile f(file); QFile f(file);
if (!f.open(QIODevice::ReadOnly)) { if (!f.open(QIODevice::ReadOnly)) {
updateTree(); updateTree();
addToList(trUtf8("Update descriptions from \"%1\": error").arg(file), Qt::darkRed); addToList(trUtf8("Update descriptions from \"%1\": error").arg(file), Qt::darkRed);
return 0; return 0;
} }
addToList(trUtf8("Update descriptions from \"%1\"").arg(file), Qt::darkMagenta); addToList(trUtf8("Update descriptions from \"%1\"").arg(file), Qt::darkMagenta);
QTextStream s(&f); QTextStream s(&f);
int cind = -1; int cind = -1;
bool found = false; bool found = false;
//qDebug() << "\nparse" << file; //qDebug() << "\nparse" << file;
while (!s.atEnd()) { while (!s.atEnd()) {
QString line = s.readLine().trimmed(), num, name, type, comment; QString line = s.readLine().trimmed(), num, name, type, comment;
int i = line.indexOf("//"); int i = line.indexOf("//");
if (i >= 0) { if (i >= 0) {
comment = line.right(line.length() - i - 2); comment = line.right(line.length() - i - 2);
type = comment.left(1); type = comment.left(1);
comment = comment.right(comment.length() - 1).trimmed(); comment = comment.right(comment.length() - 1).trimmed();
line = line.left(i).trimmed(); line = line.left(i).trimmed();
} }
if (line.isEmpty()) continue; if (line.isEmpty()) continue;
if (line.contains("enum")) { if (line.contains("enum")) {
found = true; found = true;
continue; continue;
} }
if (!found) continue; if (!found) continue;
if (line.contains('}')) if (line.contains('}'))
break; break;
line.remove(',').remove(' ').remove('\t'); line.remove(',').remove(' ').remove('\t');
i = line.indexOf("="); i = line.indexOf("=");
if (i >= 0) { if (i >= 0) {
num = line.right(line.length() - i - 1).trimmed(); num = line.right(line.length() - i - 1).trimmed();
line = line.left(i).trimmed(); line = line.left(i).trimmed();
} }
name = line; name = line;
if (num.isEmpty()) if (num.isEmpty())
++cind; ++cind;
else else
cind = Q2PIString(num).toInt(); cind = Q2PIString(num).toInt();
KDesc kd; KDesc kd;
kd.index = cind; kd.index = cind;
kd.name = name; kd.name = name;
kd.type = type; kd.type = type;
kd.comment = comment; kd.comment = comment;
map[kd.index] = kd; map[kd.index] = kd;
//qDebug() << name << cind << type << comment; //qDebug() << name << cind << type << comment;
} }
cind++; cind++;
return cind; return cind;
} }
void KX_Pult::updateKDesc(bool ask_move) { void KX_Pult::updateKDesc(bool ask_move) {
int cind = parseHeader(kdesc_file, kdesc); int cind = parseHeader(kdesc_file, kdesc);
if (K.size_s() < cind) { if (K.size_s() < cind) {
ui->spinSize->setValue(cind); ui->spinSize->setValue(cind);
ui->spinSize->setStyleSheet("background-color: rgb(220, 220, 255);"); ui->spinSize->setStyleSheet("background-color: rgb(220, 220, 255);");
} }
bool move = false; bool move = false;
if (ask_move) if (ask_move)
move = (QMessageBox::question(this, "KX Pult", "Save values at associated names?", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes); move = (QMessageBox::question(this, "KX Pult", "Save values at associated names?", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes);
updateTree(move); updateTree(move);
} }
void KX_Pult::updateCDesc() { void KX_Pult::updateCDesc() {
parseHeader(cdesc_file, cdesc); parseHeader(cdesc_file, cdesc);
updateCommands(); updateCommands();
} }
bool stringComp(const QString & s1, const QString & s2) { bool stringComp(const QString & s1, const QString & s2) {
if (s1.size() != s2.size()) if (s1.size() != s2.size())
return s1.size() > s2.size(); return s1.size() > s2.size();
return s1 > s2; return s1 > s2;
} }
void KX_Pult::updateTree(bool move) { void KX_Pult::updateTree(bool move) {
int sp = ui->treeK->verticalScrollBar()->value(); int sp = ui->treeK->verticalScrollBar()->value();
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
//qDebug() << "fill tree ..."; //qDebug() << "fill tree ...";
QMap<QString, QString> prev_val; QMap<QString, QString> prev_val;
if (move) { if (move) {
for (int i = 0; i < ui->treeK->topLevelItemCount(); ++i) { for (int i = 0; i < ui->treeK->topLevelItemCount(); ++i) {
QTreeWidgetItem * ti = ui->treeK->topLevelItem(i); QTreeWidgetItem * ti = ui->treeK->topLevelItem(i);
if (!ti->text(1).isEmpty()) if (!ti->text(1).isEmpty())
prev_val[ti->text(1)] = ti->text(2); prev_val[ti->text(1)] = ti->text(2);
} }
} }
ui->treeK->clear(); ui->treeK->clear();
ui->treeK->setUpdatesEnabled(false); ui->treeK->setUpdatesEnabled(false);
eval.clearCustomVariables(); eval.clearCustomVariables();
for (int i = 0; i < K.size_s(); ++i) { for (int i = 0; i < K.size_s(); ++i) {
QTreeWidgetItem * ti = new QTreeWidgetItem(); QTreeWidgetItem * ti = new QTreeWidgetItem();
KDesc kd = kdesc[i]; KDesc kd = kdesc[i];
QString kn = QString("k%1").arg(i); QString kn = QString("k%1").arg(i);
knames[kn] = i; knames[kn] = i;
knames_sort << kn; knames_sort << kn;
if (eval.content.findVariable(kn) < 0) if (eval.content.findVariable(kn) < 0)
eval.content.addVariable(kn, 0., false); eval.content.addVariable(kn, 0., false);
if (!kd.name.isEmpty()) { if (!kd.name.isEmpty()) {
knames[kd.name] = i; knames[kd.name] = i;
knames_sort << kd.name; knames_sort << kd.name;
eval.content.addVariable(kd.name, 0., false); eval.content.addVariable(kd.name, 0., false);
} }
if (move && !kd.name.isEmpty()) { if (move && !kd.name.isEmpty()) {
if (prev_val.contains(kd.name)) if (prev_val.contains(kd.name))
coeffs.setFormula(i, Q2PIString(prev_val[kd.name])); coeffs.setFormula(i, Q2PIString(prev_val[kd.name]));
} }
ti->setText(0, QString::number(i)); ti->setText(0, QString::number(i));
ti->setText(1, kd.name); ti->setText(1, kd.name);
ti->setText(2, PI2QString(coeffs.formula(i))); ti->setText(2, PI2QString(coeffs.formula(i)));
ti->setText(3, QString::number(K[i])); ti->setText(3, QString::number(K[i]));
ti->setText(4, typeName(kd.type)); ti->setText(4, typeName(kd.type));
ti->setText(5, kd.comment); ti->setText(5, kd.comment);
ui->treeK->addTopLevelItem(ti); ui->treeK->addTopLevelItem(ti);
} }
eval.content.sortVariables(); eval.content.sortVariables();
//qDebug() << "fill tree ok"; //qDebug() << "fill tree ok";
//qDebug() << "sort ..."; //qDebug() << "sort ...";
qSort(knames_sort.begin(), knames_sort.end(), stringComp); qSort(knames_sort.begin(), knames_sort.end(), stringComp);
//qDebug() << "names" << knames_sort; //qDebug() << "names" << knames_sort;
//qDebug() << "sort ok"; //qDebug() << "sort ok";
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
ui->treeK->setUpdatesEnabled(true); ui->treeK->setUpdatesEnabled(true);
ui->treeK->verticalScrollBar()->setValue(sp); ui->treeK->verticalScrollBar()->setValue(sp);
calculate(); calculate();
filterTree(); filterTree();
} }
void KX_Pult::updateCommands() { void KX_Pult::updateCommands() {
while (ui->layoutCommands->count() > 0) while (ui->layoutCommands->count() > 0)
delete ui->layoutCommands->itemAt(0)->widget(); delete ui->layoutCommands->itemAt(0)->widget();
QMapIterator<int, KDesc> it(cdesc); QMapIterator<int, KDesc> it(cdesc);
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
KDesc kd = it.value(); KDesc kd = it.value();
QPushButton * b = new QPushButton(); QPushButton * b = new QPushButton();
QString text = kd.name; QString text = kd.name;
if (!kd.comment.isEmpty()) if (!kd.comment.isEmpty())
text += QString("\n(%1)").arg(kd.comment); text += QString("\n(%1)").arg(kd.comment);
b->setText(text); b->setText(text);
b->setProperty("_command", kd.index); b->setProperty("_command", kd.index);
connect(b, SIGNAL(clicked()), this, SLOT(commandClicked())); connect(b, SIGNAL(clicked()), this, SLOT(commandClicked()));
ui->layoutCommands->addWidget(b); ui->layoutCommands->addWidget(b);
} }
} }
void KX_Pult::filterTree() { void KX_Pult::filterTree() {
bool he = ui->checkKHideEmpty->isChecked(); bool he = ui->checkKHideEmpty->isChecked();
bool hn = ui->checkKHideNormal->isChecked(); bool hn = ui->checkKHideNormal->isChecked();
bool hs = ui->checkKHideExpressions->isChecked(); bool hs = ui->checkKHideExpressions->isChecked();
bool ok = false; bool ok = false;
QString fl = ui->lineKSearch->text(); QString fl = ui->lineKSearch->text();
int lc = ui->treeK->topLevelItemCount(); int lc = ui->treeK->topLevelItemCount();
for (int i = 0; i < lc; ++i) { for (int i = 0; i < lc; ++i) {
QTreeWidgetItem * ti = ui->treeK->topLevelItem(i); QTreeWidgetItem * ti = ui->treeK->topLevelItem(i);
if (ti->text(1).isEmpty() && he) if (ti->text(1).isEmpty() && he)
ti->setHidden(true); ti->setHidden(true);
else else
if (fl.isEmpty()) if (fl.isEmpty())
ti->setHidden(false); ti->setHidden(false);
else else
ti->setHidden(!ti->text(0).contains(fl, Qt::CaseInsensitive) && ti->setHidden(!ti->text(0).contains(fl, Qt::CaseInsensitive) &&
!ti->text(1).contains(fl, Qt::CaseInsensitive) && !ti->text(1).contains(fl, Qt::CaseInsensitive) &&
!ti->text(2).contains(fl, Qt::CaseInsensitive) && !ti->text(2).contains(fl, Qt::CaseInsensitive) &&
!ti->text(3).contains(fl, Qt::CaseInsensitive) && !ti->text(3).contains(fl, Qt::CaseInsensitive) &&
!ti->text(4).contains(fl, Qt::CaseInsensitive)); !ti->text(4).contains(fl, Qt::CaseInsensitive));
if (hn) if (hn)
if (ti->data(0, Qt::UserRole).toBool()) if (ti->data(0, Qt::UserRole).toBool())
ti->setHidden(true); ti->setHidden(true);
if (hs) { if (hs) {
ti->data(2, Qt::DisplayRole).toDouble(&ok); ti->data(2, Qt::DisplayRole).toDouble(&ok);
if (!ok) if (!ok)
ti->setHidden(true); ti->setHidden(true);
} }
} }
} }
void KX_Pult::calculate() { void KX_Pult::calculate() {
calculated.clear(); calculated.clear();
ui->treeK->setUpdatesEnabled(false); ui->treeK->setUpdatesEnabled(false);
ui->treeK->blockSignals(true); ui->treeK->blockSignals(true);
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
progress(0, 100); progress(0, 100);
ui->buttonCalculate->setEnabled(false); ui->buttonCalculate->setEnabled(false);
QApplication::processEvents(); QApplication::processEvents();
for (int i = 0; i < K.size_s(); ++i) { for (int i = 0; i < K.size_s(); ++i) {
ui->treeK->topLevelItem(i)->setToolTip(2, QString()); ui->treeK->topLevelItem(i)->setToolTip(2, QString());
ui->treeK->topLevelItem(i)->setToolTip(3, QString()); ui->treeK->topLevelItem(i)->setToolTip(3, QString());
} }
for (int i = 0; i < K.size_s(); ++i) { for (int i = 0; i < K.size_s(); ++i) {
progress(i, K.size_s()); progress(i, K.size_s());
calculateExpression(i, QVector<int>()); calculateExpression(i, QVector<int>());
} }
ui->buttonCalculate->setEnabled(true); ui->buttonCalculate->setEnabled(true);
ui->progress->setValue(100); ui->progress->setValue(100);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
ui->treeK->blockSignals(false); ui->treeK->blockSignals(false);
ui->treeK->setUpdatesEnabled(true); ui->treeK->setUpdatesEnabled(true);
} }
bool KX_Pult::calculateExpression(int i, QVector<int> trace) { bool KX_Pult::calculateExpression(int i, QVector<int> trace) {
if (calculated.contains(i)) return true; if (calculated.contains(i)) return true;
trace << i; trace << i;
QTreeWidgetItem * ti = ui->treeK->topLevelItem(i); QTreeWidgetItem * ti = ui->treeK->topLevelItem(i);
QString expr = ti->text(2); QString expr = ti->text(2);
if (expr.isEmpty() || expr == "0" || expr == "0,00000000" || expr == "0.00000000") { if (expr.isEmpty() || expr == "0" || expr == "0,00000000" || expr == "0.00000000") {
markNormal(ti); markNormal(ti);
calculated << i; calculated << i;
K[i] = 0.; K[i] = 0.;
ti->setText(3, "0"); ti->setText(3, "0");
return true; return true;
} }
//ti->setToolTip(2, QString()); //ti->setToolTip(2, QString());
if (!eval.check(expr)) { if (!eval.check(expr)) {
markError(ti, eval.error()); markError(ti, eval.error());
return false; return false;
} }
foreach (const QString & n, knames_sort) { foreach (const QString & n, knames_sort) {
if (expr.contains(n)) { if (expr.contains(n)) {
int ki = knames.value(n, -1); int ki = knames.value(n, -1);
if (trace.contains(ki)) { if (trace.contains(ki)) {
QString strace; QString strace;
trace << ki; trace << ki;
for (int j = 0; j < trace.size(); ++j) { for (int j = 0; j < trace.size(); ++j) {
//calculated << trace[j]; //calculated << trace[j];
if (j > 0) strace += " -> "; if (j > 0) strace += " -> ";
strace += "k" + QString::number(trace[j]); strace += "k" + QString::number(trace[j]);
} }
for (int j = 0; j < trace.size(); ++j) { for (int j = 0; j < trace.size(); ++j) {
QTreeWidgetItem * pti = ui->treeK->topLevelItem(trace[j]); QTreeWidgetItem * pti = ui->treeK->topLevelItem(trace[j]);
markError(pti, QString("Circular dependency: %1!").arg(strace)); markError(pti, QString("Circular dependency: %1!").arg(strace));
} }
return false; return false;
} }
if (ki < 0) { if (ki < 0) {
markError(ti); markError(ti);
return false; return false;
} }
if (calculated.contains(ki)) { if (calculated.contains(ki)) {
eval.setVariable(n, K[ki]); eval.setVariable(n, K[ki]);
} else { } else {
if (calculateExpression(ki, trace)) if (calculateExpression(ki, trace))
eval.setVariable(n, K[ki]); eval.setVariable(n, K[ki]);
else { else {
markError(ti); markError(ti);
return false; return false;
} }
} }
} }
} }
markNormal(ti); markNormal(ti);
calculated << i; calculated << i;
complexd ret = eval.evaluate(); complexd ret = eval.evaluate();
K[i] = ret.real(); K[i] = ret.real();
ti->setText(3, QString::number(K[i])); ti->setText(3, QString::number(K[i]));
return true; return true;
} }
void KX_Pult::markError(QTreeWidgetItem * item, const QString & tool_tip) { void KX_Pult::markError(QTreeWidgetItem * item, const QString & tool_tip) {
int cc = item->columnCount(); int cc = item->columnCount();
for (int i = 0; i < cc; ++i) for (int i = 0; i < cc; ++i)
item->setBackgroundColor(i, QColor(255, 200, 200)); item->setBackgroundColor(i, QColor(255, 200, 200));
if (item->toolTip(2).isEmpty()) if (item->toolTip(2).isEmpty())
item->setToolTip(2, tool_tip); item->setToolTip(2, tool_tip);
if (item->toolTip(3).isEmpty()) if (item->toolTip(3).isEmpty())
item->setToolTip(3, tool_tip); item->setToolTip(3, tool_tip);
item->setData(0, Qt::UserRole, false); item->setData(0, Qt::UserRole, false);
item->setText(3, "Error"); item->setText(3, "Error");
} }
void KX_Pult::markNormal(QTreeWidgetItem * item) { void KX_Pult::markNormal(QTreeWidgetItem * item) {
int cc = item->columnCount(); int cc = item->columnCount();
for (int i = 0; i < cc; ++i) for (int i = 0; i < cc; ++i)
item->setBackground(i, Qt::NoBrush); item->setBackground(i, Qt::NoBrush);
item->setToolTip(2, QString()); item->setToolTip(2, QString());
item->setToolTip(3, QString()); item->setToolTip(3, QString());
item->setData(0, Qt::UserRole, true); item->setData(0, Qt::UserRole, true);
} }
void KX_Pult::progress(int val, int max) { void KX_Pult::progress(int val, int max) {
if (ctm.elapsed() < 50) return; if (ctm.elapsed() < 50) return;
ctm.restart(); ctm.restart();
ui->progress->setValue(qRound(val * 100. / max)); ui->progress->setValue(qRound(val * 100. / max));
QApplication::processEvents(); QApplication::processEvents();
} }
void KX_Pult::renew(bool write) { void KX_Pult::renew(bool write) {
addToList(trUtf8("Update settings from \"%1\"").arg(PI2QString(config_)), Qt::darkMagenta); addToList(trUtf8("Update settings from \"%1\"").arg(PI2QString(config_)), Qt::darkMagenta);
dir.setPath(config.getValue("x.output_dir", "./Experiments/").stringValue()); dir.setPath(config.getValue("x.output_dir", "./Experiments/").stringValue());
setWindowTitle(config.getValue("title", "Noname").stringValue() + trUtf8(" - KX Pult")); setWindowTitle(config.getValue("title", "Noname").stringValue() + trUtf8(" - KX Pult"));
//if (write) ui->configWidget->write(); //if (write) ui->configWidget->write();
if (prot_x != 0) { if (prot_x != 0) {
prot_x->stop(); prot_x->stop();
delete prot_x; delete prot_x;
} }
if (prot_c != 0) { if (prot_c != 0) {
prot_c->stop(); prot_c->stop();
delete prot_c; delete prot_c;
} }
prot_x = new __KX_Protocol_X(config_, name_x); prot_x = new __KX_Protocol_X(config_, name_x);
prot_c = new __KX_Protocol_C(config_, name_c); prot_c = new __KX_Protocol_C(config_, name_c);
ui->graphic->setAutoXIncrement(prot_x->expectedFrequency() > 0. ? 1. / prot_x->expectedFrequency() : 1.); ui->graphic->setAutoXIncrement(prot_x->expectedFrequency() > 0. ? 1. / prot_x->expectedFrequency() : 1.);
coeffs.renew(); coeffs.renew();
CONNECT1(void, bool, prot_x, received, this, received); CONNECT1(void, bool, prot_x, received, this, received);
} }
void KX_Pult::toggledX(int index, bool on) { void KX_Pult::toggledX(int index, bool on) {
ui->graphic->setGraphicVisible(on, index); ui->graphic->setGraphicVisible(on, index);
} }
void KX_Pult::changedX(int index, int num) { void KX_Pult::changedX(int index, int num) {
prot_x->to_x.x_num[index] = num; prot_x->to_x.x_num[index] = num;
} }
void KX_Pult::commandClicked() { void KX_Pult::commandClicked() {
QPushButton * b = qobject_cast<QPushButton*>(sender()); QPushButton * b = qobject_cast<QPushButton*>(sender());
if (!b) return; if (!b) return;
prot_c->sendCommand(b->property("_command").toInt()); prot_c->sendCommand(b->property("_command").toInt());
} }

View File

@@ -1,170 +1,170 @@
#ifndef KX_PULT_H #ifndef KX_PULT_H
#define KX_PULT_H #define KX_PULT_H
#include <QDialog> #include <QDialog>
#include <QSpinBox> #include <QSpinBox>
#include <QFont> #include <QFont>
#include <QRect> #include <QRect>
#include <QFile> #include <QFile>
#include <QVector> #include <QVector>
#include <QDir> #include <QDir>
#include <QTextStream> #include <QTextStream>
#include <QDebug> #include <QDebug>
#include <QBoxLayout> #include <QBoxLayout>
#include <QCheckBox> #include <QCheckBox>
#include <QMainWindow> #include <QMainWindow>
#include <QTimer> #include <QTimer>
#include <QTime> #include <QTime>
#include <QMenu> #include <QMenu>
#include <QMetaObject> #include <QMetaObject>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QLabel> #include <QLabel>
#include "kx_coeffs.h" #include "kx_coeffs.h"
#include "kx_protocol_x.h" #include "kx_protocol_x.h"
#include "kx_protocol_c.h" #include "kx_protocol_c.h"
#include "piqt.h" #include "piqt.h"
#include "session_manager.h" #include "session_manager.h"
#include "qpievaluator.h" #include "qpievaluator.h"
class XCheck: public QWidget { class XCheck: public QWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit XCheck(int index); explicit XCheck(int index);
QCheckBox check; QCheckBox check;
QSpinBox spin; QSpinBox spin;
private: private:
bool eventFilter(QObject * o, QEvent * e); bool eventFilter(QObject * o, QEvent * e);
int index_; int index_;
private slots: private slots:
void spinChanged(int value) {check.setChecked(true); emit valueChanged(index_, value);} void spinChanged(int value) {check.setChecked(true); emit valueChanged(index_, value);}
void checkChanged_(bool value) {emit checkChanged(index_, value);} void checkChanged_(bool value) {emit checkChanged(index_, value);}
signals: signals:
void valueChanged(int index, int value); void valueChanged(int index, int value);
void checkChanged(int index, bool on); void checkChanged(int index, bool on);
}; };
namespace Ui { namespace Ui {
class KX_Pult; class KX_Pult;
}; };
class KX_Pult: public QMainWindow, public PIObject class KX_Pult: public QMainWindow, public PIObject
{ {
Q_OBJECT Q_OBJECT
PIOBJECT(KX_Pult) PIOBJECT(KX_Pult)
public: public:
KX_Pult(); KX_Pult();
~KX_Pult(); ~KX_Pult();
private: private:
struct KDesc { struct KDesc {
KDesc() {index = -1;} KDesc() {index = -1;}
int index; int index;
QString name; QString name;
QString type; QString type;
QString comment; QString comment;
QString value; QString value;
}; };
bool eventFilter(QObject * o, QEvent * e); bool eventFilter(QObject * o, QEvent * e);
void timerEvent(QTimerEvent * ); void timerEvent(QTimerEvent * );
void setControlsEnable(bool enable); void setControlsEnable(bool enable);
void setX(const KX_X_Data & data); void setX(const KX_X_Data & data);
void addToList(const QString & s, const QColor & c); void addToList(const QString & s, const QColor & c);
QString getNewFileName(int inc); QString getNewFileName(int inc);
QColor invertColor(QColor col) {return QColor(255 - col.red(), 255 - col.green(), 255 - col.blue());} QColor invertColor(QColor col) {return QColor(255 - col.red(), 255 - col.green(), 255 - col.blue());}
void stopWait(); void stopWait();
bool calculateExpression(int i, QVector<int> trace); bool calculateExpression(int i, QVector<int> trace);
void markError(QTreeWidgetItem * item, const QString & tool_tip = QString()); void markError(QTreeWidgetItem * item, const QString & tool_tip = QString());
void markNormal(QTreeWidgetItem * item); void markNormal(QTreeWidgetItem * item);
void progress(int val, int max); void progress(int val, int max);
void clearSelected(); void clearSelected();
QString typeName(const QString & n) const; QString typeName(const QString & n) const;
int parseHeader(const QString & file, QMap<int, KDesc> & map); int parseHeader(const QString & file, QMap<int, KDesc> & map);
EVENT_HANDLER1(void, received, bool, ok); EVENT_HANDLER1(void, received, bool, ok);
EVENT_HANDLER(void, pip_sendFailed) {emit q_k_sendFailed();} EVENT_HANDLER(void, pip_sendFailed) {emit q_k_sendFailed();}
EVENT_HANDLER(void, pip_sendSucceed) {emit q_k_sendSucceed();} EVENT_HANDLER(void, pip_sendSucceed) {emit q_k_sendSucceed();}
EVENT_HANDLER(void, pip_receiveFailed) {emit q_k_receiveFailed();} EVENT_HANDLER(void, pip_receiveFailed) {emit q_k_receiveFailed();}
EVENT_HANDLER(void, pip_receiveSucceed) {emit q_k_receiveSucceed();} EVENT_HANDLER(void, pip_receiveSucceed) {emit q_k_receiveSucceed();}
QVector<XCheck * > checks; QVector<XCheck * > checks;
QVector<QLabel * > values; QVector<QLabel * > values;
Ui::KX_Pult * ui; Ui::KX_Pult * ui;
PIString config_, name_x, name_c; PIString config_, name_x, name_c;
QDir dir; QDir dir;
QString outdir, kdesc_file, cdesc_file; QString outdir, kdesc_file, cdesc_file;
QFile file; QFile file;
QTime tm, ctm; QTime tm, ctm;
QIcon icon_record, icon_stop; QIcon icon_record, icon_stop;
QTextStream stream; QTextStream stream;
QTimer timer_diag; QTimer timer_diag;
QMap<int, KDesc> kdesc, cdesc; QMap<int, KDesc> kdesc, cdesc;
QMap<QString, int> knames; QMap<QString, int> knames;
QSet<int> calculated; QSet<int> calculated;
QStringList knames_sort; QStringList knames_sort;
QPIEvaluator eval; QPIEvaluator eval;
SessionManager session; SessionManager session;
QPIConfig config; QPIConfig config;
QMenu log_menu; QMenu log_menu;
//QVector<float> k, x; //QVector<float> k, x;
KX_Coefficients coeffs; KX_Coefficients coeffs;
__KX_Protocol_X * prot_x; __KX_Protocol_X * prot_x;
__KX_Protocol_C * prot_c; __KX_Protocol_C * prot_c;
int csize, wcnt, timer, timer_update, clear_target; int csize, wcnt, timer, timer_update, clear_target;
bool needWrite, isPause, need_update, show_x; bool needWrite, isPause, need_update, show_x;
private slots: private slots:
void loading(QPIConfig & conf); void loading(QPIConfig & conf);
void saving(QPIConfig & conf); void saving(QPIConfig & conf);
void updateGraph(); void updateGraph();
void updateDiag(); void updateDiag();
void updateKDesc(bool ask_move = false); void updateKDesc(bool ask_move = false);
void updateCDesc(); void updateCDesc();
void updateTree(bool move = false); void updateTree(bool move = false);
void updateCommands(); void updateCommands();
void filterTree(); void filterTree();
void calculate(); void calculate();
void renew(bool write = true); void renew(bool write = true);
void toggledX(int index, bool on); void toggledX(int index, bool on);
void changedX(int index, int num); void changedX(int index, int num);
void commandClicked(); void commandClicked();
void k_sendFailed(); void k_sendFailed();
void k_sendSucceed(); void k_sendSucceed();
void k_receiveFailed(); void k_receiveFailed();
void k_receiveSucceed(); void k_receiveSucceed();
void on_spinBuffer_editingFinished(); void on_spinBuffer_editingFinished();
void on_buttonSendK_clicked(); void on_buttonSendK_clicked();
void on_buttonReceiveK_clicked(); void on_buttonReceiveK_clicked();
void on_buttonShowAll_clicked(); void on_buttonShowAll_clicked();
void on_buttonHideAll_clicked(); void on_buttonHideAll_clicked();
void on_buttonRead_clicked(); void on_buttonRead_clicked();
void on_buttonWrite_clicked(); void on_buttonWrite_clicked();
void on_buttonResize_clicked(); void on_buttonResize_clicked();
void on_buttonSetKDesc_clicked(); void on_buttonSetKDesc_clicked();
void on_buttonReparseKDesc_clicked() {updateKDesc(true);} void on_buttonReparseKDesc_clicked() {updateKDesc(true);}
void on_buttonSetCDesc_clicked(); void on_buttonSetCDesc_clicked();
void on_buttonReparseCDesc_clicked() {updateCDesc();} void on_buttonReparseCDesc_clicked() {updateCDesc();}
void on_buttonCalculate_clicked() {calculate();} void on_buttonCalculate_clicked() {calculate();}
void on_buttonApply_clicked() {renew();} void on_buttonApply_clicked() {renew();}
void on_spinSize_valueChanged(int); void on_spinSize_valueChanged(int);
void on_buttonPause_toggled(bool on) {isPause = on;} void on_buttonPause_toggled(bool on) {isPause = on;}
void on_buttonRecord_clicked(); void on_buttonRecord_clicked();
void on_treeK_itemClicked(QTreeWidgetItem * item, int column); void on_treeK_itemClicked(QTreeWidgetItem * item, int column);
void on_treeK_itemChanged(QTreeWidgetItem * item, int column); void on_treeK_itemChanged(QTreeWidgetItem * item, int column);
void on_actionClear_triggered(); void on_actionClear_triggered();
signals: signals:
void q_k_sendFailed(); void q_k_sendFailed();
void q_k_sendSucceed(); void q_k_sendSucceed();
void q_k_receiveFailed(); void q_k_receiveFailed();
void q_k_receiveSucceed(); void q_k_receiveSucceed();
void recordStarted(const QString & fileName); void recordStarted(const QString & fileName);
void recordStopped(const QString & fileName); void recordStopped(const QString & fileName);
}; };
#endif // KX_PULT_H #endif // KX_PULT_H

View File

@@ -1,10 +1,10 @@
#include <QtGui/QApplication> #include <QtGui/QApplication>
#include "kx_pult.h" #include "kx_pult.h"
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
QApplication a(argc, argv); QApplication a(argc, argv);
KX_Pult w; KX_Pult w;
w.show(); w.show();
return a.exec(); return a.exec();
} }

0
make_libs.sh Executable file → Normal file
View File

2
pip

Submodule pip updated: cc580d9385...a4b3edb3e1

View File

@@ -1,50 +1,21 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0017 NEW) # need include() with .cmake cmake_policy(SET CMP0017 NEW) # need include() with .cmake
set(_PIQt_MAJOR 1)
set(_PIQt_MINOR 0) macro(piqt_library NAME _MODULES _LIBS)
set(_PIQt_REVISION 0) _qt_project(${NAME} FALSE "PIQt" "${_MODULES}" "pip;${_LIBS}" ${ARGN})
set(_PIQt_SUFFIX ) _qt_install(${NAME} FALSE "pip" "out_HDR" "out_QM")
set(_PIQt_COMPANY SHS) endmacro()
set(_PIQt_DOMAIN org.SHS)
if(NOT DEFINED BUILD_NUMBER) macro(piqt_application NAME _MODULES _LIBS)
set(BUILD_NUMBER 9999) _qt_project(${NAME} TRUE "PIQt" "${_MODULES}" "pip;${_LIBS}" ${ARGN})
endif() _qt_install(${NAME} TRUE "pip" "" "out_QM")
set(PIQt_LIB_TYPE SHARED) endmacro()
set(QAD_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/piqt_version.h")
set_version(PIQt include_directories(${PIP_INCLUDES})
MAJOR "${_PIQt_MAJOR}" add_subdirectory(libs)
MINOR "${_PIQt_MINOR}" if (UTILS)
REVISION "${_PIQt_REVISION}" add_subdirectory(utils)
BUILD "${BUILD_NUMBER}" endif()
SUFFIX "${_PIQt_SUFFIX}"
OUTPUT "${PIQt_VERSION_FILE}") copy_to_parent(piqt_includes)
set_deploy_property(PIQt ${_PIQt_LIB_TYPE}
FULLNAME "${_PIQt_DOMAIN}.*"
COMPANY "${_PIQt_COMPANY}")
include(QADMacros)
macro(piqt_library NAME _MODULES _LIBS)
_qt_project(${NAME} FALSE "PIQt" "${_MODULES}" "pip;${_LIBS}" ${ARGN})
_qt_install(${NAME} FALSE "pip" "out_HDR" "out_QM")
endmacro()
macro(piqt_application NAME _MODULES _LIBS)
_qt_project(${NAME} TRUE "PIQt" "${_MODULES}" "pip;${_LIBS}" ${ARGN})
_qt_install(${NAME} TRUE "pip" "" "out_QM")
endmacro()
include_directories(${PIP_INCLUDES})
add_subdirectory(libs)
if (UTILS)
add_subdirectory(utils)
endif()
set(QT_MULTILIB_LIST ${QT_MULTILIB_LIST} PARENT_SCOPE)
set(piqt_includes ${piqt_includes} PARENT_SCOPE)
if (LIB)
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
endif()

View File

@@ -29,13 +29,14 @@
#if QT_VERSION >= 0x050200 #if QT_VERSION >= 0x050200
# include "pigeoposition.h" # include "pigeoposition.h"
#endif #endif
#include "piqt_export.h"
class QGeoCoordinate; class QGeoCoordinate;
const QVariant PI2QVariant(const PIVariant & v); PIQT_EXPORT const QVariant PI2QVariant(const PIVariant & v);
const PIVariant Q2PIVariant(const QVariant & v); PIQT_EXPORT const PIVariant Q2PIVariant(const QVariant & v);
//inline const QString PI2QString(const PIString & v) {return QString::fromLocal8Bit(v.data());} //inline const QString PI2QString(const PIString & v) {return QString::fromLocal8Bit(v.data());}
inline const QString PI2QString(const PIString & v) {return QString::fromUtf8(v.dataUTF8());} inline const QString PI2QString(const PIString & v) {return QString::fromUtf8(v.dataUTF8());}
@@ -124,20 +125,20 @@ inline PropertyStorage PI2QPropertyStorage(const PIPropertyStorage & props) {
} }
const QAD::Enum PI2QADEnum(const PIVariantTypes::Enum & el); PIQT_EXPORT const QAD::Enum PI2QADEnum(const PIVariantTypes::Enum & el);
const QAD::File PI2QADFile(const PIVariantTypes::File & v); PIQT_EXPORT const QAD::File PI2QADFile(const PIVariantTypes::File & v);
const QAD::Dir PI2QADDir(const PIVariantTypes::Dir & v); PIQT_EXPORT const QAD::Dir PI2QADDir(const PIVariantTypes::Dir & v);
const QAD::IODevice PI2QADIODevice(const PIVariantTypes::IODevice & v); PIQT_EXPORT const QAD::IODevice PI2QADIODevice(const PIVariantTypes::IODevice & v);
const PIVariantTypes::Enum QAD2PIEnum(const QAD::Enum & el); PIQT_EXPORT const PIVariantTypes::Enum QAD2PIEnum(const QAD::Enum & el);
const PIVariantTypes::File QAD2PIFile(const QAD::File & v); PIQT_EXPORT const PIVariantTypes::File QAD2PIFile(const QAD::File & v);
const PIVariantTypes::Dir QAD2PIDir(const QAD::Dir & v); PIQT_EXPORT const PIVariantTypes::Dir QAD2PIDir(const QAD::Dir & v);
const PIVariantTypes::IODevice QAD2PIIODevice(const QAD::IODevice & v); PIQT_EXPORT const PIVariantTypes::IODevice QAD2PIIODevice(const QAD::IODevice & v);
//inline const PIVariant QString2PIVariant(const QString & v) {return PIVariant::readFromString(QString2PIString(v));} //inline const PIVariant QString2PIVariant(const QString & v) {return PIVariant::readFromString(QString2PIString(v));}
#if QT_VERSION >= 0x050200 #if QT_VERSION >= 0x050200
const QGeoCoordinate PI2QGeoPosition(const PIGeoPosition & v); PIQT_EXPORT const QGeoCoordinate PI2QGeoPosition(const PIGeoPosition & v);
const PIGeoPosition Q2PIGeoPosition(const QGeoCoordinate & v); PIQT_EXPORT const PIGeoPosition Q2PIGeoPosition(const QGeoCoordinate & v);
#endif #endif
template <typename From> template <typename From>

View File

@@ -25,8 +25,10 @@
#include "piconnection.h" #include "piconnection.h"
#include "qpiconfig.h" #include "qpiconfig.h"
#include "piqt.h" #include "piqt.h"
#include "piqt_export.h"
class QPIConnection: public QObject, public PIConnection {
class PIQT_EXPORT QPIConnection: public QObject, public PIConnection {
Q_OBJECT Q_OBJECT
PIOBJECT_SUBCLASS(QPIConnection, PIConnection) PIOBJECT_SUBCLASS(QPIConnection, PIConnection)
public: public:

View File

@@ -25,12 +25,13 @@
#include <QVariant> #include <QVariant>
#include "piobject.h" #include "piobject.h"
#include "cdutils_types.h" #include "cdutils_types.h"
#include "qcd_utils_export.h"
class QCDCore; class QCDCore;
class __QCore_Initializer__ { class QCD_UTILS_EXPORT __QCore_Initializer__ {
public: public:
__QCore_Initializer__(); __QCore_Initializer__();
~__QCore_Initializer__(); ~__QCore_Initializer__();
@@ -39,7 +40,7 @@ public:
}; };
class QCDCore: public QObject, public PIObject class QCD_UTILS_EXPORT QCDCore: public QObject, public PIObject
{ {
Q_OBJECT Q_OBJECT
PIOBJECT(QCDCore) PIOBJECT(QCDCore)

View File

@@ -23,6 +23,7 @@
#include <QWidget> #include <QWidget>
#include <evalspinbox.h> #include <evalspinbox.h>
#include <pistring.h> #include <pistring.h>
#include "qcd_utils_export.h"
namespace CDUtils { namespace CDUtils {
class CDType; class CDType;
@@ -37,7 +38,7 @@ class Graphic;
class Graphic; class Graphic;
class CDGraphicWidget: public QWidget { class QCD_UTILS_EXPORT CDGraphicWidget: public QWidget {
Q_OBJECT Q_OBJECT
friend class CDGraphics; friend class CDGraphics;
friend class GDockWidget; friend class GDockWidget;

View File

@@ -32,7 +32,7 @@
<item> <item>
<widget class="Graphic" name="graphic"> <widget class="Graphic" name="graphic">
<property name="buttons"> <property name="buttons">
<set>Graphic::Autofit|Graphic::BorderInputs|Graphic::Clear|Graphic::Configure|Graphic::CursorAxis|Graphic::Fullscreen|Graphic::Legend|Graphic::OnlyExpandY|Graphic::Pause|Graphic::Save</set> <set>Graphic::Autofit|Graphic::BorderInputs|Graphic::Clear|Graphic::Configure|Graphic::CursorAxis|Graphic::Fullscreen|Graphic::Legend|Graphic::Pause|Graphic::Save</set>
</property> </property>
<property name="borderInputsVisible"> <property name="borderInputsVisible">
<bool>false</bool> <bool>false</bool>

View File

@@ -22,12 +22,13 @@
#include <QDialog> #include <QDialog>
#include <cdutils_types.h> #include <cdutils_types.h>
#include "qcd_utils_export.h"
namespace Ui { namespace Ui {
class QCDModeDialog; class QCDModeDialog;
} }
class QCDModeDialog: public QDialog class QCD_UTILS_EXPORT QCDModeDialog: public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@@ -309,10 +309,10 @@ int CDItemModel::columnCount(const QModelIndex &parent) const {
Qt::ItemFlags CDItemModel::flags(const QModelIndex & index) const { Qt::ItemFlags CDItemModel::flags(const QModelIndex & index) const {
if (!index.isValid()) return 0; if (!index.isValid()) return Qt::ItemFlags();
Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable; Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
CDItem * item = getItem(index); CDItem * item = getItem(index);
if (!item) return 0; if (!item) return Qt::ItemFlags();
if (item->type_ == CDItem::ItemCDType) { if (item->type_ == CDItem::ItemCDType) {
CDType & t(interface->section(item->buildPath())[item->index_]); CDType & t(interface->section(item->buildPath())[item->index_]);
if (t.cd_type() == CDType::cdK) { if (t.cd_type() == CDType::cdK) {

View File

@@ -24,6 +24,7 @@
#include <QItemDelegate> #include <QItemDelegate>
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include "pistring.h" #include "pistring.h"
#include "qcd_utils_export.h"
namespace CDUtils { namespace CDUtils {
class CDType; class CDType;
@@ -50,7 +51,7 @@ namespace QAD {
class CDItemModel; class CDItemModel;
class CDItem { class QCD_UTILS_EXPORT CDItem {
friend class CDItemModel; friend class CDItemModel;
friend class CDView; friend class CDView;
public: public:
@@ -78,7 +79,7 @@ private:
}; };
class CDDelegate : public QStyledItemDelegate class QCD_UTILS_EXPORT CDDelegate : public QStyledItemDelegate
{ {
Q_OBJECT Q_OBJECT
public: public:
@@ -94,7 +95,7 @@ public:
}; };
class CDItemModel : public QAbstractItemModel { class QCD_UTILS_EXPORT CDItemModel : public QAbstractItemModel {
Q_OBJECT Q_OBJECT
friend class CDView; friend class CDView;
public: public:

View File

@@ -20,8 +20,9 @@
#ifndef QCD_VIEW_H #ifndef QCD_VIEW_H
#define QCD_VIEW_H #define QCD_VIEW_H
#include "piobject.h"
#include <QTreeView> #include <QTreeView>
#include "piobject.h"
#include "qcd_utils_export.h"
namespace CDUtils { namespace CDUtils {
class CDType; class CDType;
@@ -31,7 +32,7 @@ namespace CDUtils {
class CDItemModel; class CDItemModel;
class QSortFilterProxyModel; class QSortFilterProxyModel;
class CDView: public QTreeView, public PIObject class QCD_UTILS_EXPORT CDView: public QTreeView, public PIObject
{ {
Q_OBJECT Q_OBJECT
PIOBJECT(CDView) PIOBJECT(CDView)

View File

@@ -22,6 +22,8 @@
#include <QDialog> #include <QDialog>
#include "piconnection.h" #include "piconnection.h"
#include "piqt_utils_export.h"
namespace Ui { namespace Ui {
class ConnectionEdit; class ConnectionEdit;
@@ -31,7 +33,7 @@ class FilterItem;
class DeviceItem; class DeviceItem;
class SenderItem; class SenderItem;
class ConnectionEdit: public QDialog { class PIQT_UTILS_EXPORT ConnectionEdit: public QDialog {
Q_OBJECT Q_OBJECT
public: public:
explicit ConnectionEdit(QWidget * parent = 0); explicit ConnectionEdit(QWidget * parent = 0);

View File

@@ -22,14 +22,20 @@
<widget class="QWidget" name="layoutWidget"> <widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QFrame" name="frame"> <widget class="QWidget" name="widget" native="true">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_10"> <layout class="QHBoxLayout" name="horizontalLayout_10">
<item> <item>
@@ -268,7 +274,7 @@
<string>Add</string> <string>Add</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../../../qad/libs/application/qad_application.qrc">
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset> <normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
</property> </property>
</widget> </widget>
@@ -282,8 +288,8 @@
<string>Modify</string> <string>Modify</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="piconnedit/piconnedit.qrc"> <iconset resource="../../../qad/libs/application/qad_application.qrc">
<normaloff>:/icons/document-save-.png</normaloff>:/icons/document-save-.png</iconset> <normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
@@ -330,7 +336,16 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -371,7 +386,16 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_7"> <layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -400,7 +424,16 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_8"> <layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -451,7 +484,16 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_9"> <layout class="QHBoxLayout" name="horizontalLayout_9">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -500,7 +542,16 @@
<item> <item>
<widget class="QWidget" name="widgetDT" native="true"> <widget class="QWidget" name="widgetDT" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_12"> <layout class="QHBoxLayout" name="horizontalLayout_12">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -535,7 +586,16 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_13"> <layout class="QHBoxLayout" name="horizontalLayout_13">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
</layout> </layout>
@@ -622,7 +682,7 @@
<string>Add</string> <string>Add</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../../../qad/libs/application/qad_application.qrc">
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset> <normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
</property> </property>
</widget> </widget>
@@ -636,7 +696,7 @@
<string>Modify</string> <string>Modify</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="piconnedit/piconnedit.qrc"> <iconset>
<normaloff>:/icons/document-save-.png</normaloff>:/icons/document-save-.png</iconset> <normaloff>:/icons/document-save-.png</normaloff>:/icons/document-save-.png</iconset>
</property> </property>
</widget> </widget>
@@ -727,7 +787,7 @@
<string>Add</string> <string>Add</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../../../qad/libs/application/qad_application.qrc">
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset> <normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
</property> </property>
</widget> </widget>
@@ -741,7 +801,7 @@
<string>Modify</string> <string>Modify</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="piconnedit/piconnedit.qrc"> <iconset>
<normaloff>:/icons/document-save-.png</normaloff>:/icons/document-save-.png</iconset> <normaloff>:/icons/document-save-.png</normaloff>:/icons/document-save-.png</iconset>
</property> </property>
</widget> </widget>
@@ -764,7 +824,7 @@
<string>Remove</string> <string>Remove</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../../../qad/libs/application/qad_application.qrc">
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset> <normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
</property> </property>
</widget> </widget>
@@ -775,8 +835,8 @@
<string>Clear</string> <string>Clear</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="piconnedit/piconnedit.qrc"> <iconset resource="../../../qad/libs/application/qad_application.qrc">
<normaloff>:/icons/edit-clear-.png</normaloff>:/icons/edit-clear-.png</iconset> <normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
@@ -840,7 +900,7 @@
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="piconnedit/piconnedit.qrc"/> <include location="../../../qad/libs/application/qad_application.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>
@@ -875,22 +935,6 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>lineName</sender>
<signal>editingFinished()</signal>
<receiver>ConnectionEdit</receiver>
<slot>recreateConnection()</slot>
<hints>
<hint type="sourcelabel">
<x>644</x>
<y>29</y>
</hint>
<hint type="destinationlabel">
<x>662</x>
<y>-5</y>
</hint>
</hints>
</connection>
</connections> </connections>
<slots> <slots>
<slot>recreateConnection()</slot> <slot>recreateConnection()</slot>

View File

@@ -22,13 +22,14 @@
#include "blockview.h" #include "blockview.h"
#include "piconnection.h" #include "piconnection.h"
#include "piqt_utils_export.h"
const int __CV_Device = 1; const int __CV_Device = 1;
const int __CV_Filter = 2; const int __CV_Filter = 2;
const int __CV_Sender = 3; const int __CV_Sender = 3;
class DeviceItem: public BlockItem { class PIQT_UTILS_EXPORT DeviceItem: public BlockItem {
public: public:
DeviceItem(); DeviceItem();
@@ -54,7 +55,7 @@ protected:
}; };
class FilterItem: public BlockItem { class PIQT_UTILS_EXPORT FilterItem: public BlockItem {
public: public:
FilterItem(); FilterItem();
@@ -84,7 +85,7 @@ protected:
}; };
class SenderItem: public BlockItem { class PIQT_UTILS_EXPORT SenderItem: public BlockItem {
public: public:
SenderItem(); SenderItem();
@@ -104,7 +105,7 @@ protected:
}; };
class ConnectionView: public BlockView { class PIQT_UTILS_EXPORT ConnectionView: public BlockView {
Q_OBJECT Q_OBJECT
public: public:
explicit ConnectionView(QWidget * parent = 0); explicit ConnectionView(QWidget * parent = 0);

View File

@@ -23,10 +23,11 @@
#include <QSyntaxHighlighter> #include <QSyntaxHighlighter>
#include <QTextCursor> #include <QTextCursor>
#include <QTextCharFormat> #include <QTextCharFormat>
#include "piqt_utils_export.h"
class QTextDocument; class QTextDocument;
class ConfigHighlighter : public QSyntaxHighlighter class PIQT_UTILS_EXPORT ConfigHighlighter : public QSyntaxHighlighter
{ {
Q_OBJECT Q_OBJECT
public: public:
@@ -37,7 +38,7 @@ public:
private: private:
void highlightBlock(const QString &text); void highlightBlock(const QString &text);
struct HighlightingRule { struct PIQT_UTILS_EXPORT HighlightingRule {
QRegExp pattern; QRegExp pattern;
QTextCharFormat format; QTextCharFormat format;
}; };

View File

@@ -22,13 +22,14 @@
#include <QWidget> #include <QWidget>
#include "qad_types.h" #include "qad_types.h"
#include "piqt_utils_export.h"
class QLineEdit; class QLineEdit;
class QToolButton; class QToolButton;
class IODeviceEditDialog; class IODeviceEditDialog;
class IODeviceEdit: public QWidget { class PIQT_UTILS_EXPORT IODeviceEdit: public QWidget {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
@@ -60,12 +61,14 @@ signals:
}; };
class __IODeviceEditRegistrator__ { class PIQT_UTILS_EXPORT __IODeviceEditRegistrator__ {
public: public:
__IODeviceEditRegistrator__(); __IODeviceEditRegistrator__();
}; };
static __IODeviceEditRegistrator__ __iodeviceeditregistrator__; static __IODeviceEditRegistrator__ __iodeviceeditregistrator__;
void QAD_IODevice_toString(const QVariant & v, QString & r); PIQT_UTILS_EXPORT void QAD_IODevice_toString(const QVariant & v, QString & r);
#endif // PIQT_IODEVICE_EDIT_H #endif // PIQT_IODEVICE_EDIT_H

View File

@@ -23,12 +23,13 @@
#include <QDialog> #include <QDialog>
#include "qad_types.h" #include "qad_types.h"
#include "propertystorage.h" #include "propertystorage.h"
#include "piqt_utils_export.h"
namespace Ui { namespace Ui {
class IODeviceEditDialog; class IODeviceEditDialog;
} }
class IODeviceEditDialog: public QDialog { class PIQT_UTILS_EXPORT IODeviceEditDialog: public QDialog {
Q_OBJECT Q_OBJECT
public: public:
explicit IODeviceEditDialog(QWidget * parent = 0); explicit IODeviceEditDialog(QWidget * parent = 0);

View File

@@ -1,4 +0,0 @@
<RCC>
<qresource prefix="/">
</qresource>
</RCC>

View File

@@ -7,7 +7,7 @@ else()
set(APP_ICON "icons/qpicalculator.png") set(APP_ICON "icons/qpicalculator.png")
endif() endif()
set(APP_INFO "Small calculator ang grapher") set(APP_INFO "Small calculator ang grapher")
qad_application(${PROJECT_NAME} "Gui;Widgets" "qad_utils;qad_widgets;qad_graphic") qad_application(${PROJECT_NAME} "Gui;Widgets" "qad_utils;qad_widgets;qad_graphic;pip;piqt")
if (Qt5_FOUND) if (Qt5_FOUND)
import_version(${PROJ_NAME}5 ${PROJECT_NAME}) import_version(${PROJ_NAME}5 ${PROJECT_NAME})
deploy_target(${PROJECT_NAME}5 DEPLOY_DIR ${CMAKE_CURRENT_BINARY_DIR} DESTINATION ${ROOT_DIR}/release) deploy_target(${PROJECT_NAME}5 DEPLOY_DIR ${CMAKE_CURRENT_BINARY_DIR} DESTINATION ${ROOT_DIR}/release)

View File

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 158 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -1,4 +1,5 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "piqt.h"
MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow() { MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow() {
@@ -62,7 +63,7 @@ void MainWindow::redrawGraphics() {
graphic->setGraphicName(ti->text(1), i); graphic->setGraphicName(ti->text(1), i);
pol.clear(); pol.clear();
if (ti->checkState(0) == Qt::Checked) { if (ti->checkState(0) == Qt::Checked) {
if (evaluator.check(ti->text(1))) { if (evaluator.check(Q2PIString(ti->text(1)))) {
cx = sx; cx = sx;
while (cx < fx) { while (cx < fx) {
evaluator.setVariable(vi, complexd(cx, 0.)); evaluator.setVariable(vi, complexd(cx, 0.));
@@ -140,19 +141,19 @@ void MainWindow::saving(QPIConfig & conf) {
void MainWindow::on_lineInput_textChanged(QString text) { void MainWindow::on_lineInput_textChanged(QString text) {
if (evaluator.check(text)) lineInput->setPalette(npal); if (evaluator.check(Q2PIString(text))) lineInput->setPalette(npal);
else lineInput->setPalette(epal); else lineInput->setPalette(epal);
labelParsed->setText(evaluator.expression()); labelParsed->setText(PI2QString(evaluator.expression()));
labelError->setText(evaluator.error()); labelError->setText(PI2QString(evaluator.error()));
} }
void MainWindow::on_lineInput_returnPressed() { void MainWindow::on_lineInput_returnPressed() {
bool ret = evaluator.check(lineInput->text()); bool ret = evaluator.check(Q2PIString(lineInput->text()));
if (ret) lineInput->setPalette(npal); if (ret) lineInput->setPalette(npal);
else lineInput->setPalette(epal); else lineInput->setPalette(epal);
labelParsed->setText(evaluator.expression()); labelParsed->setText(PI2QString(evaluator.expression()));
labelError->setText(evaluator.error()); labelError->setText(PI2QString(evaluator.error()));
if (!ret) return; if (!ret) return;
complexd val = evaluator.evaluate(); complexd val = evaluator.evaluate();
evaluator.setVariable(ans, val); evaluator.setVariable(ans, val);
@@ -182,6 +183,16 @@ void MainWindow::on_lineInput_returnPressed() {
} }
void MainWindow::on_treeGraphics_itemSelectionChanged() {
buttonGraphicDel->setDisabled(treeGraphics->selectedItems().isEmpty());
if (treeGraphics->currentItem()) {
int ind = treeGraphics->indexOfTopLevelItem(treeGraphics->currentItem());
if (ind < 0 || ind >= graphic->graphicsCount()) return;
graphic->setCurrentGraphic(ind);
}
}
void MainWindow::on_treeGraphics_itemDoubleClicked(QTreeWidgetItem * item, int column) { void MainWindow::on_treeGraphics_itemDoubleClicked(QTreeWidgetItem * item, int column) {
Qt::ItemFlags f = item->flags(); Qt::ItemFlags f = item->flags();
if (column != 1) f &= ~Qt::ItemIsEditable; if (column != 1) f &= ~Qt::ItemIsEditable;
@@ -254,7 +265,7 @@ void MainWindow::on_tabWidget_currentChanged(int index) {
vn = treeVariables->topLevelItem(i)->text(0); vn = treeVariables->topLevelItem(i)->text(0);
vv = treeVariables->topLevelItem(i)->text(1); vv = treeVariables->topLevelItem(i)->text(1);
eval.check(vv); eval.check(vv);
evaluator.setVariable(vn, eval.evaluate()); evaluator.setVariable(Q2PIString(vn), eval.evaluate());
} }
if (index == 0) on_lineInput_returnPressed(); if (index == 0) on_lineInput_returnPressed();
if (index == 2) redrawGraphics(); if (index == 2) redrawGraphics();

View File

@@ -8,7 +8,7 @@
#include <QScrollBar> #include <QScrollBar>
#include <QColorDialog> #include <QColorDialog>
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "qpievaluator.h" #include "pievaluator.h"
#include "session_manager.h" #include "session_manager.h"
@@ -26,7 +26,7 @@ private:
void updateGraphics(); void updateGraphics();
void redrawGraphics(); void redrawGraphics();
QPIEvaluator evaluator; PIEvaluator evaluator;
QPalette npal, epal; QPalette npal, epal;
SessionManager session; SessionManager session;
int ans; int ans;
@@ -39,7 +39,7 @@ private slots:
void on_lineInput_returnPressed(); void on_lineInput_returnPressed();
void on_treeHistory_itemDoubleClicked(QTreeWidgetItem * item, int column) {lineInput->setText(item->text(0));} void on_treeHistory_itemDoubleClicked(QTreeWidgetItem * item, int column) {lineInput->setText(item->text(0));}
void on_treeVariables_itemSelectionChanged() {buttonVarDel->setDisabled(treeVariables->selectedItems().isEmpty());} void on_treeVariables_itemSelectionChanged() {buttonVarDel->setDisabled(treeVariables->selectedItems().isEmpty());}
void on_treeGraphics_itemSelectionChanged() {buttonGraphicDel->setDisabled(treeGraphics->selectedItems().isEmpty());} void on_treeGraphics_itemSelectionChanged();
void on_treeGraphics_itemChanged(QTreeWidgetItem * , int col) { if (active_) redrawGraphics();} void on_treeGraphics_itemChanged(QTreeWidgetItem * , int col) { if (active_) redrawGraphics();}
void on_treeGraphics_itemDoubleClicked(QTreeWidgetItem * item, int column); void on_treeGraphics_itemDoubleClicked(QTreeWidgetItem * item, int column);
void on_buttonVarAdd_clicked(); void on_buttonVarAdd_clicked();

View File

@@ -1,11 +1,11 @@
{ {
\"Name\" : \"ProjectFilesystemPlugin\", \"Name\" : \"ProjectFilesystemPlugin\",
\"Version\" : \"1.1.0\", \"Version\" : \"1.1.0\",
\"CompatVersion\" : \"1.1.0\", \"CompatVersion\" : \"1.1.0\",
\"Vendor\" : \"Peri4\", \"Vendor\" : \"Peri4\",
\"Copyright\" : \"(C) Peri4\", \"Copyright\" : \"(C) Peri4\",
\"License\" : \"LGPLv3\", \"License\" : \"LGPLv3\",
\"Description\" : \"LGPLv3\", \"Description\" : \"LGPLv3\",
\"Url\" : \"\", \"Url\" : \"\",
$$dependencyList $$dependencyList
} }

View File

@@ -1,91 +1,91 @@
#include "filterdialog.h" #include "filterdialog.h"
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
#include <QDir> #include <QDir>
FilterDialog::FilterDialog(QWidget * parent): QDialog(parent) { FilterDialog::FilterDialog(QWidget * parent): QDialog(parent) {
setupUi(this); setupUi(this);
toolButton->setIcon(Utils::Icons::CLEAN.icon()); toolButton->setIcon(Utils::Icons::CLEAN.icon());
toolButton_2->setIcon(Utils::Icons::CLEAN.icon()); toolButton_2->setIcon(Utils::Icons::CLEAN.icon());
toolButton_3->setIcon(Utils::Icons::CLEAN.icon()); toolButton_3->setIcon(Utils::Icons::CLEAN.icon());
toolButton_4->setIcon(Utils::Icons::CLEAN.icon()); toolButton_4->setIcon(Utils::Icons::CLEAN.icon());
} }
void FilterDialog::changeEvent(QEvent *e) { void FilterDialog::changeEvent(QEvent *e) {
QDialog::changeEvent(e); QDialog::changeEvent(e);
switch (e->type()) { switch (e->type()) {
case QEvent::LanguageChange: case QEvent::LanguageChange:
retranslateUi(this); retranslateUi(this);
break; break;
default: default:
break; break;
} }
} }
FilterDialog::Filter FilterDialog::filter() const { FilterDialog::Filter FilterDialog::filter() const {
FilterDialog::Filter ret; FilterDialog::Filter ret;
ret.files_show = getFilters(lineFilesShow); ret.files_show = getFilters(lineFilesShow);
ret.files_hide = getFilters(lineFilesHide); ret.files_hide = getFilters(lineFilesHide);
ret.dirs_show = getFilters(lineDirsShow); ret.dirs_show = getFilters(lineDirsShow);
ret.dirs_hide = getFilters(lineDirsHide); ret.dirs_hide = getFilters(lineDirsHide);
return ret; return ret;
} }
void FilterDialog::setFilter(const FilterDialog::Filter & f) { void FilterDialog::setFilter(const FilterDialog::Filter & f) {
setFilters(lineFilesShow, f.files_show); setFilters(lineFilesShow, f.files_show);
setFilters(lineFilesHide, f.files_hide); setFilters(lineFilesHide, f.files_hide);
setFilters(lineDirsShow, f.dirs_show); setFilters(lineDirsShow, f.dirs_show);
setFilters(lineDirsHide, f.dirs_hide); setFilters(lineDirsHide, f.dirs_hide);
} }
QStringList FilterDialog::getFilters(QLineEdit * le) const { QStringList FilterDialog::getFilters(QLineEdit * le) const {
if (!le) return QStringList(); if (!le) return QStringList();
QStringList ret = le->text().split(","); QStringList ret = le->text().split(",");
for (int i = 0; i < ret.size(); ++i) for (int i = 0; i < ret.size(); ++i)
ret[i] = ret[i].trimmed(); ret[i] = ret[i].trimmed();
ret.removeAll(""); ret.removeAll("");
return ret; return ret;
} }
void FilterDialog::setFilters(QLineEdit * le, QStringList f) { void FilterDialog::setFilters(QLineEdit * le, QStringList f) {
if (!le) return; if (!le) return;
le->setText(f.join(",")); le->setText(f.join(","));
} }
FilterDialog::Filter::Filter(const QVariant & v) { FilterDialog::Filter::Filter(const QVariant & v) {
QByteArray ba = v.toByteArray(); QByteArray ba = v.toByteArray();
if (ba.isEmpty()) return; if (ba.isEmpty()) return;
QDataStream s(ba); QDataStream s(ba);
s >> files_show >> files_hide >> dirs_show >> dirs_hide; s >> files_show >> files_hide >> dirs_show >> dirs_hide;
} }
QVariant FilterDialog::Filter::toVariant() const { QVariant FilterDialog::Filter::toVariant() const {
QByteArray ba; QByteArray ba;
QDataStream s(&ba, QIODevice::ReadWrite); QDataStream s(&ba, QIODevice::ReadWrite);
s << files_show << files_hide << dirs_show << dirs_hide; s << files_show << files_hide << dirs_show << dirs_hide;
return QVariant(ba); return QVariant(ba);
} }
bool FilterDialog::Filter::filterLogic(const QStringList & fshow, const QStringList & fhide, const QString & path) const { bool FilterDialog::Filter::filterLogic(const QStringList & fshow, const QStringList & fhide, const QString & path) const {
if (fshow.isEmpty() && fhide.isEmpty()) return true; if (fshow.isEmpty() && fhide.isEmpty()) return true;
if (!fhide.isEmpty()) { if (!fhide.isEmpty()) {
if (QDir::match(fhide, path)) if (QDir::match(fhide, path))
return false; return false;
else { else {
if (fshow.isEmpty()) if (fshow.isEmpty())
return true; return true;
else else
return QDir::match(fshow, path); return QDir::match(fshow, path);
} }
} }
if (!fshow.isEmpty()) if (!fshow.isEmpty())
return QDir::match(fshow, path); return QDir::match(fshow, path);
return true; return true;
} }

View File

@@ -1,37 +1,37 @@
#ifndef FILTERDIALOG_H #ifndef FILTERDIALOG_H
#define FILTERDIALOG_H #define FILTERDIALOG_H
#include "ui_filterdialog.h" #include "ui_filterdialog.h"
class FilterDialog: public QDialog, private Ui::FilterDialog class FilterDialog: public QDialog, private Ui::FilterDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit FilterDialog(QWidget *parent = 0); explicit FilterDialog(QWidget *parent = 0);
struct Filter { struct Filter {
Filter() {} Filter() {}
Filter(const QVariant & v); Filter(const QVariant & v);
QVariant toVariant() const; QVariant toVariant() const;
bool filterFile(const QString & path) const {return filterLogic(files_show, files_hide, path);} bool filterFile(const QString & path) const {return filterLogic(files_show, files_hide, path);}
bool filterDir(const QString & path) const {return filterLogic(dirs_show, dirs_hide, path);} bool filterDir(const QString & path) const {return filterLogic(dirs_show, dirs_hide, path);}
QStringList files_show; QStringList files_show;
QStringList files_hide; QStringList files_hide;
QStringList dirs_show; QStringList dirs_show;
QStringList dirs_hide; QStringList dirs_hide;
private: private:
bool filterLogic(const QStringList & fshow, const QStringList & fhide, const QString & path) const; bool filterLogic(const QStringList & fshow, const QStringList & fhide, const QString & path) const;
}; };
Filter filter() const; Filter filter() const;
void setFilter(const Filter & f); void setFilter(const Filter & f);
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
QStringList getFilters(QLineEdit * le) const; QStringList getFilters(QLineEdit * le) const;
void setFilters(QLineEdit * le, QStringList f); void setFilters(QLineEdit * le, QStringList f);
}; };
#endif // FILTERDIALOG_H #endif // FILTERDIALOG_H

View File

@@ -1,226 +1,226 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>FilterDialog</class> <class>FilterDialog</class>
<widget class="QDialog" name="FilterDialog"> <widget class="QDialog" name="FilterDialog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>342</width> <width>342</width>
<height>250</height> <height>250</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Project filesystem filters</string> <string>Project filesystem filters</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Input filters, separated by &quot;,&quot;:</string> <string>Input filters, separated by &quot;,&quot;:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="text"> <property name="text">
<string>Show dirs:</string> <string>Show dirs:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLineEdit" name="lineFilesHide"/> <widget class="QLineEdit" name="lineFilesHide"/>
</item> </item>
<item row="1" column="2"> <item row="1" column="2">
<widget class="QToolButton" name="toolButton_2"/> <widget class="QToolButton" name="toolButton_2"/>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Hide files:</string> <string>Hide files:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Show files:</string> <string>Show files:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLineEdit" name="lineFilesShow"/> <widget class="QLineEdit" name="lineFilesShow"/>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QToolButton" name="toolButton"/> <widget class="QToolButton" name="toolButton"/>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
<string>Hide dirs:</string> <string>Hide dirs:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QLineEdit" name="lineDirsShow"/> <widget class="QLineEdit" name="lineDirsShow"/>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QLineEdit" name="lineDirsHide"/> <widget class="QLineEdit" name="lineDirsHide"/>
</item> </item>
<item row="2" column="2"> <item row="2" column="2">
<widget class="QToolButton" name="toolButton_3"/> <widget class="QToolButton" name="toolButton_3"/>
</item> </item>
<item row="3" column="2"> <item row="3" column="2">
<widget class="QToolButton" name="toolButton_4"/> <widget class="QToolButton" name="toolButton_4"/>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>lineFilesShow</tabstop> <tabstop>lineFilesShow</tabstop>
<tabstop>lineFilesHide</tabstop> <tabstop>lineFilesHide</tabstop>
<tabstop>lineDirsShow</tabstop> <tabstop>lineDirsShow</tabstop>
<tabstop>lineDirsHide</tabstop> <tabstop>lineDirsHide</tabstop>
<tabstop>toolButton</tabstop> <tabstop>toolButton</tabstop>
<tabstop>toolButton_2</tabstop> <tabstop>toolButton_2</tabstop>
<tabstop>toolButton_3</tabstop> <tabstop>toolButton_3</tabstop>
<tabstop>toolButton_4</tabstop> <tabstop>toolButton_4</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections> <connections>
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>accepted()</signal> <signal>accepted()</signal>
<receiver>FilterDialog</receiver> <receiver>FilterDialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>259</x> <x>259</x>
<y>238</y> <y>238</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>157</x> <x>157</x>
<y>274</y> <y>274</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>rejected()</signal> <signal>rejected()</signal>
<receiver>FilterDialog</receiver> <receiver>FilterDialog</receiver>
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>327</x> <x>327</x>
<y>238</y> <y>238</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>286</x> <x>286</x>
<y>274</y> <y>274</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>toolButton</sender> <sender>toolButton</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
<receiver>lineFilesShow</receiver> <receiver>lineFilesShow</receiver>
<slot>clear()</slot> <slot>clear()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>329</x> <x>329</x>
<y>60</y> <y>60</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>269</x> <x>269</x>
<y>58</y> <y>58</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>toolButton_2</sender> <sender>toolButton_2</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
<receiver>lineFilesHide</receiver> <receiver>lineFilesHide</receiver>
<slot>clear()</slot> <slot>clear()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>329</x> <x>329</x>
<y>93</y> <y>93</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>295</x> <x>295</x>
<y>91</y> <y>91</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>toolButton_3</sender> <sender>toolButton_3</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
<receiver>lineDirsShow</receiver> <receiver>lineDirsShow</receiver>
<slot>clear()</slot> <slot>clear()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>329</x> <x>329</x>
<y>126</y> <y>126</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>295</x> <x>295</x>
<y>124</y> <y>124</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>toolButton_4</sender> <sender>toolButton_4</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
<receiver>lineDirsHide</receiver> <receiver>lineDirsHide</receiver>
<slot>clear()</slot> <slot>clear()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>329</x> <x>329</x>
<y>159</y> <y>159</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>295</x> <x>295</x>
<y>157</y> <y>157</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
</connections> </connections>
</ui> </ui>

View File

@@ -1,6 +1,6 @@
<RCC> <RCC>
<qresource prefix="/"> <qresource prefix="/">
<file>icons/edit-find.png</file> <file>icons/edit-find.png</file>
<file>icons/utilities-terminal.png</file> <file>icons/utilities-terminal.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -1,89 +1,89 @@
#include "projectfilesystemplugin.h" #include "projectfilesystemplugin.h"
#include "projectfilesystempluginconstants.h" #include "projectfilesystempluginconstants.h"
#include "projectfilesystemwidget.h" #include "projectfilesystemwidget.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/icontext.h> #include <coreplugin/icontext.h>
#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h> #include <coreplugin/actionmanager/command.h>
#include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <utils/macroexpander.h> #include <utils/macroexpander.h>
#include <QAction> #include <QAction>
#include <QMessageBox> #include <QMessageBox>
#include <QMainWindow> #include <QMainWindow>
#include <QMenu> #include <QMenu>
#include <QDebug> #include <QDebug>
namespace ProjectFilesystemPlugin { namespace ProjectFilesystemPlugin {
namespace Internal { namespace Internal {
ProjectFilesystemPluginPlugin::ProjectFilesystemPluginPlugin() ProjectFilesystemPluginPlugin::ProjectFilesystemPluginPlugin()
{ {
// Create your members // Create your members
} }
ProjectFilesystemPluginPlugin::~ProjectFilesystemPluginPlugin() ProjectFilesystemPluginPlugin::~ProjectFilesystemPluginPlugin()
{ {
// Unregister objects from the plugin manager's object pool // Unregister objects from the plugin manager's object pool
// Delete members // Delete members
} }
bool ProjectFilesystemPluginPlugin::initialize(const QStringList &arguments, QString *errorString) bool ProjectFilesystemPluginPlugin::initialize(const QStringList &arguments, QString *errorString)
{ {
// Register objects in the plugin manager's object pool // Register objects in the plugin manager's object pool
// Load settings // Load settings
// Add actions to menus // Add actions to menus
// Connect to other plugins' signals // Connect to other plugins' signals
// In the initialize function, a plugin can be sure that the plugins it // In the initialize function, a plugin can be sure that the plugins it
// depends on have initialized their members. // depends on have initialized their members.
Q_UNUSED(arguments) Q_UNUSED(arguments)
Q_UNUSED(errorString) Q_UNUSED(errorString)
/*auto action = new QAction(tr("ProjectFilesystemPlugin Action"), this); /*auto action = new QAction(tr("ProjectFilesystemPlugin Action"), this);
Core::Command *cmd = Core::ActionManager::registerAction(action, Constants::ACTION_ID, Core::Command *cmd = Core::ActionManager::registerAction(action, Constants::ACTION_ID,
Core::Context(Core::Constants::C_GLOBAL)); Core::Context(Core::Constants::C_GLOBAL));
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Meta+A"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Meta+A")));
connect(action, &QAction::triggered, this, &ProjectFilesystemPluginPlugin::triggerAction); connect(action, &QAction::triggered, this, &ProjectFilesystemPluginPlugin::triggerAction);
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::MENU_ID); Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::MENU_ID);
menu->menu()->setTitle(tr("ProjectFilesystemPlugin")); menu->menu()->setTitle(tr("ProjectFilesystemPlugin"));
menu->addAction(cmd); menu->addAction(cmd);
Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu); Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu);
qDebug() << Core::IContext::widget();*/ qDebug() << Core::IContext::widget();*/
//addAutoReleasedObject(new ProjectFSWidgetFactory()); //addAutoReleasedObject(new ProjectFSWidgetFactory());
(new ProjectFSWidgetFactory())->setParent(this); (new ProjectFSWidgetFactory())->setParent(this);
return true; return true;
} }
void ProjectFilesystemPluginPlugin::extensionsInitialized() void ProjectFilesystemPluginPlugin::extensionsInitialized()
{ {
Utils::globalMacroExpander()->registerPrefix("ProjectFilesystem", "Project filesystem plugin", [](QString v) -> QString {return v;} ); Utils::globalMacroExpander()->registerPrefix("ProjectFilesystem", "Project filesystem plugin", [](QString v) -> QString {return v;} );
Utils::globalMacroExpander()->registerFileVariables("ProjectFilesystem", "Selected item", Utils::globalMacroExpander()->registerFileVariables("ProjectFilesystem", "Selected item",
[]() -> QString { return projectfs_menu_target.absoluteFilePath();}); []() -> QString { return projectfs_menu_target.absoluteFilePath();});
// Retrieve objects from the plugin manager's object pool // Retrieve objects from the plugin manager's object pool
// In the extensionsInitialized function, a plugin can be sure that all // In the extensionsInitialized function, a plugin can be sure that all
// plugins that depend on it are completely initialized. // plugins that depend on it are completely initialized.
} }
ExtensionSystem::IPlugin::ShutdownFlag ProjectFilesystemPluginPlugin::aboutToShutdown() ExtensionSystem::IPlugin::ShutdownFlag ProjectFilesystemPluginPlugin::aboutToShutdown()
{ {
// Save settings // Save settings
// Disconnect from signals that are not needed during shutdown // Disconnect from signals that are not needed during shutdown
// Hide UI (if you add UI that is not in the main window directly) // Hide UI (if you add UI that is not in the main window directly)
return SynchronousShutdown; return SynchronousShutdown;
} }
void ProjectFilesystemPluginPlugin::triggerAction() void ProjectFilesystemPluginPlugin::triggerAction()
{ {
QMessageBox::information(Core::ICore::mainWindow(), QMessageBox::information(Core::ICore::mainWindow(),
tr("Action Triggered"), tr("Action Triggered"),
tr("This is an action from ProjectFilesystemPlugin.")); tr("This is an action from ProjectFilesystemPlugin."));
} }
} // namespace Internal } // namespace Internal
} // namespace ProjectFilesystemPlugin } // namespace ProjectFilesystemPlugin

View File

@@ -1,29 +1,29 @@
#pragma once #pragma once
#include "projectfilesystemplugin_global.h" #include "projectfilesystemplugin_global.h"
#include "projectfilesystemwidgetplugin.h" #include "projectfilesystemwidgetplugin.h"
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
namespace ProjectFilesystemPlugin { namespace ProjectFilesystemPlugin {
namespace Internal { namespace Internal {
class ProjectFilesystemPluginPlugin : public ExtensionSystem::IPlugin class ProjectFilesystemPluginPlugin : public ExtensionSystem::IPlugin
{ {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "ProjectFilesystemPlugin.json") Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "ProjectFilesystemPlugin.json")
public: public:
ProjectFilesystemPluginPlugin(); ProjectFilesystemPluginPlugin();
~ProjectFilesystemPluginPlugin(); ~ProjectFilesystemPluginPlugin();
bool initialize(const QStringList &arguments, QString *errorString); bool initialize(const QStringList &arguments, QString *errorString);
void extensionsInitialized(); void extensionsInitialized();
ShutdownFlag aboutToShutdown(); ShutdownFlag aboutToShutdown();
private: private:
void triggerAction(); void triggerAction();
}; };
} // namespace Internal } // namespace Internal
} // namespace ProjectFilesystemPlugin } // namespace ProjectFilesystemPlugin

View File

@@ -1,61 +1,61 @@
DEFINES += PROJECTFILESYSTEMPLUGIN_LIBRARY DEFINES += PROJECTFILESYSTEMPLUGIN_LIBRARY
# ProjectFilesystemPlugin files # ProjectFilesystemPlugin files
SOURCES += projectfilesystemplugin.cpp \ SOURCES += projectfilesystemplugin.cpp \
projectfilesystemwidget.cpp \ projectfilesystemwidget.cpp \
projectfilesystemwidgetplugin.cpp \ projectfilesystemwidgetplugin.cpp \
filterdialog.cpp filterdialog.cpp
HEADERS += projectfilesystemplugin.h \ HEADERS += projectfilesystemplugin.h \
projectfilesystemplugin_global.h \ projectfilesystemplugin_global.h \
projectfilesystempluginconstants.h \ projectfilesystempluginconstants.h \
projectfilesystemwidget.h \ projectfilesystemwidget.h \
projectfilesystemwidgetplugin.h \ projectfilesystemwidgetplugin.h \
filterdialog.h filterdialog.h
FORMS += \ FORMS += \
projectfilesystemwidget.ui \ projectfilesystemwidget.ui \
filterdialog.ui filterdialog.ui
RESOURCES += \ RESOURCES += \
projectfilesystem.qrc projectfilesystem.qrc
#QT += network #QT += network
# Qt Creator linking # Qt Creator linking
## Either set the IDE_SOURCE_TREE when running qmake, ## Either set the IDE_SOURCE_TREE when running qmake,
## or set the QTC_SOURCE environment variable, to override the default setting ## or set the QTC_SOURCE environment variable, to override the default setting
isEmpty(IDE_SOURCE_TREE): IDE_SOURCE_TREE = $$(SDK_QTCREATOR_SRC) isEmpty(IDE_SOURCE_TREE): IDE_SOURCE_TREE = $$(SDK_QTCREATOR_SRC)
## Either set the IDE_BUILD_TREE when running qmake, ## Either set the IDE_BUILD_TREE when running qmake,
## or set the QTC_BUILD environment variable, to override the default setting ## or set the QTC_BUILD environment variable, to override the default setting
isEmpty(IDE_BUILD_TREE): IDE_BUILD_TREE = $$(SDK_QTCREATOR_BUILD) isEmpty(IDE_BUILD_TREE): IDE_BUILD_TREE = $$(SDK_QTCREATOR_BUILD)
## uncomment to build plugin into user config directory ## uncomment to build plugin into user config directory
## <localappdata>/plugins/<ideversion> ## <localappdata>/plugins/<ideversion>
## where <localappdata> is e.g. ## where <localappdata> is e.g.
## "%LOCALAPPDATA%\QtProject\qtcreator" on Windows Vista and later ## "%LOCALAPPDATA%\QtProject\qtcreator" on Windows Vista and later
## "$XDG_DATA_HOME/data/QtProject/qtcreator" or "~/.local/share/data/QtProject/qtcreator" on Linux ## "$XDG_DATA_HOME/data/QtProject/qtcreator" or "~/.local/share/data/QtProject/qtcreator" on Linux
## "~/Library/Application Support/QtProject/Qt Creator" on OS X ## "~/Library/Application Support/QtProject/Qt Creator" on OS X
#USE_USER_DESTDIR = yes #USE_USER_DESTDIR = yes
###### If the plugin can be depended upon by other plugins, this code needs to be outsourced to ###### If the plugin can be depended upon by other plugins, this code needs to be outsourced to
###### <dirname>_dependencies.pri, where <dirname> is the name of the directory containing the ###### <dirname>_dependencies.pri, where <dirname> is the name of the directory containing the
###### plugin's sources. ###### plugin's sources.
QTC_PLUGIN_NAME = ProjectFilesystemPlugin QTC_PLUGIN_NAME = ProjectFilesystemPlugin
QTC_LIB_DEPENDS += \ QTC_LIB_DEPENDS += \
# nothing here at this time # nothing here at this time
QTC_PLUGIN_DEPENDS += \ QTC_PLUGIN_DEPENDS += \
coreplugin \ coreplugin \
projectexplorer projectexplorer
QTC_PLUGIN_RECOMMENDS += \ QTC_PLUGIN_RECOMMENDS += \
# optional plugin dependencies. nothing here at this time # optional plugin dependencies. nothing here at this time
###### End _dependencies.pri contents ###### ###### End _dependencies.pri contents ######
include($$IDE_SOURCE_TREE/src/qtcreatorplugin.pri) include($$IDE_SOURCE_TREE/src/qtcreatorplugin.pri)

View File

@@ -1,9 +1,9 @@
#pragma once #pragma once
#include <QtGlobal> #include <QtGlobal>
#if defined(PROJECTFILESYSTEMPLUGIN_LIBRARY) #if defined(PROJECTFILESYSTEMPLUGIN_LIBRARY)
# define PROJECTFILESYSTEMPLUGINSHARED_EXPORT Q_DECL_EXPORT # define PROJECTFILESYSTEMPLUGINSHARED_EXPORT Q_DECL_EXPORT
#else #else
# define PROJECTFILESYSTEMPLUGINSHARED_EXPORT Q_DECL_IMPORT # define PROJECTFILESYSTEMPLUGINSHARED_EXPORT Q_DECL_IMPORT
#endif #endif

View File

@@ -1,10 +1,10 @@
#pragma once #pragma once
namespace ProjectFilesystemPlugin { namespace ProjectFilesystemPlugin {
namespace Constants { namespace Constants {
const char ACTION_ID[] = "ProjectFilesystemPlugin.Action"; const char ACTION_ID[] = "ProjectFilesystemPlugin.Action";
const char MENU_ID[] = "ProjectFilesystemPlugin.Menu"; const char MENU_ID[] = "ProjectFilesystemPlugin.Menu";
} // namespace ProjectFilesystemPlugin } // namespace ProjectFilesystemPlugin
} // namespace Constants } // namespace Constants

View File

@@ -1,328 +1,328 @@
#include "projectfilesystemwidget.h" #include "projectfilesystemwidget.h"
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h> #include <extensionsystem/pluginspec.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/fileutils.h> #include <coreplugin/fileutils.h>
#include <coreplugin/navigationwidget.h> #include <coreplugin/navigationwidget.h>
#include <coreplugin/fileiconprovider.h> #include <coreplugin/fileiconprovider.h>
#include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/editormanager/ieditor.h> #include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projecttreewidget.h> #include <projectexplorer/projecttreewidget.h>
#include <projectexplorer/projecttree.h> #include <projectexplorer/projecttree.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/projectnodes.h> #include <projectexplorer/projectnodes.h>
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
#include <utils/macroexpander.h> #include <utils/macroexpander.h>
#include <QApplication> #include <QApplication>
#include <QDesktopServices> #include <QDesktopServices>
#include <QMessageBox> #include <QMessageBox>
#include <QInputDialog> #include <QInputDialog>
#include <QScrollBar> #include <QScrollBar>
#include <QClipboard> #include <QClipboard>
QFileInfo projectfs_menu_target; QFileInfo projectfs_menu_target;
ProjectFilesystemWidget::ProjectFilesystemWidget(QWidget * parent): QWidget(parent) { ProjectFilesystemWidget::ProjectFilesystemWidget(QWidget * parent): QWidget(parent) {
setupUi(this); setupUi(this);
in_proc = need_rebuild = false; in_proc = need_rebuild = false;
int is = style()->pixelMetric(QStyle::PM_ButtonIconSize, 0, this); int is = style()->pixelMetric(QStyle::PM_ButtonIconSize, 0, this);
label->setFixedSize(is, is); label->setFixedSize(is, is);
buttonClear->setIcon(Utils::Icons::CLEAN.icon()); buttonClear->setIcon(Utils::Icons::CLEAN.icon());
buttonExpand->setIcon(Utils::Icons::EXPAND.icon()); buttonExpand->setIcon(Utils::Icons::EXPAND.icon());
buttonCollapse->setIcon(Utils::Icons::COLLAPSE.icon()); buttonCollapse->setIcon(Utils::Icons::COLLAPSE.icon());
actionOpen_here->setIcon(Utils::Icons::OPENFILE.icon()); actionOpen_here->setIcon(Utils::Icons::OPENFILE.icon());
actionOpen_external->setIcon(Utils::Icons::OPENFILE.icon()); actionOpen_external->setIcon(Utils::Icons::OPENFILE.icon());
actionShow_external->setIcon(Core::FileIconProvider::icon(QFileIconProvider::Folder)); actionShow_external->setIcon(Core::FileIconProvider::icon(QFileIconProvider::Folder));
actionCopy_name->setIcon(Utils::Icons::COPY.icon()); actionCopy_name->setIcon(Utils::Icons::COPY.icon());
actionCopy_path->setIcon(Utils::Icons::COPY.icon()); actionCopy_path->setIcon(Utils::Icons::COPY.icon());
popup_menu.addActions(QList<QAction*>() << actionOpen_here << actionOpen_external << actionShow_external << actionOpen_terminal); popup_menu.addActions(QList<QAction*>() << actionOpen_here << actionOpen_external << actionShow_external << actionOpen_terminal);
popup_menu.addSeparator(); popup_menu.addSeparator();
popup_menu.addActions(QList<QAction*>() << actionCopy_name << actionCopy_path); popup_menu.addActions(QList<QAction*>() << actionCopy_name << actionCopy_path);
proj_plug = 0; proj_plug = 0;
//connect(ProjectExplorer::ProjectTree::instance(), SIGNAL(subtreeChanged(ProjectExplorer::FolderNode*)), this, SLOT(projectsChanged())); //connect(ProjectExplorer::ProjectTree::instance(), SIGNAL(subtreeChanged(ProjectExplorer::FolderNode*)), this, SLOT(projectsChanged()));
connect(ProjectExplorer::SessionManager::instance(), SIGNAL(startupProjectChanged(ProjectExplorer::Project *)), this, SLOT(startupProjectChanged())); connect(ProjectExplorer::SessionManager::instance(), SIGNAL(startupProjectChanged(ProjectExplorer::Project *)), this, SLOT(startupProjectChanged()));
connect(ProjectExplorer::SessionManager::instance(), SIGNAL(projectAdded(ProjectExplorer::Project*)), this, SLOT(projectsChanged())); connect(ProjectExplorer::SessionManager::instance(), SIGNAL(projectAdded(ProjectExplorer::Project*)), this, SLOT(projectsChanged()));
connect(ProjectExplorer::SessionManager::instance(), SIGNAL(projectDisplayNameChanged(ProjectExplorer::Project*)), this, SLOT(projectsChanged())); connect(ProjectExplorer::SessionManager::instance(), SIGNAL(projectDisplayNameChanged(ProjectExplorer::Project*)), this, SLOT(projectsChanged()));
connect(ProjectExplorer::SessionManager::instance(), SIGNAL(projectRemoved(ProjectExplorer::Project*)), this, SLOT(projectsChanged())); connect(ProjectExplorer::SessionManager::instance(), SIGNAL(projectRemoved(ProjectExplorer::Project*)), this, SLOT(projectsChanged()));
//connect(ProjectExplorer::SessionManager::instance(), SIGNAL(), this, SLOT(startupProjectChanged())); //connect(ProjectExplorer::SessionManager::instance(), SIGNAL(), this, SLOT(startupProjectChanged()));
connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(fileChanged())); connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(fileChanged()));
projectsChanged(); projectsChanged();
} }
void ProjectFilesystemWidget::setCurrentFilter(const FilterDialog::Filter & v) { void ProjectFilesystemWidget::setCurrentFilter(const FilterDialog::Filter & v) {
cur_filter = v; cur_filter = v;
projectsChanged(); projectsChanged();
} }
void ProjectFilesystemWidget::changeEvent(QEvent *e) { void ProjectFilesystemWidget::changeEvent(QEvent *e) {
QWidget::changeEvent(e); QWidget::changeEvent(e);
switch (e->type()) { switch (e->type()) {
case QEvent::LanguageChange: case QEvent::LanguageChange:
retranslateUi(this); retranslateUi(this);
break; break;
default: default:
break; break;
} }
} }
void ProjectFilesystemWidget::createTree(QTreeWidgetItem * ti, const QString & dir) { void ProjectFilesystemWidget::createTree(QTreeWidgetItem * ti, const QString & dir) {
QFileInfoList fl = QDir(dir).entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot, QDir::LocaleAware | QDir::DirsFirst); QFileInfoList fl = QDir(dir).entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot, QDir::LocaleAware | QDir::DirsFirst);
checkProcEvents(); checkProcEvents();
for (QFileInfo i: fl) { for (QFileInfo i: fl) {
QString nit = i.fileName(); QString nit = i.fileName();
if (i.isDir()) { if (i.isDir()) {
if (!cur_filter.filterDir(nit)) if (!cur_filter.filterDir(nit))
continue; continue;
} else { } else {
if (!cur_filter.filterFile(nit)) if (!cur_filter.filterFile(nit))
continue; continue;
} }
QTreeWidgetItem * ni = new QTreeWidgetItem(); QTreeWidgetItem * ni = new QTreeWidgetItem();
ni->setText(0, nit); ni->setText(0, nit);
ni->setIcon(0, Core::FileIconProvider::icon(i)); ni->setIcon(0, Core::FileIconProvider::icon(i));
ni->setData(0, Qt::UserRole, i.absoluteFilePath()); ni->setData(0, Qt::UserRole, i.absoluteFilePath());
ni->setData(0, Qt::UserRole + 1, i.isDir()); ni->setData(0, Qt::UserRole + 1, i.isDir());
item_map[i.absoluteFilePath()] = ni; item_map[i.absoluteFilePath()] = ni;
if (i.isDir()) { if (i.isDir()) {
createTree(ni, dir + QDir::separator() + i.fileName()); createTree(ni, dir + QDir::separator() + i.fileName());
} }
ti->addChild(ni); ti->addChild(ni);
} }
//if (ti->childCount() == 0) delete ti; //if (ti->childCount() == 0) delete ti;
} }
bool ProjectFilesystemWidget::filterTree(QTreeWidgetItem * ti, const QString & filter) { bool ProjectFilesystemWidget::filterTree(QTreeWidgetItem * ti, const QString & filter) {
bool ret = false; bool ret = false;
for (int i = 0; i < ti->childCount(); ++i) { for (int i = 0; i < ti->childCount(); ++i) {
QTreeWidgetItem * ci = ti->child(i); QTreeWidgetItem * ci = ti->child(i);
QString cit = ci->text(0); QString cit = ci->text(0);
if (ci->data(0, Qt::UserRole + 1).toBool()) { if (ci->data(0, Qt::UserRole + 1).toBool()) {
if (!filterTree(ci, filter)) { if (!filterTree(ci, filter)) {
ci->setHidden(true); ci->setHidden(true);
continue; continue;
} }
ci->setHidden(false); ci->setHidden(false);
ret = true; ret = true;
} else { } else {
bool f = false; bool f = false;
if (filter.isEmpty()) { if (filter.isEmpty()) {
f = true; f = true;
} else { } else {
f = f || cit.contains(filter); f = f || cit.contains(filter);
} }
ci->setHidden(!f); ci->setHidden(!f);
if (f) ret = true; if (f) ret = true;
} }
} }
return ret; return ret;
} }
void ProjectFilesystemWidget::filter() { void ProjectFilesystemWidget::filter() {
QString f = lineFilter->text(); QString f = lineFilter->text();
for (int i = 0; i < tree->topLevelItemCount(); ++i) { for (int i = 0; i < tree->topLevelItemCount(); ++i) {
QTreeWidgetItem * ti = tree->topLevelItem(i); QTreeWidgetItem * ti = tree->topLevelItem(i);
filterTree(ti, f); filterTree(ti, f);
} }
} }
void ProjectFilesystemWidget::rememberExpanded(QTreeWidgetItem * ti) { void ProjectFilesystemWidget::rememberExpanded(QTreeWidgetItem * ti) {
//QMessageBox::information(0, ti->data(0, Qt::UserRole).toString(), QString::number(ti->childCount())); //QMessageBox::information(0, ti->data(0, Qt::UserRole).toString(), QString::number(ti->childCount()));
for (int i = 0; i < ti->childCount(); ++i) { for (int i = 0; i < ti->childCount(); ++i) {
QTreeWidgetItem * ci = ti->child(i); QTreeWidgetItem * ci = ti->child(i);
if (ci->data(0, Qt::UserRole + 1).toBool()) { if (ci->data(0, Qt::UserRole + 1).toBool()) {
if (ci->isExpanded()) if (ci->isExpanded())
last_expanded << ci->data(0, Qt::UserRole).toString(); last_expanded << ci->data(0, Qt::UserRole).toString();
rememberExpanded(ci); rememberExpanded(ci);
} }
} }
} }
void ProjectFilesystemWidget::restoreExpanded(QTreeWidgetItem * ti) { void ProjectFilesystemWidget::restoreExpanded(QTreeWidgetItem * ti) {
for (int i = 0; i < ti->childCount(); ++i) { for (int i = 0; i < ti->childCount(); ++i) {
QTreeWidgetItem * ci = ti->child(i); QTreeWidgetItem * ci = ti->child(i);
if (ci->data(0, Qt::UserRole + 1).toBool()) { if (ci->data(0, Qt::UserRole + 1).toBool()) {
if (last_expanded.contains(ci->data(0, Qt::UserRole).toString())) if (last_expanded.contains(ci->data(0, Qt::UserRole).toString()))
ci->setExpanded(true); ci->setExpanded(true);
restoreExpanded(ci); restoreExpanded(ci);
} }
} }
} }
void ProjectFilesystemWidget::setExtVariable() { void ProjectFilesystemWidget::setExtVariable() {
} }
void ProjectFilesystemWidget::checkProcEvents() { void ProjectFilesystemWidget::checkProcEvents() {
if (tm.elapsed() < 10) return; if (tm.elapsed() < 10) return;
QApplication::processEvents(); QApplication::processEvents();
tm.start(); tm.start();
} }
void ProjectFilesystemWidget::projectsChanged() { void ProjectFilesystemWidget::projectsChanged() {
if (in_proc) { if (in_proc) {
need_rebuild = true; need_rebuild = true;
return; return;
} }
in_proc = true; in_proc = true;
tm.start(); tm.start();
last_expanded.clear(); last_expanded.clear();
item_map.clear(); item_map.clear();
int spos = tree->verticalScrollBar()->value(); int spos = tree->verticalScrollBar()->value();
rememberExpanded(tree->invisibleRootItem()); rememberExpanded(tree->invisibleRootItem());
tree->clear(); tree->clear();
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
QList<ProjectExplorer::Project *> pl = ProjectExplorer::SessionManager::projects(); QList<ProjectExplorer::Project *> pl = ProjectExplorer::SessionManager::projects();
for (ProjectExplorer::Project * p: pl) { for (ProjectExplorer::Project * p: pl) {
QTreeWidgetItem * ri = new QTreeWidgetItem(); QTreeWidgetItem * ri = new QTreeWidgetItem();
QString dir = p->projectDirectory().toString(); QString dir = p->projectDirectory().toString();
ri->setText(0, p->displayName()); ri->setText(0, p->displayName());
QFile logo(dir + "/logo.png"); QFile logo(dir + "/logo.png");
if (logo.exists()) if (logo.exists())
ri->setIcon(0, QIcon(logo.fileName())); ri->setIcon(0, QIcon(logo.fileName()));
else else
ri->setIcon(0, Core::FileIconProvider::icon(QFileIconProvider::Folder)); ri->setIcon(0, Core::FileIconProvider::icon(QFileIconProvider::Folder));
ri->setData(0, Qt::UserRole, dir); ri->setData(0, Qt::UserRole, dir);
ri->setData(0, Qt::UserRole + 1, true); ri->setData(0, Qt::UserRole + 1, true);
createTree(ri, dir); createTree(ri, dir);
tree->addTopLevelItem(ri); tree->addTopLevelItem(ri);
} }
startupProjectChanged(); startupProjectChanged();
fileChanged(); fileChanged();
filter(); filter();
restoreExpanded(tree->invisibleRootItem()); restoreExpanded(tree->invisibleRootItem());
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
qApp->processEvents(); qApp->processEvents();
tree->verticalScrollBar()->setValue(spos); tree->verticalScrollBar()->setValue(spos);
in_proc = false; in_proc = false;
if (need_rebuild) { if (need_rebuild) {
need_rebuild = false; need_rebuild = false;
projectsChanged(); projectsChanged();
} }
} }
void ProjectFilesystemWidget::filterClicked() { void ProjectFilesystemWidget::filterClicked() {
filter_dialog.setFilter(cur_filter); filter_dialog.setFilter(cur_filter);
if (filter_dialog.exec() == QDialog::Rejected) return; if (filter_dialog.exec() == QDialog::Rejected) return;
setCurrentFilter(filter_dialog.filter()); setCurrentFilter(filter_dialog.filter());
} }
void ProjectFilesystemWidget::fileChanged() { void ProjectFilesystemWidget::fileChanged() {
Core::IDocument * cd = Core::EditorManager::instance()->currentDocument(); Core::IDocument * cd = Core::EditorManager::instance()->currentDocument();
if (!cd) return; if (!cd) return;
QString np = cd->filePath().toString(); QString np = cd->filePath().toString();
QTreeWidgetItem * ti = item_map.value(np); QTreeWidgetItem * ti = item_map.value(np);
if (!ti) return; if (!ti) return;
tree->setCurrentItem(ti); tree->setCurrentItem(ti);
tree->expandItem(ti); tree->expandItem(ti);
} }
void ProjectFilesystemWidget::startupProjectChanged() { void ProjectFilesystemWidget::startupProjectChanged() {
ProjectExplorer::Project * sp = ProjectExplorer::SessionManager::startupProject(); ProjectExplorer::Project * sp = ProjectExplorer::SessionManager::startupProject();
QFont f(tree->font()), bf(f); QFont f(tree->font()), bf(f);
bf.setBold(true); bf.setBold(true);
for (int i = 0; i < tree->topLevelItemCount(); ++i) { for (int i = 0; i < tree->topLevelItemCount(); ++i) {
QTreeWidgetItem * ti = tree->topLevelItem(i); QTreeWidgetItem * ti = tree->topLevelItem(i);
ti->setFont(0, f); ti->setFont(0, f);
if (!sp) continue; if (!sp) continue;
if (sp->projectDirectory().toString() == ti->data(0, Qt::UserRole).toString()) if (sp->projectDirectory().toString() == ti->data(0, Qt::UserRole).toString())
ti->setFont(0, bf); ti->setFont(0, bf);
} }
} }
void ProjectFilesystemWidget::on_tree_itemDoubleClicked(QTreeWidgetItem * item, int) { void ProjectFilesystemWidget::on_tree_itemDoubleClicked(QTreeWidgetItem * item, int) {
if (!item) return; if (!item) return;
QString afp = item->data(0, Qt::UserRole).toString(); QString afp = item->data(0, Qt::UserRole).toString();
bool dir = item->data(0, Qt::UserRole + 1).toBool(); bool dir = item->data(0, Qt::UserRole + 1).toBool();
if (dir) return; if (dir) return;
if (afp.isEmpty()) return; if (afp.isEmpty()) return;
Core::EditorManager::openEditor(afp); Core::EditorManager::openEditor(afp);
} }
void ProjectFilesystemWidget::on_lineFilter_textChanged(const QString & ) { void ProjectFilesystemWidget::on_lineFilter_textChanged(const QString & ) {
filter(); filter();
} }
void ProjectFilesystemWidget::on_tree_itemClicked(QTreeWidgetItem * item, int column) { void ProjectFilesystemWidget::on_tree_itemClicked(QTreeWidgetItem * item, int column) {
projectfs_menu_target = QFileInfo(); projectfs_menu_target = QFileInfo();
if (!item) { if (!item) {
setExtVariable(); setExtVariable();
return; return;
} }
projectfs_menu_target = QFileInfo(item->data(0, Qt::UserRole).toString()); projectfs_menu_target = QFileInfo(item->data(0, Qt::UserRole).toString());
setExtVariable(); setExtVariable();
} }
void ProjectFilesystemWidget::on_tree_customContextMenuRequested(const QPoint & pos) { void ProjectFilesystemWidget::on_tree_customContextMenuRequested(const QPoint & pos) {
projectfs_menu_target = QFileInfo(); projectfs_menu_target = QFileInfo();
QTreeWidgetItem * item = tree->itemAt(pos); QTreeWidgetItem * item = tree->itemAt(pos);
//QMessageBox::information(this, "", QString::number(index.row())); //QMessageBox::information(this, "", QString::number(index.row()));
if (!item) { if (!item) {
setExtVariable(); setExtVariable();
return; return;
} }
projectfs_menu_target = QFileInfo(item->data(0, Qt::UserRole).toString()); projectfs_menu_target = QFileInfo(item->data(0, Qt::UserRole).toString());
setExtVariable(); setExtVariable();
actionOpen_here->setEnabled(!projectfs_menu_target.isDir()); actionOpen_here->setEnabled(!projectfs_menu_target.isDir());
actionOpen_external->setEnabled(!projectfs_menu_target.isDir()); actionOpen_external->setEnabled(!projectfs_menu_target.isDir());
popup_menu.popup(tree->mapToGlobal(pos)); popup_menu.popup(tree->mapToGlobal(pos));
} }
void ProjectFilesystemWidget::on_actionOpen_here_triggered() { void ProjectFilesystemWidget::on_actionOpen_here_triggered() {
if (projectfs_menu_target.path().isEmpty()) return; if (projectfs_menu_target.path().isEmpty()) return;
Core::EditorManager::openEditor(projectfs_menu_target.absoluteFilePath(), Core::Constants::K_DEFAULT_TEXT_EDITOR_ID); Core::EditorManager::openEditor(projectfs_menu_target.absoluteFilePath(), Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
} }
void ProjectFilesystemWidget::on_actionOpen_external_triggered() { void ProjectFilesystemWidget::on_actionOpen_external_triggered() {
if (projectfs_menu_target.path().isEmpty()) return; if (projectfs_menu_target.path().isEmpty()) return;
QString wd = QDir::current().absolutePath(); QString wd = QDir::current().absolutePath();
QDir::setCurrent(projectfs_menu_target.absoluteDir().path()); QDir::setCurrent(projectfs_menu_target.absoluteDir().path());
QDesktopServices::openUrl(QUrl::fromLocalFile(projectfs_menu_target.absoluteFilePath())); QDesktopServices::openUrl(QUrl::fromLocalFile(projectfs_menu_target.absoluteFilePath()));
QDir::setCurrent(wd); QDir::setCurrent(wd);
} }
void ProjectFilesystemWidget::on_actionShow_external_triggered() { void ProjectFilesystemWidget::on_actionShow_external_triggered() {
if (projectfs_menu_target.path().isEmpty()) return; if (projectfs_menu_target.path().isEmpty()) return;
Core::FileUtils::showInGraphicalShell(Core::ICore::mainWindow(), projectfs_menu_target.absoluteFilePath()); Core::FileUtils::showInGraphicalShell(Core::ICore::mainWindow(), projectfs_menu_target.absoluteFilePath());
} }
void ProjectFilesystemWidget::on_actionOpen_terminal_triggered() { void ProjectFilesystemWidget::on_actionOpen_terminal_triggered() {
if (projectfs_menu_target.path().isEmpty()) return; if (projectfs_menu_target.path().isEmpty()) return;
Core::FileUtils::openTerminal(QDir(projectfs_menu_target.absoluteFilePath()).path()); Core::FileUtils::openTerminal(QDir(projectfs_menu_target.absoluteFilePath()).path());
} }
void ProjectFilesystemWidget::on_actionCopy_name_triggered() { void ProjectFilesystemWidget::on_actionCopy_name_triggered() {
if (projectfs_menu_target.path().isEmpty()) return; if (projectfs_menu_target.path().isEmpty()) return;
QApplication::clipboard()->setText(projectfs_menu_target.fileName()); QApplication::clipboard()->setText(projectfs_menu_target.fileName());
} }
void ProjectFilesystemWidget::on_actionCopy_path_triggered() { void ProjectFilesystemWidget::on_actionCopy_path_triggered() {
if (projectfs_menu_target.path().isEmpty()) return; if (projectfs_menu_target.path().isEmpty()) return;
QApplication::clipboard()->setText(projectfs_menu_target.absoluteFilePath()); QApplication::clipboard()->setText(projectfs_menu_target.absoluteFilePath());
} }

View File

@@ -1,68 +1,68 @@
#ifndef PROJECTFILESYSTEMWIDGET_H #ifndef PROJECTFILESYSTEMWIDGET_H
#define PROJECTFILESYSTEMWIDGET_H #define PROJECTFILESYSTEMWIDGET_H
#include "ui_projectfilesystemwidget.h" #include "ui_projectfilesystemwidget.h"
#include "filterdialog.h" #include "filterdialog.h"
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QFileSystemModel> #include <QFileSystemModel>
#include <QElapsedTimer> #include <QElapsedTimer>
#include <QMenu> #include <QMenu>
extern QFileInfo projectfs_menu_target; extern QFileInfo projectfs_menu_target;
class ProjectsModel; class ProjectsModel;
class ProjectFilesystemWidget: public QWidget, private Ui::ProjectFilesystemWidget class ProjectFilesystemWidget: public QWidget, private Ui::ProjectFilesystemWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ProjectFilesystemWidget(QWidget * parent = 0); explicit ProjectFilesystemWidget(QWidget * parent = 0);
FilterDialog::Filter currentFilters() const {return cur_filter;} FilterDialog::Filter currentFilters() const {return cur_filter;}
QString currentSearch() const {return lineFilter->text();} QString currentSearch() const {return lineFilter->text();}
void setCurrentFilter(const FilterDialog::Filter & v); void setCurrentFilter(const FilterDialog::Filter & v);
void setCurrentSearch(QString v) {lineFilter->setText(v);} void setCurrentSearch(QString v) {lineFilter->setText(v);}
protected: protected:
void changeEvent(QEvent * e); void changeEvent(QEvent * e);
void createTree(QTreeWidgetItem * ti, const QString & dir); void createTree(QTreeWidgetItem * ti, const QString & dir);
bool filterTree(QTreeWidgetItem * ti, const QString & filter); bool filterTree(QTreeWidgetItem * ti, const QString & filter);
void filter(); void filter();
void rememberExpanded(QTreeWidgetItem * ti); void rememberExpanded(QTreeWidgetItem * ti);
void restoreExpanded(QTreeWidgetItem * ti); void restoreExpanded(QTreeWidgetItem * ti);
void setExtVariable(); void setExtVariable();
void checkProcEvents(); void checkProcEvents();
bool in_proc, need_rebuild; bool in_proc, need_rebuild;
ExtensionSystem::IPlugin * proj_plug; ExtensionSystem::IPlugin * proj_plug;
QMenu popup_menu; QMenu popup_menu;
QMap<QString, QTreeWidgetItem*> item_map; QMap<QString, QTreeWidgetItem*> item_map;
QSet<QString> last_expanded; QSet<QString> last_expanded;
FilterDialog filter_dialog; FilterDialog filter_dialog;
FilterDialog::Filter cur_filter; FilterDialog::Filter cur_filter;
QElapsedTimer tm; QElapsedTimer tm;
public slots: public slots:
void projectsChanged(); void projectsChanged();
void filterClicked(); void filterClicked();
private slots: private slots:
void fileChanged(); void fileChanged();
void startupProjectChanged(); void startupProjectChanged();
void on_tree_itemDoubleClicked(QTreeWidgetItem * item, int ); void on_tree_itemDoubleClicked(QTreeWidgetItem * item, int );
void on_lineFilter_textChanged(const QString &); void on_lineFilter_textChanged(const QString &);
void on_tree_itemClicked(QTreeWidgetItem *item, int column); void on_tree_itemClicked(QTreeWidgetItem *item, int column);
void on_tree_customContextMenuRequested(const QPoint & pos); void on_tree_customContextMenuRequested(const QPoint & pos);
void on_actionOpen_here_triggered(); void on_actionOpen_here_triggered();
void on_actionOpen_external_triggered(); void on_actionOpen_external_triggered();
void on_actionShow_external_triggered(); void on_actionShow_external_triggered();
void on_actionOpen_terminal_triggered(); void on_actionOpen_terminal_triggered();
void on_actionCopy_name_triggered(); void on_actionCopy_name_triggered();
void on_actionCopy_path_triggered(); void on_actionCopy_path_triggered();
}; };
#endif // PROJECTFILESYSTEMWIDGET_H #endif // PROJECTFILESYSTEMWIDGET_H

View File

@@ -1,183 +1,183 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>ProjectFilesystemWidget</class> <class>ProjectFilesystemWidget</class>
<widget class="QWidget" name="ProjectFilesystemWidget"> <widget class="QWidget" name="ProjectFilesystemWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>386</width> <width>386</width>
<height>390</height> <height>390</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="pixmap"> <property name="pixmap">
<pixmap resource="projectfilesystem.qrc">:/icons/edit-find.png</pixmap> <pixmap resource="projectfilesystem.qrc">:/icons/edit-find.png</pixmap>
</property> </property>
<property name="scaledContents"> <property name="scaledContents">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineFilter"/> <widget class="QLineEdit" name="lineFilter"/>
</item> </item>
<item> <item>
<widget class="QToolButton" name="buttonClear"/> <widget class="QToolButton" name="buttonClear"/>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType"> <property name="sizeType">
<enum>QSizePolicy::Preferred</enum> <enum>QSizePolicy::Preferred</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QToolButton" name="buttonExpand"> <widget class="QToolButton" name="buttonExpand">
<property name="toolTip"> <property name="toolTip">
<string>Expand tree</string> <string>Expand tree</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="buttonCollapse"> <widget class="QToolButton" name="buttonCollapse">
<property name="toolTip"> <property name="toolTip">
<string>Collapse tree</string> <string>Collapse tree</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QTreeWidget" name="tree"> <widget class="QTreeWidget" name="tree">
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum> <enum>Qt::CustomContextMenu</enum>
</property> </property>
<property name="editTriggers"> <property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set> <set>QAbstractItemView::NoEditTriggers</set>
</property> </property>
<property name="textElideMode"> <property name="textElideMode">
<enum>Qt::ElideMiddle</enum> <enum>Qt::ElideMiddle</enum>
</property> </property>
<property name="verticalScrollMode"> <property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum> <enum>QAbstractItemView::ScrollPerPixel</enum>
</property> </property>
<property name="rootIsDecorated"> <property name="rootIsDecorated">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="uniformRowHeights"> <property name="uniformRowHeights">
<bool>true</bool> <bool>true</bool>
</property> </property>
<attribute name="headerVisible"> <attribute name="headerVisible">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<column> <column>
<property name="text"> <property name="text">
<string>Path</string> <string>Path</string>
</property> </property>
</column> </column>
</widget> </widget>
</item> </item>
</layout> </layout>
<action name="actionOpen_here"> <action name="actionOpen_here">
<property name="text"> <property name="text">
<string>Open as plain</string> <string>Open as plain</string>
</property> </property>
</action> </action>
<action name="actionOpen_external"> <action name="actionOpen_external">
<property name="text"> <property name="text">
<string>Open external ...</string> <string>Open external ...</string>
</property> </property>
</action> </action>
<action name="actionShow_external"> <action name="actionShow_external">
<property name="text"> <property name="text">
<string>Show external ...</string> <string>Show external ...</string>
</property> </property>
</action> </action>
<action name="actionCopy_name"> <action name="actionCopy_name">
<property name="text"> <property name="text">
<string>Copy name</string> <string>Copy name</string>
</property> </property>
</action> </action>
<action name="actionCopy_path"> <action name="actionCopy_path">
<property name="text"> <property name="text">
<string>Copy path</string> <string>Copy path</string>
</property> </property>
</action> </action>
<action name="actionOpen_terminal"> <action name="actionOpen_terminal">
<property name="icon"> <property name="icon">
<iconset resource="projectfilesystem.qrc"> <iconset resource="projectfilesystem.qrc">
<normaloff>:/icons/utilities-terminal.png</normaloff>:/icons/utilities-terminal.png</iconset> <normaloff>:/icons/utilities-terminal.png</normaloff>:/icons/utilities-terminal.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Open terminal ...</string> <string>Open terminal ...</string>
</property> </property>
</action> </action>
</widget> </widget>
<resources> <resources>
<include location="projectfilesystem.qrc"/> <include location="projectfilesystem.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>
<sender>buttonClear</sender> <sender>buttonClear</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
<receiver>lineFilter</receiver> <receiver>lineFilter</receiver>
<slot>clear()</slot> <slot>clear()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>246</x> <x>246</x>
<y>37</y> <y>37</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>212</x> <x>212</x>
<y>35</y> <y>35</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>buttonExpand</sender> <sender>buttonExpand</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
<receiver>tree</receiver> <receiver>tree</receiver>
<slot>expandAll()</slot> <slot>expandAll()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>263</x> <x>263</x>
<y>28</y> <y>28</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>251</x> <x>251</x>
<y>58</y> <y>58</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>buttonCollapse</sender> <sender>buttonCollapse</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
<receiver>tree</receiver> <receiver>tree</receiver>
<slot>collapseAll()</slot> <slot>collapseAll()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>307</x> <x>307</x>
<y>27</y> <y>27</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>297</x> <x>297</x>
<y>71</y> <y>71</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
</connections> </connections>
</ui> </ui>

View File

@@ -1,57 +1,57 @@
#include "projectfilesystemwidgetplugin.h" #include "projectfilesystemwidgetplugin.h"
#include "projectfilesystemwidget.h" #include "projectfilesystemwidget.h"
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
#include <QToolButton> #include <QToolButton>
#include <QSettings> #include <QSettings>
#include <QMessageBox> #include <QMessageBox>
ProjectFSWidgetFactory::ProjectFSWidgetFactory() { ProjectFSWidgetFactory::ProjectFSWidgetFactory() {
setDisplayName(QString::fromLatin1("Project filesystem")); setDisplayName(QString::fromLatin1("Project filesystem"));
setId("project_filesystem"); setId("project_filesystem");
} }
Core::NavigationView ProjectFSWidgetFactory::createWidget() { Core::NavigationView ProjectFSWidgetFactory::createWidget() {
Core::NavigationView view; Core::NavigationView view;
view.widget = new ProjectFilesystemWidget(); view.widget = new ProjectFilesystemWidget();
QToolButton * btn = new QToolButton(); QToolButton * btn = new QToolButton();
btn->setIcon(Utils::Icons::RELOAD.icon()); btn->setIcon(Utils::Icons::RELOAD.icon());
btn->setToolTip(tr("Reload tree")); btn->setToolTip(tr("Reload tree"));
view.dockToolBarWidgets << btn; view.dockToolBarWidgets << btn;
connect(btn, SIGNAL(clicked()), view.widget, SLOT(projectsChanged())); connect(btn, SIGNAL(clicked()), view.widget, SLOT(projectsChanged()));
btn = new QToolButton(); btn = new QToolButton();
btn->setIcon(Utils::Icons::FILTER.icon()); btn->setIcon(Utils::Icons::FILTER.icon());
btn->setToolTip(tr("Setup filters ...")); btn->setToolTip(tr("Setup filters ..."));
view.dockToolBarWidgets << btn; view.dockToolBarWidgets << btn;
connect(btn, SIGNAL(clicked()), view.widget, SLOT(filterClicked())); connect(btn, SIGNAL(clicked()), view.widget, SLOT(filterClicked()));
return view; return view;
} }
void ProjectFSWidgetFactory::saveSettings(QSettings * settings, int position, QWidget * widget) { void ProjectFSWidgetFactory::saveSettings(QSettings * settings, int position, QWidget * widget) {
//QMessageBox::information(0, "", QString::fromLatin1(widget->metaObject()->className())); //QMessageBox::information(0, "", QString::fromLatin1(widget->metaObject()->className()));
ProjectFilesystemWidget * w = qobject_cast<ProjectFilesystemWidget * >(widget); ProjectFilesystemWidget * w = qobject_cast<ProjectFilesystemWidget * >(widget);
if (!w) return; if (!w) return;
settings->beginGroup("ProjectFilesystem"); settings->beginGroup("ProjectFilesystem");
settings->beginWriteArray("widget"); settings->beginWriteArray("widget");
settings->setArrayIndex(position); settings->setArrayIndex(position);
settings->setValue("filters", w->currentFilters().toVariant()); settings->setValue("filters", w->currentFilters().toVariant());
settings->setValue("search", w->currentSearch()); settings->setValue("search", w->currentSearch());
settings->endArray(); settings->endArray();
settings->endGroup(); settings->endGroup();
settings->sync(); settings->sync();
} }
void ProjectFSWidgetFactory::restoreSettings(QSettings * settings, int position, QWidget * widget) { void ProjectFSWidgetFactory::restoreSettings(QSettings * settings, int position, QWidget * widget) {
ProjectFilesystemWidget * w = qobject_cast<ProjectFilesystemWidget * >(widget); ProjectFilesystemWidget * w = qobject_cast<ProjectFilesystemWidget * >(widget);
if (!w) return; if (!w) return;
settings->beginGroup("ProjectFilesystem"); settings->beginGroup("ProjectFilesystem");
settings->beginReadArray("widget"); settings->beginReadArray("widget");
settings->setArrayIndex(position); settings->setArrayIndex(position);
w->setCurrentFilter(FilterDialog::Filter(settings->value("filters", FilterDialog::Filter().toVariant()))); w->setCurrentFilter(FilterDialog::Filter(settings->value("filters", FilterDialog::Filter().toVariant())));
w->setCurrentSearch(settings->value("search", QString()).toString()); w->setCurrentSearch(settings->value("search", QString()).toString());
settings->endArray(); settings->endArray();
settings->endGroup(); settings->endGroup();
} }

View File

@@ -1,18 +1,18 @@
#pragma once #pragma once
#include <coreplugin/inavigationwidgetfactory.h> #include <coreplugin/inavigationwidgetfactory.h>
#include <QTableWidget> #include <QTableWidget>
class ProjectFSWidgetFactory: public Core::INavigationWidgetFactory class ProjectFSWidgetFactory: public Core::INavigationWidgetFactory
{ {
public: public:
ProjectFSWidgetFactory(); ProjectFSWidgetFactory();
~ProjectFSWidgetFactory() {} ~ProjectFSWidgetFactory() {}
Core::NavigationView createWidget(); Core::NavigationView createWidget();
void saveSettings(QSettings * settings, int position, QWidget * widget); void saveSettings(QSettings * settings, int position, QWidget * widget);
void restoreSettings(QSettings * settings, int position, QWidget * widget); void restoreSettings(QSettings * settings, int position, QWidget * widget);
}; };

View File

@@ -1,111 +1,40 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0017 NEW) # need include() with .cmake cmake_policy(SET CMP0017 NEW) # need include() with .cmake
project(qad) project(qad)
set(_QAD_MAJOR 1)
set(_QAD_MINOR 7) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
set(_QAD_REVISION 0)
set(_QAD_SUFFIX ) if (NOT DEFINED ANDROID_PLATFORM)
set(_QAD_COMPANY SHS) find_package(OpenGL REQUIRED)
set(_QAD_DOMAIN org.SHS) endif()
if (MINGW)
if ("x${CMAKE_MODULE_PATH}" STREQUAL "x") find_package(MinGW REQUIRED)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") endif()
endif()
if (NOT LIBPROJECT)
set(_plugins_default_ 1) # Version
if (DEFINED ANDROID_PLATFORM) if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/qad_version.h")
set(_plugins_default_ 0) file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/qad_version.h")
endif() endif()
option(LIB "System install" 1) #message(STATUS "Building QAD version ${QAD_VERSION} (${QAD_LIB_TYPE})")
option(DEBUG "Build with -g3" 0)
option(DESIGNER_PLUGINS "Build qt designer plugins" ${_plugins_default_}) file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in")
option(STATIC_LIB OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall") if (LIB)
if (DEBUG) install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3") if (WIN32)
endif () install(FILES ${QAD_VERSION_FILE} DESTINATION ${MINGW_INCLUDE}/qad)
endif() else()
install(FILES ${QAD_VERSION_FILE} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/qad)
include(QADMacros) endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) else()
install(FILES ${QAD_VERSION_FILE} DESTINATION include/qad)
set(EXPORT_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/qad_export.h") endif()
if(STATIC_LIB) add_subdirectory(libs)
set(QAD_LIB_TYPE STATIC) if (UTILS)
add_definitions(-DQAD_STATIC_DEFINE) add_subdirectory(utils)
#message(STATUS "Building QAD static libraries") endif()
else()
set(QAD_LIB_TYPE SHARED) copy_to_parent(qad_includes)
#message(STATUS "Building QAD shared libraries")
endif()
if (NOT DEFINED ANDROID_PLATFORM)
find_package(OpenGL REQUIRED)
endif()
if (MINGW)
find_package(MinGW REQUIRED)
endif()
# Version
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/qad_version.h")
file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/qad_version.h")
endif()
set(QAD_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/qad_version.h")
set_version(QAD
MAJOR "${_QAD_MAJOR}"
MINOR "${_QAD_MINOR}"
REVISION "${_QAD_REVISION}"
BUILD "${BUILD_NUMBER}"
SUFFIX "${_QAD_SUFFIX}"
OUTPUT "${QAD_VERSION_FILE}")
set_deploy_property(QAD ${QAD_LIB_TYPE}
FULLNAME "${_QAD_DOMAIN}.*"
COMPANY "${_QAD_COMPANY}")
message(STATUS "Building QAD version ${QAD_VERSION} (${QAD_LIB_TYPE})")
if (NOT LIBPROJECT)
if (LIB)
if(WIN32)
if(MINGW)
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
endif()
else()
if (DEFINED ANDROID_PLATFORM)
set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr)
else()
set(CMAKE_INSTALL_PREFIX /usr/local)
endif()
endif()
message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
else()
message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"")
endif()
endif()
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in")
if (LIB)
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
if (WIN32)
install(FILES ${EXPORT_HEADER} DESTINATION ${MINGW_INCLUDE}/qad)
else()
install(FILES ${EXPORT_HEADER} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/qad)
endif()
else()
install(FILES ${EXPORT_HEADER} DESTINATION include/qad)
endif()
add_subdirectory(libs)
if (UTILS)
add_subdirectory(utils)
endif()
set(QT_MULTILIB_LIST ${QT_MULTILIB_LIST} PARENT_SCOPE)
set(qad_includes ${qad_includes} PARENT_SCOPE)
if (LIB)
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
endif()

View File

@@ -1,16 +1,13 @@
macro(_qt_install _TARGET IS_APP _DIR _HDR_VAR _QM_FILES) macro(_qt_install _TARGET IS_APP _DIR _HDR_VAR _QM_FILES)
if ("${_TARGET}" STREQUAL "qad_utils")
list(APPEND ${_HDR_VAR} "${QAD_VERSION_FILE}")
endif()
sdk_install("${_DIR}" ${IS_APP} "${_TARGET}" "${${_HDR_VAR}}" "${_QM_FILES}") sdk_install("${_DIR}" ${IS_APP} "${_TARGET}" "${${_HDR_VAR}}" "${_QM_FILES}")
endmacro() endmacro()
macro(qad_plugin NAME _MODULES _LIBS) macro(_qt_plugin NAME _MODULES _LIBS)
if (NOT STATIC_LIB) if (NOT STATIC_LIB)
if(DESIGNER_PLUGINS) if(DESIGNER_PLUGINS)
set(PROJ_NAME qad_${NAME}_plugin) set(PROJ_NAME ${NAME}_plugin)
include_directories("..") include_directories("..")
add_definitions(-DQT_PLUGIN) add_definitions(-DQT_PLUGIN)
add_definitions(-DQT_NO_DEBUG) add_definitions(-DQT_NO_DEBUG)
@@ -20,12 +17,14 @@ macro(qad_plugin NAME _MODULES _LIBS)
qt_sources(SRC) qt_sources(SRC)
qt_wrap(${SRC} CPPS out_CPP QMS out_QM) qt_wrap(${SRC} CPPS out_CPP QMS out_QM)
qt_add_library(${PROJ_NAME} SHARED out_CPP) qt_add_library(${PROJ_NAME} SHARED out_CPP)
qt_target_link_libraries(${PROJ_NAME} ${_LIBS} qad_${NAME} ${_${NAME}_PLUGIN_LIBS}) qt_target_link_libraries(${PROJ_NAME} ${_LIBS} ${_${NAME}_PLUGIN_LIBS})
if (WIN32) if (WIN32)
qt_install(TARGETS ${PROJ_NAME} RUNTIME DESTINATION QtPlugins/designer) qt_install(TARGETS ${PROJ_NAME} RUNTIME DESTINATION QtPlugins/designer)
else() else()
qt_install(TARGETS ${PROJ_NAME} DESTINATION QtPlugins/designer) qt_install(TARGETS ${PROJ_NAME} DESTINATION QtPlugins/designer)
endif() endif()
list(APPEND _qt_plugs ${NAME})
copy_to_parent("")
endif() endif()
endif() endif()
endmacro() endmacro()
@@ -38,12 +37,14 @@ macro(_qt_project NAME IS_APP DOMAIN _MODULES _LIBS)
import_version(${PROJ_NAME} ${DOMAIN}) import_version(${PROJ_NAME} ${DOMAIN})
import_deploy_properties(${PROJ_NAME} ${DOMAIN}) import_deploy_properties(${PROJ_NAME} ${DOMAIN})
if (${IS_APP}) if (${IS_APP})
list(APPEND _qt_apps ${PROJ_NAME})
set_deploy_property(${PROJ_NAME} set_deploy_property(${PROJ_NAME}
LABEL ${PROJ_NAME} LABEL ${PROJ_NAME}
FULLNAME "${_${DOMAIN}_DOMAIN}.${PROJ_NAME}" FULLNAME "${_${DOMAIN}_DOMAIN}.${PROJ_NAME}"
INFO "${APP_INFO}" INFO "${APP_INFO}"
ICON "${APP_ICON}") ICON "${APP_ICON}")
else() else()
list(APPEND _qt_libs ${PROJ_NAME})
set_deploy_property(${PROJ_NAME} SHARED set_deploy_property(${PROJ_NAME} SHARED
LABEL ${PROJ_NAME} LABEL ${PROJ_NAME}
FULLNAME "${_${DOMAIN}_DOMAIN}.${PROJ_NAME}" FULLNAME "${_${DOMAIN}_DOMAIN}.${PROJ_NAME}"
@@ -58,15 +59,17 @@ macro(_qt_project NAME IS_APP DOMAIN _MODULES _LIBS)
if(NOT STATIC_LIB) if(NOT STATIC_LIB)
qt_target_compile_definitions(${PROJ_NAME} PRIVATE ${DOMAIN}_SHARED_DEFINE) qt_target_compile_definitions(${PROJ_NAME} PRIVATE ${DOMAIN}_SHARED_DEFINE)
endif() endif()
qt_generate_export_header(${PROJ_NAME})
list(APPEND out_HDR "${CMAKE_CURRENT_BINARY_DIR}/${PROJ_NAME}_export.h")
endif() endif()
qt_target_link_libraries(${PROJ_NAME} ${_LIBS}) qt_target_link_libraries(${PROJ_NAME} ${_LIBS})
list(APPEND QT_MULTILIB_LIST ${PROJ_NAME}) list(APPEND QT_MULTILIB_LIST ${PROJ_NAME})
set(QT_MULTILIB_LIST ${QT_MULTILIB_LIST} PARENT_SCOPE) #message(STATUS "Building ${PROJ_NAME}")
message(STATUS "Building ${PROJ_NAME}")
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/plugin") if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/plugin")
set(_${NAME}_PLUGIN_LIBS "${_LIBS}") set(_${NAME}_PLUGIN_LIBS "${_LIBS}")
add_subdirectory(plugin) add_subdirectory(plugin)
endif() endif()
copy_to_parent("")
endmacro() endmacro()
@@ -80,3 +83,8 @@ macro(qad_application NAME _MODULES _LIBS)
_qt_project(${NAME} TRUE "QAD" "${_MODULES}" "${_LIBS}") _qt_project(${NAME} TRUE "QAD" "${_MODULES}" "${_LIBS}")
_qt_install(${NAME} TRUE "qad" "" "out_QM") _qt_install(${NAME} TRUE "qad" "" "out_QM")
endmacro() endmacro()
macro(qad_plugin NAME _MODULES _LIBS)
_qt_plugin(qad_${NAME} "${_MODULES}" "qad_${NAME};${_LIBS}")
endmacro()

View File

@@ -1,744 +1,811 @@
#[[ #[[
find_qt([<Module1> <Module2> ...] [Qt4] [Qt5]) find_qt([<Module1> <Module2> ...] [Qt4] [Qt5])
Find Qt4 or/and Qt5 packages Find Qt4 or/and Qt5 packages
If Qt4/5 found, set If Qt4/5 found, set
* Qt<4/5>_ROOT var to Qt root dir * Qt<4/5>_ROOT var to Qt root dir
* Qt<4/5>_BIN var to Qt binary dir * Qt<4/5>_BIN var to Qt binary dir
* Qt<4/5>_PLUGINS_DIR var to Qt plugins dir * Qt<4/5>_PLUGINS_DIR var to Qt plugins dir
* Qt<4/5>_LANG_DIR var to Qt translations dir * Qt<4/5>_LANG_DIR var to Qt translations dir
qt_sources(<src_out_var> [NO_DEFAULT] [DIR <dir>] [<regexp> ...]) qt_sources(<src_out_var> [NO_DEFAULT] [DIR <dir>] [<regexp> ...])
Collect all sources, optionally in directory <dir> and Collect all sources, optionally in directory <dir> and
Additional filters <regexp>. By default filter files with regexps Additional filters <regexp>. By default filter files with regexps
"*.h", "*.hpp", "*.c", "*.cpp", "*.ui", "*.qrc", "*.rc", "*.ts" and "lang/*.ts". "*.h", "*.hpp", "*.c", "*.cpp", "*.ui", "*.qrc", "*.rc", "*.ts" and "lang/*.ts".
Default filters disabled with option NO_DEFAULT Default filters disabled with option NO_DEFAULT
qt_wrap(<file0> <file1> ... [HDRS <hrd_var>] [CPPS <cpp_var>] [QMS <qm_var>]) qt_wrap(<file0> <file1> ... [HDRS <hrd_var>] [CPPS <cpp_var>] [QMS <qm_var>])
Prepare sources for compile Prepare sources for compile
Store headers to <hrd_var>, all wrapped Qt4 files to <cpp_var>_Qt4 and Qt5 files to <cpp_var>_Qt5 Store headers to <hrd_var>, all wrapped Qt4 files to <cpp_var>_Qt4 and Qt5 files to <cpp_var>_Qt5
version are automatic detected after find_qt() call version are automatic detected after find_qt() call
qt_add_executable(<name> [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] source1 [source2 ...]) qt_add_executable(<name> [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] source1 [source2 ...])
Add executables for founded Qt versions, target names is <name><TARGET_SUFFIX_Qt?> Add executables for founded Qt versions, target names is <name><TARGET_SUFFIX_Qt?>
All needed Qt includes automatic added to corresponding targets All needed Qt includes automatic added to corresponding targets
<source> cant be CPPS variable passed to qt_wrap() or some list or filename <source> cant be CPPS variable passed to qt_wrap() or some list or filename
qt_add_library(<name> [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] source1 [source2 ...]) qt_add_library(<name> [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] source1 [source2 ...])
Add library for founded Qt versions, target names is <name><TARGET_SUFFIX_Qt?> Add library for founded Qt versions, target names is <name><TARGET_SUFFIX_Qt?>
All needed Qt includes automatic added to corresponding targets All needed Qt includes automatic added to corresponding targets
<source> cant be CPPS variable passed to qt_wrap() or some list or filename <source> cant be CPPS variable passed to qt_wrap() or some list or filename
qt_target_link_libraries(<name> ... <item> ...) qt_target_link_libraries(<name> ... <item> ...)
Link targets for founded Qt versions, target names is <name><TARGET_SUFFIX_Qt?> Link targets for founded Qt versions, target names is <name><TARGET_SUFFIX_Qt?>
All needed Qt libraries automatic added to corresponding targets All needed Qt libraries automatic added to corresponding targets
if QT_MULTILIB_LIST contains some linking library, to it name automatic if QT_MULTILIB_LIST contains some linking library, to it name automatic
add <MULTILIB_SUFFIX_Qt?> or individual <MULTILIB_>libname<_SUFFIX_Qt?> add <MULTILIB_SUFFIX_Qt?> or individual <MULTILIB_>libname<_SUFFIX_Qt?>
qt_target_compile_definitions(<name> ...) qt_target_compile_definitions(<name> ...)
Syntax similar to original "target_compile_definitions()" Syntax similar to original "target_compile_definitions()"
Specify compile definitions to use when compiling a given <name> Specify compile definitions to use when compiling a given <name>
qt_target_include_directories(<name> ...) qt_target_include_directories(<name> ...)
Syntax similar to original "target_include_directories()" Syntax similar to original "target_include_directories()"
Add include directories to a target Add include directories to a target
qt_install(...) qt_install(...)
Syntax similar to original "install()" Syntax similar to original "install()"
Install targets for founded Qt versions Install targets for founded Qt versions
if DESTINATION set to "QtBin" files will be installed if DESTINATION set to "QtBin" files will be installed
to corresponding Qt binary directory to corresponding Qt binary directory
if DESTINATION set to "QtLang" files will be installed if DESTINATION set to "QtLang" files will be installed
to corresponding Qt translation directory to corresponding Qt translation directory
if DESTINATION starts with "QtPlugins" files will be installed if DESTINATION starts with "QtPlugins" files will be installed
to corresponding Qt plugins directory to corresponding Qt plugins directory
Add LANG type for first argument - in this case you should Add LANG type for first argument - in this case you should
specify variable name, not variable value! specify variable name, not variable value!
e.g. "qt_install(LANG my_QM DESTINATION QtLang)" e.g. "qt_install(LANG my_QM DESTINATION QtLang)"
qt_install_lang(<name> DESTINATION <dir> [PATHS <path0> [<path1>] [...] ]) qt_install_lang(<name> DESTINATION <dir> [PATHS <path0> [<path1>] [...] ])
Search Qt translations for all <name> dependencies Search Qt translations for all <name> dependencies
in Qt<?>_LANG_DIR for <name>_LANG languages in Qt<?>_LANG_DIR for <name>_LANG languages
and install them to <dir>. PATH are additional search paths. and install them to <dir>. PATH are additional search paths.
You should use "set_lang()" macro before this action You should use "set_lang()" macro before this action
]]
cmake_policy(SET CMP0011 NEW) # don`t affect includer policies qt_get_target(<name> <var> [Qt4 | Qt5])
cmake_policy(SET CMP0020 NEW) # Automatically link Qt executables to qtmain target on Windows
if (POLICY CMP0057) Write real <name> Qt target name to <var>
cmake_policy(SET CMP0057 NEW) # Support if() IN_LIST If Qt4 or Qt5 specified, search for this version,
endif() otherwise returns greatest version
if (POLICY CMP0074)
cmake_policy(SET CMP0074 OLD) # ignore <PackageName>_ROOT variables
endif()
set(__qt_bug_modules "UiTools")
qt_get_targets(<name> <var>)
set(_QT_VERSIONS_ 4 5) Write all real <name> Qt target names to <var>
foreach(_v ${_QT_VERSIONS_})
if (NOT DEFINED TARGET_SUFFIX_Qt${_v})
set(TARGET_SUFFIX_Qt${_v} "${_v}")
set(MULTILIB_SUFFIX_Qt${_v} "${_v}")
endif() qt_generate_export_header(<name> ...)
set(MOC_INC_Qt${_v})
endforeach() Call generate_export_header on Qt multitarget
if (NOT DEFINED QT_MULTILIB_LIST)
set(QT_MULTILIB_LIST)
endif() ]]
#set(TARGET_SUFFIX_Qt4 "")
cmake_policy(SET CMP0011 NEW) # don`t affect includer policies
macro(find_qt) cmake_policy(SET CMP0020 NEW) # Automatically link Qt executables to qtmain target on Windows
set(_QCOMP) if (POLICY CMP0057)
foreach(_v ${_QT_VERSIONS_}) cmake_policy(SET CMP0057 NEW) # Support if() IN_LIST
set(_NEED${_v} 0) endif()
set(LOCAL_FOUND${_v} 0) if (POLICY CMP0074)
set(MOC_INC_Qt${_v}) cmake_policy(SET CMP0074 OLD) # ignore <PackageName>_ROOT variables
set(Qt${_v}_INCLUDES) endif()
set(Qt${_v}_LIBRARIES) set(__qt_bug_modules "UiTools")
set(Qt${_v}_ROOT)
set(Qt${_v}_BIN)
set(Qt${_v}_PLUGINS_DIR) set(_QT_VERSIONS_ 4 5)
set(Qt${_v}_LANG_DIR) foreach(_v ${_QT_VERSIONS_})
endforeach() if (NOT DEFINED TARGET_SUFFIX_Qt${_v})
set(_NEED_SOME 0) set(TARGET_SUFFIX_Qt${_v} "${_v}")
set(_QUIET) set(MULTILIB_SUFFIX_Qt${_v} "${_v}")
foreach(_i ${ARGN}) endif()
set(_FOUND_NEED 0) set(MOC_INC_Qt${_v})
foreach(_v ${_QT_VERSIONS_}) endforeach()
if ("x${_i}" STREQUAL "xQt${_v}") if (NOT DEFINED QT_MULTILIB_LIST)
set(_NEED${_v} 1) set(QT_MULTILIB_LIST)
set(_NEED_SOME 1) endif()
set(_FOUND_NEED 1) #set(TARGET_SUFFIX_Qt4 "")
endif()
if ("x${_i}" STREQUAL "xQUIET")
set(_QUIET QUIET) macro(find_qt)
endif() set(_QCOMP)
endforeach() foreach(_v ${_QT_VERSIONS_})
if (NOT _FOUND_NEED) set(_NEED${_v} 0)
list(APPEND _QCOMP "${_i}") set(LOCAL_FOUND${_v} 0)
endif() set(MOC_INC_Qt${_v})
endforeach() set(Qt${_v}_INCLUDES)
if (NOT _NEED_SOME) set(Qt${_v}_LIBRARIES)
foreach(_v ${_QT_VERSIONS_}) set(Qt${_v}_ROOT)
set(_NEED${_v} 1) set(Qt${_v}_BIN)
endforeach() set(Qt${_v}_PLUGINS_DIR)
endif() set(Qt${_v}_LANG_DIR)
list(REMOVE_DUPLICATES _QCOMP) endforeach()
if (_NEED4) set(_NEED_SOME 0)
find_package(Qt4 ${_QUIET}) set(_QUIET)
if (Qt4_FOUND) foreach(_i ${ARGN})
set(LOCAL_FOUND4 1) set(_FOUND_NEED 0)
get_filename_component(Qt4_BIN ${QT_QMAKE_EXECUTABLE} PATH) foreach(_v ${_QT_VERSIONS_})
set(Qt4_INCLUDES ${QT_INCLUDES}) if ("x${_i}" STREQUAL "xQt${_v}")
foreach(m ${_QCOMP}) set(_NEED${_v} 1)
string(TOUPPER "${m}" _um) set(_NEED_SOME 1)
#message("${QT_QT${_um}_FOUND}") set(_FOUND_NEED 1)
if (${QT_QT${_um}_FOUND}) endif()
list(APPEND Qt4_LIBRARIES ${QT_QT${_um}_LIBRARY}) if ("x${_i}" STREQUAL "xQUIET")
endif() set(_QUIET QUIET)
endforeach() endif()
set(Qt4_PLUGINS_DIR ${QT_PLUGINS_DIR}) endforeach()
set(Qt4_LANG_DIR ${Qt4_BIN}/../translations) if (NOT _FOUND_NEED)
set(Qt4_ROOT "${Qt4_BIN}/../") list(APPEND _QCOMP "${_i}")
endif() endif()
endif() endforeach()
if (_NEED5) if (NOT _NEED_SOME)
#set(_MSG 1) foreach(_v ${_QT_VERSIONS_})
#if (Qt5_FOUND) set(_NEED${_v} 1)
# set(_MSG 0) endforeach()
#endif() endif()
find_package(Qt5 COMPONENTS Core LinguistTools UiPlugin Widgets ${_QCOMP} ${_QUIET}) list(REMOVE_DUPLICATES _QCOMP)
if (DEFINED ANDROID_PLATFORM) if (_NEED4)
set(CMAKE_SHARED_MODULE_SUFFIX_CXX ".so") find_package(Qt4 ${_QUIET})
set(CMAKE_SHARED_LIBRARY_SUFFIX_CXX ".so") if (Qt4_FOUND)
set(CMAKE_SHARED_MODULE_SUFFIX_C ".so") set(LOCAL_FOUND4 1)
set(CMAKE_SHARED_LIBRARY_SUFFIX_C ".so") get_filename_component(Qt4_BIN ${QT_QMAKE_EXECUTABLE} PATH)
endif() set(Qt4_INCLUDES ${QT_INCLUDES})
if (Qt5_FOUND) foreach(m ${_QCOMP})
set(LOCAL_FOUND5 1) string(TOUPPER "${m}" _um)
set(_Qt5Modules) #message("${QT_QT${_um}_FOUND}")
foreach(m ${_QCOMP}) if (${QT_QT${_um}_FOUND})
if (${Qt5${m}_FOUND}) list(APPEND Qt4_LIBRARIES ${QT_QT${_um}_LIBRARY})
set(__lib ${Qt5${m}_LIBRARIES}) endif()
if (DEFINED ANDROID_PLATFORM) endforeach()
if (m IN_LIST __qt_bug_modules) set(Qt4_PLUGINS_DIR ${QT_PLUGINS_DIR})
get_target_property(__lib Qt5::${m} LOCATION) set(Qt4_LANG_DIR ${Qt4_BIN}/../translations)
endif() set(Qt4_ROOT "${Qt4_BIN}/../")
endif() endif()
list(APPEND _Qt5Modules ${m}) endif()
list(APPEND Qt5_INCLUDES ${Qt5${m}_INCLUDE_DIRS}) if (_NEED5)
list(APPEND Qt5_LIBRARIES ${__lib}) #set(_MSG 1)
endif() #if (Qt5_FOUND)
endforeach() # set(_MSG 0)
#get_property(_up_dir TARGET Qt5::UiPlugin PROPERTY INTERFACE_INCLUDE_DIRECTORIES) #endif()
#message("${_up_dir}") find_package(Qt5 COMPONENTS Core LinguistTools UiPlugin Widgets ${_QCOMP} ${_QUIET})
#if (NOT "x${_up_dir}" STREQUAL "x") if (DEFINED ANDROID_PLATFORM)
# list(APPEND Qt5_INCLUDES ${_up_dir}) set(CMAKE_SHARED_MODULE_SUFFIX_CXX ".so")
#endif() set(CMAKE_SHARED_LIBRARY_SUFFIX_CXX ".so")
get_target_property(_Qt5_qmake Qt5::qmake LOCATION) set(CMAKE_SHARED_MODULE_SUFFIX_C ".so")
get_filename_component(Qt5_BIN ${_Qt5_qmake} PATH) set(CMAKE_SHARED_LIBRARY_SUFFIX_C ".so")
foreach(_p ${Qt5Gui_PLUGINS}) endif()
get_target_property(_l ${_p} LOCATION) if (Qt5_FOUND)
get_filename_component(_l ${_l} DIRECTORY) set(LOCAL_FOUND5 1)
string(FIND "${_l}" "/" _ind REVERSE) set(_Qt5Modules)
string(SUBSTRING "${_l}" 0 ${_ind} _l) foreach(m ${_QCOMP})
set(Qt5_PLUGINS_DIR ${_l}) if (${Qt5${m}_FOUND})
#message("Qt5: plugins dir: ${Qt5_PLUGINS_DIR}") set(__lib ${Qt5${m}_LIBRARIES})
break() if (DEFINED ANDROID_PLATFORM)
endforeach() if (m IN_LIST __qt_bug_modules)
string(FIND "${Qt5_BIN}" "/" _ind REVERSE) get_target_property(__lib Qt5::${m} LOCATION)
string(SUBSTRING "${Qt5_BIN}" 0 ${_ind} Qt5_ROOT) endif()
if ("x${Qt5_PLUGINS_DIR}" STREQUAL "x") endif()
set(Qt5_PLUGINS_DIR "${Qt5_ROOT}/plugins") list(APPEND _Qt5Modules ${m})
endif() list(APPEND Qt5_INCLUDES ${Qt5${m}_INCLUDE_DIRS})
if (APPLE) list(APPEND Qt5_LIBRARIES ${__lib})
list(APPEND MOC_INC_Qt5 "-F${Qt5_ROOT}/lib") endif()
endif() endforeach()
set(Qt5_LANG_DIR ${Qt5_BIN}/../translations) #get_property(_up_dir TARGET Qt5::UiPlugin PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
if (NOT _QT5_MSG) #message("${_up_dir}")
message(STATUS "Found Qt5: ${_Qt5_qmake} (version \"${Qt5_VERSION}\")") #if (NOT "x${_up_dir}" STREQUAL "x")
set(_QT5_MSG 1 CACHE BOOL "msg_qt5" FORCE) # list(APPEND Qt5_INCLUDES ${_up_dir})
#message(STATUS "Found Qt5 modules: ${_Qt5Modules}") #endif()
endif() get_target_property(_Qt5_qmake Qt5::qmake LOCATION)
endif() get_filename_component(Qt5_BIN ${_Qt5_qmake} PATH)
endif() foreach(_p ${Qt5Gui_PLUGINS})
foreach(_v ${_QT_VERSIONS_}) get_target_property(_l ${_p} LOCATION)
if (LOCAL_FOUND${_v}) get_filename_component(_l ${_l} DIRECTORY)
foreach(_p ${Qt${_v}_INCLUDES}) string(FIND "${_l}" "/" _ind REVERSE)
list(APPEND MOC_INC_Qt${_v} "-I${_p}") string(SUBSTRING "${_l}" 0 ${_ind} _l)
#message("${_p}") set(Qt5_PLUGINS_DIR ${_l})
endforeach() #message("Qt5: plugins dir: ${Qt5_PLUGINS_DIR}")
endif() break()
#message("${MOC_INC_Qt${_v}}") endforeach()
endforeach() string(FIND "${Qt5_BIN}" "/" _ind REVERSE)
string(SUBSTRING "${Qt5_BIN}" 0 ${_ind} Qt5_ROOT)
endmacro() if ("x${Qt5_PLUGINS_DIR}" STREQUAL "x")
set(Qt5_PLUGINS_DIR "${Qt5_ROOT}/plugins")
endif()
macro(qt_sources OUT) if (APPLE)
set(${OUT}) list(APPEND MOC_INC_Qt5 "-F${Qt5_ROOT}/lib")
set(_DIR "") endif()
set(_IS_DIR 0) set(Qt5_LANG_DIR ${Qt5_BIN}/../translations)
set(_NO_DEFAULT 0) if (NOT _QT5_MSG)
set(_DEFAULT) message(STATUS "Found Qt5: ${_Qt5_qmake} (version \"${Qt5_VERSION}\")")
set(_REGEXP) set(_QT5_MSG 1 CACHE BOOL "msg_qt5" FORCE)
set(_REGEXP_WD) #message(STATUS "Found Qt5 modules: ${_Qt5Modules}")
foreach(_i ${ARGN}) endif()
if (_IS_DIR) endif()
set(_DIR "${_i}") endif()
set(_IS_DIR 0) foreach(_v ${_QT_VERSIONS_})
elseif ("x${_i}" STREQUAL "xDIR") if (LOCAL_FOUND${_v})
set(_IS_DIR 1) foreach(_p ${Qt${_v}_INCLUDES})
elseif ("x${_i}" STREQUAL "xNO_DEFAULT") list(APPEND MOC_INC_Qt${_v} "-I${_p}")
set(_NO_DEFAULT 1) #message("${_p}")
else() endforeach()
list(APPEND _REGEXP ${_i}) endif()
endif() #message("${MOC_INC_Qt${_v}}")
endforeach() endforeach()
if (NOT "x${_DIR}" STREQUAL "x")
#file(TO_CMAKE_PATH "${_DIR}//" _DIR) endmacro()
string(REPLACE "\\" "/" _DIR "${_DIR}/")
string(REPLACE "//" "/" _DIR "${_DIR}")
endif() macro(qt_sources OUT)
foreach(_i ${_REGEXP}) set(${OUT})
list(APPEND _REGEXP_WD "${_DIR}${_i}") set(_DIR "")
endforeach() set(_IS_DIR 0)
if (NOT _NO_DEFAULT) set(_NO_DEFAULT 0)
set(_DEFAULT "${_DIR}*.h" "${_DIR}*.hpp" "${_DIR}*.c" "${_DIR}*.cpp" "${_DIR}*.ui" "${_DIR}*.qrc" "${_DIR}*.rc" "${_DIR}*.ts" "${_DIR}lang/*.ts") set(_DEFAULT)
endif() set(_REGEXP)
#message("${_DEFAULT}, ${_REGEXP_WD}") set(_REGEXP_WD)
file(GLOB ${OUT} ${_DEFAULT} ${_REGEXP_WD}) foreach(_i ${ARGN})
endmacro() if (_IS_DIR)
set(_DIR "${_i}")
set(_IS_DIR 0)
macro(qt_wrap) elseif ("x${_i}" STREQUAL "xDIR")
set(HDR_VAR) set(_IS_DIR 1)
set(CPP_VAR) elseif ("x${_i}" STREQUAL "xNO_DEFAULT")
set(QM_VAR) set(_NO_DEFAULT 1)
set(_HDR_ARG 0) else()
set(_CPP_ARG 0) list(APPEND _REGEXP ${_i})
set(_QM_ARG 0) endif()
set(WAS_HDR_ARG 0) endforeach()
set(WAS_CPP_ARG 0) if (NOT "x${_DIR}" STREQUAL "x")
set(WAS_QM_ARG 0) #file(TO_CMAKE_PATH "${_DIR}//" _DIR)
set(FILE_LIST) string(REPLACE "\\" "/" _DIR "${_DIR}/")
foreach(_i ${ARGN}) string(REPLACE "//" "/" _DIR "${_DIR}")
if (_HDR_ARG) endif()
set(HDR_VAR ${_i}) foreach(_i ${_REGEXP})
set(WAS_HDR_ARG 1) list(APPEND _REGEXP_WD "${_DIR}${_i}")
set(_HDR_ARG 0) endforeach()
elseif (_CPP_ARG) if (NOT _NO_DEFAULT)
set(CPP_VAR ${_i}) set(_DEFAULT "${_DIR}*.h" "${_DIR}*.hpp" "${_DIR}*.c" "${_DIR}*.cpp" "${_DIR}*.ui" "${_DIR}*.qrc" "${_DIR}*.rc" "${_DIR}*.ts" "${_DIR}lang/*.ts")
set(WAS_CPP_ARG 1) endif()
set(_CPP_ARG 0) #message("${_DEFAULT}, ${_REGEXP_WD}")
elseif (_QM_ARG) file(GLOB ${OUT} ${_DEFAULT} ${_REGEXP_WD})
set(QM_VAR ${_i}) endmacro()
set(WAS_QM_ARG 1)
set(_QM_ARG 0)
elseif ("x${_i}" STREQUAL "xHDRS") macro(qt_wrap)
set(_HDR_ARG 1) set(HDR_VAR)
elseif ("x${_i}" STREQUAL "xCPPS") set(CPP_VAR)
set(_CPP_ARG 1) set(QM_VAR)
elseif ("x${_i}" STREQUAL "xQMS") set(_HDR_ARG 0)
set(_QM_ARG 1) set(_CPP_ARG 0)
else() set(_QM_ARG 0)
list(APPEND FILE_LIST "${_i}") set(WAS_HDR_ARG 0)
endif() set(WAS_CPP_ARG 0)
endforeach() set(WAS_QM_ARG 0)
foreach(_v ${_QT_VERSIONS_}) set(FILE_LIST)
set(CPP${_v}_VAR) foreach(_i ${ARGN})
set(QM${_v}_VAR) if (_HDR_ARG)
if (LOCAL_FOUND${_v}) set(HDR_VAR ${_i})
if (WAS_CPP_ARG) set(WAS_HDR_ARG 1)
set(CPP${_v}_VAR ${CPP_VAR}_Qt${_v}) set(_HDR_ARG 0)
endif() elseif (_CPP_ARG)
if (WAS_QM_ARG) set(CPP_VAR ${_i})
set(QM${_v}_VAR ${QM_VAR}_Qt${_v}) set(WAS_CPP_ARG 1)
endif() set(_CPP_ARG 0)
endif() elseif (_QM_ARG)
endforeach() set(QM_VAR ${_i})
#message("found 4: ${LOCAL_FOUND4}, 5: ${LOCAL_FOUND5}") set(WAS_QM_ARG 1)
#message("has HRDS: ${WAS_HDR_ARG}: ${HDR_VAR}") set(_QM_ARG 0)
#message("has CPPS4: ${WAS_CPP_ARG}: ${CPP4_VAR}") elseif ("x${_i}" STREQUAL "xHDRS")
#message("has CPPS5: ${WAS_CPP_ARG}: ${CPP5_VAR}") set(_HDR_ARG 1)
#message("files: ${FILE_LIST}") elseif ("x${_i}" STREQUAL "xCPPS")
set(H_LIST) set(_CPP_ARG 1)
set(CPP_LIST) elseif ("x${_i}" STREQUAL "xQMS")
set(UI_LIST) set(_QM_ARG 1)
set(RES_LIST) else()
set(RC_LIST) list(APPEND FILE_LIST "${_i}")
set(TS_LIST) endif()
foreach(_i ${FILE_LIST}) endforeach()
get_filename_component(_EXT "${_i}" EXT) foreach(_v ${_QT_VERSIONS_})
#message("${_EXT}") set(CPP${_v}_VAR)
if (NOT ("x${_EXT}" STREQUAL "x")) set(QM${_v}_VAR)
if (("x${_EXT}" STREQUAL "x.h") OR ("x${_EXT}" STREQUAL "x.hpp")) if (LOCAL_FOUND${_v})
list(APPEND H_LIST "${_i}") if (WAS_CPP_ARG)
#message("header") set(CPP${_v}_VAR ${CPP_VAR}_Qt${_v})
endif() endif()
if (("x${_EXT}" STREQUAL "x.c") OR ("x${_EXT}" STREQUAL "x.cpp") OR ("x${_EXT}" STREQUAL "x.cxx")) if (WAS_QM_ARG)
list(APPEND CPP_LIST "${_i}") set(QM${_v}_VAR ${QM_VAR}_Qt${_v})
#message("source") endif()
endif() endif()
if ("x${_EXT}" STREQUAL "x.ui") endforeach()
list(APPEND UI_LIST "${_i}") #message("found 4: ${LOCAL_FOUND4}, 5: ${LOCAL_FOUND5}")
endif() #message("has HRDS: ${WAS_HDR_ARG}: ${HDR_VAR}")
if ("x${_EXT}" STREQUAL "x.qrc") #message("has CPPS4: ${WAS_CPP_ARG}: ${CPP4_VAR}")
list(APPEND RES_LIST "${_i}") #message("has CPPS5: ${WAS_CPP_ARG}: ${CPP5_VAR}")
endif() #message("files: ${FILE_LIST}")
if ("x${_EXT}" STREQUAL "x.rc") set(H_LIST)
list(APPEND RC_LIST "${_i}") set(CPP_LIST)
endif() set(UI_LIST)
if ("x${_EXT}" STREQUAL "x.ts") set(RES_LIST)
list(APPEND TS_LIST "${_i}") set(RC_LIST)
endif() set(TS_LIST)
endif() foreach(_i ${FILE_LIST})
endforeach() get_filename_component(_EXT "${_i}" EXT)
if (WAS_HDR_ARG) #message("${_EXT}")
set(${HDR_VAR}) if (NOT ("x${_EXT}" STREQUAL "x"))
list(APPEND ${HDR_VAR} ${H_LIST}) if (("x${_EXT}" STREQUAL "x.h") OR ("x${_EXT}" STREQUAL "x.hpp"))
endif() list(APPEND H_LIST "${_i}")
set(SRC_CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) #message("header")
foreach(_v ${_QT_VERSIONS_}) endif()
if (LOCAL_FOUND${_v} AND WAS_CPP_ARG) if (("x${_EXT}" STREQUAL "x.c") OR ("x${_EXT}" STREQUAL "x.cpp") OR ("x${_EXT}" STREQUAL "x.cxx"))
set(CMAKE_CURRENT_BINARY_DIR ${SRC_CMAKE_CURRENT_BINARY_DIR}/qt${_v}) list(APPEND CPP_LIST "${_i}")
set(${CPP${_v}_VAR}) #message("source")
if (WAS_QM_ARG) endif()
set(${QM${_v}_VAR}) if ("x${_EXT}" STREQUAL "x.ui")
endif() list(APPEND UI_LIST "${_i}")
set(MOCS${_v}) endif()
set(CUIS${_v}) if ("x${_EXT}" STREQUAL "x.qrc")
set(CRES${_v}) list(APPEND RES_LIST "${_i}")
if (${_v} EQUAL 4) endif()
qt4_wrap_cpp(MOCS${_v} ${H_LIST} OPTIONS -nw ${MOC_INC_Qt4}) if ("x${_EXT}" STREQUAL "x.rc")
qt4_wrap_ui(CUIS${_v} ${UI_LIST}) list(APPEND RC_LIST "${_i}")
qt4_add_resources(CRES${_v} ${RES_LIST}) endif()
if (WAS_QM_ARG) if ("x${_EXT}" STREQUAL "x.ts")
set(${QM${_v}_VAR} "") list(APPEND TS_LIST "${_i}")
qt4_add_translation(${QM${_v}_VAR} ${TS_LIST}) endif()
endif() endif()
elseif (${_v} EQUAL 5) endforeach()
qt5_wrap_cpp(MOCS${_v} ${H_LIST} OPTIONS -nw ${MOC_INC_Qt5}) if (WAS_HDR_ARG)
qt5_wrap_ui(CUIS${_v} ${UI_LIST}) set(${HDR_VAR})
qt5_add_resources(CRES${_v} ${RES_LIST}) list(APPEND ${HDR_VAR} ${H_LIST})
if (WAS_QM_ARG) endif()
set(${QM${_v}_VAR} "") set(SRC_CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
qt5_add_translation(${QM${_v}_VAR} ${TS_LIST}) foreach(_v ${_QT_VERSIONS_})
endif() if (LOCAL_FOUND${_v} AND WAS_CPP_ARG)
else() set(CMAKE_CURRENT_BINARY_DIR ${SRC_CMAKE_CURRENT_BINARY_DIR}/qt${_v})
# Qt6 ... set(${CPP${_v}_VAR})
endif() if (WAS_QM_ARG)
#message("${${QM${_v}_VAR}}") set(${QM${_v}_VAR})
list(APPEND ${CPP${_v}_VAR} ${CPP_LIST}) endif()
list(APPEND ${CPP${_v}_VAR} ${RC_LIST}) set(MOCS${_v})
list(APPEND ${CPP${_v}_VAR} ${MOCS${_v}}) set(CUIS${_v})
list(APPEND ${CPP${_v}_VAR} ${CUIS${_v}}) set(CRES${_v})
list(APPEND ${CPP${_v}_VAR} ${CRES${_v}}) if (${_v} EQUAL 4)
if (WAS_QM_ARG) qt4_wrap_cpp(MOCS${_v} ${H_LIST} OPTIONS -nw ${MOC_INC_Qt4})
list(APPEND ${CPP${_v}_VAR} ${${QM${_v}_VAR}}) qt4_wrap_ui(CUIS${_v} ${UI_LIST})
endif() qt4_add_resources(CRES${_v} ${RES_LIST})
#message("${${QM${_v}_VAR}}") if (WAS_QM_ARG)
endif() set(${QM${_v}_VAR} "")
endforeach() qt4_add_translation(${QM${_v}_VAR} ${TS_LIST})
set(CMAKE_CURRENT_BINARY_DIR ${SRC_CMAKE_CURRENT_BINARY_DIR}) endif()
endmacro() elseif (${_v} EQUAL 5)
qt5_wrap_cpp(MOCS${_v} ${H_LIST} OPTIONS -nw ${MOC_INC_Qt5})
qt5_wrap_ui(CUIS${_v} ${UI_LIST})
macro(_qt_split_add_args _P _A) qt5_add_resources(CRES${_v} ${RES_LIST})
set(${_P}) if (WAS_QM_ARG)
set(${_A}) set(${QM${_v}_VAR} "")
foreach(_i ${ARGN}) qt5_add_translation(${QM${_v}_VAR} ${TS_LIST})
if (NOT ("x${${_i}_Qt${_v}}" STREQUAL "x")) endif()
list(APPEND ${_A} ${${_i}_Qt${_v}}) else()
elseif (("x${_i}" STREQUAL "xWIN32") OR # Qt6 ...
("x${_i}" STREQUAL "xMACOSX_BUNDLE") OR endif()
("x${_i}" STREQUAL "xSTATIC") OR #message("${${QM${_v}_VAR}}")
("x${_i}" STREQUAL "xSHARED") OR list(APPEND ${CPP${_v}_VAR} ${CPP_LIST})
("x${_i}" STREQUAL "xMODULE") OR list(APPEND ${CPP${_v}_VAR} ${RC_LIST})
("x${_i}" STREQUAL "xEXCLUDE_FROM_ALL")) list(APPEND ${CPP${_v}_VAR} ${MOCS${_v}})
list(APPEND ${_P} ${_i}) list(APPEND ${CPP${_v}_VAR} ${CUIS${_v}})
elseif ("x${${_i}}" STREQUAL "x") list(APPEND ${CPP${_v}_VAR} ${CRES${_v}})
list(APPEND ${_A} ${_i}) if (WAS_QM_ARG)
else() list(APPEND ${CPP${_v}_VAR} ${${QM${_v}_VAR}})
list(APPEND ${_A} ${${_i}}) endif()
endif() #message("${${QM${_v}_VAR}}")
endforeach() endif()
endmacro() endforeach()
set(CMAKE_CURRENT_BINARY_DIR ${SRC_CMAKE_CURRENT_BINARY_DIR})
endmacro()
macro(__qt_set_defines _NAME _T)
target_compile_definitions(${_T} PRIVATE "__TARGET_NAME__=\"${_NAME}\"")
target_compile_definitions(${_T} PRIVATE "__TARGET_LABEL__=\"${${_NAME}_LABEL}\"") macro(_qt_split_add_args _P _A)
target_compile_definitions(${_T} PRIVATE "__TARGET_COMPANY__=\"${${_NAME}_COMPANY}\"") set(${_P})
target_compile_definitions(${_T} PRIVATE "__TARGET_VERSION__=\"${${_NAME}_VERSION}\"") set(${_A})
endmacro() foreach(_i ${ARGN})
if (NOT ("x${${_i}_Qt${_v}}" STREQUAL "x"))
list(APPEND ${_A} ${${_i}_Qt${_v}})
macro(qt_add_executable _NAME) elseif (("x${_i}" STREQUAL "xWIN32") OR
foreach(_v ${_QT_VERSIONS_}) ("x${_i}" STREQUAL "xMACOSX_BUNDLE") OR
if (LOCAL_FOUND${_v}) ("x${_i}" STREQUAL "xSTATIC") OR
_qt_split_add_args(_PREF _ARGS ${ARGN}) ("x${_i}" STREQUAL "xSHARED") OR
if(APPLE) ("x${_i}" STREQUAL "xMODULE") OR
set(_PREV_CIND "${CMAKE_INSTALL_NAME_DIR}") ("x${_i}" STREQUAL "xEXCLUDE_FROM_ALL"))
set(CMAKE_INSTALL_NAME_DIR "@rpath") list(APPEND ${_P} ${_i})
else() elseif ("x${${_i}}" STREQUAL "x")
if(NOT WIN32) list(APPEND ${_A} ${_i})
set(CMAKE_INSTALL_RPATH "\$ORIGIN;\$ORIGIN/lib") else()
endif() list(APPEND ${_A} ${${_i}})
endif() endif()
set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}}) endforeach()
add_executable(${_TARGET} ${_PREF} ${_ARGS}) endmacro()
set(_${_NAME}_is_qt 1)
target_include_directories(${_TARGET} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/qt${_v} ${Qt${_v}_INCLUDES})
__qt_set_defines(${_NAME} ${_TARGET}) macro(__qt_set_defines _NAME _T)
target_compile_definitions(${_T} PRIVATE "__TARGET_NAME__=\"${_NAME}\"")
if(APPLE) target_compile_definitions(${_T} PRIVATE "__TARGET_LABEL__=\"${${_NAME}_LABEL}\"")
set(CMAKE_INSTALL_NAME_DIR "${_PREV_CIND}") target_compile_definitions(${_T} PRIVATE "__TARGET_COMPANY__=\"${${_NAME}_COMPANY}\"")
endif() target_compile_definitions(${_T} PRIVATE "__TARGET_VERSION__=\"${${_NAME}_VERSION}\"")
# # Apple crosscompiling rpath patch endmacro()
# if (APPLE AND CMAKE_CROSSCOMPILING AND CMAKE_MACOSX_RPATH)
# foreach(_RP ${CMAKE_INSTALL_RPATH})
# add_custom_command(TARGET ${_TARGET} POST_BUILD macro(qt_add_executable _NAME)
# COMMAND "${CMAKE_INSTALL_NAME_TOOL}" foreach(_v ${_QT_VERSIONS_})
# "-add_rpath" "${_RP}" if (LOCAL_FOUND${_v})
# "$<TARGET_FILE_DIR:${_TARGET}>/$<TARGET_FILE_NAME:${_TARGET}>" _qt_split_add_args(_PREF _ARGS ${ARGN})
# COMMENT "Add to ${_TARGET} rpath \"${_RP}\"") if(APPLE)
# endforeach() set(_PREV_CIND "${CMAKE_INSTALL_NAME_DIR}")
# endif() set(CMAKE_INSTALL_NAME_DIR "@rpath")
else()
#list(APPEND _ALL_TARGETS "${_TARGET}") if(NOT WIN32)
#set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE) set(CMAKE_INSTALL_RPATH "\$ORIGIN;\$ORIGIN/lib")
endif() endif()
endforeach() endif()
endmacro() set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}})
add_executable(${_TARGET} ${_PREF} ${_ARGS})
set(_${_NAME}_is_qt 1)
macro(qt_add_library _NAME) target_include_directories(${_TARGET} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/qt${_v} ${Qt${_v}_INCLUDES})
foreach(_v ${_QT_VERSIONS_}) __qt_set_defines(${_NAME} ${_TARGET})
if (LOCAL_FOUND${_v})
_qt_split_add_args(_PREF _ARGS ${ARGN}) if(APPLE)
if(APPLE) set(CMAKE_INSTALL_NAME_DIR "${_PREV_CIND}")
set(_PREV_CIND "${CMAKE_INSTALL_NAME_DIR}") endif()
set(CMAKE_INSTALL_NAME_DIR "@rpath") # # Apple crosscompiling rpath patch
else() # if (APPLE AND CMAKE_CROSSCOMPILING AND CMAKE_MACOSX_RPATH)
if(NOT WIN32) # foreach(_RP ${CMAKE_INSTALL_RPATH})
set(CMAKE_INSTALL_RPATH "\$ORIGIN;\$ORIGIN/lib") # add_custom_command(TARGET ${_TARGET} POST_BUILD
endif() # COMMAND "${CMAKE_INSTALL_NAME_TOOL}"
endif() # "-add_rpath" "${_RP}"
set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}}) # "$<TARGET_FILE_DIR:${_TARGET}>/$<TARGET_FILE_NAME:${_TARGET}>"
add_library(${_TARGET} ${_PREF} ${_ARGS}) # COMMENT "Add to ${_TARGET} rpath \"${_RP}\"")
set(_${_NAME}_is_qt 1) # endforeach()
target_include_directories(${_TARGET} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/qt${_v} ${Qt${_v}_INCLUDES}) # endif()
__qt_set_defines(${_NAME} ${_TARGET})
#message("add lib: \"${_TARGET}\"") #list(APPEND _ALL_TARGETS "${_TARGET}")
#set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
if(APPLE) endif()
set(CMAKE_INSTALL_NAME_DIR "${_PREV_CIND}") endforeach()
endif() endmacro()
# # Apple crosscompiling rpath patch
# if (APPLE AND CMAKE_CROSSCOMPILING AND CMAKE_MACOSX_RPATH)
# foreach(_RP ${CMAKE_INSTALL_RPATH}) macro(qt_add_library _NAME)
# add_custom_command(TARGET ${_TARGET} POST_BUILD foreach(_v ${_QT_VERSIONS_})
# COMMAND "${CMAKE_INSTALL_NAME_TOOL}" if (LOCAL_FOUND${_v})
# "-add_rpath" "${_RP}" _qt_split_add_args(_PREF _ARGS ${ARGN})
# "$<TARGET_FILE_DIR:${_TARGET}>/$<TARGET_FILE_NAME:${_TARGET}>" if(APPLE)
# COMMENT "Add to ${_TARGET} rpath \"${_RP}\"") set(_PREV_CIND "${CMAKE_INSTALL_NAME_DIR}")
# endforeach() set(CMAKE_INSTALL_NAME_DIR "@rpath")
# endif() else()
if(NOT WIN32)
list(APPEND _ALL_TARGETS "${_TARGET}") set(CMAKE_INSTALL_RPATH "\$ORIGIN;\$ORIGIN/lib")
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE) endif()
endif() endif()
endforeach() set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}})
endmacro() add_library(${_TARGET} ${_PREF} ${_ARGS})
set(_${_NAME}_is_qt 1)
target_include_directories(${_TARGET} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/qt${_v} ${Qt${_v}_INCLUDES})
macro(_qt_multitarget_suffix_ _OUT _IN _v) __qt_set_defines(${_NAME} ${_TARGET})
string(REPLACE ":" "_" _in_str "${_IN}") #message("add lib: \"${_TARGET}\"")
if (NOT "x${MULTILIB_${_in_str}_SUFFIX_Qt${_v}}" STREQUAL "x")
set(${_OUT} "${MULTILIB_${_in_str}_SUFFIX_Qt${_v}}") if(APPLE)
else() set(CMAKE_INSTALL_NAME_DIR "${_PREV_CIND}")
set(${_OUT} "${MULTILIB_SUFFIX_Qt${_v}}") endif()
endif() # # Apple crosscompiling rpath patch
endmacro() # if (APPLE AND CMAKE_CROSSCOMPILING AND CMAKE_MACOSX_RPATH)
# foreach(_RP ${CMAKE_INSTALL_RPATH})
# add_custom_command(TARGET ${_TARGET} POST_BUILD
macro(qt_target_link_libraries _NAME) # COMMAND "${CMAKE_INSTALL_NAME_TOOL}"
foreach(_v ${_QT_VERSIONS_}) # "-add_rpath" "${_RP}"
if (LOCAL_FOUND${_v}) # "$<TARGET_FILE_DIR:${_TARGET}>/$<TARGET_FILE_NAME:${_TARGET}>"
set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}}) # COMMENT "Add to ${_TARGET} rpath \"${_RP}\"")
set(_ARGS) # endforeach()
foreach(_i ${ARGN}) # endif()
set(_ind -1)
list(FIND QT_MULTILIB_LIST "${_i}" _ind) list(APPEND _ALL_TARGETS "${_TARGET}")
if (_ind GREATER -1) set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
_qt_multitarget_suffix_(_TS ${_i} ${_v}) endif()
#message(STATUS "${_i} in MULTILIB_LIST, suffix = ${_TS}") endforeach()
list(APPEND _ARGS ${_i}${_TS}) endmacro()
else()
list(APPEND _ARGS ${_i})
endif() macro(_qt_multitarget_suffix_ _OUT _IN _v)
endforeach() string(REPLACE ":" "_" _in_str "${_IN}")
target_link_libraries(${_TARGET} ${Qt${_v}_LIBRARIES} ${_ARGS}) if (NOT "x${MULTILIB_${_in_str}_SUFFIX_Qt${_v}}" STREQUAL "x")
#message("link ${_TARGET}: ${Qt${_v}_LIBRARIES} ${_ARGS}") set(${_OUT} "${MULTILIB_${_in_str}_SUFFIX_Qt${_v}}")
endif() else()
endforeach() set(${_OUT} "${MULTILIB_SUFFIX_Qt${_v}}")
endmacro() endif()
endmacro()
macro(qt_target_compile_definitions _NAME)
foreach(_v ${_QT_VERSIONS_}) macro(qt_target_link_libraries _NAME)
if (LOCAL_FOUND${_v}) foreach(_v ${_QT_VERSIONS_})
set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}}) if (LOCAL_FOUND${_v})
target_compile_definitions(${_TARGET} ${ARGN}) set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}})
endif() set(_ARGS)
endforeach() foreach(_i ${ARGN})
endmacro() set(_ind -1)
list(FIND QT_MULTILIB_LIST "${_i}" _ind)
if (_ind GREATER -1)
macro(qt_target_include_directories _NAME) _qt_multitarget_suffix_(_TS ${_i} ${_v})
foreach(_v ${_QT_VERSIONS_}) #message(STATUS "${_i} in MULTILIB_LIST, suffix = ${_TS}")
if (LOCAL_FOUND${_v}) list(APPEND _ARGS ${_i}${_TS})
set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}}) else()
target_include_directories(${_TARGET} ${ARGN}) list(APPEND _ARGS ${_i})
endif() endif()
endforeach() endforeach()
endmacro() target_link_libraries(${_TARGET} ${Qt${_v}_LIBRARIES} ${_ARGS})
#message("link ${_TARGET}: ${Qt${_v}_LIBRARIES} ${_ARGS}")
endif()
macro(qt_install) endforeach()
set(_prev_inst) endmacro()
set(__add_args)
#message("command: ${ARGN}")
foreach(_v ${_QT_VERSIONS_}) macro(qt_target_compile_definitions _NAME)
if (LOCAL_FOUND${_v}) foreach(_v ${_QT_VERSIONS_})
set(_INST_LIST) if (LOCAL_FOUND${_v})
set(_IS_TARGET 0) set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}})
set(_IS_FILES 0) target_compile_definitions(${_TARGET} ${ARGN})
set(_IS_DEST 0) endif()
set(_IS_LANG 0) endforeach()
set(_INVALID 0) endmacro()
foreach(_i ${ARGN})
if ("x${_i}" STREQUAL "xQtLang")
set(_IS_LANG 1) macro(qt_target_include_directories _NAME)
endif() foreach(_v ${_QT_VERSIONS_})
endforeach() if (LOCAL_FOUND${_v})
foreach(_i ${ARGN}) set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}})
if (_IS_TARGET) target_include_directories(${_TARGET} ${ARGN})
set(_IS_TARGET 0) endif()
set(__target ${_i}) endforeach()
if (_${_i}_is_qt) endmacro()
set(__target ${_i}${TARGET_SUFFIX_Qt${_v}})
endif()
if (DEFINED ANDROID_PLATFORM) macro(qt_install)
get_target_property(_TT ${__target} TYPE) set(_prev_inst)
if ("x${_TT}" STREQUAL "xEXECUTABLE") set(__add_args)
list(APPEND __add_args EXCLUDE_FROM_ALL) #message("command: ${ARGN}")
endif() foreach(_v ${_QT_VERSIONS_})
endif() if (LOCAL_FOUND${_v})
list(APPEND _INST_LIST ${__target}) set(_INST_LIST)
elseif (_IS_FILES) set(_IS_TARGET 0)
set(_IS_FILES 0) set(_IS_FILES 0)
if (_IS_LANG) set(_IS_DEST 0)
if (("x${${_i}_Qt${_v}}" STREQUAL "x") OR ("x${_i}" STREQUAL "xDESTINATION")) set(_IS_LANG 0)
set(_INVALID 1) set(_INVALID 0)
else() foreach(_i ${ARGN})
list(APPEND _INST_LIST ${${_i}_Qt${_v}}) if ("x${_i}" STREQUAL "xQtLang")
endif() set(_IS_LANG 1)
else() endif()
list(APPEND _INST_LIST ${_i}) endforeach()
endif() foreach(_i ${ARGN})
else() if (_IS_TARGET)
if (_IS_DEST) set(_IS_TARGET 0)
set(_IS_DEST 0) set(__target ${_i})
if ("x${_i}" STREQUAL "xQtBin") if (_${_i}_is_qt)
list(APPEND _INST_LIST "${Qt${_v}_BIN}") set(__target ${_i}${TARGET_SUFFIX_Qt${_v}})
elseif ("x${_i}" STREQUAL "xQtLang") endif()
list(APPEND _INST_LIST "${Qt${_v}_LANG_DIR}") if (DEFINED ANDROID_PLATFORM)
else() get_target_property(_TT ${__target} TYPE)
set(_ind -1) if ("x${_TT}" STREQUAL "xEXECUTABLE")
string(FIND "${_i}" "QtPlugins" _ind) list(APPEND __add_args EXCLUDE_FROM_ALL)
if (_ind GREATER -1) endif()
string(REPLACE "QtPlugins" "${Qt${_v}_PLUGINS_DIR}" _o "${_i}") endif()
list(APPEND _INST_LIST "${_o}") list(APPEND _INST_LIST ${__target})
else() elseif (_IS_FILES)
string(REPLACE "\\" "/" _o "${_i}") set(_IS_FILES 0)
list(APPEND _INST_LIST ${_o}) if (_IS_LANG)
endif() if (("x${${_i}_Qt${_v}}" STREQUAL "x") OR ("x${_i}" STREQUAL "xDESTINATION"))
endif() set(_INVALID 1)
else() else()
set(_ii ${_i}) list(APPEND _INST_LIST ${${_i}_Qt${_v}})
if ("x${_i}" STREQUAL "xTARGETS") endif()
set(_IS_TARGET 1) else()
elseif ("x${_i}" STREQUAL "xFILES") list(APPEND _INST_LIST ${_i})
set(_IS_FILES 1) endif()
elseif ("x${_i}" STREQUAL "xDESTINATION") else()
set(_IS_DEST 1) if (_IS_DEST)
elseif ("x${_i}" STREQUAL "xLANG") set(_IS_DEST 0)
set(_IS_FILES 1) if ("x${_i}" STREQUAL "xQtBin")
set(_IS_LANG 1) list(APPEND _INST_LIST "${Qt${_v}_BIN}")
set(_ii "FILES") elseif ("x${_i}" STREQUAL "xQtLang")
endif() list(APPEND _INST_LIST "${Qt${_v}_LANG_DIR}")
list(APPEND _INST_LIST ${_ii}) else()
endif() set(_ind -1)
endif() string(FIND "${_i}" "QtPlugins" _ind)
endforeach() if (_ind GREATER -1)
if (NOT _INVALID) string(REPLACE "QtPlugins" "${Qt${_v}_PLUGINS_DIR}" _o "${_i}")
if (NOT ("x${_prev_inst}" STREQUAL "x${_INST_LIST}")) list(APPEND _INST_LIST "${_o}")
#message("install: ${_INST_LIST}") else()
install(${_INST_LIST} ${__add_args}) string(REPLACE "\\" "/" _o "${_i}")
set(_prev_inst "${_INST_LIST}") list(APPEND _INST_LIST ${_o})
endif() endif()
endif() endif()
endif() else()
endforeach() set(_ii ${_i})
endmacro() if ("x${_i}" STREQUAL "xTARGETS")
set(_IS_TARGET 1)
elseif ("x${_i}" STREQUAL "xFILES")
macro(qt_install_lang _NAME) set(_IS_FILES 1)
set(_prev_inst) elseif ("x${_i}" STREQUAL "xDESTINATION")
#message("command: ${ARGN}") set(_IS_DEST 1)
set(_PATHS) elseif ("x${_i}" STREQUAL "xLANG")
set(_DEST) set(_IS_FILES 1)
if(CMAKE_CROSSCOMPILING) set(_IS_LANG 1)
list(APPEND _PATHS "${CMAKE_PREFIX_PATH}/lang") set(_ii "FILES")
endif() endif()
set(_cur_arg) list(APPEND _INST_LIST ${_ii})
set(__args "DESTINATION;PATHS") endif()
foreach(_i ${ARGN}) endif()
if (_i IN_LIST __args) endforeach()
set(_cur_arg "${_i}") if (NOT _INVALID)
elseif("${_cur_arg}" STREQUAL "DESTINATION") if (NOT ("x${_prev_inst}" STREQUAL "x${_INST_LIST}"))
set(_DEST "${_i}") #message("install: ${_INST_LIST}")
elseif("${_cur_arg}" STREQUAL "PATHS") install(${_INST_LIST} ${__add_args})
list(APPEND _PATHS "${_i}") set(_prev_inst "${_INST_LIST}")
endif() endif()
endforeach() endif()
foreach(_v ${_QT_VERSIONS_}) endif()
if (LOCAL_FOUND${_v}) endforeach()
set(_target) endmacro()
if (_${_NAME}_is_qt)
set(_target ${_NAME}${TARGET_SUFFIX_Qt${_v}})
endif() macro(qt_install_lang _NAME)
get_target_property(_LL ${_target} LINK_LIBRARIES) set(_prev_inst)
foreach (_L ${_LL}) #message("command: ${ARGN}")
get_filename_component(_libname "${_L}" NAME_WE) set(_PATHS)
#message("depend on ${_libname}") set(_DEST)
if ("${_libname}" MATCHES "Qt${_v}::.*") if(CMAKE_CROSSCOMPILING)
string(SUBSTRING "${_libname}" 5 -1 _libname) list(APPEND _PATHS "${CMAKE_PREFIX_PATH}/lang")
string(TOLOWER "${_libname}" _libname) endif()
#message("qt lib \"${_libname}\"") set(_cur_arg)
list(APPEND _qt_libs qt${_libname}) set(__args "DESTINATION;PATHS")
else() foreach(_i ${ARGN})
if ("${_libname}" MATCHES "lib.*") if (_i IN_LIST __args)
string(LENGTH ${_libname} _sl) set(_cur_arg "${_i}")
math(EXPR _sl ${_sl}-3) elseif("${_cur_arg}" STREQUAL "DESTINATION")
string(SUBSTRING ${_libname} 3 ${_sl} _libname) set(_DEST "${_i}")
endif() elseif("${_cur_arg}" STREQUAL "PATHS")
if ("${_libname}" MATCHES "qad_.*${_v}") list(APPEND _PATHS "${_i}")
string(LENGTH ${_libname} _sl) endif()
math(EXPR _sl ${_sl}-1) endforeach()
string(SUBSTRING ${_libname} 0 ${_sl} _libname) foreach(_v ${_QT_VERSIONS_})
#message("qad lib \"${_libname}\"") if (LOCAL_FOUND${_v})
list(APPEND _qt_libs ${_libname}) set(_target)
endif() if (_${_NAME}_is_qt)
endif() set(_target ${_NAME}${TARGET_SUFFIX_Qt${_v}})
endforeach() endif()
if (NOT "x${_qt_libs}" STREQUAL "x") get_target_property(_LL ${_target} LINK_LIBRARIES)
list(APPEND _qt_libs "qtbase") foreach (_L ${_LL})
foreach (_i ${${PROJECT_NAME}_LANG}) get_filename_component(_libname "${_L}" NAME_WE)
foreach (_l ${_qt_libs}) #message("depend on ${_libname}")
unset(_qm_path CACHE) if ("${_libname}" MATCHES "Qt${_v}::.*")
find_file(_qm_path "${_l}_${_i}.qm" PATHS "${Qt${_v}_LANG_DIR}" ${_PATHS} NO_DEFAULT_PATH) string(SUBSTRING "${_libname}" 5 -1 _libname)
if (EXISTS "${_qm_path}") string(TOLOWER "${_libname}" _libname)
install(FILES ${_qm_path} DESTINATION "${_DEST}") #message("qt lib \"${_libname}\"")
#message("qm = \"${_qm_path}\"") list(APPEND _qt_libs qt${_libname})
endif() else()
endforeach() if ("${_libname}" MATCHES "lib.*")
endforeach() string(LENGTH ${_libname} _sl)
endif() math(EXPR _sl ${_sl}-3)
endif() string(SUBSTRING ${_libname} 3 ${_sl} _libname)
endforeach() endif()
endmacro() if ("${_libname}" MATCHES "qad_.*${_v}")
string(LENGTH ${_libname} _sl)
math(EXPR _sl ${_sl}-1)
string(SUBSTRING ${_libname} 0 ${_sl} _libname)
#message("qad lib \"${_libname}\"")
list(APPEND _qt_libs ${_libname})
endif()
endif()
endforeach()
if (NOT "x${_qt_libs}" STREQUAL "x")
list(APPEND _qt_libs "qtbase")
foreach (_i ${${PROJECT_NAME}_LANG})
foreach (_l ${_qt_libs})
unset(_qm_path CACHE)
find_file(_qm_path "${_l}_${_i}.qm" PATHS "${Qt${_v}_LANG_DIR}" ${_PATHS} NO_DEFAULT_PATH)
if (EXISTS "${_qm_path}")
install(FILES ${_qm_path} DESTINATION "${_DEST}")
#message("qm = \"${_qm_path}\"")
endif()
endforeach()
endforeach()
endif()
endif()
endforeach()
endmacro()
macro(qt_get_target _NAME _OUT)
set(${_OUT})
set(_ver)
foreach(_i ${ARGN})
foreach(_v ${_QT_VERSIONS_})
if ("x${_i}" STREQUAL "xQt${_v}")
set(_ver ${_v})
break()
endif()
endforeach()
if (NOT "x${_ver}" STREQUAL "x")
break()
endif()
endforeach()
foreach(_v ${_QT_VERSIONS_})
if (LOCAL_FOUND${_v} AND (("x${_ver}" STREQUAL "x") OR ((NOT "x${_ver}" STREQUAL "x") AND ("x${_ver}" STREQUAL "x${_v}"))))
set(${_OUT} ${_NAME}${TARGET_SUFFIX_Qt${_v}})
endif()
endforeach()
endmacro()
macro(qt_get_targets _NAME _OUT)
set(${_OUT})
foreach(_v ${_QT_VERSIONS_})
if (LOCAL_FOUND${_v})
list(APPEND ${_OUT} ${_NAME}${TARGET_SUFFIX_Qt${_v}})
endif()
endforeach()
endmacro()
macro(qt_generate_export_header _NAME)
qt_get_target(${_NAME} _some_target)
qt_get_target(${_NAME} _targets)
foreach(_t ${_targets})
set_target_properties(${_t} PROPERTIES DEFINE_SYMBOL ${_NAME}_EXPORTS)
endforeach()
set_target_properties(${_some_target} PROPERTIES DEFINE_SYMBOL ${_NAME}_EXPORTS)
generate_export_header(${_some_target} BASE_NAME "${_NAME}" ${ARGN})
endmacro()

View File

@@ -20,8 +20,9 @@
#ifndef ABOUTWINDOW_H #ifndef ABOUTWINDOW_H
#define ABOUTWINDOW_H #define ABOUTWINDOW_H
#include "qad_export.h"
#include <QDialog> #include <QDialog>
#include "qad_application_export.h"
#define ADD_ABOUT_VERSION(lib) \ #define ADD_ABOUT_VERSION(lib) \
{ \ { \
@@ -47,7 +48,7 @@ namespace Ui {
class AboutWindow; class AboutWindow;
} }
class QAD_EXPORT AboutWindow: public QDialog class QAD_APPLICATION_EXPORT AboutWindow: public QDialog
{ {
Q_OBJECT Q_OBJECT
typedef QPair<QString, QString> SSPair; typedef QPair<QString, QString> SSPair;

View File

@@ -114,7 +114,7 @@
<string>OK</string> <string>OK</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../widgets/qad_widgets.qrc"> <iconset resource="qad_application.qrc">
<normaloff>:/icons/dialog-ok-apply.png</normaloff>:/icons/dialog-ok-apply.png</iconset> <normaloff>:/icons/dialog-ok-apply.png</normaloff>:/icons/dialog-ok-apply.png</iconset>
</property> </property>
</widget> </widget>
@@ -131,7 +131,6 @@
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../widgets/qad_widgets.qrc"/>
<include location="qad_application.qrc"/> <include location="qad_application.qrc"/>
</resources> </resources>
<connections> <connections>

View File

@@ -27,10 +27,10 @@
#include <QIcon> #include <QIcon>
#include <QToolButton> #include <QToolButton>
#include <QDebug> #include <QDebug>
#include "qad_export.h" #include "qad_application_export.h"
class QAD_EXPORT EDockWidget: public QDockWidget class QAD_APPLICATION_EXPORT EDockWidget: public QDockWidget
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@@ -32,9 +32,10 @@
#include <QSplitter> #include <QSplitter>
#include "session_manager.h" #include "session_manager.h"
#include "ribbon.h" #include "ribbon.h"
#include "qad_application_export.h"
class QAD_EXPORT UAction: public QAction { class QAD_APPLICATION_EXPORT UAction: public QAction {
Q_OBJECT Q_OBJECT
public: public:
UAction(int ind,const QString & text, QObject * parent): QAction(text, parent) { UAction(int ind,const QString & text, QObject * parent): QAction(text, parent) {
@@ -67,7 +68,7 @@ signals:
}; };
class QAD_EXPORT EMainWindow: public QMainWindow class QAD_APPLICATION_EXPORT EMainWindow: public QMainWindow
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(int maxRecentItems READ maxRecentItems WRITE setMaxRecentItems) Q_PROPERTY(int maxRecentItems READ maxRecentItems WRITE setMaxRecentItems)

View File

@@ -30,10 +30,10 @@
#include <QLayout> #include <QLayout>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QApplication> #include <QApplication>
#include "qad_export.h" #include "qad_application_export.h"
class QAD_EXPORT ETabWidget: public QTabWidget class QAD_APPLICATION_EXPORT ETabWidget: public QTabWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
@@ -51,7 +51,7 @@ private:
void tabRemoved(int) {emit countChanged();} void tabRemoved(int) {emit countChanged();}
void changeEvent(QEvent * e); void changeEvent(QEvent * e);
struct TabButton { struct QAD_APPLICATION_EXPORT TabButton {
TabButton(int r, const QIcon & i, const QString & t) {role = r; icon = i; visible = true; srcToolTip = t; toolTip = QApplication::translate("MainWindow", t.toUtf8(), 0/*, QCoreApplication::UnicodeUTF8*/);} TabButton(int r, const QIcon & i, const QString & t) {role = r; icon = i; visible = true; srcToolTip = t; toolTip = QApplication::translate("MainWindow", t.toUtf8(), 0/*, QCoreApplication::UnicodeUTF8*/);}
int role; int role;
bool visible; bool visible;

View File

@@ -22,10 +22,10 @@
#include <QListWidget> #include <QListWidget>
#include <QDebug> #include <QDebug>
#include "qad_export.h" #include "qad_application_export.h"
class QAD_EXPORT HistoryView: public QListWidget class QAD_APPLICATION_EXPORT HistoryView: public QListWidget
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool active READ isActive WRITE setActive) Q_PROPERTY(bool active READ isActive WRITE setActive)
@@ -46,7 +46,7 @@ public:
void registerAction(int action, const QString & text, const QImage & icon = QImage()); void registerAction(int action, const QString & text, const QImage & icon = QImage());
private: private:
struct Action { struct QAD_APPLICATION_EXPORT Action {
Action(int i = -1, const QString & t = QString(), const QImage & c = QImage()): id(i), text(t) { Action(int i = -1, const QString & t = QString(), const QImage & c = QImage()): id(i), text(t) {
QPixmap px = QPixmap::fromImage(c); QPixmap px = QPixmap::fromImage(c);
icon.addPixmap(px, QIcon::Active); icon.addPixmap(px, QIcon::Active);
@@ -58,7 +58,7 @@ private:
QString text; QString text;
QIcon icon; QIcon icon;
}; };
struct Entry { struct QAD_APPLICATION_EXPORT Entry {
Entry(int a = -1, const QByteArray & c = QByteArray()): action(a), command(c) {} Entry(int a = -1, const QByteArray & c = QByteArray()): action(a), command(c) {}
int action; int action;
QByteArray command; QByteArray command;

View File

@@ -30,7 +30,7 @@
# include <QRegExp> # include <QRegExp>
typedef QRegExp QRegularExpression; typedef QRegExp QRegularExpression;
#endif #endif
#include "qad_export.h" #include "qad_application_export.h"
class QTextEdit; class QTextEdit;
class QTextBlock; class QTextBlock;
@@ -40,7 +40,7 @@ namespace Ui {
class LogView; class LogView;
} }
class QAD_EXPORT LogView: public QWidget class QAD_APPLICATION_EXPORT LogView: public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool filterVisible READ isFilterVisible WRITE setFilterVisible) Q_PROPERTY(bool filterVisible READ isFilterVisible WRITE setFilterVisible)
@@ -75,7 +75,7 @@ public:
void addText(const QString & text, bool insert_newline = true); void addText(const QString & text, bool insert_newline = true);
private: private:
struct Category { struct QAD_APPLICATION_EXPORT Category {
Category(); Category();
void makeIcon(QSize size, QSize size_icon); void makeIcon(QSize size, QSize size_icon);
QString label; QString label;

View File

@@ -1,34 +1,17 @@
<RCC> <RCC>
<qresource prefix="/"> <qresource prefix="/">
<file>../../icons/application-exit.png</file> <file>../../icons/dialog-ok-apply.png</file>
<file>../../icons/dialog-close.png</file>
<file>../../icons/configure.png</file> <file>../../icons/configure.png</file>
<file>../../icons/document-edit.png</file>
<file>../../icons/document-new.png</file>
<file>../../icons/document-save.png</file>
<file>../../icons/document-save-all.png</file>
<file>../../icons/document-save-as.png</file>
<file>../../icons/document-open.png</file>
<file>../../icons/document-open-recent.png</file>
<file>../../icons/document-close.png</file>
<file>../../icons/edit-clear.png</file> <file>../../icons/edit-clear.png</file>
<file>../../icons/edit-clear-locationbar-rtl.png</file>
<file>../../icons/edit-find.png</file> <file>../../icons/edit-find.png</file>
<file>../../icons/list-add.png</file>
<file>../../icons/edit-delete.png</file>
<file>../../icons/edit-copy.png</file> <file>../../icons/edit-copy.png</file>
<file>../../icons/edit-paste.png</file>
<file>../../icons/edit-undo.png</file>
<file>../../icons/edit-redo.png</file>
<file>../../icons/border-line.png</file>
<file>../../icons/edockwidget.png</file> <file>../../icons/edockwidget.png</file>
<file>../../icons/historyview.png</file> <file>../../icons/historyview.png</file>
<file>../../icons/logview.png</file>
<file>../../icons/clear-history.png</file> <file>../../icons/clear-history.png</file>
<file>../../icons/layer-visible-off.png</file> <file>../../icons/layer-visible-off.png</file>
<file>../../icons/layer-visible-on.png</file> <file>../../icons/layer-visible-on.png</file>
<file>../../icons/logview.png</file>
<file>../../icons/qt.png</file> <file>../../icons/qt.png</file>
<file>../../icons/select-all.png</file> <file>../../icons/select-all.png</file>
<file>../../icons/select-none.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -22,10 +22,10 @@
#include <QThread> #include <QThread>
#include <QSharedMemory> #include <QSharedMemory>
#include "qad_export.h" #include "qad_application_export.h"
class QAD_EXPORT QSingleApplication: public QThread class QAD_APPLICATION_EXPORT QSingleApplication: public QThread
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@@ -31,9 +31,10 @@
#include <QToolButton> #include <QToolButton>
#include <QScrollArea> #include <QScrollArea>
#include "etabwidget.h" #include "etabwidget.h"
#include "qad_application_export.h"
class QAD_EXPORT Ribbon: public QToolBar class QAD_APPLICATION_EXPORT Ribbon: public QToolBar
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@@ -24,10 +24,10 @@
#include <QPen> #include <QPen>
#include <QBrush> #include <QBrush>
#include <QFont> #include <QFont>
#include "qad_export.h" #include "qad_blockview_export.h"
class QAD_EXPORT AlignedTextItem: public QGraphicsItem { class QAD_BLOCKVIEW_EXPORT AlignedTextItem: public QGraphicsItem {
public: public:
AlignedTextItem(QGraphicsItem * parent = 0); AlignedTextItem(QGraphicsItem * parent = 0);
AlignedTextItem(const QString & text, QGraphicsItem * parent = 0); AlignedTextItem(const QString & text, QGraphicsItem * parent = 0);

View File

@@ -29,6 +29,7 @@
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QStack> #include <QStack>
#include "qad_types.h" #include "qad_types.h"
#include "qad_blockview_export.h"
/// data: /// data:
@@ -69,11 +70,11 @@ enum BlockviewItemType {
bvitItemText, bvitItemText,
}; };
QAD_EXPORT QDataStream & operator <<(QDataStream & s, const QGraphicsItem * item); QAD_BLOCKVIEW_EXPORT QDataStream & operator <<(QDataStream & s, const QGraphicsItem * item);
QAD_EXPORT QDataStream & operator >>(QDataStream & s, QGraphicsItem *& item); QAD_BLOCKVIEW_EXPORT QDataStream & operator >>(QDataStream & s, QGraphicsItem *& item);
class QAD_EXPORT BlockItemBase: public QObject class QAD_BLOCKVIEW_EXPORT BlockItemBase: public QObject
{ {
Q_OBJECT Q_OBJECT
Q_ENUMS(Action) Q_ENUMS(Action)

View File

@@ -21,9 +21,10 @@
#define BLOCKBUSITEM_H #define BLOCKBUSITEM_H
#include "blockitem.h" #include "blockitem.h"
#include "qad_blockview_export.h"
class QAD_EXPORT BlockBusItem: public QGraphicsObject, public PropertyStorage { class QAD_BLOCKVIEW_EXPORT BlockBusItem: public QGraphicsObject, public PropertyStorage {
Q_OBJECT Q_OBJECT
Q_INTERFACES(QGraphicsItem) Q_INTERFACES(QGraphicsItem)
Q_PROPERTY(double pointSize READ pointSize WRITE setPointSize DESIGNABLE false SCRIPTABLE false) Q_PROPERTY(double pointSize READ pointSize WRITE setPointSize DESIGNABLE false SCRIPTABLE false)

View File

@@ -24,6 +24,7 @@
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include "blockitem.h" #include "blockitem.h"
#include "qad_blockview_export.h"
namespace Ui { namespace Ui {
@@ -31,7 +32,7 @@ namespace Ui {
} }
class QAD_EXPORT BlockEditor : public QWidget class QAD_BLOCKVIEW_EXPORT BlockEditor : public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool editorMode READ editorMode WRITE setEditorMode) Q_PROPERTY(bool editorMode READ editorMode WRITE setEditorMode)
@@ -84,7 +85,7 @@ private:
class QAD_EXPORT PinAlignDelegate: public QStyledItemDelegate { class QAD_BLOCKVIEW_EXPORT PinAlignDelegate: public QStyledItemDelegate {
Q_OBJECT Q_OBJECT
public: public:
PinAlignDelegate(QObject * parent = 0): QStyledItemDelegate(parent) {} PinAlignDelegate(QObject * parent = 0): QStyledItemDelegate(parent) {}
@@ -95,7 +96,7 @@ public:
}; };
class QAD_EXPORT PinBusDelegate: public QStyledItemDelegate { class QAD_BLOCKVIEW_EXPORT PinBusDelegate: public QStyledItemDelegate {
Q_OBJECT Q_OBJECT
public: public:
PinBusDelegate(QObject * parent = 0): QStyledItemDelegate(parent) {} PinBusDelegate(QObject * parent = 0): QStyledItemDelegate(parent) {}

View File

@@ -194,7 +194,7 @@
<string>Add</string> <string>Add</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../utils/qad_utils.qrc"> <iconset resource="qad_blockview.qrc">
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset> <normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
</property> </property>
</widget> </widget>
@@ -205,7 +205,7 @@
<string>Clone</string> <string>Clone</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../utils/qad_utils.qrc"> <iconset resource="qad_blockview.qrc">
<normaloff>:/icons/edit-copy.png</normaloff>:/icons/edit-copy.png</iconset> <normaloff>:/icons/edit-copy.png</normaloff>:/icons/edit-copy.png</iconset>
</property> </property>
</widget> </widget>
@@ -232,7 +232,7 @@
<string>Remove selected</string> <string>Remove selected</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../utils/qad_utils.qrc"> <iconset resource="qad_blockview.qrc">
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset> <normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
</property> </property>
</widget> </widget>
@@ -243,7 +243,7 @@
<string>Remove all</string> <string>Remove all</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../utils/qad_utils.qrc"> <iconset resource="qad_blockview.qrc">
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset> <normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
</property> </property>
</widget> </widget>
@@ -346,7 +346,7 @@
<string>Save</string> <string>Save</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../utils/qad_utils.qrc"> <iconset resource="qad_blockview.qrc">
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset> <normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
</property> </property>
<property name="shortcut"> <property name="shortcut">
@@ -376,7 +376,7 @@
<string>Save as ...</string> <string>Save as ...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../utils/qad_utils.qrc"> <iconset resource="qad_blockview.qrc">
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset> <normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
</property> </property>
<property name="shortcut"> <property name="shortcut">
@@ -406,7 +406,7 @@
<string>Load ...</string> <string>Load ...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../application/qad_application.qrc"> <iconset resource="qad_blockview.qrc">
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset> <normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
</property> </property>
<property name="shortcut"> <property name="shortcut">
@@ -433,7 +433,7 @@
<string>Clear</string> <string>Clear</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../utils/qad_utils.qrc"> <iconset resource="qad_blockview.qrc">
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset> <normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
</property> </property>
</widget> </widget>
@@ -443,7 +443,7 @@
</layout> </layout>
<action name="actionRemove_items"> <action name="actionRemove_items">
<property name="icon"> <property name="icon">
<iconset resource="../utils/qad_utils.qrc"> <iconset resource="qad_blockview.qrc">
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset> <normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@@ -467,8 +467,6 @@
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../utils/qad_utils.qrc"/>
<include location="../application/qad_application.qrc"/>
<include location="qad_blockview.qrc"/> <include location="qad_blockview.qrc"/>
</resources> </resources>
<connections> <connections>

View File

@@ -20,11 +20,12 @@
#ifndef BLOCKITEM_H #ifndef BLOCKITEM_H
#define BLOCKITEM_H #define BLOCKITEM_H
#include "blockitempin.h"
#include <QTime> #include <QTime>
#include "blockitempin.h"
#include "qad_blockview_export.h"
class QAD_EXPORT BlockItem: public QGraphicsObject, public PropertyStorage class QAD_BLOCKVIEW_EXPORT BlockItem: public QGraphicsObject, public PropertyStorage
{ {
friend class BlockView; friend class BlockView;
friend class BlockItemPin; friend class BlockItemPin;

View File

@@ -32,13 +32,14 @@
#include <qmath.h> #include <qmath.h>
#include "blockbase.h" #include "blockbase.h"
#include "alignedtextitem.h" #include "alignedtextitem.h"
#include "qad_blockview_export.h"
class BlockItem; class BlockItem;
class BlockBusItem; class BlockBusItem;
class QAD_EXPORT BlockItemPin: public QGraphicsObject, public PropertyStorage class QAD_BLOCKVIEW_EXPORT BlockItemPin: public QGraphicsObject, public PropertyStorage
{ {
friend class BlockView; friend class BlockView;
friend class BlockItem; friend class BlockItem;

View File

@@ -30,6 +30,7 @@
#include <QPropertyAnimation> #include <QPropertyAnimation>
#include "blockviewwavetrace.h" #include "blockviewwavetrace.h"
#include "blockbusitem.h" #include "blockbusitem.h"
#include "qad_blockview_export.h"
Q_DECLARE_METATYPE(BlockItem*) Q_DECLARE_METATYPE(BlockItem*)
@@ -37,7 +38,7 @@ Q_DECLARE_METATYPE(BlockItemPin*)
Q_DECLARE_METATYPE(BlockBusItem*) Q_DECLARE_METATYPE(BlockBusItem*)
class QAD_EXPORT BlockView: public QGraphicsView class QAD_BLOCKVIEW_EXPORT BlockView: public QGraphicsView
{ {
Q_OBJECT Q_OBJECT
Q_ENUMS(SelectionMode) Q_ENUMS(SelectionMode)

View File

@@ -21,9 +21,10 @@
#define BLOCKVIEWWAVETRACE_H #define BLOCKVIEWWAVETRACE_H
#include "blockitem.h" #include "blockitem.h"
#include "qad_blockview_export.h"
class QAD_EXPORT BlockViewWavetrace { class QAD_BLOCKVIEW_EXPORT BlockViewWavetrace {
public: public:
BlockViewWavetrace(int width = 1, int height = 1); BlockViewWavetrace(int width = 1, int height = 1);
@@ -52,7 +53,7 @@ public:
const QVector<QPoint> & path() const; const QVector<QPoint> & path() const;
private: private:
struct Cell { struct QAD_BLOCKVIEW_EXPORT Cell {
Cell(short v = Empty): value(v), direction(0) {} Cell(short v = Empty): value(v), direction(0) {}
short value; short value;
short direction; short direction;

View File

@@ -27,12 +27,13 @@
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QMenu> #include <QMenu>
#include "blockview.h" #include "blockview.h"
#include "qad_blockview_export.h"
class QComboBox; class QComboBox;
class QAD_EXPORT _DTSizeItem: public QGraphicsObject class QAD_BLOCKVIEW_EXPORT _DTSizeItem: public QGraphicsObject
{ {
Q_OBJECT Q_OBJECT
public: public:
@@ -72,7 +73,7 @@ namespace Ui {
} }
class QAD_EXPORT DrawTools: public QWidget class QAD_BLOCKVIEW_EXPORT DrawTools: public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool resizeHandlesEnabled READ isResizeHandlesEnabled WRITE setResizeHandlesEnabled) Q_PROPERTY(bool resizeHandlesEnabled READ isResizeHandlesEnabled WRITE setResizeHandlesEnabled)

View File

@@ -94,7 +94,7 @@
<string>Edit text ...</string> <string>Edit text ...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../application/qad_application.qrc"> <iconset resource="qad_blockview.qrc">
<normaloff>:/icons/document-edit.png</normaloff>:/icons/document-edit.png</iconset> <normaloff>:/icons/document-edit.png</normaloff>:/icons/document-edit.png</iconset>
</property> </property>
<property name="toolButtonStyle"> <property name="toolButtonStyle">
@@ -591,7 +591,7 @@
<string>Load image ...</string> <string>Load image ...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../application/qad_application.qrc"> <iconset resource="qad_blockview.qrc">
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset> <normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
</property> </property>
</widget> </widget>
@@ -814,7 +814,6 @@
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../application/qad_application.qrc"/>
<include location="qad_blockview.qrc"/> <include location="qad_blockview.qrc"/>
</resources> </resources>
<connections/> <connections/>

View File

@@ -1,39 +1,16 @@
<RCC> <RCC>
<qresource prefix="/"> <qresource prefix="/">
<file>../../icons/draw-line.png</file>
<file>../../icons/align-hor.png</file>
<file>../../icons/align-ver.png</file>
<file>../../icons/dialog-close.png</file>
<file>../../icons/edit-clear.png</file>
<file>../../icons/edit-guides.png</file>
<file>../../icons/view-grid.png</file>
<file>../../icons/zoom-fit-best.png</file>
<file>../../icons/configure.png</file>
<file>../../icons/document-save.png</file>
<file>../../icons/edit-clear-locationbar-rtl.png</file>
<file>../../icons/edit-find.png</file>
<file>../../icons/list-add.png</file>
<file>../../icons/edit-delete.png</file>
<file>../../icons/item.png</file>
<file>../../icons/node-add.png</file>
<file>../../icons/node.png</file>
<file>../../icons/edit-copy.png</file>
<file>../../icons/edit-paste.png</file>
<file>../../icons/expand_s_x.png</file>
<file>../../icons/expand_s_y.png</file>
<file>../../icons/expand_x.png</file>
<file>../../icons/expand_y.png</file>
<file>../../icons/border-line.png</file>
<file>../../icons/legend.png</file>
<file>../../icons/blockview.png</file> <file>../../icons/blockview.png</file>
<file>../../icons/view-fullscreen.png</file> <file>../../icons/draw-line.png</file>
<file>../../icons/draw-ellipse.png</file> <file>../../icons/draw-ellipse.png</file>
<file>../../icons/draw-rectangle.png</file> <file>../../icons/draw-rectangle.png</file>
<file>../../icons/draw-text.png</file> <file>../../icons/draw-text.png</file>
<file>../../icons/view-preview.png</file> <file>../../icons/z-bottom.png</file>
<file>../../icons/format-fill-color.png</file> <file>../../icons/z-down.png</file>
<file>../../icons/format-stroke-color.png</file> <file>../../icons/z-top.png</file>
<file>../../icons/document-open.png</file> <file>../../icons/z-up.png</file>
<file>../../icons/align-hor.png</file>
<file>../../icons/align-ver.png</file>
<file>../../icons/align-bottom-center.png</file> <file>../../icons/align-bottom-center.png</file>
<file>../../icons/align-bottom-left.png</file> <file>../../icons/align-bottom-left.png</file>
<file>../../icons/align-bottom-right.png</file> <file>../../icons/align-bottom-right.png</file>
@@ -43,9 +20,15 @@
<file>../../icons/align-top-center.png</file> <file>../../icons/align-top-center.png</file>
<file>../../icons/align-top-left.png</file> <file>../../icons/align-top-left.png</file>
<file>../../icons/align-top-right.png</file> <file>../../icons/align-top-right.png</file>
<file>../../icons/z-bottom.png</file> <file>../../icons/dialog-close.png</file>
<file>../../icons/z-down.png</file> <file>../../icons/edit-clear.png</file>
<file>../../icons/z-top.png</file> <file>../../icons/edit-delete.png</file>
<file>../../icons/z-up.png</file> <file>../../icons/edit-copy.png</file>
<file>../../icons/document-save.png</file>
<file>../../icons/document-open.png</file>
<file>../../icons/document-edit.png</file>
<file>../../icons/view-preview.png</file>
<file>../../icons/format-fill-color.png</file>
<file>../../icons/format-stroke-color.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -17,9 +17,11 @@ else()
endif() endif()
find_library(MARKDOWN_LIBRARY markdown) find_library(MARKDOWN_LIBRARY markdown)
if (MARKDOWN_LIBRARY) if (MARKDOWN_LIBRARY)
if(_mkd_header_found) qad_library(doc "Core" "${MARKDOWN_LIBRARY}")
qad_library(doc "Core" "${MARKDOWN_LIBRARY}") if(NOT _mkd_header_found)
else()
message(STATUS "Found markdown library, but *.h missing!") message(STATUS "Found markdown library, but *.h missing!")
endif() endif()
else()
add_definitions("-DNO_MARKDOWN")
qad_library(doc "Core" "")
endif() endif()

View File

@@ -1,5 +1,6 @@
#include "markdown.h" #include "markdown.h"
#include <QDebug> #include <QDebug>
#ifndef NO_MARKDOWN
extern "C" { extern "C" {
#include MARKDOWN_HEADER #include MARKDOWN_HEADER
} }
@@ -77,3 +78,10 @@ QString md2html(const QByteArray & src) {
return ret; return ret;
} }
#else
QString md2html(const QByteArray & src) {
return src;
}
#endif

View File

@@ -21,10 +21,10 @@
#define QAD_MARKDOWN_H #define QAD_MARKDOWN_H
#include <QString> #include <QString>
#include "qad_export.h" #include "qad_doc_export.h"
QAD_EXPORT QString md2html(const QByteArray & src); QAD_DOC_EXPORT QString md2html(const QByteArray & src);
#endif // QAD_MARKDOWN_H #endif // QAD_MARKDOWN_H

View File

@@ -8,6 +8,7 @@
#include <QTapAndHoldGesture> #include <QTapAndHoldGesture>
#include <QPanGesture> #include <QPanGesture>
#include <QPinchGesture> #include <QPinchGesture>
#include <QActionGroup>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
# include <QRandomGenerator> # include <QRandomGenerator>
#endif #endif
@@ -37,6 +38,20 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
#endif #endif
ui = new Ui::Graphic(); ui = new Ui::Graphic();
ui->setupUi(this); ui->setupUi(this);
QActionGroup * agroup = new QActionGroup(this);
agroup->addAction(ui->actionGuidesFree );
agroup->addAction(ui->actionGuidesTraceX);
agroup->addAction(ui->actionGuidesTraceY);
ui->actionGuidesFree ->setProperty("_value", (int)Free );
ui->actionGuidesTraceX->setProperty("_value", (int)TraceX);
ui->actionGuidesTraceY->setProperty("_value", (int)TraceY);
ui->actionGuidesFree->setChecked(true);
connect(agroup, SIGNAL(triggered(QAction*)), this, SLOT(actionGuidesTriggered(QAction*)));
ui->checkGuides->addAction(ui->actionGuidesFree );
ui->checkGuides->addAction(ui->actionGuidesTraceX);
ui->checkGuides->addAction(ui->actionGuidesTraceY);
ui->buttonAutofit->addAction(ui->actionExpandX);
ui->buttonAutofit->addAction(ui->actionExpandY);
line_x_min.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); line_x_min.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
line_x_max.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); line_x_max.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
((QBoxLayout * )ui->widgetLY->layout())->insertWidget(0, &line_y_min); ((QBoxLayout * )ui->widgetLY->layout())->insertWidget(0, &line_y_min);
@@ -76,6 +91,7 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
emaxx = emaxy = DBL_MIN; emaxx = emaxy = DBL_MIN;
grad_x = grad_y = Auto; grad_x = grad_y = Auto;
axis_type_x = Numeric; axis_type_x = Numeric;
floating_axis_type = Free;
min_repaint_int = 25; min_repaint_int = 25;
inc_x = 1.; inc_x = 1.;
buffer = 0; buffer = 0;
@@ -374,10 +390,7 @@ void Graphic::canvasMousePressEvent(QMouseEvent * e) {
emit graphicMousePressEvent(canvas2real(QPointF(e->pos())), e->button()); emit graphicMousePressEvent(canvas2real(QPointF(e->pos())), e->button());
if (!navigation) return; if (!navigation) return;
if (gestures && !need_mouse_pan) return; if (gestures && !need_mouse_pan) return;
#ifdef HAS_GL setGuidesCursor();
canvas_gl->setCursor(guides ? Qt::BlankCursor : Qt::ArrowCursor);
#endif
ui->canvas_raster->setCursor(guides ? Qt::BlankCursor : Qt::ArrowCursor);
prevpos = e->pos(); prevpos = e->pos();
startpos = prevpos; startpos = prevpos;
startpos_r = canvas2real(startpos); startpos_r = canvas2real(startpos);
@@ -393,7 +406,7 @@ void Graphic::canvasMousePressEvent(QMouseEvent * e) {
return; return;
} else { } else {
prevaction = curaction; prevaction = curaction;
curaction = gaMove; setCurrentAction(gaMove);
return; return;
} }
} }
@@ -419,10 +432,7 @@ void Graphic::canvasMouseReleaseEvent(QMouseEvent * e) {
if (gestures) return; if (gestures) return;
need_mouse_pan = false; need_mouse_pan = false;
if (!navigation) return; if (!navigation) return;
#ifdef HAS_GL setGuidesCursor();
canvas_gl->setCursor(guides ? Qt::BlankCursor : Qt::ArrowCursor);
#endif
ui->canvas_raster->setCursor(guides ? Qt::BlankCursor : Qt::ArrowCursor);
QPointF tlp, brp; QPointF tlp, brp;
QRect sr; QRect sr;
sr = QRect(startpos, curpos).normalized(); sr = QRect(startpos, curpos).normalized();
@@ -585,18 +595,12 @@ void Graphic::setMaxVisibleTime(double val) {
void Graphic::setOnlyExpandY(bool yes) { void Graphic::setOnlyExpandY(bool yes) {
only_expand_y = yes; ui->actionExpandY->setChecked(yes);
ui->checkExpandY->blockSignals(true);
ui->checkExpandY->setCheckable(yes);
ui->checkExpandY->blockSignals(false);
} }
void Graphic::setOnlyExpandX(bool yes) { void Graphic::setOnlyExpandX(bool yes) {
only_expand_x = yes; ui->actionExpandX->setChecked(yes);
ui->checkExpandX->blockSignals(true);
ui->checkExpandX->setCheckable(yes);
ui->checkExpandX->blockSignals(false);
} }
@@ -647,8 +651,6 @@ void Graphic::setButtons(Graphic::Buttons b) {
ui->buttonAutofit->setVisible(b.testFlag(Autofit)); ui->buttonAutofit->setVisible(b.testFlag(Autofit));
ui->checkGrid->setVisible(b.testFlag(Grid)); ui->checkGrid->setVisible(b.testFlag(Grid));
ui->checkGuides->setVisible(b.testFlag(CursorAxis)); ui->checkGuides->setVisible(b.testFlag(CursorAxis));
ui->checkExpandY->setVisible(b.testFlag(OnlyExpandY));
ui->checkExpandX->setVisible(b.testFlag(OnlyExpandX));
ui->buttonFullscreen->setVisible(b.testFlag(Fullscreen)); ui->buttonFullscreen->setVisible(b.testFlag(Fullscreen));
ui->checkBorderInputs->setVisible(b.testFlag(BorderInputs)); ui->checkBorderInputs->setVisible(b.testFlag(BorderInputs));
ui->checkLegend->setVisible(b.testFlag(Legend)); ui->checkLegend->setVisible(b.testFlag(Legend));
@@ -1149,14 +1151,58 @@ void Graphic::drawGuides() {
painter->resetTransform(); painter->resetTransform();
painter->setClipping(true); painter->setClipping(true);
painter->setClipRect(QRect(gridborder.x(), 0, wid - gridborder.x(), hei - gridborder.y())); painter->setClipRect(QRect(gridborder.x(), 0, wid - gridborder.x(), hei - gridborder.y()));
painter->drawLine(0, curpos.y(), wid, curpos.y()); QPoint apos = curpos;
painter->drawLine(curpos.x(), 0, curpos.x(), hei); QPointF rpos = canvas2real(apos);
QString str = pointCoords(canvas2real(curpos)) + fp_size; QString str;
str = pointCoords(rpos) + fp_size;
switch (floating_axis_type) {
case TraceX:
if (curGraphic >= 0 && curGraphic < graphics.size()) {
QPolygonF & pol(pause_ ? graphics[curGraphic].polyline_pause : graphics[curGraphic].polyline);
double cursor = rpos.x(), min_dist = -1, dist = 0.;
int index = -1;
for (int i = 0; i < pol.size(); ++i) {
dist = qAbs<double>(pol[i].x() - cursor);
if (min_dist > dist || min_dist < 0) {
min_dist = dist;
index = i;
}
}
if (index >= 0) {
rpos = pol[index];
apos = real2canvas(rpos).toPoint();
str = pointCoords(pol[index]) + fp_size;
}
}
break;
case TraceY:
if (curGraphic >= 0 && curGraphic < graphics.size()) {
QPolygonF & pol(pause_ ? graphics[curGraphic].polyline_pause : graphics[curGraphic].polyline);
double cursor = rpos.y(), min_dist = -1, dist = 0.;
int index = -1;
for (int i = 0; i < pol.size(); ++i) {
dist = qAbs<double>(pol[i].y() - cursor);
if (min_dist > dist || min_dist < 0) {
min_dist = dist;
index = i;
}
}
if (index >= 0) {
rpos = pol[index];
apos = real2canvas(rpos).toPoint();
str = pointCoords(pol[index]) + fp_size;
}
}
break;
default: break;
}
painter->drawLine(0, apos.y(), wid, apos.y());
painter->drawLine(apos.x(), 0, apos.x(), hei);
QPoint p = apos + QPoint(font_sz.height() / 4., -font_sz.height() / 4.);
QFontMetrics fm(font()); QFontMetrics fm(font());
QRect r = fm.boundingRect(str); QRect r = fm.boundingRect(str);
QPoint p = curpos + QPoint(font_sz.height() / 4., -font_sz.height() / 4.); if (r.width() + apos.x() > wid - font_sz.height() / 2.) p.setX(apos.x() - r.width() - font_sz.height() / 4.);
if (r.width() + curpos.x() > wid - font_sz.height() / 2.) p.setX(curpos.x() - r.width() - font_sz.height() / 4.); if (apos.y() - r.height() < font_sz.height() / 8.) p.setY(apos.y() + r.height() - font_sz.height() / 8.);
if (curpos.y() - r.height() < font_sz.height() / 8.) p.setY(curpos.y() + r.height() - font_sz.height() / 8.);
painter->setPen(text_color); painter->setPen(text_color);
painter->drawText(p, str); painter->drawText(p, str);
} }
@@ -1287,8 +1333,7 @@ void Graphic::setCurrentAction(GraphicAction action) {
curaction = action; curaction = action;
switch (action) { switch (action) {
case gaNone: case gaNone:
if (guides) setCanvasCursor(Qt::BlankCursor); setGuidesCursor();
else setCanvasCursor(Qt::ArrowCursor);
break; break;
case gaZoomInRect: case gaZoomInRect:
setCanvasCursor(Qt::CrossCursor); setCanvasCursor(Qt::CrossCursor);
@@ -1314,6 +1359,14 @@ void Graphic::setCanvasCursor(QCursor cursor) {
} }
void Graphic::setGuidesCursor() {
if (guides) {
setCanvasCursor(floating_axis_type == Free ? Qt::BlankCursor : Qt::CrossCursor);
} else
setCanvasCursor(Qt::ArrowCursor);
}
void Graphic::swapToBuffer() { void Graphic::swapToBuffer() {
QImage timg; QImage timg;
#ifdef HAS_GL #ifdef HAS_GL
@@ -1461,8 +1514,7 @@ void Graphic::on_buttonConfigure_clicked() {
void Graphic::on_checkGuides_toggled(bool checked) { void Graphic::on_checkGuides_toggled(bool checked) {
guides = checked; guides = checked;
if (guides) setCanvasCursor(Qt::BlankCursor); setGuidesCursor();
else setCanvasCursor(Qt::ArrowCursor);
update(); update();
} }
@@ -1733,13 +1785,19 @@ void Graphic::setLegendVisible(bool visible) {
} }
void Graphic::on_checkExpandY_toggled(bool checked) { void Graphic::on_actionExpandX_triggered(bool checked) {
only_expand_y = checked;
ui->checkExpandY->setIcon(checked ? icon_exp_y : icon_exp_sy);
}
void Graphic::on_checkExpandX_toggled(bool checked) {
only_expand_x = checked; only_expand_x = checked;
ui->checkExpandX->setIcon(checked ? icon_exp_x : icon_exp_sx); ui->actionExpandX->setIcon(checked ? icon_exp_x : icon_exp_sx);
}
void Graphic::on_actionExpandY_triggered(bool checked) {
only_expand_y = checked;
ui->actionExpandY->setIcon(checked ? icon_exp_y : icon_exp_sy);
}
void Graphic::actionGuidesTriggered(QAction * a) {
ui->checkGuides->setChecked(true);
setFloatingAxisType((FloatingAxisType)a->property("_value").toInt());
} }

View File

@@ -35,6 +35,7 @@
#include <float.h> #include <float.h>
#include "graphic_conf.h" #include "graphic_conf.h"
#include "evalspinbox.h" #include "evalspinbox.h"
#include "qad_graphic_export.h"
namespace Ui { namespace Ui {
@@ -48,11 +49,11 @@ class UGLWidget;
Q_DECLARE_METATYPE(QVector<QPointF>) Q_DECLARE_METATYPE(QVector<QPointF>)
class QAD_EXPORT Graphic: public QFrame class QAD_GRAPHIC_EXPORT Graphic: public QFrame
{ {
Q_OBJECT Q_OBJECT
Q_FLAGS(Buttons) Q_FLAGS(Buttons)
Q_ENUMS(Alignment Graduation AxisType) Q_ENUMS(Alignment Graduation AxisType FloatingAxisType)
Q_PROPERTY(QString caption READ caption WRITE setCaption) Q_PROPERTY(QString caption READ caption WRITE setCaption)
Q_PROPERTY(QString labelX READ labelX WRITE setLabelX) Q_PROPERTY(QString labelX READ labelX WRITE setLabelX)
@@ -112,6 +113,7 @@ class QAD_EXPORT Graphic: public QFrame
Q_PROPERTY(double graduationStepX READ graduationStepX WRITE setGraduationStepX) Q_PROPERTY(double graduationStepX READ graduationStepX WRITE setGraduationStepX)
Q_PROPERTY(double graduationStepY READ graduationStepY WRITE setGraduationStepY) Q_PROPERTY(double graduationStepY READ graduationStepY WRITE setGraduationStepY)
Q_PROPERTY(AxisType axisType READ axisType WRITE setAxisType) Q_PROPERTY(AxisType axisType READ axisType WRITE setAxisType)
Q_PROPERTY(FloatingAxisType floatingAxisType READ floatingAxisType WRITE setFloatingAxisType)
Q_PROPERTY(Graphic::GraphicsData graphicsData READ graphicsData WRITE setGraphicsData) Q_PROPERTY(Graphic::GraphicsData graphicsData READ graphicsData WRITE setGraphicsData)
Q_PROPERTY(QByteArray graphicsDataRaw READ graphicsDataRaw WRITE setGraphicsDataRaw) Q_PROPERTY(QByteArray graphicsDataRaw READ graphicsDataRaw WRITE setGraphicsDataRaw)
@@ -127,8 +129,6 @@ public:
Autofit = 0x01, Autofit = 0x01,
Grid = 0x02, Grid = 0x02,
CursorAxis = 0x04, CursorAxis = 0x04,
OnlyExpandY = 0x08,
OnlyExpandX = 0x10,
Fullscreen = 0x20, Fullscreen = 0x20,
BorderInputs = 0x40, BorderInputs = 0x40,
Legend = 0x80, Legend = 0x80,
@@ -142,6 +142,7 @@ public:
enum Alignment {Left, Right}; enum Alignment {Left, Right};
enum Graduation {Auto, Fixed}; enum Graduation {Auto, Fixed};
enum AxisType {Numeric, DateTime}; enum AxisType {Numeric, DateTime};
enum FloatingAxisType {Free, TraceX, TraceY};
Q_DECLARE_FLAGS(Buttons, Button) Q_DECLARE_FLAGS(Buttons, Button)
QString caption() const; QString caption() const;
@@ -199,6 +200,7 @@ public:
double graduationStepX() const {return gridx;} double graduationStepX() const {return gridx;}
double graduationStepY() const {return gridy;} double graduationStepY() const {return gridy;}
AxisType axisType() const {return axis_type_x;} AxisType axisType() const {return axis_type_x;}
FloatingAxisType floatingAxisType() const {return floating_axis_type;}
QVector<QPointF> graphicData(const int index = 0) const {return graphics[index].polyline;} QVector<QPointF> graphicData(const int index = 0) const {return graphics[index].polyline;}
GraphicsData graphicsData() const; GraphicsData graphicsData() const;
QByteArray graphicsDataRaw() const; QByteArray graphicsDataRaw() const;
@@ -293,6 +295,7 @@ public slots:
void setGraduationStepY(double sy) {gridy = sy; if (aupdate) update();} void setGraduationStepY(double sy) {gridy = sy; if (aupdate) update();}
void setGraduationSteps(double sx, double sy) {gridx = sx; gridy = sy; if (aupdate) update();} void setGraduationSteps(double sx, double sy) {gridx = sx; gridy = sy; if (aupdate) update();}
void setAxisType(AxisType t) {axis_type_x = t; if (aupdate) update();} void setAxisType(AxisType t) {axis_type_x = t; if (aupdate) update();}
void setFloatingAxisType(FloatingAxisType t) {floating_axis_type = t; setGuidesCursor(); if (aupdate) update();}
void addPoint(const QPointF & p, int graphic, bool update_ = true); void addPoint(const QPointF & p, int graphic, bool update_ = true);
void addPoint(const QPointF & p, bool update = true) {addPoint(p, curGraphic, update);} void addPoint(const QPointF & p, bool update = true) {addPoint(p, curGraphic, update);}
@@ -345,6 +348,7 @@ protected:
void updateLegend(bool es = true); void updateLegend(bool es = true);
void updateLegendChecks(); void updateLegendChecks();
void setCanvasCursor(QCursor cursor); void setCanvasCursor(QCursor cursor);
void setGuidesCursor();
void swapToBuffer(); void swapToBuffer();
void swapToNormal() {bufferActive = false;} void swapToNormal() {bufferActive = false;}
void setRectToLines(); void setRectToLines();
@@ -387,6 +391,7 @@ protected:
QImage icon_pause_b, icon_pause_f; QImage icon_pause_b, icon_pause_f;
Graduation grad_x, grad_y; Graduation grad_x, grad_y;
AxisType axis_type_x; AxisType axis_type_x;
FloatingAxisType floating_axis_type;
double gridx, gridy, history, visible_time, inc_x, grid_numbers_x, grid_numbers_y, LN10; double gridx, gridy, history, visible_time, inc_x, grid_numbers_x, grid_numbers_y, LN10;
double eminx, eminy, emaxx, emaxy, pause_phase, gesture_angle; double eminx, eminy, emaxx, emaxy, pause_phase, gesture_angle;
int lastw, lasth, min_repaint_int, timer_pause, thick; int lastw, lasth, min_repaint_int, timer_pause, thick;
@@ -416,11 +421,12 @@ protected slots:
void on_buttonSave_clicked() {saveImage();} void on_buttonSave_clicked() {saveImage();}
void on_checkGrid_toggled(bool checked) {grid = checked; update();} void on_checkGrid_toggled(bool checked) {grid = checked; update();}
void on_checkGuides_toggled(bool checked); void on_checkGuides_toggled(bool checked);
void on_checkExpandY_toggled(bool checked); void on_actionExpandX_triggered(bool checked);
void on_checkExpandX_toggled(bool checked); void on_actionExpandY_triggered(bool checked);
void on_checkBorderInputs_toggled(bool checked) {setBorderInputsVisible(checked);} void on_checkBorderInputs_toggled(bool checked) {setBorderInputsVisible(checked);}
void on_checkLegend_toggled(bool checked) {setLegendVisible(checked);} void on_checkLegend_toggled(bool checked) {setLegendVisible(checked);}
void on_checkPause_toggled(bool checked) {setPaused(checked);} void on_checkPause_toggled(bool checked) {setPaused(checked);}
void actionGuidesTriggered(QAction * a);
void enterFullscreen(); void enterFullscreen();
void leaveFullscreen(); void leaveFullscreen();
@@ -435,7 +441,6 @@ signals:
void cleared(); void cleared();
void visualRectChanged(); void visualRectChanged();
void graphicSettingsChanged(); void graphicSettingsChanged();
}; };
@@ -448,7 +453,7 @@ inline QDataStream & operator <<(QDataStream & s, const Graphic::Graduation & v)
inline QDataStream & operator >>(QDataStream & s, Graphic::Graduation & v) {s >> *((int*)(&v)); return s;} inline QDataStream & operator >>(QDataStream & s, Graphic::Graduation & v) {s >> *((int*)(&v)); return s;}
class __GraphicRegistrator__ { class QAD_GRAPHIC_EXPORT __GraphicRegistrator__ {
public: public:
__GraphicRegistrator__() { __GraphicRegistrator__() {
qRegisterMetaType<QVector<QPointF> >("QVector<QPointF>"); qRegisterMetaType<QVector<QPointF> >("QVector<QPointF>");

Some files were not shown because too many files have changed in this diff Show More