Fixed missing header file in make dist.
[kdbg.git] / kdbg / exprwnd.h
blobc2b31c9942c8666841d1f4b74c0a4c8e9dcd504e
1 // $Id$
3 // Copyright by Johannes Sixt
4 // This file is under GPL, the GNU General Public Licence
6 #ifndef EXPRWND_H
7 #define EXPRWND_H
9 #include "ktreeview.h"
10 #include <qlist.h>
11 #include <qstrlist.h>
13 class ProgramTypeTable;
14 class TypeInfo;
16 /* a variable's value is the tree of sub-variables */
18 class VarTree : public KTreeViewItem
20 public:
21 enum VarKind { VKsimple, VKpointer, VKstruct, VKarray,
22 VKdummy /* used to update only children */
24 VarKind m_varKind;
25 enum NameKind { NKplain, NKstatic, NKtype,
26 NKaddress /* a dereferenced pointer */
28 NameKind m_nameKind;
29 QString m_value;
30 bool m_valueChanged;
31 TypeInfo* m_type; /* type of struct */
32 int m_exprIndex; /* used in struct value update */
33 bool m_exprIndexUseGuard; /* ditto; if guard expr should be used */
34 QString m_partialValue; /* while struct value update is in progress */
36 VarTree(const QString& name, NameKind kind);
37 virtual ~VarTree();
38 public:
39 void paintValue(QPainter* painter);
40 int valueWidth();
41 QString computeExpr() const;
42 bool isToplevelExpr() const;
43 /** is this element an ancestor of (or equal to) child? */
44 bool isAncestorEq(const VarTree* child) const;
45 /** update the value; return if repaint is necessary */
46 bool updateValue(const QString& newValue);
47 /** find out the type of this value using the child values */
48 void inferTypesOfChildren(ProgramTypeTable& typeTable);
49 /** get the type from base class part */
50 TypeInfo* inferTypeFromBaseClass();
53 class ExprWnd : public KTreeView
55 Q_OBJECT
56 public:
57 ExprWnd(QWidget* parent, const char* name);
58 ~ExprWnd();
60 /** fills the list with the expressions at the topmost level */
61 void exprList(QStrList& exprs);
62 /** appends var the the end of the tree at the topmost level */
63 void insertExpr(VarTree* expr);
64 /** updates an existing expression */
65 void updateExpr(VarTree* expr);
66 void updateExpr(VarTree* display, VarTree* newValues);
67 /** updates the value and repaints it for a single item (not the children) */
68 void updateSingleExpr(VarTree* display, VarTree* newValues);
69 /** updates only the value of the node */
70 void updateStructValue(VarTree* display);
71 /** get a top-level expression by name */
72 VarTree* topLevelExprByName(const char* name);
73 /** removes an expression; must be on the topmost level*/
74 void removeExpr(VarTree* item);
75 /** retrieves the expression string at the specified line */
76 QString exprStringAt(int index);
77 /** clears the list of pointers needing updates */
78 void clearPendingUpdates();
79 /** returns a pointer to update (or 0) and removes it from the list */
80 VarTree* nextUpdatePtr();
81 VarTree* nextUpdateType();
82 VarTree* nextUpdateStruct();
84 protected:
85 bool updateExprRec(VarTree* display, VarTree* newValues);
86 void replaceChildren(VarTree* display, VarTree* newValues);
87 virtual void paintCell(QPainter* painter, int row, int col);
88 virtual int cellWidth(int col) const;
89 void updateValuesWidth();
90 static bool getMaxValueWidth(KTreeViewItem* item, void* user);
91 void collectUnknownTypes(VarTree* item);
92 static bool collectUnknownTypes(KTreeViewItem* item, void* user);
93 int maxValueWidth;
94 QPixmap m_pixPointer;
96 QList<VarTree> m_updatePtrs; /* dereferenced pointers that need update */
97 QList<VarTree> m_updateType; /* structs whose type must be determined */
98 QList<VarTree> m_updateStruct; /* structs whose nested value needs update */
100 /** remove items that are in the subTree from the list */
101 static void sweepList(QList<VarTree>& list, VarTree* subTree);
103 protected slots:
104 void slotExpandOrCollapse(int);
107 #endif // EXPRWND_H