-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcbGcovSummaryPanel.cpp
204 lines (164 loc) · 5.66 KB
/
cbGcovSummaryPanel.cpp
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#include "cbGcovSummaryPanel.h"
#include "editormanager.h"
#include <algorithm>
//(*InternalHeaders(cbGcovSummaryPanel)
#include <wx/intl.h>
#include <wx/listctrl.h>
#include <wx/sizer.h>
#include <wx/string.h>
//*)
//(*IdInit(cbGcovSummaryPanel)
const long cbGcovSummaryPanel::ID_LISTCTRL = wxNewId();
//*)
BEGIN_EVENT_TABLE(cbGcovSummaryPanel,wxPanel)
//(*EventTable(cbGcovSummaryPanel)
//*)
END_EVENT_TABLE()
wxString cbGcovSummaryPanel::shortName_(_("cbGcov summary"));
cbGcovSummaryPanel::cbGcovSummaryPanel(wxWindow* parent, const Summaries &summaries):
EditorBase(parent, _("cbGcov summary")),
summaries_(summaries)
{
//(*Initialize(cbGcovSummaryPanel)
wxBoxSizer* BoxSizer1;
Create(0, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("wxID_ANY"));
BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
listCtrl = new wxListCtrl(this, ID_LISTCTRL, wxDefaultPosition, wxDefaultSize, wxLC_REPORT, wxDefaultValidator, _T("ID_LISTCTRL"));
BoxSizer1->Add(listCtrl, 1, wxALL|wxEXPAND, 5);
SetSizer(BoxSizer1);
BoxSizer1->Fit(this);
BoxSizer1->SetSizeHints(this);
Connect(ID_LISTCTRL,wxEVT_COMMAND_LIST_ITEM_ACTIVATED,(wxObjectEventFunction)&cbGcovSummaryPanel::ItemActivated);
//*)
Connect(ID_LISTCTRL, wxEVT_COMMAND_LIST_COL_CLICK, (wxObjectEventFunction)&cbGcovSummaryPanel::OnColClick);
Layout();
InitGrid();
}
bool comapreGcovSummaryFileDataDescending(const gcovSummaryFileData &a, const gcovSummaryFileData &b)
{
return a.filename < b.filename;
}
bool comapreGcovSummaryFileDataAscending(const gcovSummaryFileData &a, const gcovSummaryFileData &b)
{
return a.filename >= b.filename;
}
void cbGcovSummaryPanel::InitGrid(bool doSort, bool sortAscending)
{
Summaries sum = summaries_;
if ( doSort )
{
if(sortAscending)
std::sort(sum.begin(), sum.end(), comapreGcovSummaryFileDataAscending);
else
std::sort(sum.begin(), sum.end(), comapreGcovSummaryFileDataDescending);
}
listCtrl->ClearAll();
wxListItem col0;
col0.SetId(0);
col0.SetAlign(wxLIST_FORMAT_LEFT);
col0.SetText( _("Filename") );
col0.SetWidth(400);
listCtrl->InsertColumn(0, col0);
wxListItem col1;
col1.SetId(1);
col1.SetAlign(wxLIST_FORMAT_RIGHT);
col1.SetText( _("Executed lines") );
col1.SetWidth(100);
listCtrl->InsertColumn(1, col1);
wxListItem col2;
col2.SetId(2);
col2.SetAlign(wxLIST_FORMAT_RIGHT);
col2.SetText( _("Line Coverage [%]") );
col2.SetWidth(100);
listCtrl->InsertColumn(2, col2);
wxListItem col3;
col3.SetId(3);
col3.SetAlign(wxLIST_FORMAT_RIGHT);
col3.SetText( _("branches evaluated") );
col3.SetWidth(100);
listCtrl->InsertColumn(3, col3);
wxListItem col4;
col4.SetId(4);
col4.SetAlign(wxLIST_FORMAT_RIGHT);
col4.SetText( _("branches taken") );
col4.SetWidth(100);
listCtrl->InsertColumn(4, col4);
wxListItem col5;
col5.SetId(5);
col5.SetAlign(wxLIST_FORMAT_RIGHT);
col5.SetText( _("Branch Coverage [%]") );
col5.SetWidth(100);
listCtrl->InsertColumn(5, col5);
wxListItem col6;
col6.SetId(6);
col6.SetAlign(wxLIST_FORMAT_RIGHT);
col6.SetText( _("Total calls") );
col6.SetWidth(100);
listCtrl->InsertColumn(6, col6);
wxListItem col7;
col7.SetId(7);
col7.SetAlign(wxLIST_FORMAT_RIGHT);
col7.SetText( _("Coverage [%]") );
col7.SetWidth(100);
listCtrl->InsertColumn(7, col7);
for(size_t n = 0 ; n < sum.size() ; ++n)
{
const gcovSummaryFileData data = sum[n];
wxListItem item;
item.SetId(n);
item.SetText( data.filename );
listCtrl->InsertItem( item );
listCtrl->SetItem(n, 0, data.filename);
if(data.hasLines)
{
listCtrl->SetItem(n, 1, wxString::Format(_T("%d / %d"), data.totalCodeLinesCalled, data.totalCodeLines));
float cov = 100.0*data.totalCodeLinesCalled/data.totalCodeLines;
long id = listCtrl->SetItem(n, 2, wxString::Format(_T("%.2f"), cov));
}
if(data.hasBranches)
{
listCtrl->SetItem(n, 3, wxString::Format(_T("%d / %d"), data.totalBranchesConditionEvaluated, data.totalBranches));
if(data.hasBranchesTaken)
{
listCtrl->SetItem(n, 4, wxString::Format(_T("%d"), data.totalBranchesTaken, data.totalBranches));
}
listCtrl->SetItem(n, 5, wxString::Format(_T("%.2f"), 100.0*data.totalBranchesConditionEvaluated/data.totalBranches));
}
if(data.hasCalls)
{
listCtrl->SetItem(n, 6, wxString::Format(_T("%d/ %d"), data.totalCallsExecuted, data.totalCalls));
listCtrl->SetItem(n, 7, wxString::Format(_T("%.2f"), 100.0*data.totalCallsExecuted/data.totalCalls));
}
}
}
cbGcovSummaryPanel::~cbGcovSummaryPanel()
{
//(*Destroy(cbGcovSummaryPanel)
//*)
}
const wxString& cbGcovSummaryPanel::GetFilename() const
{
return shortName_;
}
const wxString& cbGcovSummaryPanel::GetShortName() const
{
return shortName_;
}
const wxString& cbGcovSummaryPanel::GetTitle()
{
return shortName_;
}
void cbGcovSummaryPanel::ItemActivated(wxListEvent& event)
{
const wxListItem &item = event.GetItem();
wxString filename(item.GetText());
Manager::Get()->GetEditorManager()->Open(filename);
}
void cbGcovSummaryPanel::OnColClick(wxListEvent& event)
{
if(event.GetColumn() != 0)
return;
static bool ascending = false;
ascending = ascending ? false : true;
InitGrid(true, ascending);
}