KDevelop API Documentation

parts/classview/hierarchydlg.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2001 by Bernd Gehrmann * 00003 * bernd@kdevelop.org * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 ***************************************************************************/ 00011 00012 #include "hierarchydlg.h" 00013 00014 #include <kdialog.h> 00015 #include <klocale.h> 00016 #include <kpushbutton.h> 00017 #include <kstdguiitem.h> 00018 00019 #include <qlayout.h> 00020 #include <qlistview.h> 00021 #include <qsplitter.h> 00022 00023 #include "kdevlanguagesupport.h" 00024 #include "kcomboview.h" 00025 00026 #include "classviewpart.h" 00027 //#include "classtoolwidget.h" 00028 #include "digraphview.h" 00029 #include "viewcombos.h" 00030 00031 00032 HierarchyDialog::HierarchyDialog( ClassViewPart *part ) 00033 : QDialog(0, "hierarchy dialog", WDestructiveClose) 00034 { 00035 class_combo = new KComboView(false, 150, this); 00036 // class_combo->setMinimumWidth(150); 00037 namespace_combo = new KComboView(false, 150, this); 00038 // namespace_combo->setMinimumWidth(150); 00039 00040 QPushButton *close_button = new KPushButton(KStdGuiItem::close(), this); 00041 00042 QSplitter *splitter = new QSplitter(Vertical, this); 00043 digraph = new DigraphView(splitter, "digraph view"); 00044 // member_tree = new ClassToolWidget(part, splitter); 00045 00046 QBoxLayout *layout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint()); 00047 QBoxLayout *combo_layout = new QHBoxLayout(); 00048 layout->addLayout(combo_layout); 00049 combo_layout->addWidget(namespace_combo); 00050 combo_layout->addWidget(class_combo); 00051 combo_layout->addStretch(); 00052 combo_layout->addWidget(close_button); 00053 layout->addWidget(splitter); 00054 00055 connect( namespace_combo, SIGNAL(activated(QListViewItem*)), 00056 this, SLOT(slotNamespaceComboChoice(QListViewItem*)) ); 00057 connect( class_combo, SIGNAL(activated(QListViewItem*)), 00058 this, SLOT(slotClassComboChoice(QListViewItem*)) ); 00059 connect( close_button, SIGNAL(clicked()), 00060 this, SLOT(reject()) ); 00061 connect( digraph, SIGNAL(selected(const QString&)), 00062 this, SLOT(classSelected(const QString&)) ); 00063 00064 m_part = part; 00065 // m_part->registerHierarchyDialog(this); 00066 refresh(); 00067 } 00068 00069 00070 HierarchyDialog::~HierarchyDialog() 00071 { 00072 // m_part->unregisterHierarchyDialog(this); 00073 } 00074 00075 00076 void HierarchyDialog::refresh() 00077 { 00078 digraph->clear(); 00079 ViewCombosOp::refreshNamespaces(m_part, namespace_combo); 00080 processNamespace("", m_part->codeModel()->globalNamespace()); 00081 00082 KDevLanguageSupport *ls = m_part->languageSupport(); 00083 00084 for (QMap<QString, ClassDom>::const_iterator it = classes.begin(); it != classes.end(); ++it) 00085 { 00086 QString formattedName = ls->formatClassName(it.key()); 00087 QStringList baseClasses = it.data()->baseClassList(); 00088 for (QStringList::const_iterator bit = baseClasses.begin(); bit != baseClasses.end(); ++bit) 00089 { 00090 QMap<QString, QString>::const_iterator baseIt = uclasses.find(*bit); 00091 if (baseIt != uclasses.end()) 00092 { 00093 QString formattedParentName = ls->formatClassName(baseIt.data()); 00094 digraph->addEdge(formattedParentName, formattedName); 00095 } 00096 } 00097 } 00098 digraph->process(); 00099 } 00100 00101 void HierarchyDialog::setLanguageSupport(KDevLanguageSupport *ls) 00102 { 00103 if (ls) 00104 connect(ls, SIGNAL(updatedSourceInfo()), this, SLOT(refresh())); 00105 else 00106 refresh(); 00107 } 00108 00109 00110 void HierarchyDialog::slotClassComboChoice(QListViewItem * item) 00111 { 00112 ClassItem *ci = dynamic_cast<ClassItem*>(item); 00113 if (!ci) 00114 return; 00115 00116 KDevLanguageSupport *ls = m_part->languageSupport(); 00117 00118 QString className = ls->formatClassName(uclasses[item->text(0)]); 00119 digraph->setSelected(className); 00120 digraph->ensureVisible(className); 00121 classSelected(className); 00122 } 00123 00124 00125 void HierarchyDialog::classSelected(const QString &/*className*/) 00126 { 00127 /* ParsedClass *currentClass = m_part->classStore()->getClassByName(className); 00128 member_tree->clear(); 00129 if (currentClass) { 00130 KDevLanguageSupport::Features features = m_part->languageSupport()->features(); 00131 if (features & KDevLanguageSupport::Functions) 00132 member_tree->insertAllClassMethods(currentClass, (PIAccess)-1); 00133 if (features & KDevLanguageSupport::Variables) 00134 member_tree->insertAllClassAttributes(currentClass, (PIAccess)-1); 00135 }*/ 00136 } 00137 00138 void HierarchyDialog::slotNamespaceComboChoice( QListViewItem * item ) 00139 { 00140 NamespaceItem *ni = dynamic_cast<NamespaceItem*>(item); 00141 if (!ni) 00142 return; 00143 ViewCombosOp::refreshClasses(m_part, class_combo, ni->dom()->name()); 00144 } 00145 00146 void HierarchyDialog::processNamespace( QString prefix, NamespaceDom dom ) 00147 { 00148 qWarning("processNamespace: prefix %s", prefix.latin1()); 00149 QString prefixInc = prefix.isEmpty() ? "" : "."; 00150 // QString nsprefix = dom->name().isEmpty() ? QString("") : prefixInc + dom->name(); 00151 00152 NamespaceList namespaceList = dom->namespaceList(); 00153 for (NamespaceList::const_iterator it = namespaceList.begin(); it != namespaceList.end(); ++it) 00154 { 00155 qWarning("about to processNamespace: prefix %s", (prefixInc + (*it)->name()).latin1()); 00156 processNamespace(prefixInc + (*it)->name(), *it); 00157 } 00158 00159 ClassList classList = dom->classList(); 00160 for (ClassList::const_iterator it = classList.begin(); it != classList.end(); ++it) 00161 { 00162 processClass(prefix, *it); 00163 } 00164 } 00165 00166 void HierarchyDialog::processClass( QString prefix, ClassDom dom ) 00167 { 00168 qWarning("processClass: prefix %s class %s", prefix.latin1(), dom->name().latin1()); 00169 00170 QString prefixInc = prefix.isEmpty() ? "" : "."; 00171 classes[prefix + prefixInc + dom->name()] = dom; 00172 uclasses[dom->name()] = prefix + prefixInc + dom->name(); 00173 00174 ClassList classList = dom->classList(); 00175 for (ClassList::const_iterator it = classList.begin(); it != classList.end(); ++it) 00176 { 00177 processClass(prefix + prefixInc + dom->name(), *it); 00178 } 00179 } 00180 00181 #include "hierarchydlg.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 6 17:39:10 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003