Commit Graph

88 Commits

Author SHA1 Message Date
Jarek Kobus
d0278ae295 SelectableTextEditorWidget: Handle display settings
Avoid code repetition inside UnifiedDiffEditorWidget
and SideDiffEditorWidget.

Connect to display settings changed signal and apply
all but 4 settings (which are not desired for diff editor).

Change-Id: If4ae7f7c55690dac04fd1a00f8822db666a9ce2b
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-10-20 09:19:07 +00:00
Jarek Kobus
161fb4c440 UnifiedDiffEditor: Fix never ending spinner when no difference
Change-Id: If0d646c760cdc8c9fb8e2481a7798eed925681b6
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2022-10-13 13:21:40 +00:00
Jarek Kobus
693db6eef6 UnifiedDiffEditor: Fix '+' on added lines
Amends 15fd4a0754

Change-Id: If74b5437be241303de1e157b7980ef10ef6c060c
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-10-11 14:34:25 +00:00
Marc Mutz
8eb4d52342 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.

Task-number: QTBUG-99313
Change-Id: I88edd91395849574436299b8badda21bb93bea39
Reviewed-by: hjk <hjk@qt.io>
2022-10-07 13:47:53 +00:00
Jarek Kobus
1359557f77 DiffEditor: Limit the usage of qMakePair
Change-Id: I0f7f4235cba4e1f6df4245cb51a37ff82a8e5109
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-30 07:42:00 +00:00
Jarek Kobus
38316079f3 UnifiedDiffEditor: Early return inside jumpToOriginalFile()
Change-Id: Ib397c316296db494b81a08214049884c45a3f5e5
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-30 07:41:54 +00:00
Jarek Kobus
99589a7572 UnifiedDiffEditor: Move some methods into UnifiedDiffData
Like it's done in case of SideDiffData.

Change-Id: I27af423e50277c81e596006c960daecc6a51145f
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-29 18:46:15 +00:00
Jarek Kobus
b677fbe992 DiffUtils: Introduce DiffChunkInfo
Avoid code repetition.

Change-Id: Iea9acef8f8b27793528fa7eaf7044e12dcd21d10
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-29 18:46:10 +00:00
Jarek Kobus
daa942393a DiffEditorPlugin: Introduce DiffFileInfoArray
Change-Id: I884d72e6c500e41969f379d969bcf1f46be8fd5c
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-29 16:14:04 +00:00
Jarek Kobus
b67c868f75 PatchTool: Introduce PatchAction enum
Add static PatchTool::confirmPatching() and reuse it
in two places.

Use Tr::tr() inside PatchTool.

Change-Id: I70779619dbb58ab6e46a585bbeff51588ccb2f53
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-29 15:15:30 +00:00
Jarek Kobus
2d360db2c3 SideBySideDiffEditor: Avoid code repetition
Change-Id: Ie49834a4896dbf32a87329345e52dc99ca2f86bd
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-29 15:15:21 +00:00
Jarek Kobus
38b19bfae6 DiffEditor: Cleanup includes
Change-Id: Id8127b9b0c99ee2a0d5d367cb551a1d5779c5d38
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-29 15:15:12 +00:00
Jarek Kobus
67121e6cd3 DiffEditor: Fix scrolling to current file after reloading
This feature got broken during recent refactorings.

Change-Id: I9d2d24e7ed63d5512b64c53e4bb9303497871d5e
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-29 11:03:27 +00:00
Jarek Kobus
6ea3aad0a2 UnifiedDiffData: Remove unused charNumber argument
Change-Id: I40331b4471a1aa716003943ecfb92a9ee7a4e406
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-28 20:30:34 +00:00
Jarek Kobus
084c310c44 UnifiedDiffData: Rename setDiff into diffOutput and make it static
Conform to sibling struct SideDiffData.

Change-Id: I7630ec7480c34a94f17ef09904e332da768f0c37
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-28 20:30:30 +00:00
Jarek Kobus
53fc68bc08 SideBySideDiffEditor: Move showing diff into separate thread
Change-Id: I8b0a4835cf6f51e4acfd483dcfc7b94585c64bf5
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-28 20:30:25 +00:00
Jarek Kobus
15fd4a0754 UnifiedDiffEditor: Avoid code repetition
Change-Id: I2e361b29c3d35fe5128b6b5a4a90b6c4ee0de432
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-28 18:11:17 +00:00
Jarek Kobus
472d791fec DiffEditor: Use DiffSide in DiffEditorInput
Change-Id: I195c37f29884f1d066acbb54c8ace07f8801f829
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-28 18:11:10 +00:00
Jarek Kobus
6ec7ce539b UnifiedDiffEditor: Move setting folding markers into thread
Change-Id: I4fc6f08039813c08e70a6798f65abcea219558be
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-28 18:11:03 +00:00
Jarek Kobus
f66320c413 DiffEditor: Simplify DiffSelection
Change-Id: I9de3774fafa9f257974a4231a83b64f375291d87
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-28 18:10:32 +00:00
Jarek Kobus
3877ced865 DiffEditorPlugin: Add SideBySideDiffOutput
Move generation of SideDiffData into static diffOutput()
method.

Change-Id: Ie38b3e09dd8222e0219fdfb345bc7cf4a39f6e21
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-28 18:10:26 +00:00
Jarek Kobus
0def7c83d4 DiffEditorPlugin: Various cleanups
Change-Id: Ic0c9c397067b899932bc39d938e63df36fa4caeb
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-28 18:10:02 +00:00
Jarek Kobus
e67e2121a7 UnifiedDiffEditor: Move polishing selections into working thread
In case of big commit (like 05c35356ab)
polishing selections took about 200 ms. Move this work into
thread to avoid extra 200 ms freeze of GUI thread.

Change-Id: If159e3f0869264f467c4c015f944a3054609f812
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-28 17:13:49 +00:00
Jarek Kobus
f3a7299761 DiffEditor: Use DiffSide enum inside FileData
Change-Id: I4c18c52a9737cc46c3faeadf0abd5c4771463e0e
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-28 15:48:34 +00:00
Jarek Kobus
a1c4d563a1 DiffEditor: Use DiffSide enum inside RowData
Change-Id: I5511e443e2f76a1dab5cc78eec5faec04ee31bcc
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-28 15:48:16 +00:00
Jarek Kobus
cd8ff54b00 DiffEditor: Use DiffSide enum inside ChunkData
Change-Id: Ic10fe9faa6b6ccefcbf4c062663dedefa6bf5872
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-28 15:48:08 +00:00
Jarek Kobus
b4390a3a80 DiffEditor: Introduce DiffSide enum
This should simplify various diff structs.

Change-Id: Ia8c77de558a92a2a64fc13c674a46192521970f0
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-28 15:47:49 +00:00
Jarek Kobus
054d7d65d2 UnifiedDiffEditor: Move showing diff into separate thread
Before, when all the data was finished, we called showDiff()
in main thread. This consisted of 2 parts:

1. Calculating some extra data and generating actual text
   for UnifiedDiffEditor out of input data.
2. Calling setPlainText() with generated text.

For a really big diffs this could freeze the main thread for a
couple of seconds. Like e.g. 05c35356ab
(initial Creator import) - it contained 7 million characters,
part 1. took about 500 ms and part 2. took about 2.5 seconds.

This two tasks are now done in separate thread.
However, since we can't call TextEditorWidget::setPlainText()
directly from non-GUI thread, we create a separate
TextDocument object in the worker thread, fill it with
generated diff input and move the TextDocument object
into the main thread as a result of async computation.
In main thread we replace TextDocument object of the
TextEditorWidget with the one generated in other thread.
This replacement is very fast.

Change-Id: I49a717ced1dc2d5b8946e0fd6bee244b25071f35
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-28 15:47:39 +00:00
Jarek Kobus
8d284c222c UnifiedDiffEditor: Refactor internal data
This is a preparation step before making diff showing more
interactive.

Change-Id: I149b76466c3ccce05d823bac91fe89ac806b9130
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-22 11:38:57 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
Jarek Kobus
d96bfdff84 DiffEditorWidgetController: Use Utils::Guard
Change-Id: I3d3e22ce26c85859eb8024f2b87c7c85c5ac65f1
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-07-25 13:02:43 +00:00
hjk
2f44449a90 DiffEditor: Remove workingDir parameter from setDiff()
It was not used.

Change-Id: I33a77f4d8238218b90171a98aa25af5b31b17eb3
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2021-08-17 11:22:45 +00:00
Alessandro Portale
72d91dc94a Use qAsConst with non-const Qt containers in range-loops
... in various places

Change-Id: Ic6c0c1b9437a1ed402105c7a14a1f5f9454a68d4
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-02-17 14:43:29 +00:00
hjk
89296a98a0 Qt6: Adapt to removed QMap functionality
QMap::iterator::operator+() was removed in 14090760a8, necessitating
extra code using std::next/prev to workaround.

QMap::unite is gone, the replacement QMap::insert was only introduced
in 5.15.

QMap key values need to have an operator==() available.

Task-number: QTCREATORBUG-24098
Change-Id: Ic4cf429ab18cad58b1218180de40eb65586afd77
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2020-08-13 12:11:36 +00:00
Eike Ziller
e5bb7d1ffe Remove unnecessary removeContextObject calls
They are removed on deletion now.

Change-Id: I08461ea4938e24ab450df013a0f8f820032381da
Reviewed-by: hjk <hjk@qt.io>
2020-05-27 08:42:00 +00:00
Alessandro Portale
24a25eed14 Use isEmpty() instead of count() or size()
Change-Id: I0a89d2808c6d041da0dc41ea5aea58e6e8759bb4
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2020-01-20 20:56:57 +00:00
Jarek Kobus
3b9ce98865 Git/DiffEditor: Fix staging added/removed lines separately
Fixes: QTCREATORBUG-23243
Change-Id: Ice19e1c778aabd9cb1b9fe0681234073de85cfcb
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-12-02 15:49:03 +00:00
Andre Hartmann
1766832918 DiffEditor: Stage and unstage selected lines for Git
Fixes: QTCREATORBUG-19071
Change-Id: I560ba208e68e477ea865e499847d819cfdfeb6f3
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2019-11-19 11:19:43 +00:00
Jarek Kobus
1a23768563 Ignore index change when we set the document
Do the same as in case of sidebyside editor.

Task-number: QTCREATORBUG-18306
Change-Id: I1364aed0edb02dd9f5432e191ce4fb4b2db34430
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2018-05-04 07:58:37 +00:00
Jarek Kobus
64233a4fae Fix repeting Stage/Unstage actions in unified diff editor
Don't store diff file index, chunk index and diff editor
controller anymore. Pass needed indices by value,
retrieve them when needed as lambda copy.

Change-Id: I3a81f1ab6d131c0b1d9899ac4b061b6e25582f51
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-02-16 06:48:27 +00:00
Jarek Kobus
990da15c1e Refactor HighlightScrollBar
Rename it into HighlightScrollBarController.
Don't derive it anymore from QScrollBar.
Make it based on QObject and decorate
the existing instance of QAbstractScrollArea as needed.

Fix the highlight of the shared scrollbar of the SideBySideDiffEditor.
Both left and right diff editors have their own
HighlightScrollBarController and their own separate overlays, but both
overlays are created as children of the same right editor instance.

Synchronize also the cursor between left and right editors.
Make highlight current line working.

Make the overlay transparent for mouse events - this fixes
issues on macOS when scolling over invisible scrollbar.

Change-Id: Iab05c360173e09d8748658c59785da86438a7189
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-12-12 08:17:58 +00:00
Andre Hartmann
aae3056b33 DiffEditor: Modernize
* Use member init
* Use nullptr
* Use range-for
* omit QLatin1{String|Char} where possible

Change-Id: Ib231b747cdd9073b3d4fc6779b8e0afb2b404a31
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2017-12-09 14:45:37 +00:00
Jarek Kobus
96aeabd0a6 Add folding to Side-by-side diff editor
Add folding for files and chunks.

Change-Id: I76476351e88f0b3e71e3cccbca0fa17b02c26226
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-11-01 09:13:17 +00:00
Friedemann Kleint
0be8240002 Add folding to Unified diff editor
Add folding for files and chunks.

Change-Id: I0dd278d0bc69208a0c9c116b94e4ead7aec5fede
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2017-10-05 14:29:38 +00:00
Orgad Shaneh
6334632f00 DiffEditor: Jump to original file on Enter
Task-number: QTCREATORBUG-18650
Change-Id: Id6bfb9892aee2e4d7b7772b7dd208107ec4b3b11
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-07-31 08:43:05 +00:00
Jarek Kobus
228e4a7542 DiffEditor: refactor loops and const correctness
Change-Id: I21af8db55ff5a012de04b4934de1940babf75058
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2017-06-28 08:51:36 +00:00
Eike Ziller
ee722a047c DiffEditor: Fix editor actions
The text editor widgets all need a TextEditorActionHandler that takes
care of the editor actions for them.
Each text editor needs its own context, so the editor with focus
receives the actions. This does not happen automatically for these text
editors, since the diff editor manages these itself.

Task-number: QTCREATORBUG-9445
Change-Id: Ib42f095ec23550e401e8ee9b36f3f49517a22877
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-05-18 08:24:26 +00:00
Jarek Kobus
b29513aa5b Display "Waiting for data" properly
Display "Waiting for data" instead of "No differences" when creating new
instance of an editor for the same document (e.g. by splitting the view)
during document reload.

Change-Id: If254006de3914ad4416c7405874e8cbea57ddd8d
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-09 10:49:13 +00:00
Jarek Kobus
3c1647e6b2 Refactor DiffEditorWidgets, introduce common widget controller
Reduce code repetition.

Change-Id: I416555dd83ce888088a6a259777c294a6feb35f4
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2016-07-25 13:28:45 +00:00
Tobias Hunger
397e7f4843 Update License according to agreement with Free Qt Foundation
* Update files in src/plugins

Change-Id: Ia5d77fad7d19d4bb3498e78661982f68729adb22
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-01-19 15:57:01 +00:00