Structured files wlx (JSON, XML, CBOR, INI, TOML, YML)#41
Open
pplupo wants to merge 9 commits into
Open
Conversation
- Add createEditor/setEditorData/setModelData/updateEditorGeometry to WrapAnywhereDelegate so all grid cells edit with QPlainTextEdit, preserving newlines correctly - Let Enter/Return and Up/Down pass through to QPlainTextEdit so they work as expected within multi-line text - Ctrl+Enter commits and closes the editor - Remove the temporary MultiLineDelegate from StructViewWidget.cpp now that the fix lives in the shared delegate
The grid was showing outdated data after reopening a file because setCurrentIndex() does not always emit currentChanged when the selected position (0,0) is the same as the previous session. This left m_currentNode pointing into the destroyed old engine's node tree. Fix: explicitly null m_currentNode and clear the grid model before repopulating the tree, then call showNodeData() directly with the new root node — bypassing the selection signal entirely.
- Enter: commit and close the editor (was Ctrl+Enter) - Ctrl+Enter: insert a newline (was plain Enter)
Move QPlainTextEdit Enter handling to WrapAnywhereDelegate::eventFilter. Qt installs the delegate as event filter on the editor widget, so that is the correct interception point — not EditableGridWidget::eventFilter which only sees events on m_view (never reached during editing). Qt's QAbstractItemDelegate::eventFilter deliberately skips the Enter→commit behavior for QPlainTextEdit, so we must override it here. - Enter: commit and close - Ctrl+Enter: insert newline
Instead of calling insertPlainText() from the event filter (which was silently failing in dbview with AnyKeyPressed + proxy model), simply do not intercept Ctrl+Enter at all. QAbstractItemDelegate::eventFilter already skips the commit behavior for QPlainTextEdit editors, so the event falls through to QPlainTextEdit::keyPressEvent which inserts a newline naturally. This approach is robust regardless of edit trigger or model setup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This viewer superseeds the JSON viewer I had previously implemented. It has support for multiple formats using a standardized interface. More information in the README.md file.