forked from qt-creator/qt-creator
CppEditor: Move isObjC property to document.
Change-Id: I2267c69001da6bc136d26d874331dd734c8693f5 Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -526,11 +526,11 @@ CPPEditorWidget::CPPEditorWidget(CPPEditorWidget *other)
|
||||
|
||||
void CPPEditorWidget::ctor()
|
||||
{
|
||||
m_cppEditorDocument = qobject_cast<CPPEditorDocument *>(baseTextDocument());
|
||||
m_currentRenameSelection = NoCurrentRenameSelection;
|
||||
m_inRename = false;
|
||||
m_inRenameChanged = false;
|
||||
m_firstRenameChange = false;
|
||||
m_objcEnabled = false;
|
||||
m_commentsSettings = CppTools::CppToolsSettings::instance()->commentsSettings();
|
||||
m_followSymbolUnderCursor.reset(new FollowSymbolUnderCursor(this));
|
||||
m_preprocessorButton = 0;
|
||||
@@ -572,10 +572,7 @@ void CPPEditorWidget::ctor()
|
||||
|
||||
connect(baseTextDocument(), SIGNAL(filePathChanged(QString,QString)),
|
||||
this, SLOT(onFilePathChanged()));
|
||||
connect(baseTextDocument(), SIGNAL(mimeTypeChanged()),
|
||||
this, SLOT(onMimeTypeChanged()));
|
||||
onFilePathChanged();
|
||||
onMimeTypeChanged();
|
||||
}
|
||||
|
||||
CPPEditorWidget::~CPPEditorWidget()
|
||||
@@ -584,6 +581,11 @@ CPPEditorWidget::~CPPEditorWidget()
|
||||
m_modelManager->deleteCppEditorSupport(editor());
|
||||
}
|
||||
|
||||
CPPEditorDocument *CPPEditorWidget::cppEditorDocument() const
|
||||
{
|
||||
return m_cppEditorDocument;
|
||||
}
|
||||
|
||||
TextEditor::BaseTextEditor *CPPEditorWidget::createEditor()
|
||||
{
|
||||
CPPEditor *editable = new CPPEditor(this);
|
||||
@@ -718,14 +720,6 @@ void CPPEditorWidget::selectAll()
|
||||
BaseTextEditorWidget::selectAll();
|
||||
}
|
||||
|
||||
void CPPEditorWidget::setObjCEnabled(bool onoff)
|
||||
{
|
||||
m_objcEnabled = onoff;
|
||||
}
|
||||
|
||||
bool CPPEditorWidget::isObjCEnabled() const
|
||||
{ return m_objcEnabled; }
|
||||
|
||||
void CPPEditorWidget::startRename()
|
||||
{
|
||||
m_inRenameChanged = false;
|
||||
@@ -1822,13 +1816,6 @@ void CPPEditorWidget::onFilePathChanged()
|
||||
m_preprocessorButton->update();
|
||||
}
|
||||
|
||||
void CPPEditorWidget::onMimeTypeChanged()
|
||||
{
|
||||
const QString &mt = baseTextDocument()->mimeType();
|
||||
setObjCEnabled(mt == QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE)
|
||||
|| mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
|
||||
}
|
||||
|
||||
void CPPEditorWidget::applyDeclDefLinkChanges(bool jumpToMatch)
|
||||
{
|
||||
if (!m_declDefLink)
|
||||
@@ -1985,7 +1972,15 @@ CPPEditorDocument::CPPEditorDocument()
|
||||
{
|
||||
connect(this, SIGNAL(tabSettingsChanged()),
|
||||
this, SLOT(invalidateFormatterCache()));
|
||||
connect(this, SIGNAL(mimeTypeChanged()),
|
||||
this, SLOT(onMimeTypeChanged()));
|
||||
setSyntaxHighlighter(new CppHighlighter);
|
||||
onMimeTypeChanged();
|
||||
}
|
||||
|
||||
bool CPPEditorDocument::isObjCEnabled() const
|
||||
{
|
||||
return m_isObjCEnabled;
|
||||
}
|
||||
|
||||
void CPPEditorDocument::applyFontSettings()
|
||||
@@ -2008,4 +2003,11 @@ void CPPEditorDocument::invalidateFormatterCache()
|
||||
formatter.invalidateCache(document());
|
||||
}
|
||||
|
||||
void CPPEditorDocument::onMimeTypeChanged()
|
||||
{
|
||||
const QString &mt = mimeType();
|
||||
m_isObjCEnabled = (mt == QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE)
|
||||
|| mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
|
||||
}
|
||||
|
||||
#include <cppeditor.moc>
|
||||
|
||||
Reference in New Issue
Block a user