forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
namespace DiffEditor {
|
||||
@@ -55,7 +56,8 @@ QString DiffEditorController::makePatch(int fileIndex, int chunkIndex,
|
||||
PatchOptions options) const
|
||||
{
|
||||
return m_document->makePatch(fileIndex, chunkIndex, selection,
|
||||
options & Revert, options & AddPrefix);
|
||||
(options & Revert) ? PatchAction::Revert : PatchAction::Apply,
|
||||
options & AddPrefix);
|
||||
}
|
||||
|
||||
Core::IDocument *DiffEditorController::findOrCreateDocument(const QString &vcsId,
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <QTextCodec>
|
||||
#include <QUuid>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
namespace DiffEditor {
|
||||
@@ -63,8 +64,8 @@ static void appendRow(ChunkData *chunk, const RowData &row)
|
||||
chunk->rows.append(row);
|
||||
}
|
||||
|
||||
ChunkData DiffEditorDocument::filterChunk(const ChunkData &data,
|
||||
const ChunkSelection &selection, bool revert)
|
||||
ChunkData DiffEditorDocument::filterChunk(const ChunkData &data, const ChunkSelection &selection,
|
||||
PatchAction patchAction)
|
||||
{
|
||||
if (selection.isNull())
|
||||
return data;
|
||||
@@ -85,13 +86,13 @@ ChunkData DiffEditorDocument::filterChunk(const ChunkData &data,
|
||||
row.line[RightSide] = TextLineData(TextLineData::Separator);
|
||||
appendRow(&chunk, row);
|
||||
|
||||
if (revert) {
|
||||
if (patchAction == PatchAction::Revert) {
|
||||
newRow.line[LeftSide] = newRow.line[RightSide];
|
||||
newRow.equal = true;
|
||||
appendRow(&chunk, newRow);
|
||||
}
|
||||
} else { // isRightSelected
|
||||
if (!revert) {
|
||||
if (patchAction == PatchAction::Apply) {
|
||||
RowData newRow = row;
|
||||
newRow.line[RightSide] = newRow.line[LeftSide];
|
||||
newRow.equal = true;
|
||||
@@ -102,10 +103,10 @@ ChunkData DiffEditorDocument::filterChunk(const ChunkData &data,
|
||||
appendRow(&chunk, row);
|
||||
}
|
||||
} else {
|
||||
if (revert)
|
||||
row.line[LeftSide] = row.line[RightSide];
|
||||
else
|
||||
if (patchAction == PatchAction::Apply)
|
||||
row.line[RightSide] = row.line[LeftSide];
|
||||
else
|
||||
row.line[LeftSide] = row.line[RightSide];
|
||||
row.equal = true;
|
||||
appendRow(&chunk, row);
|
||||
}
|
||||
@@ -115,9 +116,8 @@ ChunkData DiffEditorDocument::filterChunk(const ChunkData &data,
|
||||
}
|
||||
|
||||
QString DiffEditorDocument::makePatch(int fileIndex, int chunkIndex,
|
||||
const ChunkSelection &selection,
|
||||
bool revert, bool addPrefix,
|
||||
const QString &overriddenFileName) const
|
||||
const ChunkSelection &selection, PatchAction patchAction,
|
||||
bool addPrefix, const QString &overriddenFileName) const
|
||||
{
|
||||
if (fileIndex < 0 || chunkIndex < 0 || fileIndex >= m_diffFiles.count())
|
||||
return {};
|
||||
@@ -126,22 +126,16 @@ QString DiffEditorDocument::makePatch(int fileIndex, int chunkIndex,
|
||||
if (chunkIndex >= fileData.chunks.count())
|
||||
return {};
|
||||
|
||||
const ChunkData chunkData = filterChunk(fileData.chunks.at(chunkIndex), selection, revert);
|
||||
const ChunkData chunkData = filterChunk(fileData.chunks.at(chunkIndex), selection, patchAction);
|
||||
const bool lastChunk = (chunkIndex == fileData.chunks.count() - 1);
|
||||
|
||||
const QString fileName = !overriddenFileName.isEmpty()
|
||||
? overriddenFileName : revert
|
||||
? fileData.fileInfo[RightSide].fileName
|
||||
: fileData.fileInfo[LeftSide].fileName;
|
||||
? overriddenFileName : patchAction == PatchAction::Apply
|
||||
? fileData.fileInfo[LeftSide].fileName : fileData.fileInfo[RightSide].fileName;
|
||||
|
||||
QString leftPrefix, rightPrefix;
|
||||
if (addPrefix) {
|
||||
leftPrefix = "a/";
|
||||
rightPrefix = "b/";
|
||||
}
|
||||
return DiffUtils::makePatch(chunkData,
|
||||
leftPrefix + fileName,
|
||||
rightPrefix + fileName,
|
||||
const QString leftFileName = addPrefix ? QString("a/") + fileName : fileName;
|
||||
const QString rightFileName = addPrefix ? QString("b/") + fileName : fileName;
|
||||
return DiffUtils::makePatch(chunkData, leftFileName, rightFileName,
|
||||
lastChunk && fileData.lastChunkAtTheEndOfFile);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "diffutils.h"
|
||||
|
||||
#include <coreplugin/patchtool.h>
|
||||
#include <coreplugin/textdocument.h>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QMenu)
|
||||
@@ -31,10 +32,10 @@ public:
|
||||
LoadFailed
|
||||
};
|
||||
|
||||
static ChunkData filterChunk(const ChunkData &data,
|
||||
const ChunkSelection &selection, bool revert);
|
||||
static ChunkData filterChunk(const ChunkData &data, const ChunkSelection &selection,
|
||||
Core::PatchAction patchAction);
|
||||
QString makePatch(int fileIndex, int chunkIndex, const ChunkSelection &selection,
|
||||
bool revert, bool addPrefix = false,
|
||||
Core::PatchAction patchAction, bool addPrefix = false,
|
||||
const QString &overriddenFileName = {}) const;
|
||||
|
||||
void setDiffFiles(const QList<FileData> &data, const Utils::FilePath &directory,
|
||||
|
||||
@@ -1421,7 +1421,7 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
QTest::addColumn<ChunkData>("chunk");
|
||||
QTest::addColumn<ListOfStringPairs>("rows");
|
||||
QTest::addColumn<ChunkSelection>("selection");
|
||||
QTest::addColumn<bool>("revert");
|
||||
QTest::addColumn<PatchAction>("patchAction");
|
||||
|
||||
auto createChunk = [] {
|
||||
ChunkData chunk;
|
||||
@@ -1451,7 +1451,7 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
{"", "B"},
|
||||
{"C", "C"}
|
||||
};
|
||||
QTest::newRow("one added") << chunk << rows << ChunkSelection() << false;
|
||||
QTest::newRow("one added") << chunk << rows << ChunkSelection() << PatchAction::Apply;
|
||||
|
||||
chunk = createChunk();
|
||||
appendRow(&chunk, "A", "A"); // 50
|
||||
@@ -1462,7 +1462,7 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
{"B", ""},
|
||||
{"C", "C"}
|
||||
};
|
||||
QTest::newRow("one removed") << chunk << rows << ChunkSelection() << false;
|
||||
QTest::newRow("one removed") << chunk << rows << ChunkSelection() << PatchAction::Apply;
|
||||
|
||||
chunk = createChunk();
|
||||
appendRow(&chunk, "A", "A"); // 50
|
||||
@@ -1477,7 +1477,8 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
{"", "D"},
|
||||
{"F", "F"}
|
||||
};
|
||||
QTest::newRow("stage selected added") << chunk << rows << ChunkSelection({2, 3}, {2, 3}) << false;
|
||||
QTest::newRow("stage selected added") << chunk << rows << ChunkSelection({2, 3}, {2, 3})
|
||||
<< PatchAction::Apply;
|
||||
|
||||
chunk = createChunk();
|
||||
appendRow(&chunk, "A", "A"); // 50
|
||||
@@ -1490,7 +1491,8 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
{"C", "C"},
|
||||
{"E", "E"}
|
||||
};
|
||||
QTest::newRow("stage selected added keep changed") << chunk << rows << ChunkSelection({1}, {1}) << false;
|
||||
QTest::newRow("stage selected added keep changed") << chunk << rows << ChunkSelection({1}, {1})
|
||||
<< PatchAction::Apply;
|
||||
|
||||
chunk = createChunk();
|
||||
appendRow(&chunk, "A", "A"); // 50
|
||||
@@ -1507,7 +1509,8 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
{"E", "E"},
|
||||
{"F", "F"}
|
||||
};
|
||||
QTest::newRow("stage selected removed") << chunk << rows << ChunkSelection({2, 3}, {2, 3}) << false;
|
||||
QTest::newRow("stage selected removed") << chunk << rows << ChunkSelection({2, 3}, {2, 3})
|
||||
<< PatchAction::Apply;
|
||||
|
||||
chunk = createChunk();
|
||||
appendRow(&chunk, "A", "A"); // 50
|
||||
@@ -1523,7 +1526,8 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
{"", "D"},
|
||||
{"F", "F"}
|
||||
};
|
||||
QTest::newRow("stage selected added/removed") << chunk << rows << ChunkSelection({2, 3}, {2, 3}) << false;
|
||||
QTest::newRow("stage selected added/removed") << chunk << rows << ChunkSelection({2, 3}, {2, 3})
|
||||
<< PatchAction::Apply;
|
||||
|
||||
chunk = createChunk();
|
||||
appendRow(&chunk, "A", "A"); // 50
|
||||
@@ -1534,7 +1538,8 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
{"B", "C"},
|
||||
{"D", "D"}
|
||||
};
|
||||
QTest::newRow("stage modified row") << chunk << rows << ChunkSelection({1}, {1}) << false;
|
||||
QTest::newRow("stage modified row") << chunk << rows << ChunkSelection({1}, {1})
|
||||
<< PatchAction::Apply;
|
||||
|
||||
chunk = createChunk();
|
||||
appendRow(&chunk, "A", "A"); // 50
|
||||
@@ -1545,7 +1550,8 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
{"B", "C"},
|
||||
{"D", "D"}
|
||||
};
|
||||
QTest::newRow("stage modified and unmodified rows") << chunk << rows << ChunkSelection({0, 1, 2}, {0, 1, 2}) << false;
|
||||
QTest::newRow("stage modified and unmodified rows") << chunk << rows
|
||||
<< ChunkSelection({0, 1, 2}, {0, 1, 2}) << PatchAction::Apply;
|
||||
|
||||
chunk = createChunk();
|
||||
appendRow(&chunk, "A", "A"); // 50
|
||||
@@ -1556,7 +1562,8 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
{"B", "C"},
|
||||
{"D", "D"}
|
||||
};
|
||||
QTest::newRow("stage unmodified left rows") << chunk << rows << ChunkSelection({0, 1, 2}, {1}) << false;
|
||||
QTest::newRow("stage unmodified left rows") << chunk << rows << ChunkSelection({0, 1, 2}, {1})
|
||||
<< PatchAction::Apply;
|
||||
|
||||
chunk = createChunk();
|
||||
appendRow(&chunk, "A", "A"); // 50
|
||||
@@ -1567,7 +1574,8 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
{"B", "C"},
|
||||
{"D", "D"}
|
||||
};
|
||||
QTest::newRow("stage unmodified right rows") << chunk << rows << ChunkSelection({1}, {0, 1, 2}) << false;
|
||||
QTest::newRow("stage unmodified right rows") << chunk << rows << ChunkSelection({1}, {0, 1, 2})
|
||||
<< PatchAction::Apply;
|
||||
|
||||
chunk = createChunk();
|
||||
appendRow(&chunk, "A", "A"); // 50
|
||||
@@ -1578,7 +1586,8 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
{"B", ""},
|
||||
{"D", "D"}
|
||||
};
|
||||
QTest::newRow("stage left only") << chunk << rows << ChunkSelection({1}, {}) << false;
|
||||
QTest::newRow("stage left only") << chunk << rows << ChunkSelection({1}, {})
|
||||
<< PatchAction::Apply;
|
||||
|
||||
chunk = createChunk();
|
||||
appendRow(&chunk, "A", "A"); // 50
|
||||
@@ -1590,7 +1599,8 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
{"", "C"},
|
||||
{"D", "D"}
|
||||
};
|
||||
QTest::newRow("stage right only") << chunk << rows << ChunkSelection({}, {1}) << false;
|
||||
QTest::newRow("stage right only") << chunk << rows << ChunkSelection({}, {1})
|
||||
<< PatchAction::Apply;
|
||||
|
||||
chunk = createChunk();
|
||||
appendRow(&chunk, "A", "A"); // 50
|
||||
@@ -1601,7 +1611,8 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
{"B", "C"},
|
||||
{"D", "D"}
|
||||
};
|
||||
QTest::newRow("stage modified row and revert") << chunk << rows << ChunkSelection({1}, {1}) << true;
|
||||
QTest::newRow("stage modified row and revert") << chunk << rows << ChunkSelection({1}, {1})
|
||||
<< PatchAction::Revert;
|
||||
|
||||
chunk = createChunk();
|
||||
appendRow(&chunk, "A", "A"); // 50
|
||||
@@ -1614,7 +1625,8 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
{"D", "D"}
|
||||
};
|
||||
// symmetric to: "stage right only"
|
||||
QTest::newRow("stage left only and revert") << chunk << rows << ChunkSelection({1}, {}) << true;
|
||||
QTest::newRow("stage left only and revert") << chunk << rows << ChunkSelection({1}, {})
|
||||
<< PatchAction::Revert;
|
||||
|
||||
chunk = createChunk();
|
||||
appendRow(&chunk, "A", "A"); // 50
|
||||
@@ -1626,8 +1638,8 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch_data()
|
||||
{"D", "D"}
|
||||
};
|
||||
// symmetric to: "stage left only"
|
||||
QTest::newRow("stage right only and revert") << chunk << rows << ChunkSelection({}, {1}) << true;
|
||||
|
||||
QTest::newRow("stage right only and revert") << chunk << rows << ChunkSelection({}, {1})
|
||||
<< PatchAction::Revert;
|
||||
}
|
||||
|
||||
void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch()
|
||||
@@ -1635,9 +1647,9 @@ void DiffEditor::Internal::DiffEditorPlugin::testFilterPatch()
|
||||
QFETCH(ChunkData, chunk);
|
||||
QFETCH(ListOfStringPairs, rows);
|
||||
QFETCH(ChunkSelection, selection);
|
||||
QFETCH(bool, revert);
|
||||
QFETCH(PatchAction, patchAction);
|
||||
|
||||
const ChunkData result = DiffEditorDocument::filterChunk(chunk, selection, revert);
|
||||
const ChunkData result = DiffEditorDocument::filterChunk(chunk, selection, patchAction);
|
||||
QCOMPARE(result.rows.size(), rows.size());
|
||||
for (int i = 0; i < rows.size(); ++i) {
|
||||
QCOMPARE(result.rows.at(i).line[LeftSide].text, rows.at(i).first);
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QTextCodec>
|
||||
|
||||
using namespace Core;
|
||||
@@ -127,7 +126,7 @@ void DiffEditorWidgetController::onDocumentReloadFinished()
|
||||
hideProgress();
|
||||
}
|
||||
|
||||
void DiffEditorWidgetController::patch(bool revert, int fileIndex, int chunkIndex)
|
||||
void DiffEditorWidgetController::patch(PatchAction patchAction, int fileIndex, int chunkIndex)
|
||||
{
|
||||
if (!m_document)
|
||||
return;
|
||||
@@ -135,24 +134,16 @@ void DiffEditorWidgetController::patch(bool revert, int fileIndex, int chunkInde
|
||||
if (!chunkExists(fileIndex, chunkIndex))
|
||||
return;
|
||||
|
||||
const QString title = revert ? tr("Revert Chunk") : tr("Apply Chunk");
|
||||
const QString question = revert
|
||||
? tr("Would you like to revert the chunk?")
|
||||
: tr("Would you like to apply the chunk?");
|
||||
if (QMessageBox::No == QMessageBox::question(m_diffEditorWidget, title,
|
||||
question,
|
||||
QMessageBox::Yes
|
||||
| QMessageBox::No)) {
|
||||
if (!PatchTool::confirmPatching(m_diffEditorWidget, patchAction))
|
||||
return;
|
||||
}
|
||||
|
||||
const FileData fileData = m_contextFileData.at(fileIndex);
|
||||
const QString fileName = revert
|
||||
? fileData.fileInfo[RightSide].fileName
|
||||
: fileData.fileInfo[LeftSide].fileName;
|
||||
const DiffFileInfo::PatchBehaviour patchBehaviour = revert
|
||||
? fileData.fileInfo[RightSide].patchBehaviour
|
||||
: fileData.fileInfo[LeftSide].patchBehaviour;
|
||||
const QString fileName = patchAction == PatchAction::Apply
|
||||
? fileData.fileInfo[LeftSide].fileName
|
||||
: fileData.fileInfo[RightSide].fileName;
|
||||
const DiffFileInfo::PatchBehaviour patchBehaviour = patchAction == PatchAction::Apply
|
||||
? fileData.fileInfo[LeftSide].patchBehaviour
|
||||
: fileData.fileInfo[RightSide].patchBehaviour;
|
||||
|
||||
const FilePath workingDirectory = m_document->baseDirectory().isEmpty()
|
||||
? FilePath::fromString(fileName).absolutePath()
|
||||
@@ -162,14 +153,14 @@ void DiffEditorWidgetController::patch(bool revert, int fileIndex, int chunkInde
|
||||
if (patchBehaviour == DiffFileInfo::PatchFile) {
|
||||
const int strip = m_document->baseDirectory().isEmpty() ? -1 : 0;
|
||||
|
||||
const QString patch = m_document->makePatch(fileIndex, chunkIndex, {}, revert);
|
||||
const QString patch = m_document->makePatch(fileIndex, chunkIndex, {}, patchAction);
|
||||
|
||||
if (patch.isEmpty())
|
||||
return;
|
||||
|
||||
FileChangeBlocker fileChangeBlocker(absFilePath);
|
||||
if (PatchTool::runPatch(EditorManager::defaultTextCodec()->fromUnicode(patch),
|
||||
workingDirectory, strip, revert))
|
||||
workingDirectory, strip, patchAction))
|
||||
m_document->reload();
|
||||
} else { // PatchEditor
|
||||
auto textDocument = qobject_cast<TextEditor::TextDocument *>(
|
||||
@@ -187,15 +178,14 @@ void DiffEditorWidgetController::patch(bool revert, int fileIndex, int chunkInde
|
||||
const QString contentsCopyFileName = contentsCopy.fileName();
|
||||
const QString contentsCopyDir = QFileInfo(contentsCopyFileName).absolutePath();
|
||||
|
||||
const QString patch = m_document->makePatch(fileIndex, chunkIndex,
|
||||
{}, revert, false,
|
||||
const QString patch = m_document->makePatch(fileIndex, chunkIndex, {}, patchAction, false,
|
||||
QFileInfo(contentsCopyFileName).fileName());
|
||||
|
||||
if (patch.isEmpty())
|
||||
return;
|
||||
|
||||
if (PatchTool::runPatch(EditorManager::defaultTextCodec()->fromUnicode(patch),
|
||||
FilePath::fromString(contentsCopyDir), 0, revert)) {
|
||||
FilePath::fromString(contentsCopyDir), 0, patchAction)) {
|
||||
QString errorString;
|
||||
if (textDocument->reload(&errorString, FilePath::fromString(contentsCopyFileName)))
|
||||
m_document->reload();
|
||||
@@ -266,15 +256,17 @@ bool DiffEditorWidgetController::fileNamesAreDifferent(int fileIndex) const
|
||||
return fileData.fileInfo[LeftSide].fileName != fileData.fileInfo[RightSide].fileName;
|
||||
}
|
||||
|
||||
void DiffEditorWidgetController::addApplyRevertAction(QMenu *menu, int fileIndex, int chunkIndex, DiffSide side)
|
||||
void DiffEditorWidgetController::addPatchAction(QMenu *menu, int fileIndex, int chunkIndex,
|
||||
PatchAction patchAction)
|
||||
{
|
||||
const QString actionName = side == LeftSide ? tr("Apply Chunk...") : tr("Revert Chunk...");
|
||||
const QString actionName = patchAction == PatchAction::Apply ? tr("Apply Chunk...")
|
||||
: tr("Revert Chunk...");
|
||||
QAction *action = menu->addAction(actionName);
|
||||
connect(action, &QAction::triggered, this, [this, fileIndex, chunkIndex, side] {
|
||||
patch(side == RightSide, fileIndex, chunkIndex);
|
||||
connect(action, &QAction::triggered, this, [this, fileIndex, chunkIndex, patchAction] {
|
||||
patch(patchAction, fileIndex, chunkIndex);
|
||||
});
|
||||
const bool enabled = chunkExists(fileIndex, chunkIndex)
|
||||
&& (side == RightSide || fileNamesAreDifferent(fileIndex));
|
||||
&& (patchAction == PatchAction::Revert || fileNamesAreDifferent(fileIndex));
|
||||
action->setEnabled(enabled);
|
||||
}
|
||||
|
||||
@@ -315,7 +307,7 @@ void DiffEditorWidgetController::sendChunkToCodePaster(int fileIndex, int chunkI
|
||||
auto pasteService = ExtensionSystem::PluginManager::getObject<CodePaster::Service>();
|
||||
QTC_ASSERT(pasteService, return);
|
||||
|
||||
const QString patch = m_document->makePatch(fileIndex, chunkIndex, {}, false);
|
||||
const QString patch = m_document->makePatch(fileIndex, chunkIndex, {}, PatchAction::Apply);
|
||||
|
||||
if (patch.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "diffutils.h"
|
||||
|
||||
#include <coreplugin/patchtool.h>
|
||||
#include <utils/guard.h>
|
||||
|
||||
#include <QObject>
|
||||
@@ -38,7 +39,7 @@ public:
|
||||
int columnNumber);
|
||||
void setFontSettings(const TextEditor::FontSettings &fontSettings);
|
||||
void addCodePasterAction(QMenu *menu, int fileIndex, int chunkIndex);
|
||||
void addApplyRevertAction(QMenu *menu, int fileIndex, int chunkIndex, DiffSide side);
|
||||
void addPatchAction(QMenu *menu, int fileIndex, int chunkIndex, Core::PatchAction patchAction);
|
||||
void addExtraActions(QMenu *menu, int fileIndex, int chunkIndex, const ChunkSelection &selection);
|
||||
void updateCannotDecodeInfo();
|
||||
void setBusyShowing(bool busy);
|
||||
@@ -60,7 +61,7 @@ private:
|
||||
bool isInProgress() const;
|
||||
void toggleProgress(bool wasInProgress);
|
||||
|
||||
void patch(bool revert, int fileIndex, int chunkIndex);
|
||||
void patch(Core::PatchAction patchAction, int fileIndex, int chunkIndex);
|
||||
void sendChunkToCodePaster(int fileIndex, int chunkIndex);
|
||||
bool chunkExists(int fileIndex, int chunkIndex) const;
|
||||
bool fileNamesAreDifferent(int fileIndex) const;
|
||||
|
||||
@@ -1107,8 +1107,9 @@ void SideBySideDiffEditorWidget::contextMenuRequested(DiffSide side, QMenu *menu
|
||||
{
|
||||
menu->addSeparator();
|
||||
|
||||
const PatchAction patchAction = side == LeftSide ? PatchAction::Apply : PatchAction::Revert;
|
||||
m_controller.addCodePasterAction(menu, fileIndex, chunkIndex);
|
||||
m_controller.addApplyRevertAction(menu, fileIndex, chunkIndex, side);
|
||||
m_controller.addPatchAction(menu, fileIndex, chunkIndex, patchAction);
|
||||
m_controller.addExtraActions(menu, fileIndex, chunkIndex, selection);
|
||||
}
|
||||
|
||||
|
||||
@@ -218,8 +218,8 @@ void UnifiedDiffEditorWidget::addContextMenuActions(QMenu *menu, int fileIndex,
|
||||
menu->addSeparator();
|
||||
|
||||
m_controller.addCodePasterAction(menu, fileIndex, chunkIndex);
|
||||
m_controller.addApplyRevertAction(menu, fileIndex, chunkIndex, LeftSide);
|
||||
m_controller.addApplyRevertAction(menu, fileIndex, chunkIndex, RightSide);
|
||||
m_controller.addPatchAction(menu, fileIndex, chunkIndex, PatchAction::Apply);
|
||||
m_controller.addPatchAction(menu, fileIndex, chunkIndex, PatchAction::Revert);
|
||||
m_controller.addExtraActions(menu, fileIndex, chunkIndex, selection);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user