本文整理汇总了C++中cplusplus::Snapshot::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ Snapshot::insert方法的具体用法?C++ Snapshot::insert怎么用?C++ Snapshot::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cplusplus::Snapshot
的用法示例。
在下文中一共展示了Snapshot::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: navigateToSlot
bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
const QString &signalSignature,
const QStringList ¶meterNames,
QString *errorMessage)
{
const EditorData ed = m_few->activeEditor();
QTC_ASSERT(ed, return false)
const QString currentUiFile = ed.formWindowEditor->file()->fileName();
#if 0
return Designer::Internal::navigateToSlot(currentUiFile, objectName, signalSignature, parameterNames, errorMessage);
#endif
// TODO: we should pass to findDocumentsIncluding an absolute path to generated .h file from ui.
// Currently we are guessing the name of ui_<>.h file and pass the file name only to the findDocumentsIncluding().
// The idea is that the .pro file knows if the .ui files is inside, and the .pro file knows it will
// be generating the ui_<>.h file for it, and the .pro file knows what the generated file's name and its absolute path will be.
// So we should somehow get that info from project manager (?)
const QFileInfo fi(currentUiFile);
const QString uicedName = QLatin1String("ui_") + fi.completeBaseName() + QLatin1String(".h");
// Retrieve code model snapshot restricted to project of ui file.
const ProjectExplorer::Project *uiProject = ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projectForFile(currentUiFile);
if (!uiProject) {
*errorMessage = tr("Internal error: No project could be found for %1.").arg(currentUiFile);
return false;
}
CPlusPlus::Snapshot docTable = CppModelManagerInterface::instance()->snapshot();
CPlusPlus::Snapshot newDocTable;
for (CPlusPlus::Snapshot::iterator it = docTable.begin(); it != docTable.end(); ++it) {
const ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projectForFile(it.key());
if (project == uiProject)
newDocTable.insert(it.value());
}
docTable = newDocTable;
// take all docs, find the ones that include the ui_xx.h.
QList<Document::Ptr> docList = findDocumentsIncluding(docTable, uicedName, true); // change to false when we know the absolute path to generated ui_<>.h file
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << objectName << signalSignature << "Looking for " << uicedName << " returned " << docList.size();
if (docList.isEmpty()) {
*errorMessage = tr("No documents matching '%1' could be found.\nRebuilding the project might help.").arg(uicedName);
return false;
}
QDesignerFormWindowInterface *fwi = ed.widgetHost->formWindow();
const QString uiClass = uiClassName(fwi->mainContainer()->objectName());
if (Designer::Constants::Internal::debug)
qDebug() << "Checking docs for " << uiClass;
// Find the class definition (ui class defined as member or base class)
// in the file itself or in the directly included files (order 1).
QString namespaceName;
const Class *cl = 0;
Document::Ptr doc;
foreach (const Document::Ptr &d, docList) {
const ClassDocumentPtrPair cd = findClassRecursively(docTable, d, uiClass, 1u , &namespaceName);
if (cd.first) {
cl = cd.first;
doc = cd.second;
break;
}
}
if (!cl) {
*errorMessage = msgClassNotFound(uiClass, docList);
return false;
}
Overview o;
const QString className = namespaceName + o.prettyName(cl->name());
if (Designer::Constants::Internal::debug)
qDebug() << "Found class " << className << doc->fileName();
const QString functionName = QLatin1String("on_") + objectName + QLatin1Char('_') + signalSignature;
const QString functionNameWithParameterNames = addParameterNames(functionName, parameterNames);
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << "Found " << uiClass << doc->fileName() << " checking " << functionName << functionNameWithParameterNames;
int line = 0;
Document::Ptr sourceDoc;
if (Function *fun = findDeclaration(cl, functionName)) {
sourceDoc = findDefinition(fun, &line);
if (!sourceDoc) {
// add function definition to cpp file
sourceDoc = addDefinition(docTable, doc->fileName(), className, functionNameWithParameterNames, &line);
}
} else {
// add function declaration to cl
CppModelManagerInterface::WorkingCopy workingCopy =
CppModelManagerInterface::instance()->workingCopy();
const QString fileName = doc->fileName();
getParsedDocument(fileName, workingCopy, docTable);
addDeclaration(docTable, fileName, cl, functionNameWithParameterNames);
//.........这里部分代码省略.........