Commit 58f101cb authored by hjk's avatar hjk

CppEditor: Direct element access, less symbols.

Change-Id: Id79b69b271ad90c742a3884f8b818a7ee7f26a5b
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 6dfe3207
......@@ -94,96 +94,60 @@ private:
class CppElement
{
public:
virtual ~CppElement();
const TextEditor::HelpItem::Category &helpCategory() const;
const QStringList &helpIdCandidates() const;
const QString &helpMark() const;
const CPPEditorWidget::Link &link() const;
const QString &tooltip() const;
protected:
CppElement();
void setHelpCategory(const TextEditor::HelpItem::Category &category);
void setLink(const CPPEditorWidget::Link &link);
void setTooltip(const QString &tooltip);
void setHelpIdCandidates(const QStringList &candidates);
void addHelpIdCandidate(const QString &candidate);
void setHelpMark(const QString &mark);
public:
virtual ~CppElement();
private:
TextEditor::HelpItem::Category m_helpCategory;
QStringList m_helpIdCandidates;
QString m_helpMark;
CPPEditorWidget::Link m_link;
QString m_tooltip;
TextEditor::HelpItem::Category helpCategory;
QStringList helpIdCandidates;
QString helpMark;
CPPEditorWidget::Link link;
QString tooltip;
};
class Unknown : public CppElement
{
public:
explicit Unknown(const QString &type);
virtual ~Unknown();
const QString &type() const;
private:
QString m_type;
public:
QString type;
};
class CppInclude : public CppElement
{
public:
explicit CppInclude(const CPlusPlus::Document::Include &includeFile);
virtual ~CppInclude();
const QString &path() const;
const QString &fileName() const;
private:
QString m_path;
QString m_fileName;
public:
QString path;
QString fileName;
};
class CppMacro : public CppElement
{
public:
explicit CppMacro(const CPlusPlus::Macro &macro);
virtual ~CppMacro();
};
class CppDeclarableElement : public CppElement
{
public:
CppDeclarableElement();
explicit CppDeclarableElement(CPlusPlus::Symbol *declaration);
virtual ~CppDeclarableElement();
const QString &name() const;
const QString &qualifiedName() const;
const QString &type() const;
const QIcon &icon() const;
protected:
void setName(const QString &name);
void setQualifiedName(const QString &name);
void setType(const QString &type);
void setIcon(const QIcon &icon);
private:
QString m_name;
QString m_qualifiedName;
QString m_type;
QIcon m_icon;
public:
QString name;
QString qualifiedName;
QString type;
QIcon icon;
};
class CppNamespace : public CppDeclarableElement
{
public:
explicit CppNamespace(CPlusPlus::Symbol *declaration);
virtual ~CppNamespace();
};
class CppClass : public CppDeclarableElement
......@@ -191,38 +155,31 @@ class CppClass : public CppDeclarableElement
public:
CppClass();
explicit CppClass(CPlusPlus::Symbol *declaration);
virtual ~CppClass();
void lookupBases(CPlusPlus::Symbol *declaration, const CPlusPlus::LookupContext &context);
void lookupDerived(CPlusPlus::Symbol *declaration, const CPlusPlus::Snapshot &snapshot);
const QList<CppClass> &bases() const;
const QList<CppClass> &derived() const;
private:
QList<CppClass> m_bases;
QList<CppClass> m_derived;
public:
QList<CppClass> bases;
QList<CppClass> derived;
};
class CppFunction : public CppDeclarableElement
{
public:
explicit CppFunction(CPlusPlus::Symbol *declaration);
virtual ~CppFunction();
};
class CppEnum : public CppDeclarableElement
{
public:
explicit CppEnum(CPlusPlus::Enum *declaration);
virtual ~CppEnum();
};
class CppTypedef : public CppDeclarableElement
{
public:
explicit CppTypedef(CPlusPlus::Symbol *declaration);
virtual ~CppTypedef();
};
class CppVariable : public CppDeclarableElement
......@@ -231,14 +188,12 @@ public:
CppVariable(CPlusPlus::Symbol *declaration,
const CPlusPlus::LookupContext &context,
CPlusPlus::Scope *scope);
virtual ~CppVariable();
};
class CppEnumerator : public CppDeclarableElement
{
public:
explicit CppEnumerator(CPlusPlus::EnumeratorDeclaration *declaration);
virtual ~CppEnumerator();
};
} // namespace Internal
......
......@@ -82,12 +82,12 @@ void CppHoverHandler::identifyMatch(TextEditor::ITextEditor *editor, int pos)
if (evaluator.identifiedCppElement()) {
const QSharedPointer<CppElement> &cppElement = evaluator.cppElement();
if (!isDiagnosticTooltip())
setToolTip(cppElement->tooltip());
foreach (const QString &helpId, cppElement->helpIdCandidates()) {
setToolTip(cppElement->tooltip);
foreach (const QString &helpId, cppElement->helpIdCandidates) {
if (!Core::HelpManager::instance()->linksForIdentifier(helpId).isEmpty()) {
setLastHelpItemIdentified(TextEditor::HelpItem(helpId,
cppElement->helpMark(),
cppElement->helpCategory()));
cppElement->helpMark,
cppElement->helpCategory));
break;
}
}
......
......@@ -60,20 +60,20 @@ enum ItemRole {
QStandardItem *itemForClass(const CppClass &cppClass)
{
QStandardItem *item = new QStandardItem;
item->setData(cppClass.name(), Qt::DisplayRole);
if (cppClass.name() != cppClass.qualifiedName())
item->setData(cppClass.qualifiedName(), AnnotationRole);
item->setData(cppClass.icon(), Qt::DecorationRole);
item->setData(cppClass.name, Qt::DisplayRole);
if (cppClass.name != cppClass.qualifiedName)
item->setData(cppClass.qualifiedName, AnnotationRole);
item->setData(cppClass.icon, Qt::DecorationRole);
QVariant link;
link.setValue(CPPEditorWidget::Link(cppClass.link()));
link.setValue(CPPEditorWidget::Link(cppClass.link));
item->setData(link, LinkRole);
return item;
}
bool compareCppClassNames(const CppClass &c1, const CppClass &c2)
{
const QString key1 = c1.name() + QLatin1String("::") + c1.qualifiedName();
const QString key2 = c2.name() + QLatin1String("::") + c2.qualifiedName();
const QString key1 = c1.name + QLatin1String("::") + c1.qualifiedName;
const QString key2 = c2.name + QLatin1String("::") + c2.qualifiedName;
return key1 < key2;
}
......@@ -98,8 +98,8 @@ public:
void setup(CppClass *cppClass)
{
setText(cppClass->name());
m_link = cppClass->link();
setText(cppClass->name);
m_link = cppClass->link;
}
private:
......@@ -183,24 +183,24 @@ void CppTypeHierarchyWidget::perform()
m_inspectedClass->setup(cppClass);
QStandardItem *bases = new QStandardItem(tr("Bases"));
m_model->invisibleRootItem()->appendRow(bases);
buildHierarchy(*cppClass, bases, true, &CppClass::bases);
buildHierarchy(*cppClass, bases, true, cppClass->bases);
QStandardItem *derived = new QStandardItem(tr("Derived"));
m_model->invisibleRootItem()->appendRow(derived);
buildHierarchy(*cppClass, derived, true, &CppClass::derived);
buildHierarchy(*cppClass, derived, true, cppClass->derived);
m_treeView->expandAll();
}
}
}
void CppTypeHierarchyWidget::buildHierarchy(const CppClass &cppClass, QStandardItem *parent, bool isRoot, HierarchyFunc func)
void CppTypeHierarchyWidget::buildHierarchy(const CppClass &cppClass, QStandardItem *parent, bool isRoot, const QList<CppClass> &classes)
{
if (!isRoot) {
QStandardItem *item = itemForClass(cppClass);
parent->appendRow(item);
parent = item;
}
foreach (const CppClass &klass, sortClasses((cppClass.*func)()))
buildHierarchy(klass, parent, false, func);
foreach (const CppClass &klass, sortClasses(classes))
buildHierarchy(klass, parent, false, classes);
}
void CppTypeHierarchyWidget::onItemClicked(const QModelIndex &index)
......
......@@ -75,8 +75,7 @@ private slots:
void onItemClicked(const QModelIndex &index);
private:
typedef const QList<CppClass> &(CppClass::* HierarchyFunc)() const;
void buildHierarchy(const CppClass &cppClass, QStandardItem *parent, bool isRoot, HierarchyFunc func);
void buildHierarchy(const CppClass &cppClass, QStandardItem *parent, bool isRoot, const QList<CppClass> &classes);
CPPEditorWidget *m_cppEditor;
Utils::NavigationTreeView *m_treeView;
......
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