Skip to content

feat: Upgrade QDiffTextBrowser with Word Diffing, Highlighting, Line Numbers, UI Refinements, and Algorithm Fixes#6

Merged
djad04 merged 21 commits intomainfrom
fix/dtl-dmp-lineCountingBug
Aug 2, 2025
Merged

feat: Upgrade QDiffTextBrowser with Word Diffing, Highlighting, Line Numbers, UI Refinements, and Algorithm Fixes#6
djad04 merged 21 commits intomainfrom
fix/dtl-dmp-lineCountingBug

Conversation

@djad04
Copy link
Owner

@djad04 djad04 commented Aug 2, 2025

This PR introduces significant enhancements to the QDiffTextBrowser component and improves the internal diffing logic in DMPAlgorithm and DTLAlgorithm


🔧 Key Changes

📘 QDiffTextBrowser Integration

  • Added QDiffTextBrowser class based on QTextBrowser for visual diff rendering.
  • Implemented QLineNumberArea for displaying line numbers.
  • Features:
    • Line-by-line and word-by-word diff visualization
    • Custom line highlighting in paintEvent
    • Dynamic font scaling and spacing between diff blocks
    • Resizing support for line number area
  • Cleaned up outdated TODOs and restructured source files for maintainability.

⚙️ Diff Algorithm Updates

  • Replaced char-by-char diffing with word-by-word diffing in DMPAlgorithm.
  • Removed redundant char-level diff logic from DTLAlgorithm.
  • Refactored and exposed utility methods in DMP to improve modularity.
  • fix the diffing output problems caused by the dmp way of restructuring the diffs

🛠 Build Improvements

  • Updated CMake structure for better source file organization.
  • Introduced named constants (e.g., LINE_NUMBER_TEXT_WIDTH_RATIO) to avoid magic numbers.

djad04 and others added 21 commits July 7, 2025 23:05
…rArea implementation to separate files

- Removed the old LineNumberArea.cpp file and added a new QLineNumberArea.cpp and QLineNumberArea.h.
- Updated CMakeLists.txt to reflect the new file structure and include necessary headers.
- Implemented line numbering in QDiffTextBrowser by adding a QLineNumberArea.
- Updated the constructor and added methods for calculating line number area width and handling paint events.
- Refactored the header file to include necessary declarations and updated the namespace to QDiffX.
- Increase padding and improve styling for line numbers
- Add dynamic font size adjustment based on widget height
- Replace QTextBrowser with QDiffTextBrowser for both sides
- Set initial content and geometry in main.cpp
Add functionality to display and highlight diff results with different colors for insertions, deletions and replacements. Store line operations in a map and apply appropriate formatting when rendering the text. Also includes basic setup for line number area connections and document properties.
…vent

Add background color highlighting for lines based on their operation
- Add destructor to properly clean up line number area
- Refactor line number painting to use visual position calculations
- Add top/bottom margin constant and apply consistent spacing
- Remove redundant comments and improve code clarity
Clean up source files by removing completed or no longer relevant TODO comments that were cluttering the code
…cause of the different Compatibility problems dmp has with other algorithms
…splay on the QDiffTextBroeser

- Change visibility of diff_linesToChars and diff_charsToLines from protected/private to public
- Remove unused diffCharByChar method
- Fix line number calculation and newline handling in QDiffTextBrowser
@djad04 djad04 marked this pull request as ready for review August 2, 2025 16:30
@djad04 djad04 merged commit 75b3e1b into main Aug 2, 2025
7 checks passed
@djad04 djad04 changed the title Fix/dtl-dmp-line-counting-bug feat: Upgrade QDiffTextBrowser with Word Diffing, Highlighting, Line Numbers, UI Refinements, and Algorithm Fixes Aug 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant