forked from qt-creator/qt-creator
DiffEditorPlugin: Various cleanups
Change-Id: Ic0c9c397067b899932bc39d938e63df36fa4caeb Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -46,6 +46,7 @@ static const char ignoreWhitespaceKeyC[] = "IgnoreWhitespace";
|
|||||||
|
|
||||||
static const char diffViewKeyC[] = "DiffEditorType";
|
static const char diffViewKeyC[] = "DiffEditorType";
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
|
|
||||||
namespace DiffEditor {
|
namespace DiffEditor {
|
||||||
@@ -86,10 +87,10 @@ DescriptionEditorWidget::DescriptionEditorWidget(QWidget *parent)
|
|||||||
|
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
|
||||||
auto context = new Core::IContext(this);
|
auto context = new IContext(this);
|
||||||
context->setWidget(this);
|
context->setWidget(this);
|
||||||
context->setContext(Core::Context(Constants::C_DIFF_EDITOR_DESCRIPTION));
|
context->setContext(Context(Constants::C_DIFF_EDITOR_DESCRIPTION));
|
||||||
Core::ICore::addContextObject(context);
|
ICore::addContextObject(context);
|
||||||
|
|
||||||
textDocument()->setSyntaxHighlighter(new SyntaxHighlighter);
|
textDocument()->setSyntaxHighlighter(new SyntaxHighlighter);
|
||||||
}
|
}
|
||||||
@@ -113,7 +114,7 @@ void DescriptionEditorWidget::setDisplaySettings(const DisplaySettings &ds)
|
|||||||
void DescriptionEditorWidget::setMarginSettings(const MarginSettings &ms)
|
void DescriptionEditorWidget::setMarginSettings(const MarginSettings &ms)
|
||||||
{
|
{
|
||||||
Q_UNUSED(ms)
|
Q_UNUSED(ms)
|
||||||
TextEditorWidget::setMarginSettings(MarginSettings());
|
TextEditorWidget::setMarginSettings({});
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptionEditorWidget::applyFontSettings()
|
void DescriptionEditorWidget::applyFontSettings()
|
||||||
@@ -130,11 +131,11 @@ DiffEditor::DiffEditor()
|
|||||||
setDuplicateSupported(true);
|
setDuplicateSupported(true);
|
||||||
|
|
||||||
// Widget:
|
// Widget:
|
||||||
QSplitter *splitter = new Core::MiniSplitter(Qt::Vertical);
|
QSplitter *splitter = new MiniSplitter(Qt::Vertical);
|
||||||
|
|
||||||
m_descriptionWidget = new DescriptionEditorWidget(splitter);
|
m_descriptionWidget = new DescriptionEditorWidget(splitter);
|
||||||
m_descriptionWidget->setReadOnly(true);
|
m_descriptionWidget->setReadOnly(true);
|
||||||
connect(m_descriptionWidget, &DescriptionEditorWidget::requestResize, this, [splitter](){
|
connect(m_descriptionWidget, &DescriptionEditorWidget::requestResize, this, [splitter] {
|
||||||
if (splitter->count() == 0)
|
if (splitter->count() == 0)
|
||||||
return;
|
return;
|
||||||
QList<int> sizes = splitter->sizes();
|
QList<int> sizes = splitter->sizes();
|
||||||
@@ -189,16 +190,16 @@ DiffEditor::DiffEditor()
|
|||||||
m_whitespaceButtonAction = m_toolBar->addAction(tr("Ignore Whitespace"));
|
m_whitespaceButtonAction = m_toolBar->addAction(tr("Ignore Whitespace"));
|
||||||
m_whitespaceButtonAction->setCheckable(true);
|
m_whitespaceButtonAction->setCheckable(true);
|
||||||
|
|
||||||
m_toggleDescriptionAction = m_toolBar->addAction(Icons::TOP_BAR.icon(), QString());
|
m_toggleDescriptionAction = m_toolBar->addAction(Icons::TOP_BAR.icon(), {});
|
||||||
m_toggleDescriptionAction->setCheckable(true);
|
m_toggleDescriptionAction->setCheckable(true);
|
||||||
|
|
||||||
m_reloadAction = m_toolBar->addAction(Utils::Icons::RELOAD_TOOLBAR.icon(), tr("Reload Diff"));
|
m_reloadAction = m_toolBar->addAction(Utils::Icons::RELOAD_TOOLBAR.icon(), tr("Reload Diff"));
|
||||||
m_reloadAction->setToolTip(tr("Reload Diff"));
|
m_reloadAction->setToolTip(tr("Reload Diff"));
|
||||||
|
|
||||||
m_toggleSyncAction = m_toolBar->addAction(Utils::Icons::LINK_TOOLBAR.icon(), QString());
|
m_toggleSyncAction = m_toolBar->addAction(Utils::Icons::LINK_TOOLBAR.icon(), {});
|
||||||
m_toggleSyncAction->setCheckable(true);
|
m_toggleSyncAction->setCheckable(true);
|
||||||
|
|
||||||
m_viewSwitcherAction = m_toolBar->addAction(QIcon(), QString());
|
m_viewSwitcherAction = m_toolBar->addAction(QIcon(), {});
|
||||||
|
|
||||||
connect(m_whitespaceButtonAction, &QAction::toggled,
|
connect(m_whitespaceButtonAction, &QAction::toggled,
|
||||||
this, &DiffEditor::ignoreWhitespaceHasChanged);
|
this, &DiffEditor::ignoreWhitespaceHasChanged);
|
||||||
@@ -206,7 +207,7 @@ DiffEditor::DiffEditor()
|
|||||||
this, &DiffEditor::contextLineCountHasChanged);
|
this, &DiffEditor::contextLineCountHasChanged);
|
||||||
connect(m_toggleSyncAction, &QAction::toggled, this, &DiffEditor::toggleSync);
|
connect(m_toggleSyncAction, &QAction::toggled, this, &DiffEditor::toggleSync);
|
||||||
connect(m_toggleDescriptionAction, &QAction::toggled, this, &DiffEditor::toggleDescription);
|
connect(m_toggleDescriptionAction, &QAction::toggled, this, &DiffEditor::toggleDescription);
|
||||||
connect(m_viewSwitcherAction, &QAction::triggered, this, [this]() { showDiffView(nextView()); });
|
connect(m_viewSwitcherAction, &QAction::triggered, this, [this] { showDiffView(nextView()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiffEditor::setDocument(QSharedPointer<DiffEditorDocument> doc)
|
void DiffEditor::setDocument(QSharedPointer<DiffEditorDocument> doc)
|
||||||
@@ -225,7 +226,7 @@ void DiffEditor::setDocument(QSharedPointer<DiffEditorDocument> doc)
|
|||||||
connect(m_document.data(), &DiffEditorDocument::reloadFinished,
|
connect(m_document.data(), &DiffEditorDocument::reloadFinished,
|
||||||
this, &DiffEditor::reloadHasFinished);
|
this, &DiffEditor::reloadHasFinished);
|
||||||
|
|
||||||
connect(m_reloadAction, &QAction::triggered, this, [this]() { m_document->reload(); });
|
connect(m_reloadAction, &QAction::triggered, this, [this] { m_document->reload(); });
|
||||||
connect(m_document.data(), &DiffEditorDocument::temporaryStateChanged,
|
connect(m_document.data(), &DiffEditorDocument::temporaryStateChanged,
|
||||||
this, &DiffEditor::documentStateChanged);
|
this, &DiffEditor::documentStateChanged);
|
||||||
|
|
||||||
@@ -250,9 +251,9 @@ DiffEditor::~DiffEditor()
|
|||||||
qDeleteAll(m_views);
|
qDeleteAll(m_views);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IEditor *DiffEditor::duplicate()
|
IEditor *DiffEditor::duplicate()
|
||||||
{
|
{
|
||||||
auto editor = new DiffEditor();
|
auto editor = new DiffEditor;
|
||||||
Utils::GuardLocker guard(editor->m_ignoreChanges);
|
Utils::GuardLocker guard(editor->m_ignoreChanges);
|
||||||
|
|
||||||
editor->setDocument(m_document);
|
editor->setDocument(m_document);
|
||||||
@@ -270,7 +271,7 @@ Core::IEditor *DiffEditor::duplicate()
|
|||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IDocument *DiffEditor::document() const
|
IDocument *DiffEditor::document() const
|
||||||
{
|
{
|
||||||
return m_document.data();
|
return m_document.data();
|
||||||
}
|
}
|
||||||
@@ -421,7 +422,7 @@ void DiffEditor::prepareForReload()
|
|||||||
= qMakePair(m_entriesComboBox->itemData(m_currentDiffFileIndex, Qt::UserRole).toString(),
|
= qMakePair(m_entriesComboBox->itemData(m_currentDiffFileIndex, Qt::UserRole).toString(),
|
||||||
m_entriesComboBox->itemData(m_currentDiffFileIndex, Qt::UserRole + 1).toString());
|
m_entriesComboBox->itemData(m_currentDiffFileIndex, Qt::UserRole + 1).toString());
|
||||||
} else {
|
} else {
|
||||||
m_currentFileChunk = qMakePair(QString(), QString());
|
m_currentFileChunk = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -457,7 +458,7 @@ void DiffEditor::reloadHasFinished(bool success)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentFileChunk = qMakePair(QString(), QString());
|
m_currentFileChunk = {};
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
setCurrentDiffFileIndex(index);
|
setCurrentDiffFileIndex(index);
|
||||||
}
|
}
|
||||||
@@ -519,7 +520,7 @@ void DiffEditor::toggleSync()
|
|||||||
IDiffView *DiffEditor::loadSettings()
|
IDiffView *DiffEditor::loadSettings()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(currentView(), return nullptr);
|
QTC_ASSERT(currentView(), return nullptr);
|
||||||
QSettings *s = Core::ICore::settings();
|
QSettings *s = ICore::settings();
|
||||||
|
|
||||||
// Read current settings:
|
// Read current settings:
|
||||||
s->beginGroup(settingsGroupC);
|
s->beginGroup(settingsGroupC);
|
||||||
@@ -539,7 +540,7 @@ IDiffView *DiffEditor::loadSettings()
|
|||||||
|
|
||||||
void DiffEditor::saveSetting(const QString &key, const QVariant &value) const
|
void DiffEditor::saveSetting(const QString &key, const QVariant &value) const
|
||||||
{
|
{
|
||||||
QSettings *s = Core::ICore::settings();
|
QSettings *s = ICore::settings();
|
||||||
s->beginGroup(settingsGroupC);
|
s->beginGroup(settingsGroupC);
|
||||||
s->setValue(key, value);
|
s->setValue(key, value);
|
||||||
s->endGroup();
|
s->endGroup();
|
||||||
|
@@ -63,7 +63,7 @@ Core::IDocument *DiffEditorController::findOrCreateDocument(const QString &vcsId
|
|||||||
{
|
{
|
||||||
QString preferredDisplayName = displayName;
|
QString preferredDisplayName = displayName;
|
||||||
Core::IEditor *editor = Core::EditorManager::openEditorWithContents(
|
Core::IEditor *editor = Core::EditorManager::openEditorWithContents(
|
||||||
Constants::DIFF_EDITOR_ID, &preferredDisplayName, QByteArray(), vcsId);
|
Constants::DIFF_EDITOR_ID, &preferredDisplayName, {}, vcsId);
|
||||||
return editor ? editor->document() : nullptr;
|
return editor ? editor->document() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -63,7 +63,7 @@ protected:
|
|||||||
|
|
||||||
void setDiffFiles(const QList<FileData> &diffFileList,
|
void setDiffFiles(const QList<FileData> &diffFileList,
|
||||||
const Utils::FilePath &baseDirectory = {},
|
const Utils::FilePath &baseDirectory = {},
|
||||||
const QString &startupFile = QString());
|
const QString &startupFile = {});
|
||||||
void setDescription(const QString &description);
|
void setDescription(const QString &description);
|
||||||
QString description() const;
|
QString description() const;
|
||||||
void forceContextLineCount(int lines);
|
void forceContextLineCount(int lines);
|
||||||
|
@@ -120,15 +120,12 @@ QString DiffEditorDocument::makePatch(int fileIndex, int chunkIndex,
|
|||||||
bool revert, bool addPrefix,
|
bool revert, bool addPrefix,
|
||||||
const QString &overriddenFileName) const
|
const QString &overriddenFileName) const
|
||||||
{
|
{
|
||||||
if (fileIndex < 0 || chunkIndex < 0)
|
if (fileIndex < 0 || chunkIndex < 0 || fileIndex >= m_diffFiles.count())
|
||||||
return QString();
|
return {};
|
||||||
|
|
||||||
if (fileIndex >= m_diffFiles.count())
|
|
||||||
return QString();
|
|
||||||
|
|
||||||
const FileData &fileData = m_diffFiles.at(fileIndex);
|
const FileData &fileData = m_diffFiles.at(fileIndex);
|
||||||
if (chunkIndex >= fileData.chunks.count())
|
if (chunkIndex >= fileData.chunks.count())
|
||||||
return QString();
|
return {};
|
||||||
|
|
||||||
const ChunkData chunkData = filterChunk(fileData.chunks.at(chunkIndex), selection, revert);
|
const ChunkData chunkData = filterChunk(fileData.chunks.at(chunkIndex), selection, revert);
|
||||||
const bool lastChunk = (chunkIndex == fileData.chunks.count() - 1);
|
const bool lastChunk = (chunkIndex == fileData.chunks.count() - 1);
|
||||||
@@ -257,12 +254,12 @@ bool DiffEditorDocument::save(QString *errorString, const FilePath &filePath, bo
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
setController(nullptr);
|
setController(nullptr);
|
||||||
setDescription(QString());
|
setDescription({});
|
||||||
Core::EditorManager::clearUniqueId(this);
|
Core::EditorManager::clearUniqueId(this);
|
||||||
|
|
||||||
setTemporary(false);
|
setTemporary(false);
|
||||||
setFilePath(filePath.absoluteFilePath());
|
setFilePath(filePath.absoluteFilePath());
|
||||||
setPreferredDisplayName(QString());
|
setPreferredDisplayName({});
|
||||||
emit temporaryStateChanged();
|
emit temporaryStateChanged();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -393,8 +390,8 @@ void DiffEditorDocument::beginReload()
|
|||||||
m_state = Reloading;
|
m_state = Reloading;
|
||||||
emit changed();
|
emit changed();
|
||||||
QSignalBlocker blocker(this);
|
QSignalBlocker blocker(this);
|
||||||
setDiffFiles(QList<FileData>(), {});
|
setDiffFiles({}, {});
|
||||||
setDescription(QString());
|
setDescription({});
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiffEditorDocument::endReload(bool success)
|
void DiffEditorDocument::endReload(bool success)
|
||||||
|
@@ -35,10 +35,10 @@ public:
|
|||||||
const ChunkSelection &selection, bool revert);
|
const ChunkSelection &selection, bool revert);
|
||||||
QString makePatch(int fileIndex, int chunkIndex, const ChunkSelection &selection,
|
QString makePatch(int fileIndex, int chunkIndex, const ChunkSelection &selection,
|
||||||
bool revert, bool addPrefix = false,
|
bool revert, bool addPrefix = false,
|
||||||
const QString &overriddenFileName = QString()) const;
|
const QString &overriddenFileName = {}) const;
|
||||||
|
|
||||||
void setDiffFiles(const QList<FileData> &data, const Utils::FilePath &directory,
|
void setDiffFiles(const QList<FileData> &data, const Utils::FilePath &directory,
|
||||||
const QString &startupFile = QString());
|
const QString &startupFile = {});
|
||||||
QList<FileData> diffFiles() const;
|
QList<FileData> diffFiles() const;
|
||||||
Utils::FilePath baseDirectory() const;
|
Utils::FilePath baseDirectory() const;
|
||||||
void setBaseDirectory(const Utils::FilePath &directory);
|
void setBaseDirectory(const Utils::FilePath &directory);
|
||||||
|
@@ -146,7 +146,7 @@ void DiffFilesController::cancelReload()
|
|||||||
{
|
{
|
||||||
if (m_futureWatcher.future().isRunning()) {
|
if (m_futureWatcher.future().isRunning()) {
|
||||||
m_futureWatcher.future().cancel();
|
m_futureWatcher.future().cancel();
|
||||||
m_futureWatcher.setFuture(QFuture<FileData>());
|
m_futureWatcher.setFuture({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -850,7 +850,7 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch()
|
|||||||
void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QString>("sourcePatch");
|
QTest::addColumn<QString>("sourcePatch");
|
||||||
QTest::addColumn<QList<FileData> >("fileDataList");
|
QTest::addColumn<QList<FileData>>("fileDataList");
|
||||||
|
|
||||||
QString patch = "diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp\n"
|
QString patch = "diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp\n"
|
||||||
"index eab9e9b..082c135 100644\n"
|
"index eab9e9b..082c135 100644\n"
|
||||||
@@ -1189,11 +1189,11 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
|||||||
" \n"
|
" \n"
|
||||||
;
|
;
|
||||||
|
|
||||||
fileData1 = FileData();
|
fileData1 = {};
|
||||||
fileData1.fileInfo = {DiffFileInfo("src/plugins/texteditor/basetextdocument.h"),
|
fileData1.fileInfo = {DiffFileInfo("src/plugins/texteditor/basetextdocument.h"),
|
||||||
DiffFileInfo("src/plugins/texteditor/textdocument.h")};
|
DiffFileInfo("src/plugins/texteditor/textdocument.h")};
|
||||||
fileData1.fileOperation = FileData::RenameFile;
|
fileData1.fileOperation = FileData::RenameFile;
|
||||||
fileData2 = FileData();
|
fileData2 = {};
|
||||||
fileData2.fileInfo = {DiffFileInfo("src/plugins/texteditor/basetextdocumentlayout.cpp", "0121933"),
|
fileData2.fileInfo = {DiffFileInfo("src/plugins/texteditor/basetextdocumentlayout.cpp", "0121933"),
|
||||||
DiffFileInfo("src/plugins/texteditor/textdocumentlayout.cpp", "01cc3a0")};
|
DiffFileInfo("src/plugins/texteditor/textdocumentlayout.cpp", "01cc3a0")};
|
||||||
fileData2.fileOperation = FileData::RenameFile;
|
fileData2.fileOperation = FileData::RenameFile;
|
||||||
@@ -1224,7 +1224,7 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
|||||||
"-Subproject commit eda76354077a427d692fee05479910de31040d3f\n"
|
"-Subproject commit eda76354077a427d692fee05479910de31040d3f\n"
|
||||||
"+Subproject commit eda76354077a427d692fee05479910de31040d3f-dirty\n"
|
"+Subproject commit eda76354077a427d692fee05479910de31040d3f-dirty\n"
|
||||||
;
|
;
|
||||||
fileData1 = FileData();
|
fileData1 = {};
|
||||||
fileData1.fileInfo = {DiffFileInfo("src/shared/qbs"), DiffFileInfo("src/shared/qbs")};
|
fileData1.fileInfo = {DiffFileInfo("src/shared/qbs"), DiffFileInfo("src/shared/qbs")};
|
||||||
chunkData1.startingLineNumber = {0, 0};
|
chunkData1.startingLineNumber = {0, 0};
|
||||||
rows1.clear();
|
rows1.clear();
|
||||||
@@ -1257,23 +1257,23 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
|||||||
"Binary files /dev/null and b/demos/arthurplugin/flower.jpg differ\n"
|
"Binary files /dev/null and b/demos/arthurplugin/flower.jpg differ\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
fileData1 = FileData();
|
fileData1 = {};
|
||||||
fileData1.fileInfo = {DiffFileInfo("demos/arthurplugin/arthurplugin.pro", "0000000"),
|
fileData1.fileInfo = {DiffFileInfo("demos/arthurplugin/arthurplugin.pro", "0000000"),
|
||||||
DiffFileInfo("demos/arthurplugin/arthurplugin.pro", "c5132b4")};
|
DiffFileInfo("demos/arthurplugin/arthurplugin.pro", "c5132b4")};
|
||||||
fileData1.fileOperation = FileData::NewFile;
|
fileData1.fileOperation = FileData::NewFile;
|
||||||
chunkData1 = ChunkData();
|
chunkData1 = {};
|
||||||
chunkData1.startingLineNumber = {-1, 0};
|
chunkData1.startingLineNumber = {-1, 0};
|
||||||
rows1.clear();
|
rows1.clear();
|
||||||
rows1 << RowData(TextLineData::Separator, _("XXX"));
|
rows1 << RowData(TextLineData::Separator, _("XXX"));
|
||||||
rows1 << RowData(TextLineData::Separator, TextLineData(TextLineData::TextLine));
|
rows1 << RowData(TextLineData::Separator, TextLineData(TextLineData::TextLine));
|
||||||
chunkData1.rows = rows1;
|
chunkData1.rows = rows1;
|
||||||
fileData1.chunks << chunkData1;
|
fileData1.chunks << chunkData1;
|
||||||
fileData2 = FileData();
|
fileData2 = {};
|
||||||
fileData2.fileInfo = {DiffFileInfo("demos/arthurplugin/bg1.jpg", "0000000"),
|
fileData2.fileInfo = {DiffFileInfo("demos/arthurplugin/bg1.jpg", "0000000"),
|
||||||
DiffFileInfo("demos/arthurplugin/bg1.jpg", "dfc7cee")};
|
DiffFileInfo("demos/arthurplugin/bg1.jpg", "dfc7cee")};
|
||||||
fileData2.fileOperation = FileData::NewFile;
|
fileData2.fileOperation = FileData::NewFile;
|
||||||
fileData2.binaryFiles = true;
|
fileData2.binaryFiles = true;
|
||||||
fileData3 = FileData();
|
fileData3 = {};
|
||||||
fileData3.fileInfo = {DiffFileInfo("demos/arthurplugin/flower.jpg", "0000000"),
|
fileData3.fileInfo = {DiffFileInfo("demos/arthurplugin/flower.jpg", "0000000"),
|
||||||
DiffFileInfo("demos/arthurplugin/flower.jpg", "f8e022c")};
|
DiffFileInfo("demos/arthurplugin/flower.jpg", "f8e022c")};
|
||||||
fileData3.fileOperation = FileData::NewFile;
|
fileData3.fileOperation = FileData::NewFile;
|
||||||
@@ -1291,7 +1291,7 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
|||||||
"new mode 100755\n"
|
"new mode 100755\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
fileData1 = FileData();
|
fileData1 = {};
|
||||||
fileData1.fileInfo = {DiffFileInfo("script.sh"), DiffFileInfo("script.sh")};
|
fileData1.fileInfo = {DiffFileInfo("script.sh"), DiffFileInfo("script.sh")};
|
||||||
fileData1.fileOperation = FileData::ChangeMode;
|
fileData1.fileOperation = FileData::ChangeMode;
|
||||||
|
|
||||||
@@ -1310,7 +1310,7 @@ rename to new.sh
|
|||||||
)"
|
)"
|
||||||
;
|
;
|
||||||
|
|
||||||
fileData1 = FileData();
|
fileData1 = {};
|
||||||
fileData1.fileInfo = {DiffFileInfo("old.sh"), DiffFileInfo("new.sh")};
|
fileData1.fileInfo = {DiffFileInfo("old.sh"), DiffFileInfo("new.sh")};
|
||||||
fileData1.fileOperation = FileData::RenameFile;
|
fileData1.fileOperation = FileData::RenameFile;
|
||||||
|
|
||||||
@@ -1327,10 +1327,10 @@ rename to new.sh
|
|||||||
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 0)\n"
|
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 0)\n"
|
||||||
"+++ src/plugins/subversion/subversioneditor.cpp\t(revision 0)\n"
|
"+++ src/plugins/subversion/subversioneditor.cpp\t(revision 0)\n"
|
||||||
"@@ -0,0 +125 @@\n\n";
|
"@@ -0,0 +125 @@\n\n";
|
||||||
fileData1 = FileData();
|
fileData1 = {};
|
||||||
fileData1.fileInfo = {DiffFileInfo("src/plugins/subversion/subversioneditor.cpp"),
|
fileData1.fileInfo = {DiffFileInfo("src/plugins/subversion/subversioneditor.cpp"),
|
||||||
DiffFileInfo("src/plugins/subversion/subversioneditor.cpp")};
|
DiffFileInfo("src/plugins/subversion/subversioneditor.cpp")};
|
||||||
chunkData1 = ChunkData();
|
chunkData1 = {};
|
||||||
chunkData1.startingLineNumber = {-1, 124};
|
chunkData1.startingLineNumber = {-1, 124};
|
||||||
fileData1.chunks << chunkData1;
|
fileData1.chunks << chunkData1;
|
||||||
QList<FileData> fileDataList21;
|
QList<FileData> fileDataList21;
|
||||||
@@ -1346,10 +1346,10 @@ rename to new.sh
|
|||||||
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 42)\n"
|
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 42)\n"
|
||||||
"+++ src/plugins/subversion/subversioneditor.cpp\t(working copy)\n"
|
"+++ src/plugins/subversion/subversioneditor.cpp\t(working copy)\n"
|
||||||
"@@ -1,125 +0,0 @@\n\n";
|
"@@ -1,125 +0,0 @@\n\n";
|
||||||
fileData1 = FileData();
|
fileData1 = {};
|
||||||
fileData1.fileInfo = {DiffFileInfo("src/plugins/subversion/subversioneditor.cpp"),
|
fileData1.fileInfo = {DiffFileInfo("src/plugins/subversion/subversioneditor.cpp"),
|
||||||
DiffFileInfo("src/plugins/subversion/subversioneditor.cpp")};
|
DiffFileInfo("src/plugins/subversion/subversioneditor.cpp")};
|
||||||
chunkData1 = ChunkData();
|
chunkData1 = {};
|
||||||
chunkData1.startingLineNumber = {0, -1};
|
chunkData1.startingLineNumber = {0, -1};
|
||||||
fileData1.chunks << chunkData1;
|
fileData1.chunks << chunkData1;
|
||||||
QList<FileData> fileDataList22;
|
QList<FileData> fileDataList22;
|
||||||
@@ -1365,10 +1365,10 @@ rename to new.sh
|
|||||||
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 42)\n"
|
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 42)\n"
|
||||||
"+++ src/plugins/subversion/subversioneditor.cpp\t(working copy)\n"
|
"+++ src/plugins/subversion/subversioneditor.cpp\t(working copy)\n"
|
||||||
"@@ -120,7 +120,7 @@\n\n";
|
"@@ -120,7 +120,7 @@\n\n";
|
||||||
fileData1 = FileData();
|
fileData1 = {};
|
||||||
fileData1.fileInfo = {DiffFileInfo("src/plugins/subversion/subversioneditor.cpp"),
|
fileData1.fileInfo = {DiffFileInfo("src/plugins/subversion/subversioneditor.cpp"),
|
||||||
DiffFileInfo("src/plugins/subversion/subversioneditor.cpp")};
|
DiffFileInfo("src/plugins/subversion/subversioneditor.cpp")};
|
||||||
chunkData1 = ChunkData();
|
chunkData1 = {};
|
||||||
chunkData1.startingLineNumber = {119, 119};
|
chunkData1.startingLineNumber = {119, 119};
|
||||||
fileData1.chunks << chunkData1;
|
fileData1.chunks << chunkData1;
|
||||||
QList<FileData> fileDataList23;
|
QList<FileData> fileDataList23;
|
||||||
@@ -1425,7 +1425,7 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
|||||||
QTest::addColumn<ChunkSelection>("selection");
|
QTest::addColumn<ChunkSelection>("selection");
|
||||||
QTest::addColumn<bool>("revert");
|
QTest::addColumn<bool>("revert");
|
||||||
|
|
||||||
auto createChunk = []() {
|
auto createChunk = [] {
|
||||||
ChunkData chunk;
|
ChunkData chunk;
|
||||||
chunk.contextInfo = "void DiffEditor::ctor()";
|
chunk.contextInfo = "void DiffEditor::ctor()";
|
||||||
chunk.contextChunk = false;
|
chunk.contextChunk = false;
|
||||||
|
@@ -164,7 +164,7 @@ void DiffEditorWidgetController::patch(bool revert, int fileIndex, int chunkInde
|
|||||||
if (patchBehaviour == DiffFileInfo::PatchFile) {
|
if (patchBehaviour == DiffFileInfo::PatchFile) {
|
||||||
const int strip = m_document->baseDirectory().isEmpty() ? -1 : 0;
|
const int strip = m_document->baseDirectory().isEmpty() ? -1 : 0;
|
||||||
|
|
||||||
const QString patch = m_document->makePatch(fileIndex, chunkIndex, ChunkSelection(), revert);
|
const QString patch = m_document->makePatch(fileIndex, chunkIndex, {}, revert);
|
||||||
|
|
||||||
if (patch.isEmpty())
|
if (patch.isEmpty())
|
||||||
return;
|
return;
|
||||||
@@ -190,7 +190,7 @@ void DiffEditorWidgetController::patch(bool revert, int fileIndex, int chunkInde
|
|||||||
const QString contentsCopyDir = QFileInfo(contentsCopyFileName).absolutePath();
|
const QString contentsCopyDir = QFileInfo(contentsCopyFileName).absolutePath();
|
||||||
|
|
||||||
const QString patch = m_document->makePatch(fileIndex, chunkIndex,
|
const QString patch = m_document->makePatch(fileIndex, chunkIndex,
|
||||||
ChunkSelection(), revert, false,
|
{}, revert, false,
|
||||||
QFileInfo(contentsCopyFileName).fileName());
|
QFileInfo(contentsCopyFileName).fileName());
|
||||||
|
|
||||||
if (patch.isEmpty())
|
if (patch.isEmpty())
|
||||||
@@ -251,18 +251,12 @@ bool DiffEditorWidgetController::chunkExists(int fileIndex, int chunkIndex) cons
|
|||||||
|
|
||||||
ChunkData DiffEditorWidgetController::chunkData(int fileIndex, int chunkIndex) const
|
ChunkData DiffEditorWidgetController::chunkData(int fileIndex, int chunkIndex) const
|
||||||
{
|
{
|
||||||
if (!m_document)
|
if (!m_document || fileIndex < 0 || chunkIndex < 0 || fileIndex >= m_contextFileData.count())
|
||||||
return ChunkData();
|
return {};
|
||||||
|
|
||||||
if (fileIndex < 0 || chunkIndex < 0)
|
|
||||||
return ChunkData();
|
|
||||||
|
|
||||||
if (fileIndex >= m_contextFileData.count())
|
|
||||||
return ChunkData();
|
|
||||||
|
|
||||||
const FileData fileData = m_contextFileData.at(fileIndex);
|
const FileData fileData = m_contextFileData.at(fileIndex);
|
||||||
if (chunkIndex >= fileData.chunks.count())
|
if (chunkIndex >= fileData.chunks.count())
|
||||||
return ChunkData();
|
return {};
|
||||||
|
|
||||||
return fileData.chunks.at(chunkIndex);
|
return fileData.chunks.at(chunkIndex);
|
||||||
}
|
}
|
||||||
@@ -328,8 +322,7 @@ void DiffEditorWidgetController::sendChunkToCodePaster(int fileIndex, int chunkI
|
|||||||
auto pasteService = ExtensionSystem::PluginManager::getObject<CodePaster::Service>();
|
auto pasteService = ExtensionSystem::PluginManager::getObject<CodePaster::Service>();
|
||||||
QTC_ASSERT(pasteService, return);
|
QTC_ASSERT(pasteService, return);
|
||||||
|
|
||||||
const QString patch = m_document->makePatch(fileIndex, chunkIndex,
|
const QString patch = m_document->makePatch(fileIndex, chunkIndex, {}, false);
|
||||||
ChunkSelection(), false);
|
|
||||||
|
|
||||||
if (patch.isEmpty())
|
if (patch.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@@ -38,12 +38,8 @@ static QList<TextLineData> assemblyRows(const QList<TextLineData> &lines,
|
|||||||
static bool lastLinesEqual(const QList<TextLineData> &leftLines,
|
static bool lastLinesEqual(const QList<TextLineData> &leftLines,
|
||||||
const QList<TextLineData> &rightLines)
|
const QList<TextLineData> &rightLines)
|
||||||
{
|
{
|
||||||
const bool leftLineEqual = !leftLines.isEmpty()
|
const bool leftLineEqual = leftLines.isEmpty() || leftLines.last().text.isEmpty();
|
||||||
? leftLines.last().text.isEmpty()
|
const bool rightLineEqual = rightLines.isEmpty() || rightLines.last().text.isEmpty();
|
||||||
: true;
|
|
||||||
const bool rightLineEqual = !rightLines.isEmpty()
|
|
||||||
? rightLines.last().text.isEmpty()
|
|
||||||
: true;
|
|
||||||
return leftLineEqual && rightLineEqual;
|
return leftLineEqual && rightLineEqual;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,10 +203,8 @@ ChunkData DiffUtils::calculateOriginalData(const QList<Diff> &leftDiffList,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<TextLineData> leftData = assemblyRows(leftLines,
|
QList<TextLineData> leftData = assemblyRows(leftLines, leftSpans);
|
||||||
leftSpans);
|
QList<TextLineData> rightData = assemblyRows(rightLines, rightSpans);
|
||||||
QList<TextLineData> rightData = assemblyRows(rightLines,
|
|
||||||
rightSpans);
|
|
||||||
|
|
||||||
// fill ending separators
|
// fill ending separators
|
||||||
for (int i = leftData.size(); i < rightData.size(); i++)
|
for (int i = leftData.size(); i < rightData.size(); i++)
|
||||||
@@ -334,7 +328,7 @@ QString DiffUtils::makePatch(const ChunkData &chunkData,
|
|||||||
bool lastChunk)
|
bool lastChunk)
|
||||||
{
|
{
|
||||||
if (chunkData.contextChunk)
|
if (chunkData.contextChunk)
|
||||||
return QString();
|
return {};
|
||||||
|
|
||||||
QString diffText;
|
QString diffText;
|
||||||
int leftLineCount = 0;
|
int leftLineCount = 0;
|
||||||
@@ -623,7 +617,7 @@ static QList<RowData> readLines(QStringView patch, bool lastChunk, bool *lastChu
|
|||||||
|| (noNewLineInInsert >= 0 && (noNewLineInInsert != lastInsert || lastEqual > lastInsert))) {
|
|| (noNewLineInInsert >= 0 && (noNewLineInInsert != lastInsert || lastEqual > lastInsert))) {
|
||||||
if (ok)
|
if (ok)
|
||||||
*ok = false;
|
*ok = false;
|
||||||
return QList<RowData>();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
@@ -712,7 +706,7 @@ static QStringView readLine(QStringView text, QStringView *remainingText, bool *
|
|||||||
const int indexOfFirstNewLine = text.indexOf(newLine);
|
const int indexOfFirstNewLine = text.indexOf(newLine);
|
||||||
if (indexOfFirstNewLine < 0) {
|
if (indexOfFirstNewLine < 0) {
|
||||||
if (remainingText)
|
if (remainingText)
|
||||||
*remainingText = QStringView();
|
*remainingText = {};
|
||||||
if (hasNewLine)
|
if (hasNewLine)
|
||||||
*hasNewLine = false;
|
*hasNewLine = false;
|
||||||
return text;
|
return text;
|
||||||
@@ -880,7 +874,7 @@ static FileData readDiffHeaderAndChunks(QStringView headerAndChunks, bool *ok)
|
|||||||
*ok = readOk;
|
*ok = readOk;
|
||||||
|
|
||||||
if (!readOk)
|
if (!readOk)
|
||||||
return FileData();
|
return {};
|
||||||
|
|
||||||
return fileData;
|
return fileData;
|
||||||
|
|
||||||
@@ -914,7 +908,7 @@ static QList<FileData> readDiffPatch(QStringView patch, bool *ok, QFutureInterfa
|
|||||||
int lastPos = -1;
|
int lastPos = -1;
|
||||||
do {
|
do {
|
||||||
if (jobController && jobController->isCanceled())
|
if (jobController && jobController->isCanceled())
|
||||||
return QList<FileData>();
|
return {};
|
||||||
|
|
||||||
int pos = diffMatch.capturedStart();
|
int pos = diffMatch.capturedStart();
|
||||||
if (lastPos >= 0) {
|
if (lastPos >= 0) {
|
||||||
@@ -948,7 +942,7 @@ static QList<FileData> readDiffPatch(QStringView patch, bool *ok, QFutureInterfa
|
|||||||
*ok = readOk;
|
*ok = readOk;
|
||||||
|
|
||||||
if (!readOk)
|
if (!readOk)
|
||||||
return QList<FileData>();
|
return {};
|
||||||
|
|
||||||
return fileDataList;
|
return fileDataList;
|
||||||
}
|
}
|
||||||
@@ -1044,7 +1038,7 @@ static bool detectIndexAndBinary(QStringView patch, FileData *fileData, QStringV
|
|||||||
|
|
||||||
if (*remainingPatch == binaryLine) {
|
if (*remainingPatch == binaryLine) {
|
||||||
fileData->binaryFiles = true;
|
fileData->binaryFiles = true;
|
||||||
*remainingPatch = QStringView();
|
*remainingPatch = {};
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1225,7 +1219,7 @@ static QList<FileData> readGitPatch(QStringView patch, bool *ok, QFutureInterfac
|
|||||||
const int count = startingPositions.size();
|
const int count = startingPositions.size();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if (jobController && jobController->isCanceled())
|
if (jobController && jobController->isCanceled())
|
||||||
return QList<FileData>();
|
return {};
|
||||||
|
|
||||||
const int diffStart = startingPositions.at(i);
|
const int diffStart = startingPositions.at(i);
|
||||||
const int diffEnd = (i < count - 1)
|
const int diffEnd = (i < count - 1)
|
||||||
@@ -1251,7 +1245,7 @@ static QList<FileData> readGitPatch(QStringView patch, bool *ok, QFutureInterfac
|
|||||||
if (!readOk) {
|
if (!readOk) {
|
||||||
if (ok)
|
if (ok)
|
||||||
*ok = readOk;
|
*ok = readOk;
|
||||||
return QList<FileData>();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jobController)
|
if (jobController)
|
||||||
@@ -1263,7 +1257,7 @@ static QList<FileData> readGitPatch(QStringView patch, bool *ok, QFutureInterfac
|
|||||||
for (const auto &patchInfo : qAsConst(patches)) {
|
for (const auto &patchInfo : qAsConst(patches)) {
|
||||||
if (jobController) {
|
if (jobController) {
|
||||||
if (jobController->isCanceled())
|
if (jobController->isCanceled())
|
||||||
return QList<FileData>();
|
return {};
|
||||||
jobController->setProgressValue(i++);
|
jobController->setProgressValue(i++);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1283,7 +1277,7 @@ static QList<FileData> readGitPatch(QStringView patch, bool *ok, QFutureInterfac
|
|||||||
*ok = readOk;
|
*ok = readOk;
|
||||||
|
|
||||||
if (!readOk)
|
if (!readOk)
|
||||||
return QList<FileData>();
|
return {};
|
||||||
|
|
||||||
return fileDataList;
|
return fileDataList;
|
||||||
}
|
}
|
||||||
|
@@ -31,11 +31,11 @@ static QList<DiffSelection> subtractSelection(
|
|||||||
{
|
{
|
||||||
// tha case that whole minuend is before the whole subtrahend
|
// tha case that whole minuend is before the whole subtrahend
|
||||||
if (minuendSelection.end >= 0 && minuendSelection.end <= subtrahendSelection.start)
|
if (minuendSelection.end >= 0 && minuendSelection.end <= subtrahendSelection.start)
|
||||||
return QList<DiffSelection>() << minuendSelection;
|
return {minuendSelection};
|
||||||
|
|
||||||
// the case that whole subtrahend is before the whole minuend
|
// the case that whole subtrahend is before the whole minuend
|
||||||
if (subtrahendSelection.end >= 0 && subtrahendSelection.end <= minuendSelection.start)
|
if (subtrahendSelection.end >= 0 && subtrahendSelection.end <= minuendSelection.start)
|
||||||
return QList<DiffSelection>() << minuendSelection;
|
return {minuendSelection};
|
||||||
|
|
||||||
bool makeMinuendSubtrahendStart = false;
|
bool makeMinuendSubtrahendStart = false;
|
||||||
bool makeSubtrahendMinuendEnd = false;
|
bool makeSubtrahendMinuendEnd = false;
|
||||||
|
@@ -39,7 +39,6 @@ public:
|
|||||||
SideDiffEditorWidget(QWidget *parent = nullptr);
|
SideDiffEditorWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void clearAll(const QString &message);
|
void clearAll(const QString &message);
|
||||||
void clearAllData();
|
|
||||||
void saveState();
|
void saveState();
|
||||||
using TextEditor::TextEditorWidget::restoreState;
|
using TextEditor::TextEditorWidget::restoreState;
|
||||||
void restoreState();
|
void restoreState();
|
||||||
@@ -193,7 +192,7 @@ QString SideDiffEditorWidget::lineNumber(int blockNumber) const
|
|||||||
const auto it = m_data.m_lineNumbers.constFind(blockNumber);
|
const auto it = m_data.m_lineNumbers.constFind(blockNumber);
|
||||||
if (it != m_data.m_lineNumbers.constEnd())
|
if (it != m_data.m_lineNumbers.constEnd())
|
||||||
return QString::number(it.value());
|
return QString::number(it.value());
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
int SideDiffEditorWidget::lineNumberDigits() const
|
int SideDiffEditorWidget::lineNumberDigits() const
|
||||||
@@ -223,7 +222,7 @@ QString SideDiffEditorWidget::plainTextFromSelection(const QTextCursor &cursor)
|
|||||||
const int startPosition = cursor.selectionStart();
|
const int startPosition = cursor.selectionStart();
|
||||||
const int endPosition = cursor.selectionEnd();
|
const int endPosition = cursor.selectionEnd();
|
||||||
if (startPosition == endPosition)
|
if (startPosition == endPosition)
|
||||||
return QString(); // no selection
|
return {}; // no selection
|
||||||
|
|
||||||
const QTextBlock startBlock = document()->findBlock(startPosition);
|
const QTextBlock startBlock = document()->findBlock(startPosition);
|
||||||
const QTextBlock endBlock = document()->findBlock(endPosition);
|
const QTextBlock endBlock = document()->findBlock(endPosition);
|
||||||
@@ -344,16 +343,10 @@ int SideDiffData::chunkRowsCountForBlockNumber(int blockNumber) const
|
|||||||
void SideDiffEditorWidget::clearAll(const QString &message)
|
void SideDiffEditorWidget::clearAll(const QString &message)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
clearAllData();
|
|
||||||
setExtraSelections(TextEditorWidget::OtherSelection,
|
|
||||||
QList<QTextEdit::ExtraSelection>());
|
|
||||||
setPlainText(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SideDiffEditorWidget::clearAllData()
|
|
||||||
{
|
|
||||||
m_data = {};
|
m_data = {};
|
||||||
setSelections({});
|
setSelections({});
|
||||||
|
setExtraSelections(TextEditorWidget::OtherSelection, {});
|
||||||
|
setPlainText(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SideDiffEditorWidget::scrollContentsBy(int dx, int dy)
|
void SideDiffEditorWidget::scrollContentsBy(int dx, int dy)
|
||||||
@@ -544,7 +537,7 @@ void SideDiffEditorWidget::paintEvent(QPaintEvent *e)
|
|||||||
m_drawCollapsedOffset,
|
m_drawCollapsedOffset,
|
||||||
m_drawCollapsedClip);
|
m_drawCollapsedClip);
|
||||||
// reset the data for the drawing
|
// reset the data for the drawing
|
||||||
m_drawCollapsedBlock = QTextBlock();
|
m_drawCollapsedBlock = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,8 +558,8 @@ void SideDiffEditorWidget::customDrawCollapsedBlockPopup(QPainter &painter,
|
|||||||
QRectF r = blockBoundingRect(b).translated(offset);
|
QRectF r = blockBoundingRect(b).translated(offset);
|
||||||
|
|
||||||
QTextLayout *layout = b.layout();
|
QTextLayout *layout = b.layout();
|
||||||
for (int i = layout->lineCount()-1; i >= 0; --i)
|
for (int i = layout->lineCount() - 1; i >= 0; --i)
|
||||||
maxWidth = qMax(maxWidth, layout->lineAt(i).naturalTextWidth() + 2*margin);
|
maxWidth = qMax(maxWidth, layout->lineAt(i).naturalTextWidth() + 2 * margin);
|
||||||
|
|
||||||
blockHeight += r.height();
|
blockHeight += r.height();
|
||||||
|
|
||||||
@@ -585,9 +578,8 @@ void SideDiffEditorWidget::customDrawCollapsedBlockPopup(QPainter &painter,
|
|||||||
if (ifdefedOutFormat.hasProperty(QTextFormat::BackgroundBrush))
|
if (ifdefedOutFormat.hasProperty(QTextFormat::BackgroundBrush))
|
||||||
brush = ifdefedOutFormat.background();
|
brush = ifdefedOutFormat.background();
|
||||||
painter.setBrush(brush);
|
painter.setBrush(brush);
|
||||||
painter.drawRoundedRect(QRectF(offset.x(),
|
painter.drawRoundedRect(QRectF(offset.x(), offset.y(), maxWidth, blockHeight)
|
||||||
offset.y(),
|
.adjusted(0, 0, 0, 0), 3, 3);
|
||||||
maxWidth, blockHeight).adjusted(0, 0, 0, 0), 3, 3);
|
|
||||||
painter.restore();
|
painter.restore();
|
||||||
|
|
||||||
QTextBlock end = b;
|
QTextBlock end = b;
|
||||||
@@ -782,7 +774,7 @@ DiffEditorDocument *SideBySideDiffEditorWidget::diffDocument() const
|
|||||||
void SideBySideDiffEditorWidget::clear(const QString &message)
|
void SideBySideDiffEditorWidget::clear(const QString &message)
|
||||||
{
|
{
|
||||||
const GuardLocker locker(m_controller.m_ignoreChanges);
|
const GuardLocker locker(m_controller.m_ignoreChanges);
|
||||||
setDiff(QList<FileData>());
|
setDiff({});
|
||||||
m_leftEditor->clearAll(message);
|
m_leftEditor->clearAll(message);
|
||||||
m_rightEditor->clearAll(message);
|
m_rightEditor->clearAll(message);
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,7 @@ public:
|
|||||||
|
|
||||||
void setLineNumber(int blockNumber, int lineNumber);
|
void setLineNumber(int blockNumber, int lineNumber);
|
||||||
void setFileInfo(int blockNumber, const DiffFileInfo &fileInfo);
|
void setFileInfo(int blockNumber, const DiffFileInfo &fileInfo);
|
||||||
void setSkippedLines(int blockNumber, int skippedLines, const QString &contextInfo = QString()) {
|
void setSkippedLines(int blockNumber, int skippedLines, const QString &contextInfo = {}) {
|
||||||
m_skippedLines[blockNumber] = qMakePair(skippedLines, contextInfo);
|
m_skippedLines[blockNumber] = qMakePair(skippedLines, contextInfo);
|
||||||
setSeparator(blockNumber, true);
|
setSeparator(blockNumber, true);
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ public:
|
|||||||
void saveState();
|
void saveState();
|
||||||
void restoreState();
|
void restoreState();
|
||||||
|
|
||||||
void clear(const QString &message = QString());
|
void clear(const QString &message = {});
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentDiffFileIndexChanged(int index);
|
void currentDiffFileIndexChanged(int index);
|
||||||
|
@@ -304,7 +304,7 @@ QString UnifiedDiffData::setChunk(const DiffEditorInput &input, const ChunkData
|
|||||||
DiffSelections *selections)
|
DiffSelections *selections)
|
||||||
{
|
{
|
||||||
if (chunkData.contextChunk)
|
if (chunkData.contextChunk)
|
||||||
return QString();
|
return {};
|
||||||
|
|
||||||
QString diffText;
|
QString diffText;
|
||||||
int leftLineCount = 0;
|
int leftLineCount = 0;
|
||||||
@@ -341,8 +341,7 @@ QString UnifiedDiffData::setChunk(const DiffEditorInput &input, const ChunkData
|
|||||||
'-',
|
'-',
|
||||||
lineData.text,
|
lineData.text,
|
||||||
lastChunk,
|
lastChunk,
|
||||||
i == chunkData.rows.count()
|
i == chunkData.rows.count() && j == leftBuffer.count() - 1);
|
||||||
&& j == leftBuffer.count() - 1);
|
|
||||||
|
|
||||||
const int blockDelta = line.count('\n'); // no new line
|
const int blockDelta = line.count('\n'); // no new line
|
||||||
// could have been added
|
// could have been added
|
||||||
@@ -351,10 +350,8 @@ QString UnifiedDiffData::setChunk(const DiffEditorInput &input, const ChunkData
|
|||||||
|
|
||||||
for (auto it = lineData.changedPositions.cbegin(),
|
for (auto it = lineData.changedPositions.cbegin(),
|
||||||
end = lineData.changedPositions.cend(); it != end; ++it) {
|
end = lineData.changedPositions.cend(); it != end; ++it) {
|
||||||
const int startPos = it.key() < 0
|
const int startPos = it.key() < 0 ? 1 : it.key() + 1;
|
||||||
? 1 : it.key() + 1;
|
const int endPos = it.value() < 0 ? it.value() : it.value() + 1;
|
||||||
const int endPos = it.value() < 0
|
|
||||||
? it.value() : it.value() + 1;
|
|
||||||
(*selections)[*blockNumber + blockCount + 1].append(
|
(*selections)[*blockNumber + blockCount + 1].append(
|
||||||
DiffSelection(startPos, endPos, input.m_leftCharFormat));
|
DiffSelection(startPos, endPos, input.m_leftCharFormat));
|
||||||
}
|
}
|
||||||
@@ -382,8 +379,7 @@ QString UnifiedDiffData::setChunk(const DiffEditorInput &input, const ChunkData
|
|||||||
'+',
|
'+',
|
||||||
lineData.text,
|
lineData.text,
|
||||||
lastChunk,
|
lastChunk,
|
||||||
i == chunkData.rows.count()
|
i == chunkData.rows.count() && j == rightBuffer.count() - 1);
|
||||||
&& j == rightBuffer.count() - 1);
|
|
||||||
|
|
||||||
const int blockDelta = line.count('\n'); // no new line
|
const int blockDelta = line.count('\n'); // no new line
|
||||||
// could have been added
|
// could have been added
|
||||||
@@ -393,10 +389,8 @@ QString UnifiedDiffData::setChunk(const DiffEditorInput &input, const ChunkData
|
|||||||
|
|
||||||
for (auto it = lineData.changedPositions.cbegin(),
|
for (auto it = lineData.changedPositions.cbegin(),
|
||||||
end = lineData.changedPositions.cend(); it != end; ++it) {
|
end = lineData.changedPositions.cend(); it != end; ++it) {
|
||||||
const int startPos = it.key() < 0
|
const int startPos = it.key() < 0 ? 1 : it.key() + 1;
|
||||||
? 1 : it.key() + 1;
|
const int endPos = it.value() < 0 ? it.value() : it.value() + 1;
|
||||||
const int endPos = it.value() < 0
|
|
||||||
? it.value() : it.value() + 1;
|
|
||||||
(*selections)[*blockNumber + blockCount + 1].append
|
(*selections)[*blockNumber + blockCount + 1].append
|
||||||
(DiffSelection(startPos, endPos, input.m_rightCharFormat));
|
(DiffSelection(startPos, endPos, input.m_rightCharFormat));
|
||||||
}
|
}
|
||||||
|
@@ -79,7 +79,7 @@ public:
|
|||||||
using TextEditor::TextEditorWidget::restoreState;
|
using TextEditor::TextEditorWidget::restoreState;
|
||||||
void restoreState();
|
void restoreState();
|
||||||
|
|
||||||
void clear(const QString &message = QString());
|
void clear(const QString &message = {});
|
||||||
void setDisplaySettings(const TextEditor::DisplaySettings &ds) override;
|
void setDisplaySettings(const TextEditor::DisplaySettings &ds) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
Reference in New Issue
Block a user