forked from qt-creator/qt-creator
Rename some methods and variables in DiffEditor
Change-Id: Ic6db2882c9468b9451a785e4657e4255b40fca4c Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -137,12 +137,12 @@ void DiffEditorController::setReloader(DiffEditorReloader *reloader)
|
|||||||
return; // nothing changes
|
return; // nothing changes
|
||||||
|
|
||||||
if (m_reloader)
|
if (m_reloader)
|
||||||
m_reloader->setDiffEditorController(0);
|
m_reloader->setController(0);
|
||||||
|
|
||||||
m_reloader = reloader;
|
m_reloader = reloader;
|
||||||
|
|
||||||
if (m_reloader)
|
if (m_reloader)
|
||||||
m_reloader->setDiffEditorController(this);
|
m_reloader->setController(this);
|
||||||
|
|
||||||
reloaderChanged(m_reloader);
|
reloaderChanged(m_reloader);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace DiffEditor {
|
|||||||
|
|
||||||
DiffEditorDocument::DiffEditorDocument() :
|
DiffEditorDocument::DiffEditorDocument() :
|
||||||
Core::TextDocument(),
|
Core::TextDocument(),
|
||||||
m_diffEditorController(new DiffEditorController(this))
|
m_controller(new DiffEditorController(this))
|
||||||
{
|
{
|
||||||
setId(Constants::DIFF_EDITOR_ID);
|
setId(Constants::DIFF_EDITOR_ID);
|
||||||
setTemporary(true);
|
setTemporary(true);
|
||||||
@@ -55,7 +55,7 @@ DiffEditorDocument::~DiffEditorDocument()
|
|||||||
|
|
||||||
DiffEditorController *DiffEditorDocument::controller() const
|
DiffEditorController *DiffEditorDocument::controller() const
|
||||||
{
|
{
|
||||||
return m_diffEditorController;
|
return m_controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiffEditorDocument::setContents(const QByteArray &contents)
|
bool DiffEditorDocument::setContents(const QByteArray &contents)
|
||||||
@@ -66,10 +66,10 @@ bool DiffEditorDocument::setContents(const QByteArray &contents)
|
|||||||
|
|
||||||
QString DiffEditorDocument::defaultPath() const
|
QString DiffEditorDocument::defaultPath() const
|
||||||
{
|
{
|
||||||
if (!m_diffEditorController)
|
if (!m_controller)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
return m_diffEditorController->workingDirectory();
|
return m_controller->workingDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiffEditorDocument::save(QString *errorString, const QString &fileName, bool autoSave)
|
bool DiffEditorDocument::save(QString *errorString, const QString &fileName, bool autoSave)
|
||||||
@@ -77,10 +77,10 @@ bool DiffEditorDocument::save(QString *errorString, const QString &fileName, boo
|
|||||||
Q_UNUSED(errorString)
|
Q_UNUSED(errorString)
|
||||||
Q_UNUSED(autoSave)
|
Q_UNUSED(autoSave)
|
||||||
|
|
||||||
if (!m_diffEditorController)
|
if (!m_controller)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const QString contents = DiffUtils::makePatch(m_diffEditorController->diffFiles());
|
const QString contents = DiffUtils::makePatch(m_controller->diffFiles());
|
||||||
|
|
||||||
const bool ok = write(fileName, format(), contents, errorString);
|
const bool ok = write(fileName, format(), contents, errorString);
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public:
|
|||||||
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DiffEditorController *m_diffEditorController;
|
DiffEditorController *m_controller;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace DiffEditor
|
} // namespace DiffEditor
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ void SimpleDiffEditorReloader::reload()
|
|||||||
QList<Diff> outputLeftDiffList;
|
QList<Diff> outputLeftDiffList;
|
||||||
QList<Diff> outputRightDiffList;
|
QList<Diff> outputRightDiffList;
|
||||||
|
|
||||||
if (diffEditorController()->isIgnoreWhitespace()) {
|
if (controller()->isIgnoreWhitespace()) {
|
||||||
const QList<Diff> leftIntermediate =
|
const QList<Diff> leftIntermediate =
|
||||||
Differ::moveWhitespaceIntoEqualities(leftDiffList);
|
Differ::moveWhitespaceIntoEqualities(leftDiffList);
|
||||||
const QList<Diff> rightIntermediate =
|
const QList<Diff> rightIntermediate =
|
||||||
@@ -125,14 +125,14 @@ void SimpleDiffEditorReloader::reload()
|
|||||||
const ChunkData chunkData = DiffUtils::calculateOriginalData(
|
const ChunkData chunkData = DiffUtils::calculateOriginalData(
|
||||||
outputLeftDiffList, outputRightDiffList);
|
outputLeftDiffList, outputRightDiffList);
|
||||||
FileData fileData = DiffUtils::calculateContextData(
|
FileData fileData = DiffUtils::calculateContextData(
|
||||||
chunkData, diffEditorController()->contextLinesNumber(), 0);
|
chunkData, controller()->contextLinesNumber(), 0);
|
||||||
fileData.leftFileInfo.fileName = m_leftFileName;
|
fileData.leftFileInfo.fileName = m_leftFileName;
|
||||||
fileData.rightFileInfo.fileName = m_rightFileName;
|
fileData.rightFileInfo.fileName = m_rightFileName;
|
||||||
|
|
||||||
QList<FileData> fileDataList;
|
QList<FileData> fileDataList;
|
||||||
fileDataList << fileData;
|
fileDataList << fileData;
|
||||||
|
|
||||||
diffEditorController()->setDiffFiles(fileDataList);
|
controller()->setDiffFiles(fileDataList);
|
||||||
|
|
||||||
reloadFinished();
|
reloadFinished();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,12 +44,12 @@ DiffEditorReloader::~DiffEditorReloader()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DiffEditorController *DiffEditorReloader::diffEditorController() const
|
DiffEditorController *DiffEditorReloader::controller() const
|
||||||
{
|
{
|
||||||
return m_controller;
|
return m_controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiffEditorReloader::setDiffEditorController(DiffEditorController *controller)
|
void DiffEditorReloader::setController(DiffEditorController *controller)
|
||||||
{
|
{
|
||||||
if (m_controller == controller)
|
if (m_controller == controller)
|
||||||
return; // nothing changes
|
return; // nothing changes
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ protected:
|
|||||||
// inside reload() (for synchronous reload)
|
// inside reload() (for synchronous reload)
|
||||||
// or later (for asynchronous reload)
|
// or later (for asynchronous reload)
|
||||||
virtual void reload() = 0;
|
virtual void reload() = 0;
|
||||||
DiffEditorController *diffEditorController() const;
|
DiffEditorController *controller() const;
|
||||||
void setDiffEditorController(DiffEditorController *diffEditorController);
|
void setController(DiffEditorController *controller);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void reloadFinished();
|
void reloadFinished();
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class GitDiffHandler : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GitDiffHandler(DiffEditor::DiffEditorController *editorController,
|
GitDiffHandler(DiffEditor::DiffEditorController *controller,
|
||||||
const QString &workingDirectory);
|
const QString &workingDirectory);
|
||||||
|
|
||||||
// index -> working tree
|
// index -> working tree
|
||||||
@@ -135,7 +135,7 @@ private:
|
|||||||
QProcessEnvironment processEnvironment() const;
|
QProcessEnvironment processEnvironment() const;
|
||||||
QString gitPath() const;
|
QString gitPath() const;
|
||||||
|
|
||||||
QPointer<DiffEditor::DiffEditorController> m_editorController;
|
QPointer<DiffEditor::DiffEditorController> m_controller;
|
||||||
const QString m_workingDirectory;
|
const QString m_workingDirectory;
|
||||||
GitClient *m_gitClient;
|
GitClient *m_gitClient;
|
||||||
const QString m_waitMessage;
|
const QString m_waitMessage;
|
||||||
@@ -143,9 +143,9 @@ private:
|
|||||||
QString m_id;
|
QString m_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
GitDiffHandler::GitDiffHandler(DiffEditor::DiffEditorController *editorController,
|
GitDiffHandler::GitDiffHandler(DiffEditor::DiffEditorController *controller,
|
||||||
const QString &workingDirectory)
|
const QString &workingDirectory)
|
||||||
: m_editorController(editorController),
|
: m_controller(controller),
|
||||||
m_workingDirectory(workingDirectory),
|
m_workingDirectory(workingDirectory),
|
||||||
m_gitClient(GitPlugin::instance()->gitClient()),
|
m_gitClient(GitPlugin::instance()->gitClient()),
|
||||||
m_waitMessage(tr("Waiting for data..."))
|
m_waitMessage(tr("Waiting for data..."))
|
||||||
@@ -201,12 +201,12 @@ void GitDiffHandler::show(const QString &id)
|
|||||||
|
|
||||||
void GitDiffHandler::postCollectShowDescription(const QString &id)
|
void GitDiffHandler::postCollectShowDescription(const QString &id)
|
||||||
{
|
{
|
||||||
if (m_editorController.isNull()) {
|
if (m_controller.isNull()) {
|
||||||
deleteLater();
|
deleteLater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_editorController->clear(m_waitMessage);
|
m_controller->clear(m_waitMessage);
|
||||||
VcsBase::Command *command = new VcsBase::Command(gitPath(),
|
VcsBase::Command *command = new VcsBase::Command(gitPath(),
|
||||||
m_workingDirectory,
|
m_workingDirectory,
|
||||||
processEnvironment());
|
processEnvironment());
|
||||||
@@ -226,7 +226,7 @@ void GitDiffHandler::postCollectShowDescription(const QString &id)
|
|||||||
|
|
||||||
void GitDiffHandler::slotShowDescriptionReceived(const QString &description)
|
void GitDiffHandler::slotShowDescriptionReceived(const QString &description)
|
||||||
{
|
{
|
||||||
if (m_editorController.isNull()) {
|
if (m_controller.isNull()) {
|
||||||
deleteLater();
|
deleteLater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -234,7 +234,7 @@ void GitDiffHandler::slotShowDescriptionReceived(const QString &description)
|
|||||||
postCollectDiffOutput(QStringList() << m_id + QLatin1Char('^') << m_id);
|
postCollectDiffOutput(QStringList() << m_id + QLatin1Char('^') << m_id);
|
||||||
|
|
||||||
// need to be called after postCollectDiffOutput(), since it clears the description
|
// need to be called after postCollectDiffOutput(), since it clears the description
|
||||||
m_editorController->setDescription(
|
m_controller->setDescription(
|
||||||
m_gitClient->extendedShowDescription(m_workingDirectory,
|
m_gitClient->extendedShowDescription(m_workingDirectory,
|
||||||
description));
|
description));
|
||||||
}
|
}
|
||||||
@@ -243,10 +243,10 @@ void GitDiffHandler::addJob(VcsBase::Command *command, const QStringList &argume
|
|||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << QLatin1String("diff");
|
args << QLatin1String("diff");
|
||||||
if (m_editorController->isIgnoreWhitespace())
|
if (m_controller->isIgnoreWhitespace())
|
||||||
args << QLatin1String("--ignore-space-change");
|
args << QLatin1String("--ignore-space-change");
|
||||||
args << QLatin1String("--unified=") + QString::number(
|
args << QLatin1String("--unified=") + QString::number(
|
||||||
m_editorController->contextLinesNumber());
|
m_controller->contextLinesNumber());
|
||||||
args << arguments;
|
args << arguments;
|
||||||
command->addJob(args, timeout());
|
command->addJob(args, timeout());
|
||||||
}
|
}
|
||||||
@@ -258,12 +258,12 @@ void GitDiffHandler::postCollectDiffOutput(const QStringList &arguments)
|
|||||||
|
|
||||||
void GitDiffHandler::postCollectDiffOutput(const QList<QStringList> &argumentsList)
|
void GitDiffHandler::postCollectDiffOutput(const QList<QStringList> &argumentsList)
|
||||||
{
|
{
|
||||||
if (m_editorController.isNull()) {
|
if (m_controller.isNull()) {
|
||||||
deleteLater();
|
deleteLater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_editorController->clear(m_waitMessage);
|
m_controller->clear(m_waitMessage);
|
||||||
VcsBase::Command *command = new VcsBase::Command(gitPath(),
|
VcsBase::Command *command = new VcsBase::Command(gitPath(),
|
||||||
m_workingDirectory,
|
m_workingDirectory,
|
||||||
processEnvironment());
|
processEnvironment());
|
||||||
@@ -280,7 +280,7 @@ void GitDiffHandler::postCollectDiffOutput(const QList<QStringList> &argumentsLi
|
|||||||
|
|
||||||
void GitDiffHandler::slotDiffOutputReceived(const QString &contents)
|
void GitDiffHandler::slotDiffOutputReceived(const QString &contents)
|
||||||
{
|
{
|
||||||
if (m_editorController.isNull()) {
|
if (m_controller.isNull()) {
|
||||||
deleteLater();
|
deleteLater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -288,8 +288,8 @@ void GitDiffHandler::slotDiffOutputReceived(const QString &contents)
|
|||||||
bool ok;
|
bool ok;
|
||||||
QList<DiffEditor::FileData> fileDataList
|
QList<DiffEditor::FileData> fileDataList
|
||||||
= DiffEditor::DiffUtils::readPatch(
|
= DiffEditor::DiffUtils::readPatch(
|
||||||
contents, m_editorController->isIgnoreWhitespace(), &ok);
|
contents, m_controller->isIgnoreWhitespace(), &ok);
|
||||||
m_editorController->setDiffFiles(fileDataList, m_workingDirectory);
|
m_controller->setDiffFiles(fileDataList, m_workingDirectory);
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ GitDiffEditorReloader::GitDiffEditorReloader(QObject *parent)
|
|||||||
|
|
||||||
void GitDiffEditorReloader::reload()
|
void GitDiffEditorReloader::reload()
|
||||||
{
|
{
|
||||||
GitDiffHandler *handler = new GitDiffHandler(diffEditorController(),
|
GitDiffHandler *handler = new GitDiffHandler(controller(),
|
||||||
m_workingDirectory);
|
m_workingDirectory);
|
||||||
connect(handler, SIGNAL(destroyed()), this, SLOT(reloadFinished()));
|
connect(handler, SIGNAL(destroyed()), this, SLOT(reloadFinished()));
|
||||||
|
|
||||||
@@ -798,9 +798,9 @@ void GitClient::slotChunkActionsRequested(QMenu *menu, int diffFileIndex, int ch
|
|||||||
|
|
||||||
m_contextDiffFileIndex = diffFileIndex;
|
m_contextDiffFileIndex = diffFileIndex;
|
||||||
m_contextChunkIndex = chunkIndex;
|
m_contextChunkIndex = chunkIndex;
|
||||||
m_contextDocument = qobject_cast<DiffEditor::DiffEditorController *>(sender());
|
m_contextController = qobject_cast<DiffEditor::DiffEditorController *>(sender());
|
||||||
|
|
||||||
if (m_contextDiffFileIndex < 0 || m_contextChunkIndex < 0 || !m_contextDocument) {
|
if (m_contextDiffFileIndex < 0 || m_contextChunkIndex < 0 || !m_contextController) {
|
||||||
stageChunkAction->setEnabled(false);
|
stageChunkAction->setEnabled(false);
|
||||||
unstageChunkAction->setEnabled(false);
|
unstageChunkAction->setEnabled(false);
|
||||||
}
|
}
|
||||||
@@ -808,13 +808,13 @@ void GitClient::slotChunkActionsRequested(QMenu *menu, int diffFileIndex, int ch
|
|||||||
|
|
||||||
QString GitClient::makePatch(int diffFileIndex, int chunkIndex, bool revert) const
|
QString GitClient::makePatch(int diffFileIndex, int chunkIndex, bool revert) const
|
||||||
{
|
{
|
||||||
if (m_contextDocument.isNull())
|
if (m_contextController.isNull())
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
if (diffFileIndex < 0 || chunkIndex < 0)
|
if (diffFileIndex < 0 || chunkIndex < 0)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
QList<DiffEditor::FileData> fileDataList = m_contextDocument->diffFiles();
|
QList<DiffEditor::FileData> fileDataList = m_contextController->diffFiles();
|
||||||
|
|
||||||
if (diffFileIndex >= fileDataList.count())
|
if (diffFileIndex >= fileDataList.count())
|
||||||
return QString();
|
return QString();
|
||||||
@@ -838,7 +838,7 @@ QString GitClient::makePatch(int diffFileIndex, int chunkIndex, bool revert) con
|
|||||||
|
|
||||||
void GitClient::slotStageChunk()
|
void GitClient::slotStageChunk()
|
||||||
{
|
{
|
||||||
if (m_contextDocument.isNull())
|
if (m_contextController.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QString patch = makePatch(m_contextDiffFileIndex,
|
const QString patch = makePatch(m_contextDiffFileIndex,
|
||||||
@@ -851,7 +851,7 @@ void GitClient::slotStageChunk()
|
|||||||
|
|
||||||
void GitClient::slotUnstageChunk()
|
void GitClient::slotUnstageChunk()
|
||||||
{
|
{
|
||||||
if (m_contextDocument.isNull())
|
if (m_contextController.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QString patch = makePatch(m_contextDiffFileIndex,
|
const QString patch = makePatch(m_contextDiffFileIndex,
|
||||||
@@ -870,7 +870,7 @@ void GitClient::stage(const QString &patch, bool revert)
|
|||||||
if (!patchFile.open())
|
if (!patchFile.open())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QString baseDir = m_contextDocument->workingDirectory();
|
const QString baseDir = m_contextController->workingDirectory();
|
||||||
QTextCodec *codec = EditorManager::defaultTextCodec();
|
QTextCodec *codec = EditorManager::defaultTextCodec();
|
||||||
const QByteArray patchData = codec
|
const QByteArray patchData = codec
|
||||||
? codec->fromUnicode(patch) : patch.toLocal8Bit();
|
? codec->fromUnicode(patch) : patch.toLocal8Bit();
|
||||||
@@ -891,7 +891,7 @@ void GitClient::stage(const QString &patch, bool revert)
|
|||||||
} else {
|
} else {
|
||||||
outwin->append(errorMessage);
|
outwin->append(errorMessage);
|
||||||
}
|
}
|
||||||
m_contextDocument->requestReload();
|
m_contextController->requestReload();
|
||||||
} else {
|
} else {
|
||||||
outwin->appendError(errorMessage);
|
outwin->appendError(errorMessage);
|
||||||
}
|
}
|
||||||
@@ -1750,14 +1750,14 @@ void GitClient::branchesForCommit(const QString &revision)
|
|||||||
arguments << QLatin1String("branch") << QLatin1String(noColorOption)
|
arguments << QLatin1String("branch") << QLatin1String(noColorOption)
|
||||||
<< QLatin1String("-a") << QLatin1String("--contains") << revision;
|
<< QLatin1String("-a") << QLatin1String("--contains") << revision;
|
||||||
|
|
||||||
DiffEditor::DiffEditorController *editorController
|
DiffEditor::DiffEditorController *controller
|
||||||
= qobject_cast<DiffEditor::DiffEditorController *>(sender());
|
= qobject_cast<DiffEditor::DiffEditorController *>(sender());
|
||||||
QString workingDirectory = editorController->workingDirectory();
|
QString workingDirectory = controller->workingDirectory();
|
||||||
VcsBase::Command *command = new VcsBase::Command(gitBinaryPath(), workingDirectory,
|
VcsBase::Command *command = new VcsBase::Command(gitBinaryPath(), workingDirectory,
|
||||||
processEnvironment());
|
processEnvironment());
|
||||||
command->setCodec(getSourceCodec(currentDocumentPath()));
|
command->setCodec(getSourceCodec(currentDocumentPath()));
|
||||||
|
|
||||||
connect(command, SIGNAL(output(QString)), editorController,
|
connect(command, SIGNAL(output(QString)), controller,
|
||||||
SLOT(branchesForCommitReceived(QString)));
|
SLOT(branchesForCommitReceived(QString)));
|
||||||
|
|
||||||
command->addJob(arguments, -1);
|
command->addJob(arguments, -1);
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ private:
|
|||||||
bool m_disableEditor;
|
bool m_disableEditor;
|
||||||
int m_contextDiffFileIndex;
|
int m_contextDiffFileIndex;
|
||||||
int m_contextChunkIndex;
|
int m_contextChunkIndex;
|
||||||
QPointer<DiffEditor::DiffEditorController> m_contextDocument;
|
QPointer<DiffEditor::DiffEditorController> m_contextController;
|
||||||
QFutureSynchronizer<void> m_synchronizer; // for commit updates
|
QFutureSynchronizer<void> m_synchronizer; // for commit updates
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user