First step towards dynamic ui completion. Add hooks in cppmodelmanager

This adds a way for plugins to tell the cppmodel that for certain files,
the actual contents come from it, instead of reading from the disk.
(For texteditors the cppmodel does that automatically.)

Reviewed-By: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
dt
2009-05-12 13:45:24 +02:00
parent 278fa73718
commit 5c9916478f
3 changed files with 42 additions and 0 deletions

View File

@@ -648,6 +648,16 @@ QByteArray CppModelManager::internalDefinedMacros() const
return macros;
}
void CppModelManager::addEditorSupport(AbstractEditorSupport *editorSupport)
{
m_addtionalEditorSupport.insert(editorSupport);
}
void CppModelManager::removeEditorSupport(AbstractEditorSupport *editorSupport)
{
m_addtionalEditorSupport.remove(editorSupport);
}
QMap<QString, QByteArray> CppModelManager::buildWorkingCopyList()
{
QMap<QString, QByteArray> workingCopy;
@@ -660,6 +670,12 @@ QMap<QString, QByteArray> CppModelManager::buildWorkingCopyList()
workingCopy[fileName] = editorSupport->contents();
}
QSetIterator<AbstractEditorSupport *> jt(m_addtionalEditorSupport);
while (jt.hasNext()) {
AbstractEditorSupport *es = jt.next();
workingCopy[es->fileName()] = es->contents();
}
// add the project configuration file
QByteArray conf(pp_configuration);
conf += definedMacros();

View File

@@ -91,6 +91,9 @@ public:
void stopEditorSelectionsUpdate()
{ m_updateEditorSelectionsTimer->stop(); }
virtual void addEditorSupport(AbstractEditorSupport *editorSupport);
virtual void removeEditorSupport(AbstractEditorSupport *editorSupport);
Q_SIGNALS:
void projectPathChanged(const QString &projectPath);
@@ -161,6 +164,8 @@ private:
// editor integration
QMap<TextEditor::ITextEditor *, CppEditorSupport *> m_editorSupport;
QSet<AbstractEditorSupport *> m_addtionalEditorSupport;
// project integration
QMap<ProjectExplorer::Project *, ProjectInfo> m_projects;

View File

@@ -41,6 +41,8 @@ namespace ProjectExplorer {
}
namespace CppTools {
class AbstractEditorSupport;
class CPPTOOLS_EXPORT CppModelManagerInterface : public QObject
{
@@ -87,6 +89,25 @@ public:
virtual QList<ProjectInfo> projectInfos() const = 0;
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const = 0;
virtual void updateProjectInfo(const ProjectInfo &pinfo) = 0;
virtual void addEditorSupport(AbstractEditorSupport *editorSupport) = 0;
virtual void removeEditorSupport(AbstractEditorSupport *editorSupport) = 0;
};
class CPPTOOLS_EXPORT AbstractEditorSupport
{
public:
AbstractEditorSupport(CppModelManagerInterface *modelmanager)
: m_modelmanager(modelmanager) {}
virtual ~AbstractEditorSupport() {}
virtual QByteArray contents() const = 0;
virtual QString fileName() const = 0;
void updateDocument()
{ m_modelmanager->updateSourceFiles(QStringList() << fileName()); }
private:
CppModelManagerInterface *m_modelmanager;
};
} // namespace CppTools