Less annoying syntax checker.

This commit is contained in:
Roberto Raggi
2009-02-10 22:56:04 +01:00
parent a33ae02927
commit 9539bb2b28
5 changed files with 83 additions and 7 deletions

View File

@@ -69,6 +69,7 @@
#include <QtCore/QDebug>
#include <QtCore/QMutexLocker>
#include <QtCore/QTime>
#include <QtCore/QTimer>
using namespace CppTools;
using namespace CppTools::Internal;
@@ -454,6 +455,12 @@ CppModelManager::CppModelManager(QObject *parent)
ProjectExplorer::SessionManager *session = m_projectExplorer->session();
QTC_ASSERT(session, return);
m_updateEditorSelectionsTimer = new QTimer(this);
m_updateEditorSelectionsTimer->setInterval(500);
m_updateEditorSelectionsTimer->setSingleShot(true);
connect(m_updateEditorSelectionsTimer, SIGNAL(timeout()),
this, SLOT(updateEditorSelections()));
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
this, SLOT(onProjectAdded(ProjectExplorer::Project*)));
@@ -717,8 +724,8 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
continue;
else if (lines.contains(m.line()))
continue;
else if (lines.size() == MAX_SELECTION_COUNT)
break; // we're done.
//else if (lines.size() == MAX_SELECTION_COUNT)
//break; // we're done.
lines.insert(m.line());
@@ -740,12 +747,42 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
sel.cursor = c;
selections.append(sel);
}
ed->setExtraSelections(TextEditor::BaseTextEditor::CodeWarningsSelection, selections);
QList<Editor> todo;
foreach (Editor e, todo) {
if (e.widget != ed)
todo.append(e);
}
Editor e;
e.widget = ed;
e.selections = selections;
todo.append(e);
m_todo = todo;
postEditorUpdate();
break;
}
}
}
void CppModelManager::postEditorUpdate()
{
m_updateEditorSelectionsTimer->start(500);
}
void CppModelManager::updateEditorSelections()
{
foreach (Editor ed, m_todo) {
if (! ed.widget)
continue;
ed.widget->setExtraSelections(TextEditor::BaseTextEditor::CodeWarningsSelection,
ed.selections);
}
m_todo.clear();
}
void CppModelManager::onProjectAdded(ProjectExplorer::Project *)
{
QMutexLocker locker(&mutex);