-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Library: add multi-line editor delegate for comment column #11752
Conversation
This is ready to roll, exactly what I expect from an embedded editor. |
6552429
to
97ca286
Compare
97ca286
to
19e150d
Compare
There is one major issue: edit fixed. |
19e150d
to
23a0c48
Compare
Clazy is mad and wants me to start an infinite loop :p
How to prevent such advice and run clazy dependants? |
MultiLineEditDelegate is a TableItemDelegate is a QStyledItemDelegate Its this hierarchy reasonable? I think a solution is to split TableItemDelegate into a common base class and a part not used from MultiLineEditDelegate. Or just disable the warning with
|
I think so. TableItemDelegate does the basic painting and special subclasses handle the editors and do the special painting, even if it is just to apply custom elide (location delegate). Life would be easier if we had a default void TableItemDelegate::paintItem(painter, option, index) const {
QStyledItemDelegate::paint(pPainter, option, index);
} and not force subclasses to implement Splitting up TableItemDelegate is possible, sure, though more work and makes maintenance more complicated than necessary I think (a bit like WLibraryTableView and WTrackTableView where things got mixed up IMHO) PS
|
23a0c48
to
ccaa3b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks and works good. Ready for merge?
Given all the funny Qt 'features' I stumbled upon I'd appreciate manual tests on Win & macOS before 😬 from the top of my head: @JoergAtGithub @foss- @m0dB could give this a shot? To be tested:
|
ccaa3b1
to
125f971
Compare
Hi @ronso0, I just did some testing and all points on your "To be tested:" list work fine. But there are some things I notice: Some alignment/padding issues. I guess the first one falls under "TODO: style in all skins":
But then there is some weirdness with the editor's height that I think goes beyond styling:
And finally some issues with the scrolling / positioning in the viewport. I very much like the solution of limiting/binding the editor to the viewport, but:
I think this could be solved by keeping the editor rect clamped to the viewport rect. So if the editor is full height it will stay where it is. Otherwise it will scroll along with the tableview until it's top or bottom reaches the viewport top/bottom. (I guess this would be easier if the editor is not a child of the tableview). Alternatively:
But as your solution of limiting the editor to the viewport is very elegant and works well otherwise, I think it's worth doing this with the same solution applied to scroll. |
Thanks for testing!
This is space reserved for the h-scrollbar. QPlainTextEdit would add a bottom padding, too. IIUC this stems from |
That can be fixed I guess. |
Oh, macOS' transient/translucent scrollbars... Will see what I can do.
Seems pretty straight-forward since it can be done in WTrackTableView and would apply to all editors. I think closing editors (discard changes, like hitting Esc) on scroll events is better. |
Done. @m0dB Please try again. |
8ce6356
to
ba7f5b6
Compare
This is the default behaviour of QLineEdit and I implemented that for consistency with the other fields. FWIW I just managed to get scrollbars for a one-liner so something isn't working entirely as expected. And I need to polish exit-on-scroll: when scrolling the editor it may happen that scroll events are sent to the table and close the editor unexpectedly. Explicit commands like |
so MultiLineEditDelegate doesn't have to implement it just for calling the base class implementation QStyledItemDelegate::paint() (which raised a clazy error)
…riginal height when returning to single-line mode after removing a line break
setting seems to be reset if document size changed while line count didn't
1d25ece
to
f28ea7b
Compare
Well, this is because the default QLineEdit implementation uses Qt::AlignVCenter.
So, 2. works but since it'sapplied in all direction the left shift may feel strange with a low font / row height ratio. Negligible. Please test again! |
@daschuer I'm sorry, was rebasing onto the first commit (I thought) but rebased onto main which makes the diff rather large. My bad. |
Okay, I'm happy with this. Hopefully it's fine on macOS, too. Some testing on Windows is required before merging, though I only expect minor quirks if any. @JoergAtGithub maybe? I can do fixes if required when I'm back from holiday in a few weeks. If there's a chance this slips in before 2.4.0 feel free to push fixup commits yourself.
|
in order to access protected function and hopefully fix invisble cursor at line end if editor is clamped to fit into the table view
should avoid unneeded v-scrollbars with many lines
…s, always stick to index rect
…an the table index
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and works good. Thank you for all the size fideling.
Yeah, I'm glad it works now. It's not the small adjustments that were annoying but rather same strange quirks / feature. I hope it looks good on Windows, too. |
I'm working with multi-line comments since day one, mostly to store purchase info and notes in lines 2+, sometimes lyrics.
Though it's rather inconvenient editing these inside the table view with the currently used QLineEdit, e.g. line breaks are not printed which makes navigation cumbersome. Going to Track Properties just for minor edits is also no option for me.
This PR adds a proper multi-line editor delegate.
This wasn't exactly plug'n'play, thanks to some Qt quirks and undocumented 'features'.
The editor now adjusts to content dynamically (line count changes), is limited to the table view and shifted vertically if required.
Editing single-line content looks exactly like current QLineEdits.
The table view was not touched, just the editor is now a QPlainTextEdit, subclassed to allow finishing the edit with Return (like QLineEdit) and disable line-wrap for a manageable and predictable view.
UX is also the same as with QLineEdit:
TODO