summaryrefslogtreecommitdiffstats
path: root/parts/classview/classtoolwidget.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch)
treeacaf47eb0fa12142d3896416a69e74cbf5a72242 /parts/classview/classtoolwidget.cpp
downloadtdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz
tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip
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
Diffstat (limited to 'parts/classview/classtoolwidget.cpp')
-rw-r--r--parts/classview/classtoolwidget.cpp159
1 files changed, 159 insertions, 0 deletions
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 <kconfig.h>
+#include <klocale.h>
+#include <kglobal.h>
+#include <kpopupmenu.h>
+#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<ParsedClass*> classList)
+{
+ ClassTreeItem *root = new ClassTreeClassItem(this, 0, parsedClass);
+
+ ClassTreeItem *lastItem = 0;
+
+ QValueList<ParsedClass*>::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<ParsedParent> &parentList)
+{
+ ClassTreeItem *root = new ClassTreeClassItem(this, 0, parsedClass);
+
+ ClassTreeItem *lastItem = 0;
+
+ QPtrListIterator<ParsedParent> 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<ParsedAttribute*> attrList = parsedClass->getSortedAttributeList();
+ QValueList<ParsedAttribute*>::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<ParsedMethod*> methodList = parsedClass->getSortedMethodList();
+ QValueList<ParsedMethod*>::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"