Skip to content
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

Use a global copy buffer #466

Merged
merged 2 commits into from
Sep 30, 2020
Merged

Use a global copy buffer #466

merged 2 commits into from
Sep 30, 2020

Conversation

amolenaar
Copy link
Member

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Documentation content changes

What is the current behavior?

When you copy some items in a diagram, you can only paste them in the same model.

Issue Number: #463

What is the new behavior?

You can copy, and then paste the items in a different diagram. The diagram items are backed by their model elements.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

The current implementation (a global variable) is not really nice. But it proves the application can handle this copy/paste behavior. The actual behavior should work via an gaphor.appservice. However, there's no way to inject an app service in a session. And I'm not sure if we want to.

This is not the nicest of solutions, I think. But it proves we can copy
from one model to another.
@amolenaar amolenaar marked this pull request as draft September 28, 2020 19:49
They're not visible in the UI, so no update is required.
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 29, 2020

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 1.18%.

Quality metrics Before After Change
Complexity 1.33 ⭐ 1.23 ⭐ -0.10 👍
Method Length 44.27 ⭐ 43.38 ⭐ -0.89 👍
Working memory 4.13 ⭐ 3.77 ⭐ -0.36 👍
Quality 89.04% 90.22% 1.18% 👍
Other metrics Before After Change
Lines 172 153 -19
Changed files Quality Before Quality After Quality Change
gaphor/services/copyservice.py 89.93% ⭐ 91.83% ⭐ 1.90% 👍
gaphor/services/tests/test_copyservice.py 86.60% ⭐ 86.60% ⭐ 0.00%

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
gaphor/services/tests/test_copyservice.py CopyServiceTestCase._skip_test_copy_paste_undo 0 155 😞 5 ⭐ 74.05% 🙂 Try splitting into smaller methods

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

@amolenaar
Copy link
Member Author

I want to leave it as it is, with the global copy variable. Alternative would be to use a application service instead. But we'd better improve this bit when (if) we migrate to GTK4.

@amolenaar amolenaar marked this pull request as ready for review September 29, 2020 18:55
@danyeaw danyeaw added the feature A new feature label Sep 30, 2020
Copy link
Member

@danyeaw danyeaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I agree that this will work until we migrate to GTK4 eventually 👍

@danyeaw danyeaw merged commit c0189ca into master Sep 30, 2020
@danyeaw danyeaw deleted the global-copy-paste branch September 30, 2020 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants