Fix repeting Stage/Unstage actions in unified diff editor

Don't store diff file index, chunk index and diff editor
controller anymore. Pass needed indices by value,
retrieve them when needed as lambda copy.

Change-Id: I3a81f1ab6d131c0b1d9899ac4b061b6e25582f51
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Jarek Kobus
2018-02-15 10:29:14 +01:00
parent 9494a9e0c0
commit 64233a4fae
10 changed files with 121 additions and 126 deletions

View File

@@ -59,17 +59,18 @@ public:
AddPrefix = 2
};
Q_DECLARE_FLAGS(PatchOptions, PatchOption)
QString makePatch(PatchOptions options) const;
QString makePatch(int fileIndex, int chunkIndex, PatchOptions options) const;
static Core::IDocument *findOrCreateDocument(const QString &vcsId,
const QString &displayName);
static DiffEditorController *controller(Core::IDocument *document);
void branchesReceived(const QString &branches);
void requestChunkActions(QMenu *menu, int diffFileIndex, int chunkIndex);
void requestChunkActions(QMenu *menu, int fileIndex, int chunkIndex);
bool chunkExists(int fileIndex, int chunkIndex) const;
signals:
void chunkActionsRequested(QMenu *menu, bool isValid);
void chunkActionsRequested(QMenu *menu, int fileIndex, int chunkIndex);
void requestInformationForCommit(const QString &revision);
protected:
@@ -92,10 +93,10 @@ private:
Internal::DiffEditorDocument *const m_document;
bool m_isReloading = false;
int m_diffFileIndex = -1;
int m_chunkIndex = -1;
friend class Internal::DiffEditorDocument;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(DiffEditorController::PatchOptions)
} // namespace DiffEditor