00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef _CLASSTREEBASE_H_
00015 #define _CLASSTREEBASE_H_
00016
00017 #include <klistview.h>
00018 #include "parseditem.h"
00019 #include "parsedscopecontainer.h"
00020 #include "parsedclass.h"
00021 #include "parsedmethod.h"
00022 #include "parsedattribute.h"
00023 #include "classviewpart.h"
00024 #include "parsedscript.h"
00025
00026 class ClassTreeItem;
00027 class KPopupMenu;
00028
00029
00030 class ClassTreeBase : public KListView
00031 {
00032 Q_OBJECT
00033
00034 public:
00035 ClassTreeBase( ClassViewPart *part, QWidget *parent=0, const char *name=0 );
00036 ~ClassTreeBase();
00037
00038 protected:
00039 typedef QValueList<QStringList> TreeState;
00040 typedef QValueList<QStringList>::Iterator TreeStateIterator;
00041 TreeState treeState() const;
00042 void setTreeState(TreeState state);
00043
00044 ClassTreeItem *contextItem;
00045 virtual KPopupMenu *createPopup() = 0;
00046
00047 private slots:
00048 void slotItemExecuted(QListViewItem*);
00049 void slotItemPressed(int button, QListViewItem *item);
00050 void slotContextMenuRequested(QListViewItem *item, const QPoint &p);
00051 void slotGotoDeclaration();
00052 void slotGotoImplementation();
00053 void slotAddMethod();
00054 void slotAddAttribute();
00055 void slotClassBaseClasses();
00056 void slotClassDerivedClasses();
00057 void slotClassTool();
00058
00059 protected:
00060 ClassViewPart *m_part;
00061 friend class ClassTreeItem;
00062 friend class ClassTreeScopeItem;
00063 };
00064
00065
00066 class ClassTreeItem : public QListViewItem, public NotifyClient
00067 {
00068 public:
00069 ClassTreeItem( ClassTreeBase *parent, ClassTreeItem *lastSibling, ParsedItem *parsedItem )
00070 : QListViewItem(parent, lastSibling), NotifyClient(), m_item(parsedItem)
00071 {
00072 init();
00073 }
00074 ClassTreeItem( ClassTreeItem *parent, ClassTreeItem *lastSibling, ParsedItem *parsedItem )
00075 : QListViewItem(parent, lastSibling), NotifyClient(), m_item(parsedItem)
00076 {
00077 init();
00078 }
00079 ClassTreeItem( const ClassTreeItem& other )
00080 : QListViewItem( other.parent(), other.nextSibling()), NotifyClient()
00081 {
00082 m_item = other.m_item;
00083 init();
00084 }
00085 ClassTreeItem& operator=( const ClassTreeItem& other )
00086 {
00087 m_item = other.m_item;
00088 init();
00089 return *this;
00090 }
00091 ~ClassTreeItem()
00092 {
00093 if ( m_item )
00094 m_item->unregisterNotifyClient( (NotifyClient*)this );
00095 }
00096
00097
00098 void notify() { m_item = 0; }
00099
00100 KPopupMenu *createPopup();
00101 bool isOrganizer() { return !m_item; }
00102 void init()
00103 {
00104 if ( m_item )
00105 m_item->registerNotifyClient( (NotifyClient*)this );
00106 }
00107
00108 void getDeclaration(QString *toFile, int *toLine);
00109 void getImplementation(QString *toFile, int *toLine);
00110
00111 virtual QString scopedText() const;
00112 virtual QString text( int ) const;
00113 virtual QString tipText() const;
00114
00115 protected:
00116 ClassTreeBase *classTree()
00117 { return static_cast<ClassTreeBase*>(listView()); }
00118 ParsedItem *m_item;
00119 };
00120
00121
00122 class ClassTreeOrganizerItem : public ClassTreeItem
00123 {
00124 public:
00125 ClassTreeOrganizerItem( ClassTreeBase *parent, ClassTreeItem *lastSibling,
00126 const QString &text )
00127 : ClassTreeItem(parent, lastSibling, 0 )
00128 , m_text( text )
00129 { init(); }
00130 ClassTreeOrganizerItem( ClassTreeItem *parent, ClassTreeItem *lastSibling,
00131 const QString &text )
00132 : ClassTreeItem(parent, lastSibling, 0 )
00133 , m_text( text )
00134 { init(); }
00135 ~ClassTreeOrganizerItem()
00136 {}
00137
00138 virtual QString text( int ) const { return m_text; }
00139
00140 private:
00141 QString m_text;
00142
00143 void init();
00144 };
00145
00146
00147 class ClassTreeScopeItem : public ClassTreeItem
00148 {
00149 public:
00150 ClassTreeScopeItem( ClassTreeBase *parent, ClassTreeItem *lastSibling,
00151 ParsedScopeContainer *parsedScope )
00152 : ClassTreeItem(parent, lastSibling, parsedScope)
00153 {
00154 init();
00155 }
00156 ClassTreeScopeItem( ClassTreeItem *parent, ClassTreeItem *lastSibling,
00157 ParsedScopeContainer *parsedScope )
00158 : ClassTreeItem(parent, lastSibling, parsedScope)
00159 {
00160 init();
00161 }
00162 ~ClassTreeScopeItem()
00163 {
00164 }
00165
00166 virtual QString text( int ) const;
00167 virtual void setOpen(bool o);
00168
00169 private:
00170 void init();
00171 };
00172
00173
00174 class ClassTreeClassItem : public ClassTreeItem
00175 {
00176 public:
00177 ClassTreeClassItem( ClassTreeBase *parent, ClassTreeItem *lastSibling,
00178 ParsedClass *parsedClass, bool isStruct=false )
00179 : ClassTreeItem(parent, lastSibling, parsedClass), m_isStruct( isStruct )
00180 {
00181 init();
00182 }
00183 ClassTreeClassItem( ClassTreeItem *parent, ClassTreeItem *lastSibling,
00184 ParsedClass *parsedClass, bool isStruct=false )
00185 : ClassTreeItem(parent, lastSibling, parsedClass), m_isStruct( isStruct )
00186 {
00187 init();
00188 }
00189 ~ClassTreeClassItem()
00190 {
00191 }
00192
00193 virtual void setOpen(bool o);
00194
00195 private:
00196 void init();
00197
00198 private:
00199 bool m_isStruct;
00200 };
00201
00202
00203 class ClassTreeMethodItem : public ClassTreeItem
00204 {
00205 public:
00206 ClassTreeMethodItem( ClassTreeItem *parent, ClassTreeItem *lastSibling,
00207 ParsedMethod *parsedMethod );
00208 ~ClassTreeMethodItem()
00209 {
00210 }
00211
00212 virtual QString text( int ) const;
00213 };
00214
00215
00216 class ClassTreeAttrItem : public ClassTreeItem
00217 {
00218 public:
00219 ClassTreeAttrItem( ClassTreeItem *parent, ClassTreeItem *lastSibling,
00220 ParsedAttribute *parsedAttr );
00221 ~ClassTreeAttrItem()
00222 {
00223 }
00224
00225 virtual QString text( int ) const;
00226 };
00227
00228 class ClassTreeScriptItem : public ClassTreeItem
00229 {
00230 public:
00231 ClassTreeScriptItem( ClassTreeItem *parent, ClassTreeItem *lastSibling,
00232 ParsedScript *parsedScript );
00233 ~ClassTreeScriptItem()
00234 {
00235 }
00236
00237 virtual QString text( int ) const;
00238 virtual void setOpen(bool o);
00239 };
00240
00241
00242 #endif