diff options
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeeditor.cpp | 2 | ||||
-rw-r--r-- | src/plugins/cpaster/cpasterplugin.cpp | 2 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppeditor.cpp | 8 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerplugin.cpp | 2 | ||||
-rw-r--r-- | src/plugins/projectexplorer/allprojectsfind.cpp | 3 | ||||
-rw-r--r-- | src/plugins/texteditor/basefilefind.cpp | 4 | ||||
-rw-r--r-- | src/plugins/texteditor/basetextdocument.cpp | 63 | ||||
-rw-r--r-- | src/plugins/texteditor/basetextdocument.h | 30 | ||||
-rw-r--r-- | src/plugins/texteditor/basetexteditor.cpp | 5 | ||||
-rw-r--r-- | src/plugins/texteditor/basetexteditor.h | 2 | ||||
-rw-r--r-- | src/plugins/texteditor/findincurrentfile.cpp | 3 | ||||
-rw-r--r-- | src/plugins/texteditor/findinopenfiles.cpp | 2 |
12 files changed, 56 insertions, 70 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp index f03d1f30f2..4772f256d1 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp @@ -109,7 +109,7 @@ void CMakeEditor::build() QString CMakeEditor::contextHelpId() const { int pos = position(); - TextEditor::BaseTextEditorDocument* doc = const_cast<CMakeEditor*>(this)->textDocument(); + TextEditor::BaseTextDocument *doc = const_cast<CMakeEditor*>(this)->textDocument(); QChar chr; do { diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp index 0baaed7743..605a2176d1 100644 --- a/src/plugins/cpaster/cpasterplugin.cpp +++ b/src/plugins/cpaster/cpasterplugin.cpp @@ -214,7 +214,7 @@ void CodepasterPlugin::postEditor() if (const BaseTextEditor *textEditor = qobject_cast<const BaseTextEditor *>(editor)) data = textEditor->selectedText(); if (data.isEmpty()) { - if (const BaseTextEditorDocument *textDocument = qobject_cast<const BaseTextEditorDocument *>(document)) + if (auto textDocument = qobject_cast<const BaseTextDocument *>(document)) data = textDocument->plainText(); } post(data, mimeType); diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 22b1f6ef83..7d833b6e75 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -1054,8 +1054,8 @@ void CPPEditorWidget::onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefL Core::IDocument *targetDocument = Core::DocumentModel::documentForFilePath( d->m_declDefLink->targetFile->fileName()); if (baseTextDocument() != targetDocument) { - if (TextEditor::BaseTextEditorDocument *textEditorDocument = qobject_cast<TextEditor::BaseTextEditorDocument *>(targetDocument)) - connect(textEditorDocument, SIGNAL(contentsChanged()), + if (auto textDocument = qobject_cast<TextEditor::BaseTextDocument *>(targetDocument)) + connect(textDocument, SIGNAL(contentsChanged()), this, SLOT(abortDeclDefLink())); } @@ -1103,8 +1103,8 @@ void CPPEditorWidget::abortDeclDefLink() Core::IDocument *targetDocument = Core::DocumentModel::documentForFilePath(d->m_declDefLink->targetFile->fileName()); if (baseTextDocument() != targetDocument) { - if (TextEditor::BaseTextEditorDocument *textEditorDocument = qobject_cast<TextEditor::BaseTextEditorDocument *>(targetDocument)) - disconnect(textEditorDocument, SIGNAL(contentsChanged()), + if (auto textDocument = qobject_cast<TextEditor::BaseTextDocument *>(targetDocument)) + disconnect(textDocument, SIGNAL(contentsChanged()), this, SLOT(abortDeclDefLink())); } diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 0a89cff50e..5b556e6462 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1891,7 +1891,7 @@ void DebuggerPluginPrivate::requestContextMenu(BaseTextEditor *editor, bool contextUsable = true; BreakpointModelId id = BreakpointModelId(); - BaseTextEditorDocument *document = editor->textDocument(); + BaseTextDocument *document = editor->textDocument(); args.fileName = document->filePath(); if (document->property(Constants::OPENED_WITH_DISASSEMBLY).toBool()) { QString line = document->plainText() diff --git a/src/plugins/projectexplorer/allprojectsfind.cpp b/src/plugins/projectexplorer/allprojectsfind.cpp index 7b8d047354..7762783303 100644 --- a/src/plugins/projectexplorer/allprojectsfind.cpp +++ b/src/plugins/projectexplorer/allprojectsfind.cpp @@ -83,8 +83,7 @@ Utils::FileIterator *AllProjectsFind::filesForProjects(const QStringList &nameFi foreach (const QString &filter, nameFilters) { filterRegs << QRegExp(filter, Qt::CaseInsensitive, QRegExp::Wildcard); } - QMap<QString, QTextCodec *> openEditorEncodings - = TextEditor::BaseTextEditorDocument::openedTextDocumentEncodings(); + QMap<QString, QTextCodec *> openEditorEncodings = BaseTextDocument::openedTextDocumentEncodings(); QMap<QString, QTextCodec *> encodings; foreach (const Project *project, projects) { QStringList projectFiles = project->files(Project::AllFiles); diff --git a/src/plugins/texteditor/basefilefind.cpp b/src/plugins/texteditor/basefilefind.cpp index 3a9980b2f4..1fee2bca11 100644 --- a/src/plugins/texteditor/basefilefind.cpp +++ b/src/plugins/texteditor/basefilefind.cpp @@ -174,12 +174,12 @@ void BaseFileFind::runSearch(Core::SearchResult *search) watcher->setFuture(Utils::findInFilesRegExp(parameters.text, files(parameters.nameFilters, parameters.additionalParameters), textDocumentFlagsForFindFlags(parameters.flags), - BaseTextEditorDocument::openedTextDocumentContents())); + BaseTextDocument::openedTextDocumentContents())); } else { watcher->setFuture(Utils::findInFiles(parameters.text, files(parameters.nameFilters, parameters.additionalParameters), textDocumentFlagsForFindFlags(parameters.flags), - BaseTextEditorDocument::openedTextDocumentContents())); + BaseTextDocument::openedTextDocumentContents())); } FutureProgress *progress = ProgressManager::addTask(watcher->future(), tr("Searching"), Constants::TASK_SEARCH); diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp index 0d51aaa16b..e2ac75a1f8 100644 --- a/src/plugins/texteditor/basetextdocument.cpp +++ b/src/plugins/texteditor/basetextdocument.cpp @@ -197,38 +197,15 @@ void BaseTextDocumentPrivate::onModificationChanged(bool modified) updateRevisions(); } -BaseTextEditorDocument::BaseTextEditorDocument(QObject *parent) - : Core::TextDocument(parent) -{ -} -QMap<QString, QString> BaseTextEditorDocument::openedTextDocumentContents() -{ - QMap<QString, QString> workingCopy; - foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) { - BaseTextEditorDocument *textEditorDocument = qobject_cast<BaseTextEditorDocument *>(document); - if (!textEditorDocument) - continue; - QString fileName = textEditorDocument->filePath(); - workingCopy[fileName] = textEditorDocument->plainText(); - } - return workingCopy; -} - -QMap<QString, QTextCodec *> BaseTextEditorDocument::openedTextDocumentEncodings() -{ - QMap<QString, QTextCodec *> workingCopy; - foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) { - BaseTextEditorDocument *textEditorDocument = qobject_cast<BaseTextEditorDocument *>(document); - if (!textEditorDocument) - continue; - QString fileName = textEditorDocument->filePath(); - workingCopy[fileName] = const_cast<QTextCodec *>(textEditorDocument->codec()); - } - return workingCopy; -} +/////////////////////////////////////////////////////////////////////// +// +// BaseTextDocument +// +/////////////////////////////////////////////////////////////////////// -BaseTextDocument::BaseTextDocument() : d(new BaseTextDocumentPrivate(this)) +BaseTextDocument::BaseTextDocument() + : d(new BaseTextDocumentPrivate(this)) { connect(d->m_document, SIGNAL(modificationChanged(bool)), d, SLOT(onModificationChanged(bool))); connect(d->m_document, SIGNAL(modificationChanged(bool)), this, SIGNAL(changed())); @@ -252,6 +229,32 @@ BaseTextDocument::~BaseTextDocument() delete d; } +QMap<QString, QString> BaseTextDocument::openedTextDocumentContents() +{ + QMap<QString, QString> workingCopy; + foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) { + BaseTextDocument *textEditorDocument = qobject_cast<BaseTextDocument *>(document); + if (!textEditorDocument) + continue; + QString fileName = textEditorDocument->filePath(); + workingCopy[fileName] = textEditorDocument->plainText(); + } + return workingCopy; +} + +QMap<QString, QTextCodec *> BaseTextDocument::openedTextDocumentEncodings() +{ + QMap<QString, QTextCodec *> workingCopy; + foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) { + BaseTextDocument *textEditorDocument = qobject_cast<BaseTextDocument *>(document); + if (!textEditorDocument) + continue; + QString fileName = textEditorDocument->filePath(); + workingCopy[fileName] = const_cast<QTextCodec *>(textEditorDocument->codec()); + } + return workingCopy; +} + QString BaseTextDocument::plainText() const { return document()->toPlainText(); diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h index 9b3f868dfb..437c843270 100644 --- a/src/plugins/texteditor/basetextdocument.h +++ b/src/plugins/texteditor/basetextdocument.h @@ -58,24 +58,7 @@ class TypingSettings; typedef QList<TextMark *> TextMarks; -class TEXTEDITOR_EXPORT BaseTextEditorDocument : public Core::TextDocument -{ - Q_OBJECT -public: - explicit BaseTextEditorDocument(QObject *parent = 0); - - virtual QString plainText() const = 0; - virtual QString textAt(int pos, int length) const = 0; - virtual QChar characterAt(int pos) const = 0; - - static QMap<QString, QString> openedTextDocumentContents(); - static QMap<QString, QTextCodec *> openedTextDocumentEncodings(); - -signals: - void contentsChanged(); -}; - -class TEXTEDITOR_EXPORT BaseTextDocument : public BaseTextEditorDocument +class TEXTEDITOR_EXPORT BaseTextDocument : public Core::TextDocument { Q_OBJECT @@ -83,10 +66,12 @@ public: BaseTextDocument(); virtual ~BaseTextDocument(); - // BaseTextEditorDocument - QString plainText() const; - QString textAt(int pos, int length) const; - QChar characterAt(int pos) const; + static QMap<QString, QString> openedTextDocumentContents(); + static QMap<QString, QTextCodec *> openedTextDocumentEncodings(); + + virtual QString plainText() const; + virtual QString textAt(int pos, int length) const; + virtual QChar characterAt(int pos) const; void setTypingSettings(const TypingSettings &typingSettings); void setStorageSettings(const StorageSettings &storageSettings); @@ -148,6 +133,7 @@ public slots: void setFontSettings(const TextEditor::FontSettings &fontSettings); signals: + void contentsChanged(); void tabSettingsChanged(); void fontSettingsChanged(); diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 4fd46e17b4..5fd49b555a 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -6850,12 +6850,11 @@ bool BaseTextEditor::restoreState(const QByteArray &state) return m_editorWidget->restoreState(state); } -BaseTextEditorDocument *BaseTextEditor::textDocument() +BaseTextDocument *BaseTextEditor::textDocument() { - return qobject_cast<BaseTextEditorDocument *>(document()); + return qobject_cast<BaseTextDocument *>(document()); } - BaseTextEditor *BaseTextEditor::currentTextEditor() { return qobject_cast<BaseTextEditor *>(Core::EditorManager::currentEditor()); diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index c3371c490e..d81653b8d0 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -121,7 +121,7 @@ public: BaseTextEditor(BaseTextEditorWidget *editorWidget); ~BaseTextEditor(); - virtual BaseTextEditorDocument *textDocument(); + virtual BaseTextDocument *textDocument(); enum MarkRequestKind { BreakpointRequest, diff --git a/src/plugins/texteditor/findincurrentfile.cpp b/src/plugins/texteditor/findincurrentfile.cpp index ffa0068ef1..b4a916f29b 100644 --- a/src/plugins/texteditor/findincurrentfile.cpp +++ b/src/plugins/texteditor/findincurrentfile.cpp @@ -63,8 +63,7 @@ Utils::FileIterator *FindInCurrentFile::files(const QStringList &nameFilters, { Q_UNUSED(nameFilters) QString fileName = additionalParameters.toString(); - QMap<QString, QTextCodec *> openEditorEncodings - = BaseTextEditorDocument::openedTextDocumentEncodings(); + QMap<QString, QTextCodec *> openEditorEncodings = BaseTextDocument::openedTextDocumentEncodings(); QTextCodec *codec = openEditorEncodings.value(fileName); if (!codec) codec = Core::EditorManager::defaultTextCodec(); diff --git a/src/plugins/texteditor/findinopenfiles.cpp b/src/plugins/texteditor/findinopenfiles.cpp index a46eb50acb..e3e33beda3 100644 --- a/src/plugins/texteditor/findinopenfiles.cpp +++ b/src/plugins/texteditor/findinopenfiles.cpp @@ -65,7 +65,7 @@ Utils::FileIterator *FindInOpenFiles::files(const QStringList &nameFilters, Q_UNUSED(nameFilters) Q_UNUSED(additionalParameters) QMap<QString, QTextCodec *> openEditorEncodings - = BaseTextEditorDocument::openedTextDocumentEncodings(); + = BaseTextDocument::openedTextDocumentEncodings(); QStringList fileNames; QList<QTextCodec *> codecs; foreach (Core::DocumentModel::Entry *entry, |