Compare commits

..

95 Commits

Author SHA1 Message Date
scorpio810
f2ba6a4bbe Tag version 0.4 RC2
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/tags/0.4rc2@3573 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-27 14:03:29 +00:00
scorpio810
5ec7ea194f Update TS files
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3572 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-27 13:39:51 +00:00
blacksun
a3525b466d QETDiagramEditor : clean some code
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3571 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-26 19:41:00 +00:00
scorpio810
f93b0817d6 Prepare for release candidate 2 tag
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3570 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-26 17:09:25 +00:00
blacksun
27f6b6c929 Remove information about internal connection in element editor
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3569 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-23 19:08:29 +00:00
blacksun
2c4af2b128 Remove all information about internal connection in element (obselete since internal connection is always allowed)
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3568 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-23 19:00:37 +00:00
scorpio810
10d086d378 Minor
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3567 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-23 02:06:36 +00:00
scorpio810
bcbf6ba431 Bug fix: disable entry edit text field for html editor for elements text in diagram
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3566 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-23 01:51:17 +00:00
blacksun
dfacacfdce Read only is no more managed for each diagram but for the whole project
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3565 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-21 13:17:35 +00:00
blacksun
a5b1a92beb Diagram : Constructor need a QETProject
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3564 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-21 12:50:26 +00:00
blacksun
8477d4d928 Diagram view : diagram isn't anymore optional in constructor
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3563 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-21 12:15:45 +00:00
blacksun
2147fca19b Generic panel : Fix wrong index when move diagram by x10
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3562 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-19 19:55:53 +00:00
blacksun
cf868a0cc8 When unlink an element, make sure this element isn't highlighted
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3561 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-19 19:18:05 +00:00
blacksun
51d40f9fcd Report element : minor improvement about text (text used to display the position of linked report is now tagged "label")
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3560 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-18 10:51:08 +00:00
rdsivd
11bf04390e Adapte langue be-nl
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3559 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-17 18:07:39 +00:00
pawel32640
ed263bb180 update polish translation
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3558 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-14 23:01:31 +00:00
silvio
0dd3386ec4 upgraded Italian translation of .ts file
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3557 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-14 21:59:14 +00:00
blacksun
e2211389e9 Minor clean code
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3556 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-14 21:52:27 +00:00
blacksun
0e9dc51879 Conductor text item : minor bug fix
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3555 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-14 21:30:58 +00:00
blacksun
3c94d9a054 Minor improvment : over element, highlight every linked elements
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3554 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-14 18:51:49 +00:00
aitolos
d385c6f8cf Update Greek translation
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3553 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-14 17:56:01 +00:00
scorpio810
164b442871 Update TS files
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3552 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-14 17:08:26 +00:00
scorpio810
83733f2dc6 Add new action DiagramMoveDownx10, DiagramMoveUpx10
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3551 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-14 17:01:11 +00:00
blacksun
0cc1424f90 Minor improvement
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3550 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-14 15:14:24 +00:00
blacksun
15261ba896 element text item : improve mouse double clic.
Over text (Only if tagged label or parent are report) will higlight element linked to parent element


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3549 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-14 14:36:12 +00:00
blacksun
1acf132128 forget file from previous comit
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3548 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-14 13:43:16 +00:00
blacksun
5e935a976e Minor change according to the evolution of Qt class (remove QGraphicsScene from constructor of QGraphicsItem).
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3547 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-14 13:06:21 +00:00
blacksun
62fa93ea1b Element text item -> mouse double click : If parent element is linked to other element,
show the other element (only work for report and salve element)


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3546 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-13 14:01:09 +00:00
blacksun
57edc4be80 Sort value of search field in dialog to link report/master
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3545 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-12 18:39:12 +00:00
blacksun
6ec416c351 Remove unused code
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3544 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-12 13:27:13 +00:00
blacksun
40ecef5ff9 Minor improvement
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3543 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-12 13:04:16 +00:00
blacksun
77164adf4b Change element information is now managed by an undo command
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3542 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-11 20:10:28 +00:00
blacksun
60dd0f2054 Save icon is disable when undo stack is empty
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3541 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-10 17:00:08 +00:00
silvio
575a731819 upgraded Italian translation of .ts file
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3540 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-08 20:18:30 +00:00
blacksun
e4c73b8666 Cross ref item : change how some methods work
Master element : minor change related to the change of cross ref item


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3539 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-08 17:39:57 +00:00
pawel32640
cfe267fcb3 update polish translation
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3538 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-08 17:25:41 +00:00
scorpio810
931c7811f3 Update TS files
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3537 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-08 09:41:50 +00:00
scorpio810
af5563c760 Minor
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3536 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-07 16:43:31 +00:00
scorpio810
4de19d8ae4 Element editor improve pinch to zoom
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3535 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-07 16:32:14 +00:00
blacksun
5ab965588b Fix artefact on qgraphics scene when remove a linked element
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3534 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-07 15:47:58 +00:00
scorpio810
438f98d34b Element editor add touchpad gestures, thank Yoann
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3533 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-06 17:56:07 +00:00
blacksun
74b1270d0d Conductor auto numerotation : use function from QET namespace instead of function from this file.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3532 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-04 23:25:49 +00:00
blacksun
9119d156c3 Comment item & cross ref item : reduce the size of the rectangle where is display the comment for better visual
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3531 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-04 23:14:20 +00:00
blacksun
8070f7eedb Forget file from previous commit
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3530 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-04 10:57:21 +00:00
blacksun
bc0d70e1ea Report link widget : each content show the string of the conductor and search field filter with this string.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3529 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-04 10:54:38 +00:00
blacksun
257cc7e91f Minor improvement
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3528 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-12-03 10:45:16 +00:00
blacksun
8e6a796ba8 element information : add info 'designation'
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3527 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-30 11:53:23 +00:00
scorpio810
bdadd33697 Update MacQetDeploy.sh, thank yoann
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3526 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-28 21:41:16 +00:00
blacksun
f6f0c2106f Qetdiagrameditor : tabify undo and element panel dock widget
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3525 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-28 18:14:33 +00:00
blacksun
67680f59a9 clean some code about undo stack
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3524 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-27 18:46:30 +00:00
blacksun
1c7892cc19 clean some code
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3523 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-27 17:57:10 +00:00
blacksun
c890e67ddd Remove obsolete method
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3522 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-27 17:47:01 +00:00
blacksun
8c321049d9 Bug fix
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3521 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-26 22:44:33 +00:00
blacksun
afdf20cf9f Delete an element linked to others unlink it.
Undo this action relink other element elements 


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3520 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-26 22:05:37 +00:00
scorpio810
0876d2c549 Add a progress bar on save file action
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3519 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-26 18:48:24 +00:00
scorpio810
223674c93e Update German translations, thank Nuri
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3518 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-26 14:10:00 +00:00
blacksun
9f4fbe456f Bug fix for terminal primtive : the rotation of terminal isn't save
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3517 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-25 05:45:50 +00:00
silvio
308b3a99d7 upgraded Italian translation of .ts file
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3516 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-24 22:03:35 +00:00
blacksun
e8cbb23c0b Minor change
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3515 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-24 18:17:20 +00:00
scorpio810
40a36e069e Minor change
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3514 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-24 18:00:37 +00:00
scorpio810
5a951d94d6 Minor: add forget setRenderHint(QPainter::Antialiasing, false);
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3513 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-24 17:51:13 +00:00
blacksun
dec5d3002c QetShapeItem : improve mouse interaction
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3512 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-24 17:36:02 +00:00
scorpio810
80e78b4e04 Minor, refresh TS files
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3511 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-24 03:00:36 +00:00
scorpio810
438d690edc Improve status bar about save information
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3510 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-24 02:51:08 +00:00
pawel32640
547ae24252 update polish translation
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3509 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-23 20:10:09 +00:00
aitolos
72ea869f63 Update Greek translation
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3508 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-23 16:57:01 +00:00
pavelfric
3c77a34b32 Updated Czech translations
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3507 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-23 14:05:35 +00:00
scorpio810
c744721aad Remove save information box
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3506 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-23 11:12:54 +00:00
silvio
10a94b2a5a upgraded Italian translation of .ts file
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3505 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-23 00:03:22 +00:00
scorpio810
dacfd4117f Update TS files
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3504 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-22 20:14:03 +00:00
scorpio810
48051a17de Minor: add message box for inform user as project was saved
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3503 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-22 20:03:38 +00:00
alfredo
a3ce7cbfbc update Spanish translation _es
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3500 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-20 05:38:02 +00:00
blacksun
a0ba343951 Element information : Check box "visible" for text re-work.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3499 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-18 23:00:06 +00:00
blacksun
46100f0d94 Conductor: Paste a conductor reset the text
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3498 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-17 22:32:06 +00:00
blacksun
f4bd29a5db Diagram folio sheet fix minor bug : create folio sheet isn't added in order in project.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3497 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-17 10:10:00 +00:00
blacksun
066c373365 Fix crash : When remove a diagram from project, close project, and open a project, Qet crash.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3496 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-16 23:24:30 +00:00
scorpio810
499f52e100 Enable mouse hoverMoveEvent conductor
Minor change in conductorpropertieswidget.ui


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3494 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-16 20:51:46 +00:00
scorpio810
d544fd3d85 Revert r3492
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3493 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-16 20:32:55 +00:00
runsys
02df8a5073 Download patch
Init branch

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3492 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-16 20:27:11 +00:00
runsys
e2f6e232ee Light change in user interface
When mouse over a element, coonductor, text, the graphic symbol draw his bounding box.
and draw a tooltip with his name
For conductor the conductor size change.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3490 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-16 14:15:32 +00:00
scorpio810
6f23bea143 Folio list moving to the second page
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3489 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-15 17:15:43 +00:00
scorpio810
e079fc1aac Update MacQetDeploy script, thanks Yoann
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3488 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-14 20:44:17 +00:00
blacksun
aeecb4c816 Fix wrong behavior with conductor text item when use "past here"
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3487 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-14 19:58:25 +00:00
blacksun
3be20f27bb conductor : remove qdebug
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3486 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-14 13:10:43 +00:00
blacksun
78b57e56e8 Conductor and conductor text item : minor change about how the text is save to xml
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3485 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-14 13:06:24 +00:00
blacksun
5f9251a22e Conductor : fix weird bug (not so weird when found) with the position of text item when was moved by user
and also  the two element linked by the conductor was moved.


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3484 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-13 19:32:56 +00:00
blacksun
70cc553ba0 Diagram image item fix : At opening of diagram, position is wrong if image was saved with is_movable to false;
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3483 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-13 12:12:53 +00:00
scorpio810
b83834e7ff Minor change
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3482 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-13 11:21:06 +00:00
scorpio810
bb4a9c0314 Save and read "is movable" attribute to xml for basic shape & image
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3481 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-13 11:04:34 +00:00
scorpio810
74aedf605f Minor:shape event, cosmetic change
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3480 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-12 14:44:50 +00:00
blacksun
d248e02e4a element editor : clean some code
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3479 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-11 17:09:24 +00:00
blacksun
031c0fc155 element editor : create primitive isn't selected anymore.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3478 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-11 14:05:45 +00:00
blacksun
ec288f4885 element editor : clean some code
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3477 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-11 12:02:08 +00:00
blacksun
848be587e3 Element editor : clean some code
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3476 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-10 22:57:32 +00:00
blacksun
e8d6d4de5d Element editor: add terminal is managed by esevent
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3475 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-10 21:47:28 +00:00
120 changed files with 11127 additions and 10042 deletions

View File

@@ -1,5 +1,4 @@
<definition width="70" version="0.3" hotspot_x="49" hotspot_y="15" height="30" type="element" ic="true" orientation="dyyy"
link_type="previous_report">
<definition width="20" version="0.4" hotspot_x="3" hotspot_y="10" height="20" link_type="previous_report" type="element" ic="true" orientation="dyyy">
<names>
<name lang="ar">الصفحة السابقة</name>
<name lang="de">Vorherige Seite</name>
@@ -9,15 +8,15 @@ link_type="previous_report">
<name lang="fr">Folio précédent</name>
<name lang="pl">Wejście adresowe</name>
<name lang="es">folio anterior</name>
<name lang="cs">Předchozí list</name>
<name lang="nl">Referentie Vorig</name>
<name lang="cs">Předchozí list</name>
</names>
<informations>Author: The QElectroTech team
License: see http://qelectrotech.org/wiki/doc/elements_license</informations>
<description>
<polygon x4="-1" antialias="true" style="line-style:normal;line-weight:normal;filling:black;color:black" closed="false" y1="-4" x1="-1" y2="4" x2="-1" y3="0" x3="9" y4="-4"/>
<line length1="1.5" length2="1.5" antialias="false" end1="none" end2="none" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="9" y2="0" x2="12"/>
<input x="-44" y="0" size="9" rotate="true" text="/"/>
<terminal x="13" y="0" nameHidden="0" number="" name="" orientation="e"/>
<input x="-44" y="0" size="9" rotate="true" text="/" tagg="label"/>
<terminal x="13" y="0" orientation="e"/>
</description>
</definition>

View File

@@ -1,5 +1,4 @@
<definition width="40" version="0.3" hotspot_x="18" hotspot_y="15" height="30" type="element" ic="true" orientation="dyyy"
link_type="next_report">
<definition width="30" version="0.4" hotspot_x="21" hotspot_y="10" height="20" link_type="next_report" type="element" ic="true" orientation="dyyy">
<names>
<name lang="ar">الصفحة التالية</name>
<name lang="de">Nächste Seite</name>
@@ -9,15 +8,15 @@ link_type="next_report">
<name lang="fr">Folio suivant</name>
<name lang="pl">Wyjście adresowe</name>
<name lang="es">Folio siguiente</name>
<name lang="cs">Další list</name>
<name lang="nl">Referentie volgend</name>
<name lang="cs">Další list</name>
</names>
<informations>Author: The QElectroTech team
License: see http://qelectrotech.org/wiki/doc/elements_license</informations>
<description>
<polygon x4="-9" antialias="true" style="line-style:normal;line-weight:normal;filling:black;color:black" closed="false" y1="-4" x1="-9" y2="4" x2="-9" y3="0" x3="2" y4="-4"/>
<line length1="1.5" length2="1.5" antialias="false" end1="none" end2="none" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-9" y2="0" x2="-12"/>
<input x="6" y="0" size="9" rotate="true" text="/"/>
<terminal x="-13" y="0" nameHidden="0" number="" name="" orientation="w"/>
<input x="6" y="0" size="9" rotate="true" text="/" tagg="label"/>
<terminal x="-13" y="0" orientation="w"/>
</description>
</definition>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 45 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
<context>
<name>QETElementEditor</name>
<message numerus="yes">
<location filename="../sources/editor/qetelementeditor.cpp" line="627"/>
<location filename="../sources/editor/qetelementeditor.cpp" line="589"/>
<source>%n partie(s) sélectionnée(s).</source>
<translation>
<numerusform>%n partie sélectionnée.</numerusform>
@@ -12,7 +12,7 @@
</translation>
</message>
<message numerus="yes">
<location filename="../sources/editor/qetelementeditor.cpp" line="721"/>
<location filename="../sources/editor/qetelementeditor.cpp" line="683"/>
<source>La vérification de cet élément a généré %n avertissement(s) :</source>
<comment>message box content</comment>
<translation>
@@ -87,8 +87,8 @@
</translation>
</message>
<message numerus="yes">
<location filename="../sources/diagramcommands.cpp" line="1221"/>
<location filename="../sources/diagramcommands.cpp" line="1236"/>
<location filename="../sources/diagramcommands.cpp" line="1251"/>
<source>Délier %n élément(s)</source>
<translation>
<numerusform>Délier %n élément</numerusform>

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -24,7 +24,7 @@ APPBIN="$BUNDLE/Contents/MacOS/$APPNAME"
current_dir=$(dirname "$0")
# On se remet au depart
cd ${current_dir}/../
cd "${current_dir}/../"
# Emplacement courant
current_dir=$(PWD)
@@ -74,8 +74,11 @@ svn up
# recupere le numero de la nouvelle revision
revAp=$(svnversion | cut -d : -f 2 | tr -d '[:alpha:]')
# On recupere le numero de version de l'originale
tagName=$(sed -n "s/const QString displayedVersion =\(.*\)/\1/p" sources/qet.h | cut -d\" -f2 | cut -d\" -f1 )
# Dmg de la dernière revision déjà créé
if [ -e "packaging/mac-osx/${APPNAME}_$revAp.dmg" ] ; then
if [ -e "packaging/mac-osx/${APPNAME} $tagName r$revAp.dmg" ] ; then
echo "There are not new updates, make disk image can"
echo "take a lot of time (5 min). Can you continu?"
echo "[y/n]"
@@ -101,8 +104,8 @@ echo "Adding the version tag..."
mkdir temp
cp -Rf "sources/qet.h" "temp/qet.h"
# On modifie l'originale avec le numero de version
sed -i "" "s/const QString displayedVersion = \"0.4-b\"/const QString displayedVersion = \"0.4-beta-r$revAp\"/" sources/qet.h
# On modifie l'originale avec le numero de revision du depot svn
sed -i "" "s/const QString displayedVersion =.*/const QString displayedVersion = \"$tagName r$revAp\";/" sources/qet.h
# Apres la compilation
cleanVerionTag () {
@@ -179,7 +182,7 @@ else
fi
# On rajoute le numero de version pour "cmd + i"
sed -i "" "s/<string>Created by Qt\/QMake<\/string>/<string>0.4 beta r$revAp<\/string>/" qelectrotech.app/Contents/Info.plist
sed -i "" "s/<string>Created by Qt\/QMake<\/string>/<string>$tagName r$revAp<\/string>/" qelectrotech.app/Contents/Info.plist
### copy over frameworks ############################################
@@ -241,11 +244,11 @@ echo 'Preparing (removing hold files)... '
if [ -e "/Volumes/${APPNAME}" ]; then
hdiutil detach -quiet "/Volumes/${APPNAME}"
fi
if [ -e "${APPNAME}_$revAp.dmg" ] ; then
rm -f "${APPNAME}_$revAp.dmg"
if [ -e "${APPNAME} $tagName r$revAp.dmg" ] ; then
rm -f "${APPNAME} $tagName r$revAp.dmg"
fi
if [ -e "packaging/mac-osx/${APPNAME}_$revAp.dmg" ] ; then
rm -f "packaging/mac-osx/${APPNAME}_$revAp.dmg"
if [ -e "packaging/mac-osx/${APPNAME} $tagName r$revAp.dmg" ] ; then
rm -f "packaging/mac-osx/${APPNAME} $tagName r$revAp.dmg"
fi
if [ -e $imagedir ] ; then
rm -rf $imagedir
@@ -268,13 +271,13 @@ strip "$imagedir/$APPBIN"
# Creating a disk image from a folder
echo 'Creating disk image... '
hdiutil create -quiet -ov -srcfolder $imagedir -format UDBZ -volname "${APPNAME}" "${APPNAME}_${revAp}.dmg"
hdiutil internet-enable -yes -quiet "${APPNAME}_${revAp}.dmg"
hdiutil create -quiet -ov -srcfolder $imagedir -format UDBZ -volname "${APPNAME}" "${APPNAME} $tagName r$revAp.dmg"
hdiutil internet-enable -yes -quiet "${APPNAME} $tagName r$revAp.dmg"
# Clean up disk folder
echo 'Cleaning up... '
cp -Rf "${APPNAME}_$revAp.dmg" "packaging/mac-osx/${APPNAME}_$revAp.dmg"
rm -f "${APPNAME}_$revAp.dmg"
cp -Rf "${APPNAME} $tagName r$revAp.dmg" "packaging/mac-osx/${APPNAME} $tagName r$revAp.dmg"
rm -f "${APPNAME} $tagName r$revAp.dmg"
rm -rf $imagedir
rm -rf $BUNDLE
@@ -302,6 +305,8 @@ svnversion | grep -q '[MS:]' ; if [ $? -eq 0 ] ; then
echo This is not the same version as the deposit.
echo You can use \'svn diff\' to see the differences.
echo And use \'svn revert \<fichier\>\' to delete the difference.
echo To go back, you can use svn update -r 360
echo to go to revision number 360.
echo
fi

View File

@@ -71,7 +71,8 @@ INCLUDEPATH += sources \
sources/properties \
sources/dvevent \
sources/editor \
sources/editor/esevent
sources/editor/esevent \
sources/undocommand
# Fichiers sources
@@ -79,13 +80,15 @@ HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) $$files(sources/editor/*
$$files(sources/properties/*.h) \
$$files(sources/editor/ui/*.h) \
$$files(sources/editor/esevent/*.h) \
$$files(sources/dvevent/*.h)
$$files(sources/dvevent/*.h) \
$$files(sources/undocommand/*.h)
SOURCES += $$files(sources/*.cpp) $$files(sources/editor/*.cpp) $$files(sources/titleblock/*.cpp) $$files(sources/richtext/*.cpp) $$files(sources/ui/*.cpp) $$files(sources/qetgraphicsitem/*.cpp) $$files(sources/factory/*.cpp) \
$$files(sources/properties/*.cpp) \
$$files(sources/editor/ui/*.cpp) \
$$files(sources/editor/esevent/*.cpp) \
$$files(sources/dvevent/*.cpp)
$$files(sources/dvevent/*.cpp) \
$$files(sources/undocommand/*.cpp)
# Liste des fichiers qui seront incorpores au binaire en tant que ressources Qt
RESOURCES += qelectrotech.qrc

View File

@@ -22,6 +22,7 @@
#include "conductor.h"
#include "diagram.h"
#include "potentialtextsdialog.h"
#include "qet.h"
/**
*Constructor
@@ -59,7 +60,7 @@ void ConductorAutoNumerotation::checkPotential(Conductor *conductor) {
foreach (const Conductor *c, c_list) strl<<(c->text());
//check text list, isn't same in potential, ask user what to do
if (!eachIsEqual(strl)) {
if (!QET::eachStrIsEqual(strl)) {
PotentialTextsDialog ptd(conductor, conductor->diagramEditor());
if ( ptd.exec() == QDialog::Accepted ) {
ConductorAutoNumerotation can(conductor);
@@ -111,7 +112,7 @@ void ConductorAutoNumerotation::numeratePotential() {
QStringList strl;
foreach (const Conductor *cc, conductor_list) strl<<(cc->text());
//the texts is identicals
if (eachIsEqual(strl)) {
if (QET::eachStrIsEqual(strl)) {
ConductorProperties cp = conductor_ -> properties();
cp.text = strl.at(0);
conductor_ -> setProperties(cp);
@@ -140,13 +141,3 @@ void ConductorAutoNumerotation::numerateNewConductor() {
applyText(ncc.toRepresentedString());
m_diagram->project()->addConductorAutoNum(m_diagram -> conductorsAutonumName(), ncc.next());
}
/**
* @return true if every text of qsl is identical, else false.
*/
bool eachIsEqual (const QStringList &qsl) {
foreach (const QString t, qsl) {
if (qsl.at(0) != t) return false;
}
return true;
}

View File

@@ -44,6 +44,4 @@ class ConductorAutoNumerotation {
QSet <Conductor *> conductor_list;
};
bool eachIsEqual (const QStringList &);
#endif // CONDUCTORAUTONUMEROTATION_H

View File

@@ -195,7 +195,7 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) : ConfigPage
projects_view_mode_ = new QGroupBox(tr("Projets"), this);
windowed_mode_ = new QRadioButton(tr("Utiliser des fen\352tres"), projects_view_mode_);
tabbed_mode_ = new QRadioButton(tr("Utiliser des onglets"), projects_view_mode_);
use_trackpad_ = new QCheckBox(tr("Utiliser les gestures du trackpad"), projects_view_mode_);
use_trackpad_ = new QCheckBox(tr("Utiliser les gestes du pav\351 tactile"), projects_view_mode_);
warning_view_mode_ = new QLabel(tr("Ces param\350tres s'appliqueront d\350s la prochaine ouverture d'un \351diteur de sch\351mas."));
elements_management_ = new QGroupBox(tr("Gestion des \351l\351ments"), this);

View File

@@ -41,20 +41,22 @@ const qreal Diagram::margin = 5.0;
// static variable to keep track of present background color of the diagram.
QColor Diagram::background_color = Qt::white;
/**
Constructeur
@param parent Le QObject parent du schema
* @brief Diagram::Diagram
* Constructor
* @param project : The project of this diagram and also parent QObject
*/
Diagram::Diagram(QObject *parent) :
QGraphicsScene(parent),
project_(0),
Diagram::Diagram(QETProject *project) :
QGraphicsScene (project),
project_ (nullptr),
diagram_qet_version_ (-1),
draw_grid_ (true),
use_border_ (true),
draw_terminals_ (true),
draw_colored_conductors_(true),
read_only_(false)
draw_colored_conductors_ (true)
{
setProject(project);
qgi_manager_ = new QGIManager(this);
setBackgroundBrush(Qt::white);
conductor_setter_ = new QGraphicsLineItem(0, 0);
@@ -66,18 +68,12 @@ Diagram::Diagram(QObject *parent) :
conductor_setter_ -> setPen(t);
conductor_setter_ -> setLine(QLineF(QPointF(0.0, 0.0), QPointF(0.0, 0.0)));
// initialise les objets gerant les deplacements
elements_mover_ = new ElementsMover(); // deplacements d'elements/conducteurs/textes
element_texts_mover_ = new ElementTextsMover(); // deplacements d'ElementTextItem
//Init object for manage movement
elements_mover_ = new ElementsMover();
element_texts_mover_ = new ElementTextsMover();
connect(
&border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)),
this, SLOT(setTitleBlockTemplate(const QString &))
);
connect(
&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)),
this, SLOT(titleChanged(const QString &))
);
connect(&border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)), this, SLOT(setTitleBlockTemplate(const QString &)));
connect(&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(titleChanged(const QString &)));
}
/**
@@ -555,7 +551,7 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
if (type_id.startsWith("embed://")) element_location.setProject(project_);
int state = 0;
Element *nvel_elmt = ElementFactory::Instance()->createElement(element_location, 0, this, &state);
Element *nvel_elmt = ElementFactory::Instance() -> createElement(element_location, 0, &state);
if (state) {
QString debug_message = QString("Diagram::fromXml() : Le chargement de la description de l'element %1 a echoue avec le code d'erreur %2").arg(element_location.path()).arg(state);
qDebug() << qPrintable(debug_message);
@@ -576,15 +572,16 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
}
}
// chargement de tous les textes du fichiers XML
// Load text
QList<IndependentTextItem *> added_texts;
foreach (QDomElement text_xml, QET::findInDomElement(root, "inputs", "input")) {
IndependentTextItem *iti = new IndependentTextItem(this);
IndependentTextItem *iti = new IndependentTextItem();
iti -> fromXml(text_xml);
addItem(iti);
added_texts << iti;
}
// Load image
QList<DiagramImageItem *> added_images;
foreach (QDomElement image_xml, QET::findInDomElement(root, "images", "image")) {
DiagramImageItem *dii = new DiagramImageItem ();
@@ -593,6 +590,7 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
added_images << dii;
}
// Load shape
QList<QetShapeItem *> added_shapes;
foreach (QDomElement shape_xml, QET::findInDomElement(root, "shapes", "shape")) {
QetShapeItem *dii = new QetShapeItem (QPointF(0,0));
@@ -601,71 +599,53 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
added_shapes << dii;
}
// gere la translation des nouveaux elements et texte si celle-ci est demandee
if (position != QPointF()) {
// determine quel est le coin superieur gauche du rectangle entourant les elements ajoutes
qreal minimum_x = 0, minimum_y = 0;
bool init = false;
QList<QGraphicsItem *> added_items;
foreach (Element *added_element, added_elements) added_items << added_element;
foreach (DiagramTextItem *added_text, added_texts) added_items << added_text;
foreach (DiagramImageItem *added_image, added_images) added_items << added_image;
foreach (QetShapeItem *added_shape, added_shapes) added_items << added_shape;
foreach (QGraphicsItem *item, added_items) {
QPointF csg = item -> mapToScene(item -> boundingRect()).boundingRect().topLeft();
qreal px = csg.x();
qreal py = csg.y();
if (!init) {
minimum_x = px;
minimum_y = py;
init = true;
} else {
if (px < minimum_x) minimum_x = px;
if (py < minimum_y) minimum_y = py;
}
}
qreal diff_x = position.x() - minimum_x;
qreal diff_y = position.y() - minimum_y;
foreach (Element *added_element, added_elements) {
added_element -> setPos(added_element -> pos().x() + diff_x, added_element -> pos().y() + diff_y);
}
foreach (DiagramTextItem *added_text, added_texts) {
added_text -> setPos(added_text -> pos().x() + diff_x, added_text -> pos().y() + diff_y);
}
foreach (DiagramImageItem *added_image, added_images) {
added_image -> setPos(added_image -> pos().x() + diff_x, added_image -> pos().y() + diff_y);
}
foreach (QetShapeItem *added_shape, added_shapes) {
added_shape -> setPos(added_shape -> pos().x() + diff_x, added_shape -> pos().y() + diff_y);
}
}
// chargement de tous les Conducteurs du fichier XML
// Load conductor
QList<Conductor *> added_conductors;
foreach (QDomElement f, QET::findInDomElement(root, "conductors", "conductor")) {
foreach (QDomElement f, QET::findInDomElement(root, "conductors", "conductor"))
{
if (!Conductor::valideXml(f)) continue;
// verifie que les bornes que le conducteur relie sont connues
//Check if terminal that conductor must be linked is know
int id_p1 = f.attribute("terminal1").toInt();
int id_p2 = f.attribute("terminal2").toInt();
if (table_adr_id.contains(id_p1) && table_adr_id.contains(id_p2)) {
// pose le conducteur... si c'est possible
if (table_adr_id.contains(id_p1) && table_adr_id.contains(id_p2))
{
Terminal *p1 = table_adr_id.value(id_p1);
Terminal *p2 = table_adr_id.value(id_p2);
if (p1 != p2) {
bool can_add_conductor = true;
bool cia = ((Element *)p2 -> parentItem()) -> internalConnections();
if (!cia) {
foreach(QGraphicsItem *item, p2 -> parentItem() -> children()) {
if (item == p1) can_add_conductor = false;
}
}
if (can_add_conductor) {
Conductor *c = new Conductor(table_adr_id.value(id_p1), table_adr_id.value(id_p2), this);
if (p1 != p2)
{
Conductor *c = new Conductor(table_adr_id.value(id_p1), table_adr_id.value(id_p2));
addItem(c);
c -> fromXml(f);
added_conductors << c;
}
}
} else qDebug() << "Diagram::fromXml() : Le chargement du conducteur" << id_p1 << id_p2 << "a echoue";
else qDebug() << "Diagram::fromXml() : Le chargement du conducteur" << id_p1 << id_p2 << "a echoue";
}
//Translate items if a new position was given in parameter
if (position != QPointF()) {
QList<QGraphicsItem *> added_items;
foreach (Element *added_element, added_elements ) added_items << added_element;
foreach (Conductor *added_cond, added_conductors) added_items << added_cond;
foreach (QetShapeItem *added_shape, added_shapes ) added_items << added_shape;
foreach (DiagramTextItem *added_text, added_texts ) added_items << added_text;
foreach (DiagramImageItem *added_image, added_images ) added_items << added_image;
//Get the top left corner of the rectangle that contain all added items
QRectF items_rect;
foreach (QGraphicsItem *item, added_items) {
items_rect = items_rect.united(item -> mapToScene(item -> boundingRect()).boundingRect());
}
QPointF point_ = items_rect.topLeft();
QPointF pos_ = Diagram::snapToGrid(QPointF (position.x() - point_.x(),
position.y() - point_.y()));
//Translate all added items
foreach (QGraphicsItem *qgi, added_items)
qgi -> setPos( qgi -> pos() += pos_);
}
// remplissage des listes facultatives
@@ -758,6 +738,7 @@ void Diagram::addItem(Conductor *conductor) {
QGraphicsScene::addItem(conductor);
conductor -> terminal1 -> addConductor(conductor);
conductor -> terminal2 -> addConductor(conductor);
conductor -> calculateTextItemPosition();
}
}
@@ -1196,6 +1177,22 @@ QSet<ConductorTextItem *> Diagram::selectedConductorTexts() const {
return(selected_texts);
}
/**
* @brief Diagram::selectedElementTexts
* @return the list of element texts selected
*/
QSet<ElementTextItem*> Diagram::selectedElementTexts() const {
QSet<ElementTextItem *> selected_texts;
foreach(QGraphicsItem *item, selectedItems()) {
if (ElementTextItem *cti = qgraphicsitem_cast< ElementTextItem*>(item)) {
selected_texts << cti;
}
}
return(selected_texts);
}
/// @return true si le presse-papier semble contenir un schema
bool Diagram::clipboardMayContainDiagram() {
QString clipboard_text = QApplication::clipboard() -> text().trimmed();
@@ -1213,19 +1210,25 @@ QETProject *Diagram::project() const {
/**
* @brief Diagram::setProject
* @param project: set parent project of this diagram or 0 if this diagram haven't got a parent project
* Set parent project of this diagram, project also become the parent QObject of this diagram
* @param project new project
*/
void Diagram::setProject(QETProject *project) {
if (project_) {
void Diagram::setProject(QETProject *project)
{
if (project_ == project) return;
if (project_)
{
disconnect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
disconnect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
}
project_ = project;
if (project_) {
setParent (project);
connect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
connect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
}
}
/**
@return the folio number of this diagram within its parent project, or -1
@@ -1253,20 +1256,13 @@ qreal Diagram::declaredQElectroTechVersion(bool fallback_to_project) const {
}
/**
@return true si le schema est en lecture seule
* @brief Diagram::isReadOnly
* @return true if this diagram is read only.
* This method is same has call Diagram::project() -> isReadOnly()
*/
bool Diagram::isReadOnly() const {
return(read_only_);
}
/**
@param read_only true pour passer le schema en lecture seule, false sinon
*/
void Diagram::setReadOnly(bool read_only) {
if (read_only_ != read_only) {
read_only_ = read_only;
emit(readOnlyChanged(read_only_));
}
bool Diagram::isReadOnly() const
{
return project_ -> isReadOnly();
}
/**

View File

@@ -47,14 +47,14 @@ class ElementTextsMover;
This class represents an electric diagram. It manages its various child
elements, conductors and texts and handles their graphic rendering.
*/
class Diagram : public QGraphicsScene {
class Diagram : public QGraphicsScene
{
Q_OBJECT
// constructors, destructor
public:
Diagram(QObject * = 0);
Diagram(QETProject *project);
virtual ~Diagram();
private:
Diagram(const Diagram &diagram);
@@ -97,7 +97,6 @@ class Diagram : public QGraphicsScene {
bool use_border_;
bool draw_terminals_;
bool draw_colored_conductors_;
bool read_only_;
QString m_conductors_autonum_name;
@@ -124,10 +123,7 @@ class Diagram : public QGraphicsScene {
int folioIndex() const;
qreal declaredQElectroTechVersion(bool = true) const;
void showMe() {emit showDiagram(this);}
// methods related to read only mode
bool isReadOnly() const;
void setReadOnly(bool);
// methods related to conductor creation
void setConductor(bool);
@@ -184,6 +180,7 @@ class Diagram : public QGraphicsScene {
QList<Element *> elements() const;
QSet<DiagramTextItem *> selectedTexts() const;
QSet<ConductorTextItem *> selectedConductorTexts() const;
QSet<ElementTextItem*> selectedElementTexts() const;
QSet<Conductor *> selectedConductors() const;
DiagramContent content() const;
DiagramContent selectedContent();
@@ -215,13 +212,10 @@ class Diagram : public QGraphicsScene {
signals:
void showDiagram (Diagram *);
void written();
void readOnlyChanged(bool);
void usedTitleBlockTemplateChanged(const QString &);
void diagramTitleChanged(Diagram *, const QString &);
/// Signal emitted when users wish to locate an element from the diagram within elements collection
void findElementRequired(const ElementsLocation &);
/// Signal emitted when users wish to edit an element from the diagram
void editElementRequired(const ElementsLocation &);
void findElementRequired(const ElementsLocation &); /// Signal emitted when users wish to locate an element from the diagram within elements collection
void editElementRequired(const ElementsLocation &); /// Signal emitted when users wish to edit an element from the diagram
void reportPropertiesChanged(QString);
void XRefPropertiesChanged();
};

View File

@@ -77,17 +77,22 @@ DeleteElementsCommand::~DeleteElementsCommand() {
/// annule les suppressions
void DeleteElementsCommand::undo() {
diagram -> showMe();
// remet les elements
foreach(Element *e, removed_content.elements) {
diagram -> addItem(e);
}
// remet les conducteurs
//We relink element after every element was added to diagram
foreach(Element *e, removed_content.elements) {
foreach (Element *elmt, m_link_hash[e]) {
e -> linkToElement(elmt);
}
}
foreach(Conductor *c, removed_content.conductors(DiagramContent::AnyConductor)) {
diagram -> addItem(c);
}
// remet les textes
foreach(IndependentTextItem *t, removed_content.textFields) {
diagram -> addItem(t);
}
@@ -113,7 +118,7 @@ void DeleteElementsCommand::redo() {
diagram -> removeItem(c);
//If option one text per folio is enable, and the text item of
//current conductor is visible (that mean the conductor own the single displayed text)
//current conductor is visible (that mean the conductor have the single displayed text)
//We call adjustTextItemPosition to other conductor at the same potential to keep
//a visible text on this potential.
if (diagram -> defaultConductorProperties.m_one_text_per_folio && c -> textItem() -> isVisible()) {
@@ -127,6 +132,9 @@ void DeleteElementsCommand::redo() {
// Remove elements
foreach(Element *e, removed_content.elements) {
//Get linked element, for relink it at undo
if (!e->linkedElements().isEmpty())
m_link_hash.insert(e, e->linkedElements());
diagram -> removeItem(e);
}
@@ -224,6 +232,13 @@ void PasteDiagramCommand::redo() {
eti -> setPlainText("_");
}
}
//Reset the text of conductors
foreach (Conductor *c, content.conductorsToMove) {
ConductorProperties cp = c -> properties();
cp.text = c->diagram() ? c -> diagram() -> defaultConductorProperties.text : "_";
c -> setProperties(cp);
}
}
else {
// paste the elements

View File

@@ -101,6 +101,8 @@ class DeleteElementsCommand : public QUndoCommand {
DiagramContent removed_content;
/// diagram which the content is removed from
Diagram *diagram;
/// keep linked element for each removed element linked to other element.
QHash <Element *, QList<Element *> > m_link_hash;
};
/**

View File

@@ -96,7 +96,8 @@ bool DiagramContext::keyMustShow(const QString &key) const {
}
bool DiagramContext::operator==(const DiagramContext &dc) const {
return(content_ == dc.content_);
return(content_ == dc.content_ &&
content_show == dc.content_show);
}
bool DiagramContext::operator!=(const DiagramContext &dc) const {

View File

@@ -24,17 +24,13 @@ qreal DiagramFolioList::colWidths[4] = {0.1, 0.55, 0.2, 0.15};
/**
* @brief DiagramFolioList::DiagramFolioList
* Constructor
* @param project QETproject *: The project from which this constructor was called. Important to setProject().
* @param parent parent QObject
* @param project : The project of this diagram and also parent QObject
*/
DiagramFolioList::DiagramFolioList( QETProject *project, QObject *parent) : Diagram(parent) {
if (project) {
setProject(project);
DiagramFolioList::DiagramFolioList( QETProject *project) :
Diagram(project)
{
id = project -> getFolioSheetsQuantity();
}
else
id = 0;
}
/**
* @brief DiagramFolioList::~DiagramFolioList

View File

@@ -24,7 +24,7 @@
class DiagramFolioList : public Diagram
{
public:
DiagramFolioList( QETProject *project = 0, QObject *parent = 0);
DiagramFolioList(QETProject *project);
virtual ~DiagramFolioList();
virtual QList<QLineF *> lines() const {return list_lines_;}
virtual QList<QRectF *> rectangles() const {return list_rectangles_;}

View File

@@ -48,11 +48,14 @@
@param diagram Schema a afficher ; si diagram vaut 0, un nouveau Diagram est utilise
@param parent Le QWidget parent de cette vue de schema
*/
DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : QGraphicsView(parent) {
DiagramView::DiagramView(Diagram *diagram, QWidget *parent) :
QGraphicsView (parent),
scene (diagram),
m_event_interface (nullptr)
{
grabGesture(Qt::PinchGesture);
setAttribute(Qt::WA_DeleteOnClose, true);
setInteractive(true);
m_event_interface = nullptr;
QString whatsthis = tr(
"Ceci est la zone dans laquelle vous concevez vos sch\351mas en y ajoutant"
@@ -67,7 +70,6 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : QGraphicsView(pare
setRenderHint(QPainter::TextAntialiasing, true);
setRenderHint(QPainter::SmoothPixmapTransform, true);
scene = diagram ? diagram : new Diagram(this);
setScene(scene);
scene -> undoStack().setClean();
setWindowIcon(QET::Icons::QETLogo);
@@ -84,7 +86,6 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : QGraphicsView(pare
connect(scene, SIGNAL(showDiagram(Diagram*)), this, SIGNAL(showDiagram(Diagram*)));
connect(scene, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
connect(scene, SIGNAL(readOnlyChanged(bool)), this, SLOT(applyReadOnly()));
connect(&(scene -> border_and_titleblock), SIGNAL(borderChanged(QRectF, QRectF)), this, SLOT(adjustSceneRect()));
connect(&(scene -> border_and_titleblock), SIGNAL(displayChanged()), this, SLOT(adjustSceneRect()));
connect(&(scene -> border_and_titleblock), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle()));
@@ -314,7 +315,7 @@ void DiagramView::handleTitleBlockDrop(QDropEvent *e) {
void DiagramView::handleTextDrop(QDropEvent *e) {
if (scene -> isReadOnly() || (e -> mimeData() -> hasText() == false) ) return;
IndependentTextItem *iti = new IndependentTextItem (e -> mimeData() -> text(), scene);
IndependentTextItem *iti = new IndependentTextItem (e -> mimeData() -> text());
if (e -> mimeData() -> hasHtml()) {
iti -> setHtml (e -> mimeData() -> text());
@@ -863,7 +864,7 @@ bool DiagramView::mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocati
bool DiagramView::addElementAtPos(const ElementsLocation &location, const QPoint &pos) {
// construit une instance de l'element correspondant a l'emplacement
int state;
Element *el = ElementFactory::Instance()->createElement(location, 0, diagram(), &state);
Element *el = ElementFactory::Instance()->createElement(location, 0, &state);
if (state) {
delete el;
return(false);

View File

@@ -35,25 +35,26 @@ class DiagramView : public QGraphicsView {
// constructors, destructor
public:
DiagramView(Diagram * = 0, QWidget * = 0);
DiagramView(Diagram *diagram, QWidget * = 0);
virtual ~DiagramView();
private:
DiagramView(const DiagramView &);
// attributes
private:
Diagram *scene;
DVEventInterface *m_event_interface;
QMenu *context_menu;
QAction *paste_here;
QAction *find_element_;
QPoint paste_here_pos;
bool fresh_focus_in_; ///< Indicate the focus was freshly gained
ElementsLocation next_location_;
QPoint next_position_;
QPointF center_view_;
QPointF rubber_band_origin;
DVEventInterface *m_event_interface;
bool fresh_focus_in_; ///< Indicate the focus was freshly gained
ElementsLocation next_location_;
// methods
public:

View File

@@ -143,7 +143,9 @@ void DVEventAddShape::updateHelpCross(const QPoint &p) {
//If line isn't created yet, we create it.
if (!m_help_horiz || !m_help_verti) {
QPen pen;
pen.setColor(Qt::darkBlue);
pen.setWidthF(0.4);
pen.setCosmetic(true);
pen.setColor(Qt::darkGray);
//Add +5 for each line, because the topleft of diagram isn't draw at position (0:0) but (5:5)
if (!m_help_horiz) {
m_help_horiz = new QGraphicsLineItem(m_diagram -> border_and_titleblock.rowsHeaderWidth() + 5, 0,

View File

@@ -296,7 +296,6 @@ void AddPartCommand::redo() {
part -> setZValue(z);
}
editor_scene_ -> clearSelection();
part -> setSelected(true);
first_redo = false;
return;
}

View File

@@ -48,6 +48,7 @@ ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
element_editor(editor),
decorator_(0)
{
behavior = Normal;
setItemIndexMethod(NoIndex);
setGrid(1, 1);
initPasteArea();
@@ -64,31 +65,14 @@ ElementScene::~ElementScene() {
}
/**
Passe la scene en mode "selection et deplacement de parties"
*/
void ElementScene::slot_move() {
behavior = Normal;
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
}
/**
Passe la scene en mode "ajout de borne"
*/
void ElementScene::slot_addTerminal() {
behavior = Terminal;
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
}
/**
Gere les mouvements de la souris
@param e objet decrivant l'evenement
* @brief ElementScene::mouseMoveEvent
* @param e
*/
void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
if (m_event_interface) {
if (m_event_interface -> mouseMoveEvent(e)) {
if (m_event_interface->isFinish()) {
emit(partsAdded());
emit(needNormalMode());
delete m_event_interface; m_event_interface = nullptr;
}
return;
@@ -96,7 +80,8 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
}
QPointF event_pos = e -> scenePos();
if (mustSnapToGrid(e)) event_pos = snapToGrid(event_pos);
if (!e -> modifiers() & Qt::ControlModifier)
event_pos = snapToGrid(event_pos);
if (behavior == PasteArea) {
QRectF current_rect(paste_area_ -> rect());
@@ -109,15 +94,14 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
}
/**
Gere les appuis sur les boutons de la souris
@param e objet decrivant l'evenement
* @brief ElementScene::mousePressEvent
* @param e
*/
void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
if (m_event_interface) {
if (m_event_interface -> mousePressEvent(e)) {
if (m_event_interface->isFinish()) {
emit(partsAdded());
emit(needNormalMode());
delete m_event_interface; m_event_interface = nullptr;
}
return;
@@ -128,26 +112,20 @@ void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
}
/**
Gere les relachements de boutons de la souris
@param e objet decrivant l'evenement
* @brief ElementScene::mouseReleaseEvent
* @param e
*/
void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
if (m_event_interface) {
if (m_event_interface -> mouseReleaseEvent(e)) {
if (m_event_interface->isFinish()) {
emit(partsAdded());
emit(needNormalMode());
delete m_event_interface; m_event_interface = nullptr;
}
return;
}
}
QPointF event_pos = e -> scenePos();
if (mustSnapToGrid(e)) event_pos = snapToGrid(event_pos);
PartTerminal *terminal;
if (behavior == PasteArea) {
defined_paste_area_ = paste_area_ -> rect();
removeItem(paste_area_);
@@ -156,31 +134,18 @@ void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
return;
}
if (e -> button() & Qt::LeftButton) {
switch(behavior) {
case Terminal:
terminal = new PartTerminal(element_editor, 0, this);
terminal -> setPos(event_pos);
undo_stack.push(new AddPartCommand(tr("borne"), this, terminal));
emit(partsAdded());
endCurrentBehavior(e);
break;
case Normal:
default:
// detecte les deplacements de parties
QGraphicsScene::mouseReleaseEvent(e);
moving_parts_ = false;
}
}
else QGraphicsScene::mouseReleaseEvent(e);
}
/**
* @brief ElementScene::mouseDoubleClickEvent
* @param event
*/
void ElementScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
if (m_event_interface) {
if (m_event_interface -> mouseDoubleClickEvent(event)) {
if (m_event_interface->isFinish()) {
emit(partsAdded());
emit(needNormalMode());
delete m_event_interface; m_event_interface = nullptr;
}
return;
@@ -200,7 +165,6 @@ void ElementScene::keyPressEvent(QKeyEvent *event) {
if (m_event_interface -> keyPressEvent(event)) {
if (m_event_interface->isFinish()) {
emit(partsAdded());
emit(needNormalMode());
delete m_event_interface; m_event_interface = nullptr;
}
return;
@@ -230,27 +194,18 @@ void ElementScene::drawForeground(QPainter *p, const QRectF &rect) {
p -> restore();
}
/**
A partir d'un evenement souris, cette methode regarde si la touche shift est
enfoncee ou non. Si oui, elle laisse le comportement en cours (cercle,
texte, polygone, ...). Si non, elle repasse en mode normal / selection.
@param event objet decrivant l'evenement souris
*/
void ElementScene::endCurrentBehavior(const QGraphicsSceneMouseEvent *event) {
if (!(event -> modifiers() & Qt::ShiftModifier)) {
// la touche Shift n'est pas enfoncee : on demande le mode normal
behavior = Normal;
emit(needNormalMode());
}
}
/**
* @brief ElementScene::setEventInterface
* Set a new event interface
* @param interface
*/
void ElementScene::setEventInterface(ESEventInterface *interface) {
if (m_event_interface) delete m_event_interface;
if (m_event_interface) {
delete m_event_interface;
//We must to re-init because previous interface
//Reset his own init when deleted
interface->init();
}
m_event_interface = interface;
}
@@ -315,7 +270,6 @@ const QDomDocument ElementScene::toXml(bool all_parts) {
root.setAttribute("hotspot_y", QString("%1").arg(-(qRound(size.y() - (ymargin/2)))));
root.setAttribute("orientation", "dyyy"); //we keep the orientation for compatibility with previous version of qet
root.setAttribute("version", QET::version);
root.setAttribute("ic", "true"); //we keep the internal connection for compatibility with previous version of qet
root.setAttribute("link_type", m_elmt_type);
// noms de l'element
@@ -504,14 +458,6 @@ void ElementScene::copy() {
last_copied_ = clipboard_content;
}
/**
Gere le fait de coller le contenu du presse-papier = l'importer dans le
presse-papier a une position donnee.
*/
void ElementScene::paste() {
}
void ElementScene::contextMenu(QContextMenuEvent *event) {
if (behavior == ElementScene::Normal)
element_editor -> contextMenu(event);
@@ -1004,16 +950,6 @@ QPointF ElementScene::snapToGrid(QPointF point) {
return point;
}
/**
@param e Evenement souris
@return true s'il faut utiliser le snap-to-grid
Typiquement, cette methode retourne true si l'evenement souris se produit
sans la touche Ctrl enfoncee.
*/
bool ElementScene::mustSnapToGrid(QGraphicsSceneMouseEvent *e) {
return(!(e -> modifiers() & Qt::ControlModifier));
}
/**
@return true if \a item1's zValue() is less than \a item2's.
*/

View File

@@ -41,7 +41,7 @@ class ElementScene : public QGraphicsScene {
// enum
public:
enum Behavior { Normal, Terminal, PasteArea };
enum Behavior { Normal, PasteArea };
enum ItemOption {
SortByZValue = 1,
IncludeTerminals = 2,
@@ -81,7 +81,6 @@ class ElementScene : public QGraphicsScene {
*/
QPointF fsi_pos;
QPointF moving_press_pos;
bool moving_parts_;
/// Variables related to drawing
ESEventInterface *m_event_interface;
@@ -132,7 +131,6 @@ class ElementScene : public QGraphicsScene {
bool wasCopiedFromThisElement(const QString &);
void cut();
void copy();
void paste();
void contextMenu (QContextMenuEvent *event);
QETElementEditor* editor() const;
@@ -144,7 +142,6 @@ class ElementScene : public QGraphicsScene {
virtual void keyPressEvent (QKeyEvent *event);
virtual void drawForeground(QPainter *, const QRectF &);
virtual void endCurrentBehavior(const QGraphicsSceneMouseEvent *);
private:
QRectF elementContentBoundingRect(const ElementContent &) const;
@@ -154,14 +151,11 @@ class ElementScene : public QGraphicsScene {
ElementContent addContentAtPos(const ElementContent &, const QPointF &, QString * = 0);
void addPrimitive(QGraphicsItem *);
void initPasteArea();
bool mustSnapToGrid(QGraphicsSceneMouseEvent *);
static bool zValueLessThan(QGraphicsItem *, QGraphicsItem *);
QMutex *decorator_lock_;
void centerElementToOrigine();
public slots:
void slot_move();
void slot_addTerminal();
void slot_select(const ElementContent &);
void slot_selectAll();
void slot_deselectAll();
@@ -178,11 +172,6 @@ class ElementScene : public QGraphicsScene {
void stackAction(ElementEditionCommand *);
signals:
/**
Signal emitted when the scene requires the element editor to switch back to
normal mode.
*/
void needNormalMode();
/// Signal emitted after one or several parts were added
void partsAdded();
/// Signal emitted after one or several parts were removed

View File

@@ -18,6 +18,7 @@
#include "elementview.h"
#include "qetelementeditor.h"
#include "editorcommands.h"
#include "qetapp.h"
/**
Constructeur
@param scene ElementScene visualisee par cette ElementView
@@ -28,6 +29,7 @@ ElementView::ElementView(ElementScene *scene, QWidget *parent) :
scene_(scene),
offset_paste_count_(0)
{
grabGesture(Qt::PinchGesture);
setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
setInteractive(true);
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
@@ -35,7 +37,6 @@ ElementView::ElementView(ElementScene *scene, QWidget *parent) :
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
zoomReset();
connect(scene_, SIGNAL(pasteAreaDefined(const QRectF &)), this, SLOT(pasteAreaDefined(const QRectF &)));
connect(scene_, SIGNAL(partsAdded()), this, SLOT(adjustSceneRect()));
connect(scene_, SIGNAL(needZoomFit()), this, SLOT(zoomFit()));
}
@@ -113,6 +114,20 @@ void ElementView::zoomOut() {
scale(0.75, 0.75);
}
/**
Agrandit le schema avec le trackpad
*/
void ElementView::zoomInSlowly() {
scale(1.02, 1.02);
}
/**
Retrecit le schema avec le trackpad
*/
void ElementView::zoomOutSlowly() {
scale(0.98, 0.98);
}
/**
Agrandit ou rectrecit le schema de facon a ce que tous les elements du
schema soient visibles a l'ecran. S'il n'y a aucun element sur le schema,
@@ -383,25 +398,66 @@ void ElementView::mouseReleaseEvent(QMouseEvent *e) {
}
/**
Gere les actions liees a la rollette de la souris
@param e QWheelEvent decrivant l'evenement rollette
* @brief ElementView::gestures
* @return
*/
bool ElementView::gestures() const {
return(QETApp::settings().value("diagramview/gestures", false).toBool());
}
/**
* @brief ElementView::wheelEvent
* @param e
*/
void ElementView::wheelEvent(QWheelEvent *e) {
//Zoom and scrolling
if (e->buttons() != Qt::MidButton) {
if (!(e -> modifiers() & Qt::ControlModifier)) {
if (e -> delta() > 0){
zoomIn();
}
else{
zoomOut();
if ( gestures() ) {
if (e -> modifiers() & Qt::ControlModifier)
e -> delta() > 0 ? zoomInSlowly() : zoomOutSlowly();
else
QGraphicsView::wheelEvent(e);
} else {
e -> delta() > 0 ? zoomIn(): zoomOut();
}
}
else {
QAbstractScrollArea::wheelEvent(e);
/**
Gere les evenements de la ElementView
@param e Evenement
*/
bool ElementView::event(QEvent *e) {
// By default touch events are converted to mouse events. So
// after this event we will get a mouse event also but we want
// to handle touch events as gestures only. So we need this safeguard
// to block mouse events that are actually generated from touch.
if (e->type() == QEvent::Gesture)
return gestureEvent(static_cast<QGestureEvent *>(e));
return(QGraphicsView::event(e));
}
/**
* Utilise le pincement du trackpad pour zoomer
* @brief ElementView::gestureEvent
* @param event
* @return
*/
bool ElementView::gestureEvent(QGestureEvent *event){
if (QGesture *gesture = event->gesture(Qt::PinchGesture)) {
QPinchGesture *pinch = static_cast<QPinchGesture *>(gesture);
if (pinch->changeFlags() & QPinchGesture::ScaleFactorChanged){
qreal value = gesture->property("scaleFactor").toReal();
if (value > 1){
zoomInSlowly();
}else{
zoomOutSlowly();
}
}
}
return true;
}
/**
Dessine l'arriere-plan de l'editeur, cad la grille.

View File

@@ -47,6 +47,8 @@ class ElementView : public QGraphicsView {
void mousePressEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
bool gestureEvent(QGestureEvent *event);
bool event(QEvent *event);
void wheelEvent(QWheelEvent *);
virtual void drawBackground(QPainter *, const QRectF &);
@@ -58,6 +60,8 @@ class ElementView : public QGraphicsView {
void setSelectionMode();
void zoomIn();
void zoomOut();
void zoomInSlowly();
void zoomOutSlowly();
void zoomFit();
void zoomReset();
void adjustSceneRect();
@@ -86,6 +90,7 @@ class ElementView : public QGraphicsView {
QPointF start_top_left_corner_;
QPointF reference_view_;
QPointF center_view_;
bool gestures() const;
bool is_moving_view_; ///< Indicate whether the visualisation mode has been enabled due to mouse/keyboard interactions
};
#endif

View File

@@ -60,7 +60,7 @@ bool ESEventAddEllipse::mousePressEvent(QGraphicsSceneMouseEvent *event) {
//Add ellipse to scene
m_ellipse -> setRect(m_ellipse -> rect().normalized());
m_scene -> undoStack().push(new AddPartCommand(QObject::tr("Rectangle"), m_scene, m_ellipse));
m_scene -> undoStack().push(new AddPartCommand(QObject::tr("Ellipse"), m_scene, m_ellipse));
//Set m_ellipse to nullptr for create new ellipse at next mouse press
m_ellipse = nullptr;

View File

@@ -0,0 +1,107 @@
/*
Copyright 2006-2014 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include "partterminal.h"
#include "editorcommands.h"
#include "elementscene.h"
#include "eseventaddterminal.h"
/**
* @brief ESEventAddTerminal::ESEventAddTerminal
* @param scene
*/
ESEventAddTerminal::ESEventAddTerminal(ElementScene *scene) :
ESEventInterface(scene)
{
m_terminal = new PartTerminal(m_editor, 0, m_scene);
m_running = true;
}
/**
* @brief ESEventAddTerminal::~ESEventAddTerminal
*/
ESEventAddTerminal::~ESEventAddTerminal() {
delete m_terminal;
}
/**
* @brief ESEventAddTerminal::mouseMoveEvent
* @param event
* @return
*/
bool ESEventAddTerminal::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
QPointF pos = m_scene -> snapToGrid(event -> scenePos());
updateHelpCross(pos);
m_terminal -> setPos(pos);
return true;
}
/**
* @brief ESEventAddTerminal::mouseReleaseEvent
* @param event
* @return
*/
bool ESEventAddTerminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
if (event -> button() == Qt::LeftButton) {
m_scene -> undoStack().push(new AddPartCommand(QObject::tr("Borne"), m_scene, m_terminal));
//Set new terminal with same rotation
Qet::Orientation ori = m_terminal -> orientation();
m_terminal = new PartTerminal(m_editor, 0, m_scene);
m_terminal -> setOrientation(ori);
m_terminal -> setPos(m_scene -> snapToGrid(event -> scenePos()));
return true;
}
else if (event -> button() == Qt::RightButton) {
m_running = false;
return true;
}
return false;
}
/**
* @brief ESEventAddTerminal::keyPressEvent
* @param event
* @return
*/
bool ESEventAddTerminal::keyPressEvent(QKeyEvent *event) {
if (event -> key() == Qt::Key_Space) {
switch (m_terminal->orientation()) {
case Qet::North :
m_terminal -> setOrientation(Qet::East);
break;
case Qet::East :
m_terminal -> setOrientation(Qet::South);
break;
case Qet::South :
m_terminal -> setOrientation(Qet::West);
break;
case Qet::West :
m_terminal -> setOrientation(Qet::North);
break;
default :
m_terminal -> setOrientation(Qet::North);
break;
}
return true;
}
return (ESEventInterface::keyPressEvent(event));
}

View File

@@ -0,0 +1,45 @@
/*
Copyright 2006-2014 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ESEVENTADDTERMINAL_H
#define ESEVENTADDTERMINAL_H
#include "eseventinterface.h"
class ElementScene;
class PartTerminal;
class QGraphicsSceneMouseEvent;
/**
* @brief The ESEventAddTerminal class
* This ESEvent manage creation of terminal in an ElementScene
*/
class ESEventAddTerminal : public ESEventInterface
{
public:
ESEventAddTerminal(ElementScene *scene);
virtual ~ESEventAddTerminal();
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
virtual bool keyPressEvent (QKeyEvent *event);
private:
PartTerminal *m_terminal;
};
#endif // ESEVENTADDTERMINAL_H

View File

@@ -28,8 +28,14 @@ ESEventInterface::ESEventInterface(ElementScene *scene) :
m_running (false),
m_abort (false)
{
init();
}
void ESEventInterface::init() {
foreach (QGraphicsView *qgv, m_scene->views())
qgv->setContextMenuPolicy(Qt::NoContextMenu);
m_editor->slot_setNoDragToView();
}
ESEventInterface::~ESEventInterface() {
@@ -38,6 +44,8 @@ ESEventInterface::~ESEventInterface() {
foreach (QGraphicsView *qgv, m_scene->views())
qgv->setContextMenuPolicy(Qt::DefaultContextMenu);
m_editor->slot_setRubberBandToView();
}
bool ESEventInterface::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {

View File

@@ -32,6 +32,8 @@ class ESEventInterface
ESEventInterface(ElementScene *scene);
virtual ~ESEventInterface();
void init();
virtual bool mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event);
virtual bool mousePressEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);

View File

@@ -48,6 +48,7 @@
#include "eseventaddarc.h"
#include "eseventaddtext.h"
#include "eseventaddtextfield.h"
#include "eseventaddterminal.h"
#include <QMessageBox>
/*
@@ -129,7 +130,8 @@ void QETElementEditor::setFileName(const QString &fn) {
}
/**
Met en place les actions
* @brief QETElementEditor::setupActions
* Create action used in Element editor
*/
void QETElementEditor::setupActions() {
new_element = new QAction(QET::Icons::DocumentNew, tr("&Nouveau"), this);
@@ -150,36 +152,9 @@ void QETElementEditor::setupActions() {
paste_from_elmt = new QAction(QET::Icons::Element, tr("un \351l\351ment"), this);
inv_select = new QAction( tr("Inverser la s\351lection"), this);
edit_delete = new QAction(QET::Icons::EditDelete, tr("&Supprimer"), this);
zoom_in = new QAction(QET::Icons::ZoomIn, tr("Zoom avant"), this);
zoom_out = new QAction(QET::Icons::ZoomOut, tr("Zoom arri\350re"), this);
zoom_fit = new QAction(QET::Icons::ZoomFitBest, tr("Zoom adapt\351"), this);
zoom_reset = new QAction(QET::Icons::ZoomOriginal, tr("Pas de zoom"), this);
edit_names = new QAction(QET::Icons::Names, tr("\311diter les noms"), this);
edit_author = new QAction(QET::Icons::UserInformations, tr("\311diter les informations sur l'auteur"), this);
m_edit_properties = new QAction(QET::Icons::ElementEdit, tr("\311diter les propri\351t\351es de l'\351l\351ment"), this);
edit_raise = new QAction(QET::Icons::Raise, tr("Rapprocher"), this);
edit_lower = new QAction(QET::Icons::Lower, tr("\311loigner"), this);
edit_backward = new QAction(QET::Icons::SendBackward, tr("Envoyer au fond"), this);
edit_forward = new QAction(QET::Icons::BringForward, tr("Amener au premier plan"), this);
move = new QAction(QET::Icons::PartSelect, tr("D\351placer un objet"), this);
add_line = new QAction(QET::Icons::PartLine, tr("Ajouter une ligne"), this);
add_rectangle = new QAction(QET::Icons::PartRectangle, tr("Ajouter un rectangle"), this);
add_ellipse = new QAction(QET::Icons::PartEllipse, tr("Ajouter une ellipse"), this);
add_polygon = new QAction(QET::Icons::PartPolygon, tr("Ajouter un polygone"), this);
add_text = new QAction(QET::Icons::PartText, tr("Ajouter du texte"), this);
add_arc = new QAction(QET::Icons::PartArc, tr("Ajouter un arc de cercle"), this);
add_terminal = new QAction(QET::Icons::Terminal, tr("Ajouter une borne"), this);
add_textfield = new QAction(QET::Icons::PartTextField, tr("Ajouter un champ de texte"), this);
QString add_status_tip = tr("Maintenez la touche Shift enfonc\351e pour effectuer plusieurs ajouts d'affil\351e");
add_line -> setStatusTip(add_status_tip);
add_rectangle -> setStatusTip(add_status_tip);
add_ellipse -> setStatusTip(add_status_tip);
add_text -> setStatusTip(add_status_tip);
add_arc -> setStatusTip(add_status_tip);
add_terminal -> setStatusTip(add_status_tip);
add_textfield -> setStatusTip(add_status_tip);
add_polygon -> setStatusTip(tr("Utilisez le bouton droit de la souris pour poser le dernier point du polygone"));
undo = ce_scene -> undoStack().createUndoAction(this, tr("Annuler"));
redo = ce_scene -> undoStack().createRedoAction(this, tr("Refaire"));
@@ -208,19 +183,9 @@ void QETElementEditor::setupActions() {
edit_delete -> setShortcut(QKeySequence(tr("Backspace")));
#endif
zoom_in -> setShortcut(QKeySequence::ZoomIn);
zoom_out -> setShortcut(QKeySequence::ZoomOut);
zoom_fit -> setShortcut(QKeySequence(tr("Ctrl+9")));
zoom_reset -> setShortcut(QKeySequence(tr("Ctrl+0")));
edit_names -> setShortcut(QKeySequence(tr("Ctrl+E")));
edit_author -> setShortcut(tr("Ctrl+Y"));
edit_raise -> setShortcut(QKeySequence(tr("Ctrl+Shift+Up")));
edit_lower -> setShortcut(QKeySequence(tr("Ctrl+Shift+Down")));
edit_backward -> setShortcut(QKeySequence(tr("Ctrl+Shift+End")));
edit_forward -> setShortcut(QKeySequence(tr("Ctrl+Shift+Home")));
connect(new_element, SIGNAL(triggered()), this, SLOT(slot_new()));
connect(open, SIGNAL(triggered()), this, SLOT(slot_open()));
connect(open_file, SIGNAL(triggered()), this, SLOT(slot_openFile()));
@@ -238,19 +203,75 @@ void QETElementEditor::setupActions() {
connect(paste_in_area, SIGNAL(triggered()), ce_view, SLOT(pasteInArea()));
connect(paste_from_file, SIGNAL(triggered()), this, SLOT(pasteFromFile()));
connect(paste_from_elmt, SIGNAL(triggered()), this, SLOT(pasteFromElement()));
connect(zoom_in, SIGNAL(triggered()), ce_view, SLOT(zoomIn()));
connect(zoom_out, SIGNAL(triggered()), ce_view, SLOT(zoomOut()));
connect(zoom_fit, SIGNAL(triggered()), ce_view, SLOT(zoomFit()));
connect(zoom_reset, SIGNAL(triggered()), ce_view, SLOT(zoomReset()));
connect(edit_delete, SIGNAL(triggered()), ce_scene, SLOT(slot_delete()));
connect(edit_names, SIGNAL(triggered()), ce_scene, SLOT(slot_editNames()));
connect(edit_author, SIGNAL(triggered()), ce_scene, SLOT(slot_editAuthorInformations()));
connect(m_edit_properties, SIGNAL(triggered()), ce_scene, SLOT(slot_editProperties()));
/*
* Action related to change depth of primitive
*/
m_depth_ag = new QActionGroup(this);
QAction *edit_forward = new QAction(QET::Icons::BringForward, tr("Amener au premier plan"), m_depth_ag);
QAction *edit_raise = new QAction(QET::Icons::Raise, tr("Rapprocher"), m_depth_ag);
QAction *edit_lower = new QAction(QET::Icons::Lower, tr("\311loigner"), m_depth_ag);
QAction *edit_backward = new QAction(QET::Icons::SendBackward, tr("Envoyer au fond"), m_depth_ag);
edit_raise -> setShortcut(QKeySequence(tr("Ctrl+Shift+Up")));
edit_lower -> setShortcut(QKeySequence(tr("Ctrl+Shift+Down")));
edit_backward -> setShortcut(QKeySequence(tr("Ctrl+Shift+End")));
edit_forward -> setShortcut(QKeySequence(tr("Ctrl+Shift+Home")));
connect(edit_forward, SIGNAL(triggered()), ce_scene, SLOT(slot_bringForward() ));
connect(edit_raise, SIGNAL(triggered()), ce_scene, SLOT(slot_raise() ));
connect(edit_lower, SIGNAL(triggered()), ce_scene, SLOT(slot_lower() ));
connect(edit_backward, SIGNAL(triggered()), ce_scene, SLOT(slot_sendBackward() ));
connect(move, SIGNAL(triggered()), ce_scene, SLOT(slot_move()));
depth_toolbar = addToolBar(tr("Profondeur", "toolbar title"));
depth_toolbar -> setObjectName("depth_toolbar");
depth_toolbar -> addActions(m_depth_ag -> actions());
addToolBar(Qt::TopToolBarArea, depth_toolbar);
/*
* Action related to zoom
*/
m_zoom_ag = new QActionGroup(this);
QAction *zoom_in = new QAction(QET::Icons::ZoomIn, tr("Zoom avant"), m_zoom_ag);
QAction *zoom_out = new QAction(QET::Icons::ZoomOut, tr("Zoom arri\350re"), m_zoom_ag);
QAction *zoom_fit = new QAction(QET::Icons::ZoomFitBest, tr("Zoom adapt\351"), m_zoom_ag);
QAction *zoom_reset = new QAction(QET::Icons::ZoomOriginal, tr("Pas de zoom"), m_zoom_ag);
zoom_in -> setShortcut(QKeySequence::ZoomIn);
zoom_out -> setShortcut(QKeySequence::ZoomOut);
zoom_fit -> setShortcut(QKeySequence(tr("Ctrl+9")));
zoom_reset -> setShortcut(QKeySequence(tr("Ctrl+0")));
connect(zoom_in, SIGNAL(triggered()), ce_view, SLOT(zoomIn() ));
connect(zoom_out, SIGNAL(triggered()), ce_view, SLOT(zoomOut() ));
connect(zoom_fit, SIGNAL(triggered()), ce_view, SLOT(zoomFit() ));
connect(zoom_reset, SIGNAL(triggered()), ce_view, SLOT(zoomReset() ));
/*
* Action related to primitive creation
*/
connect (ce_scene, SIGNAL(partsAdded()), this, SLOT(UncheckAddPrimitive()));
parts = new QActionGroup(this);
QAction *add_line = new QAction(QET::Icons::PartLine, tr("Ajouter une ligne"), parts);
QAction *add_rectangle = new QAction(QET::Icons::PartRectangle, tr("Ajouter un rectangle"), parts);
QAction *add_ellipse = new QAction(QET::Icons::PartEllipse, tr("Ajouter une ellipse"), parts);
QAction *add_polygon = new QAction(QET::Icons::PartPolygon, tr("Ajouter un polygone"), parts);
QAction *add_text = new QAction(QET::Icons::PartText, tr("Ajouter du texte"), parts);
QAction *add_arc = new QAction(QET::Icons::PartArc, tr("Ajouter un arc de cercle"), parts);
QAction *add_terminal = new QAction(QET::Icons::Terminal, tr("Ajouter une borne"), parts);
QAction *add_textfield = new QAction(QET::Icons::PartTextField, tr("Ajouter un champ de texte"), parts);
foreach (QAction *action, parts -> actions()) action -> setCheckable(true);
connect(add_line, SIGNAL(triggered()), this, SLOT(addLine() ));
connect(add_rectangle, SIGNAL(triggered()), this, SLOT(addRect() ));
@@ -258,54 +279,16 @@ void QETElementEditor::setupActions() {
connect(add_polygon, SIGNAL(triggered()), this, SLOT(addPolygon() ));
connect(add_text, SIGNAL(triggered()), this, SLOT(addText() ));
connect(add_arc, SIGNAL(triggered()), this, SLOT(addArc() ));
connect(add_terminal, SIGNAL(triggered()), ce_scene, SLOT(slot_addTerminal()));
connect(add_terminal, SIGNAL(triggered()), this, SLOT(addTerminal() ));
connect(add_textfield, SIGNAL(triggered()), this, SLOT(addTextField() ));
connect(move, SIGNAL(triggered()), this, SLOT(slot_setRubberBandToView()));
connect(add_line, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
connect(add_rectangle, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
connect(add_ellipse, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
connect(add_polygon, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
connect(add_text, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
connect(add_arc, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
connect(add_terminal, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
connect(add_textfield, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
connect(ce_scene, SIGNAL(needNormalMode()), this, SLOT(slot_setNormalMode()));
move -> setCheckable(true);
add_line -> setCheckable(true);
add_rectangle -> setCheckable(true);
add_ellipse -> setCheckable(true);
add_polygon -> setCheckable(true);
add_text -> setCheckable(true);
add_arc -> setCheckable(true);
add_terminal -> setCheckable(true);
add_textfield -> setCheckable(true);
parts = new QActionGroup(this);
parts -> addAction(move);
parts -> addAction(add_line);
parts -> addAction(add_rectangle);
parts -> addAction(add_ellipse);
parts -> addAction(add_polygon);
parts -> addAction(add_arc);
parts -> addAction(add_text);
parts -> addAction(add_textfield);
parts -> addAction(add_terminal);
parts -> setExclusive(true);
parts_toolbar = new QToolBar(tr("Parties", "toolbar title"), this);
parts_toolbar -> setObjectName("parts");
foreach (QAction *action, parts -> actions()) parts_toolbar -> addAction(action);
move -> setChecked(true);
parts_toolbar = addToolBar(tr("Parties", "toolbar title"));
parts_toolbar -> setAllowedAreas(Qt::AllToolBarAreas);
parts_toolbar -> setObjectName("parts");
parts_toolbar -> addActions(parts -> actions());
addToolBar(Qt::LeftToolBarArea, parts_toolbar);
/*
QAction *xml_preview = new QAction(QET::Icons::DialogInformation, tr("XML"), this);
connect(xml_preview, SIGNAL(triggered()), this, SLOT(xmlPreview()));
parts_toolbar -> addAction(xml_preview);
*/
main_toolbar = new QToolBar(tr("Outils", "toolbar title"), this);
main_toolbar -> setObjectName("main_toolbar");
@@ -313,8 +296,6 @@ void QETElementEditor::setupActions() {
view_toolbar -> setObjectName("display");
element_toolbar = new QToolBar(tr("\311l\351ment", "toolbar title"), this);
element_toolbar -> setObjectName("element_toolbar");
depth_toolbar = new QToolBar(tr("Profondeur", "toolbar title"), this);
depth_toolbar -> setObjectName("depth_toolbar");
main_toolbar -> addAction(new_element);
main_toolbar -> addAction(open);
@@ -333,16 +314,9 @@ void QETElementEditor::setupActions() {
element_toolbar -> addAction(edit_names);
element_toolbar -> addAction(m_edit_properties);
depth_toolbar -> addAction(edit_forward);
depth_toolbar -> addAction(edit_raise);
depth_toolbar -> addAction(edit_lower);
depth_toolbar -> addAction(edit_backward);
addToolBar(Qt::TopToolBarArea, main_toolbar);
addToolBar(Qt::TopToolBarArea, view_toolbar);
addToolBar(Qt::TopToolBarArea, element_toolbar);
addToolBar(Qt::TopToolBarArea, depth_toolbar);
addToolBar(Qt::LeftToolBarArea, parts_toolbar);
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateInformations()));
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateMenus()));
@@ -360,7 +334,7 @@ void QETElementEditor::setupActions() {
}
/**
Met en place les menus.
* @brief QETElementEditor::setupMenus
*/
void QETElementEditor::setupMenus() {
file_menu = new QMenu(tr("&Fichier"), this);
@@ -411,15 +385,9 @@ void QETElementEditor::setupMenus() {
edit_menu -> addAction(edit_author);
edit_menu -> addAction(m_edit_properties);
edit_menu -> addSeparator();
edit_menu -> addAction(edit_forward);
edit_menu -> addAction(edit_raise);
edit_menu -> addAction(edit_lower);
edit_menu -> addAction(edit_backward);
edit_menu -> addActions(m_depth_ag -> actions());
display_menu -> addAction(zoom_in);
display_menu -> addAction(zoom_out);
display_menu -> addAction(zoom_fit);
display_menu -> addAction(zoom_reset);
display_menu -> addActions(m_zoom_ag -> actions());
insertMenu(settings_menu_, file_menu);
insertMenu(settings_menu_, edit_menu);
@@ -446,10 +414,7 @@ void QETElementEditor::contextMenu(QContextMenuEvent *event) {
menu.addAction(paste_in_area);
menu.addMenu(paste_from_menu);
menu.addSeparator();
menu.addAction(edit_forward);
menu.addAction(edit_raise);
menu.addAction(edit_lower);
menu.addAction(edit_backward);
menu.addActions(m_depth_ag -> actions());
menu.exec(event -> globalPos());
}
@@ -471,15 +436,13 @@ void QETElementEditor::slot_updateMenus() {
paste_from_elmt -> setEnabled(!read_only);
parts_list -> setEnabled(!read_only);
// actions dependant de la presence de parties selectionnees
// Action enabled if primitive selected
deselectall -> setEnabled(selected_items);
cut -> setEnabled(selected_items);
copy -> setEnabled(selected_items);
edit_delete -> setEnabled(selected_items);
edit_forward -> setEnabled(selected_items);
edit_raise -> setEnabled(selected_items);
edit_lower -> setEnabled(selected_items);
edit_backward -> setEnabled(selected_items);
foreach (QAction *action, m_depth_ag -> actions())
action->setEnabled(selected_items);
// actions dependant du contenu du presse-papiers
paste -> setEnabled(clipboard_elmt);
@@ -510,7 +473,6 @@ void QETElementEditor::slot_updateTitle() {
void QETElementEditor::setupInterface() {
// editeur
ce_scene = new ElementScene(this, this);
ce_scene -> slot_move();
ce_view = new ElementView(ce_scene, this);
slot_setRubberBandToView();
setCentralWidget(ce_view);
@@ -596,15 +558,6 @@ void QETElementEditor::slot_setNoDragToView() {
ce_view -> setDragMode(QGraphicsView::NoDrag);
}
/**
Passe l'editeur en mode normal
*/
void QETElementEditor::slot_setNormalMode() {
if (!move -> isChecked()) move -> setChecked(true);
ce_view -> setDragMode(QGraphicsView::RubberBandDrag);
ce_scene -> slot_move();
}
/**
Met a jour la zone d'information et d'edition des primitives.
Si plusieurs primitives sont selectionnees, seule leur quantite est
@@ -684,7 +637,8 @@ bool QETElementEditor::checkElement() {
/// Check master, slave and simple element
if(ce_scene -> elementType() == "master" ||
ce_scene -> elementType() == "slave" ||
ce_scene -> elementType() == "simple" ) {
ce_scene -> elementType() == "simple" ||
ce_scene -> elementType().contains("report")) {
bool wrng = true;
foreach (CustomElementPart *cep, ce_scene->primitives()) {
@@ -694,7 +648,7 @@ bool QETElementEditor::checkElement() {
if (wrng) {
errors << qMakePair(
tr("Absence de champ texte 'label'", "warning title"),
tr("Les \351l\351ments ma\356tres, esclaves et simple doivent poss\351der "
tr("Les \351l\351ments ma\356tres, esclaves, simple et renvoie de folio doivent poss\351der "
"un champ texte comportant le tagg 'label'", "warning description"));
}
}
@@ -978,12 +932,28 @@ void QETElementEditor::addText() {
/**
* @brief QETElementEditor::addTextField
* Set text field interface to scene
* Set text field creation interface to scene
*/
void QETElementEditor::addTextField() {
ce_scene -> setEventInterface(new ESEventAddTextField(ce_scene));
}
/**
* @brief QETElementEditor::addTerminal
* Set terminal creation interface to scene
*/
void QETElementEditor::addTerminal() {
ce_scene -> setEventInterface(new ESEventAddTerminal(ce_scene));
}
/**
* @brief QETElementEditor::UncheckAddPrimitive
* Uncheck all action related to primitive
*/
void QETElementEditor::UncheckAddPrimitive() {
foreach(QAction *action, parts->actions()) action -> setChecked(false);
}
/**
Lance l'assistant de creation d'un nouvel element.
*/

View File

@@ -40,6 +40,9 @@ class QETElementEditor : public QETMainWindow {
virtual ~QETElementEditor();
private:
QETElementEditor(const QETElementEditor &);
void setupActions();
void setupMenus();
void setupInterface();
// attributes
private:
@@ -74,15 +77,10 @@ class QETElementEditor : public QETMainWindow {
QAction *cut, *copy, *paste, *paste_in_area, *paste_from_file, *paste_from_elmt;
QAction *undo, *redo;
QAction *edit_delete, *edit_size_hs, *edit_names, *edit_author, *m_edit_properties;
QAction *edit_raise, *edit_lower, *edit_backward, *edit_forward;
/// actions for the "display" menu
QAction *zoom_in, *zoom_out, *zoom_fit, *zoom_reset;
/// toolbars
QToolBar *parts_toolbar, *main_toolbar, *view_toolbar, *depth_toolbar, *element_toolbar;
/// toolbars actions
QActionGroup *parts;
QAction *move, *add_line, *add_rectangle, *add_ellipse, *add_polygon, *add_text;
QAction *add_arc, *add_terminal, *add_textfield;
/// Action group
QActionGroup *parts, *m_zoom_ag, *m_depth_ag;
/// minimum window title
QString min_title;
/// filename of the currently edited element
@@ -120,9 +118,6 @@ class QETElementEditor : public QETMainWindow {
virtual void firstActivation(QEvent *);
private:
void setupActions();
void setupMenus();
void setupInterface();
bool canClose();
QWidget *clearToolsDock();
void copyAndPasteXml(const QDomDocument &);
@@ -135,6 +130,8 @@ class QETElementEditor : public QETMainWindow {
void addArc();
void addText();
void addTextField();
void addTerminal();
void UncheckAddPrimitive();
void slot_new();
void slot_open();
@@ -147,7 +144,6 @@ class QETElementEditor : public QETMainWindow {
bool slot_saveAsFile();
void slot_setRubberBandToView();
void slot_setNoDragToView();
void slot_setNormalMode();
void slot_updateInformations();
void slot_updateMenus();
void slot_updateTitle();

View File

@@ -196,7 +196,7 @@ QPixmap ElementsCollectionCache::pixmap() const {
*/
bool ElementsCollectionCache::fetchData(const ElementsLocation &location) {
int state;
Element *custom_elmt = ElementFactory::Instance()->createElement(location, 0, 0, &state);
Element *custom_elmt = ElementFactory::Instance() -> createElement(location, 0, &state);
if (state) {
qDebug() << "ElementsCollectionCache::fetchData() : Le chargement du composant" << qPrintable(location.toString()) << "a echoue avec le code d'erreur" << state;
} else {

View File

@@ -294,7 +294,7 @@ void ElementsPanel::startElementDrag(const ElementsLocation &location) {
// element temporaire pour fournir un apercu
int elmt_creation_state;
Element *temp_elmt = ElementFactory::Instance()->createElement(location, 0, 0, &elmt_creation_state);
Element *temp_elmt = ElementFactory::Instance() -> createElement(location, 0, &elmt_creation_state);
if (elmt_creation_state) {
delete temp_elmt;
return;

View File

@@ -72,6 +72,8 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
prj_del_diagram = new QAction(QET::Icons::DiagramDelete, tr("Supprimer ce sch\351ma"), this);
prj_move_diagram_up = new QAction(QET::Icons::GoUp, tr("Remonter ce sch\351ma"), this);
prj_move_diagram_down = new QAction(QET::Icons::GoDown, tr("Abaisser ce sch\351ma"), this);
prj_move_diagram_upx10 = new QAction(QET::Icons::GoUp, tr("Remonter ce sch\351ma x10"), this);
prj_move_diagram_downx10 = new QAction(QET::Icons::GoDown, tr("Abaisser ce sch\351ma x10"), this);
tbt_add = new QAction(QET::Icons::TitleBlock, tr("Nouveau mod\350le"), this);
tbt_edit = new QAction(QET::Icons::TitleBlock, tr("\311diter ce mod\350le"), this);
tbt_remove = new QAction(QET::Icons::TitleBlock, tr("Supprimer ce mod\350le"), this);
@@ -118,6 +120,8 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
connect(prj_del_diagram, SIGNAL(triggered()), this, SLOT(deleteDiagram()));
connect(prj_move_diagram_up, SIGNAL(triggered()), this, SLOT(moveDiagramUp()));
connect(prj_move_diagram_down, SIGNAL(triggered()), this, SLOT(moveDiagramDown()));
connect(prj_move_diagram_upx10, SIGNAL(triggered()), this, SLOT(moveDiagramUpx10()));
connect(prj_move_diagram_downx10, SIGNAL(triggered()), this, SLOT(moveDiagramDownx10()));
connect(tbt_add, SIGNAL(triggered()), this, SLOT(addTitleBlockTemplate()));
connect(tbt_edit, SIGNAL(triggered()), this, SLOT(editTitleBlockTemplate()));
connect(tbt_remove, SIGNAL(triggered()), this, SLOT(removeTitleBlockTemplate()));
@@ -311,6 +315,25 @@ void ElementsPanelWidget::moveDiagramDown() {
}
}
/**
Emet le signal requestForDiagramMoveUpx10 avec le schema selectionne
*/
void ElementsPanelWidget::moveDiagramUpx10() {
if (Diagram *selected_diagram = elements_panel -> selectedDiagram()) {
emit(requestForDiagramMoveUpx10(selected_diagram));
}
}
/**
Emet le signal requestForDiagramMoveDownx10 avec le schema selectionne
*/
void ElementsPanelWidget::moveDiagramDownx10() {
if (Diagram *selected_diagram = elements_panel -> selectedDiagram()) {
emit(requestForDiagramMoveDownx10(selected_diagram));
}
}
/**
Opens a template editor to create a new title block template.
*/
@@ -431,6 +454,8 @@ void ElementsPanelWidget::updateButtons() {
prj_del_diagram -> setEnabled(is_writable);
prj_move_diagram_up -> setEnabled(is_writable && diagram_position > 0);
prj_move_diagram_down -> setEnabled(is_writable && diagram_position < project_diagrams_count - 1);
prj_move_diagram_upx10 -> setEnabled(is_writable && diagram_position > 10);
prj_move_diagram_downx10 -> setEnabled(is_writable && diagram_position < project_diagrams_count - 10);
setElementsActionEnabled(false);
} else if (current_type == QET::TitleBlockTemplatesCollection) {
TitleBlockTemplateLocation location = elements_panel -> templateLocationForItem(current_item);
@@ -533,8 +558,10 @@ void ElementsPanelWidget::handleContextMenu(const QPoint &pos) {
case QET::Diagram:
context_menu -> addAction(prj_prop_diagram);
context_menu -> addAction(prj_del_diagram);
context_menu -> addAction(prj_move_diagram_upx10);
context_menu -> addAction(prj_move_diagram_up);
context_menu -> addAction(prj_move_diagram_down);
context_menu -> addAction(prj_move_diagram_downx10);
break;
case QET::TitleBlockTemplatesCollection:
context_menu -> addAction(tbt_add);

View File

@@ -44,7 +44,7 @@ class ElementsPanelWidget : public QWidget {
QAction *new_category, *edit_category, *delete_category;
QAction *delete_collection;
QAction *new_element, *edit_element, *delete_element, *open_element;
QAction *prj_activate, *prj_close, *prj_edit_prop, *prj_prop_diagram, *prj_add_diagram, *prj_del_diagram, *prj_move_diagram_up, *prj_move_diagram_down;
QAction *prj_activate, *prj_close, *prj_edit_prop, *prj_prop_diagram, *prj_add_diagram, *prj_del_diagram, *prj_move_diagram_up, *prj_move_diagram_down, *prj_move_diagram_upx10, *prj_move_diagram_downx10;
QAction *tbt_add, *tbt_edit, *tbt_remove;
QAction *copy_elements_, *move_elements_, *cancel_elements_;
QMenu *context_menu;
@@ -67,6 +67,8 @@ class ElementsPanelWidget : public QWidget {
void requestForDiagramDeletion(Diagram *);
void requestForDiagramMoveUp(Diagram *);
void requestForDiagramMoveDown(Diagram *);
void requestForDiagramMoveUpx10(Diagram *);
void requestForDiagramMoveDownx10(Diagram *);
public slots:
void clearFilterTextField();
@@ -81,6 +83,8 @@ class ElementsPanelWidget : public QWidget {
void deleteDiagram();
void moveDiagramUp();
void moveDiagramDown();
void moveDiagramUpx10();
void moveDiagramDownx10();
void addTitleBlockTemplate();
void editTitleBlockTemplate();
void removeTitleBlockTemplate();

View File

@@ -31,29 +31,31 @@ ElementFactory* ElementFactory::factory_ = 0;
* @brief ElementFactory::createElement
* @param location create element at this location
* @param qgi parent item for this elemnt
* @param s diagram of the element
* @param state state of the creation
* @return the element or 0
*/
Element * ElementFactory::createElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) {
Element * ElementFactory::createElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state)
{
// recupere la definition de l'element
ElementsCollectionItem *element_item = QETApp::collectionItem(location);
ElementDefinition *element_definition;
if (!element_item ||\
!element_item -> isElement() ||\
!(element_definition = qobject_cast<ElementDefinition *>(element_item))) {
!(element_definition = qobject_cast<ElementDefinition *>(element_item)))
{
if (state) *state = 1;
return 0;
}
if (element_definition->xml().hasAttribute("link_type")) {
if (element_definition->xml().hasAttribute("link_type"))
{
QString link_type = element_definition->xml().attribute("link_type");
if (link_type == "next_report" || link_type == "previous_report") return (new ReportElement(location, link_type, qgi, s, state));
if (link_type == "master") return (new MasterElement (location, qgi, s, state));
if (link_type == "slave") return (new SlaveElement (location, qgi, s, state));
if (link_type == "terminal") return (new TerminalElement (location, qgi, s, state));
if (link_type == "next_report" || link_type == "previous_report") return (new ReportElement(location, link_type, qgi, state));
if (link_type == "master") return (new MasterElement (location, qgi, state));
if (link_type == "slave") return (new SlaveElement (location, qgi, state));
if (link_type == "terminal") return (new TerminalElement (location, qgi, state));
}
//default if nothing match for link_type
return (new SimpleElement(location, qgi, s, state));
return (new SimpleElement(location, qgi, state));
}

View File

@@ -45,6 +45,7 @@ class ElementFactory
}
return factory_;
}
// delete the instance of factory
static void dropInstance () {
static QMutex mutex;
@@ -55,6 +56,7 @@ class ElementFactory
mutex.unlock();
}
}
//attributes
private:
static ElementFactory* factory_;
@@ -67,7 +69,7 @@ class ElementFactory
~ElementFactory() {}
public:
Element * createElement (const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
Element * createElement (const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
};
//ElementFactory ElementFactory::factory_ = 0;
#endif // ELEMENTFACTORY_H

View File

@@ -969,11 +969,13 @@ void GenericPanel::diagramRemoved(QETProject *project, Diagram *diagram) {
}
/**
@param project Projet auquel appartiennent les schemas concernes
@param from Index de l'onglet avant le deplacement
@param to Index de l'onglet apres le deplacement
* @brief GenericPanel::projectDiagramsOrderChanged
* @param project project where diagram moved
* @param from Index of diagram before move
* @param to Index of diagram after move
*/
void GenericPanel::projectDiagramsOrderChanged(QETProject *project, int from, int to) {
void GenericPanel::projectDiagramsOrderChanged(QETProject *project, int from, int to)
{
// get the item representing the provided project
QTreeWidgetItem *qtwi_project = itemForProject(project);
if (!qtwi_project) return;
@@ -988,19 +990,19 @@ void GenericPanel::projectDiagramsOrderChanged(QETProject *project, int from, in
qtwi_project -> insertChild (to, moved_qtwi_diagram);
// update the QTWI labels because they may display the folio index
foreach (int diagram_index, QList<int>() << from << to) {
QTreeWidgetItem *qtwi_diagram = qtwi_project -> child(diagram_index);
for (int i = qMin(from, to); i < qMax(from, to) + 1; i++)
{
QTreeWidgetItem *qtwi_diagram = qtwi_project -> child(i);
if (!qtwi_diagram) continue;
Diagram *diagram = valueForItem<Diagram *>(qtwi_diagram);
if (diagram) {
if (diagram)
updateDiagramItem(qtwi_diagram, diagram);
}
}
if (was_selected) {
if (was_selected)
setCurrentItem(moved_qtwi_diagram);
}
emit(panelContentChanged());
}

View File

@@ -81,7 +81,7 @@ bool nomenclature::saveToCSVFile() {
QString nomenclature::getNomenclature() {
//Process...
QString data = tr("NOMENCLATURE : ") + m_project -> title() + "\n\n";
data += tr("Folio") +";"+ tr("Sch\351ma") +";"+ tr("D\351signation")+";"+ tr("Label") +";"+ tr("Commentaire") +";"+ tr("Fabriquant") +";"+ tr("Reference") +";"+ tr("Machine-reference")+"\n";
data += tr("Folio") +";"+ tr("Sch\351ma") +";"+ tr("D\351signation qet")+";"+ tr("Label") +";"+ tr("D\351signation")+";"+ tr("Commentaire") +";"+ tr("Fabriquant") +";"+ tr("Reference") +";"+ tr("Machine-reference")+"\n";
if(m_list_diagram.isEmpty()) return data;
@@ -115,6 +115,7 @@ QString nomenclature::getElementInfo(const Element *elmt) {
info += diagram -> title() + ";";
info += elmt -> name() + ";";
info += elmt_info["label"].toString() + ";";
info += elmt_info["designation"].toString() + ";";
info += elmt_info["comment"].toString() + ";";
info += elmt_info["manufacturer"].toString() + ";";
info += elmt_info["manufacturer-reference"].toString() + ";";

View File

@@ -113,13 +113,6 @@ QList<Diagram *> ProjectView::getDiagrams(ProjectSaveOptions options) {
}
}
if (options & ModifiedDiagramsOnly) {
foreach (Diagram *diagram, selection) {
if (!diagram -> undoStack().isClean() || !diagram -> wasWritten()) continue;
selection.removeOne(diagram);
}
}
return(selection);
}
@@ -315,8 +308,8 @@ void ProjectView::addNewDiagram() {
*/
void ProjectView::addNewDiagramFolioList() {
if (project_ -> isReadOnly()) return;
int i = 0; //< Each new diagram is added to the end of the project.
//< We use @i to move the folio list at the beginning of the project
int i = 1; //< Each new diagram is added to the end of the project.
//< We use @i to move the folio list at second position in the project
foreach (Diagram *d, project_ -> addNewDiagramFolioList()) {
DiagramView *new_diagram_view = new DiagramView(d);
addDiagram(new_diagram_view);
@@ -371,11 +364,8 @@ void ProjectView::removeDiagram(DiagramView *diagram_view) {
// verifie que le schema est bien present dans le projet
if (!diagram_ids_.values().contains(diagram_view)) return;
// demande confirmation a l'utilisateur
if (
diagram_view -> diagram() -> wasWritten() ||\
!diagram_view -> diagram() -> undoStack().isClean()
) {
//Ask confirmation to user.
int answer = QET::MessageBox::question(
this,
tr("Supprimer le sch\351ma ?", "message box title"),
@@ -386,10 +376,6 @@ void ProjectView::removeDiagram(DiagramView *diagram_view) {
if (answer != QMessageBox::Yes) {
return;
}
}
// notifie le reste du monde que le DiagramView va disparaitre
emit(diagramAboutToBeRemoved(diagram_view));
// enleve le DiagramView des onglets
int diagram_tab_id = diagram_ids_.key(diagram_view);
@@ -515,6 +501,48 @@ void ProjectView::moveDiagramDown(Diagram *diagram) {
moveDiagramDown(findDiagram(diagram));
}
/**
Deplace le schema diagram_view vers le haut / la gauche x10
*/
void ProjectView::moveDiagramUpx10(DiagramView *diagram_view) {
if (!diagram_view) return;
int diagram_view_position = diagram_ids_.key(diagram_view);
if (!diagram_view_position) {
// le schema est le premier du projet
return;
}
tabs_ -> moveTab(diagram_view_position, diagram_view_position - 10);
}
/**
Deplace le schema diagram vers le haut / la gauche x10
*/
void ProjectView::moveDiagramUpx10(Diagram *diagram) {
moveDiagramUpx10(findDiagram(diagram));
}
/**
Deplace le schema diagram_view vers le bas / la droite x10
*/
void ProjectView::moveDiagramDownx10(DiagramView *diagram_view) {
if (!diagram_view) return;
int diagram_view_position = diagram_ids_.key(diagram_view);
if (diagram_view_position + 1 == diagram_ids_.count()) {
// le schema est le dernier du projet
return;
}
tabs_ -> moveTab(diagram_view_position, diagram_view_position + 10);
}
/**
Deplace le schema diagram vers le bas / la droite x10
*/
void ProjectView::moveDiagramDownx10(Diagram *diagram) {
moveDiagramDownx10(findDiagram(diagram));
}
/**
Ce slot demarre un dialogue permettant a l'utilisateur de parametrer et de
lancer l'impression de toute ou partie du projet.
@@ -777,7 +805,7 @@ void ProjectView::loadDiagrams() {
// If project have the folios list, move it at the beginning of the project
if (project_ -> getFolioSheetsQuantity()) {
for (int i = 0; i < project_->getFolioSheetsQuantity(); i++)
tabs_ -> moveTab(diagrams().size()-1, 0);
tabs_ -> moveTab(diagrams().size()-1, + 1);
}
}

View File

@@ -34,7 +34,6 @@ class ProjectView : public QWidget {
public:
enum ProjectSaveOption {
ModifiedDiagramsOnly = 1,
CurrentDiagram = 2,
AllDiagramsButCurrent = 4,
AllDiagrams = 6
@@ -74,10 +73,14 @@ class ProjectView : public QWidget {
void moveDiagramUp(Diagram *);
void moveDiagramDown(DiagramView *);
void moveDiagramDown(Diagram *);
void moveDiagramUpx10(DiagramView *);
void moveDiagramUpx10(Diagram *);
void moveDiagramDownx10(DiagramView *);
void moveDiagramDownx10(Diagram *);
void printProject();
void exportProject();
QETResult save();
QETResult saveAs(ProjectSaveOptions = ProjectSaveOptions(AllDiagrams | ModifiedDiagramsOnly));
QETResult saveAs(ProjectSaveOptions = ProjectSaveOptions(AllDiagrams));
QETResult doSave(ProjectSaveOptions);
void saveDiagrams(const QList<Diagram *> &);
int cleanProject();
@@ -88,7 +91,6 @@ class ProjectView : public QWidget {
signals:
void diagramAdded(DiagramView *);
void diagramAboutToBeRemoved(DiagramView *);
void diagramRemoved(DiagramView *);
void diagramActivated(DiagramView *);
void diagramOrderChanged(ProjectView *, int, int);

View File

@@ -683,3 +683,18 @@ QPointF QET::graphicsSceneEventPos(QEvent *event) {
}
return(event_scene_pos);
}
/**
* @brief QET::eachStrIsEqual
* @param qsl list of string to compare
* @return true if every string is identical, else false;
* The list must not be empty
* If the list can be empty, call isEmpty() before calling this function
*/
bool QET::eachStrIsEqual(const QStringList &qsl) {
if (qsl.size() == 1) return true;
foreach (const QString t, qsl) {
if (qsl.at(0) != t) return false;
}
return true;
}

View File

@@ -27,7 +27,7 @@ namespace QET {
/// QElectroTech version (as string, used to mark projects and elements XML documents)
const QString version = "0.4";
/// QElectroTech displayed version
const QString displayedVersion = "0.4-rc1";
const QString displayedVersion = "0.4-rc2";
QString license();
/// Oriented movements
@@ -154,6 +154,7 @@ namespace QET {
QString titleBlockColumnLengthToString(const TitleBlockColumnLength &);
bool writeXmlFile(QDomDocument &, const QString &, QString * = 0);
QPointF graphicsSceneEventPos(QEvent *);
bool eachStrIsEqual (const QStringList &qsl);
}
class Qet : public QObject {

View File

@@ -346,6 +346,7 @@ QStringList QETApp::elementInfoKeys() {
QStringList info_list;
info_list << "label"
<< "comment"
<< "designation"
<< "manufacturer"
<< "manufacturer-reference"
<< "machine-manufacturer-reference";
@@ -362,6 +363,7 @@ QStringList QETApp::elementInfoKeys() {
QString QETApp::elementTranslatedInfoKey(QString &info) {
if (info == "label") return tr("Label");
else if (info == "comment") return tr("Commentaire");
else if (info == "designation") return tr("D\351signation");
else if (info == "manufacturer") return tr("Fabriquant");
else if (info == "manufacturer-reference") return tr("R\351f\351rence fabriquant");
else if (info == "machine-manufacturer-reference") return tr("R\351f\351rence fabriquant machine");

View File

@@ -44,10 +44,12 @@
#include <QMessageBox>
/**
constructeur
@param files Liste de fichiers a ouvrir
@param parent le widget parent de la fenetre principale
* @brief QETDiagramEditor::QETDiagramEditor
* Constructor
* @param files, list of files to open
* @param parent, parent widget
*/
QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
QETMainWindow(parent),
@@ -57,13 +59,12 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
m_selection_actions_group (this),
m_row_column_actions_group (this),
m_file_actions_group (this),
open_dialog_dir (QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)),
can_update_actions (true)
open_dialog_dir (QDesktopServices::storageLocation(QDesktopServices::DesktopLocation))
{
// mise en place de l'interface MDI au centre de l'application
//Setup the mdi area at center of application
setCentralWidget(&workspace);
// nomme l'objet afin qu'il soit reperable par les feuilles de style
//Set object name to be retrieved by the stylesheets
workspace.setBackground(QBrush(Qt::NoBrush));
workspace.setObjectName("mdiarea");
@@ -71,16 +72,11 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
workspace.setTabsClosable(true);
#endif
// mise en place du signalmapper
//Set the signal mapper
connect(&windowMapper, SIGNAL(mapped(QWidget *)), this, SLOT(activateWidget(QWidget *)));
// titre de la fenetre
setWindowTitle(tr("QElectroTech", "window title"));
// icone de la fenetre
setWindowIcon(QET::Icons::QETLogo);
// barre de statut de la fenetre
statusBar() -> showMessage(tr("QElectroTech", "status bar message"));
setUpElementsPanel();
@@ -89,37 +85,30 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
setUpToolBar();
setUpMenu();
// la fenetre est maximisee par defaut
tabifyDockWidget(qdw_undo, qdw_pa);
//By default the windows is maximised
setMinimumSize(QSize(500, 350));
setWindowState(Qt::WindowMaximized);
// connexions signaux / slots pour une interface sensee
connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(slot_updateWindowsMenu()));
connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(slot_updateUndoStack()));
connect (&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(subWindowActivated(QMdiSubWindow*)));
connect (QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slot_updatePasteAction()));
connect (&undo_group, SIGNAL(cleanChanged(bool)), this, SLOT(activeUndoStackCleanChanged(bool)));
// lecture des parametres
readSettings();
// affichage
show();
// si des chemins de fichiers valides sont passes en arguments
//If valid file path is given as arguments
uint opened_projects = 0;
if (files.count()) {
// alors on ouvre ces fichiers
foreach(QString file, files) {
bool project_opening = openAndAddProject(file, false);
if (project_opening) {
if (files.count())
{
//So we open this files
foreach(QString file, files)
if (openAndAddProject(file, false))
++ opened_projects;
}
}
}
slot_updateActions();
// si aucun schema n'a ete ouvert jusqu'a maintenant, on ouvre un nouveau schema
//if (!opened_projects) newProject();
}
/**
@@ -142,6 +131,7 @@ void QETDiagramEditor::setUpElementsPanel() {
qdw_pa -> setMinimumWidth (160);
qdw_pa -> setWidget (pa = new ElementsPanelWidget(qdw_pa));
addDockWidget(Qt::LeftDockWidgetArea, qdw_pa);
connect(pa, SIGNAL(requestForProject (QETProject *)), this, SLOT(activateProject(QETProject *)));
connect(pa, SIGNAL(requestForProjectClosing (QETProject *)), this, SLOT(closeProject(QETProject *)));
@@ -153,6 +143,8 @@ void QETDiagramEditor::setUpElementsPanel() {
connect(pa, SIGNAL(requestForDiagramDeletion (Diagram *)), this, SLOT(removeDiagram(Diagram *)));
connect(pa, SIGNAL(requestForDiagramMoveUp (Diagram *)), this, SLOT(moveDiagramUp(Diagram *)));
connect(pa, SIGNAL(requestForDiagramMoveDown (Diagram *)), this, SLOT(moveDiagramDown(Diagram *)));
connect(pa, SIGNAL(requestForDiagramMoveUpx10 (Diagram *)), this, SLOT(moveDiagramUpx10(Diagram *)));
connect(pa, SIGNAL(requestForDiagramMoveDownx10 (Diagram *)), this, SLOT(moveDiagramDownx10(Diagram *)));
}
/**
@@ -174,6 +166,8 @@ void QETDiagramEditor::setUpUndoStack() {
qdw_undo -> setFeatures(QDockWidget::AllDockWidgetFeatures);
qdw_undo -> setMinimumWidth(160);
qdw_undo -> setWidget(undo_view);
addDockWidget(Qt::LeftDockWidgetArea, qdw_undo);
}
/**
@@ -619,30 +613,44 @@ void QETDiagramEditor::exportDialog() {
}
/**
Methode enregistrant le schema dans le dernier nom de fichier connu.
@return true si l'enregistrement a reussi, false sinon
* @brief QETDiagramEditor::save
* Ask the current active project to save
*/
void QETDiagramEditor::save() {
if (ProjectView *project_view = currentProject()) {
QETResult saved = project_view -> save();
if (saved.isOk()) {
save_file -> setDisabled(true);
QETApp::projectsRecentFiles() -> fileWasOpened(project_view -> project() -> filePath());
} else {
QString title = (project_view -> project() -> title ());
if (title.isEmpty()) title = "QElectroTech ";
QString filePath = (project_view -> project() -> filePath ());
statusBar()-> showMessage(tr("Projet %1 enregistr\351 dans le repertoire: %2.").arg(title).arg (filePath), 2000);
}
else {
showError(saved);
}
}
}
/**
Cette methode demande un nom de fichier a l'utilisateur pour enregistrer le schema
@return true si l'enregistrement a reussi, false sinon
* @brief QETDiagramEditor::saveAs
* Ask the current active project to save as
*/
void QETDiagramEditor::saveAs() {
if (ProjectView *project_view = currentProject()) {
QETResult save_file = project_view -> saveAs();
if (save_file.isOk()) {
QETApp::projectsRecentFiles() -> fileWasOpened(project_view -> project() -> filePath());
} else {
QString title = (project_view -> project() -> title ());
if (title.isEmpty()) title = "QElectroTech ";
QString filePath = (project_view -> project() -> filePath ());
statusBar()->showMessage(tr("Projet %1 enregistr\351 dans le repertoire: %2.").arg(title).arg (filePath), 2000);
}
else {
showError(save_file);
}
}
@@ -859,6 +867,8 @@ bool QETDiagramEditor::addProject(QETProject *project, bool update_panel) {
ProjectView *project_view = new ProjectView(project);
addProjectView(project_view);
undo_group.addStack(project -> undoStack());
// met a jour le panel d'elements
if (update_panel) {
pa -> elementsPanel().projectWasOpened(project);
@@ -1132,24 +1142,22 @@ void QETDiagramEditor::slot_setVisualisationMode() {
}
/**
gere les actions
* @brief QETDiagramEditor::slot_updateActions
* Manage actions
*/
void QETDiagramEditor::slot_updateActions() {
void QETDiagramEditor::slot_updateActions()
{
DiagramView *dv = currentDiagram();
ProjectView *pv = currentProject();
bool opened_project = pv;
bool opened_diagram = dv;
bool editable_project = (pv && !pv -> project() -> isReadOnly());
bool editable_diagram = (dv && !dv -> diagram() -> isReadOnly());
// actions ayant juste besoin d'un document ouvert
close_file -> setEnabled(opened_project);
save_file -> setEnabled(editable_project);
save_file_as -> setEnabled(opened_project);
prj_edit_prop -> setEnabled(opened_project);
prj_add_diagram -> setEnabled(editable_project);
//prj_add_diagram_foliolist -> setEnabled(editable_project);
prj_del_diagram -> setEnabled(editable_project);
prj_clean -> setEnabled(editable_project);
prj_diagramList -> setEnabled(opened_project);
@@ -1160,10 +1168,10 @@ void QETDiagramEditor::slot_updateActions() {
prj_nomenclature -> setEnabled(editable_project);
m_zoom_actions_group. setEnabled(opened_diagram);
m_select_actions_group. setEnabled(opened_diagram);
m_add_item_actions_group.setEnabled(editable_diagram);
m_row_column_actions_group.setEnabled(editable_diagram);
m_add_item_actions_group. setEnabled(editable_project);
m_row_column_actions_group.setEnabled(editable_project);
slot_updateUndoStack();
slot_updateModeActions();
slot_updatePasteAction();
slot_updateComplexActions();
@@ -1173,12 +1181,17 @@ void QETDiagramEditor::slot_updateActions() {
* @brief QETDiagramEditor::slot_updateUndoStack
* Update the undo stack view
*/
void QETDiagramEditor::slot_updateUndoStack() {
void QETDiagramEditor::slot_updateUndoStack()
{
ProjectView *pv = currentProject();
if (pv && can_update_actions) {
if (pv)
{
undo_group.setActiveStack(pv->project()->undoStack());
undo -> setEnabled (undo_group.canUndo());
redo -> setEnabled (undo_group.canRedo());
save_file -> setEnabled (undo_group.activeStack() -> count() && !pv -> project() -> isReadOnly());
}
else
{
save_file -> setDisabled(true);
}
}
@@ -1210,13 +1223,14 @@ void QETDiagramEditor::slot_updateComplexActions() {
// actions ayant besoin de textes selectionnes
int selected_texts = dv ? (dv -> diagram() -> selectedTexts().count()) : 0;
int selected_conductor_texts = dv ? (dv -> diagram() -> selectedConductorTexts().count()) : 0;
int selected_element_texts = dv ? (dv -> diagram() -> selectedElementTexts().count()) : 0;
rotate_texts -> setEnabled(editable_diagram && selected_texts);
// actions need only one editable item
int selected_image = dv ? dv -> diagram() -> selectedContent().count(DiagramContent::Images) : 0;
int selected_shape = dv ? dv -> diagram() -> selectedContent().count(DiagramContent::Shapes) : 0;
int selected_editable = selected_elements_count + (selected_texts - selected_conductor_texts) + selected_image + selected_shape;
int selected_editable = selected_elements_count + (selected_texts - selected_conductor_texts - selected_element_texts) + selected_image + selected_shape;
if (selected_editable == 1) {
edit_selection -> setEnabled(true);
@@ -1283,65 +1297,46 @@ void QETDiagramEditor::slot_updatePasteAction() {
}
/**
Ajoute un projet dans l'espace de travail
@param project_view Le projet a ajouter dans l'espace de travail
* @brief QETDiagramEditor::addProjectView
* Add a new project view to workspace and
* build the connection between the projectview / project and this QETDiagramEditor.
* @param project_view, project view to add
*/
void QETDiagramEditor::addProjectView(ProjectView *project_view) {
void QETDiagramEditor::addProjectView(ProjectView *project_view)
{
if (!project_view) return;
// on maximise la nouvelle fenetre si la fenetre en cours est inexistante ou bien maximisee
QWidget *current_window = workspace.activeSubWindow();
bool maximise = ((!current_window) || (current_window -> windowState() & Qt::WindowMaximized));
// ajoute la fenetre
QMdiSubWindow *sub_window = workspace.addSubWindow(project_view);
sub_window -> setWindowIcon(project_view -> windowIcon());
sub_window -> systemMenu() -> clear();
// lie les schemas du projet a l'editeur :
// quand on change de schemas a l'interieur d'un projet, on met a jour les menus
connect(project_view, SIGNAL(diagramActivated(DiagramView *)), this, SLOT(slot_updateWindowsMenu()));
connect(project_view, SIGNAL(diagramActivated(DiagramView *)), this, SLOT(slot_updateActions()));
//connect(project_view->project(), SIGNAL(projectModified(QETProject*,bool)), save_file, SLOT(setEnabled(bool)));
foreach(DiagramView *dv, project_view -> diagrams()) {
foreach(DiagramView *dv, project_view -> diagrams())
diagramWasAdded(dv);
}
// gere la fermeture du projet
//Manage the close event of project
connect(project_view, SIGNAL(projectClosed(ProjectView*)), this, SLOT(projectWasClosed(ProjectView *)));
// gere l'ajout et le retrait de schema du projet
//Manage the adding of diagram
connect(project_view, SIGNAL(diagramAdded(DiagramView *)), this, SLOT(diagramWasAdded(DiagramView *)));
connect(project_view, SIGNAL(diagramAdded(DiagramView *)), this, SLOT(slot_updateActions()));
connect(project_view, SIGNAL(diagramAboutToBeRemoved(DiagramView *)), this, SLOT(diagramIsAboutToBeRemoved(DiagramView *)));
connect(project_view, SIGNAL(diagramRemoved(DiagramView *)), this, SLOT(diagramWasRemoved(DiagramView *)));
connect(project_view, SIGNAL(diagramRemoved(DiagramView *)), this, SLOT(slot_updateActions()));
if (QETProject *project = project_view -> project()) {
// on met aussi les menus a jour quand un projet passe en lecture seule ou non
if (QETProject *project = project_view -> project())
connect(project, SIGNAL(readOnlyChanged(QETProject *, bool)), this, SLOT(slot_updateActions()));
}
// gere les demandes consistant a retrouver un element dans le panel
//Manage request for edit or find element and titleblock
connect(project_view, SIGNAL(findElementRequired(const ElementsLocation &)), this, SLOT(findElementInPanel(const ElementsLocation &)));
// gere les demandes pour l'edition d'un element
connect(project_view, SIGNAL(editElementRequired(const ElementsLocation &)), this, SLOT(editElementInEditor(const ElementsLocation &)));
// handles requests to edit and/or duplicate an existing title block template
connect(
project_view, SIGNAL(editTitleBlockTemplate(const TitleBlockTemplateLocation &, bool)),
QETApp::instance(), SLOT(openTitleBlockTemplate(TitleBlockTemplateLocation, bool))
);
connect(project_view, SIGNAL(editTitleBlockTemplate(const TitleBlockTemplateLocation &, bool)), QETApp::instance(), SLOT(openTitleBlockTemplate(TitleBlockTemplateLocation, bool)));
// display error messages sent by the project view
connect(project_view, SIGNAL(errorEncountered(QString)), this, SLOT(showError(const QString &)));
// affiche la fenetre
//We maximise the new window if the current window is inexistent or maximized
QWidget *current_window = workspace.activeSubWindow();
bool maximise = ((!current_window) || (current_window -> windowState() & Qt::WindowMaximized));
//Add the new window
QMdiSubWindow *sub_window = workspace.addSubWindow(project_view);
sub_window -> setWindowIcon(project_view -> windowIcon());
sub_window -> systemMenu() -> clear();
//Display the new window
if (maximise) project_view -> showMaximized();
else project_view -> show();
slot_updateActions();
}
/**
@@ -1666,6 +1661,7 @@ void QETDiagramEditor::projectWasClosed(ProjectView *project_view) {
QETProject *project = project_view -> project();
if (project) {
pa -> elementsPanel().projectWasClosed(project);
undo_group.removeStack(project -> undoStack());
QETApp::unregisterProject(project);
}
project_view -> deleteLater();
@@ -1792,6 +1788,46 @@ void QETDiagramEditor::moveDiagramDown(Diagram *diagram) {
}
}
/**
Change l'ordre des schemas d'un projet, en decalant le schema vers le haut /
la gauche x10
@param diagram Schema a decaler vers le haut / la gauche x10
*/
void QETDiagramEditor::moveDiagramUpx10(Diagram *diagram) {
if (!diagram) return;
// recupere le projet contenant le schema
if (QETProject *diagram_project = diagram -> project()) {
if (diagram_project -> isReadOnly()) return;
// recupere la vue sur ce projet
if (ProjectView *project_view = findProject(diagram_project)) {
project_view -> moveDiagramUpx10(diagram);
}
}
}
/**
Change l'ordre des schemas d'un projet, en decalant le schema vers le bas /
la droite x10
@param diagram Schema a decaler vers le bas / la droite x10
*/
void QETDiagramEditor::moveDiagramDownx10(Diagram *diagram) {
if (!diagram) return;
// recupere le projet contenant le schema
if (QETProject *diagram_project = diagram -> project()) {
if (diagram_project -> isReadOnly()) return;
// recupere la vue sur ce projet
if (ProjectView *project_view = findProject(diagram_project)) {
project_view -> moveDiagramDownx10(diagram);
}
}
}
/**
Nettoie le projet courant
*/
@@ -1817,7 +1853,6 @@ void QETDiagramEditor::nomenclatureProject() {
void QETDiagramEditor::removeDiagramFromProject() {
if (ProjectView *current_project = currentProject()) {
if (DiagramView *current_diagram = current_project -> currentDiagram()) {
can_update_actions = false;
bool isFolioList = false;
// if diagram to remove is a "folio list sheet", then set a flag.
@@ -1849,36 +1884,17 @@ void QETDiagramEditor::removeDiagramFromProject() {
}
/**
Gere l'ajout d'un schema dans un projet
@param dv DiagramView concerne
* @brief QETDiagramEditor::diagramWasAdded
* Manage the adding of diagram view in a project
* @param dv, added diagram view
*/
void QETDiagramEditor::diagramWasAdded(DiagramView *dv) {
// quand on change qqc a l'interieur d'un schema, on met a jour les menus
undo_group.addStack(&(dv -> diagram() -> undoStack()));
void QETDiagramEditor::diagramWasAdded(DiagramView *dv)
{
connect(dv, SIGNAL(selectionChanged()), this, SLOT(slot_updateComplexActions()));
connect(dv, SIGNAL(modeChanged()), this, SLOT(slot_updateModeActions()));
connect(dv, SIGNAL(itemAdded()), this, SLOT(addItemFinish()));
}
/**
Gere le retrait d'un schema dans un projet avant que le retrait ne soit effectif
@param dv DiagramView concerne
*/
void QETDiagramEditor::diagramIsAboutToBeRemoved(DiagramView *dv) {
undo_group.removeStack(&(dv -> diagram() -> undoStack()));
can_update_actions = false;
}
/**
Gere le retrait d'un schema dans un projet apres que le retrait soit effectif
@param dv DiagramView concerne
*/
void QETDiagramEditor::diagramWasRemoved(DiagramView *dv) {
Q_UNUSED(dv);
can_update_actions = true;
slot_updateUndoStack();
}
/**
@param location Emplacement de l'element a retrouver dans le panel
d'elements.
@@ -1970,3 +1986,28 @@ void QETDiagramEditor::showError(const QString &error) {
void QETDiagramEditor::addItemFinish() {
m_add_item_actions_group.checkedAction()->setChecked(false);
}
/**
* @brief QETDiagramEditor::subWindowActivated
* Slot used to update menu and undo stack when subwindows of MDIarea was activated
* @param subWindows
*/
void QETDiagramEditor::subWindowActivated(QMdiSubWindow *subWindows)
{
Q_UNUSED(subWindows);
slot_updateActions();
slot_updateWindowsMenu();
}
/**
* @brief QETDiagramEditor::activeUndoStackCleanChanged
* Enable the QAction save_file when @clean is set to false
* @clean at true do nothing;
* @param clean
*/
void QETDiagramEditor::activeUndoStackCleanChanged(bool clean) {
if (!clean) {
save_file -> setEnabled(true);
}
}

View File

@@ -146,11 +146,11 @@ class QETDiagramEditor : public QETMainWindow {
void removeDiagramFromProject();
void moveDiagramUp(Diagram *);
void moveDiagramDown(Diagram *);
void moveDiagramUpx10(Diagram *);
void moveDiagramDownx10(Diagram *);
void cleanCurrentProject();
void nomenclatureProject();
void diagramWasAdded(DiagramView *);
void diagramIsAboutToBeRemoved(DiagramView *);
void diagramWasRemoved(DiagramView *);
void findElementInPanel(const ElementsLocation &);
void findSelectedElementInPanel();
void editElementInEditor(const ElementsLocation &);
@@ -158,6 +158,10 @@ class QETDiagramEditor : public QETMainWindow {
void showError(const QETResult &);
void showError(const QString &);
void addItemFinish();
void subWindowActivated(QMdiSubWindow *subWindows);
private slots:
void activeUndoStackCleanChanged (bool clean);
// attributes
public:
@@ -229,6 +233,5 @@ class QETDiagramEditor : public QETMainWindow {
QToolBar *diagram_bar;
QToolBar *m_add_item_toolBar;
QUndoGroup undo_group;
bool can_update_actions;
};
#endif

View File

@@ -37,7 +37,7 @@ CommentItem::CommentItem(Element *elmt) :
connect(elmt, SIGNAL(yChanged()), this, SLOT (autoPos()));
connect(elmt, SIGNAL(rotationChanged()), this, SLOT (autoPos()));
}
connect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT (updateLabel()));
connect(elmt, SIGNAL(elementInfoChange(DiagramContext,DiagramContext)), this, SLOT (updateLabel()));
updateLabel();
}
@@ -121,7 +121,7 @@ void CommentItem::updateLabel() {
painter.setPen (pen);
painter.setFont (QETApp::diagramTextsFont(6));
QRectF drawing_rect(QPointF(0,0), QSizeF(100, 100));
QRectF drawing_rect(QPointF(0,0), QSizeF(70, 100));
QRectF text_bounding;
painter.drawText(drawing_rect, Qt::TextWordWrap | Qt::AlignHCenter, m_comment, &text_bounding);
@@ -129,6 +129,7 @@ void CommentItem::updateLabel() {
text_bounding.adjust(-1,0,1,0); //adjust only for better visual
painter.drawRoundedRect(text_bounding, 2, 2);
prepareGeometryChange();
m_bounding_rect = text_bounding;
}

View File

@@ -39,11 +39,12 @@ QBrush Conductor::square_brush = QBrush(Qt::darkGreen);
@param p2 Seconde Borne a laquelle le conducteur est lie
@param parent_diagram QGraphicsScene a laquelle appartient le conducteur
*/
Conductor::Conductor(Terminal *p1, Terminal* p2, Diagram *parent_diagram) :
Conductor::Conductor(Terminal *p1, Terminal* p2) :
QObject(),
QGraphicsPathItem(0, parent_diagram),
QGraphicsPathItem(0),
terminal1(p1),
terminal2(p2),
bMouseOver(false),
destroyed_(false),
text_item(0),
segments(NULL),
@@ -91,7 +92,6 @@ Conductor::Conductor(Terminal *p1, Terminal* p2, Diagram *parent_diagram) :
// ajout du champ de texte editable
text_item = new ConductorTextItem(properties_.text, this);
text_item -> setFlag(QGraphicsItem::ItemStacksBehindParent);
calculateTextItemPosition();
connect(
text_item,
SIGNAL(diagramTextChanged(DiagramTextItem *, const QString &, const QString &)),
@@ -444,6 +444,10 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
}
}
// if mouse over conductor change size
if ( bMouseOver ) conductor_pen.setWidthF(3.0);
else conductor_pen.setWidthF(1.0);
// affectation du QPen et de la QBrush modifies au QPainter
qp -> setBrush(conductor_brush);
QPen final_conductor_pen = conductor_pen;
@@ -677,7 +681,6 @@ void Conductor::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
if (!(e -> modifiers() & Qt::ControlModifier)) {
QGraphicsPathItem::mouseReleaseEvent(e);
}
calculateTextItemPosition();
}
/**
@@ -687,10 +690,9 @@ void Conductor::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
void Conductor::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
Q_UNUSED(e);
segments_squares_scale_ = 2.0;
if (isSelected()) {
bMouseOver = true;
update();
}
}
/**
Gere la sortie de la souris de la zone du conducteur
@@ -699,24 +701,23 @@ void Conductor::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
void Conductor::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) {
Q_UNUSED(e);
segments_squares_scale_ = 1.0;
if (isSelected()) {
update();
}
bMouseOver = false;
}
/**
Gere les mouvements de souris au dessus du conducteur
@param e Le QGraphicsSceneHoverEvent decrivant l'evenement
* @brief Conductor::hoverMoveEvent conductor
* @param e QGraphicsSceneHoverEvent describing the event
*/
void Conductor::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
/*
if (isSelected()) {
QPointF hover_point = mapFromScene(e -> pos());
QPointF hover_point = mapFromScene(e -> pos()) + scenePos();
ConductorSegment *segment = segments;
bool cursor_set = false;
while (segment -> hasNextSegment()) {
if (hasClickedOn(hover_point, segment -> secondPoint())) {
setCursor(Qt::CrossCursor);
setCursor(Qt::ForbiddenCursor);
cursor_set = true;
} else if (hasClickedOn(hover_point, segment -> middle())) {
setCursor(segment -> isVertical() ? Qt::SplitHCursor : Qt::SplitVCursor);
@@ -726,7 +727,7 @@ void Conductor::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
}
if (!cursor_set) setCursor(Qt::ArrowCursor);
}
*/
QGraphicsPathItem::hoverMoveEvent(e);
}
@@ -951,27 +952,66 @@ bool Conductor::hasClickedOn(QPointF press_point, QPointF point) const {
}
/**
Charge les caracteristiques du conducteur depuis un element XML.
@param e Un element XML
@return true si le chargement a reussi, false sinon
* @brief Conductor::fromXml
* Load the conductor and her information from xml element
* @param e
* @return true is loading success else return false
*/
bool Conductor::fromXml(QDomElement &e) {
// recupere la "configuration" du conducteur
setPos(e.attribute("x", 0).toDouble(),
e.attribute("y", 0).toDouble());
bool return_ = pathFromXml(e);
text_item -> fromXml(e);
properties_. fromXml(e);
readProperties();
qreal user_pos_x, user_pos_y;
if (
QET::attributeIsAReal(e, "userx", &user_pos_x) &&
QET::attributeIsAReal(e, "usery", &user_pos_y)
) {
text_item -> forceMovedByUser(true);
text_item -> setPos(user_pos_x, user_pos_y);
}
if (e.hasAttribute("rotation")) {
text_item -> setRotationAngle(e.attribute("rotation").toDouble());
text_item -> forceRotateByUser(true);
return return_;
}
/**
Exporte les caracteristiques du conducteur sous forme d'une element XML.
@param d Le document XML a utiliser pour creer l'element XML
@param table_adr_id Hash stockant les correspondances entre les ids des
bornes dans le document XML et leur adresse en memoire
@return Un element XML representant le conducteur
*/
QDomElement Conductor::toXml(QDomDocument &d, QHash<Terminal *, int> &table_adr_id) const {
QDomElement e = d.createElement("conductor");
e.setAttribute("x", pos().x());
e.setAttribute("y", pos().y());
e.setAttribute("terminal1", table_adr_id.value(terminal1));
e.setAttribute("terminal2", table_adr_id.value(terminal2));
// on n'exporte les segments du conducteur que si ceux-ci ont
// ete modifies par l'utilisateur
if (modified_path) {
// parcours et export des segments
QDomElement current_segment;
foreach(ConductorSegment *segment, segmentsList()) {
current_segment = d.createElement("segment");
current_segment.setAttribute("orientation", segment -> isHorizontal() ? "horizontal" : "vertical");
current_segment.setAttribute("length", QString("%1").arg(segment -> length()));
e.appendChild(current_segment);
}
}
// Export the properties and text
properties_. toXml(e);
text_item -> toXml(e);
return(e);
}
/**
* @brief Conductor::pathFromXml
* Generate the path from xml file
* @param e
* @return true if generate path success else return false
*/
bool Conductor::pathFromXml(const QDomElement &e) {
// parcourt les elements XML "segment" et en extrait deux listes de longueurs
// les segments non valides sont ignores
QList<qreal> segments_x, segments_y;
@@ -997,8 +1037,12 @@ bool Conductor::fromXml(QDomElement &e) {
}
}
// s'il n'y a pas de segments, on renvoie true
if (!segments_x.size()) return(true);
//If there isn't segment we generate automatic path and return true
if (!segments_x.size()) {
generateConductorPath(terminal1 -> dockConductor(), terminal1 -> orientation(), terminal2 -> dockConductor(), terminal2 -> orientation());
return(true);
}
// les longueurs recueillies doivent etre coherentes avec les positions des bornes
qreal width = 0.0, height = 0.0;
foreach (qreal t, segments_x) width += t;
@@ -1020,7 +1064,7 @@ bool Conductor::fromXml(QDomElement &e) {
/* on recree les segments a partir des donnes XML */
// cree la liste de points
QList<QPointF> points_list;
points_list << t1;
points_list << mapFromScene(t1);
for (int i = 0 ; i < segments_x.size() ; ++ i) {
points_list << QPointF(
points_list.last().x() + segments_x.at(i),
@@ -1038,43 +1082,6 @@ bool Conductor::fromXml(QDomElement &e) {
return(true);
}
/**
Exporte les caracteristiques du conducteur sous forme d'une element XML.
@param d Le document XML a utiliser pour creer l'element XML
@param table_adr_id Hash stockant les correspondances entre les ids des
bornes dans le document XML et leur adresse en memoire
@return Un element XML representant le conducteur
*/
QDomElement Conductor::toXml(QDomDocument &d, QHash<Terminal *, int> &table_adr_id) const {
QDomElement e = d.createElement("conductor");
e.setAttribute("terminal1", table_adr_id.value(terminal1));
e.setAttribute("terminal2", table_adr_id.value(terminal2));
// on n'exporte les segments du conducteur que si ceux-ci ont
// ete modifies par l'utilisateur
if (modified_path) {
// parcours et export des segments
QDomElement current_segment;
foreach(ConductorSegment *segment, segmentsList()) {
current_segment = d.createElement("segment");
current_segment.setAttribute("orientation", segment -> isHorizontal() ? "horizontal" : "vertical");
current_segment.setAttribute("length", QString("%1").arg(segment -> length()));
e.appendChild(current_segment);
}
}
// exporte la "configuration" du conducteur
properties_.toXml(e);
if (text_item -> wasRotateByUser()) {
e.setAttribute("rotation", QString("%1").arg(text_item -> rotationAngle()));
}
if (text_item -> wasMovedByUser()) {
e.setAttribute("userx", QString("%1").arg(text_item -> pos().x()));
e.setAttribute("usery", QString("%1").arg(text_item -> pos().y()));
}
return(e);
}
/// @return les segments de ce conducteur
const QList<ConductorSegment *> Conductor::segmentsList() const {
if (segments == NULL) return(QList<ConductorSegment *>());
@@ -1328,9 +1335,12 @@ void Conductor::setText(const QString &t) {
* @param p : properties
*/
void Conductor::setProperties(const ConductorProperties &p) {
if (properties_ != p)
{
properties_ = p;
readProperties();
}
}
/**
* @brief Conductor::properties

View File

@@ -43,7 +43,7 @@ class Conductor : public QObject, public QGraphicsPathItem {
// constructors, destructor
public:
Conductor(Terminal *, Terminal *, Diagram * = 0);
Conductor(Terminal *, Terminal *);
virtual ~Conductor();
private:
@@ -92,9 +92,15 @@ class Conductor : public QObject, public QGraphicsPathItem {
bool containsPoint(const QPointF &) const;
QString text() const;
void setText(const QString &);
public:
static bool valideXml (QDomElement &);
bool fromXml (QDomElement &);
QDomElement toXml (QDomDocument &, QHash<Terminal *, int> &) const;
private:
bool pathFromXml(const QDomElement &);
public:
const QList<ConductorSegment *> segmentsList() const;
void setProperties(const ConductorProperties &);
ConductorProperties properties() const;
@@ -124,6 +130,8 @@ class Conductor : public QObject, public QGraphicsPathItem {
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *);
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
bool bMouseOver;
private:
/// Functional properties
ConductorProperties properties_;

View File

@@ -25,12 +25,14 @@
@param parent_conductor Conducteur auquel ce texte est rattache
@param parent_diagram Schema auquel ce texte et son conducteur parent sont rattaches
*/
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor, Diagram *parent_diagram) :
DiagramTextItem(parent_conductor, parent_diagram),
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
DiagramTextItem(parent_conductor),
parent_conductor_(parent_conductor),
moved_by_user_(false),
rotate_by_user_(false)
{}
{
setAcceptsHoverEvents(true);
}
/**
Constructeur
@@ -38,8 +40,8 @@ ConductorTextItem::ConductorTextItem(Conductor *parent_conductor, Diagram *paren
@param parent_conductor Conducteur auquel ce texte est rattache
@param parent_diagram Schema auquel ce texte et son conducteur parent sont rattaches
*/
ConductorTextItem::ConductorTextItem(const QString &text, Conductor *parent_conductor, Diagram *parent_diagram) :
DiagramTextItem(text, parent_conductor, parent_diagram),
ConductorTextItem::ConductorTextItem(const QString &text, Conductor *parent_conductor) :
DiagramTextItem(text, parent_conductor),
parent_conductor_(parent_conductor),
moved_by_user_(false),
rotate_by_user_(false)
@@ -60,38 +62,36 @@ Conductor *ConductorTextItem::parentConductor() const {
}
/**
Permet de lire le texte a mettre dans le champ a partir d'un element XML.
Cette methode se base sur la position du champ pour assigner ou non la
valeur a ce champ.
@param e L'element XML representant le champ de texte
* @brief ConductorTextItem::fromXml
* Read the properties stored in the xml element given in parameter
* @param e
*/
void ConductorTextItem::fromXml(const QDomElement &e) {
setPlainText(e.attribute("text"));
qreal user_pos_x, user_pos_y;
if (
QET::attributeIsAReal(e, "userx", &user_pos_x) &&
QET::attributeIsAReal(e, "usery", &user_pos_y)
) {
setPos(user_pos_x, user_pos_y);
if (e.hasAttribute("userx")) {
setPos(e.attribute("userx").toDouble(),
e.attribute("usery").toDouble());
moved_by_user_ = true;
}
if (e.hasAttribute("rotation")) {
setRotation(e.attribute("rotation").toDouble());
rotate_by_user_ = true;
}
setRotationAngle(e.attribute("rotation").toDouble());
}
/**
@param document Le document XML a utiliser
@return L'element XML representant ce champ de texte
* @brief ConductorTextItem::toXml
* Export the properties of this text in the attribute of the xml element given in parameter
* The properties exported are position and rotation (only if moved or rotate by user)
* @param xml
*/
QDomElement ConductorTextItem::toXml(QDomDocument &document) const {
QDomElement result = document.createElement("input");
result.setAttribute("userx", QString("%1").arg(pos().x()));
result.setAttribute("usery", QString("%1").arg(pos().y()));
result.setAttribute("text", toPlainText());
if (rotationAngle()) {
result.setAttribute("rotation", QString("%1").arg(rotationAngle()));
void ConductorTextItem::toXml(QDomElement &xml) const {
if (moved_by_user_) {
xml.setAttribute("userx", QString("%1").arg(pos().x()));
xml.setAttribute("usery", QString("%1").arg(pos().y()));
}
if (rotate_by_user_) {
xml.setAttribute("rotation", QString("%1").arg(rotation()));
}
return(result);
}
/**
@@ -203,3 +203,40 @@ void ConductorTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
QGraphicsTextItem::mouseReleaseEvent(e);
}
}
/**
When mouse over element
change bMouseOver to true (used in paint() function )
@param e QGraphicsSceneHoverEvent
*/
void ConductorTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
Q_UNUSED(e);
bMouseOver = true;
QString str_ToolTip = toPlainText();
setToolTip( str_ToolTip );
update();
}
/**
When mouse over element leave the position
change bMouseOver to false(used in paint() function )
@param e QGraphicsSceneHoverEvent
*/
void ConductorTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) {
Q_UNUSED(e);
//qDebug() << "Leave mouse over";
bMouseOver = false;
update();
}
/**
Do nothing default function .
@param e QGraphicsSceneHoverEvent
*/
void ConductorTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
Q_UNUSED(e);
QGraphicsTextItem::hoverMoveEvent(e);
}

View File

@@ -31,8 +31,8 @@ class ConductorTextItem : public DiagramTextItem {
// constructors, destructor
public:
ConductorTextItem(Conductor * = 0, Diagram * = 0);
ConductorTextItem(const QString &, Conductor * = 0, Diagram * = 0);
ConductorTextItem(Conductor * = 0);
ConductorTextItem(const QString &, Conductor * = 0);
virtual ~ConductorTextItem();
private:
ConductorTextItem(const ConductorTextItem &);
@@ -42,7 +42,7 @@ class ConductorTextItem : public DiagramTextItem {
enum { Type = UserType + 1006 };
Conductor *parentConductor() const;
virtual void fromXml(const QDomElement &);
virtual QDomElement toXml(QDomDocument &) const;
virtual void toXml (QDomElement &xml) const;
// methods
public:
@@ -57,6 +57,11 @@ class ConductorTextItem : public DiagramTextItem {
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
protected:
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *);
// attributes
private:
Conductor *parent_conductor_;

View File

@@ -32,14 +32,20 @@
* @brief CrossRefItem::CrossRefItem
* Default constructor
* @param elmt element to display the cross ref and also parent item.
* elmt must be in a diagram
*/
/**
* @brief CrossRefItem::CrossRefItem
* @param elmt
*/
CrossRefItem::CrossRefItem(Element *elmt) :
QGraphicsObject(elmt),
m_element (elmt)
{
Q_ASSERT_X(elmt->diagram(), "CrossRefItem constructor", "Parent element is not in a diagram");
m_properties = elmt->diagram()->defaultXRefProperties(elmt->kindInformations()["type"].toString());
connect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
connect(elmt -> diagram() -> project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
connect(elmt -> diagram() -> project(), SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(updateLabel()));
connect(elmt -> diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateProperties()));
@@ -106,6 +112,13 @@ QString CrossRefItem::elementPositionText(const Element *elmt, const bool &add_p
void CrossRefItem::allElementsPositionText(QString &no_str, QString &nc_str, const bool &add_prefix) const {
QString *tmp_str;
foreach (Element *elmt, m_element->linkedElements()) {
//We continue if element is a power contact and xref propertie
//is set to don't show power contact
if (m_properties.displayHas() == XRefProperties::Cross &&
!m_properties.showPowerContact() &&
elmt -> kindInformations()["type"].toString() == "power")
continue;
QString state = elmt->kindInformations()["state"].toString();
//NO and NC are displayed in single place in the cross
@@ -159,6 +172,7 @@ void CrossRefItem::updateProperties() {
void CrossRefItem::updateLabel() {
//init the shape and bounding rect
m_shape_path = QPainterPath();
prepareGeometryChange();
m_bounding_rect = QRectF();
//init the painter
@@ -183,8 +197,6 @@ void CrossRefItem::updateLabel() {
qp.end();
autoPos();
update();
checkMustShow();
}
/**
@@ -274,18 +286,23 @@ void CrossRefItem::buildHeaderContact() {
* The cross ref item is drawing according to the size of the cross bounding rect.
*/
void CrossRefItem::setUpCrossBoundingRect(QPainter &painter) {
//this is the default size of cross ref item
QRectF default_bounding(0, 0, 40, header + cross_min_heigth);
//No need to calcul if nothing is linked
if (!m_element->isFree()) {
QString no_str, nc_str;
allElementsPositionText(no_str, nc_str, true);
//Adjust the size of default_bounding if needed.
//We calcule the size by using a single text
//because in the method fillCrossRef, the text is draw like this (aka single text)
//There is no string to display, we return now
if (no_str.isEmpty() && nc_str.isEmpty()) return;
//this is the default size of cross ref item
QRectF default_bounding(0, 0, 40, header + cross_min_heigth);
/*
* Adjust the size of default_bounding if needed.
* We calcule the size by using a single text
* because in the method fillCrossRef, the text is draw like this (aka single text)
*/
//Adjust according to the NO
QRectF bounding = painter.boundingRect(QRectF (), Qt::AlignCenter, no_str);
@@ -300,11 +317,12 @@ void CrossRefItem::setUpCrossBoundingRect(QPainter &painter) {
default_bounding.setHeight(bounding.height() + header); //adjust the heigth
if (bounding.width() > default_bounding.width()/2)
default_bounding.setWidth(bounding.width()*2); //adjust the width
}
m_shape_path.addRect(default_bounding);
prepareGeometryChange();
m_bounding_rect = default_bounding;
}
}
/**
* @brief CrossRefItem::drawHasCross
@@ -315,6 +333,9 @@ void CrossRefItem::drawHasCross(QPainter &painter) {
//calcul the size of the cross
setUpCrossBoundingRect(painter);
//Bounding rect is empty that mean there's no contact to draw
if (boundingRect().isEmpty()) return;
//draw the cross
QRectF br = boundingRect();
painter.drawLine(br.width()/2, 0, br.width()/2, br.height()); //vertical line
@@ -337,6 +358,8 @@ void CrossRefItem::drawHasCross(QPainter &painter) {
* @param painter painter to use
*/
void CrossRefItem::drawHasContacts(QPainter &painter) {
if (m_element -> isFree()) return;
m_drawed_contacts = 0;
//Draw each linked contact
@@ -361,6 +384,7 @@ void CrossRefItem::drawHasContacts(QPainter &painter) {
}
QRectF br(0, 0, 50, m_drawed_contacts*10+4);
prepareGeometryChange();
m_bounding_rect = br;
m_shape_path.addRect(br);
}
@@ -492,8 +516,6 @@ void CrossRefItem::fillCrossRef(QPainter &painter) {
rect_.moveTopLeft(QPointF (middle_cross, header));
painter.drawText(rect_, Qt::AlignTop | Qt::AlignRight, nc_str);
}
/**
@@ -504,62 +526,27 @@ void CrossRefItem::fillCrossRef(QPainter &painter) {
void CrossRefItem::AddExtraInfo(QPainter &painter) {
QString comment = m_element -> elementInformations()["comment"].toString();
bool must_show = m_element -> elementInformations().keyMustShow("comment");
if (!comment.isEmpty() && must_show) {
painter.save();
painter.setFont(QETApp::diagramTextsFont(6));
QRectF r, text_bounding;
qreal center = boundingRect().center().x();
r = QRectF(QPointF(center - 50, boundingRect().bottom()),
QPointF(center + 50, boundingRect().bottom() + 50));
r = QRectF(QPointF(center - 35, boundingRect().bottom()),
QPointF(center + 35, boundingRect().bottom() + 50));
painter.drawText(r, Qt::TextWordWrap | Qt::AlignHCenter, comment, &text_bounding);
text_bounding.adjust(-1,0,1,0); //adjust only for better visual
m_shape_path.addRect(text_bounding);
prepareGeometryChange();
m_bounding_rect = m_bounding_rect.united(text_bounding);
painter.drawRoundedRect(text_bounding, 2, 2);
painter.restore();
}
}
/**
* @brief CrossRefItem::checkMustShow
* Check the propertie of this Xref for know if we
* must to be show or not
*/
void CrossRefItem::checkMustShow() {
//We always show Xref when is displayed has contact
if (m_properties.displayHas() == XRefProperties::Contacts) {
this->show();
return;
}
//if Xref is display has cross and we must to don't show power contact, check it
else if (m_properties.displayHas() == XRefProperties::Cross && !m_properties.showPowerContact()) {
bool power = false;
foreach (Element *elmt, m_element->linkedElements()) {
// contact checked isn't power, show this xref and return;
if (elmt->kindInformations()["type"].toString() != "power") {
this->show();
return;
} else {
power = true;
}
}
if (power) {
this->hide();
return;
}
}
//By default, show this Xref
else {
this->show();
return;
}
}
/**
* @brief CrossRefItem::setTextParent
* Set the text field tagged "label" of m_element
@@ -568,6 +555,6 @@ void CrossRefItem::checkMustShow() {
void CrossRefItem::setTextParent() {
ElementTextItem *eti = m_element->taggedText("label");
if (eti) setParentItem(eti);
else qDebug() << "CrossRefItem,no texte tagged 'label' found to set has parent";
else qDebug() << "CrossRefItem,no text tagged 'label' found to set has parent";
}

View File

@@ -82,7 +82,6 @@ class CrossRefItem : public QGraphicsObject
void drawContact (QPainter &painter, int flags, QString str = QString());
void fillCrossRef (QPainter &painter);
void AddExtraInfo (QPainter &painter);
void checkMustShow ();
void setTextParent ();
//Attributes

View File

@@ -44,8 +44,8 @@
- 7 : L'analyse d'un element XML decrivant une partie du dessin de l'element a echoue
- 8 : Aucune partie du dessin n'a pu etre chargee
*/
CustomElement::CustomElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
FixedElement(qgi, s),
CustomElement::CustomElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) :
FixedElement(qgi),
elmt_state(-1),
location_(location),
forbid_antialiasing(false)
@@ -137,13 +137,12 @@ bool CustomElement::buildFromXml(const QDomElement &xml_def_elmt, int *state) {
return(false);
}
// on peut d'ores et deja specifier la taille et le hotspot
setSize(w, h);
setHotspot(QPoint(hot_x, hot_y));
setInternalConnections(xml_def_elmt.attribute("ic") == "true");
// la definition est supposee avoir des enfants
if (xml_def_elmt.firstChild().isNull()) {
//the definition must have childs
if (xml_def_elmt.firstChild().isNull())
{
if (state) *state = 6;
return(false);
}
@@ -759,7 +758,7 @@ Terminal *CustomElement::parseTerminal(QDomElement &e) {
else if (e.attribute("orientation") == "e") terminalo = Qet::East;
else if (e.attribute("orientation") == "w") terminalo = Qet::West;
else return(0);
Terminal *new_terminal = new Terminal(terminalx, terminaly, terminalo, this, qobject_cast<Diagram *>(scene()));
Terminal *new_terminal = new Terminal(terminalx, terminaly, terminalo, this);
new_terminal -> setZValue(420); // valeur arbitraire pour maintenir les bornes au-dessus des champs de texte
list_terminals << new_terminal;
return(new_terminal);

View File

@@ -36,7 +36,7 @@ class CustomElement : public FixedElement {
// constructors, destructor
public:
CustomElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
CustomElement(const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
virtual ~CustomElement();
private:

View File

@@ -211,6 +211,7 @@ bool DiagramImageItem::fromXml(const QDomElement &e) {
setScale(e.attribute("size").toDouble());
applyRotation(e.attribute("rotation").toDouble());
setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
is_movable_ = (e.attribute("is_movable").toInt());
return (true);
}
@@ -226,6 +227,7 @@ QDomElement DiagramImageItem::toXml(QDomDocument &document) const {
result.setAttribute("y", QString("%1").arg(pos().y()));
result.setAttribute("rotation", QString("%1").arg(rotation()));
result.setAttribute("size", QString("%1").arg(scale()));
result.setAttribute("is_movable", bool(is_movable_));
//write the pixmap in the xml element after he was been transformed to base64
QByteArray array;

View File

@@ -26,12 +26,14 @@
@param parent Le QGraphicsItem parent du champ de texte
@param parent_diagram Le schema auquel appartient le champ de texte
*/
DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, Diagram *parent_diagram) :
QGraphicsTextItem(parent, parent_diagram),
DiagramTextItem::DiagramTextItem(QGraphicsItem *parent) :
QGraphicsTextItem(parent),
bMouseOver(false),
previous_text_(),
rotation_angle_(0.0),
m_first_move (true)
{
setAcceptsHoverEvents(true);
build();
}
@@ -41,12 +43,14 @@ DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, Diagram *parent_diagram)
@param parent Le QGraphicsItem parent du champ de texte
@param parent_diagram Le schema auquel appartient le champ de texte
*/
DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent, Diagram *parent_diagram) :
QGraphicsTextItem(text, parent, parent_diagram),
DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent) :
QGraphicsTextItem(text, parent),
bMouseOver(false),
previous_text_(text),
rotation_angle_(0.0)
{
build();
setAcceptsHoverEvents(true);
}
/// Destructeur
@@ -79,6 +83,16 @@ Diagram *DiagramTextItem::diagram() const {
return(qobject_cast<Diagram *>(scene()));
}
/**
* @brief DiagramTextItem::toXml
* This method do nothing and return an empty DomElement
* This is used to be inherited by child class
* @return
*/
QDomElement DiagramTextItem::toXml(QDomDocument &) const {
return QDomElement();
}
/**
@return l'angle de rotation actuel de ce texte
*/
@@ -201,6 +215,24 @@ void DiagramTextItem::setFontSize(int &s) {
void DiagramTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
painter -> setRenderHint(QPainter::Antialiasing, false);
QGraphicsTextItem::paint(painter, option, widget);
if ( bMouseOver ) {
painter -> save();
// Annulation des renderhints
painter -> setRenderHint(QPainter::Antialiasing, false);
painter -> setRenderHint(QPainter::TextAntialiasing, false);
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
// Dessin du cadre de selection en gris
QPen t;
t.setColor(Qt::gray);
t.setStyle(Qt::DashDotLine);
painter -> setPen(t);
// Le dessin se fait a partir du rectangle delimitant
//painter -> drawRoundRect(boundingRect().adjusted(1, 1, -1, -1), 10, 10);
painter -> drawRoundRect(boundingRect().adjusted(0, 0, 0, 0), 10, 10);
painter -> restore();
}
}
/**
@@ -356,3 +388,39 @@ void DiagramTextItem::edit() {
editor->show();
}
/**
When mouse over element
change bMouseOver to true (used in paint() function )
@param e QGraphicsSceneHoverEvent
*/
void DiagramTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
Q_UNUSED(e);
bMouseOver = true;
QString str_ToolTip = toPlainText();
setToolTip( str_ToolTip );
update();
}
/**
When mouse over element leave the position
change bMouseOver to false (used in paint() function )
@param e QGraphicsSceneHoverEvent
*/
void DiagramTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) {
Q_UNUSED(e);
//qDebug() << "Leave mouse over";
bMouseOver = false;
update();
}
/**
Do nothing default function .
@param e QGraphicsSceneHoverEvent
*/
void DiagramTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
Q_UNUSED(e);
QGraphicsTextItem::hoverMoveEvent(e);
}

View File

@@ -33,8 +33,8 @@ class DiagramTextItem : public QGraphicsTextItem {
Q_OBJECT
// constructors, destructor
public:
DiagramTextItem(QGraphicsItem * = 0, Diagram * = 0);
DiagramTextItem(const QString &, QGraphicsItem * = 0, Diagram * = 0);
DiagramTextItem(QGraphicsItem * = 0);
DiagramTextItem(const QString &, QGraphicsItem * = 0);
virtual ~DiagramTextItem();
private:
@@ -54,7 +54,7 @@ class DiagramTextItem : public QGraphicsTextItem {
virtual int type() const { return Type; }
Diagram *diagram() const;
virtual void fromXml(const QDomElement &) = 0;
virtual QDomElement toXml(QDomDocument &) const = 0;
virtual QDomElement toXml(QDomDocument &) const;
qreal rotationAngle() const;
void setRotationAngle(const qreal &);
void rotateBy(const qreal &);
@@ -76,8 +76,13 @@ class DiagramTextItem : public QGraphicsTextItem {
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *);
virtual void applyRotation(const qreal &);
bool bMouseOver;
signals:
/// signal emitted when the text field loses focus
void lostFocus();

View File

@@ -30,18 +30,16 @@
/**
Constructeur pour un element sans scene ni parent
*/
Element::Element(QGraphicsItem *parent, Diagram *scene) :
Element::Element(QGraphicsItem *parent) :
QetGraphicsItem(parent),
internal_connections_(false),
must_highlight_(false)
must_highlight_(false),
m_mouse_over(false)
{
Q_UNUSED(scene);
link_type_ = Simple;
uuid_ = QUuid::createUuid();
setZValue(10);
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
setAcceptsHoverEvents(true);
}
/**
@@ -101,11 +99,11 @@ void Element::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
#endif
if (must_highlight_) drawHighlight(painter, options);
// Dessin de l'element lui-meme
//Draw the element himself
paint(painter, options);
// Dessin du cadre de selection si necessaire
if (isSelected()) drawSelection(painter, options);
//Draw the selection rectangle
if ( isSelected() || m_mouse_over ) drawSelection(painter, options);
}
/**
@@ -515,8 +513,9 @@ void Element::initLink(QETProject *prj) {
* @param dc
*/
void Element::setElementInformations(DiagramContext dc) {
DiagramContext old_info = element_informations_;
element_informations_ = dc;
emit elementInfoChange(element_informations_);
emit elementInfoChange(old_info, element_informations_);
}
/**
@@ -540,3 +539,37 @@ bool comparPos(const Element *elmt1, const Element *elmt2) {
return elmt1->y() <= elmt2->pos().y();
return elmt1->pos().x() <= elmt2->pos().x();
}
/**
* When mouse over element
* change m_mouse_over to true (used in paint() function )
* Also highlight linked elements
* @param e QGraphicsSceneHoverEvent
*/
void Element::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
Q_UNUSED(e);
foreach (Element *elmt, linkedElements())
elmt -> setHighlighted(true);
m_mouse_over = true;
setToolTip( name() );
update();
}
/**
* When mouse over element leave the position
* change m_mouse_over to false(used in paint() function )
* Also un-highlight linked elements
* @param e QGraphicsSceneHoverEvent
*/
void Element::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) {
Q_UNUSED(e);
foreach (Element *elmt, linkedElements())
elmt -> setHighlighted(false);
m_mouse_over = false;
update();
}

View File

@@ -22,7 +22,6 @@
#include "qetgraphicsitem.h"
#include "diagramcontext.h"
class Diagram;
class ElementTextItem;
class QETProject;
class Terminal;
@@ -32,12 +31,11 @@ class Conductor;
This is the base class for electrical elements.
*/
class Element : public QetGraphicsItem {
Q_OBJECT
// constructors, destructor
public:
Element(QGraphicsItem * = 0, Diagram * = 0);
Element(QGraphicsItem * = 0);
virtual ~Element();
private:
Element(const Element &);
@@ -121,7 +119,7 @@ class Element : public QetGraphicsItem {
kind link_type_;
signals:
void elementInfoChange(DiagramContext);
void elementInfoChange(DiagramContext old_info, DiagramContext new_info);
//METHODS related to information
public:
@@ -162,9 +160,6 @@ class Element : public QetGraphicsItem {
void select();
void deselect();
// methods related to internal connections
bool internalConnections();
void setInternalConnections(bool);
virtual void rotateBy(const qreal &);
virtual void editProperty();
@@ -181,11 +176,17 @@ class Element : public QetGraphicsItem {
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
private:
bool internal_connections_;
bool must_highlight_;
void drawSelection(QPainter *, const QStyleOptionGraphicsItem *);
void drawHighlight(QPainter *, const QStyleOptionGraphicsItem *);
void updatePixmap();
protected:
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * );
private:
bool m_mouse_over;
};
bool comparPos(const Element * elmt1, const Element * elmt2);
@@ -194,24 +195,6 @@ inline bool Element::isFree() const {
return (connected_elements.isEmpty());
}
/**
Indicate whether this element allows internal connections, i.e. whether its
terminals can be linked together using a conductor.
@return true if internal connections are accepted, false otherwise
*/
inline bool Element::internalConnections() {
return(internal_connections_);
}
/**
Specify whether this element allows internal connections, i.e. whether its
terminals can be linked together using a conductor.
@return true for internal connections to be accepted, false otherwise
*/
inline void Element::setInternalConnections(bool ic) {
internal_connections_ = ic;
}
/**
Indicate the current orientation of this element
O = 0°

View File

@@ -26,8 +26,8 @@
@param parent_element Le QGraphicsItem parent du champ de texte
@param parent_diagram Le schema auquel appartient le champ de texte
*/
ElementTextItem::ElementTextItem(Element *parent_element, Diagram *parent_diagram) :
DiagramTextItem(parent_element, parent_diagram),
ElementTextItem::ElementTextItem(Element *parent_element) :
DiagramTextItem(parent_element),
parent_element_(parent_element),
follow_parent_rotations(false),
original_rotation_angle_(0.0)
@@ -39,8 +39,8 @@ ElementTextItem::ElementTextItem(Element *parent_element, Diagram *parent_diagra
@param parent_diagram Le schema auquel appartient le champ de texte
@param text Le texte affiche par le champ de texte
*/
ElementTextItem::ElementTextItem(const QString &text, Element *parent_element, Diagram *parent_diagram) :
DiagramTextItem(text, parent_element, parent_diagram),
ElementTextItem::ElementTextItem(const QString &text, Element *parent_element) :
DiagramTextItem(text, parent_element),
parent_element_(parent_element),
follow_parent_rotations(false),
original_rotation_angle_(0.0)
@@ -174,23 +174,63 @@ void ElementTextItem::adjustItemPosition(int new_block_count) {
}
/**
Effetue la rotation du texte en elle-meme
Pour les ElementTextItem, la rotation s'effectue autour du milieu du bord
gauche du champ de texte.
@param angle Angle de la rotation a effectuer
* @brief ElementTextItem::mouseDoubleClickEvent
* @param event
*/
void ElementTextItem::applyRotation(const qreal &angle) {
QGraphicsTextItem::setRotation(QGraphicsTextItem::rotation() + angle);
void ElementTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
/*
* Before revision 3559, report element haven't got text tagged label
* so if parent is a report and haven't got text tagged label,
* we know if this text is used has tagged label.
*/
bool report_text = false;
if (parent_element_ -> linkType() & Element::AllReport && !parent_element_ -> taggedText("label"))
{
//This is the first of list, so this text is used to display
//pos of linked report.
if (parent_element_ -> texts().first() == this)
report_text = true;
}
if ( (tagg_ == "label" || report_text) && !parent_element_ -> isFree())
{
//If parent is linked, show the linked element
if ( parent_element_ -> linkType() & (Element::AllReport | Element::Slave) )
{
//Unselect and ungrab mouse to prevent unwanted
//move when linked element is in the same scene of this.
setSelected(false);
ungrabMouse();
//Show and select the linked element
Element *linked = parent_element_ -> linkedElements().first();
if (scene() != linked -> scene())
linked -> diagram() -> showMe();
linked -> setSelected(true);
//Zoom to the linked element
foreach(QGraphicsView *view, linked -> diagram() -> views()) {
QRectF fit = linked -> sceneBoundingRect();
fit.adjust(-200, -200, 200, 200);
view -> fitInView(fit, Qt::KeepAspectRatioByExpanding);
}
}
}
else
{
DiagramTextItem::mouseDoubleClickEvent(event);
}
}
/**
* @brief ElementTextItem::mouseMoveEvent
* @param e
*/
void ElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
void ElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
if (textInteractionFlags() & Qt::TextEditable) {
DiagramTextItem::mouseMoveEvent(e);
} else if ((flags() & QGraphicsItem::ItemIsMovable) && (e -> buttons() & Qt::LeftButton)) {
DiagramTextItem::mouseMoveEvent(event);
} else if ((flags() & QGraphicsItem::ItemIsMovable) && (event -> buttons() & Qt::LeftButton)) {
QPointF old_pos = pos();
/*
@@ -199,7 +239,7 @@ void ElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
* Instead of this, we apply to the actual pos,
* the vector defined by the movement of cursor since the last pos clicked by left button
*/
QPointF movement = e -> pos() - e -> buttonDownPos(Qt::LeftButton);
QPointF movement = event -> pos() - event -> buttonDownPos(Qt::LeftButton);
/*
* the method pos() and setPos() always work with coordinate of parent item
@@ -207,7 +247,7 @@ void ElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
* before applyRotation
*/
QPointF new_pos = pos() + mapMovementToParent(movement);
e -> modifiers() == Qt::ControlModifier ? setPos(new_pos) : setPos(Diagram::snapToGrid(new_pos));
event -> modifiers() == Qt::ControlModifier ? setPos(new_pos) : setPos(Diagram::snapToGrid(new_pos));
Diagram *diagram_ptr = diagram();
if (diagram_ptr) {
@@ -233,7 +273,7 @@ void ElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
// on applique le mouvement subi aux autres textes a deplacer
diagram_ptr -> continueMoveElementTexts(scene_effective_movement);
}
} else e -> ignore();
} else event -> ignore();
if (m_first_move) {
m_first_move = false;
@@ -244,7 +284,7 @@ void ElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
* @brief ElementTextItem::mouseReleaseEvent
* @param e
*/
void ElementTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
void ElementTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
if (Diagram *diagram_ptr = diagram()) {
if (parent_element_) {
if (parent_element_ -> isHighlighted()) {
@@ -254,7 +294,79 @@ void ElementTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
diagram_ptr -> endMoveElementTexts();
}
if (!(e -> modifiers() & Qt::ControlModifier)) {
QGraphicsTextItem::mouseReleaseEvent(e);
if (!(event -> modifiers() & Qt::ControlModifier)) {
QGraphicsTextItem::mouseReleaseEvent(event);
}
}
/**
* @brief ElementTextItem::hoverEnterEvent
* @param event
*/
void ElementTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
/*
* Before revision 3559, report element haven't got text tagged label
* so if parent is a report and haven't got text tagged label,
* we know if this text is used has tagged label.
*/
bool report_text = false;
if (parent_element_ -> linkType() & Element::AllReport && !parent_element_ -> taggedText("label"))
{
//This is the first of list, so this text is used to display
//pos of linked report.
if (parent_element_ -> texts().first() == this)
report_text = true;
}
if (tagg_ == "label" || report_text)
{
if (parent_element_ -> linkType() & (Element::AllReport | Element::Slave) && !parent_element_->isFree()) {
setDefaultTextColor(Qt::blue);
//Also color the child text if parent is a slave and linked
if (parent_element_-> linkType() == Element::Slave && !parent_element_ -> isFree())
foreach (QGraphicsItem *qgi, childItems())
if (QGraphicsTextItem *qgti = qgraphicsitem_cast<QGraphicsTextItem *> (qgi))
qgti -> setDefaultTextColor(Qt::blue);
}
}
DiagramTextItem::hoverEnterEvent(event);
}
/**
* @brief ElementTextItem::hoverLeaveEvent
* @param event
*/
void ElementTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
/*
* Before revision 3559, report element haven't got text tagged label
* so if parent is a report and haven't got text tagged label,
* we know if this text is used has tagged label.
*/
bool report_text = false;
if (parent_element_ -> linkType() & Element::AllReport && !parent_element_ -> taggedText("label"))
{
//This is the first of list, so this text is used to display
//pos of linked report.
if (parent_element_ -> texts().first() == this)
report_text = true;
}
if (tagg_ == "label" || report_text)
{
if (defaultTextColor() != Qt::black)
setDefaultTextColor(Qt::black);
//Also color the child text if parent is a slave and linked
if (parent_element_-> linkType() == Element::Slave && !parent_element_ -> isFree())
foreach (QGraphicsItem *qgi, childItems())
if (QGraphicsTextItem *qgti = qgraphicsitem_cast<QGraphicsTextItem *> (qgi))
qgti -> setDefaultTextColor(Qt::black);
}
DiagramTextItem::hoverLeaveEvent(event);
}

View File

@@ -20,7 +20,6 @@
#include "diagramtextitem.h"
class Diagram;
class Element;
/**
@@ -32,13 +31,14 @@ class ElementTextItem : public DiagramTextItem {
Q_OBJECT
// constructors, destructor
public:
ElementTextItem(Element * = 0, Diagram * = 0);
ElementTextItem(const QString &, Element * = 0, Diagram * = 0);
ElementTextItem(Element * = 0);
ElementTextItem(const QString &, Element * = 0);
virtual ~ElementTextItem();
// attributes
public:
enum { Type = UserType + 1003 };
virtual int type () const { return Type; }
private:
Element *parent_element_;
@@ -49,12 +49,7 @@ class ElementTextItem : public DiagramTextItem {
// methods
public:
virtual int type() const { return Type; }
Element *parentElement () const;
/// @return the rectangle defining the bounds of this text item
virtual QRectF boundingRect() const { return(QGraphicsTextItem::boundingRect().adjusted(0.0, -1.1, 0.0, 0.0)); }
bool followParentRotations() const;
void setFollowParentRotations(bool);
void fromXml ( const QDomElement & );
QDomElement toXml ( QDomDocument & ) const;
void setOriginalPos ( const QPointF & );
@@ -64,15 +59,18 @@ class ElementTextItem : public DiagramTextItem {
virtual void setFont ( const QFont & );
void setTagg ( const QString &str ) {tagg_ = str;}
QString tagg () const {return tagg_;}
void setFollowParentRotations ( bool fpr);
bool followParentRotations () const;
public slots:
void adjustItemPosition(int = 0);
protected:
virtual void applyRotation(const qreal &);
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *e);
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *e);
virtual void mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *event );
virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent *event );
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent *event );
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent *event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent *event );
private:
void build ();

View File

@@ -19,7 +19,7 @@
/**
Constructeur
*/
FixedElement::FixedElement(QGraphicsItem *parent, Diagram *scene) : Element(parent, scene) {
FixedElement::FixedElement(QGraphicsItem *parent) : Element(parent) {
}
/**

View File

@@ -17,7 +17,9 @@
*/
#ifndef ELEMENTFIXE_H
#define ELEMENTFIXE_H
#include "element.h"
/**
This class represents an element having a fixed number of terminals.
*/
@@ -27,7 +29,7 @@ class FixedElement : public Element {
// constructors, destructor
public:
FixedElement(QGraphicsItem * = 0, Diagram * = 0);
FixedElement(QGraphicsItem * = 0);
virtual ~FixedElement();
// methods

View File

@@ -29,10 +29,9 @@
*/
GhostElement::GhostElement(
const ElementsLocation &location,
QGraphicsItem *qgi,
Diagram *d
QGraphicsItem *qgi
) :
CustomElement(location, qgi, d)
CustomElement(location, qgi)
{
QString tooltip_string = QString(
tr("<u>\311l\351ment manquant\240:</u> %1")
@@ -74,7 +73,6 @@ bool GhostElement::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr,
QRect final_bounding_rect = minimalBoundingRect().united(childrenBoundingRect()).toAlignedRect();
setSize(final_bounding_rect.width(), final_bounding_rect.height());
setHotspot(QPoint() - final_bounding_rect.topLeft());
setInternalConnections(true);
// on peut desormais confectionner le rendu de l'element
generateDrawings();

View File

@@ -18,7 +18,6 @@
#ifndef GHOST_ELEMENT_H
#define GHOST_ELEMENT_H
#include "customelement.h"
class Diagram;
class QGraphicsItem;
class ElementsLocation;
class Terminal;
@@ -37,7 +36,7 @@ class GhostElement : public CustomElement {
// constructor, destructor
public:
GhostElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0);
GhostElement(const ElementsLocation &, QGraphicsItem * = 0);
virtual ~GhostElement();
// methods

View File

@@ -22,8 +22,8 @@
Constructeur
@param parent_diagram Le schema auquel est rattache le champ de texte
*/
IndependentTextItem::IndependentTextItem(Diagram *parent_diagram) :
DiagramTextItem(0, parent_diagram)
IndependentTextItem::IndependentTextItem() :
DiagramTextItem(0)
{}
/**
@@ -31,8 +31,8 @@ IndependentTextItem::IndependentTextItem(Diagram *parent_diagram) :
@param text Le texte affiche par le champ de texte
@param parent_diagram Le schema auquel est rattache le champ de texte
*/
IndependentTextItem::IndependentTextItem(const QString &text, Diagram *parent_diagram) :
DiagramTextItem(text, 0, parent_diagram)
IndependentTextItem::IndependentTextItem(const QString &text) :
DiagramTextItem(text, 0)
{}
/// Destructeur

View File

@@ -28,8 +28,8 @@ class IndependentTextItem : public DiagramTextItem {
Q_OBJECT
// constructors, destructor
public:
IndependentTextItem(Diagram * = 0);
IndependentTextItem(const QString &, Diagram* = 0);
IndependentTextItem();
IndependentTextItem(const QString &);
virtual ~IndependentTextItem();
// attributes

View File

@@ -17,6 +17,7 @@
*/
#include "masterelement.h"
#include "crossrefitem.h"
#include "elementtextitem.h"
/**
* @brief MasterElement::MasterElement
@@ -26,12 +27,12 @@
* @param s parent diagram
* @param state int used to know if the creation of element have error
*/
MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
CustomElement(location, qgi, s, state),
MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) :
CustomElement(location, qgi, state),
cri_ (nullptr)
{
link_type_ = Master;
connect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext)));
}
/**
@@ -80,30 +81,34 @@ void MasterElement::unlinkAllElements() {
* Unlink the given elmt in parametre
* @param elmt element to unlink from this
*/
void MasterElement::unlinkElement(Element *elmt) {
void MasterElement::unlinkElement(Element *elmt)
{
//Ensure elmt is linked to this element
if (connected_elements.contains(elmt)) {
if (connected_elements.contains(elmt))
{
connected_elements.removeOne(elmt);
elmt -> unlinkElement (this);
elmt -> setHighlighted (false);
//update the graphics cross ref
disconnect(elmt, SIGNAL(xChanged()), cri_, SLOT(updateLabel()));
disconnect(elmt, SIGNAL(yChanged()), cri_, SLOT(updateLabel()));
if (aboutDeleteXref()) return;
cri_ -> updateLabel();
aboutDeleteXref();
}
}
/**
* @brief MasterElement::initLink
* Initialise the links between this element and other element.
* @param project
* Call init Link from custom element and after
* call update label for setup it.
*/
void MasterElement::initLink(QETProject *project) {
//Create the link with other element if needed
CustomElement::initLink(project);
updateLabel();
updateLabel(DiagramContext(), elementInformations());
}
/**
@@ -111,16 +116,22 @@ void MasterElement::initLink(QETProject *project) {
* update label of this element
* and the comment item if he's displayed.
*/
void MasterElement::updateLabel() {
QString label = elementInformations()["label"].toString();
bool show = elementInformations().keyMustShow("label");
// setup the label
if (!label.isEmpty() && show) setTaggedText("label", label, true);
void MasterElement::updateLabel(DiagramContext old_info, DiagramContext new_info) {
//Label of element
if (old_info["label"].toString() != new_info["label"].toString()) {
if (new_info["label"].toString().isEmpty())
setTaggedText("label", "_", false);
else
setTaggedText("label", new_info["label"].toString(), true);
}
if (ElementTextItem *eti = taggedText("label")) {
new_info["label"].toString().isEmpty() ? eti->setVisible(true) : eti -> setVisible(new_info.keyMustShow("label"));
}
//Delete or update the xref
if (cri_) {
cri_ -> updateLabel();
aboutDeleteXref();
}
else {
@@ -143,11 +154,7 @@ void MasterElement::updateLabel() {
bool MasterElement::aboutDeleteXref() {
if(!cri_) return true;
QString comment = elementInformations()["comment"].toString();
bool must_show = elementInformations().keyMustShow("comment");
//Delete Xref item if there isn't reason to display it
if (linkedElements().isEmpty() && (comment.isEmpty() || !must_show)) {
if (cri_ -> boundingRect().isNull()) {
delete cri_;
cri_ = nullptr;
return true;

View File

@@ -33,7 +33,7 @@ class MasterElement : public CustomElement
Q_OBJECT
public:
explicit MasterElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
explicit MasterElement(const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
~MasterElement();
virtual void linkToElement (Element *elmt);
@@ -44,7 +44,7 @@ class MasterElement : public CustomElement
signals:
public slots:
void updateLabel();
void updateLabel(DiagramContext old_info, DiagramContext new_info);
private:
bool aboutDeleteXref ();

View File

@@ -35,16 +35,17 @@ QetShapeItem::QetShapeItem(QPointF p1, QPointF p2, ShapeType type, QGraphicsItem
m_shapeType(type),
m_shapeStyle(Qt::DashLine),
m_P1 (Diagram::snapToGrid(p1)),
m_P2 (Diagram::snapToGrid(p2))
m_P2 (Diagram::snapToGrid(p2)),
m_hovered(false)
{
if (type == Polyline) m_polygon << m_P1 << m_P2;
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
setAcceptHoverEvents(true);
}
QetShapeItem::~QetShapeItem()
{
}
{}
/**
* @brief QetShapeItem::setStyle
@@ -108,11 +109,7 @@ void QetShapeItem::setNextPoint(QPointF P) {
* @return the bounding rect of this item
*/
QRectF QetShapeItem::boundingRect() const {
if (m_shapeType == Polyline)
return ( shape().boundingRect());
QRectF b(m_P1, m_P2);
return b.normalized();
return shape().boundingRect();
}
/**
@@ -121,20 +118,17 @@ QRectF QetShapeItem::boundingRect() const {
*/
QPainterPath QetShapeItem::shape() const {
QPainterPath path;
QPainterPathStroker pps;
switch (m_shapeType) {
case Line:
path.moveTo(m_P1);
path.lineTo(m_P2);
pps.setWidth(10);
path = pps.createStroke(path);
break;
case Rectangle:
path.addRect(boundingRect());
path.addRect(QRectF(m_P1, m_P2));
break;
case Ellipse:
path.addEllipse(boundingRect());
path.addEllipse(QRectF(m_P1, m_P2));
break;
case Polyline:
path.addPolygon(m_polygon);
@@ -144,7 +138,11 @@ QPainterPath QetShapeItem::shape() const {
break;
}
return path;
QPainterPathStroker pps;
pps.setWidth(10);
pps.setJoinStyle(Qt::RoundJoin);
return (pps.createStroke(path));
}
/**
@@ -170,24 +168,35 @@ void QetShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
{
Q_UNUSED(option); Q_UNUSED(widget);
QPen pen;
pen.setStyle(m_shapeStyle);
if (isSelected()) pen.setColor(Qt::red);
QPen pen(m_shapeStyle);
painter -> setRenderHint(QPainter::Antialiasing, false);
pen.setWidthF(1);
if (m_hovered) {
painter->save();
QColor color(Qt::darkBlue);
color.setAlpha(25);
painter -> setBrush (QBrush (color));
painter -> setPen (Qt::NoPen);
painter -> drawPath (shape());
painter -> restore ();
}
else if (isSelected()) {
pen.setColor(Qt::red);
}
painter -> setPen(pen);
switch (m_shapeType) {
case Line:
painter->drawLine(QLineF(m_P1, m_P2));
break;
case Rectangle:
painter->drawRect(boundingRect());
painter->drawRect(QRectF(m_P1, m_P2));
break;
case Ellipse:
painter->drawEllipse(boundingRect());
painter->drawEllipse(QRectF(m_P1, m_P2));
break;
case Polyline:
painter->drawPolyline(m_polygon);
@@ -195,6 +204,30 @@ void QetShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
}
}
/**
* @brief QetShapeItem::hoverEnterEvent
* Handle hover enter event
* @param event
*/
void QetShapeItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) {
Q_UNUSED(event);
m_hovered = true;
update();
}
/**
* @brief QetShapeItem::hoverLeaveEvent
* Handle hover leave event
* @param event
*/
void QetShapeItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
Q_UNUSED(event);
m_hovered = false;
update();
}
/**
* @brief QetShapeItem::fromXml
* Build this item from the xml description
@@ -204,6 +237,7 @@ void QetShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
bool QetShapeItem::fromXml(const QDomElement &e) {
if (e.tagName() != "shape") return (false);
is_movable_ = (e.attribute("is_movable").toInt());
m_shapeStyle = Qt::PenStyle(e.attribute("style","0").toInt());
if (e.attribute("type", "0").toInt() != Polyline) {
@@ -235,6 +269,7 @@ QDomElement QetShapeItem::toXml(QDomDocument &document) const {
//write some attribute
result.setAttribute("type", QString::number(m_shapeType));
result.setAttribute("style", QString::number(m_shapeStyle));
result.setAttribute("is_movable", bool(is_movable_));
if (m_shapeType != Polyline) {
result.setAttribute("x1", mapToScene(m_P1).x());

View File

@@ -68,6 +68,8 @@ class QetShapeItem : public QetGraphicsItem
protected:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *event);
private:
void changeGraphicsItem (const ShapeType &newtype);
@@ -81,5 +83,6 @@ class QetShapeItem : public QetGraphicsItem
Qt::PenStyle m_shapeStyle;
QPointF m_P1, m_P2;
QPolygonF m_polygon;
bool m_hovered;
};
#endif // QETSHAPEITEM_H

View File

@@ -21,17 +21,24 @@
#include "qetproject.h"
#include "diagram.h"
ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, Diagram *s, int *state) :
CustomElement(location, qgi, s, state)
ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, int *state) :
CustomElement(location, qgi, state),
m_text_field (nullptr)
{
if (!texts().isEmpty())
texts().first()->setNoEditable();
/*
* Get text tagged label. This is work for report
* create after the revision 3559.
* for report create before, we take the first text field
* because report haven't got a text field tagged label
*/
m_text_field = taggedText("label");
if (!m_text_field && !texts().isEmpty())
m_text_field = texts().first();
if (m_text_field)
m_text_field -> setNoEditable();
link_type == "next_report"? link_type_=NextReport : link_type_=PreviousReport;
link_type == "next_report"? inverse_report=PreviousReport : inverse_report=NextReport;
if (s) {
label_ = s->defaultReportProperties();
connect(s, SIGNAL(reportPropertiesChanged(QString)), this, SLOT(setLabel(QString)));
}
}
ReportElement::~ReportElement() {
@@ -44,21 +51,35 @@ ReportElement::~ReportElement() {
* @param elmt
* element to be linked with this
*/
void ReportElement::linkToElement(Element * elmt) {
void ReportElement::linkToElement(Element * elmt)
{
if (!diagram() && !elmt -> diagram())
{
qDebug() << "ReportElement : linkToElement : Unable to link this or element to link isn't in a diagram";
return;
}
//ensure elmt isn't already linked
bool i = true;
if (!this->isFree()){
if (!this -> isFree())
{
if (connected_elements.first() == elmt) i = false;
}
//ensure elmt is an inverse report of this element
if ((elmt->linkType() == inverse_report) && i) {
if ((elmt->linkType() == inverse_report) && i)
{
unlinkAllElements();
connected_elements << elmt;
connect(elmt, SIGNAL( xChanged() ), this, SLOT( updateLabel() ));
connect(elmt, SIGNAL( yChanged() ), this, SLOT( updateLabel() ));
connect(diagram(), SIGNAL( reportPropertiesChanged(QString) ), this, SLOT( setLabel(QString) ));
connect(diagram() -> project(), SIGNAL( projectDiagramsOrderChanged(QETProject*,int,int) ), this, SLOT( updateLabel() ));
label_ = diagram() -> defaultReportProperties();
updateLabel();
elmt -> linkToElement(this);
}
}
@@ -67,11 +88,13 @@ void ReportElement::linkToElement(Element * elmt) {
* @brief ReportElement::unLinkAllElements
* Unlink all of the element in the QList connected_elements
*/
void ReportElement::unlinkAllElements(){
void ReportElement::unlinkAllElements()
{
if (!isFree()){
QList <Element *> tmp_elmt = connected_elements;
foreach(Element *elmt, connected_elements) {
foreach(Element *elmt, connected_elements)
{
disconnect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
disconnect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
disconnect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
@@ -79,7 +102,9 @@ void ReportElement::unlinkAllElements(){
connected_elements.clear();
updateLabel();
foreach(Element *elmt, tmp_elmt){
foreach(Element *elmt, tmp_elmt)
{
elmt -> setHighlighted(false);
elmt -> unlinkAllElements();
}
}
@@ -111,18 +136,21 @@ void ReportElement::setLabel(QString label) {
* Update the displayed label.
* ie the folio and position of the linked folio report
*/
void ReportElement::updateLabel() {
if (texts().isEmpty()) return;
ElementTextItem *text = texts().first();
void ReportElement::updateLabel()
{
if (!m_text_field) return;
if (!connected_elements.isEmpty()){
if (!connected_elements.isEmpty())
{
Element *elmt = connected_elements.at(0);
QString label = label_;
label.replace("%f", QString::number(elmt->diagram()->folioIndex()+1));
label.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number()));
label.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter());
text->setPlainText(label);
} else {
text->setPlainText("/");
m_text_field -> setPlainText(label);
}
else
{
m_text_field -> setPlainText("/");
}
}

View File

@@ -20,6 +20,8 @@
#include "customelement.h"
class ElementTextItem;
/**
* @brief The ReportElement class
*this class represent an element that can be linked to an other ReportElement
@@ -30,7 +32,7 @@ class ReportElement : public CustomElement {
Q_OBJECT
public :
explicit ReportElement(const ElementsLocation &,QString link_type, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
explicit ReportElement(const ElementsLocation &,QString link_type, QGraphicsItem * = 0, int * = 0);
~ReportElement();
virtual void linkToElement(Element *);
virtual void unlinkAllElements();
@@ -39,6 +41,7 @@ class ReportElement : public CustomElement {
private:
int inverse_report;
QString label_;
ElementTextItem *m_text_field;
signals:

View File

@@ -17,6 +17,7 @@
*/
#include "simpleelement.h"
#include "commentitem.h"
#include "elementtextitem.h"
/**
* @brief SimpleElement::SimpleElement
* @param location
@@ -24,42 +25,52 @@
* @param s
* @param state
*/
SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
CustomElement(location, qgi, s, state),
SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) :
CustomElement(location, qgi, state),
m_comment_item (nullptr)
{
link_type_ = Simple;
connect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext)));
}
/**
* @brief SimpleElement::~SimpleElement
*/
SimpleElement::~SimpleElement() {
disconnect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
if (m_comment_item) delete m_comment_item;
}
/**
* @brief SimpleElement::initLink
* @param project
* Call init Link from custom element and after
* call update label for setup it.
*/
void SimpleElement::initLink(QETProject *project) {
CustomElement::initLink(project);
updateLabel();
updateLabel(DiagramContext(), elementInformations());
}
/**
* @brief SimpleElement::updateLabel
* update label of this element
*/
void SimpleElement::updateLabel() {
void SimpleElement::updateLabel(DiagramContext old_info, DiagramContext new_info) {
//Label of element
QString label = elementInformations()["label"].toString();
bool show = elementInformations().keyMustShow("label");
if (old_info["label"].toString() != new_info["label"].toString()) {
if (new_info["label"].toString().isEmpty())
setTaggedText("label", "_", false);
else
setTaggedText("label", new_info["label"].toString(), true);
}
// setup the label
if (!label.isEmpty() && show) setTaggedText("label", label, true);
if (ElementTextItem *eti = taggedText("label")) {
new_info["label"].toString().isEmpty() ? eti->setVisible(true) : eti -> setVisible(new_info.keyMustShow("label"));
}
//Comment of element
QString comment = elementInformations()["comment"].toString();
bool must_show = elementInformations().keyMustShow("comment");
QString comment = new_info["comment"].toString();
bool must_show = new_info.keyMustShow("comment");
if (!(comment.isEmpty() || !must_show) && !m_comment_item) {
m_comment_item = new CommentItem(this);

View File

@@ -32,7 +32,7 @@ class SimpleElement : public CustomElement {
Q_OBJECT
public :
explicit SimpleElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
explicit SimpleElement(const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
~SimpleElement();
virtual void initLink(QETProject *project);
@@ -40,7 +40,7 @@ class SimpleElement : public CustomElement {
signals:
public slots:
void updateLabel();
void updateLabel(DiagramContext old_info, DiagramContext new_info);
private:
CommentItem *m_comment_item;

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