summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cpptoolseditorsupport.cpp
diff options
context:
space:
mode:
authorRoberto Raggi <qtc-committer@nokia.com>2009-02-10 22:56:04 +0100
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2009-02-11 15:03:31 +0100
commitf3c2bbaabe052f2fa02dae93c62bef093a68a866 (patch)
treeb8569a5744957cdd1dd27d36d9f3d82c55a15fe2 /src/plugins/cpptools/cpptoolseditorsupport.cpp
parentb6ca8da0bd19fa6fda32fc2993f5bec7bd1f5168 (diff)
downloadqt-creator-f3c2bbaabe052f2fa02dae93c62bef093a68a866.tar.gz
Less annoying syntax checker.
(cherry picked from commit 9539bb2b28c05aa3ff7ca1aa19161ae864116422)
Diffstat (limited to 'src/plugins/cpptools/cpptoolseditorsupport.cpp')
-rw-r--r--src/plugins/cpptools/cpptoolseditorsupport.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/plugins/cpptools/cpptoolseditorsupport.cpp b/src/plugins/cpptools/cpptoolseditorsupport.cpp
index 5a907a2d17..ab6fe3532c 100644
--- a/src/plugins/cpptools/cpptoolseditorsupport.cpp
+++ b/src/plugins/cpptools/cpptoolseditorsupport.cpp
@@ -35,6 +35,7 @@
#include "cppmodelmanager.h"
#include <texteditor/itexteditor.h>
+#include <texteditor/basetexteditor.h>
#include <QTimer>
@@ -68,12 +69,14 @@ void CppEditorSupport::setTextEditor(TextEditor::ITextEditor *textEditor)
updateDocument();
}
-QString CppEditorSupport::contents() const
+QString CppEditorSupport::contents()
{
if (! _textEditor)
return QString();
+ else if (! _cachedContents.isEmpty())
+ _cachedContents = _textEditor->contents();
- return _textEditor->contents();
+ return _cachedContents;
}
int CppEditorSupport::updateDocumentInterval() const
@@ -83,7 +86,20 @@ void CppEditorSupport::setUpdateDocumentInterval(int updateDocumentInterval)
{ _updateDocumentInterval = updateDocumentInterval; }
void CppEditorSupport::updateDocument()
-{ _updateDocumentTimer->start(_updateDocumentInterval); }
+{
+ if (TextEditor::BaseTextEditor *edit = qobject_cast<TextEditor::BaseTextEditor*>(_textEditor->widget())) {
+ const QList<QTextEdit::ExtraSelection> selections =
+ edit->extraSelections(TextEditor::BaseTextEditor::CodeWarningsSelection);
+
+ if (! selections.isEmpty())
+ edit->setExtraSelections(TextEditor::BaseTextEditor::CodeWarningsSelection,
+ QList<QTextEdit::ExtraSelection>());
+
+ _modelManager->stopEditorSelectionsUpdate();
+ }
+
+ _updateDocumentTimer->start(_updateDocumentInterval);
+}
void CppEditorSupport::updateDocumentNow()
{
@@ -91,7 +107,9 @@ void CppEditorSupport::updateDocumentNow()
_updateDocumentTimer->start(_updateDocumentInterval);
} else {
_updateDocumentTimer->stop();
+
QStringList sourceFiles(_textEditor->file()->fileName());
+ _cachedContents = _textEditor->contents();
_documentParser = _modelManager->refreshSourceFiles(sourceFiles);
}
}