Commit 5c991647 authored by dt's avatar dt

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: default avatarRoberto Raggi <roberto.raggi@nokia.com>
parent 278fa737
......@@ -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();
......
......@@ -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;
......
......@@ -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
......
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