-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copy Paste Functionality #3603
base: master
Are you sure you want to change the base?
Copy Paste Functionality #3603
Conversation
@grossmj Will you please review this and guide me for further modifications. |
@grossmj There was a problem with KeyPressEvent Function so i fixed it i hope now it will pass all the test cases |
I just tested this PR and it doesn't work here. My environment: Debian Linux 12.6 (Bullseye) with Python 3.11.2 and QT 5.15.8. I cloned the repository https://github.com/athaarnaqvi/gns3-gui and then did a 1. Issue: The function copySelectedItems needs the parameter selfWhen issuing a ctrl-c I get a traceback:
Adding parameter self fixes that. 2. Issue: The global variable isctrlcpressed can't be setI could verify, that copySelectedItems is called on ctrl-c and it sets isctrlcpressed to True, but on ctrl-v in function pasteItemsFromClipboard the variable is False. I have no explanation for that. But when I change isctrlcpressed to a class variable it works. 3. Issue: The connections are not copiedI used a rectangle area selection to select R1 and R2 and the link between them. Then I'm using ctrl-c and ctrl-v to cut and paste them. But only the nodes were copied, not the link. I added a debug output in pasteItemsFromClipboard to show the items selected. Two nodes and 4 labels were selected, but no link.
Here the diffs of all my changes:
So I'm really puzzled, did I select it wrong? Or does the code not work in my environment? At least I think it needs some polishing. Just some additional remarks:
|
I used the conventional shortcut key for copy. Changing the convention may not be very handful for the users.
I have fixed this in the PR as now the copySelectedItems function will call the pasteItemsFromClipboard function only when the CTRL+V is pressed.
I have directly called the duplicate function in here as for the duplication of links can you identify where in the code the links are being added initially then i will work on it. |
Hi! |
I think the correct way to copy items would be to use the QClipboard class in Qt: https://doc.qt.io/qt-5/qclipboard.html Something similar to https://stackoverflow.com/questions/57353390/how-to-copy-paste-an-qgraphicsitem-in-pyqt5 When CTRL + V is pressed, you retrieve the items saved in the QClipboard and create new ones like it is done in duplicateActionSlot() Once this has been correctly implement, you can try to focus on copying the links as well, however the actual duplication is done on the server side. You will have to create another PR there. |
okay I will try to cover it as soon as possible |
I have introduced an enhancement to the existing duplicate functionality by implementing new Copy and Paste features. Unlike the existing duplication feature, the new Copy and Paste functionality supports copying connections (Links) as well.
-Added key bindings for Copy and Paste operations in the keyPressEvent function.
-Implemented a new Copy function that enables the Paste function through a boolean variable.
-Introduced a new Paste function that handles the duplication of copied items. This function is triggered by the boolean variable set by the Copy function, ensuring that paste operations are only performed when there is copied content to paste.
This enhancement significantly improves the user experience by allowing not only the duplication of items but also their associated connections, thus preserving the integrity of the duplicated elements.