KDevelop API Documentation

classtoolwidget.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 1999 by Jonas Nordin                                    *
00003  *   jonas.nordin@syncom.se                                                *
00004  *   Copyright (C) 2000-2001 by Bernd Gehrmann                             *
00005  *   bernd@kdevelop.org                                                    *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  ***************************************************************************/
00013 
00014 #include "classtoolwidget.h"
00015 
00016 #include <kconfig.h>
00017 #include <klocale.h>
00018 #include <kglobal.h>
00019 #include <kpopupmenu.h>
00020 #include "classstore.h"
00021 
00022 
00023 ClassToolWidget::ClassToolWidget(ClassViewPart *part, QWidget *parent)
00024     : ClassTreeBase(part, parent, "class tool widget")
00025 {}
00026 
00027 
00028 ClassToolWidget::~ClassToolWidget()
00029 {}
00030 
00031 
00032 KPopupMenu *ClassToolWidget::createPopup()
00033 {
00034     KPopupMenu *popup = contextItem? contextItem->createPopup() : 0;
00035     if (!popup) {
00036         popup = new KPopupMenu(this);
00037     popup->insertTitle(i18n("Class Tool"));
00038     }
00039 
00040     return popup;
00041 }
00042 
00043 
00044 void ClassToolWidget::insertClassAndClasses(ParsedClass *parsedClass, QValueList<ParsedClass*> classList)
00045 {
00046     ClassTreeItem *root = new ClassTreeClassItem(this, 0, parsedClass);
00047     
00048     ClassTreeItem *lastItem = 0;
00049 
00050     QValueList<ParsedClass*>::ConstIterator it;
00051     for (it = classList.begin(); it != classList.end(); ++it) {
00052         lastItem = new ClassTreeClassItem(root, lastItem, *it);
00053         lastItem->setExpandable(false);
00054     }
00055     
00056     if (!root->firstChild())
00057         root->setExpandable(false);
00058     else
00059         root->setOpen(true);
00060 }
00061 
00062 
00063 void ClassToolWidget::insertClassAndClasses(ParsedClass *parsedClass, const QPtrList<ParsedParent> &parentList)
00064 {
00065     ClassTreeItem *root = new ClassTreeClassItem(this, 0, parsedClass);
00066     
00067     ClassTreeItem *lastItem = 0;
00068 
00069     QPtrListIterator<ParsedParent> it(parentList);
00070     for (; it.current(); ++it) {
00071         ParsedClass *parentClass = m_part->classStore()->getClassByName((*it)->name());
00072         lastItem = new ClassTreeClassItem(root, lastItem, parentClass);
00073         lastItem->setExpandable(false);
00074     }
00075     
00076     if (!root->firstChild())
00077         root->setExpandable(false);
00078     else
00079         root->setOpen(true);
00080 }
00081 
00082 
00083 void ClassToolWidget::addClassAndAttributes(ParsedClass *parsedClass, PIAccess filter, ClassTreeItem **lastItem)
00084 {
00085     *lastItem = new ClassTreeClassItem(this, *lastItem, parsedClass);
00086 
00087     ClassTreeItem *ilastItem = 0;
00088     
00089     QValueList<ParsedAttribute*> attrList = parsedClass->getSortedAttributeList();
00090     QValueList<ParsedAttribute*>::ConstIterator it;
00091     for (it = attrList.begin(); it != attrList.end(); ++it) {
00092         if (filter == (PIAccess)-1 || filter == (*it)->access())
00093             ilastItem = new ClassTreeAttrItem(*lastItem, ilastItem, *it);
00094     }
00095 
00096     if (!(*lastItem)->firstChild())
00097         (*lastItem)->setExpandable(false);
00098     else
00099         (*lastItem)->setOpen(true);
00100 }
00101 
00102 
00103 void ClassToolWidget::addClassAndMethods(ParsedClass *parsedClass, PIAccess filter, ClassTreeItem **lastItem)
00104 {
00105     *lastItem = new ClassTreeClassItem(this, *lastItem, parsedClass);
00106     
00107     ClassTreeItem *ilastItem = 0;
00108     
00109     QValueList<ParsedMethod*> methodList = parsedClass->getSortedMethodList();
00110     QValueList<ParsedMethod*>::ConstIterator it;
00111     for (it = methodList.begin(); it != methodList.end(); ++it) {
00112         if (filter == (PIAccess)-1 || filter == (*it)->access())
00113             ilastItem = new ClassTreeMethodItem(*lastItem, ilastItem, *it);
00114     }
00115     
00116     if (!(*lastItem)->firstChild())
00117         (*lastItem)->setExpandable(false);
00118     else
00119         (*lastItem)->setOpen(true);
00120 }
00121 
00122 
00123 void ClassToolWidget::insertAllClassMethods(ParsedClass *parsedClass, PIAccess filter)
00124 {
00125     ClassTreeItem *lastItem = 0;
00126     
00127     // First treat all parents.
00128     for ( ParsedParent *pParent = parsedClass->parents.first();
00129           pParent != 0;
00130           pParent = parsedClass->parents.next() )
00131         {
00132             ParsedClass *parentClass = m_part->classStore()->getClassByName(pParent->name());
00133             if (parentClass)
00134                 addClassAndMethods(parentClass, filter, &lastItem);
00135         }
00136     
00137     // Add the current class
00138     addClassAndMethods(parsedClass, filter, &lastItem);
00139 }
00140 
00141 
00142 void ClassToolWidget::insertAllClassAttributes(ParsedClass *parsedClass, PIAccess filter)
00143 {
00144     ClassTreeItem *lastItem = 0;
00145     // First treat all parents.
00146     for ( ParsedParent *pParent = parsedClass->parents.first();
00147           pParent != 0;
00148           pParent = parsedClass->parents.next() )
00149         {
00150             ParsedClass *parentClass = m_part->classStore()->getClassByName(pParent->name());
00151             if (parentClass)
00152                 addClassAndAttributes(parentClass, filter, &lastItem);
00153         }
00154     
00155     // Add the current class
00156     addClassAndAttributes(parsedClass, filter, &lastItem);
00157 }
00158 
00159 #include "classtoolwidget.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:54 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003