2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2016-07-13 15:55:18 +02:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "diffutils.h"
|
|
|
|
|
|
2022-07-22 12:12:33 +02:00
|
|
|
#include <utils/guard.h>
|
|
|
|
|
|
2016-07-13 15:55:18 +02:00
|
|
|
#include <QObject>
|
|
|
|
|
#include <QTextCharFormat>
|
2016-11-22 13:32:29 +01:00
|
|
|
#include <QTimer>
|
2016-07-13 15:55:18 +02:00
|
|
|
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QMenu)
|
|
|
|
|
|
|
|
|
|
namespace Core { class IDocument; }
|
|
|
|
|
namespace TextEditor { class FontSettings; }
|
2016-11-22 13:32:29 +01:00
|
|
|
namespace Utils { class ProgressIndicator; }
|
2016-07-13 15:55:18 +02:00
|
|
|
|
|
|
|
|
namespace DiffEditor {
|
|
|
|
|
|
2017-11-29 21:36:30 +01:00
|
|
|
class ChunkSelection;
|
|
|
|
|
|
2016-07-13 15:55:18 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class DiffEditorDocument;
|
|
|
|
|
|
|
|
|
|
class DiffEditorWidgetController : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
explicit DiffEditorWidgetController(QWidget *diffEditorWidget);
|
|
|
|
|
|
|
|
|
|
void setDocument(DiffEditorDocument *document);
|
2016-11-23 11:20:12 +01:00
|
|
|
DiffEditorDocument *document() const;
|
2016-07-13 15:55:18 +02:00
|
|
|
|
|
|
|
|
void jumpToOriginalFile(const QString &fileName, int lineNumber,
|
|
|
|
|
int columnNumber);
|
|
|
|
|
void setFontSettings(const TextEditor::FontSettings &fontSettings);
|
2018-02-15 10:29:14 +01:00
|
|
|
void addCodePasterAction(QMenu *menu, int fileIndex, int chunkIndex);
|
|
|
|
|
void addApplyAction(QMenu *menu, int fileIndex, int chunkIndex);
|
|
|
|
|
void addRevertAction(QMenu *menu, int fileIndex, int chunkIndex);
|
2017-11-29 21:36:30 +01:00
|
|
|
void addExtraActions(QMenu *menu, int fileIndex, int chunkIndex, const ChunkSelection &selection);
|
2020-04-14 11:10:52 +02:00
|
|
|
void updateCannotDecodeInfo();
|
2022-09-22 13:48:54 +02:00
|
|
|
void setBusyShowing(bool busy);
|
2017-11-29 21:36:30 +01:00
|
|
|
|
|
|
|
|
ChunkData chunkData(int fileIndex, int chunkIndex) const;
|
2016-07-13 15:55:18 +02:00
|
|
|
|
2022-07-22 12:12:33 +02:00
|
|
|
Utils::Guard m_ignoreChanges;
|
2016-07-13 15:55:18 +02:00
|
|
|
QList<FileData> m_contextFileData; // ultimate data to be shown
|
|
|
|
|
// contextLineCount taken into account
|
|
|
|
|
QTextCharFormat m_fileLineFormat;
|
|
|
|
|
QTextCharFormat m_chunkLineFormat;
|
|
|
|
|
QTextCharFormat m_leftLineFormat;
|
|
|
|
|
QTextCharFormat m_rightLineFormat;
|
|
|
|
|
QTextCharFormat m_leftCharFormat;
|
|
|
|
|
QTextCharFormat m_rightCharFormat;
|
|
|
|
|
|
|
|
|
|
private:
|
2022-09-22 13:48:54 +02:00
|
|
|
bool isInProgress() const;
|
|
|
|
|
void toggleProgress(bool wasInProgress);
|
|
|
|
|
|
2018-02-15 10:29:14 +01:00
|
|
|
void patch(bool revert, int fileIndex, int chunkIndex);
|
|
|
|
|
void sendChunkToCodePaster(int fileIndex, int chunkIndex);
|
|
|
|
|
bool chunkExists(int fileIndex, int chunkIndex) const;
|
|
|
|
|
bool fileNamesAreDifferent(int fileIndex) const;
|
2016-07-13 15:55:18 +02:00
|
|
|
|
2016-11-22 13:32:29 +01:00
|
|
|
void scheduleShowProgress();
|
|
|
|
|
void showProgress();
|
|
|
|
|
void hideProgress();
|
2020-04-14 11:10:52 +02:00
|
|
|
void onDocumentReloadFinished();
|
2016-11-22 13:32:29 +01:00
|
|
|
|
2017-12-06 21:30:57 +01:00
|
|
|
QWidget *m_diffEditorWidget = nullptr;
|
2016-07-13 15:55:18 +02:00
|
|
|
|
|
|
|
|
DiffEditorDocument *m_document = nullptr;
|
|
|
|
|
|
2022-09-22 13:48:54 +02:00
|
|
|
bool m_isBusyShowing = false;
|
2016-11-22 13:32:29 +01:00
|
|
|
Utils::ProgressIndicator *m_progressIndicator = nullptr;
|
|
|
|
|
QTimer m_timer;
|
2016-07-13 15:55:18 +02:00
|
|
|
};
|
|
|
|
|
|
2022-09-22 11:00:38 +02:00
|
|
|
class DiffEditorInput
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
DiffEditorInput(DiffEditorWidgetController *controller);
|
|
|
|
|
QList<FileData> m_contextFileData;
|
|
|
|
|
QTextCharFormat *m_fileLineFormat = nullptr;
|
|
|
|
|
QTextCharFormat *m_chunkLineFormat = nullptr;
|
|
|
|
|
QTextCharFormat *m_leftLineFormat = nullptr;
|
|
|
|
|
QTextCharFormat *m_rightLineFormat = nullptr;
|
|
|
|
|
QTextCharFormat *m_leftCharFormat = nullptr;
|
|
|
|
|
QTextCharFormat *m_rightCharFormat = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
2016-07-13 15:55:18 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace DiffEditor
|