Commit e60f355f authored by Eike Ziller's avatar Eike Ziller

CppEditor: Move isObjC property to document.

Change-Id: I2267c69001da6bc136d26d874331dd734c8693f5
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 13349331
......@@ -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>
......@@ -77,11 +77,17 @@ class CPPEditorDocument : public TextEditor::BaseTextDocument
public:
CPPEditorDocument();
bool isObjCEnabled() const;
protected:
void applyFontSettings();
private slots:
void invalidateFormatterCache();
void onMimeTypeChanged();
private:
bool m_isObjCEnabled;
};
class CPPEditor : public TextEditor::BaseTextEditor
......@@ -113,6 +119,9 @@ public:
CPPEditorWidget(QWidget *parent = 0);
CPPEditorWidget(CPPEditorWidget *other);
~CPPEditorWidget();
CPPEditorDocument *cppEditorDocument() const;
void unCommentSelection();
unsigned editorRevision() const;
......@@ -126,9 +135,6 @@ public:
virtual void cut(); // reimplemented from BaseTextEditorWidget
virtual void selectAll(); // reimplemented from BaseTextEditorWidget
void setObjCEnabled(bool onoff);
bool isObjCEnabled() const;
bool openLink(const Link &link, bool inNextSplit) { return openCppEditorAt(link, inNextSplit); }
static Link linkToSymbol(CPlusPlus::Symbol *symbol);
......@@ -182,7 +188,6 @@ private slots:
void updateFunctionDeclDefLinkNow();
void onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefLink> link);
void onFilePathChanged();
void onMimeTypeChanged();
void onDocumentUpdated();
void onContentsChanged(int position, int charsRemoved, int charsAdded);
void updatePreprocessorButtonTooltip();
......@@ -230,6 +235,7 @@ private:
QPointer<CppTools::CppModelManagerInterface> m_modelManager;
CPPEditorDocument *m_cppEditorDocument;
QComboBox *m_outlineCombo;
CPlusPlus::OverviewModel *m_outlineModel;
QModelIndex m_outlineModelIndex;
......@@ -250,7 +256,6 @@ private:
CppTools::SemanticInfo m_lastSemanticInfo;
QList<TextEditor::QuickFixOperation::Ptr> m_quickFixes;
bool m_objcEnabled;
QScopedPointer<QFutureWatcher<TextEditor::HighlightingResult> > m_highlightWatcher;
unsigned m_highlightRevision; // the editor revision that requested the highlight
......
......@@ -1388,7 +1388,7 @@ void ConvertCStringToNSString::match(const CppQuickFixInterface &interface,
{
CppRefactoringFilePtr file = interface->currentFile();
if (!interface->editor()->isObjCEnabled())
if (!interface->editor()->cppEditorDocument()->isObjCEnabled())
return;
WrapStringLiteral::Type type = WrapStringLiteral::TypeNone;
......
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