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
|
#include "settingsdialog.h"
#include <QMessageBox>
SettingsDialog::SettingsDialog(QWidget *parent)
: QDialog(parent),
m_filter(0)
{
setupUi(this);
m_showFilters.insert(
tr("Draw events"),
QRegExp("glDraw|glVertex|glBegin|glEnd"));
m_showFilters.insert(
tr("Texture events"),
QRegExp("glTex|glBindTex|glBegin|glEnd"));
QMap<QString, QRegExp>::const_iterator itr;
for (itr = m_showFilters.constBegin();
itr != m_showFilters.constEnd(); ++itr) {
showFilterCB->addItem(itr.key(), itr.value());
}
showFilterCB->addItem(tr("Custom"), QRegExp());
connect(showFilterCB, SIGNAL(currentIndexChanged(const QString &)),
SLOT(changeRegexp(const QString&)));
connect(showFilterEdit, SIGNAL(textEdited(const QString &)),
SLOT(regexpChanged(const QString&)));
showFilterCB->setCurrentIndex(0);
showFilterEdit->setText(m_showFilters.constBegin().value().pattern());
}
void SettingsDialog::filtersFromModel(const ApiTraceFilter *model)
{
ApiTraceFilter::FilterOptions opts = model->filterOptions();
extensionsBox->setChecked(opts & ApiTraceFilter::ExtensionsFilter);
functionsBox->setChecked(opts & ApiTraceFilter::ResolutionsFilter);
errorsBox->setChecked(opts & ApiTraceFilter::ErrorsQueryFilter);
statesBox->setChecked(opts & ApiTraceFilter::ExtraStateFilter);
customBox->setChecked(opts & ApiTraceFilter::CustomFilter);
QString customFilter = model->customFilterRegexp();
if (!customFilter.isEmpty()) {
customEdit->setText(customFilter);
} else {
//Add a common default
QLatin1String str("glXMakeContextCurrent");
customEdit->setText(str);
}
QRegExp regexp = model->filterRegexp();
if (regexp.isEmpty()) {
showFilterBox->setChecked(false);
} else {
showFilterBox->setChecked(true);
QMap<QString, QRegExp>::const_iterator itr;
int i = 0;
for (itr = m_showFilters.constBegin();
itr != m_showFilters.constEnd(); ++itr, ++i) {
if (itr.value() == regexp) {
showFilterCB->setCurrentIndex(i);
showFilterEdit->setText(itr.value().pattern());
return;
}
}
/* custom filter */
showFilterCB->setCurrentIndex(m_showFilters.count());
showFilterEdit->setText(regexp.pattern());
}
}
void SettingsDialog::filtersToModel(ApiTraceFilter *model)
{
ApiTraceFilter::FilterOptions opts = ApiTraceFilter::NullFilter;
if (extensionsBox->isChecked()) {
opts |= ApiTraceFilter::ExtensionsFilter;
}
if (functionsBox->isChecked()) {
opts |= ApiTraceFilter::ResolutionsFilter;
}
if (errorsBox->isChecked()) {
opts |= ApiTraceFilter::ErrorsQueryFilter;
}
if (statesBox->isChecked()) {
opts |= ApiTraceFilter::ExtraStateFilter;
}
if (customBox->isChecked()) {
opts |= ApiTraceFilter::CustomFilter;
m_filter->setCustomFilterRegexp(customEdit->text());
}
m_filter->setFilterOptions(opts);
if (showFilterBox->isChecked()) {
m_filter->setFilterRegexp(QRegExp(showFilterEdit->text()));
} else {
m_filter->setFilterRegexp(QRegExp());
}
}
void SettingsDialog::accept()
{
if (showFilterBox->isChecked()) {
QRegExp regexp(showFilterEdit->text());
if (!regexp.isValid()) {
QMessageBox::warning(
this,
tr("Invalid Regexp"),
tr("The currently set regular expression "
"for filtering events is invalid."));
return;
}
}
if (customBox->isChecked()) {
QRegExp regexp(customEdit->text());
if (!regexp.isValid()) {
QMessageBox::warning(
this,
tr("Invalid Regexp"),
tr("The currently set regular expression "
"for custom events is invalid."));
return;
}
}
filtersToModel(m_filter);
QDialog::accept();
}
void SettingsDialog::changeRegexp(const QString &name)
{
showFilterEdit->setText(m_showFilters[name].pattern());
}
void SettingsDialog::regexpChanged(const QString &pattern)
{
int customIndex = m_showFilters.count();
if (showFilterCB->currentIndex() != customIndex) {
showFilterCB->blockSignals(true);
showFilterCB->setCurrentIndex(customIndex);
showFilterCB->blockSignals(false);
}
}
void SettingsDialog::setFilterModel(ApiTraceFilter *filter)
{
m_filter = filter;
filtersFromModel(m_filter);
}
#include "settingsdialog.moc"
|