diff options
Diffstat (limited to 'src/plugins/diffeditor')
-rw-r--r-- | src/plugins/diffeditor/diffeditor.cpp | 6 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditor.h | 6 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditorcontroller.cpp | 13 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditorcontroller.h | 29 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditordocument.cpp | 6 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditorfactory.cpp | 6 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditorfactory.h | 6 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditorplugin.cpp | 8 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditorplugin.h | 6 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditorwidgetcontroller.cpp | 9 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffview.cpp | 6 | ||||
-rw-r--r-- | src/plugins/diffeditor/selectabletexteditorwidget.cpp | 6 | ||||
-rw-r--r-- | src/plugins/diffeditor/selectabletexteditorwidget.h | 6 | ||||
-rw-r--r-- | src/plugins/diffeditor/sidebysidediffeditorwidget.cpp | 20 | ||||
-rw-r--r-- | src/plugins/diffeditor/unifieddiffeditorwidget.cpp | 10 |
15 files changed, 59 insertions, 84 deletions
diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp index 929c30c3398..ddf91b4e1ec 100644 --- a/src/plugins/diffeditor/diffeditor.cpp +++ b/src/plugins/diffeditor/diffeditor.cpp @@ -51,8 +51,7 @@ using namespace Core; using namespace TextEditor; using namespace Utils; -namespace DiffEditor { -namespace Internal { +namespace DiffEditor::Internal { class DescriptionEditorWidget : public TextEditorWidget { @@ -618,7 +617,6 @@ void DiffEditor::showDiffView(IDiffView *view) setupView(view); } -} // namespace Internal -} // namespace DiffEditor +} // namespace DiffEditor::Internal #include "diffeditor.moc" diff --git a/src/plugins/diffeditor/diffeditor.h b/src/plugins/diffeditor/diffeditor.h index 49922d323eb..24f89d55030 100644 --- a/src/plugins/diffeditor/diffeditor.h +++ b/src/plugins/diffeditor/diffeditor.h @@ -18,9 +18,8 @@ QT_END_NAMESPACE namespace TextEditor { class TextEditorWidget; } -namespace DiffEditor { +namespace DiffEditor::Internal { -namespace Internal { class DescriptionEditorWidget; class DiffEditorDocument; class IDiffView; @@ -95,5 +94,4 @@ private: bool m_showDescription = true; }; -} // namespace Internal -} // namespace DiffEditor +} // namespace DiffEditor::Internal diff --git a/src/plugins/diffeditor/diffeditorcontroller.cpp b/src/plugins/diffeditor/diffeditorcontroller.cpp index 1ab7bfccb2d..4756afc7828 100644 --- a/src/plugins/diffeditor/diffeditorcontroller.cpp +++ b/src/plugins/diffeditor/diffeditorcontroller.cpp @@ -124,15 +124,18 @@ void DiffEditorController::reloadFinished(bool success) m_document->endReload(success); } -void DiffEditorController::setStartupFile(const QString &startupFile) +void DiffEditorController::addExtraActions(QMenu *menu, int fileIndex, int chunkIndex, + const ChunkSelection &selection) { - m_document->setStartupFile(startupFile); + Q_UNUSED(menu) + Q_UNUSED(fileIndex) + Q_UNUSED(chunkIndex) + Q_UNUSED(selection) } -void DiffEditorController::requestChunkActions(QMenu *menu, int fileIndex, int chunkIndex, - const ChunkSelection &selection) +void DiffEditorController::setStartupFile(const QString &startupFile) { - emit chunkActionsRequested(menu, fileIndex, chunkIndex, selection); + m_document->setStartupFile(startupFile); } bool DiffEditorController::chunkExists(int fileIndex, int chunkIndex) const diff --git a/src/plugins/diffeditor/diffeditorcontroller.h b/src/plugins/diffeditor/diffeditorcontroller.h index 1f791b2dcb3..1fddc31c4dd 100644 --- a/src/plugins/diffeditor/diffeditorcontroller.h +++ b/src/plugins/diffeditor/diffeditorcontroller.h @@ -19,7 +19,10 @@ namespace Utils { class FilePath; } namespace DiffEditor { -namespace Internal { class DiffEditorDocument; } +namespace Internal { +class DiffEditorDocument; +class DiffEditorWidgetController; +} class ChunkSelection; @@ -30,12 +33,9 @@ public: explicit DiffEditorController(Core::IDocument *document); void requestReload(); - bool isReloading() const; Utils::FilePath workingDirectory() const; void setWorkingDirectory(const Utils::FilePath &directory); - int contextLineCount() const; - bool ignoreWhitespace() const; enum PatchOption { NoOption = 0, @@ -43,23 +43,19 @@ public: AddPrefix = 2 }; Q_DECLARE_FLAGS(PatchOptions, PatchOption) - QString makePatch(int fileIndex, int chunkIndex, const ChunkSelection &selection, - PatchOptions options) const; - static Core::IDocument *findOrCreateDocument(const QString &vcsId, - const QString &displayName); + static Core::IDocument *findOrCreateDocument(const QString &vcsId, const QString &displayName); static DiffEditorController *controller(Core::IDocument *document); - void requestChunkActions(QMenu *menu, int fileIndex, int chunkIndex, - const ChunkSelection &selection); +protected: + bool isReloading() const; + int contextLineCount() const; + bool ignoreWhitespace() const; bool chunkExists(int fileIndex, int chunkIndex) const; Core::IDocument *document() const; + QString makePatch(int fileIndex, int chunkIndex, const ChunkSelection &selection, + PatchOptions options) const; -signals: - void chunkActionsRequested(QMenu *menu, int fileIndex, int chunkIndex, - const ChunkSelection &selection); - -protected: // Core functions: void setReloadRecipe(const Tasking::Group &recipe) { m_reloadRecipe = recipe; } void setDiffFiles(const QList<FileData> &diffFileList); @@ -71,6 +67,9 @@ protected: private: void reloadFinished(bool success); + friend class Internal::DiffEditorWidgetController; + virtual void addExtraActions(QMenu *menu, int fileIndex, int chunkIndex, + const ChunkSelection &selection); Internal::DiffEditorDocument *const m_document; QString m_displayName; diff --git a/src/plugins/diffeditor/diffeditordocument.cpp b/src/plugins/diffeditor/diffeditordocument.cpp index 1d43064d60f..ed89d69c4f0 100644 --- a/src/plugins/diffeditor/diffeditordocument.cpp +++ b/src/plugins/diffeditor/diffeditordocument.cpp @@ -24,8 +24,7 @@ using namespace Core; using namespace Utils; -namespace DiffEditor { -namespace Internal { +namespace DiffEditor::Internal { DiffEditorDocument::DiffEditorDocument() : Core::BaseTextDocument() @@ -388,5 +387,4 @@ void DiffEditorDocument::endReload(bool success) emit reloadFinished(success); } -} // namespace Internal -} // namespace DiffEditor +} // namespace DiffEditor::Internal diff --git a/src/plugins/diffeditor/diffeditorfactory.cpp b/src/plugins/diffeditor/diffeditorfactory.cpp index a771fda53a1..70537dd3f73 100644 --- a/src/plugins/diffeditor/diffeditorfactory.cpp +++ b/src/plugins/diffeditor/diffeditorfactory.cpp @@ -15,8 +15,7 @@ using namespace Core; using namespace TextEditor; using namespace Utils; -namespace DiffEditor { -namespace Internal { +namespace DiffEditor::Internal { DiffEditorFactory::DiffEditorFactory() : descriptionHandler { @@ -50,5 +49,4 @@ DiffEditorFactory::DiffEditorFactory() : setEditorCreator([] { return new DiffEditor(new DiffEditorDocument); }); } -} // namespace Internal -} // namespace DiffEditor +} // namespace DiffEditor::Internal diff --git a/src/plugins/diffeditor/diffeditorfactory.h b/src/plugins/diffeditor/diffeditorfactory.h index bebabb208aa..e39f0fc46fc 100644 --- a/src/plugins/diffeditor/diffeditorfactory.h +++ b/src/plugins/diffeditor/diffeditorfactory.h @@ -7,8 +7,7 @@ #include <texteditor/texteditoractionhandler.h> -namespace DiffEditor { -namespace Internal { +namespace DiffEditor::Internal { class DiffEditorFactory : public Core::IEditorFactory { @@ -22,5 +21,4 @@ private: TextEditor::TextEditorActionHandler rightHandler; }; -} // namespace Internal -} // namespace DiffEditor +} // namespace DiffEditor::Internal diff --git a/src/plugins/diffeditor/diffeditorplugin.cpp b/src/plugins/diffeditor/diffeditorplugin.cpp index 867217d86d8..3112170bc41 100644 --- a/src/plugins/diffeditor/diffeditorplugin.cpp +++ b/src/plugins/diffeditor/diffeditorplugin.cpp @@ -29,8 +29,7 @@ using namespace Core; using namespace TextEditor; using namespace Utils; -namespace DiffEditor { -namespace Internal { +namespace DiffEditor::Internal { class ReloadInput { public: @@ -133,7 +132,7 @@ DiffFilesController::DiffFilesController(IDocument *document) tasks.append(AsyncTask<FileData>(std::bind(setupDiff, _1, inputList.at(i)), std::bind(onDiffDone, _1, i))); } - taskTree.setupRoot(tasks); + taskTree.setRecipe(tasks); }; const auto onTreeDone = [this, storage] { const QList<std::optional<FileData>> &results = *storage; @@ -535,8 +534,7 @@ void DiffEditorPlugin::initialize() d = new DiffEditorPluginPrivate; } -} // namespace Internal -} // namespace DiffEditor +} // namespace DiffEditor::Internal #ifdef WITH_TESTS diff --git a/src/plugins/diffeditor/diffeditorplugin.h b/src/plugins/diffeditor/diffeditorplugin.h index 17b6a2d430d..9888628daac 100644 --- a/src/plugins/diffeditor/diffeditorplugin.h +++ b/src/plugins/diffeditor/diffeditorplugin.h @@ -6,8 +6,7 @@ #include <coreplugin/diffservice.h> #include <extensionsystem/iplugin.h> -namespace DiffEditor { -namespace Internal { +namespace DiffEditor::Internal { class DiffEditorServiceImpl : public QObject, public Core::DiffService { @@ -46,5 +45,4 @@ private slots: #endif // WITH_TESTS }; -} // namespace Internal -} // namespace DiffEditor +} // namespace DiffEditor::Internal diff --git a/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp b/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp index e3f321c7c44..0f3a57ee086 100644 --- a/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp +++ b/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp @@ -29,8 +29,7 @@ using namespace Core; using namespace TextEditor; using namespace Utils; -namespace DiffEditor { -namespace Internal { +namespace DiffEditor::Internal { DiffEditorWidgetController::DiffEditorWidgetController(QWidget *diffEditorWidget) : QObject(diffEditorWidget) @@ -280,7 +279,7 @@ void DiffEditorWidgetController::addExtraActions(QMenu *menu, int fileIndex, int const ChunkSelection &selection) { if (DiffEditorController *controller = m_document->controller()) - controller->requestChunkActions(menu, fileIndex, chunkIndex, selection); + controller->addExtraActions(menu, fileIndex, chunkIndex, selection); } void DiffEditorWidgetController::updateCannotDecodeInfo() @@ -330,6 +329,4 @@ DiffEditorInput::DiffEditorInput(DiffEditorWidgetController *controller) , m_charFormat{&controller->m_charFormat[LeftSide], &controller->m_charFormat[RightSide]} { } - -} // namespace Internal -} // namespace DiffEditor +} // namespace DiffEditor::Internal diff --git a/src/plugins/diffeditor/diffview.cpp b/src/plugins/diffeditor/diffview.cpp index 686f9798b23..1b513aefc33 100644 --- a/src/plugins/diffeditor/diffview.cpp +++ b/src/plugins/diffeditor/diffview.cpp @@ -14,8 +14,7 @@ #include <QCoreApplication> -namespace DiffEditor { -namespace Internal { +namespace DiffEditor::Internal { IDiffView::IDiffView(QObject *parent) : QObject(parent) { } @@ -230,5 +229,4 @@ void SideBySideView::setSync(bool sync) m_widget->setHorizontalSync(sync); } -} // namespace Internal -} // namespace DiffEditor +} // namespace DiffEditor::Internal diff --git a/src/plugins/diffeditor/selectabletexteditorwidget.cpp b/src/plugins/diffeditor/selectabletexteditorwidget.cpp index bbf0480a6bb..e0c95f6abd3 100644 --- a/src/plugins/diffeditor/selectabletexteditorwidget.cpp +++ b/src/plugins/diffeditor/selectabletexteditorwidget.cpp @@ -13,8 +13,7 @@ using namespace TextEditor; -namespace DiffEditor { -namespace Internal { +namespace DiffEditor::Internal { SelectableTextEditorWidget::SelectableTextEditorWidget(Utils::Id id, QWidget *parent) : TextEditorWidget(parent) @@ -142,5 +141,4 @@ void SelectableTextEditorWidget::paintBlock(QPainter *painter, TextEditorWidget::paintBlock(painter, block, offset, newSelections, clipRect); } -} // namespace Internal -} // namespace DiffEditor +} // namespace DiffEditor::Internal diff --git a/src/plugins/diffeditor/selectabletexteditorwidget.h b/src/plugins/diffeditor/selectabletexteditorwidget.h index ca128aa28e5..4b0d465204f 100644 --- a/src/plugins/diffeditor/selectabletexteditorwidget.h +++ b/src/plugins/diffeditor/selectabletexteditorwidget.h @@ -7,8 +7,7 @@ namespace TextEditor { class DisplaySettings; } -namespace DiffEditor { -namespace Internal { +namespace DiffEditor::Internal { class DiffSelection { @@ -46,5 +45,4 @@ private: DiffSelections m_diffSelections; }; -} // namespace Internal -} // namespace DiffEditor +} // namespace DiffEditor::Internal diff --git a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp index d2f58f83ac4..341edce7334 100644 --- a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp +++ b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp @@ -35,8 +35,7 @@ using namespace Utils; using namespace std::placeholders; -namespace DiffEditor { -namespace Internal { +namespace DiffEditor::Internal { static DiffSide oppositeSide(DiffSide side) { @@ -316,7 +315,7 @@ static SideBySideDiffOutput diffOutput(QPromise<SideBySideShowResults> &promise, addChunkLine(RightSide, -2); blockNumber++; } else { - for (int j = 0; j < contextFileData.chunks.count(); j++) { + for (int j = 0; j < contextFileData.chunks.size(); j++) { const ChunkData &chunkData = contextFileData.chunks.at(j); int leftLineNumber = chunkData.startingLineNumber[LeftSide]; @@ -331,7 +330,7 @@ static SideBySideDiffOutput diffOutput(QPromise<SideBySideShowResults> &promise, blockNumber++; } - const int rows = chunkData.rows.count(); + const int rows = chunkData.rows.size(); output.side[LeftSide].diffData.m_chunkInfo.setChunkIndex(blockNumber, rows, j); output.side[RightSide].diffData.m_chunkInfo.setChunkIndex(blockNumber, rows, j); @@ -342,11 +341,11 @@ static SideBySideDiffOutput diffOutput(QPromise<SideBySideShowResults> &promise, } } - if (j == contextFileData.chunks.count() - 1) { // the last chunk + if (j == contextFileData.chunks.size() - 1) { // the last chunk int skippedLines = -2; if (chunkData.contextChunk) { // if it's context chunk - skippedLines = chunkData.rows.count(); + skippedLines = chunkData.rows.size(); } else if (!contextFileData.lastChunkAtTheEndOfFile && !contextFileData.contextChunksIncluded) { // if not a context chunk and not a chunk at the end of file @@ -381,7 +380,7 @@ void SideDiffData::setLineNumber(int blockNumber, int lineNumber) { const QString lineNumberString = QString::number(lineNumber); m_lineNumbers.insert(blockNumber, lineNumber); - m_lineNumberDigits = qMax(m_lineNumberDigits, lineNumberString.count()); + m_lineNumberDigits = qMax(m_lineNumberDigits, lineNumberString.size()); } void SideDiffData::setFileInfo(int blockNumber, const DiffFileInfo &fileInfo) @@ -986,7 +985,7 @@ void SideBySideDiffEditorWidget::setFontSettings(const FontSettings &fontSetting void SideBySideDiffEditorWidget::jumpToOriginalFileRequested(DiffSide side, int diffFileIndex, int lineNumber, int columnNumber) { - if (diffFileIndex < 0 || diffFileIndex >= m_controller.m_contextFileData.count()) + if (diffFileIndex < 0 || diffFileIndex >= m_controller.m_contextFileData.size()) return; const FileData fileData = m_controller.m_contextFileData.at(diffFileIndex); @@ -1007,7 +1006,7 @@ void SideBySideDiffEditorWidget::jumpToOriginalFileRequested(DiffSide side, int int thisLineNumber = chunkData.startingLineNumber[side]; int otherLineNumber = chunkData.startingLineNumber[otherSide]; - for (int j = 0; j < chunkData.rows.count(); j++) { + for (int j = 0; j < chunkData.rows.size(); j++) { const RowData rowData = chunkData.rows.at(j); if (rowData.line[side].textLineType == TextLineData::TextLine) thisLineNumber++; @@ -1104,7 +1103,6 @@ void SideBySideDiffEditorWidget::syncCursor(SideDiffEditorWidget *source, SideDi dest->horizontalScrollBar()->setValue(oldHSliderPos); } -} // namespace Internal -} // namespace DiffEditor +} // namespace DiffEditor::Internal #include "sidebysidediffeditorwidget.moc" diff --git a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp index bb64e61d5b0..d5633d50ec0 100644 --- a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp +++ b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp @@ -28,8 +28,7 @@ using namespace Core; using namespace TextEditor; using namespace Utils; -namespace DiffEditor { -namespace Internal { +namespace DiffEditor::Internal { UnifiedDiffEditorWidget::UnifiedDiffEditorWidget(QWidget *parent) : SelectableTextEditorWidget("DiffEditor.UnifiedDiffEditor", parent) @@ -226,7 +225,7 @@ QString UnifiedDiffEditorWidget::lineNumber(int blockNumber) const const QString line = lineExists ? QString::number(m_data.m_lineNumbers[side].value(blockNumber).first) : QString(); - lineNumberString += QString(m_data.m_lineNumberDigits[side] - line.count(), ' ') + line; + lineNumberString += QString(m_data.m_lineNumberDigits[side] - line.size(), ' ') + line; }; addSideNumber(LeftSide, leftLineExists); lineNumberString += '|'; @@ -263,7 +262,7 @@ void UnifiedDiffData::setLineNumber(DiffSide side, int blockNumber, int lineNumb QTC_ASSERT(side < SideCount, return); const QString lineNumberString = QString::number(lineNumber); m_lineNumbers[side].insert(blockNumber, {lineNumber, rowNumberInChunk}); - m_lineNumberDigits[side] = qMax(m_lineNumberDigits[side], lineNumberString.count()); + m_lineNumberDigits[side] = qMax(m_lineNumberDigits[side], lineNumberString.size()); } QString UnifiedDiffData::setChunk(const DiffEditorInput &input, const ChunkData &chunkData, @@ -589,5 +588,4 @@ void UnifiedDiffEditorWidget::setCurrentDiffFileIndex(int diffFileIndex) verticalScrollBar()->setValue(blockNumber); } -} // namespace Internal -} // namespace DiffEditor +} // namespace DiffEditor::Internal |