diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 8cbc6083a38..3f3d707cc0b 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -40,12 +40,12 @@ #include #include +#include #include #include #include #include -#include -#include +#include #include #include #include @@ -55,8 +55,6 @@ #include #include -#include -#include #include #include @@ -420,6 +418,8 @@ class CPPEditorWidgetPrivate public: CPPEditorWidgetPrivate(CPPEditorWidget *q); + QTimer *newSingleShowTimer(int msecInterval); + public: CPPEditorWidget *q; @@ -481,6 +481,14 @@ CPPEditorWidgetPrivate::CPPEditorWidgetPrivate(CPPEditorWidget *q) { } +QTimer *CPPEditorWidgetPrivate::newSingleShowTimer(int msecInterval) +{ + QTimer *timer = new QTimer(q); + timer->setSingleShot(true); + timer->setInterval(msecInterval); + return timer; +} + CPPEditorWidget::CPPEditorWidget(QWidget *parent) : TextEditor::BaseTextEditorWidget(new CPPEditorDocument(), parent) { @@ -578,24 +586,16 @@ void CPPEditorWidget::createToolBar(CPPEditor *editor) CppEditorPlugin::instance(), SLOT(setSortedOutline(bool))); d->m_outlineCombo->addAction(d->m_sortAction); - d->m_updateOutlineTimer = new QTimer(this); - d->m_updateOutlineTimer->setSingleShot(true); - d->m_updateOutlineTimer->setInterval(UPDATE_OUTLINE_INTERVAL); + d->m_updateOutlineTimer = d->newSingleShowTimer(UPDATE_OUTLINE_INTERVAL); connect(d->m_updateOutlineTimer, SIGNAL(timeout()), this, SLOT(updateOutlineNow())); - d->m_updateOutlineIndexTimer = new QTimer(this); - d->m_updateOutlineIndexTimer->setSingleShot(true); - d->m_updateOutlineIndexTimer->setInterval(UPDATE_OUTLINE_INTERVAL); + d->m_updateOutlineIndexTimer = d->newSingleShowTimer(UPDATE_OUTLINE_INTERVAL); connect(d->m_updateOutlineIndexTimer, SIGNAL(timeout()), this, SLOT(updateOutlineIndexNow())); - d->m_updateUsesTimer = new QTimer(this); - d->m_updateUsesTimer->setSingleShot(true); - d->m_updateUsesTimer->setInterval(UPDATE_USES_INTERVAL); + d->m_updateUsesTimer = d->newSingleShowTimer(UPDATE_USES_INTERVAL); connect(d->m_updateUsesTimer, SIGNAL(timeout()), this, SLOT(updateUsesNow())); - d->m_updateFunctionDeclDefLinkTimer = new QTimer(this); - d->m_updateFunctionDeclDefLinkTimer->setSingleShot(true); - d->m_updateFunctionDeclDefLinkTimer->setInterval(UPDATE_FUNCTION_DECL_DEF_LINK_INTERVAL); + d->m_updateFunctionDeclDefLinkTimer = d->newSingleShowTimer(UPDATE_FUNCTION_DECL_DEF_LINK_INTERVAL); connect(d->m_updateFunctionDeclDefLinkTimer, SIGNAL(timeout()), this, SLOT(updateFunctionDeclDefLinkNow())); @@ -766,8 +766,7 @@ void CPPEditorWidget::findUsages() } } - -void CPPEditorWidget::renameUsagesNow(const QString &replacement) +void CPPEditorWidget::renameUsages(const QString &replacement) { if (!d->m_modelManager) return; @@ -786,11 +785,6 @@ void CPPEditorWidget::renameUsagesNow(const QString &replacement) } } -void CPPEditorWidget::renameUsages() -{ - renameUsagesNow(); -} - void CPPEditorWidget::markSymbolsNow() { QTC_ASSERT(d->m_referencesWatcher, return); diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h index f6fb196b529..0a88efff6a8 100644 --- a/src/plugins/cppeditor/cppeditor.h +++ b/src/plugins/cppeditor/cppeditor.h @@ -34,7 +34,6 @@ #include "cppfunctiondecldeflink.h" -#include #include #include @@ -50,6 +49,7 @@ class Symbol; namespace CppTools { class SemanticInfo; +class CommentsSettings; } namespace CppEditor { @@ -118,11 +118,12 @@ public slots: void unCommentSelection() QTC_OVERRIDE; void setSortedOutline(bool sort); void switchDeclarationDefinition(bool inNextSplit); - void renameSymbolUnderCursor(); - void renameUsages(); - void findUsages(); void showPreProcessorWidget(); - void renameUsagesNow(const QString &replacement = QString()); + + void findUsages(); + void renameSymbolUnderCursor(); + void renameUsages(const QString &replacement = QString()); + void semanticRehighlight(bool force = false); void highlighterStarted(QFuture *highlighter, unsigned revision); @@ -138,8 +139,9 @@ protected: bool openLink(const Link &link, bool inNextSplit) QTC_OVERRIDE { return openCppEditorAt(link, inNextSplit); } - const CPlusPlus::Macro *findCanonicalMacro(const QTextCursor &cursor, - CPlusPlus::Document::Ptr doc) const; + Link findLinkAt(const QTextCursor &, bool resolveTarget = true, + bool inNextSplit = false) QTC_OVERRIDE; + protected slots: void slotCodeStyleSettingsChanged(const QVariant &) QTC_OVERRIDE; @@ -164,38 +166,35 @@ private slots: void finishHighlightSymbolUsages(); void markSymbolsNow(); - void performQuickFix(int index); - void onRefactorMarkerClicked(const TextEditor::RefactorMarker &marker); - void onCommentsSettingsChanged(const CppTools::CommentsSettings &settings); + void abortDeclDefLink(); private: + static bool openCppEditorAt(const Link &, bool inNextSplit = false); + CPPEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity void ctor(); + void createToolBar(CPPEditor *editable); + unsigned editorRevision() const; bool isOutdated() const; + const CPlusPlus::Macro *findCanonicalMacro(const QTextCursor &cursor, + CPlusPlus::Document::Ptr doc) const; + void markSymbols(const QTextCursor &tc, const CppTools::SemanticInfo &info); bool sortedOutline() const; void highlightUses(const QList &uses, QList *selections); - void createToolBar(CPPEditor *editable); - void startRename(); void finishRename(); void abortRename(); - Q_SLOT void abortDeclDefLink(); - - Link findLinkAt(const QTextCursor &, bool resolveTarget = true, - bool inNextSplit = false) QTC_OVERRIDE; - bool openCppEditorAt(const Link &, bool inNextSplit = false); - QModelIndex indexForPosition(int line, int column, const QModelIndex &rootIndex = QModelIndex()) const; diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index b62b844301a..0ce49f10b19 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -1786,7 +1786,7 @@ public: m_name[i] = m_name.at(i).toUpper(); } } - static_cast(assistInterface()->editor())->renameUsagesNow(m_name); + static_cast(assistInterface()->editor())->renameUsages(m_name); } static bool isConvertibleUnderscore(const QString &name, int pos)