From e2aa0bbecd086b1420f8b94b56fbd58577f2cb5c Mon Sep 17 00:00:00 2001 From: hjk Date: Sat, 20 Sep 2014 21:54:00 +0200 Subject: [PATCH] TextEditor: Clean up RefactoringChanges Namespaces; use QVector instead of QList for QPair. Change-Id: I60c3bede66c404ded96b982299cf853b0b9d4f8e Reviewed-by: David Schulz --- src/plugins/texteditor/refactoringchanges.cpp | 18 ++++++++++-------- src/plugins/texteditor/refactoringchanges.h | 7 +++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp index 0dab146b704..a7474e2029e 100644 --- a/src/plugins/texteditor/refactoringchanges.cpp +++ b/src/plugins/texteditor/refactoringchanges.cpp @@ -43,7 +43,7 @@ #include #include -using namespace TextEditor; +namespace TextEditor { RefactoringChanges::RefactoringChanges() : m_data(new RefactoringChangesData) @@ -56,10 +56,10 @@ RefactoringChanges::RefactoringChanges(RefactoringChangesData *data) RefactoringChanges::~RefactoringChanges() {} -QList > RefactoringChanges::rangesToSelections(QTextDocument *document, - const QList &ranges) +RefactoringSelections RefactoringChanges::rangesToSelections(QTextDocument *document, + const QList &ranges) { - QList > selections; + RefactoringSelections selections; foreach (const Range &range, ranges) { QTextCursor start(document); @@ -179,7 +179,7 @@ RefactoringFile::RefactoringFile(const QString &fileName, const QSharedPointer editors = Core::DocumentModel::editorsForFilePath(fileName); if (!editors.isEmpty()) - m_editor = qobject_cast(editors.first()->widget()); + m_editor = qobject_cast(editors.first()->widget()); } RefactoringFile::~RefactoringFile() @@ -351,10 +351,10 @@ void RefactoringFile::apply() c.beginEditBlock(); // build indent selections now, applying the changeset will change locations - const QList > &indentSelections = + const RefactoringSelections &indentSelections = RefactoringChanges::rangesToSelections(doc, m_indentRanges); m_indentRanges.clear(); - const QList > &reindentSelections = + const RefactoringSelections &reindentSelections = RefactoringChanges::rangesToSelections(doc, m_reindentRanges); m_reindentRanges.clear(); @@ -385,7 +385,7 @@ void RefactoringFile::apply() void RefactoringFile::indentOrReindent(void (RefactoringChangesData::*mf)(const QTextCursor &, const QString &, const BaseTextDocument *) const, - const QList > &ranges) + const RefactoringSelections &ranges) { typedef QPair CursorPair; @@ -419,3 +419,5 @@ void RefactoringChangesData::reindentSelection(const QTextCursor &, const QStrin void RefactoringChangesData::fileChanged(const QString &) { } + +} // namespace TextEditor diff --git a/src/plugins/texteditor/refactoringchanges.h b/src/plugins/texteditor/refactoringchanges.h index 4570ed14bf4..27af9999b66 100644 --- a/src/plugins/texteditor/refactoringchanges.h +++ b/src/plugins/texteditor/refactoringchanges.h @@ -50,6 +50,7 @@ class RefactoringChanges; class RefactoringFile; class RefactoringChangesData; typedef QSharedPointer RefactoringFilePtr; +typedef QVector > RefactoringSelections; // ### listen to the m_editor::destroyed signal? class TEXTEDITOR_EXPORT RefactoringFile @@ -99,7 +100,7 @@ protected: void indentOrReindent(void (RefactoringChangesData::*mf)(const QTextCursor &, const QString &, const BaseTextDocument *) const, - const QList > &ranges); + const RefactoringSelections &ranges); protected: QString m_fileName; @@ -140,9 +141,7 @@ protected: explicit RefactoringChanges(RefactoringChangesData *data); static BaseTextEditorWidget *openEditor(const QString &fileName, bool activate, int line, int column); - - static QList > rangesToSelections(QTextDocument *document, - const QList &ranges); + static RefactoringSelections rangesToSelections(QTextDocument *document, const QList &ranges); protected: QSharedPointer m_data;