forked from qt-creator/qt-creator
DiffEditor: Modernize
modernize-use-auto modernize-use-override modernize-use-equals-default Change-Id: I4e70550ed2962781b62661a405517b5c79126bad Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -68,7 +68,7 @@ QList<TextEditor::TextEditorWidget *> DescriptionWidgetWatcher::descriptionWidge
|
||||
|
||||
TextEditor::TextEditorWidget *DescriptionWidgetWatcher::descriptionWidget(Core::IEditor *editor) const
|
||||
{
|
||||
if (Internal::DiffEditor *diffEditor = qobject_cast<Internal::DiffEditor *>(editor)) {
|
||||
if (auto diffEditor = qobject_cast<const Internal::DiffEditor *>(editor)) {
|
||||
if (diffEditor->document() == m_document)
|
||||
return diffEditor->descriptionWidget();
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ DiffEditor::~DiffEditor()
|
||||
|
||||
Core::IEditor *DiffEditor::duplicate()
|
||||
{
|
||||
DiffEditor *editor = new DiffEditor();
|
||||
auto editor = new DiffEditor();
|
||||
Utils::GuardLocker guard(editor->m_ignoreChanges);
|
||||
|
||||
editor->setDocument(m_document);
|
||||
|
||||
@@ -40,7 +40,7 @@ class DiffEditorFactory : public Core::IEditorFactory
|
||||
public:
|
||||
explicit DiffEditorFactory(QObject *parent);
|
||||
|
||||
Core::IEditor *createEditor();
|
||||
Core::IEditor *createEditor() override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -129,7 +129,7 @@ class DiffFilesController : public DiffEditorController
|
||||
Q_OBJECT
|
||||
public:
|
||||
DiffFilesController(IDocument *document);
|
||||
~DiffFilesController();
|
||||
~DiffFilesController() override;
|
||||
|
||||
protected:
|
||||
void reload() final;
|
||||
@@ -203,7 +203,7 @@ QList<ReloadInput> DiffCurrentFileController::reloadInputList() const
|
||||
{
|
||||
QList<ReloadInput> result;
|
||||
|
||||
TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(
|
||||
auto textDocument = qobject_cast<TextEditor::TextDocument *>(
|
||||
DocumentModel::documentForFilePath(m_fileName));
|
||||
|
||||
if (textDocument && textDocument->isModified()) {
|
||||
@@ -259,7 +259,7 @@ QList<ReloadInput> DiffOpenFilesController::reloadInputList() const
|
||||
const QList<IDocument *> openedDocuments = DocumentModel::openedDocuments();
|
||||
|
||||
for (IDocument *doc : openedDocuments) {
|
||||
TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(doc);
|
||||
auto textDocument = qobject_cast<TextEditor::TextDocument *>(doc);
|
||||
|
||||
if (textDocument && textDocument->isModified()) {
|
||||
QString errorString;
|
||||
@@ -317,7 +317,7 @@ QList<ReloadInput> DiffModifiedFilesController::reloadInputList() const
|
||||
QList<ReloadInput> result;
|
||||
|
||||
for (const QString &fileName : m_fileNames) {
|
||||
TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(
|
||||
auto textDocument = qobject_cast<TextEditor::TextDocument *>(
|
||||
DocumentModel::documentForFilePath(fileName));
|
||||
|
||||
if (textDocument && textDocument->isModified()) {
|
||||
|
||||
@@ -54,8 +54,8 @@ class DiffEditorPlugin : public ExtensionSystem::IPlugin
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "DiffEditor.json")
|
||||
|
||||
public:
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage = nullptr);
|
||||
void extensionsInitialized();
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage = nullptr) override;
|
||||
void extensionsInitialized() override;
|
||||
|
||||
private:
|
||||
void updateDiffCurrentFileAction();
|
||||
|
||||
@@ -168,7 +168,7 @@ void DiffEditorWidgetController::patch(bool revert, int fileIndex, int chunkInde
|
||||
workingDirectory, strip, revert))
|
||||
m_document->reload();
|
||||
} else { // PatchEditor
|
||||
TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(
|
||||
auto textDocument = qobject_cast<TextEditor::TextDocument *>(
|
||||
DocumentModel::documentForFilePath(absFileName));
|
||||
if (!textDocument)
|
||||
return;
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
PatchEditor
|
||||
};
|
||||
|
||||
DiffFileInfo() {}
|
||||
DiffFileInfo() = default;
|
||||
DiffFileInfo(const QString &file) : fileName(file) {}
|
||||
DiffFileInfo(const QString &file, const QString &type)
|
||||
: fileName(file), typeInfo(type) {}
|
||||
|
||||
@@ -93,17 +93,17 @@ class UnifiedView : public IDiffView
|
||||
public:
|
||||
UnifiedView();
|
||||
|
||||
QWidget *widget();
|
||||
QWidget *widget() override;
|
||||
TextEditor::TextEditorWidget *textEditorWidget();
|
||||
|
||||
void setDocument(DiffEditorDocument *document);
|
||||
void setDocument(DiffEditorDocument *document) override;
|
||||
|
||||
void beginOperation();
|
||||
void setCurrentDiffFileIndex(int index);
|
||||
void setDiff(const QList<FileData> &diffFileList, const QString &workingDirectory);
|
||||
void endOperation(bool success);
|
||||
void beginOperation() override;
|
||||
void setCurrentDiffFileIndex(int index) override;
|
||||
void setDiff(const QList<FileData> &diffFileList, const QString &workingDirectory) override;
|
||||
void endOperation(bool success) override;
|
||||
|
||||
void setSync(bool sync);
|
||||
void setSync(bool sync) override;
|
||||
|
||||
private:
|
||||
UnifiedDiffEditorWidget *m_widget = nullptr;
|
||||
@@ -116,18 +116,18 @@ class SideBySideView : public IDiffView
|
||||
public:
|
||||
SideBySideView();
|
||||
|
||||
QWidget *widget();
|
||||
QWidget *widget() override;
|
||||
TextEditor::TextEditorWidget *leftEditorWidget();
|
||||
TextEditor::TextEditorWidget *rightEditorWidget();
|
||||
|
||||
void setDocument(DiffEditorDocument *document);
|
||||
void setDocument(DiffEditorDocument *document) override;
|
||||
|
||||
void beginOperation();
|
||||
void setCurrentDiffFileIndex(int index);
|
||||
void setDiff(const QList<FileData> &diffFileList, const QString &workingDirectory);
|
||||
void endOperation(bool success);
|
||||
void beginOperation() override;
|
||||
void setCurrentDiffFileIndex(int index) override;
|
||||
void setDiff(const QList<FileData> &diffFileList, const QString &workingDirectory) override;
|
||||
void endOperation(bool success) override;
|
||||
|
||||
void setSync(bool sync);
|
||||
void setSync(bool sync) override;
|
||||
|
||||
private:
|
||||
SideBySideDiffEditorWidget *m_widget;
|
||||
|
||||
@@ -40,9 +40,7 @@ SelectableTextEditorWidget::SelectableTextEditorWidget(Core::Id id, QWidget *par
|
||||
setupFallBackEditor(id);
|
||||
}
|
||||
|
||||
SelectableTextEditorWidget::~SelectableTextEditorWidget()
|
||||
{
|
||||
}
|
||||
SelectableTextEditorWidget::~SelectableTextEditorWidget() = default;
|
||||
|
||||
static QList<DiffSelection> subtractSelection(
|
||||
const DiffSelection &minuendSelection,
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Internal {
|
||||
class DiffSelection
|
||||
{
|
||||
public:
|
||||
DiffSelection() {}
|
||||
DiffSelection() = default;
|
||||
DiffSelection(QTextCharFormat *f) : format(f) {}
|
||||
DiffSelection(int s, int e, QTextCharFormat *f) : start(s), end(e), format(f) {}
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ SideDiffEditorWidget::SideDiffEditorWidget(QWidget *parent)
|
||||
ToolTip::hide();
|
||||
});
|
||||
|
||||
TextDocumentLayout *documentLayout = qobject_cast<TextDocumentLayout*>(document()->documentLayout());
|
||||
auto documentLayout = qobject_cast<TextDocumentLayout*>(document()->documentLayout());
|
||||
if (documentLayout)
|
||||
connect(documentLayout, &TextDocumentLayout::foldChanged,
|
||||
this, &SideDiffEditorWidget::foldChanged);
|
||||
@@ -210,7 +210,7 @@ void SideDiffEditorWidget::setFolded(int blockNumber, bool folded)
|
||||
|
||||
TextDocumentLayout::doFoldOrUnfold(block, !folded);
|
||||
|
||||
TextDocumentLayout *documentLayout = qobject_cast<TextDocumentLayout*>(document()->documentLayout());
|
||||
auto documentLayout = qobject_cast<TextDocumentLayout*>(document()->documentLayout());
|
||||
documentLayout->requestUpdate();
|
||||
documentLayout->emitDocumentSizeChanged();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class SideBySideDiffEditorWidget : public QWidget
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SideBySideDiffEditorWidget(QWidget *parent = nullptr);
|
||||
~SideBySideDiffEditorWidget();
|
||||
~SideBySideDiffEditorWidget() override;
|
||||
|
||||
TextEditor::TextEditorWidget *leftEditorWidget() const;
|
||||
TextEditor::TextEditorWidget *rightEditorWidget() const;
|
||||
|
||||
Reference in New Issue
Block a user