forked from qt-creator/qt-creator
CppEditor: Further cleanup
* Kill duplicate code * Kill useless forwarding function * Regroup some declarations * Replace include by declaration Change-Id: I54656e4e97b1fbdf7cf2f4a87d17955128f3825e Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -40,12 +40,12 @@
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
|
||||
#include <cpptools/commentssettings.h>
|
||||
#include <cpptools/cppchecksymbols.h>
|
||||
#include <cpptools/cppcodeformatter.h>
|
||||
#include <cpptools/cppcompletionassistprovider.h>
|
||||
#include <cpptools/cpphighlightingsupport.h>
|
||||
#include <cpptools/cpplocalsymbols.h>
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <cpptools/cppmodelmanagerinterface.h>
|
||||
#include <cpptools/cppqtstyleindenter.h>
|
||||
#include <cpptools/cppsemanticinfo.h>
|
||||
#include <cpptools/cpptoolseditorsupport.h>
|
||||
@@ -55,8 +55,6 @@
|
||||
#include <cpptools/doxygengenerator.h>
|
||||
#include <cpptools/symbolfinder.h>
|
||||
|
||||
#include <projectexplorer/nodesvisitor.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <projectexplorer/session.h>
|
||||
|
||||
#include <texteditor/basetextdocument.h>
|
||||
@@ -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);
|
||||
|
@@ -34,7 +34,6 @@
|
||||
|
||||
#include "cppfunctiondecldeflink.h"
|
||||
|
||||
#include <cpptools/commentssettings.h>
|
||||
#include <texteditor/basetexteditor.h>
|
||||
#include <texteditor/semantichighlighter.h>
|
||||
|
||||
@@ -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<TextEditor::HighlightingResult> *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<TextEditor::HighlightingResult> &uses,
|
||||
QList<QTextEdit::ExtraSelection> *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;
|
||||
|
||||
|
@@ -1786,7 +1786,7 @@ public:
|
||||
m_name[i] = m_name.at(i).toUpper();
|
||||
}
|
||||
}
|
||||
static_cast<CPPEditorWidget*>(assistInterface()->editor())->renameUsagesNow(m_name);
|
||||
static_cast<CPPEditorWidget*>(assistInterface()->editor())->renameUsages(m_name);
|
||||
}
|
||||
|
||||
static bool isConvertibleUnderscore(const QString &name, int pos)
|
||||
|
Reference in New Issue
Block a user