Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix QgsDateTimeEdit paste when fully selected #60646

Merged
merged 2 commits into from
Feb 19, 2025

Conversation

elpaso
Copy link
Contributor

@elpaso elpaso commented Feb 17, 2025

Fix #53149
...and possibly #60625

The issue is deep into QT internals: the abstract spinbox has a line edit wich holds the different datetime components divided into "Sections", when the user selects all (e.g. with CTRL+A) and then pastes a datetime string from the clipboard, it may get pasted in the wrong position (i.e. not at the beginning of the selection) because the internal position of the cursor wasn't updated.

I tried hard to write a test (even tried QTest::click* and injection of forged events) but I couldn't find a way to reproduce the issue programmatically using the QT public API).

Fix qgis#53149
...and possibly qgis#60625

The issue is deep into QT internals: the abstract spinbox
has a line edit wich holds the different datetime components
divided into "Sections", when the user selects all (e.g. with
CTRL+A) and then pastes a datetime string from the clipboard,
it may get pasted in the wrong position (i.e. not at the beginning
of the selection) because the internal position of the cursor
wasn't updated).

I tried hard to write a test (even tried QTest::click* and events
but I couldn't find a way to reproduce the issue programmatically
using the QT public API).
@elpaso elpaso added GUI/UX Related to QGIS application GUI or User Experience Bug Either a bug report, or a bug fix. Let's hope for the latter! Widgets labels Feb 17, 2025
@github-actions github-actions bot added this to the 3.42.0 milestone Feb 17, 2025
@elpaso
Copy link
Contributor Author

elpaso commented Feb 17, 2025

@andreasneumann please give this a try when ready and check if it solves #60625

Copy link

github-actions bot commented Feb 17, 2025

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 9d85a3b)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 9d85a3b)

@@ -109,6 +109,22 @@ bool QgsDateTimeEdit::event( QEvent *event )
mClearAction->setVisible( !isReadOnly() && mAllowNull && ( !mIsNull || mIsEmpty ) );
}

// Fix wrong internal logic of Qt when pasting text with selected text
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth reporting to Qt upstream?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMHO it doesn't: I couldn't find a way to reproduce it by code, and even if I did my past experience with QT bug reporting makes me think it would be a complete waste of time.

@andreasneumann
Copy link
Member

@andreasneumann please give this a try when ready and check if it solves #60625

Looks good. My issue is solved with this commit. Thank you very much!

@elpaso
Copy link
Contributor Author

elpaso commented Feb 18, 2025

@andreasneumann please give this a try when ready and check if it solves #60625

Looks good. My issue is solved with this commit. Thank you very much!

Thanks for checking, I realized that I misused the API when restoring the selection, would you mind re-testing after my last commit please?

@elpaso elpaso merged commit 6f1dde3 into qgis:master Feb 19, 2025
30 checks passed
@elpaso elpaso deleted the bugfix-gh_53149-qgsdatetimeedit-paste branch February 19, 2025 08:10
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! GUI/UX Related to QGIS application GUI or User Experience Widgets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect date pasting in the attribute table
3 participants