Compare commits

...

231 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
5d32c02b5f forget cd_utils
fixed dangling piconnedit
2020-08-19 17:27:22 +03:00
d0148bf460 tree changes 2020-08-19 16:22:10 +03:00
76d9604282 missing CMakeLists.txt on previous commit 2020-08-19 00:48:38 +03:00
3e1768b418 tree changes 2020-08-19 00:47:44 +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
4b7c513f7f flags() 2020-08-18 17:03:13 +03:00
0f6bc121aa ImageView fix 2020-08-18 17:02:14 +03:00
0ec173d9bb improve ImageView quality 2020-08-18 16:59:58 +03:00
cabacdd908 BlockView trace fix 2020-08-17 12:10:13 +03:00
f66138593c BlockView tracing fix 2020-08-17 00:57:44 +03:00
c49454bb03 another version of tracing across buses 2020-08-17 00:32:59 +03:00
efb5cbe484 blockview migrate to "deploy*" 2020-08-16 16:36:46 +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
ddc4da54be pip
BlockBusItem paint fix
2020-08-14 18:00:58 +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
d6cc5f0033 QAD 1.7.0
backport PIChunkStream optimizations to ChunkStream
2020-08-14 14:18:20 +03:00
055b8a9480 bus joint paint now configured with BlockView::setBusSquareNodes(), square or round. By default round 2020-08-14 14:08:31 +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
8fbed9f427 revert busitem paint 2020-08-13 18:09:04 +03:00
e43ae02e48 Merge branch 'master' of https://git.signalmodelling.ru/SHS/libs 2020-08-13 18:04:02 +03:00
a9b9061475 binlog and PathEdit fixes 2020-08-13 18:03:52 +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
b37318a5a5 BlockView draw bus joint changed 2020-08-13 14:13:23 +03:00
6f97d849e9 Merge branch 'master' of https://git.shs.tools/SHS/libs 2020-08-13 13:00:59 +03:00
58432fa62e version 1.6.0
QAD::File add "is_save" flag
2020-08-13 13:00:52 +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
aa2ea1eda6 binlog user header 2020-08-12 20:01:46 +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
11e665c419 pip 2020-08-11 21:19:02 +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
1312f950c7 pip 2020-08-11 20:59:25 +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
56b3dcad7c Merge remote-tracking branch 'remotes/origin/release' 2020-08-11 20:20:24 +03:00
75464792ba Merge remote-tracking branch 'remotes/origin/master' into release
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
2020-08-11 20:16:10 +03:00
8b86f93e38 pip 2.0.0 2020-08-11 20:11:10 +03:00
3e0ec72e7d Blockview changes:
1) Теперь для создания сегмента не надо держать Shift, а перемешение шины теперь с нажатой клавишей Shift
2) Режим трассировки шин теперь пытается проложить маршрут с возможностью пересечения шины под прямым углом
3) Теперь рисуются точки соединения сегментов если их больше 2х
4) Обновлена подсказка в tooltip

p.s. update pip)
2020-08-11 17:35:18 +03:00
b45bfca826 getSaveFileName for QAD::File editor 2020-08-11 10:15:09 +03:00
6a9b1751ac android docker
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-08-10 22:13:31 +03:00
ede780249a android docker 2020-08-10 22:12:52 +03:00
067839f02b Dockerfile ENV patch
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-08-10 17:55:07 +03:00
da9237e74b Dockerfile ENV patch 2020-08-10 17:48:35 +03:00
905eb77091 windows PIP -> QtBin install fix 2020-08-05 12:06:56 +03:00
2974967790 TouchButtFrame fix 2020-08-04 17:57:11 +03:00
4a567dbba4 pip 2020-08-03 09:05:06 +03:00
0c7619d00b new pip 2020-08-03 01:43:47 +03:00
fa4634b0c7 last pip 2020-08-02 12:16:14 +03:00
0f1825bf33 merged to PIP 1.99.3 2020-08-01 21:30:25 +03:00
562cb280f7 Merge branch 'master' of https://git.shs.tools/SHS/libs 2020-07-30 00:25:33 +03:00
5ec9c22d46 pip 2020-07-30 00:25:24 +03:00
d78a1f532b Merge branch 'master' of https://git.signalmodelling.ru/SHS/libs 2020-07-29 14:36:30 +03:00
0d9ecc9ceb Dockerfile, clone only one branch 2020-07-29 14:36:21 +03:00
7baa7916f7 pip v2 2020-07-29 01:32:19 +03:00
7ecf33a908 Merge branch 'master' of https://git.shs.tools/SHS/libs 2020-07-24 21:54:44 +03:00
c3f921ea6a FindQAD.cmake patch for piqt and piqt_utils 2020-07-24 21:54:38 +03:00
2251caf12c clean qglengine/qglview.h 2020-07-23 17:14:22 +03:00
c76608abf0 QGLEngine license 2020-07-22 11:24:42 +03:00
06c99dd105 Merge pull request 'pip' (#55) from master into release
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
2020-07-16 13:59:20 +03:00
caf149ed28 pip 2020-07-16 13:59:07 +03:00
13a543bfd5 Merge pull request 'pip 24' (#54) from master into release
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
2020-07-16 13:51:49 +03:00
16e52701be pip 2020-07-16 13:44:26 +03:00
09ed9a9907 compile fixes 2020-07-16 13:41:50 +03:00
a5d75fec09 includes 2020-07-16 13:05:49 +03:00
afd15e20f6 fix warning 2020-07-16 12:58:31 +03:00
77c2296320 pip 24 2020-07-16 12:52:59 +03:00
1c8d2d5c5f Merge branch 'master' of https://git.signalmodelling.ru/SHS/libs 2020-07-16 12:50:49 +03:00
f6a9e44805 piSwap 2020-07-16 12:50:24 +03:00
a5e5c289db Merge pull request 'fix qad_export.h' (#51) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-07-10 21:46:56 +03:00
a49aeda257 fix qad_export.h 2020-07-10 21:46:36 +03:00
79db8ea408 Merge pull request 'master' (#50) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-07-10 09:21:40 +03:00
c359ba34a6 update pip 2020-07-09 22:25:46 +03:00
760c57a843 FindQAD multiple add target fix 2020-07-09 13:11:23 +03:00
61316462fa Imported targets for QAD 2020-06-28 17:11:42 +03:00
4e3baadd70 Merge pull request 'master' (#49) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-06-28 01:16:49 +03:00
8324776fb8 fix for Qt4 2020-06-28 01:04:28 +03:00
65f3cc0698 pip update 2020-06-28 00:18:49 +03:00
b72ef08892 Merge pull request 'master' (#48) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-06-26 09:56:46 +03:00
8363ad29ef pip 2020-06-26 09:51:27 +03:00
ab4f2a3d40 Graphic mouse signals fix 2020-06-25 12:05:45 +03:00
754d46a250 missing Graphic::setGraphicStyle(const Qt::PenStyle & style, int index) 2020-06-24 11:45:56 +03:00
ba5a30a7dd Android graphic fix 2020-06-24 02:09:08 +03:00
50efa51975 version 1.5.0
IconedLabel now remove spacings in case of empty text or icon
2020-06-23 19:57:16 +03:00
8bb52f59fe Merge pull request 'update pip' (#47) from master into release
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
2020-06-19 22:53:42 +03:00
3acec2297b Merge branch 'master' of https://git.shs.tools/SHS/libs 2020-06-19 22:53:05 +03:00
d39488397c update pip 2020-06-19 22:52:54 +03:00
97a0bad71d Merge pull request 'master' (#46) from master into release
Some checks failed
SHS Gitea/libs/pipeline/head Something is wrong with the build of this commit
2020-06-19 22:48:53 +03:00
f02c38884b LogView fixes and optimizations 2020-06-19 19:17:30 +03:00
a195ec4006 logview improvments and fixes 2020-06-18 22:46:16 +03:00
d15b6ff855 yet clean qad/graphic 2020-06-18 20:21:37 +03:00
bd6e672568 clean qad/graphic/graphic.cpp and qad/graphic/graphic.h 2020-06-18 19:57:15 +03:00
2c9279248d Merge pull request 'master' (#45) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-06-17 22:58:20 +03:00
e67c1925b1 version 1.4.0_alpha
add LogView
patch MatrixEdit for old Qt
2020-06-17 22:15:47 +03:00
7741878f3e fxes for new qt 2020-06-15 11:08:35 +03:00
61e16d4f1b Merge pull request 'master' (#44) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-06-10 15:38:40 +03:00
5bd869968e Merge branch 'master' of https://git.shs.tools/SHS/libs 2020-06-10 15:38:04 +03:00
94f1b68b6f pip 2020-06-10 15:38:00 +03:00
86439ae05c Merge pull request 'pip' (#43) from master into release
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
2020-06-10 15:11:55 +03:00
a64e03b28d pip 2020-06-10 15:11:36 +03:00
9d708342ca Merge pull request 'pip 1.20' (#42) from master into release
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
2020-06-10 14:38:27 +03:00
265251d47d pip 2020-06-10 14:36:43 +03:00
8962d051ea update pip to 1.20 2020-06-10 14:30:55 +03:00
e513e2f16a copyright clean 2020-06-10 14:12:43 +03:00
8ab6a4716f Merge pull request 'graphic default theme color in session save/load' (#40) from master into release 2020-06-09 21:00:58 +03:00
ab330967f3 version 2020-06-09 21:00:30 +03:00
46dd2eeaad graphic default theme color in session save/load 2020-06-09 20:57:49 +03:00
fdee11cbc0 Merge pull request 'pip' (#39) from master into release 2020-06-09 18:12:16 +03:00
4dbca6f145 pip 2020-06-09 18:05:26 +03:00
57c19a2e8c Merge pull request 'Jenkinsfile' (#37) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-06-02 15:32:40 +03:00
14c8a359bd Jenkinsfile 2020-06-02 15:31:47 +03:00
e45464f480 Merge pull request 'fix PIMathMatrix in pip' (#36) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-06-02 13:26:20 +03:00
892c2e48a3 Merge branch 'master' of https://git.shs.tools/SHS/libs 2020-06-02 13:06:08 +03:00
f0340c5d48 update pip 2020-06-02 13:06:03 +03:00
db37f8b963 Merge pull request 'master' (#34) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-05-28 17:34:27 +03:00
a7f182a7cb Jenkinsfile doc, PIP 2020-05-28 17:32:31 +03:00
b8e4e7203f Jenkinsfile pip doc works
Some checks failed
pipdoc/pipeline/head Something is wrong with the build of this commit
2020-05-28 15:06:32 +03:00
1010eaf6db Jenkinsfile
All checks were successful
pipdoc/pipeline/head This commit looks good
2020-05-28 15:00:25 +03:00
007e3db9ef Jenkinsfile
Some checks failed
pipdoc/pipeline/head There was a failure building this commit
2020-05-28 14:59:04 +03:00
dbff7cec26 Merge branch 'master' of https://git.shs.tools/SHS/libs
Some checks failed
pipdoc/pipeline/head There was a failure building this commit
2020-05-28 14:44:29 +03:00
3c94cce018 Jenkinsfile 2020-05-28 14:44:20 +03:00
ab356664e2 pip PIVector2D resize
Some checks failed
pipdoc/pipeline/head Something is wrong with the build of this commit
2020-05-28 14:21:30 +03:00
2945c07a31 Jenkinsfile pip doc
Some checks failed
pipdoc/pipeline/head There was a failure building this commit
2020-05-28 14:04:35 +03:00
0ffcedb5ef Merge pull request 'master' (#33) from master into release
Some checks failed
pipdoc/pipeline/head There was a failure building this commit
2020-05-28 10:47:24 +03:00
87f49853b2 Merge branch 'master' of https://git.shs.tools/SHS/libs 2020-05-28 10:17:15 +03:00
c269dd6b9e update pip and matrixedit.ui size 2020-05-28 10:17:10 +03:00
cb739f61b0 Merge pull request 'pip' (#31) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-05-26 16:50:23 +03:00
54ad05ffef pip 2020-05-26 16:49:21 +03:00
2857dee71c Merge pull request 'v1.3.1_beta, session default path and dynamic translations, PIP' (#28) from master into release
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
2020-05-26 16:30:12 +03:00
5abe72697d version 1.3.1_beta
qad_locations simplify
pip
2020-05-26 16:27:21 +03:00
e90f5d23c4 remove translations before load 2020-05-25 18:47:28 +03:00
c1fa375145 add dynamic language change support
add "en" ts
2020-05-25 16:59:19 +03:00
69b0ee9d1a EMainWindow session fix 2020-05-25 13:56:55 +03:00
b6e86b6160 Merge branch 'master' of https://git.shs.tools/SHS/libs 2020-05-25 11:51:00 +03:00
1384cf3c21 add default session path 2020-05-25 11:50:44 +03:00
6a84167a58 add default session path 2020-05-25 11:49:49 +03:00
da32c7c723 multiline fix 2020-05-23 21:55:31 +03:00
0418638fc9 QPIConfig multiline support 2020-05-23 21:42:00 +03:00
8dd574fef1 pip 2020-05-23 17:42:30 +03:00
3137dc7c03 pip 2020-05-23 16:39:06 +03:00
a627ea557e DrawTools, ui fix (line mode) 2020-05-23 16:26:24 +03:00
da939e30c7 ProjectFilesystemPlugin 1.1.0: pseudo-threaded tree rebuild 2020-05-22 18:25:27 +03:00
a8625e2333 Merge pull request 'update pip' (#27) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-05-22 12:25:41 +03:00
8406767c76 update pip 2020-05-22 12:24:53 +03:00
7395146bfb Merge pull request 'master' (#26) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-05-21 13:15:32 +03:00
09511b6afd pip 2020-05-21 13:07:21 +03:00
2d509afe89 Merge branch 'master' of https://git.shs.tools/SHS/libs 2020-05-20 18:14:56 +03:00
fda0983d0b translations 2020-05-20 18:14:45 +03:00
880bda410a Merge pull request 'master' (#25) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-05-19 21:49:11 +03:00
3d64351da6 update pip 2020-05-19 21:15:03 +03:00
52b00ac0ab Merge branch 'master' of https://git.shs.tools/SHS/libs 2020-05-19 21:13:41 +03:00
e3000e5ebc Jenkinsfile comment 2020-05-19 21:13:31 +03:00
d9cb8da8ae Merge pull request 'master' (#24) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-05-19 18:39:59 +03:00
7855536959 Merge branch 'master' of https://git.shs.tools/SHS/libs 2020-05-19 18:32:39 +03:00
9bbe763184 version 1.2.0_beta
QAD_SETUP_APPLICATION, QtWraps.cmake
2020-05-19 18:32:26 +03:00
68945371f5 Jenkinsfile stage download 2020-05-19 16:19:30 +03:00
5d1706834b Merge branch 'master' of https://git.shs.tools/SHS/libs 2020-05-19 12:07:55 +03:00
e3ab26dc4c remove old Dockerfile 2020-05-19 12:06:57 +03:00
af8c3a44ff Merge pull request 'retry' (#23) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-05-18 19:34:55 +03:00
4bc671584c retry 2020-05-18 19:34:12 +03:00
bed8f9e2f0 Merge pull request 'Jenkinsfile' (#22) from master into release
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
2020-05-18 19:24:36 +03:00
72e7b42813 Jenkinsfile 2020-05-18 19:24:11 +03:00
961dd32c69 Merge pull request 'docker' (#21) from master into release
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
2020-05-18 19:18:47 +03:00
b65f154f29 docker 2020-05-18 19:18:21 +03:00
cab5d7334a Merge pull request 'pip' (#20) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-05-18 17:42:21 +03:00
03442306b9 pip 2020-05-18 17:41:57 +03:00
c5b61c619c Merge pull request 'pip, qad version' (#19) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-05-18 16:40:04 +03:00
ada132e992 pip, qad version 2020-05-18 16:39:37 +03:00
54954c9ae7 Merge pull request 'master' (#18) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-05-16 11:31:45 +03:00
2e59133c66 version 1.1.1_alpha 2020-05-16 11:26:13 +03:00
9db04f5aa0 qad_locations 2020-05-16 10:02:44 +03:00
30d1faff9a qad_locations 2020-05-15 22:49:08 +03:00
864940446d mobile about 2020-05-13 13:36:38 +03:00
36487e636f Merge pull request 'docker system prune' (#14) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-05-12 22:41:22 +03:00
47fd2bfc8a docker system prune 2020-05-12 22:40:22 +03:00
a10ba790f5 Merge pull request 'master' (#13) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-05-12 18:50:56 +03:00
446e74a51d linux deploy, buildnumber 2020-05-12 18:50:01 +03:00
ef9e75d584 jobs 2020-05-12 11:22:22 +03:00
854f1dc3e9 Merge pull request 'master' (#12) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-05-11 12:01:41 +03:00
965d845a64 pip 2020-05-11 12:00:40 +03:00
682e493fa3 Jenkins: add stages 2020-05-08 22:26:56 +03:00
63012cd7e4 Merge pull request 'Изменить 'Jenkinsfile'' (#10) from andrey-patch-1 into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-05-08 15:29:55 +03:00
ccd6838508 Изменить 'Jenkinsfile' 2020-05-08 15:27:30 +03:00
0df5b36586 Merge pull request 'RPI Dockerfile' (#9) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
SHS/libs/pipeline/head This commit looks good
2020-05-07 18:47:50 +03:00
9e2032cd27 RPI Dockerfile
All checks were successful
SHS/libs/pipeline/head This commit looks good
2020-05-07 18:47:08 +03:00
aa5b8af51c Merge pull request 'Jenkinsfile' (#8) from master into release
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
2020-05-07 18:16:22 +03:00
b5f69363cc Jenkinsfile 2020-05-07 18:15:25 +03:00
d4ddaf5f58 Merge remote-tracking branch 'remotes/origin/master' into HEAD
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-05-07 17:46:47 +03:00
3267e13aa8 migrate to docker tree 2020-05-07 17:41:48 +03:00
96dd4202d5 CROSSTOOLS support 2020-05-04 12:51:32 +03:00
f674b6fe2f README 2020-04-30 16:10:11 +03:00
b60e2db625 Licence add LGPLv3 2020-04-30 16:07:01 +03:00
b3d9dc8133 fix CMake "qt_install_lang()"
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-04-30 11:56:12 +03:00
18854891f4 fix CMake "qt_install_lang()" 2020-04-30 11:49:37 +03:00
11e903dc24 Исправляем сборку PIP
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-04-29 18:50:22 +03:00
6a037a8367 Merge branch 'master' of https://git.shs.tools/SHS/libs 2020-04-29 18:42:48 +03:00
90d73ba248 update pip 2020-04-29 18:42:44 +03:00
fa7851ade0 Merge pull request 'pip' (#4) from master into release
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
2020-04-29 18:34:44 +03:00
13e20d7c83 pip 2020-04-29 18:33:52 +03:00
163a5b943e Merge pull request 'update to PIP 1.14' (#3) from master into release
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
2020-04-29 18:19:31 +03:00
ad5bb3a750 cmake_android.bat 2020-04-29 18:13:19 +03:00
c8369d2bd9 pip fixes 2020-04-29 17:44:37 +03:00
a4eada7441 update to PIP 1.14 2020-04-29 17:21:24 +03:00
fdedf11f00 Merge pull request 'master' (#2) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-04-29 13:18:27 +03:00
2c7528fe6d Merge remote-tracking branch 'remotes/origin/release'
# Conflicts:
#	.gitmodules
2020-04-29 13:16:46 +03:00
c38ad9f907 deploy 2020-04-29 12:58:42 +03:00
dcee031d8b clean
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-04-28 14:50:26 +03:00
92d469750e c 2020-04-28 14:44:17 +03:00
ced89be7c8 clean 2020-04-28 14:42:42 +03:00
5519d4117b Jenkinsfile
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-04-28 13:33:24 +03:00
3606f0c90a README.md
Some checks failed
SHS Gitea/libs/pipeline/head Something is wrong with the build of this commit
2020-04-28 13:09:53 +03:00
59a20f4cd8 Jenkinsfile
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good
2020-04-27 21:15:01 +03:00
0e3aec8539 Jenkinsfile
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
2020-04-27 20:47:48 +03:00
fe715857fb Jenkinsfile
Some checks failed
SHS Gitea/libs/pipeline/head There was a failure building this commit
2020-04-27 20:22:57 +03:00
2c3310250a Jenkinsfile
Some checks failed
SHS Gitea/libs/pipeline/head Something is wrong with the build of this commit
2020-04-27 20:15:30 +03:00
823 changed files with 29700 additions and 22652 deletions

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
/.svn
CMakeLists.txt.user*
/project_fs_build
/qad/qad_version.h
/qglengine/core/qglengine_version.h

View File

@@ -9,15 +9,84 @@ 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()
set(_COMPANY SHS) if("x${BUILD_NUMBER}" STREQUAL "x")
set(_DOMAIN org.SHS) set(BUILD_NUMBER 0)
endif()
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_BINARY_DIR}/piqt)
if(MINGW) if(MINGW)
find_package(MinGW REQUIRED) find_package(MinGW REQUIRED)
else() else()
@@ -31,7 +100,7 @@ else()
link_directories(/usr/local/lib) link_directories(/usr/local/lib)
endif() endif()
else() else()
set(CMAKE_INSTALL_RPATH "\$ORIGIN/lib") set(CMAKE_INSTALL_RPATH "\$ORIGIN;\$ORIGIN/lib")
endif() endif()
endif() endif()
if (DEFINED ANDROID_PLATFORM) if (DEFINED ANDROID_PLATFORM)
@@ -42,20 +111,29 @@ 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(LIB "System install" 1) option(CROSSTOOLS "Crosstools minimal build" OFF)
option(QGLVIEW "Build QGLview library and utils" 0) option(LIB "System install" ON)
option(QGLENGINE "Build QGLENGINE library and utils" 0) option(QGLVIEW "Build QGLview library and utils" OFF)
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)
set(LIB 1)
set(QGLVIEW 0)
set(QGLENGINE 0)
set(UTILS 0)
set(DESIGNER_PLUGINS 0)
endif()
if (CMAKE_BUILD_TYPE MATCHES Debug) if (CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -Wall") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -Wall")
@@ -66,7 +144,6 @@ endif()
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(PIP_LIBRARY pip) set(PIP_LIBRARY pip)
set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io_devices" "io_utils" "console" "math" "code" "geo" "resources" "opencl" "crypt" "introspection" "concurrent" "cloud")
set(PIP_INCLUDES) set(PIP_INCLUDES)
if(LIB) if(LIB)
@@ -90,73 +167,132 @@ else()
message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"") message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"")
endif() endif()
foreach(F ${PIP_FOLDERS})
list(APPEND PIP_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/pip/src_main/${F}")
endforeach(F)
#message(${PIP_INCLUDES}) #message(${PIP_INCLUDES})
if(CMAKE_CROSSCOMPILING OR (DEFINED ANDROID_PLATFORM)) if(CMAKE_CROSSCOMPILING OR (DEFINED ANDROID_PLATFORM))
set(PIP_CMG "pip_cmg") set(PIP_CMG "pip_cmg")
set(PIP_RC "pip_rc") set(PIP_RC "pip_rc")
set(PIP_DEPLOY_TOOL "deploy_tool")
else() else()
set(PIP_CMG "${CMAKE_CURRENT_BINARY_DIR}/pip/utils/code_model_generator/pip_cmg") set(PIP_CMG "${CMAKE_CURRENT_BINARY_DIR}/pip/utils/code_model_generator/pip_cmg")
set(PIP_RC "${CMAKE_CURRENT_BINARY_DIR}/pip/utils/resources_compiler/pip_rc") set(PIP_RC "${CMAKE_CURRENT_BINARY_DIR}/pip/utils/resources_compiler/pip_rc")
set(PIP_DEPLOY_TOOL "${CMAKE_CURRENT_BINARY_DIR}/pip/utils/deploy_tool/deploy_tool")
endif() endif()
if(WIN32) if(WIN32)
set(PIP_DLL_DIR "${CMAKE_CURRENT_BINARY_DIR}/pip") set(PIP_DLL_DIR "${CMAKE_CURRENT_BINARY_DIR}/pip")
endif() endif()
set(QAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/qad) set(QAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/qad)
set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
include(QtWraps) if (CROSSTOOLS)
find_qt(Core QUIET)
set(QtVersions) add_subdirectory(pip)
set(SomeQtFound 0) file(GLOB CMAKES "qad/cmake/*.cmake" "qad/cmake/*.in")
foreach(_v ${_QT_VERSIONS_}) install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
option(Qt${_v} "Build for Qt${_v}" 1)
if (Qt${_v})
#message("Qt${_v} -> ${LOCAL_FOUND${_v}}")
if (LOCAL_FOUND${_v})
list(APPEND QtVersions Qt${_v})
set(SomeQtFound 1)
endif()
endif()
endforeach()
if(UTILS)
message(STATUS "Building with utils")
else() else()
message(STATUS "Building only libraries")
endif()
add_subdirectory(pip) include(QtWraps)
set(_DIRS) find_qt(Core QUIET)
if (SomeQtFound) set(QtVersions)
message(STATUS "Building Qt-derived targets for ${QtVersions}") set(SomeQtFound 0)
add_subdirectory(qad) foreach(_v ${_QT_VERSIONS_})
set(_DIRS piqt piqt_utils qcd_utils) option(Qt${_v} "Build for Qt${_v}" 1)
if (Qt5) if (Qt${_v})
if (QGLVIEW) #message("Qt${_v} -> ${LOCAL_FOUND${_v}}")
list(APPEND _DIRS qglview) if (LOCAL_FOUND${_v})
list(APPEND QtVersions Qt${_v})
set(SomeQtFound 1)
endif()
endif() endif()
if (QGLENGINE) endforeach()
list(APPEND _DIRS qglengine)
#if(UTILS)
# message(STATUS "Building with utils")
#else()
# message(STATUS "Building only libraries")
#endif()
add_subdirectory(pip)
foreach(F ${PIP_MAIN_FOLDERS})
list(APPEND PIP_INCLUDES "${F}")
endforeach(F)
add_subdirectory(cd_utils)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/cd_utils" "${CMAKE_CURRENT_BINARY_DIR}/cd_utils")
set(_DIRS)
if (SomeQtFound)
#message(STATUS "Building Qt-derived targets for ${QtVersions}")
add_subdirectory(qad)
include_directories(${qad_includes})
add_subdirectory(piqt)
include_directories(${piqt_includes})
set(_DIRS)
if (Qt5)
if (QGLVIEW)
list(APPEND _DIRS qglview)
endif()
if (QGLENGINE)
list(APPEND _DIRS qglengine)
endif()
endif() endif()
foreach(_D ${_DIRS})
list(APPEND QT_MULTILIB_LIST ${_D})
add_subdirectory(${_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()
message(STATUS "None of Qt found, skip Qt-derived targets")
endif() endif()
foreach(_D ${_DIRS})
list(APPEND QT_MULTILIB_LIST ${_D})
endforeach(_D)
include_directories(piqt)
else()
message(STATUS "None of Qt found, skip Qt-derived targets")
endif() endif()
include_directories(cd_utils)
list(INSERT _DIRS 0 cd_utils)
foreach(_D ${_DIRS})
add_subdirectory(${_D})
endforeach(_D)
if(WIN32) if(WIN32)
foreach(PIP_LT ${PIP_LIBS_TARGETS}) foreach(PIP_LT ${PIP_MODULES})
if (SomeQtFound) if (SomeQtFound)
qt_install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pip/lib${PIP_LT}.dll" DESTINATION QtBin) qt_install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pip/lib${PIP_LT}.dll" DESTINATION QtBin)
endif() endif()

70
Jenkinsfile vendored
View File

@@ -1,10 +1,62 @@
node { def build_docker(name) {
def img def image = "${name}-libs"
def def_args = "--no-cache --build-arg LIBS_BUILD_NUMBER=${env.BUILD_NUMBER} --build-arg JOBS_COUNT=4" echo "Build image ${image}"
if (env.DOCKER_PREFIX) { def pref = ""
img = docker.build("${env.DOCKER_PREFIX}/libs", "${def_args} --build-arg DOCKER_PREFIX=${env.DOCKER_PREFIX} .") if (env.DOCKER_PREFIX) {
} else { pref = "--build-arg DOCKER_PREFIX=${env.DOCKER_PREFIX}/"
img = docker.build("libs", "${def_args} .")
} }
img.push() def jobs = 4
} if (env.JOBS_COUNT) {
jobs = "${env.JOBS_COUNT}"
}
def args = "${pref} --build-arg LIBS_BUILD_NUMBER=${env.BUILD_NUMBER} --build-arg JOBS_COUNT=${jobs}"
dir ("docker/${image}") {
sh "docker build ${args} --no-cache -t ${image} ."
}
return "\n - ${image}"
}
node {
stage("checkout") {
checkout scm
}
def _envmap = [:]
def _env = sh(script: "env", returnStdout: true).trim().split("\n")
_env.each{ l ->
def _ind = l.indexOf('=');
def _n = l.substring(0, _ind);
def _v = l.substring(_ind + 1);
_envmap["${_n}"] = "${_v}";
}
def _msg = "Built images:"
def platforms = ['debian', 'osx', 'windows', 'android', 'pi']
for (int i = 0; i < platforms.size(); ++i) {
if (_envmap["BUILD_${platforms[i]}"] == "1") {
stage("${platforms[i]}-libs") {
_msg += build_docker("${platforms[i]}")
}
}
}
sh "docker system prune -f"
echo "${_msg}"
}
pipeline {
agent {
label 'master'
}
stages {
stage("PIP doc") {
steps {
checkout scm
sh "rm -rf share"
sh "rm -vf *.zip"
sh "mkdir -p build"
sh "cd build && cmake -DLIB=0 -DCMAKE_INSTALL_PREFIX=`pwd` ../"
sh "cd build && make doc"
sh "cd share/doc && zip -r ../../pip_doc.zip pip"
sh "cp share/doc/pip/html/pip.qch ./"
archiveArtifacts 'pip_doc.zip'
archiveArtifacts 'pip.qch'
}
}
}
}

165
LICENSE.txt Normal file
View File

@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@@ -1,5 +1,7 @@
# Main SHS SDK libraries repo # Main SHS SDK libraries repo
## Introduction ## Introduction
This repo contains PIP, QAD and derived projects: This repo contains PIP, QAD and derived projects:
* cd_utils - PIP-based client/server library for read, transmit and use custom structures of coefficients * cd_utils - PIP-based client/server library for read, transmit and use custom structures of coefficients
* qcd_utils - Qt bindings to CDUtils and "CD Pult" executable - full-featured CD client * qcd_utils - Qt bindings to CDUtils and "CD Pult" executable - full-featured CD client
@@ -7,6 +9,7 @@ This repo contains PIP, QAD and derived projects:
* piqt_utils - Gui libraries and executables to edit PIConnection configs and watch PIIntrospection * piqt_utils - Gui libraries and executables to edit PIConnection configs and watch PIIntrospection
* qglview - old Qt-base OpenGL engine * qglview - old Qt-base OpenGL engine
* qglengine - new Qt-base OpenGL engine * qglengine - new Qt-base OpenGL engine
## Compile ## Compile
This repo can be compile with GCC/MinGW/Clang, for Qt 4/5. This repo can be compile with GCC/MinGW/Clang, for Qt 4/5.
@@ -18,6 +21,7 @@ CMake options:
* **DESIGNER_PLUGINS** - build or not Qt Designer plugins, enabled by default * **DESIGNER_PLUGINS** - build or not Qt Designer plugins, enabled by default
* **QGLVIEW** - build or not QGLView, disabled by default * **QGLVIEW** - build or not QGLView, disabled by default
* **QGLENGINE** - build or not QGLEngine, disabled by default * **QGLENGINE** - build or not QGLEngine, disabled by default
## Windows scripts ## Windows scripts
Build steps for i686 architecture: Build steps for i686 architecture:
1. unzip mingw.7z to C:\mingw 1. unzip mingw.7z to C:\mingw
@@ -36,6 +40,15 @@ Build steps for amd64 architecture:
Build steps for both architectures: Build steps for both architectures:
-- follow previos steps, but on '4' state run make_libs_all.bat -- follow previos steps, but on '4' state run make_libs_all.bat
## Non-Windows scripts
Script "make_libs.sh" compile and install SDK for current environment, e.g. ## Non-Windows scripts
`./make_libs.sh -j4` Script "make_libs.sh" compile and install SDK for current environment, e.g.
`./make_libs.sh -j4`
## Docker
This repo provide Dockerfile, so you can exec `docker build -t libs .` in this directory
and make docker image "libs" with installed SHS SDK for:
* Debian 10
* Windows x64
* MacOS
* Android ndk 21 armeabi-v71, arm64-v8a, x86, x86_64

View File

@@ -1,35 +1,107 @@
macro(sdk_install _DIR _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(NOT "x${_H_FILES}" STREQUAL "x") if(WIN32)
install(FILES ${_H_FILES} DESTINATION ${MINGW_INCLUDE}/${_DIR}) install(FILES ${_H_FILES} DESTINATION ${MINGW_INCLUDE}/${_DIR})
endif() else()
qt_install(TARGETS ${_TARGET} ARCHIVE DESTINATION ${MINGW_LIB}) install(FILES ${_H_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${_DIR})
qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION ${MINGW_BIN}) endif()
qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION QtBin) else()
else() install(FILES ${_H_FILES} DESTINATION include/${_DIR})
if (NOT "x${_H_FILES}" STREQUAL "x") endif()
install(FILES ${_H_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${_DIR}) endif()
endif() if (NOT "${_TARGET}" STREQUAL "")
qt_install(TARGETS ${_TARGET} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) if(LIB)
endif() if(WIN32)
if(NOT "x${_QM_FILES}" STREQUAL "x") if (${IS_APP})
qt_install(LANG ${_QM_FILES} DESTINATION QtLang) qt_install(TARGETS ${_TARGET} DESTINATION ${MINGW_BIN})
endif() qt_install(TARGETS ${_TARGET} DESTINATION QtBin)
else() else()
if(NOT "x${_H_FILES}" STREQUAL "x") qt_install(TARGETS ${_TARGET} ARCHIVE DESTINATION ${MINGW_LIB})
install(FILES ${_H_FILES} DESTINATION include/${_DIR}) qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION ${MINGW_BIN})
endif() qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION QtBin)
if(WIN32) endif()
qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION bin) else()
qt_install(TARGETS ${_TARGET} ARCHIVE DESTINATION lib) if (${IS_APP})
else() qt_install(TARGETS ${_TARGET} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
qt_install(TARGETS ${_TARGET} DESTINATION lib) else()
endif() qt_install(TARGETS ${_TARGET} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
if(NOT "x${_QM_FILES}" STREQUAL "x") endif()
qt_install(LANG ${_QM_FILES} DESTINATION lang) endif()
endif() if(NOT "x${_QM_FILES}" STREQUAL "x")
endif() qt_install(LANG ${_QM_FILES} DESTINATION QtLang)
endmacro() endif()
else()
if(${IS_APP})
qt_install(TARGETS ${_TARGET} DESTINATION bin)
else()
if(WIN32)
qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION bin)
qt_install(TARGETS ${_TARGET} ARCHIVE DESTINATION lib)
else()
qt_install(TARGETS ${_TARGET} DESTINATION lib)
endif()
endif()
if(NOT "x${_QM_FILES}" STREQUAL "x")
qt_install(LANG ${_QM_FILES} DESTINATION lang)
endif()
endif()
endif()
endmacro()
macro(copy_to_parent _inc_var)
set(QT_MULTILIB_LIST ${QT_MULTILIB_LIST} PARENT_SCOPE)
set(_qt_libs ${_qt_libs} PARENT_SCOPE)
set(_qt_apps ${_qt_apps} PARENT_SCOPE)
set(_qt_plugs ${_qt_plugs} PARENT_SCOPE)
if (NOT "x${_inc_var}" STREQUAL "x")
set(${_inc_var} ${${_inc_var}} PARENT_SCOPE)
endif()
if (LIB)
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
endif()
endmacro()
macro(add_directories_with_include multilib_prefix)
set(DIRS)
file(GLOB _dl "[^.]*")
foreach(_d ${_dl})
if(IS_DIRECTORY ${_d})
list(APPEND DIRS ${_d})
endif()
endforeach()
set(inc_var ${multilib_prefix}includes)
set(${inc_var})
foreach(_d ${DIRS})
get_filename_component(_dname "${_d}" NAME)
list(APPEND QT_MULTILIB_LIST ${multilib_prefix}${_dname})
list(APPEND ${inc_var} "${_d}")
list(APPEND ${inc_var} "${CMAKE_CURRENT_BINARY_DIR}/${_dname}")
endforeach()
include_directories(${${inc_var}})
foreach(_d ${DIRS})
add_subdirectory(${_d})
endforeach()
copy_to_parent(${inc_var})
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,6 +0,0 @@
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY FIRST)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE FIRST)
set(CMAKE_PREFIX_PATH /soft/android/${ANDROID_ABI})
list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH}/lib)
include_directories(${CMAKE_PREFIX_PATH}/include)

View File

@@ -1,86 +1,37 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(cd_utils) project(cd_utils)
if (NOT LIBPROJECT) find_package(MinGW REQUIRED)
find_package(PIP REQUIRED) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES})
option(LIB "System install" 1) file(GLOB CPPS_UTILS "cdutils_*.cpp")
option(DEBUG "Build with -g3" 0) file(GLOB HDRS_UTILS "cdutils_*.h")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall") add_library(${PROJECT_NAME} SHARED ${CPPS_UTILS} ${HDRS_UTILS})
if (DEBUG) target_link_libraries(${PROJECT_NAME} ${PIP_LIBRARY})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3") generate_export_header(${PROJECT_NAME})
endif() list(APPEND HDRS_UTILS "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_export.h")
endif()
if (MINGW) add_executable(cdutilstest "cdutilstest.cpp" "cdtest.h")
find_package(MinGW REQUIRED) target_link_libraries(cdutilstest ${PIP_LIBRARY} ${PROJECT_NAME})
endif() message(STATUS "Building ${PROJECT_NAME}")
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES})
#file(GLOB HDRS_UTILS "*.h") if(LIB)
#file(GLOB CPPS_UTILS "*.cpp") list(APPEND _ALL_TARGETS ${PROJECT_NAME})
file(GLOB CPPS_UTILS "cdutils_*.cpp") set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
file(GLOB HDRS_UTILS "cdutils_*.h") if(WIN32)
if (DEFINED ENV{QNX_HOST}) install(FILES ${HDRS_UTILS} DESTINATION ${MINGW_INCLUDE})
add_library(${PROJECT_NAME} STATIC ${CPPS_UTILS} ${HDRS_UTILS}) install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${MINGW_LIB})
else() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${MINGW_BIN})
add_library(${PROJECT_NAME} SHARED ${CPPS_UTILS} ${HDRS_UTILS}) else()
endif() install(FILES ${HDRS_UTILS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
target_link_libraries(${PROJECT_NAME} ${PIP_LIBRARY}) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif()
# # Apple crosscompiling rpath patch #message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
# if (APPLE AND CMAKE_CROSSCOMPILING AND CMAKE_MACOSX_RPATH) else()
# foreach(_RP ${CMAKE_INSTALL_RPATH}) if(WIN32)
# add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
# COMMAND "${CMAKE_INSTALL_NAME_TOOL}" install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib)
# "-add_rpath" "${_RP}" else()
# "$<TARGET_FILE_DIR:${PROJECT_NAME}>/$<TARGET_FILE_NAME:${PROJECT_NAME}>" install(TARGETS ${PROJECT_NAME} DESTINATION lib)
# COMMENT "Add to ${PROJECT_NAME} rpath \"${_RP}\"") endif()
# endforeach() install(FILES ${HDRS_UTILS} DESTINATION include)
# endif() #message(STATUS "Install ${PROJECT_NAME} to local \"bin\"")
endif()
add_executable(cdutilstest "cdutilstest.cpp" "cdtest.h")
target_link_libraries(cdutilstest ${PIP_LIBRARY} ${PROJECT_NAME})
message(STATUS "Building ${PROJECT_NAME}")
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()
if(CMAKE_CROSSCOMPILING)
set(CMAKE_INSTALL_PREFIX ${CMAKE_STAGING_PREFIX})
else()
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr/local)
endif()
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()
if(LIB)
list(APPEND _ALL_TARGETS ${PROJECT_NAME})
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
if(WIN32)
install(FILES ${HDRS_UTILS} DESTINATION ${MINGW_INCLUDE})
install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${MINGW_LIB})
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${MINGW_BIN})
else()
install(FILES ${HDRS_UTILS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif()
#message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
else()
if(WIN32)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib)
else()
install(TARGETS ${PROJECT_NAME} DESTINATION lib)
endif()
install(FILES ${HDRS_UTILS} DESTINATION include)
#message(STATUS "Install ${PROJECT_NAME} to local \"bin\"")
endif()

165
cd_utils/LICENSE.txt Normal file
View File

@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

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,26 +1,46 @@
#ifndef CDUTILS_C_H /*
#define CDUTILS_C_H CD Utils - Control-Debug utilites
#include "cdutils_interface.h" Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
namespace CDUtils { 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
(at your option) any later version.
class CInterface: public Interface
{ This program is distributed in the hope that it will be useful,
PIOBJECT_SUBCLASS(CInterface, Interface) but WITHOUT ANY WARRANTY; without even the implied warranty of
public: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
CInterface(); GNU Lesser General Public License for more details.
void sendCommand(const CDType & c); You should have received a copy of the GNU Lesser General Public License
void connect(const CDType & c, PIObject * o, Handler eh); along with this program. If not, see <http://www.gnu.org/licenses/>.
void autoConnect(PIObject * o, const PIString & prefix = PIStringAscii("c_")); */
}; #ifndef CDUTILS_C_H
#define CDUTILS_C_H
}
#include "cdutils_interface.h"
extern CDUtils::CInterface C; #include "cd_utils_export.h"
#endif // CDUTILS_C_H
namespace CDUtils {
class CD_UTILS_EXPORT CInterface: public Interface
{
PIOBJECT_SUBCLASS(CInterface, Interface)
public:
CInterface();
void sendCommand(const CDType & c);
void connect(const CDType & c, PIObject * o, Handler eh);
void autoConnect(PIObject * o, const PIString & prefix = PIStringAscii("c_"));
};
}
extern CD_UTILS_EXPORT CDUtils::CInterface C;
#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,127 +1,147 @@
#ifndef CDUTILS_CORE_H /*
#define CDUTILS_CORE_H CD Utils - Control-Debug utilites
#include "cdutils_types.h" Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
#include "cdutils_protocol.h"
#include "piconnection.h" This program is free software: you can redistribute it and/or modify
#include "pidatatransfer.h" 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
(at your option) any later version.
namespace CDUtils {
This program is distributed in the hope that it will be useful,
class CDCore; but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
class __Core_Initializer__ {
public: You should have received a copy of the GNU Lesser General Public License
__Core_Initializer__(); along with this program. If not, see <http://www.gnu.org/licenses/>.
~__Core_Initializer__(); */
static int count_;
static CDCore * __instance__; #ifndef CDUTILS_CORE_H
}; #define CDUTILS_CORE_H
#include "cdutils_types.h"
class CDCore: public PIObject #include "cdutils_protocol.h"
{ #include "piconnection.h"
PIOBJECT(CDUtils::CDCore) #include "pidatatransfer.h"
friend class __Core_Initializer__; #include "cd_utils_export.h"
friend class CDSection;
friend class Interface;
friend class XInterface; namespace CDUtils {
public:
static CDCore * instance(); class CDCore;
static bool destroy();
EVENT(K_Sended) class CD_UTILS_EXPORT __Core_Initializer__ {
EVENT(K_SendFail) public:
EVENT(K_Received) __Core_Initializer__();
EVENT(K_ReceiveFail) ~__Core_Initializer__();
EVENT(K_ChangedGlobal) static int count_;
EVENT_HANDLER2(void, K_DirectChange, PIDeque<int>, path, PIString, value); static CDCore * __instance__;
};
EVENT(X_Sended)
EVENT(X_SendFail)
EVENT(X_Received) class CD_UTILS_EXPORT CDCore: public PIObject
EVENT(X_ReceiveFail) {
EVENT(X_ChangedGlobal) PIOBJECT(CDUtils::CDCore)
EVENT1(X_ReceivedX, PIVector<PIDeque<int> >, pathes) friend class __Core_Initializer__;
friend class CDSection;
EVENT(C_Sended) friend class Interface;
EVENT(C_SendFail) friend class XInterface;
EVENT(C_Received) public:
EVENT(C_ReceiveFail) static CDCore * instance();
EVENT(C_ChangedGlobal) static bool destroy();
EVENT(M_Sended) EVENT(K_Sended)
EVENT(M_SendFail) EVENT(K_SendFail)
EVENT(M_Received) EVENT(K_Received)
EVENT(M_ReceiveFail) EVENT(K_ReceiveFail)
EVENT(M_ChangedGlobal) EVENT(K_ChangedGlobal)
EVENT3(M_Message, PIDeque<int>, path, int, type, PIString, msg) EVENT_HANDLER2(void, K_DirectChange, PIDeque<int>, path, PIString, value);
void cd_write (CDSection * cd, PIIODevice * d); EVENT(X_Sended)
void cd_read (CDSection * cd, PIIODevice * d); EVENT(X_SendFail)
void cd_parse (CDSection * cd, PIIODevice * d); EVENT(X_Received)
void cd_update (CDSection * cd, PIIODevice * d, UpdateModeFlags mode); EVENT(X_ReceiveFail)
void cd_calculate(CDSection * cd); EVENT(X_ChangedGlobal)
void cd_send (CDSection * cd, CDPacketType pt, bool direct = false); EVENT1(X_ReceivedX, PIVector<PIDeque<int> >, pathes)
void send(CDType::cdT cdt);
void request(CDType::cdT cdt); EVENT(C_Sended)
void initApp(); EVENT(C_SendFail)
void initPult(); EVENT(C_Received)
void init(const PIString & configuration, bool pult = false); EVENT(C_ReceiveFail)
void stop(); EVENT(C_ChangedGlobal)
void release();
void startX(double freq = 20.); EVENT(M_Sended)
void stopX(); EVENT(M_SendFail)
void sendCommand(const CDType & c); EVENT(M_Received)
void registerCHandler(const CDType & c, PIObject * o, Handler h); EVENT(M_ReceiveFail)
bool inProgress() {return sendt.isRunning();} EVENT(M_ChangedGlobal)
void sendMessage(const CDType & m, MessageType mt, const PIString & msg); EVENT3(M_Message, PIDeque<int>, path, int, type, PIString, msg)
CDSection * root(CDType::cdT cdt); void cd_write (CDSection * cd, PIIODevice * d);
PIString typeLetter(CDType::cdT cdt); void cd_read (CDSection * cd, PIIODevice * d);
static PIString pathToString(const PIDeque<int> & p); void cd_parse (CDSection * cd, PIIODevice * d);
static PIDeque<int> stringToPath(const PIString & p); void cd_update (CDSection * cd, PIIODevice * d, UpdateModeFlags mode);
void cd_calculate(CDSection * cd);
static PIString pultConfig() {return PIString(pult_config);} void cd_send (CDSection * cd, CDPacketType pt, bool direct = false);
static PIString appConfig() {return PIString(app_config);} void send(CDType::cdT cdt);
void request(CDType::cdT cdt);
private: void initApp();
CDCore(); void initPult();
~CDCore(); void init(const PIString & configuration, bool pult = false);
EVENT_HANDLER2(void, dataReceived, const PIString &, from, const PIByteArray &, data); void stop();
EVENT_HANDLER1(void, dtSendRequest, PIByteArray &, data); void release();
EVENT_HANDLER1(void, dtReceiveFinished, bool, ok); void startX(double freq = 20.);
EVENT_HANDLER(void, sendThread); void stopX();
EVENT_HANDLER(void, xTimerTick); void sendCommand(const CDType & c);
EVENT_HANDLER2(void, piCoutFinished, int, id, PIString*, buffer); void registerCHandler(const CDType & c, PIObject * o, Handler h);
void initRoot(CDSection * r); bool inProgress() {return sendt.isRunning();}
PIByteArray makeHeader(CDPacketType type, int session_id = 0) const; void sendMessage(const CDType & m, MessageType mt, const PIString & msg);
void sendDirect(PIByteArray & ba);
void sendThreaded(PIByteArray & ba); CDSection * root(CDType::cdT cdt);
void procReceivedPacket(PIByteArray & ba); PIString typeLetter(CDType::cdT cdt);
void raiseChangedGlobal(CDType::cdT cdt); static PIString pathToString(const PIDeque<int> & p);
static PIDeque<int> stringToPath(const PIString & p);
typedef PIPair<PIObject * , Handler> OHPair;
static PIString pultConfig() {return PIString(pult_config);}
static const char app_config[], pult_config[]; static PIString appConfig() {return PIString(app_config);}
PIConnection connection;
PIDataTransfer datatr; private:
PIByteArray send_data; CDCore();
PIThread sendt; ~CDCore();
PITimer x_timer; EVENT_HANDLER2(void, dataReceived, const PIString &, from, const PIByteArray &, data);
CDSection k_, x_, c_, m_; EVENT_HANDLER1(void, dtSendRequest, PIByteArray &, data);
PIMutex x_mutex; EVENT_HANDLER1(void, dtReceiveFinished, bool, ok);
PIVector<PIDeque<int> > x_selected; EVENT_HANDLER(void, sendThread);
PIMap<PIString, OHPair> c_handlers; EVENT_HANDLER(void, xTimerTick);
bool need_rebuild_x, x_pult_side; EVENT_HANDLER2(void, piCoutFinished, int, id, PIString*, buffer);
void initRoot(CDSection * r);
}; PIByteArray makeHeader(CDPacketType type, int session_id = 0) const;
void sendDirect(PIByteArray & ba);
void sendThreaded(PIByteArray & ba);
static __Core_Initializer__ __Core_initializer__; void procReceivedPacket(PIByteArray & ba);
void raiseChangedGlobal(CDType::cdT cdt);
}
typedef PIPair<PIObject * , Handler> OHPair;
#endif // CDUTILS_CORE_H
static const char app_config[], pult_config[];
PIConnection connection;
PIDataTransfer datatr;
PIByteArray send_data;
PIThread sendt;
PITimer x_timer;
CDSection k_, x_, c_, m_;
PIMutex x_mutex;
PIVector<PIDeque<int> > x_selected;
PIMap<PIString, OHPair> c_handlers;
bool need_rebuild_x, x_pult_side;
};
static __Core_Initializer__ __Core_initializer__;
}
#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)); 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,76 +1,96 @@
#ifndef CDUTILS_INTERFACE_H /*
#define CDUTILS_INTERFACE_H CD Utils - Control-Debug utilites
#include "cdutils_types.h" Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
#include "piobject.h"
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
namespace CDUtils { the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
class CDCore;
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
class Interface: public PIObject MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
{ GNU Lesser General Public License for more details.
PIOBJECT(CDUtils::Interface)
public: You should have received a copy of the GNU Lesser General Public License
Interface(CDType::cdT type_); along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
bool test(int v);
CDType & operator [](int v); #ifndef CDUTILS_INTERFACE_H
const CDType operator [](int v) const; #define CDUTILS_INTERFACE_H
CDType & operator [](const PIString & name_);
const CDType operator [](const PIString & name_) const; #include "cdutils_types.h"
CDType & operator [](const PIDeque<int> & path_); #include "piobject.h"
const CDType operator [](const PIDeque<int> & path_) const; #include "cd_utils_export.h"
CDSection & section(int v);
const CDSection section(int v) const;
CDSection & section(const PIDeque<int> & path); namespace CDUtils {
CDSection & root();
const CDSection & root() const; class CDCore;
int count(bool recursive = true) const;
const PIString file() const {return file_;} class CD_UTILS_EXPORT Interface: public PIObject
int fileSize() const {return file_size;} {
CDType::cdT cdType() const {return type;} PIOBJECT(CDUtils::Interface)
bool exists(PIDeque<int> path) const; public:
Interface(CDType::cdT type_);
void setFileName(const PIString & _file);
bool configure(const PIString & config); bool test(int v);
void reinitConnection(const PIString & configuration); CDType & operator [](int v);
void releaseConnection(); const CDType operator [](int v) const;
void write(PIIODevice * d); CDType & operator [](const PIString & name_);
void read(PIIODevice * d); const CDType operator [](const PIString & name_) const;
void parse(PIIODevice * d); CDType & operator [](const PIDeque<int> & path_);
void update(PIIODevice * d, UpdateModeFlags mode = SaveByName); const CDType operator [](const PIDeque<int> & path_) const;
void calculate(); CDSection & section(int v);
const CDSection section(int v) const;
PIString appConfig(); CDSection & section(const PIDeque<int> & path);
PIString pultConfig(); CDSection & root();
const CDSection & root() const;
void readFile();
void writeFile(); int count(bool recursive = true) const;
bool inProgress(); const PIString file() const {return file_;}
int fileSize() const {return file_size;}
EVENT(sended) CDType::cdT cdType() const {return type;}
EVENT(sendFailed) bool exists(PIDeque<int> path) const;
EVENT(received)
EVENT(receiveFailed) void setFileName(const PIString & _file);
EVENT(changedGlobal) bool configure(const PIString & config);
EVENT_HANDLER(void, send); void reinitConnection(const PIString & configuration);
EVENT_HANDLER(void, request); void releaseConnection();
void write(PIIODevice * d);
protected: void read(PIIODevice * d);
CDCore * core; void parse(PIIODevice * d);
CDSection * s; void update(PIIODevice * d, UpdateModeFlags mode = SaveByName);
CDType::cdT type; void calculate();
PIString file_;
int file_size; PIString appConfig();
PIString pultConfig();
};
void readFile();
void writeFile();
} bool inProgress();
EVENT(sended)
#endif // CDUTILS_INTERFACE_H EVENT(sendFailed)
EVENT(received)
EVENT(receiveFailed)
EVENT(changedGlobal)
EVENT_HANDLER(void, send);
EVENT_HANDLER(void, request);
protected:
CDCore * core;
CDSection * s;
CDType::cdT type;
PIString file_;
int file_size;
};
}
#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,27 +1,47 @@
#ifndef CDUTILS_K_H /*
#define CDUTILS_K_H CD Utils - Control-Debug utilites
#include "cdutils_interface.h" Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
namespace CDUtils { 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
(at your option) any later version.
class KInterface: public Interface
{ This program is distributed in the hope that it will be useful,
PIOBJECT_SUBCLASS(KInterface, Interface) but WITHOUT ANY WARRANTY; without even the implied warranty of
public: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
KInterface(); GNU Lesser General Public License for more details.
EVENT1(keepNamesRequest, bool*, kn) 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/>.
void directChange(const CDType & k); */
void directChange(const CDType & k, double v);
#ifndef CDUTILS_K_H
}; #define CDUTILS_K_H
} #include "cdutils_interface.h"
#include "cd_utils_export.h"
extern CDUtils::KInterface K;
#endif // CDUTILS_K_H namespace CDUtils {
class CD_UTILS_EXPORT KInterface: public Interface
{
PIOBJECT_SUBCLASS(KInterface, Interface)
public:
KInterface();
EVENT1(keepNamesRequest, bool*, kn)
void directChange(const CDType & k);
void directChange(const CDType & k, double v);
};
}
extern CD_UTILS_EXPORT CDUtils::KInterface K;
#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,36 +1,56 @@
#ifndef CDUTILS_M_H /*
#define CDUTILS_M_H CD Utils - Control-Debug utilites
#include "cdutils_interface.h" Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
namespace CDUtils { 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
(at your option) any later version.
class MInterface: public Interface
{ This program is distributed in the hope that it will be useful,
PIOBJECT_SUBCLASS(MInterface, Interface) but WITHOUT ANY WARRANTY; without even the implied warranty of
public: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MInterface(); GNU Lesser General Public License for more details.
PICout operator [](int v) {return createPICout((*s)[v]);} You should have received a copy of the GNU Lesser General Public License
PICout operator [](int v) const {return createPICout((*s)[v]);} along with this program. If not, see <http://www.gnu.org/licenses/>.
PICout operator [](const PIString & name_) {return createPICout((*s)[name_]);} */
PICout operator [](const PIString & name_) const {return createPICout((*s)[name_]);}
PICout operator [](const PIDeque<int> & path_) {return createPICout((*s)[path_]);} #ifndef CDUTILS_M_H
PICout operator [](const PIDeque<int> & path_) const {return createPICout((*s)[path_]);} #define CDUTILS_M_H
void messageBox(const CDType & m, const PIString & msg); #include "cdutils_interface.h"
#include "cd_utils_export.h"
EVENT3(messageReceived, PIDeque<int>, path, int, type, PIString, msg)
private: namespace CDUtils {
PICout createPICout(const CDType & m) const;
}; class CD_UTILS_EXPORT MInterface: public Interface
{
} PIOBJECT_SUBCLASS(MInterface, Interface)
public:
extern CDUtils::MInterface M; MInterface();
#endif // CDUTILS_M_H PICout operator [](int v) {return createPICout((*s)[v]);}
PICout operator [](int v) const {return createPICout((*s)[v]);}
PICout operator [](const PIString & name_) {return createPICout((*s)[name_]);}
PICout operator [](const PIString & name_) const {return createPICout((*s)[name_]);}
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);
EVENT3(messageReceived, PIDeque<int>, path, int, type, PIString, msg)
private:
PICout createPICout(const CDType & m) const;
};
}
extern CD_UTILS_EXPORT CDUtils::MInterface M;
#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,19 +1,39 @@
#ifndef CDUTILS_PARSER_H /*
#define CDUTILS_PARSER_H CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
class PIIODevice;
This program is free software: you can redistribute it and/or modify
namespace CDUtils { 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
class CDSection; (at your option) any later version.
namespace CDParser { This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
CDSection parse(PIIODevice * d, int cdsection_type); MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
}
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/>.
*/
#endif // CDUTILS_PARSER_H
#ifndef CDUTILS_PARSER_H
#define CDUTILS_PARSER_H
#include "cd_utils_export.h"
class PIIODevice;
namespace CDUtils {
class CDSection;
namespace CDParser {
CD_UTILS_EXPORT CDSection parse(PIIODevice * d, int cdsection_type);
}
}
#endif // CDUTILS_PARSER_H

View File

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

View File

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

View File

@@ -43,7 +43,7 @@ set Qt5_ROOT=%ANDROID_QT5_DIR%\lib\cmake
rem set Qt5_DIR=%Qt5_ROOT%\Qt5 rem set Qt5_DIR=%Qt5_ROOT%\Qt5
if NOT [%QARCH%]==[] ( if NOT [%QARCH%]==[] (
@echo on @echo on
cmake_mgw -Wno-dev -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK_HOME%\build\cmake\android.toolchain.cmake -DANDROID_STL=c++_shared -DANDROID_PLATFORM=android-%_PLATFORM_% -DANDROID_ABI=%AARCH% -DICU=0 -DQt4=0 -DQt5=1 -DQGLVIEW=0 -DQGLENGINE=0 -DQt5_DIR=%Qt5_ROOT%\Qt5 -DQt5LinguistTools_DIR=%Qt5_ROOT%\Qt5LinguistTools -DQt5UiPlugin_DIR=%Qt5_ROOT%\Qt5UiPlugin -DQt5UiTools_DIR=%Qt5_ROOT%\Qt5UiTools -DQt5Widgets_DIR=%Qt5_ROOT%\Qt5Widgets -DQt5Core_DIR=%Qt5_ROOT%\Qt5Core -DQt5Gui_DIR=%Qt5_ROOT%\Qt5Gui -DQt5Sql_DIR=%Qt5_ROOT%\Qt5Sql -DQt5OpenGL_DIR=%Qt5_ROOT%\Qt5OpenGL -DQt5PrintSupport_DIR=%Qt5_ROOT%\Qt5PrintSupport -DQt5Script_DIR=%Qt5_ROOT%\Qt5Script -DQt5Positioning_DIR=%Qt5_ROOT%\Qt5Positioning -DQt5Network_DIR=%Qt5_ROOT%\Qt5Network -DQt5Qml_DIR=%Qt5_ROOT%\Qt5Qml -DQt5Quick_DIR=%Qt5_ROOT%\Qt5Quick -DQt5QuickWidgets_DIR=%Qt5_ROOT%\Qt5QuickWidgets %~3 %~4 %~5 %~6 cmake_mgw -Wno-dev -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK_HOME%\build\cmake\android.toolchain.cmake -DANDROID_STL=c++_shared -DANDROID_PLATFORM=android-%_PLATFORM_% -DANDROID_ABI=%AARCH% -DICU=0 -DQt4=0 -DQt5=1 -DQGLVIEW=0 -DQGLENGINE=0 -DQt5_DIR=%Qt5_ROOT%\Qt5 -DQt5LinguistTools_DIR=%Qt5_ROOT%\Qt5LinguistTools -DQt5UiPlugin_DIR=%Qt5_ROOT%\Qt5UiPlugin -DQt5UiTools_DIR=%Qt5_ROOT%\Qt5UiTools -DQt5Widgets_DIR=%Qt5_ROOT%\Qt5Widgets -DQt5Core_DIR=%Qt5_ROOT%\Qt5Core -DQt5Gui_DIR=%Qt5_ROOT%\Qt5Gui -DQt5Sql_DIR=%Qt5_ROOT%\Qt5Sql -DQt5OpenGL_DIR=%Qt5_ROOT%\Qt5OpenGL -DQt5PrintSupport_DIR=%Qt5_ROOT%\Qt5PrintSupport -DQt5Script_DIR=%Qt5_ROOT%\Qt5Script -DQt5Positioning_DIR=%Qt5_ROOT%\Qt5Positioning -DQt5Network_DIR=%Qt5_ROOT%\Qt5Network -DQt5Qml_DIR=%Qt5_ROOT%\Qt5Qml -DQt5Quick_DIR=%Qt5_ROOT%\Qt5Quick -DQt5QuickWidgets_DIR=%Qt5_ROOT%\Qt5QuickWidgets -DQt5QmlModels_DIR=%Qt5_ROOT%\Qt5QmlModels -DQt5AndroidExtras_DIR=%Qt5_ROOT%\Qt5AndroidExtras %~3 %~4 %~5 %~6
) else ( ) else (
@echo on @echo on
cmake_mgw -Wno-dev -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK_HOME%\build\cmake\android.toolchain.cmake -DANDROID_STL=c++_shared -DANDROID_PLATFORM=android-%_PLATFORM_% -DANDROID_ABI=%AARCH% -DICU=0 -DQt4=0 -DQt5=0 -DQGLVIEW=0 %~3 %~4 %~5 %~6 cmake_mgw -Wno-dev -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK_HOME%\build\cmake\android.toolchain.cmake -DANDROID_STL=c++_shared -DANDROID_PLATFORM=android-%_PLATFORM_% -DANDROID_ABI=%AARCH% -DICU=0 -DQt4=0 -DQt5=0 -DQGLVIEW=0 %~3 %~4 %~5 %~6

0
cmake_android.sh Executable file → Normal file
View File

View File

@@ -1,50 +1,43 @@
ARG DOCKER_PREFIX=wapmobil ARG DOCKER_PREFIX=wapmobil/
FROM ${DOCKER_PREFIX}android
FROM ${DOCKER_PREFIX}/android
ARG LIBS_BUILD_NUMBER=9999 ARG LIBS_BUILD_NUMBER=9999
ARG JOBS_COUNT=4 ARG JOBS_COUNT=4
ENV PATH=/opt/cmake/bin:$PATH
ENV ANDROID_HOME=/usr/lib/android-sdk
ENV ANDROID_NDK_HOME=${ANDROID_HOME}/ndk-bundle
ENV ANDROID_TOOLCHAIN=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake
ENV NDK_PLATFORM="android-21"
WORKDIR /soft WORKDIR /soft
#RUN svn co svn://db.shs.com.ru/libs --username peri4 --password a --no-auth-cache --non-interactive --trust-server-cert RUN git clone -b release --single-branch --depth 1 --recursive https://git.shs.tools/SHS/libs.git
RUN git clone -b release --depth 1 --recursive https://git.shs.tools/SHS/libs.git
WORKDIR /soft/build_libs_linux WORKDIR /soft/libs_build_host
RUN cmake -DICU=0 -DQGLENGINE=1 -DQGLVIEW=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs/ \ RUN cmake -DICU=0 -DCROSSTOOLS=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \
&& make install -j${JOBS_COUNT} && rm -rf * \ && make install -j${JOBS_COUNT} \
&& rm -rf * \
&& ldconfig && ldconfig
WORKDIR /soft/build_libs_windows
RUN cmake -DCMAKE_INSTALL_PREFIX=/soft/windows -DICU=0 -DLIB=0 -DQGLENGINE=1 -DQGLVIEW=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} -DCMAKE_TOOLCHAIN_FILE=/soft/toolchain-Windows.cmake ../libs/ \
&& make install -j${JOBS_COUNT} && rm -rf *
WORKDIR /soft/build_libs_macos
RUN cmake -DCMAKE_INSTALL_PREFIX=/soft/osx -DICU=0 -DLIB=0 -DQGLENGINE=1 -DQGLVIEW=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} -DCMAKE_TOOLCHAIN_FILE=/soft/toolchain-Darwin.cmake ../libs/ \
&& make install -j${JOBS_COUNT} && rm -rf *
WORKDIR /soft/libs_build_anroid
ENV _ANDROID_TOOLCHAIN=/usr/lib/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake ENV _ANDROID_TOOLCHAIN=/usr/lib/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake
ENV _CUR_ABI=armeabi-v7a ENV _CUR_ABI=armeabi-v7a
WORKDIR /soft/build_libs_android_${_CUR_ABI}
RUN cmake -DCMAKE_INSTALL_PREFIX=/soft/android/${_CUR_ABI} -DICU=0 -DLIB=0 -DQGLENGINE=0 -DQGLVIEW=0 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} -DCMAKE_TOOLCHAIN_FILE=${_ANDROID_TOOLCHAIN} -DQt5_DIR=/soft/android/qt/lib/cmake/Qt5 -DANDROID_PLATFORM=${NDK_PLATFORM} -DANDROID_ABI=${_CUR_ABI} ../libs/ \ RUN cmake -DCMAKE_INSTALL_PREFIX=/soft/android/${_CUR_ABI} -DICU=0 -DLIB=0 -DQGLENGINE=0 -DQGLVIEW=0 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} -DCMAKE_TOOLCHAIN_FILE=${_ANDROID_TOOLCHAIN} -DQt5_DIR=/soft/android/qt/lib/cmake/Qt5 -DANDROID_PLATFORM=${NDK_PLATFORM} -DANDROID_ABI=${_CUR_ABI} ../libs/ \
&& make install -j${JOBS_COUNT} && rm -rf * && make install -j${JOBS_COUNT} && rm -rf *
ENV _CUR_ABI=arm64-v8a ENV _CUR_ABI=arm64-v8a
WORKDIR /soft/build_libs_android_${_CUR_ABI} WORKDIR /soft/libs_build_android_${_CUR_ABI}
RUN cmake -DCMAKE_INSTALL_PREFIX=/soft/android/${_CUR_ABI} -DICU=0 -DLIB=0 -DQGLENGINE=0 -DQGLVIEW=0 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} -DCMAKE_TOOLCHAIN_FILE=${_ANDROID_TOOLCHAIN} -DQt5_DIR=/soft/android/qt/lib/cmake/Qt5 -DANDROID_PLATFORM=${NDK_PLATFORM} -DANDROID_ABI=${_CUR_ABI} ../libs/ \ RUN cmake -DCMAKE_INSTALL_PREFIX=/soft/android/${_CUR_ABI} -DICU=0 -DLIB=0 -DQGLENGINE=0 -DQGLVIEW=0 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} -DCMAKE_TOOLCHAIN_FILE=${_ANDROID_TOOLCHAIN} -DQt5_DIR=/soft/android/qt/lib/cmake/Qt5 -DANDROID_PLATFORM=${NDK_PLATFORM} -DANDROID_ABI=${_CUR_ABI} ../libs/ \
&& make install -j${JOBS_COUNT} && rm -rf * && make install -j${JOBS_COUNT} && rm -rf *
ENV _CUR_ABI=x86 ENV _CUR_ABI=x86
WORKDIR /soft/build_libs_android_${_CUR_ABI} WORKDIR /soft/libs_build_android_${_CUR_ABI}
RUN cmake -DCMAKE_INSTALL_PREFIX=/soft/android/${_CUR_ABI} -DICU=0 -DLIB=0 -DQGLENGINE=0 -DQGLVIEW=0 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} -DCMAKE_TOOLCHAIN_FILE=${_ANDROID_TOOLCHAIN} -DQt5_DIR=/soft/android/qt/lib/cmake/Qt5 -DANDROID_PLATFORM=${NDK_PLATFORM} -DANDROID_ABI=${_CUR_ABI} ../libs/ \ RUN cmake -DCMAKE_INSTALL_PREFIX=/soft/android/${_CUR_ABI} -DICU=0 -DLIB=0 -DQGLENGINE=0 -DQGLVIEW=0 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} -DCMAKE_TOOLCHAIN_FILE=${_ANDROID_TOOLCHAIN} -DQt5_DIR=/soft/android/qt/lib/cmake/Qt5 -DANDROID_PLATFORM=${NDK_PLATFORM} -DANDROID_ABI=${_CUR_ABI} ../libs/ \
&& make install -j${JOBS_COUNT} && rm -rf * && make install -j${JOBS_COUNT} && rm -rf *
ENV _CUR_ABI=x86_64 ENV _CUR_ABI=x86_64
WORKDIR /soft/build_libs_android_${_CUR_ABI} WORKDIR /soft/libs_build_android_${_CUR_ABI}
RUN cmake -DCMAKE_INSTALL_PREFIX=/soft/android/${_CUR_ABI} -DICU=0 -DLIB=0 -DQGLENGINE=0 -DQGLVIEW=0 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} -DCMAKE_TOOLCHAIN_FILE=${_ANDROID_TOOLCHAIN} -DQt5_DIR=/soft/android/qt/lib/cmake/Qt5 -DANDROID_PLATFORM=${NDK_PLATFORM} -DANDROID_ABI=${_CUR_ABI} ../libs/ \ RUN cmake -DCMAKE_INSTALL_PREFIX=/soft/android/${_CUR_ABI} -DICU=0 -DLIB=0 -DQGLENGINE=0 -DQGLVIEW=0 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} -DCMAKE_TOOLCHAIN_FILE=${_ANDROID_TOOLCHAIN} -DQt5_DIR=/soft/android/qt/lib/cmake/Qt5 -DANDROID_PLATFORM=${NDK_PLATFORM} -DANDROID_ABI=${_CUR_ABI} ../libs/ \
&& make install -j${JOBS_COUNT} && rm -rf * && make install -j${JOBS_COUNT} && rm -rf *
WORKDIR /soft/src WORKDIR /soft/src
# examples
# docker build --no-cache -t libs .
# cd <your_project_dir>
# docker run --rm -it -v $(pwd):/soft/src libs bash

View File

@@ -0,0 +1,17 @@
ARG DOCKER_PREFIX=wapmobil/
FROM ${DOCKER_PREFIX}debian
ARG LIBS_BUILD_NUMBER=9999
ARG JOBS_COUNT=4
ENV PATH=/opt/cmake/bin:$PATH
WORKDIR /soft
RUN git clone -b release --single-branch --depth 1 --recursive https://git.shs.tools/SHS/libs.git
WORKDIR /soft/libs_build_debian
RUN cmake -DICU=0 -DLIB=1 -DQGLENGINE=1 -DQGLVIEW=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \
&& make install -j${JOBS_COUNT} \
&& rm -rf * \
&& ldconfig
WORKDIR /soft/src

View File

@@ -0,0 +1,21 @@
ARG DOCKER_PREFIX=wapmobil/
FROM ${DOCKER_PREFIX}osx
ARG LIBS_BUILD_NUMBER=9999
ARG JOBS_COUNT=4
ENV PATH=/soft/osxcross/target/bin:/opt/cmake/bin:$PATH
WORKDIR /soft
RUN git clone -b release --single-branch --depth 1 --recursive https://git.shs.tools/SHS/libs.git
WORKDIR /soft/libs_build_host
RUN cmake -DICU=0 -DCROSSTOOLS=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \
&& make install -j${JOBS_COUNT} \
&& rm -rf * \
&& ldconfig
WORKDIR /soft/libs_build_osx
RUN cmake -DCMAKE_INSTALL_PREFIX=/soft/osx -DICU=0 -DLIB=0 -DQGLENGINE=1 -DQGLVIEW=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} -DCMAKE_TOOLCHAIN_FILE=/soft/toolchain-Darwin.cmake ../libs/ \
&& make install -j${JOBS_COUNT} && rm -rf *
WORKDIR /soft/src

21
docker/pi-libs/Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
ARG DOCKER_PREFIX=wapmobil/
FROM ${DOCKER_PREFIX}pi
ARG LIBS_BUILD_NUMBER=9999
ARG JOBS_COUNT=4
ENV PATH=/opt/cmake/bin:$PATH
WORKDIR /soft
RUN git clone -b release --single-branch --depth 1 --recursive https://git.shs.tools/SHS/libs.git
WORKDIR /soft/libs_build_host
RUN cmake -DICU=0 -DCROSSTOOLS=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \
&& make install -j${JOBS_COUNT} \
&& rm -rf * \
&& ldconfig
WORKDIR /soft/libs_build_pi
RUN cmake -DCMAKE_INSTALL_PREFIX=/soft/pi/usr -DICU=0 -DLIB=0 -DQGLENGINE=0 -DQGLVIEW=0 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} -DCMAKE_TOOLCHAIN_FILE=/soft/toolchain-RPi.cmake ../libs/ \
&& make install -j${JOBS_COUNT} && rm -rf *
WORKDIR /soft/src

View File

@@ -0,0 +1,21 @@
ARG DOCKER_PREFIX=wapmobil/
FROM ${DOCKER_PREFIX}windows
ARG LIBS_BUILD_NUMBER=9999
ARG JOBS_COUNT=4
ENV PATH=/opt/cmake/bin:$PATH
WORKDIR /soft
RUN git clone -b release --single-branch --depth 1 --recursive https://git.shs.tools/SHS/libs.git
WORKDIR /soft/libs_build_host
RUN cmake -DICU=0 -DCROSSTOOLS=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \
&& make install -j${JOBS_COUNT} \
&& rm -rf * \
&& ldconfig
WORKDIR /soft/libs_build_windows
RUN cmake -DCMAKE_INSTALL_PREFIX=/soft/windows -DICU=0 -DLIB=0 -DQGLENGINE=1 -DQGLVIEW=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} -DCMAKE_TOOLCHAIN_FILE=/soft/toolchain-Windows.cmake ../libs/ \
&& make install -j${JOBS_COUNT} && rm -rf *
WORKDIR /soft/src

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();
} }

View File

@@ -4,19 +4,19 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Protocol, input/output channel (COM, UDP) Protocol, input/output channel (COM, UDP)
Copyright (C) 2020 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 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 General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU 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/>.
*/ */

0
make_libs.sh Executable file → Normal file
View File

2
pip

Submodule pip updated: f4cbd499a8...a4b3edb3e1

View File

@@ -1,49 +1,21 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(piqt) cmake_policy(SET CMP0017 NEW) # need include() with .cmake
if(NOT LIBPROJECT)
find_package(PIP REQUIRED) macro(piqt_library NAME _MODULES _LIBS)
option(LIB "System install" 0) _qt_project(${NAME} FALSE "PIQt" "${_MODULES}" "pip;${_LIBS}" ${ARGN})
option(DEBUG "Build with -g3" 0) _qt_install(${NAME} FALSE "pip" "out_HDR" "out_QM")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall") endmacro()
if(DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3") macro(piqt_application NAME _MODULES _LIBS)
endif() _qt_project(${NAME} TRUE "PIQt" "${_MODULES}" "pip;${_LIBS}" ${ARGN})
endif() _qt_install(${NAME} TRUE "pip" "" "out_QM")
find_package(QAD REQUIRED) endmacro()
list(APPEND QT_MULTILIB_LIST ${PROJECT_NAME})
set(QT_MULTILIB_LIST ${QT_MULTILIB_LIST} PARENT_SCOPE)
include_directories(${PIP_INCLUDES} ${QAD_INCLUDES}) include_directories(${PIP_INCLUDES})
file(GLOB SRC "*.h" "*.cpp" "*.ui" "*.qrc" "lang/*.ts") add_subdirectory(libs)
find_qt(${QtVersions} Core Gui Positioning) if (UTILS)
qt_wrap(${SRC} HDRS out_HDR CPPS out_CPP QMS out_QM) add_subdirectory(utils)
qt_add_library(${PROJECT_NAME} SHARED out_CPP) endif()
qt_target_link_libraries(${PROJECT_NAME} pip qad_utils qad_widgets)
message(STATUS "Building ${PROJECT_NAME}") copy_to_parent(piqt_includes)
if(LIBPROJECT)
sdk_install("pip" "${PROJECT_NAME}" "${out_HDR}" "${out_QM}")
else()
if(LIB)
if(WIN32)
install(FILES ${out_HDR} DESTINATION ${MINGW_INCLUDE}/pip)
if(NOT "x${out_QM}" STREQUAL "x")
qt_install(FILES ${out_QM} DESTINATION QtLang)
endif()
qt_install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${MINGW_LIB})
qt_install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${MINGW_BIN})
qt_install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION QtBin)
else()
install(FILES ${out_HDR} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pip)
qt_install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif()
message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
else()
if(WIN32)
qt_install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
qt_install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib)
else()
qt_install(TARGETS ${PROJECT_NAME} DESTINATION lib)
endif()
install(FILES ${out_HDR} DESTINATION include/pip)
message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"")
endif()
endif()

165
piqt/LICENSE.txt Normal file
View File

@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

1
piqt/libs/CMakeLists.txt Normal file
View File

@@ -0,0 +1 @@
add_directories_with_include("piqt_")

View File

@@ -0,0 +1 @@
piqt_library(piqt "Gui;Positioning" "qad_utils;qad_widgets")

View File

@@ -106,7 +106,7 @@ const QAD::IODevice PI2QADIODevice(const PIVariantTypes::IODevice & v) {
const QAD::File PI2QADFile(const PIVariantTypes::File & v) { const QAD::File PI2QADFile(const PIVariantTypes::File & v) {
return QAD::File(PI2QString(v.file), PI2QString(v.filter), v.is_abs); return QAD::File(PI2QString(v.file), PI2QString(v.filter), v.is_abs, v.is_save);
} }
@@ -116,7 +116,7 @@ const QAD::Dir PI2QADDir(const PIVariantTypes::Dir & v) {
const PIVariantTypes::File QAD2PIFile(const QAD::File & v) { const PIVariantTypes::File QAD2PIFile(const QAD::File & v) {
return PIVariantTypes::File(Q2PIString(v.file), Q2PIString(v.filter), v.is_abs); return PIVariantTypes::File(Q2PIString(v.file), Q2PIString(v.filter), v.is_abs, v.is_save);
} }

View File

@@ -1,3 +1,22 @@
/*
PIQt - PIP <-> Qt convertions
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
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/>.
*/
#ifndef PIQT_H #ifndef PIQT_H
#define PIQT_H #define PIQT_H
@@ -10,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());}
@@ -105,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

@@ -0,0 +1,52 @@
/*
PIQt Utils - Qt utilites for PIP
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
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/>.
*/
#ifndef QPICONNECTION_H
#define QPICONNECTION_H
#include <QObject>
#include <QMetaObject>
#include "piconnection.h"
#include "qpiconfig.h"
#include "piqt.h"
#include "piqt_export.h"
class PIQT_EXPORT QPIConnection: public QObject, public PIConnection {
Q_OBJECT
PIOBJECT_SUBCLASS(QPIConnection, PIConnection)
public:
QPIConnection(const QString & name = QString());
bool loadFromCMFile(const QString & file);
protected:
void propertyChanged(const PIString & ) {setObjectName(PI2QString(name()));}
EVENT_HANDLER2(void, piDataRec, const PIString &, from, const PIByteArray &, data);
EVENT_HANDLER2(void, piPacketRec, const PIString &, from, const PIByteArray &, data);
public slots:
signals:
void qDataReceivedEvent(QString from, QByteArray data);
void qPacketReceivedEvent(QString from, QByteArray data);
};
#endif // QPICONNECTION_H

View File

@@ -0,0 +1 @@
piqt_library(qcd_utils "Gui" "pip;qad_utils;qad_widgets;qad_graphic;cd_utils;piqt")

View File

@@ -1,297 +1,297 @@
#include "qcd_core.h" #include "qcd_core.h"
#include "cdutils_k.h" #include "cdutils_k.h"
#include "cdutils_core.h" #include "cdutils_core.h"
#include "piqt.h" #include "piqt.h"
#include <QWidget> #include <QWidget>
#include <QCheckBox> #include <QCheckBox>
#include <QGroupBox> #include <QGroupBox>
#include <QSpinBox> #include <QSpinBox>
#include <QSlider> #include <QSlider>
#include <QScrollBar> #include <QScrollBar>
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#include <QLineEdit> #include <QLineEdit>
#include <spinslider.h> #include <spinslider.h>
#include <clineedit.h> #include <clineedit.h>
#include <evalspinbox.h> #include <evalspinbox.h>
#include <qvariantedit.h> #include <qvariantedit.h>
#include <qcd_view.h> #include <qcd_view.h>
using namespace CDUtils; using namespace CDUtils;
int __QCore_Initializer__::count_(0); int __QCore_Initializer__::count_(0);
QCDCore * __QCore_Initializer__::__instance__(0); QCDCore * __QCore_Initializer__::__instance__(0);
__QCore_Initializer__::__QCore_Initializer__() { __QCore_Initializer__::__QCore_Initializer__() {
count_++; count_++;
if (count_ > 1) return; if (count_ > 1) return;
__instance__ = new QCDCore(); __instance__ = new QCDCore();
} }
__QCore_Initializer__::~__QCore_Initializer__() { __QCore_Initializer__::~__QCore_Initializer__() {
count_--; count_--;
if (count_ > 0) return; if (count_ > 0) return;
if (__instance__ != 0) { if (__instance__ != 0) {
delete __instance__; delete __instance__;
__instance__ = 0; __instance__ = 0;
} }
} }
QCDCore::QCDCore() { QCDCore::QCDCore() {
setObjectName("QCDCore"); setObjectName("QCDCore");
setName("QCDCore"); setName("QCDCore");
CONNECTU(&K, changedGlobal, this, K_ChangedGlobal); CONNECTU(&K, changedGlobal, this, K_ChangedGlobal);
updating = direct_on = false; updating = direct_on = false;
} }
QCDCore::~QCDCore() { QCDCore::~QCDCore() {
} }
void QCDCore::K_ChangedGlobal() { void QCDCore::K_ChangedGlobal() {
QMetaObject::invokeMethod(this, "updateBindedWidgets", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "updateBindedWidgets", Qt::QueuedConnection);
} }
void QCDCore::slotBool(bool v) { void QCDCore::slotBool(bool v) {
QWidget * w = (QWidget*)sender(); QWidget * w = (QWidget*)sender();
if (!w || updating) return; if (!w || updating) return;
QList<PIDeque<int> > pathes = binded_widgets.values(w); QList<PIDeque<int> > pathes = binded_widgets.values(w);
foreach (const PIDeque<int> & path, pathes) foreach (const PIDeque<int> & path, pathes)
K[path].setValue(PIString::fromBool(v)); K[path].setValue(PIString::fromBool(v));
K.calculate(); K.calculate();
emit updateViewRequest(); emit updateViewRequest();
} }
void QCDCore::slotInt(int v) { void QCDCore::slotInt(int v) {
QWidget * w = (QWidget*)sender(); QWidget * w = (QWidget*)sender();
if (!w || updating) return; if (!w || updating) return;
QList<PIDeque<int> > pathes = binded_widgets.values(w); QList<PIDeque<int> > pathes = binded_widgets.values(w);
foreach (const PIDeque<int> & path, pathes) foreach (const PIDeque<int> & path, pathes)
K[path].setValue(PIString::fromNumber(v)); K[path].setValue(PIString::fromNumber(v));
finishEdit(pathes); finishEdit(pathes);
} }
void QCDCore::slotDouble(double v) { void QCDCore::slotDouble(double v) {
QWidget * w = (QWidget*)sender(); QWidget * w = (QWidget*)sender();
if (!w || updating) return; if (!w || updating) return;
QList<PIDeque<int> > pathes = binded_widgets.values(w); QList<PIDeque<int> > pathes = binded_widgets.values(w);
foreach (const PIDeque<int> & path, pathes) foreach (const PIDeque<int> & path, pathes)
K[path].setValue(PIString::fromNumber(v)); K[path].setValue(PIString::fromNumber(v));
finishEdit(pathes); finishEdit(pathes);
} }
void QCDCore::slotText(QString v) { void QCDCore::slotText(QString v) {
QWidget * w = (QWidget*)sender(); QWidget * w = (QWidget*)sender();
if (!w || updating) return; if (!w || updating) return;
QList<PIDeque<int> > pathes = binded_widgets.values(w); QList<PIDeque<int> > pathes = binded_widgets.values(w);
foreach (const PIDeque<int> & path, pathes) foreach (const PIDeque<int> & path, pathes)
K[path].setValue(Q2PIString(v)); K[path].setValue(Q2PIString(v));
finishEdit(pathes); finishEdit(pathes);
} }
void QCDCore::slotVariant(QVariant v) { void QCDCore::slotVariant(QVariant v) {
QWidget * w = (QWidget*)sender(); QWidget * w = (QWidget*)sender();
if (!w || updating) return; if (!w || updating) return;
QList<PIDeque<int> > pathes = binded_widgets.values(w); QList<PIDeque<int> > pathes = binded_widgets.values(w);
foreach (const PIDeque<int> & path, pathes) foreach (const PIDeque<int> & path, pathes)
K[path].setVariantValue(Q2PIVariant(v)); K[path].setVariantValue(Q2PIVariant(v));
finishEdit(pathes); finishEdit(pathes);
} }
void QCDCore::slotDestroyed(QObject * o) { void QCDCore::slotDestroyed(QObject * o) {
if (!o) return; if (!o) return;
if (!binded_widgets.contains((QWidget*)o)) return; if (!binded_widgets.contains((QWidget*)o)) return;
binded_widgets.remove((QWidget*)o); binded_widgets.remove((QWidget*)o);
} }
int QCDCore::bindWindow(QWidget * wnd) { int QCDCore::bindWindow(QWidget * wnd) {
if (!wnd) return 0; if (!wnd) return 0;
//K.root().makePath(); //K.root().makePath();
return bindWidgets(wnd->findChildren<QWidget * >()); return bindWidgets(wnd->findChildren<QWidget * >());
} }
int QCDCore::bindWidgets(QList<QWidget * > wl) { int QCDCore::bindWidgets(QList<QWidget * > wl) {
int ret = 0; int ret = 0;
foreach (QWidget * w, wl) foreach (QWidget * w, wl)
if (bindWidget(w)) ++ret; if (bindWidget(w)) ++ret;
return ret; return ret;
} }
bool QCDCore::bindWidget(QWidget * w) { bool QCDCore::bindWidget(QWidget * w) {
if (!w) return false; if (!w) return false;
QString on = w->objectName(); QString on = w->objectName();
QString cn = w->metaObject()->className(); QString cn = w->metaObject()->className();
if (cn == "CDView") { if (cn == "CDView") {
bindView(w); bindView(w);
return false; return false;
} }
PIVector<CDType * > ak = K.root().children(); PIVector<CDType * > ak = K.root().children();
piForeachC (CDType * k, ak) { piForeachC (CDType * k, ak) {
if (!on.endsWith(PI2QString(k->pathString().join("_")))) continue; if (!on.endsWith(PI2QString(k->pathString().join("_")))) continue;
if (bindWidget(w, *k)) return true; if (bindWidget(w, *k)) return true;
} }
return false; return false;
} }
bool QCDCore::bindWidget(QWidget * w, const CDType & k) { bool QCDCore::bindWidget(QWidget * w, const CDType & k) {
if (!w) return false; if (!w) return false;
//piCout << "bind..." << k.name() << k.path(); //piCout << "bind..." << k.name() << k.path();
QString cn = w->metaObject()->className(); QString cn = w->metaObject()->className();
bool ok = false; bool ok = false;
if (cn == "QCheckBox" || cn == "QGroupBox") { if (cn == "QCheckBox" || cn == "QGroupBox") {
connect(w, SIGNAL(toggled(bool)), this, SLOT(slotBool(bool)), Qt::UniqueConnection); connect(w, SIGNAL(toggled(bool)), this, SLOT(slotBool(bool)), Qt::UniqueConnection);
ok = true; ok = true;
} }
if (cn == "QSpinBox" || cn == "QSlider" || cn == "QScrollBar") { if (cn == "QSpinBox" || cn == "QSlider" || cn == "QScrollBar") {
connect(w, SIGNAL(valueChanged(int)), this, SLOT(slotInt(int)), Qt::UniqueConnection); connect(w, SIGNAL(valueChanged(int)), this, SLOT(slotInt(int)), Qt::UniqueConnection);
ok = true; ok = true;
} }
if (cn == "QDoubleSpinBox" || cn == "SpinSlider" || cn == "EvalSpinBox") { if (cn == "QDoubleSpinBox" || cn == "SpinSlider" || cn == "EvalSpinBox") {
connect(w, SIGNAL(valueChanged(double)), this, SLOT(slotDouble(double)), Qt::UniqueConnection); connect(w, SIGNAL(valueChanged(double)), this, SLOT(slotDouble(double)), Qt::UniqueConnection);
ok = true; ok = true;
} }
if (cn == "QLineEdit" || cn == "CLineEdit") { if (cn == "QLineEdit" || cn == "CLineEdit") {
connect(w, SIGNAL(textChanged(QString)), this, SLOT(slotText(QString)), Qt::UniqueConnection); connect(w, SIGNAL(textChanged(QString)), this, SLOT(slotText(QString)), Qt::UniqueConnection);
ok = true; ok = true;
} }
if (cn == "QVariantEdit") { if (cn == "QVariantEdit") {
connect(w, SIGNAL(valueChanged(QVariant)), this, SLOT(slotVariant(QVariant)), Qt::UniqueConnection); connect(w, SIGNAL(valueChanged(QVariant)), this, SLOT(slotVariant(QVariant)), Qt::UniqueConnection);
ok = true; ok = true;
} }
if (cn == "CDView") { if (cn == "CDView") {
bindView(w); bindView(w);
} }
connect(w, SIGNAL(destroyed(QObject*)), this, SLOT(slotDestroyed(QObject*)), Qt::UniqueConnection); connect(w, SIGNAL(destroyed(QObject*)), this, SLOT(slotDestroyed(QObject*)), Qt::UniqueConnection);
setWidgetValue(w, k); setWidgetValue(w, k);
if (!ok) return false; if (!ok) return false;
//piCout << k.name() << k.path() << "ok"; //piCout << k.name() << k.path() << "ok";
binded_widgets.insert(w, k.path()); binded_widgets.insert(w, k.path());
return true; return true;
} }
void QCDCore::updateBindedWidgets() { void QCDCore::updateBindedWidgets() {
QMapIterator<QWidget * , PIDeque<int> > it(binded_widgets); QMapIterator<QWidget * , PIDeque<int> > it(binded_widgets);
QWidgetList to_remove; QWidgetList to_remove;
updating = true; updating = true;
while (it.hasNext()) { while (it.hasNext()) {
QWidget * w = it.next().key(); QWidget * w = it.next().key();
if (!K.exists(it.value())) if (!K.exists(it.value()))
to_remove << w; to_remove << w;
else else
setWidgetValue(w, K[it.value()]); setWidgetValue(w, K[it.value()]);
} }
foreach (QWidget * w, to_remove) foreach (QWidget * w, to_remove)
unbindWidget(w); unbindWidget(w);
updating = false; updating = false;
} }
void QCDCore::bindView(QWidget * v) { void QCDCore::bindView(QWidget * v) {
CDView * w = qobject_cast<CDView * >(v); CDView * w = qobject_cast<CDView * >(v);
if (!w) return; if (!w) return;
connect(this, SIGNAL(updateViewRequest()), w, SLOT(refreshValues()), Qt::UniqueConnection); connect(this, SIGNAL(updateViewRequest()), w, SLOT(refreshValues()), Qt::UniqueConnection);
} }
void QCDCore::setWidgetValue(QWidget * w, const CDType & k) { void QCDCore::setWidgetValue(QWidget * w, const CDType & k) {
if (!w) return; if (!w) return;
QString cn = w->metaObject()->className(); QString cn = w->metaObject()->className();
if (cn == "QCheckBox") qobject_cast<QCheckBox*>(w)->setChecked(k.toBool()); if (cn == "QCheckBox") qobject_cast<QCheckBox*>(w)->setChecked(k.toBool());
if (cn == "QGroupBox") qobject_cast<QGroupBox*>(w)->setChecked(k.toBool()); if (cn == "QGroupBox") qobject_cast<QGroupBox*>(w)->setChecked(k.toBool());
if (cn == "QSpinBox") qobject_cast<QSpinBox*>(w)->setValue(k.toInt()); if (cn == "QSpinBox") qobject_cast<QSpinBox*>(w)->setValue(k.toInt());
if (cn == "QSlider") qobject_cast<QSlider*>(w)->setValue(k.toInt()); if (cn == "QSlider") qobject_cast<QSlider*>(w)->setValue(k.toInt());
if (cn == "QScrollBar") qobject_cast<QScrollBar*>(w)->setValue(k.toInt()); if (cn == "QScrollBar") qobject_cast<QScrollBar*>(w)->setValue(k.toInt());
if (cn == "QDoubleSpinBox") qobject_cast<QDoubleSpinBox*>(w)->setValue(k.toDouble()); if (cn == "QDoubleSpinBox") qobject_cast<QDoubleSpinBox*>(w)->setValue(k.toDouble());
if (cn == "SpinSlider") qobject_cast<SpinSlider*>(w)->setValue(k.toDouble()); if (cn == "SpinSlider") qobject_cast<SpinSlider*>(w)->setValue(k.toDouble());
if (cn == "QLineEdit") qobject_cast<QLineEdit*>(w)->setText(PI2QString(k.value())); if (cn == "QLineEdit") qobject_cast<QLineEdit*>(w)->setText(PI2QString(k.value()));
if (cn == "CLineEdit") qobject_cast<CLineEdit*>(w)->setText(PI2QString(k.value())); if (cn == "CLineEdit") qobject_cast<CLineEdit*>(w)->setText(PI2QString(k.value()));
if (cn == "EvalSpinBox") qobject_cast<EvalSpinBox*>(w)->setValue(k.toDouble()); if (cn == "EvalSpinBox") qobject_cast<EvalSpinBox*>(w)->setValue(k.toDouble());
if (cn == "QVariantEdit") qobject_cast<QVariantEdit*>(w)->setValue(PI2QVariant(k.variantValue())); if (cn == "QVariantEdit") qobject_cast<QVariantEdit*>(w)->setValue(PI2QVariant(k.variantValue()));
} }
void QCDCore::finishEdit(const QList<PIDeque<int> > & pathes) { void QCDCore::finishEdit(const QList<PIDeque<int> > & pathes) {
K.calculate(); K.calculate();
if (direct_on) { if (direct_on) {
foreach (const PIDeque<int> & path, pathes) foreach (const PIDeque<int> & path, pathes)
K.directChange(K[path]); K.directChange(K[path]);
} }
emit updateViewRequest(); emit updateViewRequest();
} }
int QCDCore::unbindWindow(QWidget * wnd) { int QCDCore::unbindWindow(QWidget * wnd) {
if (!wnd) return 0; if (!wnd) return 0;
return unbindWidgets(wnd->findChildren<QWidget * >()); return unbindWidgets(wnd->findChildren<QWidget * >());
} }
int QCDCore::unbindWidgets(QList<QWidget * > wl) { int QCDCore::unbindWidgets(QList<QWidget * > wl) {
int ret = 0; int ret = 0;
foreach (QWidget * w, wl) foreach (QWidget * w, wl)
if (unbindWidget(w)) ++ret; if (unbindWidget(w)) ++ret;
return ret; return ret;
} }
bool QCDCore::unbindWidget(QWidget * w) { bool QCDCore::unbindWidget(QWidget * w) {
if (!w) return false; if (!w) return false;
//qDebug() << "unbind" << w; //qDebug() << "unbind" << w;
if (!binded_widgets.contains(w)) return false; if (!binded_widgets.contains(w)) return false;
QString cn = w->metaObject()->className(); QString cn = w->metaObject()->className();
if (cn == "QCheckBox" || cn == "QGroupBox") if (cn == "QCheckBox" || cn == "QGroupBox")
disconnect(w, SIGNAL(toggled(bool)), this, SLOT(slotBool(bool))); disconnect(w, SIGNAL(toggled(bool)), this, SLOT(slotBool(bool)));
if (cn == "QSpinBox" || cn == "QSlider" || cn == "QScrollBar") if (cn == "QSpinBox" || cn == "QSlider" || cn == "QScrollBar")
disconnect(w, SIGNAL(valueChanged(int)), this, SLOT(slotInt(int))); disconnect(w, SIGNAL(valueChanged(int)), this, SLOT(slotInt(int)));
if (cn == "QDoubleSpinBox" || cn == "SpinSlider" || cn == "EvalSpinBox") if (cn == "QDoubleSpinBox" || cn == "SpinSlider" || cn == "EvalSpinBox")
disconnect(w, SIGNAL(valueChanged(double)), this, SLOT(slotDouble(double))); disconnect(w, SIGNAL(valueChanged(double)), this, SLOT(slotDouble(double)));
if (cn == "QLineEdit" || cn == "CLineEdit") if (cn == "QLineEdit" || cn == "CLineEdit")
disconnect(w, SIGNAL(textChanged(QString)), this, SLOT(slotText(QString))); disconnect(w, SIGNAL(textChanged(QString)), this, SLOT(slotText(QString)));
if (cn == "QVariantEdit") if (cn == "QVariantEdit")
disconnect(w, SIGNAL(valueChanged(QVariant)), this, SLOT(slotVariant(QVariant))); disconnect(w, SIGNAL(valueChanged(QVariant)), this, SLOT(slotVariant(QVariant)));
//qDebug() << "remove b" << binded_widgets.size(); //qDebug() << "remove b" << binded_widgets.size();
binded_widgets.remove(w); binded_widgets.remove(w);
//qDebug() << "remove a" << binded_widgets.size(); //qDebug() << "remove a" << binded_widgets.size();
return true; return true;
} }
void QCDCore::unbindAllWidgets() { void QCDCore::unbindAllWidgets() {
QMap<QWidget * , PIDeque<int> > bwm = binded_widgets; QMap<QWidget * , PIDeque<int> > bwm = binded_widgets;
QMapIterator<QWidget * , PIDeque<int> > it(bwm); QMapIterator<QWidget * , PIDeque<int> > it(bwm);
while (it.hasNext()) { while (it.hasNext()) {
QWidget * w = it.next().key(); QWidget * w = it.next().key();
unbindWidget(w); unbindWidget(w);
} }
binded_widgets.clear(); binded_widgets.clear();
} }
void QCDCore::updateBindedWidget(const CDType & k_) { void QCDCore::updateBindedWidget(const CDType & k_) {
QMapIterator<QWidget * , PIDeque<int> > it(binded_widgets); QMapIterator<QWidget * , PIDeque<int> > it(binded_widgets);
updating = true; updating = true;
while (it.hasNext()) { while (it.hasNext()) {
QWidget * w = it.next().key(); QWidget * w = it.next().key();
const CDType & k(K[it.value()]); const CDType & k(K[it.value()]);
if (k.path() != k_.path()) continue; if (k.path() != k_.path()) continue;
setWidgetValue(w, k); setWidgetValue(w, k);
} }
updating = false; updating = false;
} }

View File

@@ -1,77 +1,97 @@
#ifndef QCD_CORE_H /*
#define QCD_CORE_H QCD Utils - Qt bindings/utilites for CD Utils
#include <QObject> Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
#include <QMultiMap>
#include <QVariant> This program is free software: you can redistribute it and/or modify
#include "piobject.h" it under the terms of the GNU Lesser General Public License as published by
#include "cdutils_types.h" the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
class QCDCore; This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
class __QCore_Initializer__ { GNU Lesser General Public License for more details.
public:
__QCore_Initializer__(); You should have received a copy of the GNU Lesser General Public License
~__QCore_Initializer__(); along with this program. If not, see <http://www.gnu.org/licenses/>.
static int count_; */
static QCDCore * __instance__;
}; #ifndef QCD_CORE_H
#define QCD_CORE_H
class QCDCore: public QObject, public PIObject #include <QObject>
{ #include <QMultiMap>
Q_OBJECT #include <QVariant>
PIOBJECT(QCDCore) #include "piobject.h"
friend class __QCore_Initializer__; #include "cdutils_types.h"
public: #include "qcd_utils_export.h"
static QCDCore * instance() {return __QCore_Initializer__::__instance__;}
int bindWindow(QWidget * wnd); class QCDCore;
int bindWidgets(QList<QWidget * > wl);
bool bindWidget(QWidget * w);
bool bindWidget(QWidget * w, const CDUtils::CDType & k); class QCD_UTILS_EXPORT __QCore_Initializer__ {
public:
int unbindWindow(QWidget * wnd); __QCore_Initializer__();
int unbindWidgets(QList<QWidget * > wl); ~__QCore_Initializer__();
bool unbindWidget(QWidget * w); static int count_;
void unbindAllWidgets(); static QCDCore * __instance__;
};
void updateBindedWidget(const CDUtils::CDType & k_);
void setDirectKEnabled(bool yes) {direct_on = yes;}
bool isDirectKEnabled() const {return direct_on;} class QCD_UTILS_EXPORT QCDCore: public QObject, public PIObject
{
private: Q_OBJECT
QCDCore(); PIOBJECT(QCDCore)
~QCDCore(); friend class __QCore_Initializer__;
public:
void bindView(QWidget * v); static QCDCore * instance() {return __QCore_Initializer__::__instance__;}
void setWidgetValue(QWidget * w, const CDUtils::CDType & k);
void finishEdit(const QList<PIDeque<int> > & pathes); int bindWindow(QWidget * wnd);
EVENT_HANDLER(void, K_ChangedGlobal); int bindWidgets(QList<QWidget * > wl);
bool bindWidget(QWidget * w);
QMultiMap<QWidget * , PIDeque<int> > binded_widgets; bool bindWidget(QWidget * w, const CDUtils::CDType & k);
bool updating, direct_on;
int unbindWindow(QWidget * wnd);
private slots: int unbindWidgets(QList<QWidget * > wl);
void slotBool(bool v); bool unbindWidget(QWidget * w);
void slotInt(int v); void unbindAllWidgets();
void slotDouble(double v);
void slotText(QString v); void updateBindedWidget(const CDUtils::CDType & k_);
void slotVariant(QVariant v); void setDirectKEnabled(bool yes) {direct_on = yes;}
void slotDestroyed(QObject * ); bool isDirectKEnabled() const {return direct_on;}
public slots: private:
void updateBindedWidgets(); QCDCore();
~QCDCore();
signals:
void updateViewRequest(); void bindView(QWidget * v);
void setWidgetValue(QWidget * w, const CDUtils::CDType & k);
}; void finishEdit(const QList<PIDeque<int> > & pathes);
EVENT_HANDLER(void, K_ChangedGlobal);
static __QCore_Initializer__ __QCore_initializer__; QMultiMap<QWidget * , PIDeque<int> > binded_widgets;
bool updating, direct_on;
#endif // QCD_CORE_H private slots:
void slotBool(bool v);
void slotInt(int v);
void slotDouble(double v);
void slotText(QString v);
void slotVariant(QVariant v);
void slotDestroyed(QObject * );
public slots:
void updateBindedWidgets();
signals:
void updateViewRequest();
};
static __QCore_Initializer__ __QCore_initializer__;
#endif // QCD_CORE_H

View File

@@ -1,40 +1,40 @@
#include "qcd_graphic.h" #include "qcd_graphic.h"
#include "ui_qcd_graphic.h" #include "ui_qcd_graphic.h"
#include "cdutils_core.h" #include "cdutils_core.h"
#include "cdutils_x.h" #include "cdutils_x.h"
#include "graphic.h" #include "graphic.h"
#include "piqt.h" #include "piqt.h"
using namespace CDUtils; using namespace CDUtils;
CDGraphicWidget::CDGraphicWidget(QWidget * p): QWidget(p) { CDGraphicWidget::CDGraphicWidget(QWidget * p): QWidget(p) {
ui = new Ui::CDGraphicWidget(); ui = new Ui::CDGraphicWidget();
ui->setupUi(this); ui->setupUi(this);
ui->graphic->setGraphicsCount(0); ui->graphic->setGraphicsCount(0);
} }
Graphic * CDGraphicWidget::graphic() const { Graphic * CDGraphicWidget::graphic() const {
return ui->graphic; return ui->graphic;
} }
void CDGraphicWidget::setConfigVisible(bool on) { void CDGraphicWidget::setConfigVisible(bool on) {
ui->widgetConfig->setVisible(on); ui->widgetConfig->setVisible(on);
} }
bool CDGraphicWidget::isConfigVisible() const { bool CDGraphicWidget::isConfigVisible() const {
return ui->widgetConfig->isVisible(); return ui->widgetConfig->isVisible();
} }
EvalSpinBox * CDGraphicWidget::evalSpinBoxHistory() { EvalSpinBox * CDGraphicWidget::evalSpinBoxHistory() {
return ui->evalHistory; return ui->evalHistory;
} }
EvalSpinBox * CDGraphicWidget::evalSpinBoxVisible() { EvalSpinBox * CDGraphicWidget::evalSpinBoxVisible() {
return ui->evalVisible; return ui->evalVisible;
} }

View File

@@ -0,0 +1,67 @@
/*
QCD Utils - Qt bindings/utilites for CD Utils
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
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/>.
*/
#ifndef QCD_GRAPHIC_H
#define QCD_GRAPHIC_H
#include <QWidget>
#include <evalspinbox.h>
#include <pistring.h>
#include "qcd_utils_export.h"
namespace CDUtils {
class CDType;
class CDSection;
}
namespace Ui {
class CDGraphicWidget;
}
class Graphic;
class Graphic;
class QCD_UTILS_EXPORT CDGraphicWidget: public QWidget {
Q_OBJECT
friend class CDGraphics;
friend class GDockWidget;
public:
CDGraphicWidget(QWidget * p = 0);
Graphic * graphic() const;
bool isConfigVisible() const;
EvalSpinBox * evalSpinBoxHistory();
EvalSpinBox * evalSpinBoxVisible();
public slots:
void setConfigVisible(bool on);
private:
Ui::CDGraphicWidget * ui;
private slots:
signals:
};
#endif // QCD_GRAPHIC_H

View File

@@ -1,169 +1,169 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>CDGraphicWidget</class> <class>CDGraphicWidget</class>
<widget class="QWidget" name="CDGraphicWidget"> <widget class="QWidget" name="CDGraphicWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>470</width> <width>470</width>
<height>380</height> <height>380</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>CD Pult</string> <string>CD Pult</string>
</property> </property>
<layout class="QVBoxLayout" name="layoutMain"> <layout class="QVBoxLayout" name="layoutMain">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<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>
</property> </property>
<property name="statusVisible"> <property name="statusVisible">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="historySize"> <property name="historySize">
<double>100.000000000000000</double> <double>100.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QWidget" name="widgetConfig" native="true"> <widget class="QWidget" name="widgetConfig" native="true">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>History:</string> <string>History:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="EvalSpinBox" name="evalHistory"> <widget class="EvalSpinBox" name="evalHistory">
<property name="value"> <property name="value">
<double>100.000000000000000</double> <double>100.000000000000000</double>
</property> </property>
</widget> </widget>
</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="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>1</width> <width>1</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Visible:</string> <string>Visible:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="EvalSpinBox" name="evalVisible"> <widget class="EvalSpinBox" name="evalVisible">
<property name="value"> <property name="value">
<double>-1.000000000000000</double> <double>-1.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>1</width> <width>1</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>Graphic</class> <class>Graphic</class>
<extends>QFrame</extends> <extends>QFrame</extends>
<header>graphic.h</header> <header>graphic.h</header>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>EvalSpinBox</class> <class>EvalSpinBox</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header>evalspinbox.h</header> <header>evalspinbox.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections> <connections>
<connection> <connection>
<sender>evalHistory</sender> <sender>evalHistory</sender>
<signal>valueChanged(double)</signal> <signal>valueChanged(double)</signal>
<receiver>graphic</receiver> <receiver>graphic</receiver>
<slot>setHistorySize(double)</slot> <slot>setHistorySize(double)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>148</x> <x>148</x>
<y>363</y> <y>363</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>156</x> <x>156</x>
<y>297</y> <y>297</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>evalVisible</sender> <sender>evalVisible</sender>
<signal>valueChanged(double)</signal> <signal>valueChanged(double)</signal>
<receiver>graphic</receiver> <receiver>graphic</receiver>
<slot>setMaxVisibleTime(double)</slot> <slot>setMaxVisibleTime(double)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>345</x> <x>345</x>
<y>361</y> <y>361</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>342</x> <x>342</x>
<y>337</y> <y>337</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
</connections> </connections>
</ui> </ui>

View File

@@ -1,46 +1,46 @@
#include "qcd_modedialog.h" #include "qcd_modedialog.h"
#include "ui_qcd_modedialog.h" #include "ui_qcd_modedialog.h"
QCDModeDialog::QCDModeDialog(QWidget * parent): QDialog(parent) { QCDModeDialog::QCDModeDialog(QWidget * parent): QDialog(parent) {
ui = new Ui::QCDModeDialog(); ui = new Ui::QCDModeDialog();
ui->setupUi(this); ui->setupUi(this);
} }
QCDModeDialog::~QCDModeDialog() { QCDModeDialog::~QCDModeDialog() {
delete ui; delete ui;
} }
CDUtils::UpdateModeFlags QCDModeDialog::mode() const { CDUtils::UpdateModeFlags QCDModeDialog::mode() const {
CDUtils::UpdateModeFlags ret = 0; CDUtils::UpdateModeFlags ret = 0;
if (ui->checkSaveIndex->isChecked()) ret |= CDUtils::SaveByIndex; if (ui->checkSaveIndex->isChecked()) ret |= CDUtils::SaveByIndex;
if (ui->checkSaveName->isChecked()) ret |= CDUtils::SaveByName; if (ui->checkSaveName->isChecked()) ret |= CDUtils::SaveByName;
if (ui->checkMerge->isChecked()) ret |= CDUtils::Merge; if (ui->checkMerge->isChecked()) ret |= CDUtils::Merge;
return ret; return ret;
} }
void QCDModeDialog::changeEvent(QEvent *e) { void QCDModeDialog::changeEvent(QEvent *e) {
QDialog::changeEvent(e); QDialog::changeEvent(e);
switch (e->type()) { switch (e->type()) {
case QEvent::LanguageChange: case QEvent::LanguageChange:
ui->retranslateUi(this); ui->retranslateUi(this);
break; break;
default: default:
break; break;
} }
} }
void QCDModeDialog::on_checkSaveIndex_clicked(bool checked) { void QCDModeDialog::on_checkSaveIndex_clicked(bool checked) {
if (!checked) return; if (!checked) return;
ui->checkSaveName->setChecked(false); ui->checkSaveName->setChecked(false);
} }
void QCDModeDialog::on_checkSaveName_clicked(bool checked) { void QCDModeDialog::on_checkSaveName_clicked(bool checked) {
if (!checked) return; if (!checked) return;
ui->checkSaveIndex->setChecked(false); ui->checkSaveIndex->setChecked(false);
} }

View File

@@ -0,0 +1,51 @@
/*
QCD Utils - Qt bindings/utilites for CD Utils
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
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/>.
*/
#ifndef QCD_MODEDIALOG_H
#define QCD_MODEDIALOG_H
#include <QDialog>
#include <cdutils_types.h>
#include "qcd_utils_export.h"
namespace Ui {
class QCDModeDialog;
}
class QCD_UTILS_EXPORT QCDModeDialog: public QDialog
{
Q_OBJECT
public:
explicit QCDModeDialog(QWidget * parent = 0);
~QCDModeDialog();
CDUtils::UpdateModeFlags mode() const;
protected:
void changeEvent(QEvent *e);
Ui::QCDModeDialog * ui;
private slots:
void on_checkSaveIndex_clicked(bool checked);
void on_checkSaveName_clicked(bool checked);
};
#endif // QCD_MODEDIALOG_H

View File

@@ -1,98 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>QCDModeDialog</class> <class>QCDModeDialog</class>
<widget class="QDialog" name="QCDModeDialog"> <widget class="QDialog" name="QCDModeDialog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>251</width> <width>251</width>
<height>152</height> <height>152</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Update description mode</string> <string>Update description mode</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QCheckBox" name="checkSaveIndex"> <widget class="QCheckBox" name="checkSaveIndex">
<property name="text"> <property name="text">
<string>Save by index</string> <string>Save by index</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkSaveName"> <widget class="QCheckBox" name="checkSaveName">
<property name="text"> <property name="text">
<string>Save by name</string> <string>Save by name</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkMerge"> <widget class="QCheckBox" name="checkMerge">
<property name="text"> <property name="text">
<string>Merge</string> <string>Merge</string>
</property> </property>
</widget> </widget>
</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>1</height> <height>1</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>
<resources/> <resources/>
<connections> <connections>
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>accepted()</signal> <signal>accepted()</signal>
<receiver>QCDModeDialog</receiver> <receiver>QCDModeDialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>106</x> <x>106</x>
<y>131</y> <y>131</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>101</x> <x>101</x>
<y>146</y> <y>146</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>rejected()</signal> <signal>rejected()</signal>
<receiver>QCDModeDialog</receiver> <receiver>QCDModeDialog</receiver>
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>182</x> <x>182</x>
<y>127</y> <y>127</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>169</x> <x>169</x>
<y>146</y> <y>146</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
</connections> </connections>
</ui> </ui>

View File

@@ -1,460 +1,460 @@
#include "qcd_model.h" #include "qcd_model.h"
#include "cdutils_interface.h" #include "cdutils_interface.h"
#include "cdutils_core.h" #include "cdutils_core.h"
#include "cdutils_x.h" #include "cdutils_x.h"
#include "piqt.h" #include "piqt.h"
#include <QDebug> #include <QDebug>
#include <QBrush> #include <QBrush>
#include <QColor> #include <QColor>
#include <QMimeData> #include <QMimeData>
#include "qvariantedit.h" #include "qvariantedit.h"
#include "qad_types.h" #include "qad_types.h"
using namespace CDUtils; using namespace CDUtils;
// CDKItem // CDKItem
CDItem::CDItem(CDUtils::Interface * i, int _index, CDItem::CDItemType type, CDItem *parent) { CDItem::CDItem(CDUtils::Interface * i, int _index, CDItem::CDItemType type, CDItem *parent) {
interface = i; interface = i;
index_ = _index; index_ = _index;
parent_ = parent; parent_ = parent;
type_ = type; type_ = type;
item_count = 0; item_count = 0;
expanded = true; expanded = true;
} }
CDItem::~CDItem() { CDItem::~CDItem() {
qDeleteAll(childs); qDeleteAll(childs);
} }
QVariant CDItem::data(int column, int role) const { QVariant CDItem::data(int column, int role) const {
if (role == Qt::BackgroundRole) { if (role == Qt::BackgroundRole) {
switch (type_) { switch (type_) {
case ItemCDType: { case ItemCDType: {
CDType & t(interface->section(buildPath())[index_]); CDType & t(interface->section(buildPath())[index_]);
if (t.errorString().isEmpty()) return QBrush(QColor(255, 250, 230)); if (t.errorString().isEmpty()) return QBrush(QColor(255, 250, 230));
else return QBrush(QColor(255, 128, 128)); else return QBrush(QColor(255, 128, 128));
} }
case ItemCDSection: return QBrush(QColor(230, 250, 230)); case ItemCDSection: return QBrush(QColor(230, 250, 230));
} }
} }
if (role == Qt::CheckStateRole && type_ == ItemCDType) { if (role == Qt::CheckStateRole && type_ == ItemCDType) {
CDType & t(interface->section(buildPath())[index_]); CDType & t(interface->section(buildPath())[index_]);
if (column == cValue && t.cd_type() == CDType::cdK) { if (column == cValue && t.cd_type() == CDType::cdK) {
if (t.type() == "b") return t.toBool() ? Qt::Checked : Qt::Unchecked; if (t.type() == "b") return t.toBool() ? Qt::Checked : Qt::Unchecked;
else QVariant(); else QVariant();
} }
if (column == cName_Cmd && t.cd_type() == CDType::cdX) { if (column == cName_Cmd && t.cd_type() == CDType::cdX) {
return t.isSelectedX() ? Qt::Checked : Qt::Unchecked; return t.isSelectedX() ? Qt::Checked : Qt::Unchecked;
} }
} }
if (role == Qt::ToolTipRole && type_ == ItemCDType) { if (role == Qt::ToolTipRole && type_ == ItemCDType) {
CDType & t(interface->section(buildPath())[index_]); CDType & t(interface->section(buildPath())[index_]);
return PI2QString(t.errorString()); return PI2QString(t.errorString());
} }
if (role != Qt::DisplayRole && role != Qt::EditRole) return QVariant(); if (role != Qt::DisplayRole && role != Qt::EditRole) return QVariant();
PIDeque<int> path = buildPath(); PIDeque<int> path = buildPath();
CDSection & rs = interface->section(path); CDSection & rs = interface->section(path);
CDSection s; CDSection s;
switch (type_) { switch (type_) {
case ItemCDType: case ItemCDType:
switch (column) { switch (column) {
case cID: return QString::number(index_); case cID: return QString::number(index_);
case cName_Cmd: return PI2QString(rs[index_].name()); case cName_Cmd: return PI2QString(rs[index_].name());
case cType: return stringType(rs[index_].type()); case cType: return stringType(rs[index_].type());
case cXMode: return QVariant::fromValue(xModeEnum(rs[index_].xmode())); case cXMode: return QVariant::fromValue(xModeEnum(rs[index_].xmode()));
case cXAvg: return rs[index_].avg(); case cXAvg: return rs[index_].avg();
case cExpression: return PI2QString(rs[index_].formula()); case cExpression: return PI2QString(rs[index_].formula());
case cValue: return value(rs[index_], role); case cValue: return value(rs[index_], role);
case cComment: return PI2QString(rs[index_].comment()); case cComment: return PI2QString(rs[index_].comment());
default: break; default: break;
} }
break; break;
case ItemCDSection: case ItemCDSection:
s = rs.section(index_); s = rs.section(index_);
// piCout << rs.name << rs.alias << s.name << s.alias; // piCout << rs.name << rs.alias << s.name << s.alias;
switch (column) { switch (column) {
case cID: return QString("[") + QString::number(index_) + QString("]"); case cID: return QString("[") + QString::number(index_) + QString("]");
case cName_Cmd: return PI2QString(s.alias); case cName_Cmd: return PI2QString(s.alias);
case cType: return PI2QString(s.name); case cType: return PI2QString(s.name);
default: break; default: break;
} }
break; break;
} }
return QVariant(); return QVariant();
} }
QVariant CDItem::value(CDType & t, int role) const { QVariant CDItem::value(CDType & t, int role) const {
if (t.type() == "f") return t.toDouble(); if (t.type() == "f") return t.toDouble();
if (t.type() == "n") return t.toInt(); if (t.type() == "n") return t.toInt();
if (t.type() == "b") return t.toBool(); if (t.type() == "b") return t.toBool();
if (t.type() == "e") { if (t.type() == "e") {
QAD::Enum et = PI2QADEnum(t.enumValues()); QAD::Enum et = PI2QADEnum(t.enumValues());
et.selectValue(t.toInt()); et.selectValue(t.toInt());
if (role == Qt::EditRole) return QVariant::fromValue<QAD::Enum>(et); if (role == Qt::EditRole) return QVariant::fromValue<QAD::Enum>(et);
else return et.selectedName(); else return et.selectedName();
} }
return PI2QString(t.value()); return PI2QString(t.value());
} }
bool CDItem::setData(int column, const QVariant & value) { bool CDItem::setData(int column, const QVariant & value) {
if (type_ == ItemCDType) { if (type_ == ItemCDType) {
CDType & t(interface->section(buildPath())[index_]); CDType & t(interface->section(buildPath())[index_]);
if ((column == cExpression || column == cValue) && (t.cd_type() == CDType::cdK)) { if ((column == cExpression || column == cValue) && (t.cd_type() == CDType::cdK)) {
interface->section(buildPath())[index_].setValue(Q2PIString(value.toString())); interface->section(buildPath())[index_].setValue(Q2PIString(value.toString()));
interface->calculate(); interface->calculate();
return true; return true;
} }
if (t.cd_type() == CDType::cdX) { if (t.cd_type() == CDType::cdX) {
switch (column) { switch (column) {
case cName_Cmd: case cName_Cmd:
X.setEnabled(t, value.toBool()); X.setEnabled(t, value.toBool());
return true; return true;
case cXMode: case cXMode:
t.setXMode((CDType::XMode)value.toInt()); t.setXMode((CDType::XMode)value.toInt());
return true; return true;
case cXAvg: case cXAvg:
t.setAvg(piMax(value.toInt(), 1)); t.setAvg(piMax(value.toInt(), 1));
return true; return true;
default: break; default: break;
} }
} }
} }
return false; return false;
} }
PIDeque<int> CDItem::buildPath() const { PIDeque<int> CDItem::buildPath() const {
PIDeque<int> path; PIDeque<int> path;
CDItem * p = parent_; CDItem * p = parent_;
while (p) { while (p) {
path.push_front(p->index_); path.push_front(p->index_);
p = p->parent_; p = p->parent_;
} }
path.take_front(); path.take_front();
return path; return path;
} }
QString CDItem::stringType(const PIString & t) const { QString CDItem::stringType(const PIString & t) const {
QString n = PI2QString(t); QString n = PI2QString(t);
if (n.isEmpty()) return QString(""); if (n.isEmpty()) return QString("");
switch (n[0].toLatin1()) { switch (n[0].toLatin1()) {
case 'l': return QString("list"); break; case 'l': return QString("list"); break;
case 'b': return QString("bool"); break; case 'b': return QString("bool"); break;
case 'n': return QString("int"); break; case 'n': return QString("int"); break;
case 'f': return QString("double"); break; case 'f': return QString("double"); break;
case 'c': return QString("color"); break; case 'c': return QString("color"); break;
case 'r': return QString("rect"); break; case 'r': return QString("rect"); break;
case 'a': return QString("rect"); break; case 'a': return QString("rect"); break;
case 'p': return QString("point"); break; case 'p': return QString("point"); break;
case 'v': return QString("vector"); break; case 'v': return QString("vector"); break;
case 'i': return QString("IP"); break; case 'i': return QString("IP"); break;
case 'e': return QString("enum"); break; case 'e': return QString("enum"); break;
case 'F': return QString("file"); break; case 'F': return QString("file"); break;
case 'D': return QString("dir"); break; case 'D': return QString("dir"); break;
} }
return QString("string"); return QString("string");
} }
QAD::Enum CDItem::xModeEnum(int v) const { QAD::Enum CDItem::xModeEnum(int v) const {
QAD::Enum ret; QAD::Enum ret;
ret << QAD::Enumerator(CDType::X_Current, "Current") ret << QAD::Enumerator(CDType::X_Current, "Current")
<< QAD::Enumerator(CDType::X_All_Avg, "All, Averaging"); << QAD::Enumerator(CDType::X_All_Avg, "All, Averaging");
ret.selectValue(v); ret.selectValue(v);
return ret; return ret;
} }
// CDKDelegate // CDKDelegate
CDDelegate::CDDelegate(QObject *parent) : QStyledItemDelegate(parent) { CDDelegate::CDDelegate(QObject *parent) : QStyledItemDelegate(parent) {
} }
void CDDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const { void CDDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const {
CDItem * item = ((CDItemModel*)index.model())->getItem(index); CDItem * item = ((CDItemModel*)index.model())->getItem(index);
if (item) { if (item) {
if (item->itemType() == CDItem::ItemCDType && item->interface->cdType() == CDType::cdC) { if (item->itemType() == CDItem::ItemCDType && item->interface->cdType() == CDType::cdC) {
QStyleOptionButton bo; QStyleOptionButton bo;
bo.direction = option.direction; bo.direction = option.direction;
bo.fontMetrics = option.fontMetrics; bo.fontMetrics = option.fontMetrics;
bo.palette = option.palette; bo.palette = option.palette;
bo.rect = option.rect; bo.rect = option.rect;
bo.state = option.state;// & ~(QStyle::State_HasFocus | QStyle::State_MouseOver); bo.state = option.state;// & ~(QStyle::State_HasFocus | QStyle::State_MouseOver);
bo.text = item->data(1, Qt::DisplayRole).toString(); bo.text = item->data(1, Qt::DisplayRole).toString();
QWidget * v = (QWidget*)(painter->device()); QWidget * v = (QWidget*)(painter->device());
if (v) { if (v) {
QPoint cp = v->mapFromGlobal(QCursor::pos()); QPoint cp = v->mapFromGlobal(QCursor::pos());
if (bo.rect.contains(cp, true)) { if (bo.rect.contains(cp, true)) {
//bo.state |= QStyle::State_MouseOver; //bo.state |= QStyle::State_MouseOver;
if (qApp->mouseButtons().testFlag(Qt::LeftButton)) if (qApp->mouseButtons().testFlag(Qt::LeftButton))
bo.state |= QStyle::State_On; bo.state |= QStyle::State_On;
} }
} }
qApp->style()->drawControl(QStyle::CE_PushButton, &bo, painter); qApp->style()->drawControl(QStyle::CE_PushButton, &bo, painter);
return; return;
} }
} }
QStyledItemDelegate::paint(painter, option, index); QStyledItemDelegate::paint(painter, option, index);
} }
QWidget * CDDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { QWidget * CDDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const {
return new QVariantEdit(parent); return new QVariantEdit(parent);
} }
void CDDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { void CDDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const {
QVariantEdit *edit = static_cast<QVariantEdit*>(editor); QVariantEdit *edit = static_cast<QVariantEdit*>(editor);
edit->setValue(index.model()->data(index, Qt::EditRole)); edit->setValue(index.model()->data(index, Qt::EditRole));
} }
void CDDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { void CDDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
QVariantEdit *edit = static_cast<QVariantEdit*>(editor); QVariantEdit *edit = static_cast<QVariantEdit*>(editor);
QVariant v = edit->value(); QVariant v = edit->value();
if (v.canConvert<QAD::Enum>()) { if (v.canConvert<QAD::Enum>()) {
QAD::Enum et = v.value<QAD::Enum>(); QAD::Enum et = v.value<QAD::Enum>();
model->setData(index, et.selectedValue(), Qt::EditRole); model->setData(index, et.selectedValue(), Qt::EditRole);
} else model->setData(index, v, Qt::EditRole); } else model->setData(index, v, Qt::EditRole);
} }
void CDDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const { void CDDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const {
editor->setGeometry(option.rect); editor->setGeometry(option.rect);
} }
QSize CDDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { QSize CDDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const {
QSize s = QStyledItemDelegate::sizeHint(option, index); QSize s = QStyledItemDelegate::sizeHint(option, index);
s.setWidth(s.width() + 20); s.setWidth(s.width() + 20);
return s; return s;
} }
// CDItemModel // CDItemModel
CDItemModel::CDItemModel(int type_, QObject *parent) : QAbstractItemModel(parent) { CDItemModel::CDItemModel(int type_, QObject *parent) : QAbstractItemModel(parent) {
interface = new Interface((CDType::cdT)type_); interface = new Interface((CDType::cdT)type_);
root = 0; root = 0;
internalRebuild(); internalRebuild();
} }
CDItemModel::~CDItemModel() { CDItemModel::~CDItemModel() {
delete root; delete root;
delete interface; delete interface;
} }
QVariant CDItemModel::data(const QModelIndex &index, int role) const { QVariant CDItemModel::data(const QModelIndex &index, int role) const {
if (!index.isValid()) return QVariant(); if (!index.isValid()) return QVariant();
CDItem * item = getItem(index); CDItem * item = getItem(index);
return item->data(index.column(), role); return item->data(index.column(), role);
} }
QVariant CDItemModel::headerData(int section, Qt::Orientation orientation, int role) const { QVariant CDItemModel::headerData(int section, Qt::Orientation orientation, int role) const {
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch (section) { switch (section) {
case cID: return tr("Index"); case cID: return tr("Index");
case cName_Cmd: return interface->cdType() == CDType::cdC ? tr("Command") : tr("Name"); case cName_Cmd: return interface->cdType() == CDType::cdC ? tr("Command") : tr("Name");
case cType: return tr("Type"); case cType: return tr("Type");
case cXMode: return tr("Mode"); case cXMode: return tr("Mode");
case cXAvg: return tr("Averaging"); case cXAvg: return tr("Averaging");
case cExpression: return tr("Expression"); case cExpression: return tr("Expression");
case cValue: return tr("Value"); case cValue: return tr("Value");
case cComment: return tr("Comment"); case cComment: return tr("Comment");
} }
} }
return QVariant(); return QVariant();
} }
QModelIndex CDItemModel::index(int row, int column, const QModelIndex &parent) const { QModelIndex CDItemModel::index(int row, int column, const QModelIndex &parent) const {
if (parent.isValid() && parent.column() != cID) return QModelIndex(); if (parent.isValid() && parent.column() != cID) return QModelIndex();
CDItem * p = getItem(parent); CDItem * p = getItem(parent);
CDItem * c = p->childs.value(row, 0); CDItem * c = p->childs.value(row, 0);
if (c) return createIndex(row, column, c); if (c) return createIndex(row, column, c);
else return QModelIndex(); else return QModelIndex();
} }
QModelIndex CDItemModel::parent(const QModelIndex &index) const { QModelIndex CDItemModel::parent(const QModelIndex &index) const {
if (!index.isValid()) return QModelIndex(); if (!index.isValid()) return QModelIndex();
CDItem * c = getItem(index); CDItem * c = getItem(index);
CDItem * p = c->parent_; CDItem * p = c->parent_;
if (p == root) return QModelIndex(); if (p == root) return QModelIndex();
return createIndex(p->parent_->childs.indexOf(p), cID, p); return createIndex(p->parent_->childs.indexOf(p), cID, p);
} }
int CDItemModel::rowCount(const QModelIndex &parent) const { int CDItemModel::rowCount(const QModelIndex &parent) const {
CDItem * p = getItem(parent); CDItem * p = getItem(parent);
return p->childs.count(); return p->childs.count();
} }
int CDItemModel::columnCount(const QModelIndex &parent) const { int CDItemModel::columnCount(const QModelIndex &parent) const {
return cLastColumn; return cLastColumn;
} }
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) {
if (index.column() == cExpression || index.column() == cValue) if (index.column() == cExpression || index.column() == cValue)
f |= Qt::ItemIsEditable; f |= Qt::ItemIsEditable;
if (index.column() == cValue && t.type() == "b") if (index.column() == cValue && t.type() == "b")
f |= Qt::ItemIsUserCheckable; f |= Qt::ItemIsUserCheckable;
if (index.column() == cName_Cmd) if (index.column() == cName_Cmd)
f |= Qt::ItemIsDragEnabled; f |= Qt::ItemIsDragEnabled;
} }
if (t.cd_type() == CDType::cdX) { if (t.cd_type() == CDType::cdX) {
if (index.column() == cXMode || index.column() == cXAvg) if (index.column() == cXMode || index.column() == cXAvg)
f |= Qt::ItemIsEditable; f |= Qt::ItemIsEditable;
if (index.column() == cName_Cmd) if (index.column() == cName_Cmd)
f |= Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled; f |= Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled;
} }
} }
return f; return f;
} }
bool CDItemModel::setData(const QModelIndex & index, const QVariant & value, int role) { bool CDItemModel::setData(const QModelIndex & index, const QVariant & value, int role) {
if (role == Qt::CheckStateRole && (index.column() == cName_Cmd || index.column() == cValue)) { if (role == Qt::CheckStateRole && (index.column() == cName_Cmd || index.column() == cValue)) {
CDItem * item = getItem(index); CDItem * item = getItem(index);
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 (index.column() == cValue && (t.cd_type() == CDType::cdK)) { if (index.column() == cValue && (t.cd_type() == CDType::cdK)) {
if (t.type() == "b") { if (t.type() == "b") {
bool result = item->setData(index.column(), PI2QString(PIString::fromBool(value.toBool()))); bool result = item->setData(index.column(), PI2QString(PIString::fromBool(value.toBool())));
QModelIndex rin(CDItemModel::index(index.row(), cExpression, index.parent())); QModelIndex rin(CDItemModel::index(index.row(), cExpression, index.parent()));
emit dataChanged(rin, rin); emit dataChanged(rin, rin);
return result; return result;
} }
} }
if (index.column() == cName_Cmd && (t.cd_type() == CDType::cdX)) { if (index.column() == cName_Cmd && (t.cd_type() == CDType::cdX)) {
bool result = item->setData(index.column(), value); bool result = item->setData(index.column(), value);
//QModelIndex rin(CDItemModel::index(index.row(), 1, index.parent())); //QModelIndex rin(CDItemModel::index(index.row(), 1, index.parent()));
//emit dataChanged(rin, rin); //emit dataChanged(rin, rin);
return result; return result;
} }
} }
} }
if (role != Qt::EditRole) return false; if (role != Qt::EditRole) return false;
CDItem * item = getItem(index); CDItem * item = getItem(index);
bool result = item->setData(index.column(), value); bool result = item->setData(index.column(), value);
if (result) { if (result) {
QModelIndex rin(CDItemModel::index(index.row(), cExpression, index.parent())); QModelIndex rin(CDItemModel::index(index.row(), cExpression, index.parent()));
emit dataChanged(rin, rin); emit dataChanged(rin, rin);
emit dataChanged(index, index); emit dataChanged(index, index);
} }
return result; return result;
} }
QMimeData * CDItemModel::mimeData(const QModelIndexList & indexes) const { QMimeData * CDItemModel::mimeData(const QModelIndexList & indexes) const {
if (indexes.size() == 1) { if (indexes.size() == 1) {
QModelIndex index = indexes[0]; QModelIndex index = indexes[0];
if (index.isValid()/* && interface->cdType() == CDType::cdX*/) { if (index.isValid()/* && interface->cdType() == CDType::cdX*/) {
CDItem * item = getItem(index); CDItem * item = getItem(index);
if (item) { if (item) {
CDType & t(interface->section(item->buildPath())[item->index_]); CDType & t(interface->section(item->buildPath())[item->index_]);
QMimeData * mime = new QMimeData(); QMimeData * mime = new QMimeData();
mime->setText(PI2QString(CDCore::instance()->typeLetter(interface->cdType()) + mime->setText(PI2QString(CDCore::instance()->typeLetter(interface->cdType()) +
CDCore::pathToString(t.path()))); CDCore::pathToString(t.path())));
return mime; return mime;
} }
} }
} }
return QAbstractItemModel::mimeData(indexes); return QAbstractItemModel::mimeData(indexes);
} }
void CDItemModel::rebuildModel() { void CDItemModel::rebuildModel() {
beginResetModel(); beginResetModel();
internalRebuild(); internalRebuild();
endResetModel(); endResetModel();
} }
void CDItemModel::buildItem(CDItem * it, CDSection & r) { void CDItemModel::buildItem(CDItem * it, CDSection & r) {
//piCout << "build item" << r.name << r.alias; //piCout << "build item" << r.name << r.alias;
PIMap<int, CDType>::iterator i; auto i = r.cd.makeIterator();
for (i = r.cd.begin(); i != r.cd.end(); ++i) { while (i.next()) {
it->childs << new CDItem(interface, i.key(), CDItem::ItemCDType, it); it->childs << new CDItem(interface, i.key(), CDItem::ItemCDType, it);
} }
it->item_count = it->childs.size(); it->item_count = it->childs.size();
PIMap<int, CDSection>::iterator j; auto j = r.s.makeIterator();
for (j = r.s.begin(); j != r.s.end(); ++j) { while (j.next()) {
it->childs << new CDItem(interface, j.key(), CDItem::ItemCDSection, it); it->childs << new CDItem(interface, j.key(), CDItem::ItemCDSection, it);
buildItem(it->childs.back(), j.value()); buildItem(it->childs.back(), j.valueRef());
} }
} }
void CDItemModel::updateModel() { void CDItemModel::updateModel() {
beginResetModel(); beginResetModel();
endResetModel(); endResetModel();
} }
void CDItemModel::internalRebuild() { void CDItemModel::internalRebuild() {
//qDebug() << "[CDKItemModel]" << "internalRebuild()"; //qDebug() << "[CDKItemModel]" << "internalRebuild()";
if (root) delete root; if (root) delete root;
root = new CDItem(interface, 0, CDItem::ItemCDSection, 0); root = new CDItem(interface, 0, CDItem::ItemCDSection, 0);
CDSection & r = interface->root(); CDSection & r = interface->root();
buildItem(root, r); buildItem(root, r);
} }
CDItem * CDItemModel::getItem(const QModelIndex &index) const { CDItem * CDItemModel::getItem(const QModelIndex &index) const {
if (index.isValid()) { if (index.isValid()) {
CDItem * item = static_cast<CDItem*>(index.internalPointer()); CDItem * item = static_cast<CDItem*>(index.internalPointer());
if (item) return item; if (item) return item;
} }
return root; return root;
} }
QModelIndex CDItemModel::indexByPath(const PIDeque<int> & path, int column) const { QModelIndex CDItemModel::indexByPath(const PIDeque<int> & path, int column) const {
if (path.isEmpty()) return QModelIndex(); if (path.isEmpty()) return QModelIndex();
CDItem * item = root; CDItem * item = root;
//piCout << path << "..."; //piCout << path << "...";
bool ok = false; bool ok = false;
for (int i = 0; i < path.size_s() - 1; ++i) { for (int i = 0; i < path.size_s() - 1; ++i) {
ok = false; ok = false;
foreach (CDItem * j, item->childs) foreach (CDItem * j, item->childs)
if (j->type_ == CDItem::ItemCDSection && j->index_ == path[i]) { if (j->type_ == CDItem::ItemCDSection && j->index_ == path[i]) {
item = j; item = j;
ok = true; ok = true;
break; break;
} }
if (!ok) return QModelIndex(); if (!ok) return QModelIndex();
} }
ok = false; ok = false;
foreach (CDItem * j, item->childs) foreach (CDItem * j, item->childs)
if (j->type_ == CDItem::ItemCDType && j->index_ == path.back()) { if (j->type_ == CDItem::ItemCDType && j->index_ == path.back()) {
item = j; item = j;
ok = true; ok = true;
break; break;
} }
if (!ok || !item->parent_) return QModelIndex(); if (!ok || !item->parent_) return QModelIndex();
QModelIndex ret = createIndex(item->parent_->childs.indexOf(item), column, item); QModelIndex ret = createIndex(item->parent_->childs.indexOf(item), column, item);
//piCout << path << Q2PIString(item->data(cName_Cmd, Qt::DisplayRole).toString()) << getItem(ret)->buildPath(); //piCout << path << Q2PIString(item->data(cName_Cmd, Qt::DisplayRole).toString()) << getItem(ret)->buildPath();
return ret; return ret;
} }

View File

@@ -1,113 +1,133 @@
#ifndef QCD_MODEL_H /*
#define QCD_MODEL_H QCD Utils - Qt bindings/utilites for CD Utils
#include <QAbstractItemModel> Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
#include <QItemDelegate>
#include <QStyledItemDelegate> This program is free software: you can redistribute it and/or modify
#include "pistring.h" 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
namespace CDUtils { (at your option) any later version.
class CDType;
class CDSection; This program is distributed in the hope that it will be useful,
class Interface; but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
enum Column { GNU Lesser General Public License for more details.
cID ,
cName_Cmd , You should have received a copy of the GNU Lesser General Public License
cType , along with this program. If not, see <http://www.gnu.org/licenses/>.
cXMode , */
cXAvg ,
cExpression, #ifndef QCD_MODEL_H
cValue , #define QCD_MODEL_H
cComment ,
cLastColumn, #include <QAbstractItemModel>
}; #include <QItemDelegate>
} #include <QStyledItemDelegate>
#include "pistring.h"
namespace QAD { #include "qcd_utils_export.h"
struct Enum;
} namespace CDUtils {
class CDType;
class CDItemModel; class CDSection;
class Interface;
class CDItem { enum Column {
friend class CDItemModel; cID ,
friend class CDView; cName_Cmd ,
public: cType ,
enum CDItemType{ItemCDType, ItemCDSection}; cXMode ,
CDItem(CDUtils::Interface * interface, int _index, CDItemType type, CDItem * parent); cXAvg ,
~CDItem(); cExpression,
QVariant data(int column, int role) const; cValue ,
QVariant value(CDUtils::CDType & t, int role) const; cComment ,
bool setData(int column, const QVariant & value); cLastColumn,
CDItemType itemType() const {return type_;} };
PIDeque<int> buildPath() const; }
int index() const {return index_;}
namespace QAD {
CDUtils::Interface * interface; struct Enum;
bool expanded; }
private: class CDItemModel;
QString stringType(const PIString & t) const;
QAD::Enum xModeEnum(int v) const;
class QCD_UTILS_EXPORT CDItem {
CDItem * parent_; friend class CDItemModel;
int index_, item_count; friend class CDView;
CDItemType type_; public:
QList<CDItem *> childs; enum CDItemType{ItemCDType, ItemCDSection};
}; CDItem(CDUtils::Interface * interface, int _index, CDItemType type, CDItem * parent);
~CDItem();
QVariant data(int column, int role) const;
class CDDelegate : public QStyledItemDelegate QVariant value(CDUtils::CDType & t, int role) const;
{ bool setData(int column, const QVariant & value);
Q_OBJECT CDItemType itemType() const {return type_;}
public: PIDeque<int> buildPath() const;
CDDelegate(QObject *parent = 0); int index() const {return index_;}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const; CDUtils::Interface * interface;
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; bool expanded;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; private:
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; QString stringType(const PIString & t) const;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; QAD::Enum xModeEnum(int v) const;
}; CDItem * parent_;
int index_, item_count;
CDItemType type_;
class CDItemModel : public QAbstractItemModel { QList<CDItem *> childs;
Q_OBJECT };
friend class CDView;
public:
explicit CDItemModel(int type_, QObject *parent = 0); class QCD_UTILS_EXPORT CDDelegate : public QStyledItemDelegate
~CDItemModel(); {
Q_OBJECT
QVariant data(const QModelIndex & index, int role) const; public:
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; CDDelegate(QObject *parent = 0);
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const; void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const; QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const; void setEditorData(QWidget *editor, const QModelIndex &index) const;
Qt::ItemFlags flags(const QModelIndex &index) const; void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
QMimeData * mimeData(const QModelIndexList & indexes) const; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
CDItem * getItem(const QModelIndex & index) const;
QModelIndex indexByPath(const PIDeque<int> & path, int column = CDUtils::cID) const; };
void buildItem(CDItem * it, CDUtils::CDSection &r);
class QCD_UTILS_EXPORT CDItemModel : public QAbstractItemModel {
public slots: Q_OBJECT
void rebuildModel(); friend class CDView;
void updateModel(); public:
explicit CDItemModel(int type_, QObject *parent = 0);
private: ~CDItemModel();
void internalRebuild();
QVariant data(const QModelIndex & index, int role) const;
CDUtils::Interface * interface; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
CDItem * root; QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
signals: int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
}; Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
#endif // QCD_MODEL_H QMimeData * mimeData(const QModelIndexList & indexes) const;
CDItem * getItem(const QModelIndex & index) const;
QModelIndex indexByPath(const PIDeque<int> & path, int column = CDUtils::cID) const;
void buildItem(CDItem * it, CDUtils::CDSection &r);
public slots:
void rebuildModel();
void updateModel();
private:
void internalRebuild();
CDUtils::Interface * interface;
CDItem * root;
signals:
};
#endif // QCD_MODEL_H

View File

@@ -1,371 +1,371 @@
#include <QDir> #include <QDir>
#include <QMouseEvent> #include <QMouseEvent>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#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 "qcd_view.h" #include "qcd_view.h"
#include "qcd_model.h" #include "qcd_model.h"
#include "piqt.h" #include "piqt.h"
#include "pifile.h" #include "pifile.h"
using namespace CDUtils; using namespace CDUtils;
CDView::CDView(QWidget * parent) : QTreeView(parent) { CDView::CDView(QWidget * parent) : QTreeView(parent) {
type_ = -1; type_ = -1;
model_ = 0; model_ = 0;
proxy_ = 0; proxy_ = 0;
connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(indexClicked(QModelIndex))); connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(indexClicked(QModelIndex)));
connect(this, SIGNAL(_qcd_sendFailed()), this, SLOT(cd_sendFailed()), Qt::QueuedConnection); connect(this, SIGNAL(_qcd_sendFailed()), this, SLOT(cd_sendFailed()), Qt::QueuedConnection);
connect(this, SIGNAL(_qcd_sendSucceed()), this, SLOT(cd_sendSucceed()), Qt::QueuedConnection); connect(this, SIGNAL(_qcd_sendSucceed()), this, SLOT(cd_sendSucceed()), Qt::QueuedConnection);
connect(this, SIGNAL(_qcd_receiveFailed()), this, SLOT(cd_receiveFailed()), Qt::QueuedConnection); connect(this, SIGNAL(_qcd_receiveFailed()), this, SLOT(cd_receiveFailed()), Qt::QueuedConnection);
connect(this, SIGNAL(_qcd_receiveSucceed()), this, SLOT(cd_receiveSucceed()), Qt::QueuedConnection); connect(this, SIGNAL(_qcd_receiveSucceed()), this, SLOT(cd_receiveSucceed()), Qt::QueuedConnection);
connect(this, SIGNAL(_qcd_receivedX()), this, SLOT(cd_receivedX()), Qt::QueuedConnection); connect(this, SIGNAL(_qcd_receivedX()), this, SLOT(cd_receivedX()), Qt::QueuedConnection);
connect(this, SIGNAL(_qcd_changedGlobal()), this, SLOT(cd_changedGlobal()), Qt::QueuedConnection); connect(this, SIGNAL(_qcd_changedGlobal()), this, SLOT(cd_changedGlobal()), Qt::QueuedConnection);
} }
CDView::~CDView() { CDView::~CDView() {
if (model_) { if (model_) {
delete model_; delete model_;
delete proxy_; delete proxy_;
} }
model_ = 0; model_ = 0;
proxy_ = 0; proxy_ = 0;
} }
void CDView::setType(int cdt) { void CDView::setType(int cdt) {
if (cdt < 0) return; if (cdt < 0) return;
if (type_ >= 0) return; if (type_ >= 0) return;
type_ = cdt; type_ = cdt;
switch ((CDType::cdT)type_) { switch ((CDType::cdT)type_) {
case CDType::cdK: case CDType::cdK:
CONNECTU(&K, sended, this, pi_cd_sendSucceed); CONNECTU(&K, sended, this, pi_cd_sendSucceed);
CONNECTU(&K, sendFailed, this, pi_cd_sendFailed); CONNECTU(&K, sendFailed, this, pi_cd_sendFailed);
CONNECTU(&K, received, this, pi_cd_receiveSucceed); CONNECTU(&K, received, this, pi_cd_receiveSucceed);
CONNECTU(&K, receiveFailed, this, pi_cd_receiveFailed); CONNECTU(&K, receiveFailed, this, pi_cd_receiveFailed);
CONNECTU(&K, changedGlobal, this, pi_cd_changedGlobal); CONNECTU(&K, changedGlobal, this, pi_cd_changedGlobal);
break; break;
case CDType::cdX: case CDType::cdX:
CONNECTU(&X, sended, this, pi_cd_sendSucceed); CONNECTU(&X, sended, this, pi_cd_sendSucceed);
CONNECTU(&X, sendFailed, this, pi_cd_sendFailed); CONNECTU(&X, sendFailed, this, pi_cd_sendFailed);
CONNECTU(&X, received, this, pi_cd_receiveSucceed); CONNECTU(&X, received, this, pi_cd_receiveSucceed);
CONNECTU(&X, receiveFailed, this, pi_cd_receiveFailed); CONNECTU(&X, receiveFailed, this, pi_cd_receiveFailed);
CONNECTU(&X, receivedX, this, pi_cd_receivedX); CONNECTU(&X, receivedX, this, pi_cd_receivedX);
CONNECTU(&X, changedGlobal, this, pi_cd_changedGlobal); CONNECTU(&X, changedGlobal, this, pi_cd_changedGlobal);
break; break;
case CDType::cdC: case CDType::cdC:
CONNECTU(&C, sended, this, pi_cd_sendSucceed); CONNECTU(&C, sended, this, pi_cd_sendSucceed);
CONNECTU(&C, sendFailed, this, pi_cd_sendFailed); CONNECTU(&C, sendFailed, this, pi_cd_sendFailed);
CONNECTU(&C, received, this, pi_cd_receiveSucceed); CONNECTU(&C, received, this, pi_cd_receiveSucceed);
CONNECTU(&C, receiveFailed, this, pi_cd_receiveFailed); CONNECTU(&C, receiveFailed, this, pi_cd_receiveFailed);
CONNECTU(&C, changedGlobal, this, pi_cd_changedGlobal); CONNECTU(&C, changedGlobal, this, pi_cd_changedGlobal);
break; break;
case CDType::cdM: case CDType::cdM:
CONNECTU(&M, sended, this, pi_cd_sendSucceed); CONNECTU(&M, sended, this, pi_cd_sendSucceed);
CONNECTU(&M, sendFailed, this, pi_cd_sendFailed); CONNECTU(&M, sendFailed, this, pi_cd_sendFailed);
CONNECTU(&M, received, this, pi_cd_receiveSucceed); CONNECTU(&M, received, this, pi_cd_receiveSucceed);
CONNECTU(&M, receiveFailed, this, pi_cd_receiveFailed); CONNECTU(&M, receiveFailed, this, pi_cd_receiveFailed);
CONNECTU(&M, changedGlobal, this, pi_cd_changedGlobal); CONNECTU(&M, changedGlobal, this, pi_cd_changedGlobal);
CONNECTU(&M, messageReceived, this, pi_cd_messageReceived); CONNECTU(&M, messageReceived, this, pi_cd_messageReceived);
break; break;
default: break; default: break;
} }
} }
void CDView::mousePressEvent(QMouseEvent * e) { void CDView::mousePressEvent(QMouseEvent * e) {
if (type_ == CDType::cdC) { if (type_ == CDType::cdC) {
QModelIndex i = indexAt(e->pos()); QModelIndex i = indexAt(e->pos());
if (i.isValid() && i.column() == cName_Cmd) if (i.isValid() && i.column() == cName_Cmd)
update(i); update(i);
} }
QTreeView::mousePressEvent(e); QTreeView::mousePressEvent(e);
} }
void CDView::mouseReleaseEvent(QMouseEvent * e) { void CDView::mouseReleaseEvent(QMouseEvent * e) {
if (type_ == CDType::cdC) { if (type_ == CDType::cdC) {
QModelIndex i = indexAt(e->pos()); QModelIndex i = indexAt(e->pos());
if (i.isValid() && i.column() == cName_Cmd) if (i.isValid() && i.column() == cName_Cmd)
update(i); update(i);
} }
QTreeView::mouseReleaseEvent(e); QTreeView::mouseReleaseEvent(e);
} }
void CDView::currentChanged(const QModelIndex & cur, const QModelIndex & prev) { void CDView::currentChanged(const QModelIndex & cur, const QModelIndex & prev) {
if (type_ == CDType::cdC) { if (type_ == CDType::cdC) {
if (prev.isValid() && prev.column() == cName_Cmd) if (prev.isValid() && prev.column() == cName_Cmd)
update(prev); update(prev);
} }
QTreeView::currentChanged(cur, prev); QTreeView::currentChanged(cur, prev);
} }
void CDView::refresh() { void CDView::refresh() {
if (type_ < 0) return; if (type_ < 0) return;
if (!model_) { if (!model_) {
model_ = new CDItemModel(type_); model_ = new CDItemModel(type_);
proxy_ = new QSortFilterProxyModel(); proxy_ = new QSortFilterProxyModel();
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
proxy_->setRecursiveFilteringEnabled(true); proxy_->setRecursiveFilteringEnabled(true);
#endif #endif
proxy_->setFilterKeyColumn(-1); proxy_->setFilterKeyColumn(-1);
proxy_->setFilterCaseSensitivity(Qt::CaseInsensitive); proxy_->setFilterCaseSensitivity(Qt::CaseInsensitive);
proxy_->setSourceModel(model_); proxy_->setSourceModel(model_);
setModel(proxy_); setModel(proxy_);
setItemDelegateForColumn(type_ == CDType::cdC ? cName_Cmd : cValue, new CDDelegate()); setItemDelegateForColumn(type_ == CDType::cdC ? cName_Cmd : cValue, new CDDelegate());
if (type_ == CDType::cdX) if (type_ == CDType::cdX)
setItemDelegateForColumn(cXMode, new CDDelegate()); setItemDelegateForColumn(cXMode, new CDDelegate());
} }
model_->rebuildModel(); model_->rebuildModel();
switch ((CDType::cdT)type_) { switch ((CDType::cdT)type_) {
case CDType::cdK: case CDType::cdK:
setColumnHidden(cXMode, true); setColumnHidden(cXMode, true);
setColumnHidden(cXAvg, true); setColumnHidden(cXAvg, true);
break; break;
case CDType::cdX: case CDType::cdX:
setColumnHidden(cExpression, true); setColumnHidden(cExpression, true);
break; break;
case CDType::cdC: case CDType::cdC:
case CDType::cdM: case CDType::cdM:
setColumnHidden(cType, true); setColumnHidden(cType, true);
setColumnHidden(cXMode, true); setColumnHidden(cXMode, true);
setColumnHidden(cXAvg, true); setColumnHidden(cXAvg, true);
setColumnHidden(cExpression, true); setColumnHidden(cExpression, true);
setColumnHidden(cValue, true); setColumnHidden(cValue, true);
break; break;
default: break; default: break;
} }
expandAll(); expandAll();
for (int i = 0; i < model_->columnCount(); i++) resizeColumnToContents(i); for (int i = 0; i < model_->columnCount(); i++) resizeColumnToContents(i);
} }
void CDView::refreshValues() { void CDView::refreshValues() {
if (!model_) return; if (!model_) return;
model_->dataChanged(model_->index(0, 0), model_->index(model_->columnCount() - 1, model_->rowCount() - 1)); model_->dataChanged(model_->index(0, 0), model_->index(model_->columnCount() - 1, model_->rowCount() - 1));
} }
void CDView::setFile(const QString & filename) { void CDView::setFile(const QString & filename) {
switch ((CDType::cdT)type_) { switch ((CDType::cdT)type_) {
case CDType::cdK: K.setFileName(Q2PIString(filename)); break; case CDType::cdK: K.setFileName(Q2PIString(filename)); break;
case CDType::cdX: X.setFileName(Q2PIString(filename)); break; case CDType::cdX: X.setFileName(Q2PIString(filename)); break;
case CDType::cdC: C.setFileName(Q2PIString(filename)); break; case CDType::cdC: C.setFileName(Q2PIString(filename)); break;
case CDType::cdM: M.setFileName(Q2PIString(filename)); break; case CDType::cdM: M.setFileName(Q2PIString(filename)); break;
default: break; default: break;
} }
} }
bool CDView::inProgress() const { bool CDView::inProgress() const {
switch ((CDType::cdT)type_) { switch ((CDType::cdT)type_) {
case CDType::cdK: return K.inProgress(); break; case CDType::cdK: return K.inProgress(); break;
case CDType::cdX: return X.inProgress(); break; case CDType::cdX: return X.inProgress(); break;
case CDType::cdC: return C.inProgress(); break; case CDType::cdC: return C.inProgress(); break;
case CDType::cdM: return M.inProgress(); break; case CDType::cdM: return M.inProgress(); break;
default: break; default: break;
} }
return false; return false;
} }
void CDView::startX(double freq) { void CDView::startX(double freq) {
switch ((CDType::cdT)type_) { switch ((CDType::cdT)type_) {
case CDType::cdX: X.start(freq); break; case CDType::cdX: X.start(freq); break;
default: break; default: break;
} }
} }
CDSection * CDView::root() { CDSection * CDView::root() {
return CDCore::instance()->root((CDType::cdT)type_); return CDCore::instance()->root((CDType::cdT)type_);
} }
QString CDView::typeLetter() const { QString CDView::typeLetter() const {
return PI2QString(CDCore::instance()->typeLetter((CDType::cdT)type_)); return PI2QString(CDCore::instance()->typeLetter((CDType::cdT)type_));
} }
void CDView::send() { void CDView::send() {
busyStatusChanged(true); busyStatusChanged(true);
switch ((CDType::cdT)type_) { switch ((CDType::cdT)type_) {
case CDType::cdK: K.send(); break; case CDType::cdK: K.send(); break;
case CDType::cdX: X.send(); break; case CDType::cdX: X.send(); break;
case CDType::cdC: C.send(); break; case CDType::cdC: C.send(); break;
case CDType::cdM: M.send(); break; case CDType::cdM: M.send(); break;
default: break; default: break;
} }
} }
void CDView::receive() { void CDView::receive() {
busyStatusChanged(true); busyStatusChanged(true);
switch ((CDType::cdT)type_) { switch ((CDType::cdT)type_) {
case CDType::cdK: K.request(); break; case CDType::cdK: K.request(); break;
case CDType::cdX: X.request(); break; case CDType::cdX: X.request(); break;
case CDType::cdC: C.request(); break; case CDType::cdC: C.request(); break;
case CDType::cdM: M.request(); break; case CDType::cdM: M.request(); break;
default: break; default: break;
} }
} }
void CDView::save() { void CDView::save() {
switch ((CDType::cdT)type_) { switch ((CDType::cdT)type_) {
case CDType::cdK: K.writeFile(); break; case CDType::cdK: K.writeFile(); break;
case CDType::cdX: X.writeFile(); break; case CDType::cdX: X.writeFile(); break;
case CDType::cdC: C.writeFile(); break; case CDType::cdC: C.writeFile(); break;
case CDType::cdM: M.writeFile(); break; case CDType::cdM: M.writeFile(); break;
default: break; default: break;
} }
} }
void CDView::load() { void CDView::load() {
switch ((CDType::cdT)type_) { switch ((CDType::cdT)type_) {
case CDType::cdK: case CDType::cdK:
K.readFile(); K.readFile();
K.calculate(); K.calculate();
break; break;
case CDType::cdX: case CDType::cdX:
X.readFile(); X.readFile();
X.calculate(); X.calculate();
break; break;
case CDType::cdC: case CDType::cdC:
C.readFile(); C.readFile();
C.calculate(); C.calculate();
break; break;
case CDType::cdM: case CDType::cdM:
M.readFile(); M.readFile();
M.calculate(); M.calculate();
break; break;
default: break; default: break;
} }
refresh(); refresh();
} }
void CDView::clear() { void CDView::clear() {
//piCout << "clearK"; //piCout << "clearK";
switch ((CDType::cdT)type_) { switch ((CDType::cdT)type_) {
case CDType::cdK: K.root() = CDSection(); break; case CDType::cdK: K.root() = CDSection(); break;
case CDType::cdX: X.root() = CDSection(); break; case CDType::cdX: X.root() = CDSection(); break;
case CDType::cdC: C.root() = CDSection(); break; case CDType::cdC: C.root() = CDSection(); break;
case CDType::cdM: M.root() = CDSection(); break; case CDType::cdM: M.root() = CDSection(); break;
default: break; default: break;
} }
refresh(); refresh();
} }
void CDView::buildFromHeader(const QString & description, int mode) { void CDView::buildFromHeader(const QString & description, int mode) {
if (description.isEmpty()) return; if (description.isEmpty()) return;
PIString desc_file = Q2PIString(QDir::current().relativeFilePath(description)); PIString desc_file = Q2PIString(QDir::current().relativeFilePath(description));
PIFile f(desc_file, PIIODevice::ReadOnly); PIFile f(desc_file, PIIODevice::ReadOnly);
switch ((CDType::cdT)type_) { switch ((CDType::cdT)type_) {
case CDType::cdK: K.update(&f, mode); break; case CDType::cdK: K.update(&f, mode); break;
case CDType::cdX: X.update(&f, mode); break; case CDType::cdX: X.update(&f, mode); break;
case CDType::cdC: C.update(&f, mode); break; case CDType::cdC: C.update(&f, mode); break;
case CDType::cdM: M.update(&f, mode); break; case CDType::cdM: M.update(&f, mode); break;
default: break; default: break;
} }
refresh(); refresh();
} }
void CDView::calculate() { void CDView::calculate() {
switch ((CDType::cdT)type_) { switch ((CDType::cdT)type_) {
case CDType::cdK: K.calculate(); break; case CDType::cdK: K.calculate(); break;
case CDType::cdX: X.calculate(); break; case CDType::cdX: X.calculate(); break;
case CDType::cdC: C.calculate(); break; case CDType::cdC: C.calculate(); break;
case CDType::cdM: M.calculate(); break; case CDType::cdM: M.calculate(); break;
default: break; default: break;
} }
} }
void CDView::filter(const QString & f) { void CDView::filter(const QString & f) {
proxy_->setFilterRegExp(QRegExp(f, Qt::CaseInsensitive)); proxy_->setFilterRegExp(QRegExp(f, Qt::CaseInsensitive));
} }
void CDView::indexClicked(const QModelIndex & i) { void CDView::indexClicked(const QModelIndex & i) {
if (!model_ || !i.isValid() || type_ != CDType::cdC || i.column() != cName_Cmd) return; if (!model_ || !i.isValid() || type_ != CDType::cdC || i.column() != cName_Cmd) return;
CDItem * item = model_->getItem(i); CDItem * item = model_->getItem(i);
if (!item) return; if (!item) return;
if (item->itemType() != CDItem::ItemCDType) return; if (item->itemType() != CDItem::ItemCDType) return;
CDType & t(model_->interface->section(item->buildPath())[item->index()]); CDType & t(model_->interface->section(item->buildPath())[item->index()]);
C.sendCommand(t); C.sendCommand(t);
emit commandSended(PI2QString(t.pathString().join("."))); emit commandSended(PI2QString(t.pathString().join(".")));
//piCout << t; //piCout << t;
qDebug() << PI2QString(t.pathString().join(".")); qDebug() << PI2QString(t.pathString().join("."));
} }
void CDView::cd_sendFailed() { void CDView::cd_sendFailed() {
busyStatusChanged(false); busyStatusChanged(false);
emit messageStatus("send failed"); emit messageStatus("send failed");
emit sendFailed(); emit sendFailed();
} }
void CDView::cd_sendSucceed() { void CDView::cd_sendSucceed() {
busyStatusChanged(false); busyStatusChanged(false);
emit messageStatus("send success"); emit messageStatus("send success");
emit sendSucceed(); emit sendSucceed();
} }
void CDView::cd_receiveFailed() { void CDView::cd_receiveFailed() {
busyStatusChanged(false); busyStatusChanged(false);
emit messageStatus("receive failed"); emit messageStatus("receive failed");
emit receiveFailed(); emit receiveFailed();
} }
void CDView::cd_receiveSucceed() { void CDView::cd_receiveSucceed() {
refresh(); refresh();
busyStatusChanged(false); busyStatusChanged(false);
emit messageStatus("receive success"); emit messageStatus("receive success");
emit receiveSucceed(); emit receiveSucceed();
} }
void CDView::cd_receivedX() { void CDView::cd_receivedX() {
X.lock(); X.lock();
PIVector<PIDeque<int> > xl = X.enabledList(); PIVector<PIDeque<int> > xl = X.enabledList();
//piCout << "X" << xl.size(); //piCout << "X" << xl.size();
piForeachC (PIDeque<int> & x, xl) { piForeachC (PIDeque<int> & x, xl) {
CDType & t(X[x]); CDType & t(X[x]);
//piCout << t; //piCout << t;
//piCout << t.path(); //piCout << t.path();
if (t.cd_type() != CDType::cdX) continue; if (t.cd_type() != CDType::cdX) continue;
update(model_->indexByPath(t.path(), cValue)); update(model_->indexByPath(t.path(), cValue));
//piCout << CDCore::pathToString(t.path()) << t.toDouble() << "model"; //piCout << CDCore::pathToString(t.path()) << t.toDouble() << "model";
//qDebug() << "val" << model_->data(model_->indexByPath(t.path(), cValue), Qt::DisplayRole).toDouble(); //qDebug() << "val" << model_->data(model_->indexByPath(t.path(), cValue), Qt::DisplayRole).toDouble();
} }
X.unlock(); X.unlock();
emit receivedX(); emit receivedX();
} }
void CDView::cd_changedGlobal() { void CDView::cd_changedGlobal() {
emit changedGlobal(); emit changedGlobal();
} }
void CDView::pi_cd_messageReceived(PIDeque<int> path, int type, PIString msg) { void CDView::pi_cd_messageReceived(PIDeque<int> path, int type, PIString msg) {
QMetaObject::invokeMethod(this, "messageReceived", Qt::QueuedConnection, QMetaObject::invokeMethod(this, "messageReceived", Qt::QueuedConnection,
Q_ARG(QString, PI2QString(CDCore::pathToString(path))), Q_ARG(QString, PI2QString(CDCore::pathToString(path))),
Q_ARG(int, type), Q_ARG(int, type),
Q_ARG(QString, PI2QString(msg))); Q_ARG(QString, PI2QString(msg)));
} }

View File

@@ -1,93 +1,113 @@
#ifndef QCD_VIEW_H /*
#define QCD_VIEW_H QCD Utils - Qt bindings/utilites for CD Utils
#include "piobject.h" Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
#include <QTreeView>
This program is free software: you can redistribute it and/or modify
namespace CDUtils { it under the terms of the GNU Lesser General Public License as published by
class CDType; the Free Software Foundation, either version 3 of the License, or
class CDSection; (at your option) any later version.
}
This program is distributed in the hope that it will be useful,
class CDItemModel; but WITHOUT ANY WARRANTY; without even the implied warranty of
class QSortFilterProxyModel; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
class CDView: public QTreeView, public PIObject
{ You should have received a copy of the GNU Lesser General Public License
Q_OBJECT along with this program. If not, see <http://www.gnu.org/licenses/>.
PIOBJECT(CDView) */
public:
explicit CDView(QWidget *parent = 0); #ifndef QCD_VIEW_H
~CDView(); #define QCD_VIEW_H
void setType(int cdt); #include <QTreeView>
void setFile(const QString & filename); #include "piobject.h"
bool inProgress() const; #include "qcd_utils_export.h"
void startX(double freq = 20.);
CDUtils::CDSection * root(); namespace CDUtils {
QString typeLetter() const; class CDType;
class CDSection;
CDItemModel * CDModel() {return model_;} }
protected: class CDItemModel;
void mousePressEvent(QMouseEvent * ); class QSortFilterProxyModel;
void mouseReleaseEvent(QMouseEvent * );
void currentChanged(const QModelIndex & cur, const QModelIndex & prev); class QCD_UTILS_EXPORT CDView: public QTreeView, public PIObject
{
public slots: Q_OBJECT
void refresh(); PIOBJECT(CDView)
void refreshValues(); public:
void send(); explicit CDView(QWidget *parent = 0);
void receive(); ~CDView();
void save();
void load(); void setType(int cdt);
void clear(); void setFile(const QString & filename);
void buildFromHeader(const QString & description, int mode = 2); bool inProgress() const;
void calculate(); void startX(double freq = 20.);
void filter(const QString & f); CDUtils::CDSection * root();
QString typeLetter() const;
private slots:
void indexClicked(const QModelIndex & i); CDItemModel * CDModel() {return model_;}
void cd_sendFailed();
void cd_sendSucceed(); protected:
void cd_receiveFailed(); void mousePressEvent(QMouseEvent * );
void cd_receiveSucceed(); void mouseReleaseEvent(QMouseEvent * );
void cd_receivedX(); void currentChanged(const QModelIndex & cur, const QModelIndex & prev);
void cd_changedGlobal();
public slots:
private: void refresh();
bool filterTree(const QModelIndex & ti, const QString & filter); void refreshValues();
EVENT_HANDLER(void, pi_cd_sendFailed) {emit _qcd_sendFailed();} void send();
EVENT_HANDLER(void, pi_cd_sendSucceed) {emit _qcd_sendSucceed();} void receive();
EVENT_HANDLER(void, pi_cd_receiveFailed) {emit _qcd_receiveFailed();} void save();
EVENT_HANDLER(void, pi_cd_receiveSucceed) {emit _qcd_receiveSucceed();} void load();
EVENT_HANDLER(void, pi_cd_receivedX) {emit _qcd_receivedX();} void clear();
EVENT_HANDLER(void, pi_cd_changedGlobal) {emit _qcd_changedGlobal();} void buildFromHeader(const QString & description, int mode = 2);
EVENT_HANDLER3(void, pi_cd_messageReceived, PIDeque<int>, path, int, type, PIString, msg); void calculate();
void filter(const QString & f);
CDItemModel * model_;
QSortFilterProxyModel * proxy_; private slots:
int type_; void indexClicked(const QModelIndex & i);
void cd_sendFailed();
signals: void cd_sendSucceed();
void sendFailed(); void cd_receiveFailed();
void sendSucceed(); void cd_receiveSucceed();
void receiveFailed(); void cd_receivedX();
void receiveSucceed(); void cd_changedGlobal();
void receivedX();
void changedGlobal(); private:
void messageStatus(QString msg); bool filterTree(const QModelIndex & ti, const QString & filter);
void commandSended(QString msg); EVENT_HANDLER(void, pi_cd_sendFailed) {emit _qcd_sendFailed();}
void messageReceived(QString path, int type, QString msg); EVENT_HANDLER(void, pi_cd_sendSucceed) {emit _qcd_sendSucceed();}
void busyStatusChanged(bool busy); EVENT_HANDLER(void, pi_cd_receiveFailed) {emit _qcd_receiveFailed();}
EVENT_HANDLER(void, pi_cd_receiveSucceed) {emit _qcd_receiveSucceed();}
void _qcd_sendFailed(); // PRIVATE EVENT_HANDLER(void, pi_cd_receivedX) {emit _qcd_receivedX();}
void _qcd_sendSucceed(); // PRIVATE EVENT_HANDLER(void, pi_cd_changedGlobal) {emit _qcd_changedGlobal();}
void _qcd_receiveFailed(); // PRIVATE EVENT_HANDLER3(void, pi_cd_messageReceived, PIDeque<int>, path, int, type, PIString, msg);
void _qcd_receiveSucceed(); // PRIVATE
void _qcd_receivedX(); // PRIVATE CDItemModel * model_;
void _qcd_changedGlobal(); // PRIVATE QSortFilterProxyModel * proxy_;
int type_;
};
signals:
#endif // QCD_VIEW_H void sendFailed();
void sendSucceed();
void receiveFailed();
void receiveSucceed();
void receivedX();
void changedGlobal();
void messageStatus(QString msg);
void commandSended(QString msg);
void messageReceived(QString path, int type, QString msg);
void busyStatusChanged(bool busy);
void _qcd_sendFailed(); // PRIVATE
void _qcd_sendSucceed(); // PRIVATE
void _qcd_receiveFailed(); // PRIVATE
void _qcd_receiveSucceed(); // PRIVATE
void _qcd_receivedX(); // PRIVATE
void _qcd_changedGlobal(); // PRIVATE
};
#endif // QCD_VIEW_H

View File

@@ -0,0 +1,9 @@
include(PIPMacros)
pip_code_model(CCM "${ROOT_DIR}/pip/libs/main/io_devices/piiodevice.h" "${ROOT_DIR}/pip/libs/main/io_utils/pipacketextractor.h" OPTIONS "-DPIP_EXPORT" "-Es")
piqt_library(piqt_utils "Gui" "qad_utils;qad_widgets;qad_blockview;piqt" ${CCM})
foreach(_v ${_QT_VERSIONS_})
if (LOCAL_FOUND${_v})
add_dependencies(piqt_utils${_v} pip_cmg)
endif()
endforeach()

View File

@@ -1,8 +1,29 @@
/*
PIQt Utils - Qt utilites for PIP
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
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/>.
*/
#ifndef CONNECTION_EDIT_H #ifndef CONNECTION_EDIT_H
#define CONNECTION_EDIT_H #define CONNECTION_EDIT_H
#include <QDialog> #include <QDialog>
#include "piconnection.h" #include "piconnection.h"
#include "piqt_utils_export.h"
namespace Ui { namespace Ui {
class ConnectionEdit; class ConnectionEdit;
@@ -12,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

@@ -74,7 +74,7 @@ void FilterItem::rename() {
piForeachC (PICodeInfo::EnumeratorInfo & i, ei->members) piForeachC (PICodeInfo::EnumeratorInfo & i, ei->members)
if (i.value == mode()) { if (i.value == mode()) {
ms = PI2QString(i.name); ms = PI2QString(i.name);
piBreak; break;
} }
} }
text_mode->setText(ms); text_mode->setText(ms);

View File

@@ -1,15 +1,35 @@
/*
PIQt Utils - Qt utilites for PIP
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
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/>.
*/
#ifndef CONNECTION_VIEW_H #ifndef CONNECTION_VIEW_H
#define CONNECTION_VIEW_H #define CONNECTION_VIEW_H
#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();
@@ -35,7 +55,7 @@ protected:
}; };
class FilterItem: public BlockItem { class PIQT_UTILS_EXPORT FilterItem: public BlockItem {
public: public:
FilterItem(); FilterItem();
@@ -65,7 +85,7 @@ protected:
}; };
class SenderItem: public BlockItem { class PIQT_UTILS_EXPORT SenderItem: public BlockItem {
public: public:
SenderItem(); SenderItem();
@@ -85,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

@@ -0,0 +1,51 @@
/*
PIQt Utils - Qt utilites for PIP
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
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/>.
*/
#ifndef CONF_HIGHLIGHTER_H
#define CONF_HIGHLIGHTER_H
#include <QSyntaxHighlighter>
#include <QTextCursor>
#include <QTextCharFormat>
#include "piqt_utils_export.h"
class QTextDocument;
class PIQT_UTILS_EXPORT ConfigHighlighter : public QSyntaxHighlighter
{
Q_OBJECT
public:
ConfigHighlighter(QTextDocument *parent = 0);
QTextCursor cursor;
private:
void highlightBlock(const QString &text);
struct PIQT_UTILS_EXPORT HighlightingRule {
QRegExp pattern;
QTextCharFormat format;
};
QVector<HighlightingRule> highlightingRules;
QRegExp commentStartExpression, commentEndExpression;
QTextCharFormat singleLineCommentFormat, valueNameFormat, valueFormat, equalFormat, sectionFormat, spaceFormat, substFormat;
};
#endif // CONF_HIGHTLIGHTER_H

View File

@@ -0,0 +1,74 @@
/*
PIQt Utils - Qt utilites for PIP
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
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/>.
*/
#ifndef PIQT_IODEVICE_EDIT_H
#define PIQT_IODEVICE_EDIT_H
#include <QWidget>
#include "qad_types.h"
#include "piqt_utils_export.h"
class QLineEdit;
class QToolButton;
class IODeviceEditDialog;
class PIQT_UTILS_EXPORT IODeviceEdit: public QWidget {
Q_OBJECT
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
public:
explicit IODeviceEdit(QWidget * parent = 0);
~IODeviceEdit();
QVariant value() const;
bool isReadOnly() const;
private:
void setDevice(const QAD::IODevice & d);
QLineEdit * line;
QToolButton * btn;
IODeviceEditDialog * dlg;
QAD::IODevice dev;
public slots:
void setValue(const QVariant & v);
void setReadOnly(bool yes);
private slots:
void buttonDlg_clicked();
signals:
void valueChanged();
};
class PIQT_UTILS_EXPORT __IODeviceEditRegistrator__ {
public:
__IODeviceEditRegistrator__();
};
static __IODeviceEditRegistrator__ __iodeviceeditregistrator__;
PIQT_UTILS_EXPORT void QAD_IODevice_toString(const QVariant & v, QString & r);
#endif // PIQT_IODEVICE_EDIT_H

View File

@@ -0,0 +1,54 @@
/*
PIQt Utils - Qt utilites for PIP
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
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/>.
*/
#ifndef PIQT_IODEVICE_EDIT_DIALOG_H
#define PIQT_IODEVICE_EDIT_DIALOG_H
#include <QDialog>
#include "qad_types.h"
#include "propertystorage.h"
#include "piqt_utils_export.h"
namespace Ui {
class IODeviceEditDialog;
}
class PIQT_UTILS_EXPORT IODeviceEditDialog: public QDialog {
Q_OBJECT
public:
explicit IODeviceEditDialog(QWidget * parent = 0);
~IODeviceEditDialog();
QAD::IODevice getIODevice(const QAD::IODevice & d);
private:
QAD::IODevice value() const;
void setValue(const QAD::IODevice & d);
int getOptions() const;
void setOptions(int o);
PropertyStorage ps;
Ui::IODeviceEditDialog * ui;
private slots:
void on_comboType_currentIndexChanged(int index);
};
#endif // PIQT_IODEVICE_EDIT_DIALOG_H

View File

@@ -0,0 +1 @@
add_directories("piqt_")

View File

@@ -0,0 +1,14 @@
project(cd_pult)
if(APPLE)
set(APP_ICON "")
elseif(WIN32)
set(APP_ICON "")
else()
set(APP_ICON "")
endif()
set(APP_INFO "CD Pult")
piqt_application(${PROJECT_NAME} "Gui;Widgets" "qad_utils;qad_widgets;qad_graphic;qad_application;qcd_utils;piqt_utils")
if (Qt5_FOUND)
import_version(${PROJ_NAME}5 ${PROJECT_NAME})
deploy_target(${PROJECT_NAME}5 DEPLOY_DIR ${CMAKE_CURRENT_BINARY_DIR} DESTINATION ${ROOT_DIR}/release)
endif()

View File

@@ -1,312 +1,312 @@
#include "cddirectk.h" #include "cddirectk.h"
#include "ui_cddirectk_type_dialog.h" #include "ui_cddirectk_type_dialog.h"
#include "cdutils_core.h" #include "cdutils_core.h"
#include "cdutils_k.h" #include "cdutils_k.h"
#include "qcd_core.h" #include "qcd_core.h"
#include "qcd_model.h" #include "qcd_model.h"
#include "graphic.h" #include "graphic.h"
#include "piqt.h" #include "piqt.h"
#include "qvariantedit.h" #include "qvariantedit.h"
#include <QFormLayout> #include <QFormLayout>
#include <QMimeData> #include <QMimeData>
#include <QDragEnterEvent> #include <QDragEnterEvent>
#include <QDragMoveEvent> #include <QDragMoveEvent>
#include <QDropEvent> #include <QDropEvent>
#include <QMainWindow> #include <QMainWindow>
#include <QDockWidget> #include <QDockWidget>
#include <QInputDialog> #include <QInputDialog>
using namespace CDUtils; using namespace CDUtils;
KDockWidget::KDockWidget(QString title, QMainWindow * p): QDockWidget(title, p) { KDockWidget::KDockWidget(QString title, QMainWindow * p): QDockWidget(title, p) {
da = p; da = p;
menu = new QMenu(this); menu = new QMenu(this);
QAction * a = new QAction(QIcon(":/icons/document-edit.png"), "Rename ...", this); QAction * a = new QAction(QIcon(":/icons/document-edit.png"), "Rename ...", this);
connect(a, SIGNAL(triggered(bool)), this, SLOT(rename())); connect(a, SIGNAL(triggered(bool)), this, SLOT(rename()));
dactions << a; dactions << a;
a = new QAction(QIcon(":/icons/edit-delete.png"), "Remove", this); a = new QAction(QIcon(":/icons/edit-delete.png"), "Remove", this);
connect(a, SIGNAL(triggered(bool)), this, SIGNAL(removeRequest())); connect(a, SIGNAL(triggered(bool)), this, SIGNAL(removeRequest()));
dactions << a; dactions << a;
menu_k = new QMenu(this); menu_k = new QMenu(this);
menu_k->setTitle(tr("Remove K")); menu_k->setTitle(tr("Remove K"));
lay = new QFormLayout(); lay = new QFormLayout();
lay->setContentsMargins(0, qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin), 0, 0); lay->setContentsMargins(0, qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin), 0, 0);
lay->setLabelAlignment(Qt::AlignRight | Qt::AlignVCenter); lay->setLabelAlignment(Qt::AlignRight | Qt::AlignVCenter);
QWidget * w = new QWidget(); QWidget * w = new QWidget();
w->setAcceptDrops(true); w->setAcceptDrops(true);
w->installEventFilter(this); w->installEventFilter(this);
w->setLayout(lay); w->setLayout(lay);
setWidget(w); setWidget(w);
type_dialog = new CDDirectKTypeDialog(); type_dialog = new CDDirectKTypeDialog();
} }
void KDockWidget::addK(const CDType & t, CDDirectKTypeDialog::TypeInfo ti) { void KDockWidget::addK(const CDType & t, CDDirectKTypeDialog::TypeInfo ti) {
if (t.cd_type() != CDType::cdK) return; if (t.cd_type() != CDType::cdK) return;
PIDeque<int> xp = t.path(); PIDeque<int> xp = t.path();
if (k_list.contains(xp)) return; if (k_list.contains(xp)) return;
k_list << xp; k_list << xp;
info_list << ti; info_list << ti;
//piCout << "add" << xp; //piCout << "add" << xp;
QWidget * ve = ti.create(); QWidget * ve = ti.create();
//qDebug() << "add" << ve; //qDebug() << "add" << ve;
lay->addRow(PI2QString(t.pathString().join(".")) + ":", ve); lay->addRow(PI2QString(t.pathString().join(".")) + ":", ve);
QCDCore::instance()->bindWidget(ve, t); QCDCore::instance()->bindWidget(ve, t);
//ve->setValue(); //ve->setValue();
} }
QByteArray KDockWidget::save() const { QByteArray KDockWidget::save() const {
ChunkStream cs; ChunkStream cs;
cs.add(1, windowTitle()) cs.add(1, windowTitle())
.add(2, getList(k_list)) .add(2, getList(k_list))
.add(3, info_list); .add(3, info_list);
return cs.data(); return cs.data();
} }
void KDockWidget::load(QByteArray ba) { void KDockWidget::load(QByteArray ba) {
clear(); clear();
if (ba.isEmpty()) return; if (ba.isEmpty()) return;
ChunkStream cs(ba); ChunkStream cs(ba);
PIVector<PIDeque<int> > list; PIVector<PIDeque<int> > list;
QVector<CDDirectKTypeDialog::TypeInfo> ilist; QVector<CDDirectKTypeDialog::TypeInfo> ilist;
while (!cs.atEnd()) { while (!cs.atEnd()) {
switch (cs.read()) { switch (cs.read()) {
case 1: setWindowTitle(cs.getData<QString>()); break; case 1: setWindowTitle(cs.getData<QString>()); break;
case 2: list = setList(cs.getData<QStringList>()); break; case 2: list = setList(cs.getData<QStringList>()); break;
case 3: ilist = cs.getData<QVector<CDDirectKTypeDialog::TypeInfo> >(); break; case 3: ilist = cs.getData<QVector<CDDirectKTypeDialog::TypeInfo> >(); break;
default: break; default: break;
} }
} }
ilist.resize(list.size()); ilist.resize(list.size());
for (int i = 0; i < list.size_s(); ++i) { for (int i = 0; i < list.size_s(); ++i) {
addK(K[list[i]], ilist[i]); addK(K[list[i]], ilist[i]);
} }
} }
void KDockWidget::clear() { void KDockWidget::clear() {
while (lay->rowCount() > 0) while (lay->rowCount() > 0)
removeRow(0); removeRow(0);
k_list.clear(); k_list.clear();
info_list.clear(); info_list.clear();
} }
void KDockWidget::changedGlobal() { void KDockWidget::changedGlobal() {
//piCout << "changedGlobal ..." << k_list.size_s() << info_list.size() << lay->count() << lay->rowCount(); //piCout << "changedGlobal ..." << k_list.size_s() << info_list.size() << lay->count() << lay->rowCount();
for (int i = 0; i < k_list.size_s(); ++i) { for (int i = 0; i < k_list.size_s(); ++i) {
//piCout << "update" << i << "0"; //piCout << "update" << i << "0";
if (!K.exists(k_list[i])) { if (!K.exists(k_list[i])) {
k_list.remove(i); k_list.remove(i);
info_list.remove(i); info_list.remove(i);
removeRow(i); removeRow(i);
--i; --i;
continue; continue;
} }
//piCout << "update" << i << "1"; //piCout << "update" << i << "1";
QLabel * lbl = qobject_cast<QLabel*>(lay->itemAt(i, QFormLayout::LabelRole)->widget()); QLabel * lbl = qobject_cast<QLabel*>(lay->itemAt(i, QFormLayout::LabelRole)->widget());
//piCout << "update" << i << "2"; //piCout << "update" << i << "2";
if (lbl) lbl->setText(PI2QString(K[k_list[i]].pathString().join(".")) + ":"); if (lbl) lbl->setText(PI2QString(K[k_list[i]].pathString().join(".")) + ":");
//piCout << "update" << i << "3"; //piCout << "update" << i << "3";
} }
//piCout << "changedGlobal ok"; //piCout << "changedGlobal ok";
} }
bool KDockWidget::eventFilter(QObject * o, QEvent * e) { bool KDockWidget::eventFilter(QObject * o, QEvent * e) {
//if (o == graphic->viewport()) { //if (o == graphic->viewport()) {
switch (e->type()) { switch (e->type()) {
case QEvent::DragMove: { case QEvent::DragMove: {
QDragMoveEvent * de = (QDragMoveEvent*)e; QDragMoveEvent * de = (QDragMoveEvent*)e;
const QMimeData * mime = de->mimeData(); const QMimeData * mime = de->mimeData();
if (!mime) break; if (!mime) break;
if (!mime->text().startsWith("k")) break; if (!mime->text().startsWith("k")) break;
de->setDropAction(Qt::CopyAction); de->setDropAction(Qt::CopyAction);
de->accept(); de->accept();
return true; return true;
} break; } break;
case QEvent::DragEnter: { case QEvent::DragEnter: {
QDragEnterEvent * de = (QDragEnterEvent*)e; QDragEnterEvent * de = (QDragEnterEvent*)e;
const QMimeData * mime = de->mimeData(); const QMimeData * mime = de->mimeData();
if (!mime) break; if (!mime) break;
if (!mime->text().startsWith("k")) break; if (!mime->text().startsWith("k")) break;
de->setDropAction(Qt::CopyAction); de->setDropAction(Qt::CopyAction);
de->accept(); de->accept();
return true; return true;
} break; } break;
case QEvent::Drop: { case QEvent::Drop: {
QDropEvent * de = (QDropEvent*)e; QDropEvent * de = (QDropEvent*)e;
const QMimeData * mime = de->mimeData(); const QMimeData * mime = de->mimeData();
if (!mime) break; if (!mime) break;
//qDebug() << "drop" << mime->text(); //qDebug() << "drop" << mime->text();
if (!mime->text().startsWith("k")) break; if (!mime->text().startsWith("k")) break;
CDDirectKTypeDialog::TypeInfo ti; CDDirectKTypeDialog::TypeInfo ti;
CDType & k(K[CDCore::stringToPath(Q2PIString(mime->text().mid(1)))]); CDType & k(K[CDCore::stringToPath(Q2PIString(mime->text().mid(1)))]);
if (k.type().left(1) == "n" || k.type().left(1) == "f") { if (k.type().left(1) == "n" || k.type().left(1) == "f") {
if (type_dialog->exec() == QDialog::Accepted) if (type_dialog->exec() == QDialog::Accepted)
ti = type_dialog->getType(); ti = type_dialog->getType();
else else
return true; return true;
} }
addK(k, ti); addK(k, ti);
de->accept(); de->accept();
return true; return true;
} break; } break;
default: break; default: break;
} }
//} //}
return QWidget::eventFilter(o, e); return QWidget::eventFilter(o, e);
} }
void KDockWidget::contextMenuEvent(QContextMenuEvent * e) { void KDockWidget::contextMenuEvent(QContextMenuEvent * e) {
qDeleteAll(menu_k->actions()); qDeleteAll(menu_k->actions());
menu_k->clear(); menu_k->clear();
for (int i = 0; i < k_list.size_s(); ++i) { for (int i = 0; i < k_list.size_s(); ++i) {
QAction * a = new QAction(PI2QString(K[k_list[i]].pathString().join(".")), this); QAction * a = new QAction(PI2QString(K[k_list[i]].pathString().join(".")), this);
a->setData(i); a->setData(i);
connect(a, SIGNAL(triggered(bool)), this, SLOT(removeK())); connect(a, SIGNAL(triggered(bool)), this, SLOT(removeK()));
menu_k->addAction(a); menu_k->addAction(a);
} }
QMenu * mwm = da->createPopupMenu(); QMenu * mwm = da->createPopupMenu();
menu->clear(); menu->clear();
menu->addActions(dactions); menu->addActions(dactions);
menu->addMenu(menu_k); menu->addMenu(menu_k);
menu->addSeparator(); menu->addSeparator();
menu->addActions(mwm->actions()); menu->addActions(mwm->actions());
menu->popup(e->globalPos()); menu->popup(e->globalPos());
mwm->deleteLater(); mwm->deleteLater();
} }
void KDockWidget::removeRow(int r) { void KDockWidget::removeRow(int r) {
if (r < 0 || r >= lay->rowCount()) return; if (r < 0 || r >= lay->rowCount()) return;
#if QT_VERSION >= 0x050800 #if QT_VERSION >= 0x050800
QFormLayout::TakeRowResult rr = lay->takeRow(r); QFormLayout::TakeRowResult rr = lay->takeRow(r);
if (rr.fieldItem) {delete rr.fieldItem->widget(); delete rr.fieldItem;} if (rr.fieldItem) {delete rr.fieldItem->widget(); delete rr.fieldItem;}
if (rr.labelItem) {delete rr.labelItem->widget(); delete rr.labelItem;} if (rr.labelItem) {delete rr.labelItem->widget(); delete rr.labelItem;}
#else #else
piForTimes (2) { piForTimes (2) {
QLayoutItem * i = lay->itemAt(r+r); QLayoutItem * i = lay->itemAt(r+r);
lay->removeItem(i); lay->removeItem(i);
if (i) {delete i->widget(); delete i;} if (i) {delete i->widget(); delete i;}
} }
#endif #endif
} }
void KDockWidget::rename() { void KDockWidget::rename() {
QString nn = QInputDialog::getText(this, tr("Rename area"), tr("New area name:"), QString nn = QInputDialog::getText(this, tr("Rename area"), tr("New area name:"),
QLineEdit::Normal, windowTitle()); QLineEdit::Normal, windowTitle());
if (nn.isEmpty()) return; if (nn.isEmpty()) return;
setWindowTitle(nn); setWindowTitle(nn);
} }
void KDockWidget::removeK() { void KDockWidget::removeK() {
QAction * a = qobject_cast<QAction * >(sender()); QAction * a = qobject_cast<QAction * >(sender());
if (!a) return; if (!a) return;
int ind = a->data().toInt(); int ind = a->data().toInt();
if (ind < 0 || ind >= k_list.size_s()) return; if (ind < 0 || ind >= k_list.size_s()) return;
k_list.remove(ind); k_list.remove(ind);
if (ind >= 0 && ind < info_list.size()) if (ind >= 0 && ind < info_list.size())
info_list.remove(ind); info_list.remove(ind);
removeRow(ind); removeRow(ind);
} }
CDDirectK::CDDirectK(QWidget * parent) : QWidget(parent), Ui::CDDirectK() { CDDirectK::CDDirectK(QWidget * parent) : QWidget(parent), Ui::CDDirectK() {
setupUi(this); setupUi(this);
da = new QMainWindow(); da = new QMainWindow();
da->setWindowFlags(frame->windowFlags()); da->setWindowFlags(frame->windowFlags());
da->setDockNestingEnabled(true); da->setDockNestingEnabled(true);
layoutMain->addWidget(da); layoutMain->addWidget(da);
} }
CDDirectK::~CDDirectK() { CDDirectK::~CDDirectK() {
} }
void CDDirectK::reset() { void CDDirectK::reset() {
qDeleteAll(docks); qDeleteAll(docks);
docks.clear(); docks.clear();
} }
QByteArray CDDirectK::save() const { QByteArray CDDirectK::save() const {
ChunkStream cs; ChunkStream cs;
QVector<QByteArray> dstates; QVector<QByteArray> dstates;
foreach (KDockWidget * d, docks) { foreach (KDockWidget * d, docks) {
dstates << d->save(); dstates << d->save();
} }
cs.add(1, docks.size()) cs.add(1, docks.size())
.add(2, dstates) .add(2, dstates)
.add(3, da->saveState()); .add(3, da->saveState());
return cs.data(); return cs.data();
} }
void CDDirectK::load(QByteArray ba) { void CDDirectK::load(QByteArray ba) {
reset(); reset();
if (ba.isEmpty()) return; if (ba.isEmpty()) return;
ChunkStream cs(ba); ChunkStream cs(ba);
while (!cs.atEnd()) { while (!cs.atEnd()) {
switch (cs.read()) { switch (cs.read()) {
case 1: { case 1: {
int s = cs.getData<int>(); int s = cs.getData<int>();
piForTimes (s) piForTimes (s)
addArea(); addArea();
} break; } break;
case 2: { case 2: {
QVector<QByteArray> dstates = cs.getData<QVector<QByteArray> >(); QVector<QByteArray> dstates = cs.getData<QVector<QByteArray> >();
for (int i = 0; i < piMini(dstates.size(), docks.size()); ++i) for (int i = 0; i < piMini(dstates.size(), docks.size()); ++i)
docks[i]->load(dstates[i]); docks[i]->load(dstates[i]);
} break; } break;
case 3: da->restoreState(cs.getData<QByteArray>()); break; case 3: da->restoreState(cs.getData<QByteArray>()); break;
default: break; default: break;
} }
} }
} }
void CDDirectK::addArea() { void CDDirectK::addArea() {
KDockWidget * dw = new KDockWidget(QString("area %1").arg(docks.size()), da); KDockWidget * dw = new KDockWidget(QString("area %1").arg(docks.size()), da);
connect(dw, SIGNAL(removeRequest()), this, SLOT(removeArea())); connect(dw, SIGNAL(removeRequest()), this, SLOT(removeArea()));
da->addDockWidget(Qt::RightDockWidgetArea, dw); da->addDockWidget(Qt::RightDockWidgetArea, dw);
docks << dw; docks << dw;
for (int i = 0; i < docks.size(); ++i) for (int i = 0; i < docks.size(); ++i)
docks[i]->setObjectName(QString("dock_%1").arg(i)); docks[i]->setObjectName(QString("dock_%1").arg(i));
} }
void CDDirectK::changedGlobal() { void CDDirectK::changedGlobal() {
foreach (KDockWidget * d, docks) foreach (KDockWidget * d, docks)
d->changedGlobal(); d->changedGlobal();
} }
void CDDirectK::removeArea() { void CDDirectK::removeArea() {
KDockWidget * d = qobject_cast<KDockWidget * >(sender()); KDockWidget * d = qobject_cast<KDockWidget * >(sender());
if (!d) return; if (!d) return;
docks.removeAll(d); docks.removeAll(d);
d->deleteLater(); d->deleteLater();
for (int i = 0; i < docks.size(); ++i) for (int i = 0; i < docks.size(); ++i)
docks[i]->setObjectName(QString("dock_%1").arg(i)); docks[i]->setObjectName(QString("dock_%1").arg(i));
} }
void CDDirectK::on_buttonAdd_clicked() { void CDDirectK::on_buttonAdd_clicked() {
addArea(); addArea();
} }
void CDDirectK::on_buttonRemoveAll_clicked() { void CDDirectK::on_buttonRemoveAll_clicked() {
qDeleteAll(docks); qDeleteAll(docks);
docks.clear(); docks.clear();
} }

View File

@@ -1,77 +1,77 @@
#ifndef CDDIRECTK_H #ifndef CDDIRECTK_H
#define CDDIRECTK_H #define CDDIRECTK_H
#include "cdgraphics.h" #include "cdgraphics.h"
#include "ui_cddirectk.h" #include "ui_cddirectk.h"
#include "cddirectk_type_dialog.h" #include "cddirectk_type_dialog.h"
class QFormLayout; class QFormLayout;
class KDockWidget: public QDockWidget { class KDockWidget: public QDockWidget {
Q_OBJECT Q_OBJECT
public: public:
KDockWidget(QString title = QString(), QMainWindow * p = 0); KDockWidget(QString title = QString(), QMainWindow * p = 0);
void addK(const CDUtils::CDType & t, CDDirectKTypeDialog::TypeInfo ti); void addK(const CDUtils::CDType & t, CDDirectKTypeDialog::TypeInfo ti);
QByteArray save() const; QByteArray save() const;
void load(QByteArray ba); void load(QByteArray ba);
void clear(); void clear();
void changedGlobal(); void changedGlobal();
QFormLayout * lay; QFormLayout * lay;
private: private:
bool eventFilter(QObject * o, QEvent * e); bool eventFilter(QObject * o, QEvent * e);
void contextMenuEvent(QContextMenuEvent * e); void contextMenuEvent(QContextMenuEvent * e);
void removeRow(int r); void removeRow(int r);
QMenu * menu, * menu_k; QMenu * menu, * menu_k;
QList<QAction*> dactions; QList<QAction*> dactions;
QMainWindow * da; QMainWindow * da;
CDDirectKTypeDialog * type_dialog; CDDirectKTypeDialog * type_dialog;
PIVector<PIDeque<int> > k_list; PIVector<PIDeque<int> > k_list;
QVector<CDDirectKTypeDialog::TypeInfo> info_list; QVector<CDDirectKTypeDialog::TypeInfo> info_list;
private slots: private slots:
void rename(); void rename();
void removeK(); void removeK();
signals: signals:
void removeRequest(); void removeRequest();
}; };
class CDDirectK: public QWidget, public Ui::CDDirectK class CDDirectK: public QWidget, public Ui::CDDirectK
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CDDirectK(QWidget *parent = 0); explicit CDDirectK(QWidget *parent = 0);
~CDDirectK(); ~CDDirectK();
void reset(); void reset();
QByteArray save() const; QByteArray save() const;
void load(QByteArray ba); void load(QByteArray ba);
private: private:
void addArea(); void addArea();
QList<KDockWidget * > docks; QList<KDockWidget * > docks;
QMainWindow * da; QMainWindow * da;
public slots: public slots:
void changedGlobal(); void changedGlobal();
private slots: private slots:
void removeArea(); void removeArea();
void on_buttonAdd_clicked(); void on_buttonAdd_clicked();
void on_buttonRemoveAll_clicked(); void on_buttonRemoveAll_clicked();
signals: signals:
}; };
#endif // CDDIRECTK_H #endif // CDDIRECTK_H

View File

@@ -1,85 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>CDDirectK</class> <class>CDDirectK</class>
<widget class="QWidget" name="CDDirectK"> <widget class="QWidget" name="CDDirectK">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>624</width> <width>624</width>
<height>411</height> <height>411</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>CD Pult</string> <string>CD Pult</string>
</property> </property>
<layout class="QVBoxLayout" name="layoutMain" stretch="0"> <layout class="QVBoxLayout" name="layoutMain" stretch="0">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QFrame" name="frame"> <widget class="QFrame" name="frame">
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::StyledPanel</enum>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QToolButton" name="buttonAdd"> <widget class="QToolButton" name="buttonAdd">
<property name="toolTip"> <property name="toolTip">
<string>Add new</string> <string>Add new</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../qad/application/qad_application.qrc"> <iconset resource="../../qad/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>
</item> </item>
<item> <item>
<widget class="QToolButton" name="buttonRemoveAll"> <widget class="QToolButton" name="buttonRemoveAll">
<property name="toolTip"> <property name="toolTip">
<string>Remove all</string> <string>Remove all</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../qad/application/qad_application.qrc"> <iconset resource="../../qad/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>
</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="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>1</width> <width>1</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="../../qad/application/qad_application.qrc"/> <include location="../../qad/application/qad_application.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View File

@@ -1,76 +1,76 @@
#include "cddirectk_type_dialog.h" #include "cddirectk_type_dialog.h"
#include "cdutils_core.h" #include "cdutils_core.h"
#include "qcd_core.h" #include "qcd_core.h"
#include "qcd_model.h" #include "qcd_model.h"
#include "piqt.h" #include "piqt.h"
#include "spinslider.h" #include "spinslider.h"
#include "qvariantedit.h" #include "qvariantedit.h"
CDDirectKTypeDialog::CDDirectKTypeDialog(QWidget * parent) : QDialog(parent), Ui::CDDirectKTypeDialog() { CDDirectKTypeDialog::CDDirectKTypeDialog(QWidget * parent) : QDialog(parent), Ui::CDDirectKTypeDialog() {
setupUi(this); setupUi(this);
} }
CDDirectKTypeDialog::~CDDirectKTypeDialog() { CDDirectKTypeDialog::~CDDirectKTypeDialog() {
} }
CDDirectKTypeDialog::TypeInfo CDDirectKTypeDialog::getType() const { CDDirectKTypeDialog::TypeInfo CDDirectKTypeDialog::getType() const {
if (!groupBox->isChecked()) return TypeInfo(); if (!groupBox->isChecked()) return TypeInfo();
TypeInfo ret; TypeInfo ret;
ret.type = comboType->currentIndex(); ret.type = comboType->currentIndex();
ret.params_d[0] = evalMin->value(); ret.params_d[0] = evalMin->value();
ret.params_d[1] = evalMax->value(); ret.params_d[1] = evalMax->value();
ret.params_d[2] = spinDecimals->value(); ret.params_d[2] = spinDecimals->value();
ret.params_d[3] = evalStep->value(); ret.params_d[3] = evalStep->value();
ret.params_s[0] = linePrefix->text(); ret.params_s[0] = linePrefix->text();
ret.params_s[1] = lineSuffix->text(); ret.params_s[1] = lineSuffix->text();
return ret; return ret;
} }
CDDirectKTypeDialog::TypeInfo::TypeInfo(int type_) { CDDirectKTypeDialog::TypeInfo::TypeInfo(int type_) {
type = type_; type = type_;
params_d.resize(4); params_d.resize(4);
params_s.resize(2); params_s.resize(2);
} }
QWidget * CDDirectKTypeDialog::TypeInfo::create() { QWidget * CDDirectKTypeDialog::TypeInfo::create() {
params_d.resize(4); params_d.resize(4);
params_s.resize(2); params_s.resize(2);
switch (type) { switch (type) {
case 0: { case 0: {
QDoubleSpinBox * ret = new QDoubleSpinBox(); QDoubleSpinBox * ret = new QDoubleSpinBox();
ret->setMinimum(params_d[0]); ret->setMinimum(params_d[0]);
ret->setMaximum(params_d[1]); ret->setMaximum(params_d[1]);
ret->setDecimals(params_d[2]); ret->setDecimals(params_d[2]);
ret->setSingleStep(params_d[3]); ret->setSingleStep(params_d[3]);
ret->setPrefix(params_s[0]); ret->setPrefix(params_s[0]);
ret->setSuffix(params_s[1]); ret->setSuffix(params_s[1]);
return ret; return ret;
} break; } break;
case 1: { case 1: {
QSlider * ret = new QSlider(Qt::Horizontal); QSlider * ret = new QSlider(Qt::Horizontal);
ret->setMinimum(params_d[0]); ret->setMinimum(params_d[0]);
ret->setMaximum(params_d[1]); ret->setMaximum(params_d[1]);
ret->setSingleStep(params_d[3]); ret->setSingleStep(params_d[3]);
return ret; return ret;
} break; } break;
case 2: { case 2: {
SpinSlider * ret = new SpinSlider(); SpinSlider * ret = new SpinSlider();
ret->setMinimum(params_d[0]); ret->setMinimum(params_d[0]);
ret->setMaximum(params_d[1]); ret->setMaximum(params_d[1]);
ret->setDecimals(params_d[2]); ret->setDecimals(params_d[2]);
ret->setSingleStep(params_d[3]); ret->setSingleStep(params_d[3]);
ret->setPrefix(params_s[0]); ret->setPrefix(params_s[0]);
ret->setSuffix(params_s[1]); ret->setSuffix(params_s[1]);
return ret; return ret;
} break; } break;
default: break; default: break;
} }
return new QVariantEdit(); return new QVariantEdit();
} }

View File

@@ -1,44 +1,44 @@
#ifndef CDDIRECTK_TYPE_DIALOG_H #ifndef CDDIRECTK_TYPE_DIALOG_H
#define CDDIRECTK_TYPE_DIALOG_H #define CDDIRECTK_TYPE_DIALOG_H
#include <QDialog> #include <QDialog>
#include "ui_cddirectk_type_dialog.h" #include "ui_cddirectk_type_dialog.h"
class CDDirectKTypeDialog: public QDialog, public Ui::CDDirectKTypeDialog class CDDirectKTypeDialog: public QDialog, public Ui::CDDirectKTypeDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CDDirectKTypeDialog(QWidget * parent = 0); explicit CDDirectKTypeDialog(QWidget * parent = 0);
~CDDirectKTypeDialog(); ~CDDirectKTypeDialog();
struct TypeInfo { struct TypeInfo {
TypeInfo(int type_ = -1); TypeInfo(int type_ = -1);
QWidget * create(); QWidget * create();
int type; int type;
QVector<double> params_d; QVector<double> params_d;
QVector<QString> params_s; QVector<QString> params_s;
}; };
TypeInfo getType() const; TypeInfo getType() const;
private: private:
public slots: public slots:
private slots: private slots:
signals: signals:
}; };
inline QDataStream & operator <<(QDataStream & s, const CDDirectKTypeDialog::TypeInfo & v) { inline QDataStream & operator <<(QDataStream & s, const CDDirectKTypeDialog::TypeInfo & v) {
s << v.type << v.params_d << v.params_s; s << v.type << v.params_d << v.params_s;
return s; return s;
} }
inline QDataStream & operator >>(QDataStream & s, CDDirectKTypeDialog::TypeInfo & v) { inline QDataStream & operator >>(QDataStream & s, CDDirectKTypeDialog::TypeInfo & v) {
s >> v.type >> v.params_d >> v.params_s; s >> v.type >> v.params_d >> v.params_s;
return s; return s;
} }
#endif // CDDIRECTK_TYPE_DIALOG_H #endif // CDDIRECTK_TYPE_DIALOG_H

View File

@@ -1,232 +1,232 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>CDDirectKTypeDialog</class> <class>CDDirectKTypeDialog</class>
<widget class="QDialog" name="CDDirectKTypeDialog"> <widget class="QDialog" name="CDDirectKTypeDialog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>275</width> <width>275</width>
<height>310</height> <height>310</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>CD Pult</string> <string>CD Pult</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string>Custom</string> <string>Custom</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QWidget" name="widget" native="true"> <widget class="QWidget" name="widget" native="true">
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy"> <property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum> <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property> </property>
<property name="labelAlignment"> <property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Type:</string> <string>Type:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="comboType"> <widget class="QComboBox" name="comboType">
<item> <item>
<property name="text"> <property name="text">
<string>Spin</string> <string>Spin</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Slider</string> <string>Slider</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>SpinSlider</string> <string>SpinSlider</string>
</property> </property>
</item> </item>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Min:</string> <string>Min:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="EvalSpinBox" name="evalMin"/> <widget class="EvalSpinBox" name="evalMin"/>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Max:</string> <string>Max:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="EvalSpinBox" name="evalMax"> <widget class="EvalSpinBox" name="evalMax">
<property name="value"> <property name="value">
<double>100.000000000000000</double> <double>100.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="text"> <property name="text">
<string>Decimals:</string> <string>Decimals:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QSpinBox" name="spinDecimals"/> <widget class="QSpinBox" name="spinDecimals"/>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
<string>Single step:</string> <string>Single step:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="4" column="1">
<widget class="EvalSpinBox" name="evalStep"> <widget class="EvalSpinBox" name="evalStep">
<property name="value"> <property name="value">
<double>1.000000000000000</double> <double>1.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="5" column="0">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="text"> <property name="text">
<string>Prefix:</string> <string>Prefix:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="5" column="1">
<widget class="CLineEdit" name="linePrefix"/> <widget class="CLineEdit" name="linePrefix"/>
</item> </item>
<item row="6" column="0"> <item row="6" column="0">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
<property name="text"> <property name="text">
<string>Suffix:</string> <string>Suffix:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="6" column="1">
<widget class="CLineEdit" name="lineSuffix"/> <widget class="CLineEdit" name="lineSuffix"/>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</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>1</height> <height>1</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<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>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>CLineEdit</class> <class>CLineEdit</class>
<extends>QLineEdit</extends> <extends>QLineEdit</extends>
<header>clineedit.h</header> <header>clineedit.h</header>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>EvalSpinBox</class> <class>EvalSpinBox</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header>evalspinbox.h</header> <header>evalspinbox.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections> <connections>
<connection> <connection>
<sender>groupBox</sender> <sender>groupBox</sender>
<signal>toggled(bool)</signal> <signal>toggled(bool)</signal>
<receiver>widget</receiver> <receiver>widget</receiver>
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>86</x> <x>86</x>
<y>49</y> <y>49</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>94</x> <x>94</x>
<y>91</y> <y>91</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>accepted()</signal> <signal>accepted()</signal>
<receiver>CDDirectKTypeDialog</receiver> <receiver>CDDirectKTypeDialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>297</x> <x>297</x>
<y>285</y> <y>285</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>315</x> <x>315</x>
<y>280</y> <y>280</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>rejected()</signal> <signal>rejected()</signal>
<receiver>CDDirectKTypeDialog</receiver> <receiver>CDDirectKTypeDialog</receiver>
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>281</x> <x>281</x>
<y>290</y> <y>290</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>283</x> <x>283</x>
<y>307</y> <y>307</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
</connections> </connections>
</ui> </ui>

View File

@@ -1,354 +1,354 @@
#include "cdgraphics.h" #include "cdgraphics.h"
//#include "ui_qcd_graphic.h" //#include "ui_qcd_graphic.h"
#include "cdutils_core.h" #include "cdutils_core.h"
#include "cdutils_x.h" #include "cdutils_x.h"
#include "qcd_core.h" #include "qcd_core.h"
#include "qcd_model.h" #include "qcd_model.h"
#include "qcd_graphic.h" #include "qcd_graphic.h"
#include "graphic.h" #include "graphic.h"
#include "piqt.h" #include "piqt.h"
#include <QMimeData> #include <QMimeData>
#include <QDragEnterEvent> #include <QDragEnterEvent>
#include <QDragMoveEvent> #include <QDragMoveEvent>
#include <QDropEvent> #include <QDropEvent>
#include <QMainWindow> #include <QMainWindow>
#include <QDockWidget> #include <QDockWidget>
#include <QInputDialog> #include <QInputDialog>
using namespace CDUtils; using namespace CDUtils;
QStringList CDUtils::getList(const PIVector<PIDeque<int> > & x_list) { QStringList CDUtils::getList(const PIVector<PIDeque<int> > & x_list) {
QStringList ret; QStringList ret;
piForeachC (PIDeque<int> & p, x_list) piForeachC (PIDeque<int> & p, x_list)
ret << PI2QString(CDCore::pathToString(p)); ret << PI2QString(CDCore::pathToString(p));
return ret; return ret;
} }
PIVector<PIDeque<int> > CDUtils::setList(const QStringList & l) { PIVector<PIDeque<int> > CDUtils::setList(const QStringList & l) {
PIVector<PIDeque<int> > ret; PIVector<PIDeque<int> > ret;
foreach (QString s, l) foreach (QString s, l)
ret << CDCore::stringToPath(Q2PIString(s)); ret << CDCore::stringToPath(Q2PIString(s));
return ret; return ret;
} }
GDockWidget::GDockWidget(QString title, QMainWindow * p): QDockWidget(title, p) { GDockWidget::GDockWidget(QString title, QMainWindow * p): QDockWidget(title, p) {
da = p; da = p;
menu = new QMenu(this); menu = new QMenu(this);
QAction * a = new QAction(QIcon(":/icons/document-edit.png"), "Rename ...", this); QAction * a = new QAction(QIcon(":/icons/document-edit.png"), "Rename ...", this);
connect(a, SIGNAL(triggered(bool)), this, SLOT(rename())); connect(a, SIGNAL(triggered(bool)), this, SLOT(rename()));
dactions << a; dactions << a;
a = new QAction(QIcon(":/icons/edit-delete.png"), "Remove", this); a = new QAction(QIcon(":/icons/edit-delete.png"), "Remove", this);
connect(a, SIGNAL(triggered(bool)), this, SIGNAL(removeRequest())); connect(a, SIGNAL(triggered(bool)), this, SIGNAL(removeRequest()));
dactions << a; dactions << a;
menu_x = new QMenu(this); menu_x = new QMenu(this);
menu_x->setTitle(tr("Remove X")); menu_x->setTitle(tr("Remove X"));
graphic = new CDGraphicWidget(); graphic = new CDGraphicWidget();
graphic->graphic()->viewport()->setAcceptDrops(true); graphic->graphic()->viewport()->setAcceptDrops(true);
graphic->graphic()->viewport()->installEventFilter(this); graphic->graphic()->viewport()->installEventFilter(this);
setWidget(graphic); setWidget(graphic);
} }
void GDockWidget::addX(const CDType & t) { void GDockWidget::addX(const CDType & t) {
if (t.cd_type() != CDType::cdX) return; if (t.cd_type() != CDType::cdX) return;
PIDeque<int> xp = t.path(); PIDeque<int> xp = t.path();
if (x_list.contains(xp)) return; if (x_list.contains(xp)) return;
x_list << xp; x_list << xp;
int gind = graphic->graphic()->graphicsCount(); int gind = graphic->graphic()->graphicsCount();
graphic->graphic()->setGraphicsCount(gind + 1); graphic->graphic()->setGraphicsCount(gind + 1);
graphic->graphic()->setGraphicName(PI2QString(t.pathString().join(".")), gind); graphic->graphic()->setGraphicName(PI2QString(t.pathString().join(".")), gind);
} }
void GDockWidget::drawX(const PIMap<PIString, PIVector<double> > & data) { void GDockWidget::drawX(const PIMap<PIString, PIVector<double> > & data) {
for (int i = 0; i < x_list.size_s(); ++i) { for (int i = 0; i < x_list.size_s(); ++i) {
PIString sp = CDCore::pathToString(x_list[i]); PIString sp = CDCore::pathToString(x_list[i]);
const PIVector<double> & ch(data[sp]); const PIVector<double> & ch(data[sp]);
for (int j = 0; j < ch.size_s(); ++j) for (int j = 0; j < ch.size_s(); ++j)
graphic->graphic()->addPoint(ch[j], i, false); graphic->graphic()->addPoint(ch[j], i, false);
} }
graphic->graphic()->updateGraphics(); graphic->graphic()->updateGraphics();
} }
QByteArray GDockWidget::save() const { QByteArray GDockWidget::save() const {
ChunkStream cs; ChunkStream cs;
cs.add(1, windowTitle()) cs.add(1, windowTitle())
.add(2, getList(x_list)) .add(2, getList(x_list))
.add(3, graphic->graphic()->save()) .add(3, graphic->graphic()->save())
.add(4, graphic->evalSpinBoxHistory()->expression()) .add(4, graphic->evalSpinBoxHistory()->expression())
.add(5, graphic->evalSpinBoxVisible()->expression()); .add(5, graphic->evalSpinBoxVisible()->expression());
return cs.data(); return cs.data();
} }
void GDockWidget::load(QByteArray ba) { void GDockWidget::load(QByteArray ba) {
if (ba.isEmpty()) return; if (ba.isEmpty()) return;
ChunkStream cs(ba); ChunkStream cs(ba);
while (!cs.atEnd()) { while (!cs.atEnd()) {
switch (cs.read()) { switch (cs.read()) {
case 1: setWindowTitle(cs.getData<QString>()); break; case 1: setWindowTitle(cs.getData<QString>()); break;
case 2: x_list = setList(cs.getData<QStringList>()); break; case 2: x_list = setList(cs.getData<QStringList>()); break;
case 3: graphic->graphic()->load(cs.getData<QByteArray>()); break; case 3: graphic->graphic()->load(cs.getData<QByteArray>()); break;
case 4: graphic->evalSpinBoxHistory()->setExpression(cs.getData<QString>()); break; case 4: graphic->evalSpinBoxHistory()->setExpression(cs.getData<QString>()); break;
case 5: graphic->evalSpinBoxVisible()->setExpression(cs.getData<QString>()); break; case 5: graphic->evalSpinBoxVisible()->setExpression(cs.getData<QString>()); break;
default: break; default: break;
} }
} }
} }
void GDockWidget::changedGlobal() { void GDockWidget::changedGlobal() {
for (int i = 0; i < x_list.size_s(); ++i) { for (int i = 0; i < x_list.size_s(); ++i) {
if (!X.exists(x_list[i])) { if (!X.exists(x_list[i])) {
x_list.remove(i); x_list.remove(i);
graphic->graphic()->removeGraphic(i); graphic->graphic()->removeGraphic(i);
--i; --i;
continue; continue;
} }
graphic->graphic()->setGraphicName(PI2QString(X[x_list[i]].pathString().join(".")), i); graphic->graphic()->setGraphicName(PI2QString(X[x_list[i]].pathString().join(".")), i);
} }
} }
bool GDockWidget::eventFilter(QObject * o, QEvent * e) { bool GDockWidget::eventFilter(QObject * o, QEvent * e) {
//if (o == graphic->viewport()) { //if (o == graphic->viewport()) {
switch (e->type()) { switch (e->type()) {
case QEvent::DragMove: { case QEvent::DragMove: {
QDragMoveEvent * de = (QDragMoveEvent*)e; QDragMoveEvent * de = (QDragMoveEvent*)e;
const QMimeData * mime = de->mimeData(); const QMimeData * mime = de->mimeData();
//qDebug() << "enter" << mime; //qDebug() << "enter" << mime;
if (!mime) break; if (!mime) break;
if (!mime->text().startsWith("x")) break; if (!mime->text().startsWith("x")) break;
de->setDropAction(Qt::CopyAction); de->setDropAction(Qt::CopyAction);
de->accept(); de->accept();
return true; return true;
} break; } break;
case QEvent::DragEnter: { case QEvent::DragEnter: {
QDragEnterEvent * de = (QDragEnterEvent*)e; QDragEnterEvent * de = (QDragEnterEvent*)e;
const QMimeData * mime = de->mimeData(); const QMimeData * mime = de->mimeData();
//qDebug() << "enter" << mime; //qDebug() << "enter" << mime;
if (!mime) break; if (!mime) break;
if (!mime->text().startsWith("x")) break; if (!mime->text().startsWith("x")) break;
de->setDropAction(Qt::CopyAction); de->setDropAction(Qt::CopyAction);
de->accept(); de->accept();
return true; return true;
} break; } break;
case QEvent::Drop: { case QEvent::Drop: {
QDropEvent * de = (QDropEvent*)e; QDropEvent * de = (QDropEvent*)e;
const QMimeData * mime = de->mimeData(); const QMimeData * mime = de->mimeData();
if (!mime) break; if (!mime) break;
//qDebug() << "drop" << mime->text(); //qDebug() << "drop" << mime->text();
if (!mime->text().startsWith("x")) break; if (!mime->text().startsWith("x")) break;
addX(X[CDCore::stringToPath(Q2PIString(mime->text().mid(1)))]); addX(X[CDCore::stringToPath(Q2PIString(mime->text().mid(1)))]);
de->accept(); de->accept();
return true; return true;
} break; } break;
default: break; default: break;
} }
//} //}
return QWidget::eventFilter(o, e); return QWidget::eventFilter(o, e);
} }
void GDockWidget::contextMenuEvent(QContextMenuEvent * e) { void GDockWidget::contextMenuEvent(QContextMenuEvent * e) {
if (graphic->graphic()->underMouse()) return; if (graphic->graphic()->underMouse()) return;
qDeleteAll(menu_x->actions()); qDeleteAll(menu_x->actions());
menu_x->clear(); menu_x->clear();
for (int i = 0; i < graphic->graphic()->graphicsCount(); ++i) { for (int i = 0; i < graphic->graphic()->graphicsCount(); ++i) {
QPixmap icon(da->iconSize()); QPixmap icon(da->iconSize());
icon.fill(graphic->graphic()->graphic(i).pen.color()); icon.fill(graphic->graphic()->graphic(i).pen.color());
QAction * a = new QAction(QIcon(icon), graphic->graphic()->graphic(i).name, this); QAction * a = new QAction(QIcon(icon), graphic->graphic()->graphic(i).name, this);
a->setData(i); a->setData(i);
connect(a, SIGNAL(triggered(bool)), this, SLOT(removeX())); connect(a, SIGNAL(triggered(bool)), this, SLOT(removeX()));
menu_x->addAction(a); menu_x->addAction(a);
} }
QMenu * mwm = da->createPopupMenu(); QMenu * mwm = da->createPopupMenu();
menu->clear(); menu->clear();
menu->addActions(dactions); menu->addActions(dactions);
menu->addMenu(menu_x); menu->addMenu(menu_x);
menu->addSeparator(); menu->addSeparator();
menu->addActions(mwm->actions()); menu->addActions(mwm->actions());
menu->popup(e->globalPos()); menu->popup(e->globalPos());
mwm->deleteLater(); mwm->deleteLater();
} }
CDGraphicWidget * GDockWidget::viewportGraphic(QObject * o) const { CDGraphicWidget * GDockWidget::viewportGraphic(QObject * o) const {
if (!o) return 0; if (!o) return 0;
while (!qobject_cast<CDGraphicWidget*>(o) && o) while (!qobject_cast<CDGraphicWidget*>(o) && o)
o = o->parent(); o = o->parent();
return qobject_cast<CDGraphicWidget*>(o); return qobject_cast<CDGraphicWidget*>(o);
} }
void GDockWidget::rename() { void GDockWidget::rename() {
QString nn = QInputDialog::getText(this, tr("Rename area"), tr("New area name:"), QString nn = QInputDialog::getText(this, tr("Rename area"), tr("New area name:"),
QLineEdit::Normal, windowTitle()); QLineEdit::Normal, windowTitle());
if (nn.isEmpty()) return; if (nn.isEmpty()) return;
setWindowTitle(nn); setWindowTitle(nn);
} }
void GDockWidget::removeX() { void GDockWidget::removeX() {
QAction * a = qobject_cast<QAction * >(sender()); QAction * a = qobject_cast<QAction * >(sender());
if (!a) return; if (!a) return;
int ind = a->data().toInt(); int ind = a->data().toInt();
if (ind < 0 || ind >= x_list.size_s()) return; if (ind < 0 || ind >= x_list.size_s()) return;
x_list.remove(ind); x_list.remove(ind);
graphic->graphic()->removeGraphic(ind); graphic->graphic()->removeGraphic(ind);
} }
CDGraphics::CDGraphics(QWidget * parent) : QWidget(parent), Ui::CDGraphics() { CDGraphics::CDGraphics(QWidget * parent) : QWidget(parent), Ui::CDGraphics() {
setupUi(this); setupUi(this);
da = new QMainWindow(); da = new QMainWindow();
da->setWindowFlags(frame->windowFlags()); da->setWindowFlags(frame->windowFlags());
da->setDockNestingEnabled(true); da->setDockNestingEnabled(true);
layoutMain->addWidget(da); layoutMain->addWidget(da);
} }
CDGraphics::~CDGraphics() { CDGraphics::~CDGraphics() {
} }
void CDGraphics::reset() { void CDGraphics::reset() {
qDeleteAll(docks); qDeleteAll(docks);
docks.clear(); docks.clear();
} }
QByteArray CDGraphics::save() const { QByteArray CDGraphics::save() const {
ChunkStream cs; ChunkStream cs;
QVector<QByteArray> dstates; QVector<QByteArray> dstates;
foreach (GDockWidget * d, docks) { foreach (GDockWidget * d, docks) {
dstates << d->save(); dstates << d->save();
} }
cs.add(1, docks.size()) cs.add(1, docks.size())
.add(2, dstates) .add(2, dstates)
.add(3, da->saveState()); .add(3, da->saveState());
X.lock(); X.lock();
cs.add(4, getList(X.enabledList())); cs.add(4, getList(X.enabledList()));
X.unlock(); X.unlock();
cs.add(5, buttonConfigVisible->isChecked()); cs.add(5, buttonConfigVisible->isChecked());
return cs.data(); return cs.data();
} }
void CDGraphics::load(QByteArray ba) { void CDGraphics::load(QByteArray ba) {
reset(); reset();
if (ba.isEmpty()) return; if (ba.isEmpty()) return;
ChunkStream cs(ba); ChunkStream cs(ba);
while (!cs.atEnd()) { while (!cs.atEnd()) {
switch (cs.read()) { switch (cs.read()) {
case 1: { case 1: {
int s = cs.getData<int>(); int s = cs.getData<int>();
piForTimes (s) piForTimes (s)
addGraphic(); addGraphic();
} break; } break;
case 2: { case 2: {
QVector<QByteArray> dstates = cs.getData<QVector<QByteArray> >(); QVector<QByteArray> dstates = cs.getData<QVector<QByteArray> >();
for (int i = 0; i < piMini(dstates.size(), docks.size()); ++i) for (int i = 0; i < piMini(dstates.size(), docks.size()); ++i)
docks[i]->load(dstates[i]); docks[i]->load(dstates[i]);
} break; } break;
case 3: da->restoreState(cs.getData<QByteArray>()); break; case 3: da->restoreState(cs.getData<QByteArray>()); break;
case 4: case 4:
X.lock(); X.lock();
X.setEnabledList(setList(cs.getData<QStringList>())); X.setEnabledList(setList(cs.getData<QStringList>()));
X.unlock(); X.unlock();
break; break;
case 5: case 5:
buttonConfigVisible->setChecked(cs.getData<bool>()); buttonConfigVisible->setChecked(cs.getData<bool>());
break; break;
default: break; default: break;
} }
} }
} }
GDockWidget * CDGraphics::graphicDock(Graphic * o) const { GDockWidget * CDGraphics::graphicDock(Graphic * o) const {
if (!o) return 0; if (!o) return 0;
foreach (GDockWidget * d, docks) foreach (GDockWidget * d, docks)
if (d->widget() == o) if (d->widget() == o)
return d; return d;
return 0; return 0;
} }
void CDGraphics::addGraphic() { void CDGraphics::addGraphic() {
GDockWidget * dw = new GDockWidget(QString("area %1").arg(docks.size()), da); GDockWidget * dw = new GDockWidget(QString("area %1").arg(docks.size()), da);
connect(dw, SIGNAL(removeRequest()), this, SLOT(removeGraphic())); connect(dw, SIGNAL(removeRequest()), this, SLOT(removeGraphic()));
connect(buttonConfigVisible, SIGNAL(toggled(bool)), dw->graphic, SLOT(setConfigVisible(bool))); connect(buttonConfigVisible, SIGNAL(toggled(bool)), dw->graphic, SLOT(setConfigVisible(bool)));
connect(buttonLegendVisible, SIGNAL(clicked(bool)), dw->graphic->graphic(), SLOT(setLegendVisible(bool))); connect(buttonLegendVisible, SIGNAL(clicked(bool)), dw->graphic->graphic(), SLOT(setLegendVisible(bool)));
connect(buttonBorderInputsVisible, SIGNAL(clicked(bool)), dw->graphic->graphic(), SLOT(setBorderInputsVisible(bool))); connect(buttonBorderInputsVisible, SIGNAL(clicked(bool)), dw->graphic->graphic(), SLOT(setBorderInputsVisible(bool)));
connect(buttonPause, SIGNAL(clicked(bool)), dw->graphic->graphic(), SLOT(setPaused(bool))); connect(buttonPause, SIGNAL(clicked(bool)), dw->graphic->graphic(), SLOT(setPaused(bool)));
dw->graphic->setConfigVisible(buttonConfigVisible->isChecked()); dw->graphic->setConfigVisible(buttonConfigVisible->isChecked());
dw->graphic->graphic()->setLegendVisible(buttonLegendVisible->isChecked()); dw->graphic->graphic()->setLegendVisible(buttonLegendVisible->isChecked());
dw->graphic->graphic()->setBorderInputsVisible(buttonBorderInputsVisible->isChecked()); dw->graphic->graphic()->setBorderInputsVisible(buttonBorderInputsVisible->isChecked());
da->addDockWidget(Qt::RightDockWidgetArea, dw); da->addDockWidget(Qt::RightDockWidgetArea, dw);
docks << dw; docks << dw;
for (int i = 0; i < docks.size(); ++i) for (int i = 0; i < docks.size(); ++i)
docks[i]->setObjectName(QString("dock_%1").arg(i)); docks[i]->setObjectName(QString("dock_%1").arg(i));
} }
void CDGraphics::receivedX() { void CDGraphics::receivedX() {
PIMap<PIString, PIVector<double> > data; PIMap<PIString, PIVector<double> > data;
X.lock(); X.lock();
PIVector<PIDeque<int> > x_list = X.enabledList(); PIVector<PIDeque<int> > x_list = X.enabledList();
PIVector<double> ch; PIVector<double> ch;
piForeachC (PIDeque<int> & p, x_list) { piForeachC (PIDeque<int> & p, x_list) {
CDType & t(X[p]); CDType & t(X[p]);
if (t.xmode_rec() == CDType::X_Current) if (t.xmode_rec() == CDType::X_Current)
ch.resize(1).fill(t.toDouble()); ch.resize(1).fill(t.toDouble());
else else
ch = t.history; ch = t.history;
t.history.clear(); t.history.clear();
data[CDCore::pathToString(t.path())] = ch; data[CDCore::pathToString(t.path())] = ch;
} }
//piCout << data; //piCout << data;
X.unlock(); X.unlock();
foreach (GDockWidget * d, docks) foreach (GDockWidget * d, docks)
d->drawX(data); d->drawX(data);
} }
void CDGraphics::changedGlobal() { void CDGraphics::changedGlobal() {
foreach (GDockWidget * d, docks) foreach (GDockWidget * d, docks)
d->changedGlobal(); d->changedGlobal();
} }
void CDGraphics::removeGraphic() { void CDGraphics::removeGraphic() {
GDockWidget * d = qobject_cast<GDockWidget * >(sender()); GDockWidget * d = qobject_cast<GDockWidget * >(sender());
if (!d) return; if (!d) return;
docks.removeAll(d); docks.removeAll(d);
d->deleteLater(); d->deleteLater();
for (int i = 0; i < docks.size(); ++i) for (int i = 0; i < docks.size(); ++i)
docks[i]->setObjectName(QString("dock_%1").arg(i)); docks[i]->setObjectName(QString("dock_%1").arg(i));
} }
void CDGraphics::on_buttonAdd_clicked() { void CDGraphics::on_buttonAdd_clicked() {
addGraphic(); addGraphic();
} }
void CDGraphics::on_buttonClear_clicked() { void CDGraphics::on_buttonClear_clicked() {
foreach (GDockWidget * d, docks) foreach (GDockWidget * d, docks)
d->graphic->graphic()->clear(); d->graphic->graphic()->clear();
} }
void CDGraphics::on_buttonRemoveAll_clicked() { void CDGraphics::on_buttonRemoveAll_clicked() {
qDeleteAll(docks); qDeleteAll(docks);
docks.clear(); docks.clear();
} }

View File

@@ -1,92 +1,92 @@
#ifndef CDGRAPHICS_H #ifndef CDGRAPHICS_H
#define CDGRAPHICS_H #define CDGRAPHICS_H
#include <QWidget> #include <QWidget>
#include <QDockWidget> #include <QDockWidget>
#include <QMenu> #include <QMenu>
#include "ui_cdgraphics.h" #include "ui_cdgraphics.h"
#include "qcd_graphic.h" #include "qcd_graphic.h"
#include <pistring.h> #include <pistring.h>
namespace CDUtils { namespace CDUtils {
class CDType; class CDType;
class CDSection; class CDSection;
QStringList getList(const PIVector<PIDeque<int> > & x_list); QStringList getList(const PIVector<PIDeque<int> > & x_list);
PIVector<PIDeque<int> > setList(const QStringList & l); PIVector<PIDeque<int> > setList(const QStringList & l);
} }
class QMainWindow; class QMainWindow;
class Graphic; class Graphic;
class GDockWidget: public QDockWidget { class GDockWidget: public QDockWidget {
Q_OBJECT Q_OBJECT
public: public:
GDockWidget(QString title = QString(), QMainWindow * p = 0); GDockWidget(QString title = QString(), QMainWindow * p = 0);
void addX(const CDUtils::CDType & t); void addX(const CDUtils::CDType & t);
void drawX(const PIMap<PIString, PIVector<double> > & data); void drawX(const PIMap<PIString, PIVector<double> > & data);
QByteArray save() const; QByteArray save() const;
void load(QByteArray ba); void load(QByteArray ba);
void changedGlobal(); void changedGlobal();
CDGraphicWidget * graphic; CDGraphicWidget * graphic;
private: private:
bool eventFilter(QObject * o, QEvent * e); bool eventFilter(QObject * o, QEvent * e);
void contextMenuEvent(QContextMenuEvent * e); void contextMenuEvent(QContextMenuEvent * e);
CDGraphicWidget * viewportGraphic(QObject * o) const; CDGraphicWidget * viewportGraphic(QObject * o) const;
QMenu * menu, * menu_x; QMenu * menu, * menu_x;
QList<QAction*> dactions; QList<QAction*> dactions;
QMainWindow * da; QMainWindow * da;
PIVector<PIDeque<int> > x_list; PIVector<PIDeque<int> > x_list;
private slots: private slots:
void rename(); void rename();
void removeX(); void removeX();
signals: signals:
void removeRequest(); void removeRequest();
}; };
class CDGraphics : public QWidget, public Ui::CDGraphics class CDGraphics : public QWidget, public Ui::CDGraphics
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CDGraphics(QWidget *parent = 0); explicit CDGraphics(QWidget *parent = 0);
~CDGraphics(); ~CDGraphics();
void reset(); void reset();
QByteArray save() const; QByteArray save() const;
void load(QByteArray ba); void load(QByteArray ba);
private: private:
GDockWidget * graphicDock(Graphic * o) const; GDockWidget * graphicDock(Graphic * o) const;
void addXToGraphic(const QString & xp, Graphic * g); void addXToGraphic(const QString & xp, Graphic * g);
void addGraphic(); void addGraphic();
QList<GDockWidget * > docks; QList<GDockWidget * > docks;
QMainWindow * da; QMainWindow * da;
public slots: public slots:
void receivedX(); void receivedX();
void changedGlobal(); void changedGlobal();
private slots: private slots:
void removeGraphic(); void removeGraphic();
void on_buttonAdd_clicked(); void on_buttonAdd_clicked();
void on_buttonClear_clicked(); void on_buttonClear_clicked();
void on_buttonRemoveAll_clicked(); void on_buttonRemoveAll_clicked();
signals: signals:
}; };
#endif // CDGRAPHICS_H #endif // CDGRAPHICS_H

View File

@@ -1,168 +1,168 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>CDGraphics</class> <class>CDGraphics</class>
<widget class="QWidget" name="CDGraphics"> <widget class="QWidget" name="CDGraphics">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>624</width> <width>624</width>
<height>411</height> <height>411</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>CD Pult</string> <string>CD Pult</string>
</property> </property>
<layout class="QVBoxLayout" name="layoutMain" stretch="0"> <layout class="QVBoxLayout" name="layoutMain" stretch="0">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QFrame" name="frame"> <widget class="QFrame" name="frame">
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::StyledPanel</enum>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QToolButton" name="buttonAdd"> <widget class="QToolButton" name="buttonAdd">
<property name="toolTip"> <property name="toolTip">
<string>Add new</string> <string>Add new</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../qad/utils/qad_utils.qrc"> <iconset resource="../../qad/utils/qad_utils.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>
</item> </item>
<item> <item>
<widget class="QToolButton" name="buttonClear"> <widget class="QToolButton" name="buttonClear">
<property name="toolTip"> <property name="toolTip">
<string>Clear all</string> <string>Clear all</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../qad/utils/qad_utils.qrc"> <iconset resource="../../qad/utils/qad_utils.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>
<item> <item>
<widget class="QToolButton" name="buttonRemoveAll"> <widget class="QToolButton" name="buttonRemoveAll">
<property name="toolTip"> <property name="toolTip">
<string>Remove all</string> <string>Remove all</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../qad/utils/qad_utils.qrc"> <iconset resource="../../qad/utils/qad_utils.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>
</item> </item>
<item> <item>
<widget class="QToolButton" name="buttonConfigVisible"> <widget class="QToolButton" name="buttonConfigVisible">
<property name="toolTip"> <property name="toolTip">
<string>Remove all</string> <string>Remove all</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../qad/application/qad_application.qrc"> <iconset resource="../../qad/application/qad_application.qrc">
<normaloff>:/icons/layer-visible-off.png</normaloff> <normaloff>:/icons/layer-visible-off.png</normaloff>
<normalon>:/icons/layer-visible-on.png</normalon>:/icons/layer-visible-off.png</iconset> <normalon>:/icons/layer-visible-on.png</normalon>:/icons/layer-visible-off.png</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="buttonLegendVisible"> <widget class="QToolButton" name="buttonLegendVisible">
<property name="toolTip"> <property name="toolTip">
<string>Remove all</string> <string>Remove all</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../qad/widgets/qad_widgets.qrc"> <iconset resource="../../qad/widgets/qad_widgets.qrc">
<normaloff>:/icons/legend.png</normaloff>:/icons/legend.png</iconset> <normaloff>:/icons/legend.png</normaloff>:/icons/legend.png</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="buttonPause"> <widget class="QToolButton" name="buttonPause">
<property name="toolTip"> <property name="toolTip">
<string>Remove all</string> <string>Remove all</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../qad/graphic/qad_graphic.qrc"> <iconset resource="../../qad/graphic/qad_graphic.qrc">
<normaloff>:/icons/media-playback-pause.png</normaloff>:/icons/media-playback-pause.png</iconset> <normaloff>:/icons/media-playback-pause.png</normaloff>:/icons/media-playback-pause.png</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="checked"> <property name="checked">
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="buttonBorderInputsVisible"> <widget class="QToolButton" name="buttonBorderInputsVisible">
<property name="toolTip"> <property name="toolTip">
<string>Remove all</string> <string>Remove all</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../qad/widgets/qad_widgets.qrc"> <iconset resource="../../qad/widgets/qad_widgets.qrc">
<normaloff>:/icons/border-line.png</normaloff>:/icons/border-line.png</iconset> <normaloff>:/icons/border-line.png</normaloff>:/icons/border-line.png</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="checked"> <property name="checked">
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</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="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>1</width> <width>1</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="../../qad/utils/qad_utils.qrc"/> <include location="../../qad/utils/qad_utils.qrc"/>
<include location="../../qad/widgets/qad_widgets.qrc"/> <include location="../../qad/widgets/qad_widgets.qrc"/>
<include location="../../qad/application/qad_application.qrc"/> <include location="../../qad/application/qad_application.qrc"/>
<include location="../../qad/graphic/qad_graphic.qrc"/> <include location="../../qad/graphic/qad_graphic.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View File

@@ -0,0 +1,16 @@
<RCC>
<qresource prefix="/">
<file>../../../qad/icons/dialog-information.png</file>
<file>../../../qad/icons/dialog-cancel.png</file>
<file>../../../qad/icons/dialog-ok-apply.png</file>
<file>../../../qad/icons/document-revert.png</file>
<file>../../../qad/icons/view-refresh.png</file>
<file>../../../qad/icons/format-stroke-color.png</file>
<file>icons/db-export.png</file>
<file>icons/db-import.png</file>
<file>icons/timer.png</file>
<file>icons/flame.png</file>
<file>icons/Apps-accessories-calculator-icon.png</file>
<file>icons/accessories-text-editor.png</file>
</qresource>
</RCC>

View File

@@ -1,292 +1,292 @@
#include "edockwidget.h" #include "edockwidget.h"
#include "cdpultwindow.h" #include "cdpultwindow.h"
#include "cdutils_core.h" #include "cdutils_core.h"
#include "cdutils_k.h" #include "cdutils_k.h"
#include "cdutils_x.h" #include "cdutils_x.h"
#include "cdutils_m.h" #include "cdutils_m.h"
#include "qcd_core.h" #include "qcd_core.h"
#include "qcd_view.h" #include "qcd_view.h"
#include "qcd_model.h" #include "qcd_model.h"
#include "qcd_modedialog.h" #include "qcd_modedialog.h"
#include "chunkstream.h" #include "chunkstream.h"
#include "qvariantedit.h" #include "qvariantedit.h"
#include "piqt.h" #include "piqt.h"
#include "piqt_highlighter.h" #include "piqt_highlighter.h"
#include "qcodeedit.h" #include "qcodeedit.h"
#include <QFileDialog> #include <QFileDialog>
#include <QScrollBar> #include <QScrollBar>
#include <QImageReader> #include <QImageReader>
#include <QMessageBox> #include <QMessageBox>
using namespace CDUtils; using namespace CDUtils;
CDPultWindow::CDPultWindow(QWidget *parent) : EMainWindow(parent), Ui::CDPultWindow() { CDPultWindow::CDPultWindow(QWidget *parent) : EMainWindow(parent), Ui::CDPultWindow() {
setupUi(this); setupUi(this);
centralWidget()->hide(); centralWidget()->hide();
setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
CDCore::instance()->initPult(); CDCore::instance()->initPult();
def_config = codeConfig->text(); def_config = codeConfig->text();
checkDefaultConfig->setChecked(true); checkDefaultConfig->setChecked(true);
new ConfigHighlighter(codeConfig->document()); new ConfigHighlighter(codeConfig->document());
widgetK->setType(CDUtils::CDType::cdK); widgetK->setType(CDUtils::CDType::cdK);
widgetX->setType(CDUtils::CDType::cdX); widgetX->setType(CDUtils::CDType::cdX);
widgetC->setType(CDUtils::CDType::cdC); widgetC->setType(CDUtils::CDType::cdC);
widgetM->setType(CDUtils::CDType::cdM); widgetM->setType(CDUtils::CDType::cdM);
editFileK->setValue(QVariant::fromValue(QAD::File("", "*.dat"))); editFileK->setValue(QVariant::fromValue(QAD::File("", "*.dat")));
editFileX->setValue(QVariant::fromValue(QAD::File("", "*.dat"))); editFileX->setValue(QVariant::fromValue(QAD::File("", "*.dat")));
editFileC->setValue(QVariant::fromValue(QAD::File("", "*.dat"))); editFileC->setValue(QVariant::fromValue(QAD::File("", "*.dat")));
editFileM->setValue(QVariant::fromValue(QAD::File("", "*.dat"))); editFileM->setValue(QVariant::fromValue(QAD::File("", "*.dat")));
log_icons[CDViewWidget::OKIcon] = QIcon(":/icons/dialog-ok-apply.png"); log_icons[CDViewWidget::OKIcon] = QIcon(":/icons/dialog-ok-apply.png");
log_icons[CDViewWidget::FailIcon] = QIcon(":/icons/dialog-cancel.png"); log_icons[CDViewWidget::FailIcon] = QIcon(":/icons/dialog-cancel.png");
log_icons[CDViewWidget::WaitIcon] = QIcon(":/icons/timer.png"); log_icons[CDViewWidget::WaitIcon] = QIcon(":/icons/timer.png");
setRecentMenu(menuOpen_recent); setRecentMenu(menuOpen_recent);
ribbon = new Ribbon(this); ribbon = new Ribbon(this);
session.setFile("session_cdpult.conf"); session.setFile("session_cdpult.conf");
session.addEntry(this); session.addEntry(this);
session.addEntry(ribbon->tabWidget()); session.addEntry(ribbon->tabWidget());
session.load(); session.load();
reset(); reset();
connect(widgetK, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString))); connect(widgetK, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString)));
connect(widgetX, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString))); connect(widgetX, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString)));
connect(widgetC, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString))); connect(widgetC, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString)));
connect(widgetM, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString))); connect(widgetM, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString)));
connect(widgetK->view, SIGNAL(changedGlobal()), widgetDirectK, SLOT(changedGlobal())); connect(widgetK->view, SIGNAL(changedGlobal()), widgetDirectK, SLOT(changedGlobal()));
connect(widgetX->view, SIGNAL(changedGlobal()), widgetGraphics, SLOT(changedGlobal())); connect(widgetX->view, SIGNAL(changedGlobal()), widgetGraphics, SLOT(changedGlobal()));
connect(widgetX->view, SIGNAL(receivedX()), widgetGraphics, SLOT(receivedX())); connect(widgetX->view, SIGNAL(receivedX()), widgetGraphics, SLOT(receivedX()));
connect(widgetM->view, SIGNAL(messageReceived(QString,int,QString)), this, SLOT(messageReceived(QString,int,QString))); connect(widgetM->view, SIGNAL(messageReceived(QString,int,QString)), this, SLOT(messageReceived(QString,int,QString)));
QCDCore::instance()->bindWidget(widgetK->view); QCDCore::instance()->bindWidget(widgetK->view);
QCDCore::instance()->setDirectKEnabled(true); QCDCore::instance()->setDirectKEnabled(true);
X.start(); X.start();
if (windowState() == Qt::WindowMinimized) if (windowState() == Qt::WindowMinimized)
setWindowState(Qt::WindowNoState); setWindowState(Qt::WindowNoState);
} }
CDPultWindow::~CDPultWindow() { CDPultWindow::~CDPultWindow() {
} }
void CDPultWindow::loadFile(const QString & fp) { void CDPultWindow::loadFile(const QString & fp) {
load(fp); load(fp);
} }
void CDPultWindow::apply(bool sessions) { void CDPultWindow::apply(bool sessions) {
CDCore::instance()->stop(); CDCore::instance()->stop();
widgetK->setFile(editFileK->value().value<QAD::File>().file); widgetK->setFile(editFileK->value().value<QAD::File>().file);
widgetX->setFile(editFileX->value().value<QAD::File>().file); widgetX->setFile(editFileX->value().value<QAD::File>().file);
widgetC->setFile(editFileC->value().value<QAD::File>().file); widgetC->setFile(editFileC->value().value<QAD::File>().file);
widgetM->setFile(editFileM->value().value<QAD::File>().file); widgetM->setFile(editFileM->value().value<QAD::File>().file);
if (checkDefaultConfig->isChecked()) if (checkDefaultConfig->isChecked())
CDCore::instance()->initPult(); CDCore::instance()->initPult();
else else
CDCore::instance()->init(Q2PIString(codeConfig->text()), true); CDCore::instance()->init(Q2PIString(codeConfig->text()), true);
widgetX->view->startX(); widgetX->view->startX();
if (sessions) { if (sessions) {
widgetGraphics->load(session_gr); widgetGraphics->load(session_gr);
widgetDirectK->load(session_dk); widgetDirectK->load(session_dk);
if (!session_mw.isEmpty()) if (!session_mw.isEmpty())
restoreState(session_mw); restoreState(session_mw);
X.lock(); X.lock();
PIVector<PIDeque<int> > x_list = X.enabledList(); PIVector<PIDeque<int> > x_list = X.enabledList();
X.unlock(); X.unlock();
piForeachC (PIDeque<int> & p, x_list) piForeachC (PIDeque<int> & p, x_list)
X.enable(X[p]); X.enable(X[p]);
((CDItemModel*)widgetX->view->model())->updateModel(); ((CDItemModel*)widgetX->view->model())->updateModel();
widgetX->view->expandAll(); widgetX->view->expandAll();
} }
dockCDKView->setVisible(checkHasK->isChecked()); dockCDKView->setVisible(checkHasK->isChecked());
dockCDXView->setVisible(checkHasX->isChecked()); dockCDXView->setVisible(checkHasX->isChecked());
dockCDCView->setVisible(checkHasC->isChecked()); dockCDCView->setVisible(checkHasC->isChecked());
dockCDMView->setVisible(checkHasM->isChecked()); dockCDMView->setVisible(checkHasM->isChecked());
QMetaObject::invokeMethod(this, "changedDock", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "changedDock", Qt::QueuedConnection);
} }
void CDPultWindow::closeEvent(QCloseEvent *e) { void CDPultWindow::closeEvent(QCloseEvent *e) {
EMainWindow::closeEvent(e); EMainWindow::closeEvent(e);
if (!e->isAccepted()) if (!e->isAccepted())
return; return;
QApplication::closeAllWindows(); QApplication::closeAllWindows();
session.save(); session.save();
session.setFile(QString()); session.setFile(QString());
} }
void CDPultWindow::reset(bool full) { void CDPultWindow::reset(bool full) {
setWindowTitle(QString("CD Pult")); setWindowTitle(QString("CD Pult"));
widgetK->reset(); widgetK->reset();
setChanged(false); setChanged(false);
} }
bool CDPultWindow::load(const QString & path) { bool CDPultWindow::load(const QString & path) {
qApp->setOverrideCursor(Qt::WaitCursor); qApp->setOverrideCursor(Qt::WaitCursor);
QPIConfig conf(path, QIODevice::ReadOnly); QPIConfig conf(path, QIODevice::ReadOnly);
QAD::File f = editFileK->value().value<QAD::File>(); QAD::File f = editFileK->value().value<QAD::File>();
checkSyncFiles->setChecked(false); checkSyncFiles->setChecked(false);
editFileK->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_k").toString(), f.filter))); editFileK->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_k").toString(), f.filter)));
editFileX->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_x").toString(), f.filter))); editFileX->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_x").toString(), f.filter)));
editFileC->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_c").toString(), f.filter))); editFileC->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_c").toString(), f.filter)));
editFileM->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_m").toString(), f.filter))); editFileM->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_m").toString(), f.filter)));
checkSyncFiles->setChecked(conf.getValue("sync_files").toBool()); checkSyncFiles->setChecked(conf.getValue("sync_files").toBool());
lineSessionName->setText(conf.getValue("session_name").toString()); lineSessionName->setText(conf.getValue("session_name").toString());
last_icon = conf.getValue("icon_path").toString(); last_icon = conf.getValue("icon_path").toString();
setAppIcon(conf.getValue("icon").toByteArray()); setAppIcon(conf.getValue("icon").toByteArray());
checkHasK->setChecked(conf.getValue("has_k").toBool()); checkHasK->setChecked(conf.getValue("has_k").toBool());
checkHasX->setChecked(conf.getValue("has_x").toBool()); checkHasX->setChecked(conf.getValue("has_x").toBool());
checkHasC->setChecked(conf.getValue("has_c").toBool()); checkHasC->setChecked(conf.getValue("has_c").toBool());
checkHasM->setChecked(conf.getValue("has_m").toBool()); checkHasM->setChecked(conf.getValue("has_m").toBool());
checkDefaultConfig->setChecked(conf.getValue("default_config").toBool()); checkDefaultConfig->setChecked(conf.getValue("default_config").toBool());
codeConfig->setText(QByteArray2QString(conf.getValue("config").toByteArray())); codeConfig->setText(QByteArray2QString(conf.getValue("config").toByteArray()));
if (codeConfig->text().isEmpty()) if (codeConfig->text().isEmpty())
codeConfig->setText(def_config); codeConfig->setText(def_config);
session_gr = conf.getValue("session_gr").toByteArray(); session_gr = conf.getValue("session_gr").toByteArray();
session_dk = conf.getValue("session_dk").toByteArray(); session_dk = conf.getValue("session_dk").toByteArray();
session_mw = conf.getValue("session_mw").toByteArray(); session_mw = conf.getValue("session_mw").toByteArray();
setChanged(false); setChanged(false);
file_name = path; file_name = path;
apply(true); apply(true);
qApp->restoreOverrideCursor(); qApp->restoreOverrideCursor();
return true; return true;
} }
bool CDPultWindow::save(const QString & path) { bool CDPultWindow::save(const QString & path) {
session_gr = widgetGraphics->save(); session_gr = widgetGraphics->save();
session_dk = widgetDirectK->save(); session_dk = widgetDirectK->save();
session_mw = saveState(); session_mw = saveState();
QPIConfig conf(path, QIODevice::ReadWrite); QPIConfig conf(path, QIODevice::ReadWrite);
conf.clear(); conf.clear();
conf.setValue("file_k", editFileK->value().value<QAD::File>().file); conf.setValue("file_k", editFileK->value().value<QAD::File>().file);
conf.setValue("file_x", editFileX->value().value<QAD::File>().file); conf.setValue("file_x", editFileX->value().value<QAD::File>().file);
conf.setValue("file_c", editFileC->value().value<QAD::File>().file); conf.setValue("file_c", editFileC->value().value<QAD::File>().file);
conf.setValue("file_m", editFileM->value().value<QAD::File>().file); conf.setValue("file_m", editFileM->value().value<QAD::File>().file);
conf.setValue("sync_files", checkSyncFiles->isChecked()); conf.setValue("sync_files", checkSyncFiles->isChecked());
conf.setValue("session_name", lineSessionName->text()); conf.setValue("session_name", lineSessionName->text());
conf.setValue("icon_path", last_icon); conf.setValue("icon_path", last_icon);
conf.setValue("icon", appIcon()); conf.setValue("icon", appIcon());
conf.setValue("has_k", checkHasK->isChecked()); conf.setValue("has_k", checkHasK->isChecked());
conf.setValue("has_x", checkHasX->isChecked()); conf.setValue("has_x", checkHasX->isChecked());
conf.setValue("has_c", checkHasC->isChecked()); conf.setValue("has_c", checkHasC->isChecked());
conf.setValue("has_m", checkHasM->isChecked()); conf.setValue("has_m", checkHasM->isChecked());
conf.setValue("default_config", checkDefaultConfig->isChecked()); conf.setValue("default_config", checkDefaultConfig->isChecked());
conf.setValue("config", QString2QByteArray(codeConfig->text())); conf.setValue("config", QString2QByteArray(codeConfig->text()));
conf.setValue("session_gr", session_gr); conf.setValue("session_gr", session_gr);
conf.setValue("session_dk", session_dk); conf.setValue("session_dk", session_dk);
conf.setValue("session_mw", session_mw); conf.setValue("session_mw", session_mw);
file_name = path; file_name = path;
return true; return true;
//widgetK->setFile(path); //widgetK->setFile(path);
//widgetK->save(); //widgetK->save();
} }
void CDPultWindow::loadingSession(QPIConfig & conf) { void CDPultWindow::loadingSession(QPIConfig & conf) {
setRecentFiles(conf.getValue("recent files").toStringList()); setRecentFiles(conf.getValue("recent files").toStringList());
} }
void CDPultWindow::savingSession(QPIConfig & conf) { void CDPultWindow::savingSession(QPIConfig & conf) {
conf.setValue("recent files", recentFiles()); conf.setValue("recent files", recentFiles());
} }
QByteArray CDPultWindow::appIcon() const { QByteArray CDPultWindow::appIcon() const {
QByteArray ret; QByteArray ret;
if (icon.isNull()) return ret; if (icon.isNull()) return ret;
QBuffer buff(&ret); QBuffer buff(&ret);
buff.open(QIODevice::WriteOnly); buff.open(QIODevice::WriteOnly);
icon.save(&buff, "png"); icon.save(&buff, "png");
//qDebug() << "s" << ret.size(); //qDebug() << "s" << ret.size();
return ret; return ret;
} }
void CDPultWindow::setAppIcon(QByteArray ba) { void CDPultWindow::setAppIcon(QByteArray ba) {
if (ba.isEmpty()) { if (ba.isEmpty()) {
icon = QImage(); icon = QImage();
setWindowIcon(QIcon()); setWindowIcon(QIcon());
return; return;
} }
//qDebug() << "l" << ba.size(); //qDebug() << "l" << ba.size();
icon = QImage::fromData(ba); icon = QImage::fromData(ba);
setWindowIcon(QIcon(QPixmap::fromImage(icon))); setWindowIcon(QIcon(QPixmap::fromImage(icon)));
//qDebug() << QApplication::windowIcon().availableSizes(); //qDebug() << QApplication::windowIcon().availableSizes();
} }
void CDPultWindow::addToLog(CDViewWidget::LogIcon icon, const QString & msg) { void CDPultWindow::addToLog(CDViewWidget::LogIcon icon, const QString & msg) {
QListWidgetItem * ni = new QListWidgetItem(log_icons[icon], "(" + QTime::currentTime().toString() + ") " + msg); QListWidgetItem * ni = new QListWidgetItem(log_icons[icon], "(" + QTime::currentTime().toString() + ") " + msg);
bool s = listLog->verticalScrollBar()->value() == listLog->verticalScrollBar()->maximum(); bool s = listLog->verticalScrollBar()->value() == listLog->verticalScrollBar()->maximum();
listLog->addItem(ni); listLog->addItem(ni);
if (s) listLog->scrollToBottom(); if (s) listLog->scrollToBottom();
} }
void CDPultWindow::messageReceived(QString path, int type, QString msg) { void CDPultWindow::messageReceived(QString path, int type, QString msg) {
MessageType mt = (MessageType)type; MessageType mt = (MessageType)type;
const CDType & t(M.root()[CDCore::stringToPath(Q2PIString(path))]); const CDType & t(M.root()[CDCore::stringToPath(Q2PIString(path))]);
if (t.cd_type() != CDType::cdM) return; if (t.cd_type() != CDType::cdM) return;
if (mt == MessageBox) if (mt == MessageBox)
QMessageBox::information(this, windowTitle(), QString("[%1]\n%2").arg(PI2QString(t.name()), msg)); QMessageBox::information(this, windowTitle(), QString("[%1]\n%2").arg(PI2QString(t.name()), msg));
} }
void CDPultWindow::on_editFileK_valueChanged(const QVariant & p) { void CDPultWindow::on_editFileK_valueChanged(const QVariant & p) {
if (!checkSyncFiles->isChecked()) return; if (!checkSyncFiles->isChecked()) return;
QFileInfo fi(p.value<QAD::File>().file); QFileInfo fi(p.value<QAD::File>().file);
if (fi.path().isEmpty()) return; if (fi.path().isEmpty()) return;
QString n = fi.baseName(); QString n = fi.baseName();
QString xn(n), cn(n), mn(n); QString xn(n), cn(n), mn(n);
if (n.contains("k")) { if (n.contains("k")) {
xn.replace(n.indexOf("k"), 1, "x"); xn.replace(n.indexOf("k"), 1, "x");
cn.replace(n.indexOf("k"), 1, "c"); cn.replace(n.indexOf("k"), 1, "c");
mn.replace(n.indexOf("k"), 1, "m"); mn.replace(n.indexOf("k"), 1, "m");
} else { } else {
xn += "_x"; xn += "_x";
cn += "_c"; cn += "_c";
mn += "_m"; mn += "_m";
} }
QString ext = fi.suffix(), dot, dir; QString ext = fi.suffix(), dot, dir;
QString kfn(fi.filePath()); QString kfn(fi.filePath());
if (!ext.isEmpty()) { if (!ext.isEmpty()) {
kfn.chop(ext.size()); kfn.chop(ext.size());
if (kfn.endsWith(".")) { if (kfn.endsWith(".")) {
kfn.chop(1); kfn.chop(1);
dot = "."; dot = ".";
} }
} }
if (!fi.path().isEmpty() && fi.path() != ".") { if (!fi.path().isEmpty() && fi.path() != ".") {
dir = fi.path(); dir = fi.path();
if (!dir.endsWith("/")) if (!dir.endsWith("/"))
dir += "/"; dir += "/";
} }
QAD::File f = editFileK->value().value<QAD::File>(); QAD::File f = editFileK->value().value<QAD::File>();
f.file = dir + xn + dot + ext; editFileX->setValue(QVariant::fromValue(f)); f.file = dir + xn + dot + ext; editFileX->setValue(QVariant::fromValue(f));
f.file = dir + cn + dot + ext; editFileC->setValue(QVariant::fromValue(f)); f.file = dir + cn + dot + ext; editFileC->setValue(QVariant::fromValue(f));
f.file = dir + mn + dot + ext; editFileM->setValue(QVariant::fromValue(f)); f.file = dir + mn + dot + ext; editFileM->setValue(QVariant::fromValue(f));
} }
void CDPultWindow::on_buttonSessionApply_clicked() { void CDPultWindow::on_buttonSessionApply_clicked() {
apply(false); apply(false);
} }
void CDPultWindow::on_lineSessionName_textChanged(const QString & t) { void CDPultWindow::on_lineSessionName_textChanged(const QString & t) {
setWindowTitle(QString("CD Pult - %1").arg(t)); setWindowTitle(QString("CD Pult - %1").arg(t));
} }
void CDPultWindow::on_buttonIcon_clicked() { void CDPultWindow::on_buttonIcon_clicked() {
QList<QByteArray> ifl = QImageReader::supportedImageFormats(); QList<QByteArray> ifl = QImageReader::supportedImageFormats();
QStringList sfl; foreach (QByteArray s, ifl) sfl << ("*." + QString(s).toLower()); QStringList sfl; foreach (QByteArray s, ifl) sfl << ("*." + QString(s).toLower());
QString f = QFileDialog::getOpenFileName(this, tr("Select icon"), last_icon, tr("Images") + " (" + sfl.join(" ") + ")"); QString f = QFileDialog::getOpenFileName(this, tr("Select icon"), last_icon, tr("Images") + " (" + sfl.join(" ") + ")");
if (f.isEmpty()) return; if (f.isEmpty()) return;
last_icon = f; last_icon = f;
icon = QImage(last_icon); icon = QImage(last_icon);
setWindowIcon(QIcon(QPixmap::fromImage(icon))); setWindowIcon(QIcon(QPixmap::fromImage(icon)));
} }

View File

@@ -1,53 +1,53 @@
#ifndef CDPULTWINDOW_H #ifndef CDPULTWINDOW_H
#define CDPULTWINDOW_H #define CDPULTWINDOW_H
#include "emainwindow.h" #include "emainwindow.h"
#include "ui_cdpultwindow.h" #include "ui_cdpultwindow.h"
#include "cdviewwidget.h" #include "cdviewwidget.h"
#include "ribbon.h" #include "ribbon.h"
#include "piobject.h" #include "piobject.h"
class CDPultWindow : public EMainWindow, public Ui::CDPultWindow class CDPultWindow : public EMainWindow, public Ui::CDPultWindow
{ {
Q_OBJECT Q_OBJECT
Q_ENUMS(LogIcon) Q_ENUMS(LogIcon)
public: public:
explicit CDPultWindow(QWidget *parent = 0); explicit CDPultWindow(QWidget *parent = 0);
~CDPultWindow(); ~CDPultWindow();
void loadFile(const QString & fp); void loadFile(const QString & fp);
void apply(bool sessions); void apply(bool sessions);
private: private:
void closeEvent(QCloseEvent *); void closeEvent(QCloseEvent *);
void reset(bool full = false); void reset(bool full = false);
bool load(const QString & path); bool load(const QString & path);
bool save(const QString & path); bool save(const QString & path);
QString loadFilter() {return "Pult session(*.conf)";} QString loadFilter() {return "Pult session(*.conf)";}
QString saveFilter() {return loadFilter();} QString saveFilter() {return loadFilter();}
void loadingSession(QPIConfig & conf); void loadingSession(QPIConfig & conf);
void savingSession(QPIConfig & conf); void savingSession(QPIConfig & conf);
QByteArray appIcon() const; QByteArray appIcon() const;
void setAppIcon(QByteArray ba); void setAppIcon(QByteArray ba);
Ribbon * ribbon; Ribbon * ribbon;
QMap<CDViewWidget::LogIcon, QIcon> log_icons; QMap<CDViewWidget::LogIcon, QIcon> log_icons;
QByteArray session_gr, session_dk, session_mw; QByteArray session_gr, session_dk, session_mw;
QString def_config, last_icon; QString def_config, last_icon;
QImage icon; QImage icon;
private slots: private slots:
void addToLog(CDViewWidget::LogIcon icon, const QString & msg); void addToLog(CDViewWidget::LogIcon icon, const QString & msg);
void messageReceived(QString path, int type, QString msg); void messageReceived(QString path, int type, QString msg);
void on_editFileK_valueChanged(const QVariant & p); void on_editFileK_valueChanged(const QVariant & p);
void on_buttonSessionApply_clicked(); void on_buttonSessionApply_clicked();
void on_lineSessionName_textChanged(const QString & t); void on_lineSessionName_textChanged(const QString & t);
void on_buttonIcon_clicked(); void on_buttonIcon_clicked();
}; };
#endif // CDPULTWINDOW_H #endif // CDPULTWINDOW_H

View File

@@ -1,612 +1,612 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>CDPultWindow</class> <class>CDPultWindow</class>
<widget class="EMainWindow" name="CDPultWindow"> <widget class="EMainWindow" name="CDPultWindow">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>798</width> <width>798</width>
<height>593</height> <height>593</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>CD Pult</string> <string>CD Pult</string>
</property> </property>
<property name="dockNestingEnabled"> <property name="dockNestingEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="dockOptions"> <property name="dockOptions">
<set>QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks</set> <set>QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks</set>
</property> </property>
<widget class="QWidget" name="central"/> <widget class="QWidget" name="central"/>
<widget class="QMenuBar" name="menuBar"> <widget class="QMenuBar" name="menuBar">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>798</width> <width>798</width>
<height>24</height> <height>24</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuMain"> <widget class="QMenu" name="menuMain">
<property name="title"> <property name="title">
<string>Main</string> <string>Main</string>
</property> </property>
<widget class="QMenu" name="menuOpen_recent"> <widget class="QMenu" name="menuOpen_recent">
<property name="title"> <property name="title">
<string>Open recent</string> <string>Open recent</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../qad/application/qad_application.qrc"> <iconset resource="../../qad/application/qad_application.qrc">
<normaloff>:/icons/document-open-recent.png</normaloff>:/icons/document-open-recent.png</iconset> <normaloff>:/icons/document-open-recent.png</normaloff>:/icons/document-open-recent.png</iconset>
</property> </property>
</widget> </widget>
<addaction name="actionOpen"/> <addaction name="actionOpen"/>
<addaction name="menuOpen_recent"/> <addaction name="menuOpen_recent"/>
<addaction name="actionSave"/> <addaction name="actionSave"/>
<addaction name="actionSaveAs"/> <addaction name="actionSaveAs"/>
</widget> </widget>
<addaction name="menuMain"/> <addaction name="menuMain"/>
</widget> </widget>
<widget class="EDockWidget" name="dockCDKView"> <widget class="EDockWidget" name="dockCDKView">
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="../../qad/application/qad_application.qrc"> <iconset resource="../../qad/application/qad_application.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="windowTitle"> <property name="windowTitle">
<string>K</string> <string>K</string>
</property> </property>
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>1</number> <number>1</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents"> <widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="CDViewWidget" name="widgetK" native="true"/> <widget class="CDViewWidget" name="widgetK" native="true"/>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="EDockWidget" name="dockLog"> <widget class="EDockWidget" name="dockLog">
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="cdpult.qrc"> <iconset resource="cdpult.qrc">
<normaloff>:/icons/dialog-information.png</normaloff>:/icons/dialog-information.png</iconset> <normaloff>:/icons/dialog-information.png</normaloff>:/icons/dialog-information.png</iconset>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Log</string> <string>Log</string>
</property> </property>
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>8</number> <number>8</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_2"> <widget class="QWidget" name="dockWidgetContents_2">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QListWidget" name="listLog"> <widget class="QListWidget" name="listLog">
<property name="editTriggers"> <property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set> <set>QAbstractItemView::NoEditTriggers</set>
</property> </property>
<property name="showDropIndicator" stdset="0"> <property name="showDropIndicator" stdset="0">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="alternatingRowColors"> <property name="alternatingRowColors">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="selectionMode"> <property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum> <enum>QAbstractItemView::SingleSelection</enum>
</property> </property>
<property name="selectionBehavior"> <property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum> <enum>QAbstractItemView::SelectRows</enum>
</property> </property>
<property name="verticalScrollMode"> <property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum> <enum>QAbstractItemView::ScrollPerPixel</enum>
</property> </property>
<property name="horizontalScrollMode"> <property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum> <enum>QAbstractItemView::ScrollPerPixel</enum>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="EDockWidget" name="dockCDXView"> <widget class="EDockWidget" name="dockCDXView">
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="../../qad/widgets/qad_widgets.qrc"> <iconset resource="../../qad/widgets/qad_widgets.qrc">
<normaloff>:/icons/qvariantedit.png</normaloff>:/icons/qvariantedit.png</iconset> <normaloff>:/icons/qvariantedit.png</normaloff>:/icons/qvariantedit.png</iconset>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>X</string> <string>X</string>
</property> </property>
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>1</number> <number>1</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_3"> <widget class="QWidget" name="dockWidgetContents_3">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
<widget class="CDViewWidget" name="widgetX" native="true"/> <widget class="CDViewWidget" name="widgetX" native="true"/>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="EDockWidget" name="dockSession"> <widget class="EDockWidget" name="dockSession">
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="../../qad/application/qad_application.qrc"> <iconset resource="../../qad/application/qad_application.qrc">
<normaloff>:/icons/configure.png</normaloff>:/icons/configure.png</iconset> <normaloff>:/icons/configure.png</normaloff>:/icons/configure.png</iconset>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Session</string> <string>Session</string>
</property> </property>
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>2</number> <number>2</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_4"> <widget class="QWidget" name="dockWidgetContents_4">
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QPushButton" name="buttonSessionApply"> <widget class="QPushButton" name="buttonSessionApply">
<property name="text"> <property name="text">
<string>Apply</string> <string>Apply</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../qad/widgets/qad_widgets.qrc"> <iconset resource="../../qad/widgets/qad_widgets.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>
</item> </item>
<item> <item>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy"> <property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum> <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property> </property>
<property name="labelAlignment"> <property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="text"> <property name="text">
<string>Name:</string> <string>Name:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="CLineEdit" name="lineSessionName"/> <widget class="CLineEdit" name="lineSessionName"/>
</item> </item>
<item> <item>
<widget class="QPushButton" name="buttonIcon"> <widget class="QPushButton" name="buttonIcon">
<property name="toolTip"> <property name="toolTip">
<string>Select icon...</string> <string>Select icon...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../qad/blockview/qad_blockview.qrc"> <iconset resource="../../qad/blockview/qad_blockview.qrc">
<normaloff>:/icons/view-preview.png</normaloff>:/icons/view-preview.png</iconset> <normaloff>:/icons/view-preview.png</normaloff>:/icons/view-preview.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>K file:</string> <string>K file:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QVariantEdit" name="editFileK"/> <widget class="QVariantEdit" name="editFileK"/>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>X file:</string> <string>X file:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QVariantEdit" name="editFileX"/> <widget class="QVariantEdit" name="editFileX"/>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>C file:</string> <string>C file:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QVariantEdit" name="editFileC"/> <widget class="QVariantEdit" name="editFileC"/>
</item> </item>
<item row="5" column="0" colspan="2"> <item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="checkSyncFiles"> <widget class="QCheckBox" name="checkSyncFiles">
<property name="text"> <property name="text">
<string>Sync files</string> <string>Sync files</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0" colspan="2"> <item row="6" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QCheckBox" name="checkHasK"> <widget class="QCheckBox" name="checkHasK">
<property name="text"> <property name="text">
<string>K</string> <string>K</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkHasX"> <widget class="QCheckBox" name="checkHasX">
<property name="text"> <property name="text">
<string>X</string> <string>X</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkHasC"> <widget class="QCheckBox" name="checkHasC">
<property name="text"> <property name="text">
<string>C</string> <string>C</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkHasM"> <widget class="QCheckBox" name="checkHasM">
<property name="text"> <property name="text">
<string>M</string> <string>M</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="7" column="0" colspan="2"> <item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="checkDefaultConfig"> <widget class="QCheckBox" name="checkDefaultConfig">
<property name="text"> <property name="text">
<string>Default config</string> <string>Default config</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
<string>M file:</string> <string>M file:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="4" column="1">
<widget class="QVariantEdit" name="editFileM"/> <widget class="QVariantEdit" name="editFileM"/>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QCodeEdit" name="codeConfig"> <widget class="QCodeEdit" name="codeConfig">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>include = ip.conf <string>include = ip.conf
[connection] [connection]
device.cd = eth://udp:${ip.pult}:27002:${ip.app}:27001 #s device.cd = eth://udp:${ip.pult}:27002:${ip.app}:27001 #s
[] []
</string> </string>
</property> </property>
<property name="editorFont"> <property name="editorFont">
<font> <font>
<family>DejaVu Sans Mono</family> <family>DejaVu Sans Mono</family>
<pointsize>9</pointsize> <pointsize>9</pointsize>
</font> </font>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="EDockWidget" name="dockCDCView"> <widget class="EDockWidget" name="dockCDCView">
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="../../qad/blockview/qad_blockview.qrc"> <iconset resource="../../qad/blockview/qad_blockview.qrc">
<normaloff>:/icons/legend.png</normaloff>:/icons/legend.png</iconset> <normaloff>:/icons/legend.png</normaloff>:/icons/legend.png</iconset>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>C</string> <string>C</string>
</property> </property>
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>1</number> <number>1</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_5"> <widget class="QWidget" name="dockWidgetContents_5">
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">
<item> <item>
<widget class="CDViewWidget" name="widgetC" native="true"/> <widget class="CDViewWidget" name="widgetC" native="true"/>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="EDockWidget" name="dockGraphics"> <widget class="EDockWidget" name="dockGraphics">
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="../../qad/blockview/qad_blockview.qrc"> <iconset resource="../../qad/blockview/qad_blockview.qrc">
<normaloff>:/icons/format-stroke-color.png</normaloff>:/icons/format-stroke-color.png</iconset> <normaloff>:/icons/format-stroke-color.png</normaloff>:/icons/format-stroke-color.png</iconset>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Graphics</string> <string>Graphics</string>
</property> </property>
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>8</number> <number>8</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_6"> <widget class="QWidget" name="dockWidgetContents_6">
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="verticalLayout_6">
<item> <item>
<widget class="CDGraphics" name="widgetGraphics" native="true"/> <widget class="CDGraphics" name="widgetGraphics" native="true"/>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="EDockWidget" name="dockDirectK"> <widget class="EDockWidget" name="dockDirectK">
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="../../qad/widgets/qad_widgets.qrc"> <iconset resource="../../qad/widgets/qad_widgets.qrc">
<normaloff>:/icons/tools-wizard.png</normaloff>:/icons/tools-wizard.png</iconset> <normaloff>:/icons/tools-wizard.png</normaloff>:/icons/tools-wizard.png</iconset>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Direct K</string> <string>Direct K</string>
</property> </property>
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>8</number> <number>8</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_7"> <widget class="QWidget" name="dockWidgetContents_7">
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
<item> <item>
<widget class="CDDirectK" name="widgetDirectK" native="true"/> <widget class="CDDirectK" name="widgetDirectK" native="true"/>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="EDockWidget" name="dockCDMView"> <widget class="EDockWidget" name="dockCDMView">
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="cdpult.qrc"> <iconset resource="cdpult.qrc">
<normaloff>:/icons/accessories-text-editor.png</normaloff>:/icons/accessories-text-editor.png</iconset> <normaloff>:/icons/accessories-text-editor.png</normaloff>:/icons/accessories-text-editor.png</iconset>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>M</string> <string>M</string>
</property> </property>
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>1</number> <number>1</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_8"> <widget class="QWidget" name="dockWidgetContents_8">
<layout class="QVBoxLayout" name="verticalLayout_8"> <layout class="QVBoxLayout" name="verticalLayout_8">
<item> <item>
<widget class="CDViewWidget" name="widgetM" native="true"/> <widget class="CDViewWidget" name="widgetM" native="true"/>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
<action name="actionOpen"> <action name="actionOpen">
<property name="icon"> <property name="icon">
<iconset resource="../../qad/application/qad_application.qrc"> <iconset resource="../../qad/application/qad_application.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="text"> <property name="text">
<string>Open...</string> <string>Open...</string>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+O</string> <string>Ctrl+O</string>
</property> </property>
</action> </action>
<action name="actionSave"> <action name="actionSave">
<property name="icon"> <property name="icon">
<iconset resource="../../qad/application/qad_application.qrc"> <iconset resource="../../qad/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>
<property name="text"> <property name="text">
<string>Save</string> <string>Save</string>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+S</string> <string>Ctrl+S</string>
</property> </property>
</action> </action>
<action name="actionSaveAs"> <action name="actionSaveAs">
<property name="icon"> <property name="icon">
<iconset resource="../../qad/application/qad_application.qrc"> <iconset resource="../../qad/application/qad_application.qrc">
<normaloff>:/icons/document-save-as.png</normaloff>:/icons/document-save-as.png</iconset> <normaloff>:/icons/document-save-as.png</normaloff>:/icons/document-save-as.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Save As...</string> <string>Save As...</string>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+Shift+S</string> <string>Ctrl+Shift+S</string>
</property> </property>
</action> </action>
<addaction name="actionOpen"/> <addaction name="actionOpen"/>
<addaction name="actionSave"/> <addaction name="actionSave"/>
<addaction name="actionSaveAs"/> <addaction name="actionSaveAs"/>
<addaction name="menuMain"/> <addaction name="menuMain"/>
<addaction name="menuOpen_recent"/> <addaction name="menuOpen_recent"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="separator"/> <addaction name="separator"/>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>EMainWindow</class> <class>EMainWindow</class>
<extends>QMainWindow</extends> <extends>QMainWindow</extends>
<header>emainwindow.h</header> <header>emainwindow.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>CLineEdit</class> <class>CLineEdit</class>
<extends>QLineEdit</extends> <extends>QLineEdit</extends>
<header>clineedit.h</header> <header>clineedit.h</header>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>QCodeEdit</class> <class>QCodeEdit</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header>qcodeedit.h</header> <header>qcodeedit.h</header>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>QVariantEdit</class> <class>QVariantEdit</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header>qvariantedit.h</header> <header>qvariantedit.h</header>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>EDockWidget</class> <class>EDockWidget</class>
<extends>QDockWidget</extends> <extends>QDockWidget</extends>
<header>edockwidget.h</header> <header>edockwidget.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>CDViewWidget</class> <class>CDViewWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header>cdviewwidget.h</header> <header>cdviewwidget.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>CDGraphics</class> <class>CDGraphics</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header>cdgraphics.h</header> <header>cdgraphics.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>CDDirectK</class> <class>CDDirectK</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header>cddirectk.h</header> <header>cddirectk.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../../qad/application/qad_application.qrc"/> <include location="../../qad/application/qad_application.qrc"/>
<include location="../../qad/blockview/qad_blockview.qrc"/> <include location="../../qad/blockview/qad_blockview.qrc"/>
<include location="../../qad/widgets/qad_widgets.qrc"/> <include location="../../qad/widgets/qad_widgets.qrc"/>
<include location="cdpult.qrc"/> <include location="cdpult.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>
<sender>actionSave</sender> <sender>actionSave</sender>
<signal>triggered()</signal> <signal>triggered()</signal>
<receiver>CDPultWindow</receiver> <receiver>CDPultWindow</receiver>
<slot>saveFile()</slot> <slot>saveFile()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>-1</x> <x>-1</x>
<y>-1</y> <y>-1</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>399</x> <x>399</x>
<y>299</y> <y>299</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>actionSaveAs</sender> <sender>actionSaveAs</sender>
<signal>triggered()</signal> <signal>triggered()</signal>
<receiver>CDPultWindow</receiver> <receiver>CDPultWindow</receiver>
<slot>saveAsFile()</slot> <slot>saveAsFile()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>-1</x> <x>-1</x>
<y>-1</y> <y>-1</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>399</x> <x>399</x>
<y>299</y> <y>299</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>actionOpen</sender> <sender>actionOpen</sender>
<signal>triggered()</signal> <signal>triggered()</signal>
<receiver>CDPultWindow</receiver> <receiver>CDPultWindow</receiver>
<slot>openFile()</slot> <slot>openFile()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>-1</x> <x>-1</x>
<y>-1</y> <y>-1</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>399</x> <x>399</x>
<y>299</y> <y>299</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>checkSyncFiles</sender> <sender>checkSyncFiles</sender>
<signal>toggled(bool)</signal> <signal>toggled(bool)</signal>
<receiver>editFileX</receiver> <receiver>editFileX</receiver>
<slot>setDisabled(bool)</slot> <slot>setDisabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>786</x> <x>786</x>
<y>220</y> <y>220</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>786</x> <x>786</x>
<y>151</y> <y>151</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>checkSyncFiles</sender> <sender>checkSyncFiles</sender>
<signal>toggled(bool)</signal> <signal>toggled(bool)</signal>
<receiver>editFileC</receiver> <receiver>editFileC</receiver>
<slot>setDisabled(bool)</slot> <slot>setDisabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>786</x> <x>786</x>
<y>220</y> <y>220</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>786</x> <x>786</x>
<y>172</y> <y>172</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>checkDefaultConfig</sender> <sender>checkDefaultConfig</sender>
<signal>toggled(bool)</signal> <signal>toggled(bool)</signal>
<receiver>codeConfig</receiver> <receiver>codeConfig</receiver>
<slot>setDisabled(bool)</slot> <slot>setDisabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>786</x> <x>786</x>
<y>276</y> <y>276</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>581</x> <x>581</x>
<y>304</y> <y>304</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>checkSyncFiles</sender> <sender>checkSyncFiles</sender>
<signal>toggled(bool)</signal> <signal>toggled(bool)</signal>
<receiver>editFileM</receiver> <receiver>editFileM</receiver>
<slot>setDisabled(bool)</slot> <slot>setDisabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>767</x> <x>767</x>
<y>205</y> <y>205</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>767</x> <x>767</x>
<y>187</y> <y>187</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
</connections> </connections>
</ui> </ui>

View File

@@ -1,78 +1,78 @@
#include "cdviewwidget.h" #include "cdviewwidget.h"
#include "cdutils_core.h" #include "cdutils_core.h"
#include "qcd_core.h" #include "qcd_core.h"
#include "qcd_model.h" #include "qcd_model.h"
#include "qcd_modedialog.h" #include "qcd_modedialog.h"
#include "qvariantedit.h" #include "qvariantedit.h"
#include <QFileDialog> #include <QFileDialog>
CDViewWidget::CDViewWidget(QWidget * parent) : QWidget(parent), Ui::CDViewWidget() { CDViewWidget::CDViewWidget(QWidget * parent) : QWidget(parent), Ui::CDViewWidget() {
qRegisterMetaType<CDViewWidget::LogIcon>("CDViewWidget::LogIcon"); qRegisterMetaType<CDViewWidget::LogIcon>("CDViewWidget::LogIcon");
setupUi(this); setupUi(this);
connect(view, SIGNAL(sendSucceed()), this, SLOT(sended())); connect(view, SIGNAL(sendSucceed()), this, SLOT(sended()));
connect(view, SIGNAL(receiveSucceed()), this, SLOT(received())); connect(view, SIGNAL(receiveSucceed()), this, SLOT(received()));
connect(view, SIGNAL(sendFailed()), this, SLOT(sendFailed())); connect(view, SIGNAL(sendFailed()), this, SLOT(sendFailed()));
connect(view, SIGNAL(receiveFailed()), this, SLOT(receiveFailed())); connect(view, SIGNAL(receiveFailed()), this, SLOT(receiveFailed()));
} }
CDViewWidget::~CDViewWidget() { CDViewWidget::~CDViewWidget() {
} }
void CDViewWidget::reset() { void CDViewWidget::reset() {
setFile(""); setFile("");
} }
void CDViewWidget::setType(int t) { void CDViewWidget::setType(int t) {
view->setType((CDUtils::CDType::cdT)t); view->setType((CDUtils::CDType::cdT)t);
tl_u = view->typeLetter().toUpper(); tl_u = view->typeLetter().toUpper();
tl_l = view->typeLetter().toLower(); tl_l = view->typeLetter().toLower();
view->refresh(); view->refresh();
} }
void CDViewWidget::setFile(const QString & f) { void CDViewWidget::setFile(const QString & f) {
view->setFile(f); view->setFile(f);
view->load(); view->load();
} }
void CDViewWidget::on_buttonSend_clicked() { void CDViewWidget::on_buttonSend_clicked() {
if (view->inProgress()) {addToLog(WaitIcon, "processing..."); return;} if (view->inProgress()) {addToLog(WaitIcon, "processing..."); return;}
addToLog(WaitIcon, "Sending " + tl_u + "..."); addToLog(WaitIcon, "Sending " + tl_u + "...");
view->send(); view->send();
} }
void CDViewWidget::on_buttonReceive_clicked() { void CDViewWidget::on_buttonReceive_clicked() {
if (view->inProgress()) {addToLog(WaitIcon, "processing..."); return;} if (view->inProgress()) {addToLog(WaitIcon, "processing..."); return;}
addToLog(WaitIcon, "Receiving " + tl_u + "..."); addToLog(WaitIcon, "Receiving " + tl_u + "...");
view->receive(); view->receive();
} }
void CDViewWidget::on_buttonLoad_clicked() { void CDViewWidget::on_buttonLoad_clicked() {
view->load(); view->load();
} }
void CDViewWidget::on_buttonSave_clicked() { void CDViewWidget::on_buttonSave_clicked() {
view->save(); view->save();
} }
void CDViewWidget::on_buttonParse_clicked() { void CDViewWidget::on_buttonParse_clicked() {
QString path = QFileDialog::getOpenFileName(this, "Select header file", "", QString path = QFileDialog::getOpenFileName(this, "Select header file", "",
QString("%1 Description(%2_description.h);;Headers(*.h)").arg(tl_u, tl_l)); QString("%1 Description(%2_description.h);;Headers(*.h)").arg(tl_u, tl_l));
if (path.isEmpty()) return; if (path.isEmpty()) return;
CDUtils::UpdateModeFlags mode = CDUtils::SaveByName; CDUtils::UpdateModeFlags mode = CDUtils::SaveByName;
if (!view->root()->isEmpty()) { if (!view->root()->isEmpty()) {
QCDModeDialog cdm; QCDModeDialog cdm;
if (cdm.exec() != QDialog::Accepted) return; if (cdm.exec() != QDialog::Accepted) return;
mode = cdm.mode(); mode = cdm.mode();
} }
view->buildFromHeader(path, mode); view->buildFromHeader(path, mode);
} }

View File

@@ -1,41 +1,41 @@
#ifndef CDVIEWWIDGET_H #ifndef CDVIEWWIDGET_H
#define CDVIEWWIDGET_H #define CDVIEWWIDGET_H
#include <QWidget> #include <QWidget>
#include "ui_cdviewwidget.h" #include "ui_cdviewwidget.h"
class CDViewWidget : public QWidget, public Ui::CDViewWidget class CDViewWidget : public QWidget, public Ui::CDViewWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CDViewWidget(QWidget *parent = 0); explicit CDViewWidget(QWidget *parent = 0);
~CDViewWidget(); ~CDViewWidget();
enum LogIcon {NoIcon, OKIcon, FailIcon, WaitIcon}; enum LogIcon {NoIcon, OKIcon, FailIcon, WaitIcon};
void reset(); void reset();
void setType(int t); void setType(int t);
void setFile(const QString & f); void setFile(const QString & f);
private: private:
QString tl_u, tl_l; QString tl_u, tl_l;
private slots: private slots:
void sended() {addToLog(OKIcon, tl_u + " " + tr("sended succesfull"));} void sended() {addToLog(OKIcon, tl_u + " " + tr("sended succesfull"));}
void received() {addToLog(OKIcon, tl_u + " " + tr("received succesfull"));} void received() {addToLog(OKIcon, tl_u + " " + tr("received succesfull"));}
void sendFailed() {addToLog(FailIcon, tl_u + " " + tr("NOT sended"));} void sendFailed() {addToLog(FailIcon, tl_u + " " + tr("NOT sended"));}
void receiveFailed() {addToLog(FailIcon, tl_u + " " + tr("NOT received"));} void receiveFailed() {addToLog(FailIcon, tl_u + " " + tr("NOT received"));}
void on_buttonSend_clicked(); void on_buttonSend_clicked();
void on_buttonReceive_clicked(); void on_buttonReceive_clicked();
void on_buttonLoad_clicked(); void on_buttonLoad_clicked();
void on_buttonSave_clicked(); void on_buttonSave_clicked();
void on_buttonParse_clicked(); void on_buttonParse_clicked();
//void on_buttonCalculate_clicked(); //void on_buttonCalculate_clicked();
signals: signals:
void addToLog(CDViewWidget::LogIcon icon, const QString & msg); void addToLog(CDViewWidget::LogIcon icon, const QString & msg);
}; };
#endif // CDVIEWWIDGET_H #endif // CDVIEWWIDGET_H

View File

@@ -1,176 +1,176 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>CDViewWidget</class> <class>CDViewWidget</class>
<widget class="QWidget" name="CDViewWidget"> <widget class="QWidget" name="CDViewWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>689</width> <width>689</width>
<height>459</height> <height>459</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>CD Pult</string> <string>CD Pult</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1"> <layout class="QHBoxLayout" name="horizontalLayout" stretch="1">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QPushButton" name="buttonSend"> <widget class="QPushButton" name="buttonSend">
<property name="text"> <property name="text">
<string>Send</string> <string>Send</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="cdpult.qrc"> <iconset resource="cdpult.qrc">
<normaloff>:/icons/flame.png</normaloff>:/icons/flame.png</iconset> <normaloff>:/icons/flame.png</normaloff>:/icons/flame.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="buttonReceive"> <widget class="QPushButton" name="buttonReceive">
<property name="text"> <property name="text">
<string>Receive</string> <string>Receive</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="cdpult.qrc"> <iconset resource="cdpult.qrc">
<normaloff>:/icons/document-revert.png</normaloff>:/icons/document-revert.png</iconset> <normaloff>:/icons/document-revert.png</normaloff>:/icons/document-revert.png</iconset>
</property> </property>
</widget> </widget>
</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="QPushButton" name="buttonLoad"> <widget class="QPushButton" name="buttonLoad">
<property name="text"> <property name="text">
<string>Load</string> <string>Load</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../qad/application/qad_application.qrc"> <iconset resource="../../qad/application/qad_application.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>
</item> </item>
<item> <item>
<widget class="QPushButton" name="buttonSave"> <widget class="QPushButton" name="buttonSave">
<property name="text"> <property name="text">
<string>Save</string> <string>Save</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../qad/application/qad_application.qrc"> <iconset resource="../../qad/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>
<item> <item>
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
<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="QPushButton" name="buttonParse"> <widget class="QPushButton" name="buttonParse">
<property name="text"> <property name="text">
<string>Update description ...</string> <string>Update description ...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="cdpult.qrc"> <iconset resource="cdpult.qrc">
<normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset> <normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_3"> <spacer name="horizontalSpacer_3">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType"> <property name="sizeType">
<enum>QSizePolicy::Expanding</enum> <enum>QSizePolicy::Expanding</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>1</width> <width>1</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="CDView" name="view"> <widget class="CDView" name="view">
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum> <enum>Qt::CustomContextMenu</enum>
</property> </property>
<property name="editTriggers"> <property name="editTriggers">
<set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set> <set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set>
</property> </property>
<property name="dragEnabled"> <property name="dragEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="dragDropMode"> <property name="dragDropMode">
<enum>QAbstractItemView::DragOnly</enum> <enum>QAbstractItemView::DragOnly</enum>
</property> </property>
<property name="verticalScrollMode"> <property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum> <enum>QAbstractItemView::ScrollPerPixel</enum>
</property> </property>
<property name="horizontalScrollMode"> <property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum> <enum>QAbstractItemView::ScrollPerPixel</enum>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>CDView</class> <class>CDView</class>
<extends>QTreeView</extends> <extends>QTreeView</extends>
<header>qcd_view.h</header> <header>qcd_view.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../../qad/application/qad_application.qrc"/> <include location="../../qad/application/qad_application.qrc"/>
<include location="cdpult.qrc"/> <include location="cdpult.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

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