DiffEditorController: Make setReloader() protected

Change-Id: I2c988794176aa2e234c15ae88c425f30c1726810
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2022-12-11 14:54:13 +01:00
parent 32e824c762
commit 1cdf29a1e6
2 changed files with 7 additions and 9 deletions

View File

@@ -52,15 +52,14 @@ public:
bool chunkExists(int fileIndex, int chunkIndex) const; bool chunkExists(int fileIndex, int chunkIndex) const;
Core::IDocument *document() const; Core::IDocument *document() const;
// reloadFinished() should be called inside the reloader (for synchronous reload)
// or later (for asynchronous reload)
void setReloader(const std::function<void ()> &reloader);
signals: signals:
void chunkActionsRequested(QMenu *menu, int fileIndex, int chunkIndex, void chunkActionsRequested(QMenu *menu, int fileIndex, int chunkIndex,
const ChunkSelection &selection); const ChunkSelection &selection);
protected: protected:
// reloadFinished() should be called inside the reloader (for synchronous reload)
// or later (for asynchronous reload)
void setReloader(const std::function<void ()> &reloader);
void reloadFinished(bool success); void reloadFinished(bool success);
void setDiffFiles(const QList<FileData> &diffFileList, void setDiffFiles(const QList<FileData> &diffFileList,

View File

@@ -38,12 +38,14 @@ namespace Mercurial::Internal {
class MercurialDiffEditorController : public VcsBaseDiffEditorController class MercurialDiffEditorController : public VcsBaseDiffEditorController
{ {
public: public:
MercurialDiffEditorController(IDocument *document) MercurialDiffEditorController(IDocument *document, const QStringList &args)
: VcsBaseDiffEditorController(document) : VcsBaseDiffEditorController(document)
{ {
setDisplayName("Hg Diff"); setDisplayName("Hg Diff");
setReloader([this, args] { runCommand({addConfigurationArguments(args)}); });
} }
private:
void runCommand(const QList<QStringList> &args, QTextCodec *codec = nullptr); void runCommand(const QList<QStringList> &args, QTextCodec *codec = nullptr);
QStringList addConfigurationArguments(const QStringList &args) const; QStringList addConfigurationArguments(const QStringList &args) const;
}; };
@@ -416,10 +418,7 @@ void MercurialClient::requestReload(const QString &documentId, const QString &so
IDocument *document = DiffEditorController::findOrCreateDocument(documentId, title); IDocument *document = DiffEditorController::findOrCreateDocument(documentId, title);
QTC_ASSERT(document, return); QTC_ASSERT(document, return);
auto controller = new MercurialDiffEditorController(document); auto controller = new MercurialDiffEditorController(document, args);
controller->setReloader([controller, args] {
controller->runCommand({controller->addConfigurationArguments(args)});
});
controller->setVcsBinary(settings().binaryPath.filePath()); controller->setVcsBinary(settings().binaryPath.filePath());
controller->setVcsTimeoutS(settings().timeout.value()); controller->setVcsTimeoutS(settings().timeout.value());
controller->setProcessEnvironment(processEnvironment()); controller->setProcessEnvironment(processEnvironment());