本文整理汇总了C++中Overview::prettyName方法的典型用法代码示例。如果您正苦于以下问题:C++ Overview::prettyName方法的具体用法?C++ Overview::prettyName怎么用?C++ Overview::prettyName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Overview
的用法示例。
在下文中一共展示了Overview::prettyName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: debugCppSymbolRecursion
static void debugCppSymbolRecursion(QTextStream &str, const Overview &o,
const Symbol &s, bool doRecurse = true,
int recursion = 0)
{
for (int i = 0; i < recursion; i++)
str << " ";
str << "Symbol: " << o.prettyName(s.name()) << " at line " << s.line();
if (s.isFunction())
str << " function";
if (s.isClass())
str << " class";
if (s.isDeclaration())
str << " declaration";
if (s.isBlock())
str << " block";
if (doRecurse && s.isScope()) {
const Scope *scoped = s.asScope();
const int size = scoped->memberCount();
str << " scoped symbol of " << size << '\n';
for (int m = 0; m < size; m++)
debugCppSymbolRecursion(str, o, *scoped->memberAt(m), true, recursion + 1);
} else {
str << '\n';
}
}
示例2:
static Function *findDeclaration(const Class *cl, const QString &functionName)
{
const QString funName = QString::fromUtf8(QMetaObject::normalizedSignature(functionName.toUtf8()));
const unsigned mCount = cl->memberCount();
// we are interested only in declarations (can be decl of function or of a field)
// we are only interested in declarations of functions
const Overview overview;
for (unsigned j = 0; j < mCount; ++j) { // go through all members
if (Declaration *decl = cl->memberAt(j)->asDeclaration())
if (Function *fun = decl->type()->asFunctionType()) {
// Format signature
QString memberFunction = overview.prettyName(fun->name());
memberFunction += '(';
const uint aCount = fun->argumentCount();
for (uint i = 0; i < aCount; i++) { // we build argument types string
const Argument *arg = fun->argumentAt(i)->asArgument();
if (i > 0)
memberFunction += ',';
memberFunction += overview.prettyType(arg->type());
}
memberFunction += ')';
// we compare normalized signatures
memberFunction = QString::fromUtf8(QMetaObject::normalizedSignature(memberFunction.toUtf8()));
if (memberFunction == funName) // we match function names and argument lists
return fun;
}
}
return 0;
}
示例3: inherits
// Does klass inherit baseClass?
static bool inherits(const Overview &o, const Class *klass, const QString &baseClass)
{
const unsigned int baseClassCount = klass->baseClassCount();
for (unsigned int b = 0; b < baseClassCount; ++b)
if (o.prettyName(klass->baseClassAt(b)->name()) == baseClass)
return true;
return false;
}
示例4: qDebug
// Find class definition in namespace (that is, the outer class
// containing a member of the desired class type) or inheriting the desired class
// in case of forms using the Multiple Inheritance approach
static const Class *findClass(const Namespace *parentNameSpace, const QString &className, QString *namespaceName)
{
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << className;
const Overview o;
const unsigned namespaceMemberCount = parentNameSpace->memberCount();
for (unsigned i = 0; i < namespaceMemberCount; i++) { // we go through all namespace members
const Symbol *sym = parentNameSpace->memberAt(i);
// we have found a class - we are interested in classes only
if (const Class *cl = sym->asClass()) {
// 1) we go through class members
const unsigned classMemberCount = cl->memberCount();
for (unsigned j = 0; j < classMemberCount; j++)
if (const Declaration *decl = cl->memberAt(j)->asDeclaration()) {
// we want to know if the class contains a member (so we look into
// a declaration) of uiClassName type
const NamedType *nt = decl->type()->asNamedType();
// handle pointers to member variables
if (PointerType *pt = decl->type()->asPointerType())
nt = pt->elementType()->asNamedType();
if (nt && matchMemberClassName(className, o.prettyName(nt->name())))
return cl;
} // decl
// 2) does it inherit the desired class
if (inherits(o, cl, className))
return cl;
} else {
// Check namespaces
if (const Namespace *ns = sym->asNamespace()) {
QString tempNS = *namespaceName;
tempNS += o.prettyName(ns->name());
tempNS += QLatin1String("::");
if (const Class *cl = findClass(ns, className, &tempNS)) {
*namespaceName = tempNS;
return cl;
}
} // member is namespave
} // member is no class
} // for members
return 0;
}
示例5: CppElement
CppDeclarableElement::CppDeclarableElement(Symbol *declaration) : CppElement()
{
icon = Icons().iconForSymbol(declaration);
Overview overview;
overview.showArgumentNames = true;
overview.showReturnTypes = true;
name = overview.prettyName(declaration->name());
if (declaration->enclosingScope()->isClass() ||
declaration->enclosingScope()->isNamespace() ||
declaration->enclosingScope()->isEnum()) {
qualifiedName = overview.prettyName(LookupContext::fullyQualifiedName(declaration));
helpIdCandidates = stripName(qualifiedName);
} else {
qualifiedName = name;
helpIdCandidates.append(name);
}
tooltip = overview.prettyType(declaration->type(), qualifiedName);
link = CPPEditorWidget::linkToSymbol(declaration);
helpMark = name;
}
示例6: CppElement
CppDeclarableElement::CppDeclarableElement(Symbol *declaration) : CppElement()
{
m_icon = Icons().iconForSymbol(declaration);
Overview overview;
overview.setShowArgumentNames(true);
overview.setShowReturnTypes(true);
m_name = overview.prettyName(declaration->name());
if (declaration->enclosingScope()->isClass() ||
declaration->enclosingScope()->isNamespace() ||
declaration->enclosingScope()->isEnum()) {
m_qualifiedName = overview.prettyName(LookupContext::fullyQualifiedName(declaration));
setHelpIdCandidates(stripName(m_qualifiedName));
} else {
m_qualifiedName = m_name;
setHelpIdCandidates(QStringList(m_name));
}
setTooltip(overview.prettyType(declaration->type(), m_qualifiedName));
setLink(CPPEditorWidget::linkToSymbol(declaration));
setHelpMark(m_name);
}
示例7: isOwnershipRAIIType
bool isOwnershipRAIIType(Symbol *symbol, const LookupContext &context)
{
if (!symbol)
return false;
// This is not a "real" comparison of types. What we do is to resolve the symbol
// in question and then try to match its name with already known ones.
if (symbol->isDeclaration()) {
Declaration *declaration = symbol->asDeclaration();
const NamedType *namedType = declaration->type()->asNamedType();
if (namedType) {
LookupScope *clazz = context.lookupType(namedType->name(),
declaration->enclosingScope());
if (clazz && !clazz->symbols().isEmpty()) {
Overview overview;
Symbol *symbol = clazz->symbols().at(0);
return isOwnershipRAIIName(overview.prettyName(symbol->name()));
}
}
}
return false;
}
示例8: navigateToSlot
bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
const QString &signalSignature,
const QStringList ¶meterNames,
QString *errorMessage)
{
typedef QMap<int, Document::Ptr> DocumentMap;
const Utils::FileName currentUiFile = FormEditorW::activeEditor()->document()->filePath();
#if 0
return Designer::Internal::navigateToSlot(currentUiFile.toString(), 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.toFileInfo();
const QString uiFolder = fi.absolutePath();
const QString uicedName = "ui_" + fi.completeBaseName() + ".h";
// Retrieve code model snapshot restricted to project of ui file or the working copy.
Snapshot docTable = CppTools::CppModelManager::instance()->snapshot();
Snapshot newDocTable;
const Project *uiProject = SessionManager::projectForFile(currentUiFile);
if (uiProject) {
for (Snapshot::const_iterator i = docTable.begin(), ei = docTable.end(); i != ei; ++i) {
const Project *project = SessionManager::projectForFile(i.key());
if (project == uiProject)
newDocTable.insert(i.value());
}
} else {
const CppTools::WorkingCopy workingCopy =
CppTools::CppModelManager::instance()->workingCopy();
const Utils::FileName configFileName =
Utils::FileName::fromString(CppTools::CppModelManager::configurationFileName());
QHashIterator<Utils::FileName, QPair<QByteArray, unsigned> > it = workingCopy.iterator();
while (it.hasNext()) {
it.next();
const Utils::FileName &fileName = it.key();
if (fileName != configFileName)
newDocTable.insert(docTable.document(fileName));
}
}
docTable = newDocTable;
// take all docs, find the ones that include the ui_xx.h.
// Sort into a map, putting the ones whose path closely matches the ui-folder path
// first in case there are project subdirectories that contain identical file names.
const QList<Document::Ptr> docList = findDocumentsIncluding(docTable, uicedName, true); // change to false when we know the absolute path to generated ui_<>.h file
DocumentMap docMap;
for (const Document::Ptr &d : docList) {
const QFileInfo docFi(d->fileName());
docMap.insert(qAbs(docFi.absolutePath().compare(uiFolder, Qt::CaseInsensitive)), d);
}
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << objectName << signalSignature << "Looking for " << uicedName << " returned " << docList.size();
if (docMap.isEmpty()) {
*errorMessage = tr("No documents matching \"%1\" could be found.\nRebuilding the project might help.").arg(uicedName);
return false;
}
QDesignerFormWindowInterface *fwi = FormEditorW::activeWidgetHost()->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;
for (const Document::Ptr &d : qAsConst(docMap)) {
LookupContext context(d, docTable);
const ClassDocumentPtrPair cd = findClassRecursively(context, 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 = "on_" + objectName + '_' + signalSignature;
const QString functionNameWithParameterNames = addParameterNames(functionName, parameterNames);
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << "Found " << uiClass << doc->fileName() << " checking " << functionName << functionNameWithParameterNames;
//.........这里部分代码省略.........
示例9: 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);
//.........这里部分代码省略.........
示例10: toString
QString CPlusPlus::toString(const Name *name, QString id)
{
Overview oo;
return QString::fromLatin1("%0: %1").arg(id, name ? oo.prettyName(name) : QLatin1String("(null)"));
}