3 // Copyright by Johannes Sixt
4 // This file is under GPL, the GNU General Public Licence
13 class ProgramTypeTable
;
16 /* a variable's value is the tree of sub-variables */
18 class VarTree
: public KTreeViewItem
21 enum VarKind
{ VKsimple
, VKpointer
, VKstruct
, VKarray
,
22 VKdummy
/* used to update only children */
25 enum NameKind
{ NKplain
, NKstatic
, NKtype
,
26 NKaddress
/* a dereferenced pointer */
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
);
39 void paintValue(QPainter
* painter
);
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
57 ExprWnd(QWidget
* parent
, const char* name
);
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();
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
);
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
);
104 void slotExpandOrCollapse(int);