forked from qt-creator/qt-creator
DiffEditor: Simplify makePatch
Store indices in controller and avoid passing them around. Change-Id: I49c80cb6cf6734a18f80ad5c7c441973d246708f Reviewed-by: Jarek Kobus <jaroslaw.kobus@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
b01a6a4663
commit
20b836f59c
@@ -298,9 +298,7 @@ void UnifiedDiffEditorWidget::slotSendChunkToCodePaster()
|
||||
if (m_contextMenuChunkIndex >= fileData.chunks.count())
|
||||
return;
|
||||
|
||||
const QString patch = m_controller->makePatch(m_contextMenuFileIndex,
|
||||
m_contextMenuChunkIndex,
|
||||
false);
|
||||
const QString patch = m_controller->makePatch(false);
|
||||
|
||||
if (patch.isEmpty())
|
||||
return;
|
||||
@@ -321,27 +319,27 @@ void UnifiedDiffEditorWidget::slotSendChunkToCodePaster()
|
||||
|
||||
void UnifiedDiffEditorWidget::slotApplyChunk()
|
||||
{
|
||||
patch(m_contextMenuFileIndex, m_contextMenuChunkIndex, false);
|
||||
patch(false);
|
||||
}
|
||||
|
||||
void UnifiedDiffEditorWidget::slotRevertChunk()
|
||||
{
|
||||
patch(m_contextMenuFileIndex, m_contextMenuChunkIndex, true);
|
||||
patch(true);
|
||||
}
|
||||
|
||||
void UnifiedDiffEditorWidget::patch(int diffFileIndex, int chunkIndex, bool revert)
|
||||
void UnifiedDiffEditorWidget::patch(bool revert)
|
||||
{
|
||||
if (!m_controller)
|
||||
return;
|
||||
|
||||
if (diffFileIndex < 0 || chunkIndex < 0)
|
||||
if (m_contextMenuFileIndex < 0 || m_contextMenuChunkIndex < 0)
|
||||
return;
|
||||
|
||||
if (diffFileIndex >= m_contextFileData.count())
|
||||
if (m_contextMenuFileIndex >= m_contextFileData.count())
|
||||
return;
|
||||
|
||||
const FileData fileData = m_contextFileData.at(diffFileIndex);
|
||||
if (chunkIndex >= fileData.chunks.count())
|
||||
const FileData fileData = m_contextFileData.at(m_contextMenuFileIndex);
|
||||
if (m_contextMenuChunkIndex >= fileData.chunks.count())
|
||||
return;
|
||||
|
||||
const QString title = revert ? tr("Revert Chunk") : tr("Apply Chunk");
|
||||
@@ -364,9 +362,7 @@ void UnifiedDiffEditorWidget::patch(int diffFileIndex, int chunkIndex, bool reve
|
||||
? QFileInfo(fileName).absolutePath()
|
||||
: m_controller->workingDirectory();
|
||||
|
||||
const QString patch = m_controller->makePatch(diffFileIndex,
|
||||
chunkIndex,
|
||||
revert);
|
||||
const QString patch = m_controller->makePatch(revert);
|
||||
if (patch.isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user