File: exprwnd.h

package info (click to toggle)
kdbg 1.2.4-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,504 kB
  • ctags: 1,945
  • sloc: cpp: 15,961; sh: 8,183; makefile: 481; perl: 71; ansic: 16
file content (107 lines) | stat: -rw-r--r-- 3,805 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// $Id: exprwnd.h,v 1.13.2.1 2001/12/28 21:10:28 jsixt Exp $

// Copyright by Johannes Sixt
// This file is under GPL, the GNU General Public Licence

#ifndef EXPRWND_H
#define EXPRWND_H

#include "ktreeview.h"
#include <qlist.h>
#include <qstrlist.h>

class ProgramTypeTable;
class TypeInfo;

/* a variable's value is the tree of sub-variables */

class VarTree : public KTreeViewItem
{
public:
    enum VarKind { VKsimple, VKpointer, VKstruct, VKarray,
	VKdummy				/* used to update only children */
    };
    VarKind m_varKind;
    enum NameKind { NKplain, NKstatic, NKtype,
	NKaddress			/* a dereferenced pointer */
    };
    NameKind m_nameKind;
    QString m_value;
    bool m_valueChanged;
    TypeInfo* m_type;			/* type of struct */
    int m_exprIndex;			/* used in struct value update */
    bool m_exprIndexUseGuard;		/* ditto; if guard expr should be used */
    QString m_partialValue;		/* while struct value update is in progress */

    VarTree(const QString& name, NameKind kind);
    virtual ~VarTree();
public:
    void paintValue(QPainter* painter);
    int valueWidth();
    QString computeExpr() const;
    bool isToplevelExpr() const;
    /** is this element an ancestor of (or equal to) child? */
    bool isAncestorEq(const VarTree* child) const;
    /** update the value; return if repaint is necessary */
    bool updateValue(const QString& newValue);
    /** find out the type of this value using the child values */
    void inferTypesOfChildren(ProgramTypeTable& typeTable);
    /** get the type from base class part */
    TypeInfo* inferTypeFromBaseClass();
};

class ExprWnd : public KTreeView
{
    Q_OBJECT
public:
    ExprWnd(QWidget* parent, const char* name);
    ~ExprWnd();

    /** fills the list with the expressions at the topmost level */
    void exprList(QStrList& exprs);
    /** appends var the the end of the tree at the topmost level */
    void insertExpr(VarTree* expr);
    /** updates an existing expression */
    void updateExpr(VarTree* expr);
    void updateExpr(VarTree* display, VarTree* newValues);
    /** updates the value and repaints it for a single item (not the children) */
    void updateSingleExpr(VarTree* display, VarTree* newValues);
    /** updates only the value of the node */
    void updateStructValue(VarTree* display);
    /** get a top-level expression by name */
    VarTree* topLevelExprByName(const char* name);
    /** removes an expression; must be on the topmost level*/
    void removeExpr(VarTree* item);
    /** retrieves the expression string at the specified line */
    QString exprStringAt(int index);
    /** clears the list of pointers needing updates */
    void clearPendingUpdates();
    /** returns a pointer to update (or 0) and removes it from the list */
    VarTree* nextUpdatePtr();
    VarTree* nextUpdateType();
    VarTree* nextUpdateStruct();

protected:
    bool updateExprRec(VarTree* display, VarTree* newValues);
    void replaceChildren(VarTree* display, VarTree* newValues);
    virtual void paintCell(QPainter* painter, int row, int col);
    virtual int cellWidth(int col) const;
    void updateValuesWidth();
    static bool getMaxValueWidth(KTreeViewItem* item, void* user);
    void collectUnknownTypes(VarTree* item);
    static bool collectUnknownTypes(KTreeViewItem* item, void* user);
    int maxValueWidth;
    QPixmap m_pixPointer;

    QList<VarTree> m_updatePtrs;	/* dereferenced pointers that need update */
    QList<VarTree> m_updateType;	/* structs whose type must be determined */
    QList<VarTree> m_updateStruct;	/* structs whose nested value needs update */

    /** remove items that are in the subTree from the list */
    static void sweepList(QList<VarTree>& list, VarTree* subTree);

protected slots:
    void slotExpandOrCollapse(int);
};

#endif // EXPRWND_H