Commit e2aa0bbe authored by hjk's avatar hjk
Browse files

TextEditor: Clean up RefactoringChanges



Namespaces; use QVector instead of QList for
QPair<QTextCursor, QTextCursor>.

Change-Id: I60c3bede66c404ded96b982299cf853b0b9d4f8e
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent d33727b6
......@@ -43,7 +43,7 @@
#include <QDebug>
#include <QApplication>
using namespace TextEditor;
namespace TextEditor {
RefactoringChanges::RefactoringChanges()
: m_data(new RefactoringChangesData)
......@@ -56,10 +56,10 @@ RefactoringChanges::RefactoringChanges(RefactoringChangesData *data)
RefactoringChanges::~RefactoringChanges()
{}
QList<QPair<QTextCursor, QTextCursor > > RefactoringChanges::rangesToSelections(QTextDocument *document,
const QList<Range> &ranges)
RefactoringSelections RefactoringChanges::rangesToSelections(QTextDocument *document,
const QList<Range> &ranges)
{
QList<QPair<QTextCursor, QTextCursor> > selections;
RefactoringSelections selections;
foreach (const Range &range, ranges) {
QTextCursor start(document);
......@@ -179,7 +179,7 @@ RefactoringFile::RefactoringFile(const QString &fileName, const QSharedPointer<R
{
QList<Core::IEditor *> editors = Core::DocumentModel::editorsForFilePath(fileName);
if (!editors.isEmpty())
m_editor = qobject_cast<TextEditor::BaseTextEditorWidget *>(editors.first()->widget());
m_editor = qobject_cast<BaseTextEditorWidget *>(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<QPair<QTextCursor, QTextCursor> > &indentSelections =
const RefactoringSelections &indentSelections =
RefactoringChanges::rangesToSelections(doc, m_indentRanges);
m_indentRanges.clear();
const QList<QPair<QTextCursor, QTextCursor> > &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<QPair<QTextCursor, QTextCursor> > &ranges)
const RefactoringSelections &ranges)
{
typedef QPair<QTextCursor, QTextCursor> CursorPair;
......@@ -419,3 +419,5 @@ void RefactoringChangesData::reindentSelection(const QTextCursor &, const QStrin
void RefactoringChangesData::fileChanged(const QString &)
{
}
} // namespace TextEditor
......@@ -50,6 +50,7 @@ class RefactoringChanges;
class RefactoringFile;
class RefactoringChangesData;
typedef QSharedPointer<RefactoringFile> RefactoringFilePtr;
typedef QVector<QPair<QTextCursor, QTextCursor> > 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<QPair<QTextCursor, QTextCursor> > &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<QPair<QTextCursor, QTextCursor> > rangesToSelections(QTextDocument *document,
const QList<Range> &ranges);
static RefactoringSelections rangesToSelections(QTextDocument *document, const QList<Range> &ranges);
protected:
QSharedPointer<RefactoringChangesData> m_data;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment