]> git.cworth.org Git - apitrace/blob - gui/apitracefilter.cpp
Cleanup the event model code.
[apitrace] / gui / apitracefilter.cpp
1 #include "apitracefilter.h"
2
3 #include "apitracecall.h"
4 #include "apitracemodel.h"
5
6 #include <QDebug>
7
8 ApiTraceFilter::ApiTraceFilter(QObject *parent)
9     : QSortFilterProxyModel()
10 {
11 }
12
13 bool ApiTraceFilter::filterAcceptsRow(int sourceRow,
14                                       const QModelIndex &sourceParent) const
15 {
16     QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
17     QVariant varientData = sourceModel()->data(index0, ApiTraceModel::EventRole);
18     ApiTraceEvent *event = varientData.value<ApiTraceEvent*>();
19
20     Q_ASSERT(event);
21     if (!event)
22         return false;
23
24     //we don't filter frames
25     if (event->type() == ApiTraceEvent::Frame) {
26         return true;
27     }
28
29     ApiTraceCall *call = static_cast<ApiTraceCall*>(event);
30     QString function = call->name;
31
32     if (!m_text.isEmpty()) {
33         return function.contains(m_text);
34     }
35
36     //XXX make it configurable
37     if (function.contains(QLatin1String("glXGetProcAddress")))
38         return false;
39     if (function.contains(QLatin1String("wglGetProcAddress")))
40         return false;
41
42     QString fullText = call->filterText();
43     if (function.contains(QLatin1String("glGetString")) &&
44         fullText.contains(QLatin1String("GL_EXTENSIONS")))
45         return false;
46
47     return true;
48 }
49
50
51 void ApiTraceFilter::setFilterString(const QString &text)
52 {
53     if (text != m_text) {
54         m_text = text;
55         invalidate();
56     }
57 }
58
59 #include "apitracefilter.moc"