~ubuntu-branches/ubuntu/oneiric/valkyrie/oneiric

« back to all changes in this revision

Viewing changes to valkyrie/tool_views/vglogview.h

  • Committer: Bazaar Package Importer
  • Author(s): Hai Zaar
  • Date: 2009-05-06 14:48:00 UTC
  • Revision ID: james.westby@ubuntu.com-20090506144800-vw617m4d4qa2pam3
Tags: upstream-1.4.0
ImportĀ upstreamĀ versionĀ 1.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ---------------------------------------------------------------------
 
2
 * Definition of VgLogView                                   vglogview.h
 
3
 * Links VgLog elements with qlistview elements
 
4
 * ---------------------------------------------------------------------
 
5
 * This file is part of Valkyrie, a front-end for Valgrind
 
6
 * Copyright (C) 2000-2008, OpenWorks LLP <info@open-works.co.uk>
 
7
 * This program is released under the terms of the GNU GPL v.2
 
8
 * See the file COPYING for the full license details.
 
9
 */
 
10
 
 
11
#ifndef __VK_VGLOGVIEW_H
 
12
#define __VK_VGLOGVIEW_H
 
13
 
 
14
#include "vglog.h"
 
15
 
 
16
#include <qlistview.h>
 
17
#include <qpixmap.h>
 
18
#include <qdatetime.h>
 
19
 
 
20
 
 
21
/**********************************************************************/
 
22
/* VgOutputItem: base class
 
23
   item classes set up their own state and text in their construtors,
 
24
   and item->setOpen() sets up item's children.
 
25
   - only spends time populating an item when seen
 
26
   - no item opened before setup (inc. children's) finished.
 
27
   only a couple of sub-classes currently implement different
 
28
   looks/functionality, but more future proof to have them separated.
 
29
*/
 
30
class VgOutputItem : public QListViewItem
 
31
{
 
32
public:
 
33
   VgOutputItem( QListView* parent, VgElement );
 
34
   VgOutputItem( QListViewItem* parent, VgElement );
 
35
   VgOutputItem( QListViewItem* parent, QListViewItem* after, VgElement );
 
36
 
 
37
   void initialise();
 
38
   void setText( QString str );
 
39
 
 
40
   /* some make-life-simpler stuff */
 
41
   VgOutputItem* firstChild();
 
42
   VgOutputItem* nextSibling();
 
43
   VgOutputItem* parent();
 
44
   void paintCell( QPainter* p, const QColorGroup& cg,
 
45
                   int col, int width, int align );
 
46
   void setOpen( bool open );
 
47
 
 
48
   VgElement::ElemType elemType() { return elem.elemType(); }
 
49
 
 
50
public:
 
51
   bool isReadable, isWriteable;
 
52
   VgElement elem;               /* associated element */
 
53
};
 
54
 
 
55
/**********************************************************************/
 
56
class TopStatusItem : public VgOutputItem
 
57
{
 
58
public:
 
59
   TopStatusItem( QListView* parent, VgStatus status,
 
60
                  VgElement args, QString protocol );
 
61
   void updateStatus( VgStatus s );
 
62
   void updateErrorCounts( VgErrCounts ec );
 
63
   void updateLeakCounts( VgError leak );
 
64
 
 
65
private:
 
66
   int num_errs, num_bytes, num_blocks;
 
67
   QString status_tmplt, status_str, errcounts_tmplt;
 
68
   QString stime;
 
69
   QString protocol;
 
70
};
 
71
 
 
72
/**********************************************************************/
 
73
class InfoItem : public VgOutputItem
 
74
{
 
75
public:
 
76
   InfoItem( VgOutputItem* parent, VgElement root );
 
77
   void setOpen( bool open );
 
78
};
 
79
 
 
80
/**********************************************************************/
 
81
class LogQualItem : public VgOutputItem
 
82
{
 
83
public:
 
84
   LogQualItem( VgOutputItem* parent, VgElement logqual );
 
85
   void setOpen( bool open );
 
86
};
 
87
 
 
88
/**********************************************************************/
 
89
class CommentItem : public VgOutputItem
 
90
{
 
91
public:
 
92
   CommentItem( VgOutputItem* parent, QListViewItem* after,
 
93
                VgElement cmnt );
 
94
   void setOpen( bool open );
 
95
};
 
96
 
 
97
/**********************************************************************/
 
98
class ArgsItem : public VgOutputItem
 
99
{
 
100
public:
 
101
   ArgsItem( VgOutputItem* parent, QListViewItem* after,
 
102
             VgElement vgargs );
 
103
   void setOpen( bool open );
 
104
};
 
105
 
 
106
/**********************************************************************/
 
107
class PreambleItem : public VgOutputItem
 
108
{
 
109
public:
 
110
   PreambleItem( VgOutputItem* parent, QListViewItem* after,
 
111
                 VgPreamble preamble );
 
112
   void setOpen( bool open );
 
113
};
 
114
 
 
115
/**********************************************************************/
 
116
class ErrorItem : public VgOutputItem
 
117
{
 
118
public:
 
119
   ErrorItem( VgOutputItem* parent, QListViewItem* after,
 
120
              VgError err );
 
121
   void setOpen( bool open );
 
122
   void updateCount( QString count );
 
123
   bool isLeak() { return ((VgError*)&elem)->isLeak(); }
 
124
 
 
125
   /* mapping of error::kind to 3-letter acronyms */
 
126
   typedef QMap<QString, QString> AcronymMap;
 
127
   static AcronymMap acronymMap;
 
128
 
 
129
private:
 
130
   QString errorAcronym( QString kind );
 
131
   QString err_tmplt;
 
132
};
 
133
 
 
134
/**********************************************************************/
 
135
class StackItem : public VgOutputItem
 
136
{
 
137
public:
 
138
   StackItem( VgOutputItem* parent, QListViewItem* after,
 
139
              VgElement stck );
 
140
   void setOpen( bool open );
 
141
};
 
142
 
 
143
/**********************************************************************/
 
144
class FrameItem : public VgOutputItem
 
145
{
 
146
public:
 
147
   FrameItem( VgOutputItem* parent, QListViewItem* after,
 
148
              VgFrame frm );
 
149
   void setOpen( bool open );
 
150
};
 
151
 
 
152
/**********************************************************************/
 
153
/* class SrcItem (error::stack::frame::dir/file/line)
 
154
   - pale gray background colour.
 
155
   - 'read'/'write' pixmap to denote user perms for src file.
 
156
   - click item => source file opened in an editor, at lineno. */
 
157
class SrcItem : public VgOutputItem
 
158
{
 
159
public:
 
160
   SrcItem( VgOutputItem* parent, VgElement line, QString path );
 
161
   ~SrcItem();
 
162
 
 
163
   void setPixmap( const char* pix_xpm[] );
 
164
   const QPixmap* pixmap( int i ) const;
 
165
   void paintCell( QPainter* p, const QColorGroup& cg,
 
166
                   int col, int width, int align );
 
167
 
 
168
private:
 
169
   QPixmap* pix;
 
170
};
 
171
 
 
172
/**********************************************************************/
 
173
class SuppCountsItem : public VgOutputItem
 
174
{
 
175
public:
 
176
   SuppCountsItem( VgOutputItem* parent, QListViewItem* after,
 
177
                   VgSuppCounts sc );
 
178
   void setOpen( bool open );
 
179
};
 
180
 
 
181
 
 
182
 
 
183
 
 
184
/**********************************************************************/
 
185
/* VgLogView: inherits VgLog
 
186
   - takes qlistview in constructor, and populates it at the same 
 
187
   time the underlying vglog is populated
 
188
   - associates each listview item with a VgLog element,
 
189
   which is used to set the text of the item, and is intended for
 
190
   future use of accessing/editing the underlying log
 
191
   (e.g. generating a suppression by clicking on an error item)
 
192
*/
 
193
class VgLogView : public VgLog
 
194
{
 
195
public:
 
196
   VgLogView( QListView* lv );
 
197
   ~VgLogView();
 
198
 
 
199
   bool appendNode( QDomNode node );
 
200
 
 
201
private:
 
202
   void updateErrorItems( VgErrCounts ec );
 
203
 
 
204
private:
 
205
   QListView* lview;          /* we don't own this: don't delete it */
 
206
   VgOutputItem* lastChild;
 
207
   TopStatusItem* topStatus;
 
208
};
 
209
 
 
210
 
 
211
#endif // #ifndef __VK_VGLOGVIEW_H