From 114a878c64ce6f8223cfd22d76a20eb16d177e5e Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- parts/classview/classtoolwidget.cpp | 159 ++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 parts/classview/classtoolwidget.cpp (limited to 'parts/classview/classtoolwidget.cpp') diff --git a/parts/classview/classtoolwidget.cpp b/parts/classview/classtoolwidget.cpp new file mode 100644 index 00000000..f800bd15 --- /dev/null +++ b/parts/classview/classtoolwidget.cpp @@ -0,0 +1,159 @@ +/*************************************************************************** + * Copyright (C) 1999 by Jonas Nordin * + * jonas.nordin@syncom.se * + * Copyright (C) 2000-2001 by Bernd Gehrmann * + * bernd@kdevelop.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "classtoolwidget.h" + +#include +#include +#include +#include +#include "classstore.h" + + +ClassToolWidget::ClassToolWidget(ClassViewPart *part, QWidget *parent) + : ClassTreeBase(part, parent, "class tool widget") +{} + + +ClassToolWidget::~ClassToolWidget() +{} + + +KPopupMenu *ClassToolWidget::createPopup() +{ + KPopupMenu *popup = contextItem? contextItem->createPopup() : 0; + if (!popup) { + popup = new KPopupMenu(this); + popup->insertTitle(i18n("Class Tool")); + } + + return popup; +} + + +void ClassToolWidget::insertClassAndClasses(ParsedClass *parsedClass, QValueList classList) +{ + ClassTreeItem *root = new ClassTreeClassItem(this, 0, parsedClass); + + ClassTreeItem *lastItem = 0; + + QValueList::ConstIterator it; + for (it = classList.begin(); it != classList.end(); ++it) { + lastItem = new ClassTreeClassItem(root, lastItem, *it); + lastItem->setExpandable(false); + } + + if (!root->firstChild()) + root->setExpandable(false); + else + root->setOpen(true); +} + + +void ClassToolWidget::insertClassAndClasses(ParsedClass *parsedClass, const QPtrList &parentList) +{ + ClassTreeItem *root = new ClassTreeClassItem(this, 0, parsedClass); + + ClassTreeItem *lastItem = 0; + + QPtrListIterator it(parentList); + for (; it.current(); ++it) { + ParsedClass *parentClass = m_part->classStore()->getClassByName((*it)->name()); + lastItem = new ClassTreeClassItem(root, lastItem, parentClass); + lastItem->setExpandable(false); + } + + if (!root->firstChild()) + root->setExpandable(false); + else + root->setOpen(true); +} + + +void ClassToolWidget::addClassAndAttributes(ParsedClass *parsedClass, PIAccess filter, ClassTreeItem **lastItem) +{ + *lastItem = new ClassTreeClassItem(this, *lastItem, parsedClass); + + ClassTreeItem *ilastItem = 0; + + QValueList attrList = parsedClass->getSortedAttributeList(); + QValueList::ConstIterator it; + for (it = attrList.begin(); it != attrList.end(); ++it) { + if (filter == (PIAccess)-1 || filter == (*it)->access()) + ilastItem = new ClassTreeAttrItem(*lastItem, ilastItem, *it); + } + + if (!(*lastItem)->firstChild()) + (*lastItem)->setExpandable(false); + else + (*lastItem)->setOpen(true); +} + + +void ClassToolWidget::addClassAndMethods(ParsedClass *parsedClass, PIAccess filter, ClassTreeItem **lastItem) +{ + *lastItem = new ClassTreeClassItem(this, *lastItem, parsedClass); + + ClassTreeItem *ilastItem = 0; + + QValueList methodList = parsedClass->getSortedMethodList(); + QValueList::ConstIterator it; + for (it = methodList.begin(); it != methodList.end(); ++it) { + if (filter == (PIAccess)-1 || filter == (*it)->access()) + ilastItem = new ClassTreeMethodItem(*lastItem, ilastItem, *it); + } + + if (!(*lastItem)->firstChild()) + (*lastItem)->setExpandable(false); + else + (*lastItem)->setOpen(true); +} + + +void ClassToolWidget::insertAllClassMethods(ParsedClass *parsedClass, PIAccess filter) +{ + ClassTreeItem *lastItem = 0; + + // First treat all parents. + for ( ParsedParent *pParent = parsedClass->parents.first(); + pParent != 0; + pParent = parsedClass->parents.next() ) + { + ParsedClass *parentClass = m_part->classStore()->getClassByName(pParent->name()); + if (parentClass) + addClassAndMethods(parentClass, filter, &lastItem); + } + + // Add the current class + addClassAndMethods(parsedClass, filter, &lastItem); +} + + +void ClassToolWidget::insertAllClassAttributes(ParsedClass *parsedClass, PIAccess filter) +{ + ClassTreeItem *lastItem = 0; + // First treat all parents. + for ( ParsedParent *pParent = parsedClass->parents.first(); + pParent != 0; + pParent = parsedClass->parents.next() ) + { + ParsedClass *parentClass = m_part->classStore()->getClassByName(pParent->name()); + if (parentClass) + addClassAndAttributes(parentClass, filter, &lastItem); + } + + // Add the current class + addClassAndAttributes(parsedClass, filter, &lastItem); +} + +#include "classtoolwidget.moc" -- cgit v1.2.1