summaryrefslogtreecommitdiff
path: root/src/plugins/diffeditor/diffeditorplugin.cpp
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2022-09-29 15:31:27 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2022-09-29 15:15:30 +0000
commitb67c868f757a05ef0785f671439dd9132930b1dd (patch)
tree8d1d9580b79e09b808ff944a48f5c72693f112e5 /src/plugins/diffeditor/diffeditorplugin.cpp
parent2d360db2c320e16d3bccf624c0d7c452d8231dd9 (diff)
downloadqt-creator-b67c868f757a05ef0785f671439dd9132930b1dd.tar.gz
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>
Diffstat (limited to 'src/plugins/diffeditor/diffeditorplugin.cpp')
-rw-r--r--src/plugins/diffeditor/diffeditorplugin.cpp50
1 files changed, 31 insertions, 19 deletions
diff --git a/src/plugins/diffeditor/diffeditorplugin.cpp b/src/plugins/diffeditor/diffeditorplugin.cpp
index bb9d3259e3..fafc85fb17 100644
--- a/src/plugins/diffeditor/diffeditorplugin.cpp
+++ b/src/plugins/diffeditor/diffeditorplugin.cpp
@@ -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);