DiffEditor: Replace bool arguments with flags enum

Change-Id: I70262476d015ba5b73069b149093dac66f7c6008
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Andre Hartmann
2018-01-16 22:20:07 +02:00
committed by Orgad Shaneh
parent b8ee51fef1
commit 6bc12ff446
3 changed files with 15 additions and 5 deletions

View File

@@ -71,9 +71,10 @@ QString DiffEditorController::revisionFromDescription() const
return m_document->description().mid(7, 12); return m_document->description().mid(7, 12);
} }
QString DiffEditorController::makePatch(bool revert, bool addPrefix) const QString DiffEditorController::makePatch(PatchOptions options) const
{ {
return m_document->makePatch(m_diffFileIndex, m_chunkIndex, revert, addPrefix); return m_document->makePatch(m_diffFileIndex, m_chunkIndex,
options & Revert, options & AddPrefix);
} }
Core::IDocument *DiffEditorController::findOrCreateDocument(const QString &vcsId, Core::IDocument *DiffEditorController::findOrCreateDocument(const QString &vcsId,

View File

@@ -53,7 +53,13 @@ public:
QString revisionFromDescription() const; QString revisionFromDescription() const;
QString makePatch(bool revert, bool addPrefix = false) const; enum PatchOption {
NoOption = 0,
Revert = 1,
AddPrefix = 2
};
Q_DECLARE_FLAGS(PatchOptions, PatchOption)
QString makePatch(PatchOptions options) const;
static Core::IDocument *findOrCreateDocument(const QString &vcsId, static Core::IDocument *findOrCreateDocument(const QString &vcsId,
const QString &displayName); const QString &displayName);

View File

@@ -617,7 +617,8 @@ void GitClient::slotStageChunk()
if (m_contextController.isNull()) if (m_contextController.isNull())
return; return;
const QString patch = m_contextController->makePatch(false, true); DiffEditorController::PatchOptions options = DiffEditorController::AddPrefix;
const QString patch = m_contextController->makePatch(options);
if (patch.isEmpty()) if (patch.isEmpty())
return; return;
@@ -629,7 +630,9 @@ void GitClient::slotUnstageChunk()
if (m_contextController.isNull()) if (m_contextController.isNull())
return; return;
const QString patch = m_contextController->makePatch(true, true); DiffEditorController::PatchOptions options = DiffEditorController::AddPrefix;
options |= DiffEditorController::Revert;
const QString patch = m_contextController->makePatch(options);
if (patch.isEmpty()) if (patch.isEmpty())
return; return;