diff options
author | Zack Rusin <zack@kde.org> | 2011-09-24 17:06:38 -0400 |
---|---|---|
committer | Zack Rusin <zack@kde.org> | 2011-09-24 17:06:38 -0400 |
commit | 101c49423726ec6700b9a28cdcefc559400b5aee (patch) | |
tree | 76fff2aa030e52ccb7a5837d3db5571709a990b3 | |
parent | daf82af9d5f270c87434cc1142f32a6407703781 (diff) |
Add a custom filter to the event view.
Allows one to filter out any custom call. Very useful on large traces
that have e.g. millions of redundant GetCurrentContext and
MakeCurrentContext calls.
-rw-r--r-- | gui/apitracefilter.cpp | 14 | ||||
-rw-r--r-- | gui/apitracefilter.h | 7 | ||||
-rw-r--r-- | gui/settingsdialog.cpp | 36 | ||||
-rw-r--r-- | gui/ui/settings.ui | 109 |
4 files changed, 129 insertions, 37 deletions
diff --git a/gui/apitracefilter.cpp b/gui/apitracefilter.cpp index cfa930d..a908325 100644 --- a/gui/apitracefilter.cpp +++ b/gui/apitracefilter.cpp @@ -63,6 +63,10 @@ bool ApiTraceFilter::filterAcceptsRow(int sourceRow, return false; } + if (m_filters & CustomFilter) { + return !function.contains(m_customRegexp); + } + return true; } @@ -102,4 +106,14 @@ QRegExp ApiTraceFilter::filterRegexp() const return m_regexp; } +void ApiTraceFilter::setCustomFilterRegexp(const QString &str) +{ + m_customRegexp = QRegExp(str); +} + +QString ApiTraceFilter::customFilterRegexp() const +{ + return m_customRegexp.pattern(); +} + #include "apitracefilter.moc" diff --git a/gui/apitracefilter.h b/gui/apitracefilter.h index 30c92a1..35f627d 100644 --- a/gui/apitracefilter.h +++ b/gui/apitracefilter.h @@ -11,11 +11,12 @@ class ApiTraceFilter : public QSortFilterProxyModel Q_OBJECT public: enum FilterOption { - NullFilter = 0, + NullFilter = 0, ExtensionsFilter = 1 << 0, ResolutionsFilter = 1 << 1, ErrorsQueryFilter = 1 << 2, ExtraStateFilter = 1 << 3, + CustomFilter = 1 << 4, }; Q_DECLARE_FLAGS(FilterOptions, FilterOption) public: @@ -27,6 +28,9 @@ public: void setFilterRegexp(const QRegExp ®exp); QRegExp filterRegexp() const; + void setCustomFilterRegexp(const QString &str); + QString customFilterRegexp() const; + QModelIndex indexForCall(ApiTraceCall *call) const; protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; @@ -34,6 +38,7 @@ protected: private: QRegExp m_regexp; FilterOptions m_filters; + QRegExp m_customRegexp; }; #endif diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index e3d7864..c44b107 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -38,6 +38,15 @@ void SettingsDialog::filtersFromModel(const ApiTraceFilter *model) 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()) { @@ -63,14 +72,22 @@ void SettingsDialog::filtersFromModel(const ApiTraceFilter *model) void SettingsDialog::filtersToModel(ApiTraceFilter *model) { ApiTraceFilter::FilterOptions opts = ApiTraceFilter::NullFilter; - if (extensionsBox->isChecked()) + if (extensionsBox->isChecked()) { opts |= ApiTraceFilter::ExtensionsFilter; - if (functionsBox->isChecked()) + } + if (functionsBox->isChecked()) { opts |= ApiTraceFilter::ResolutionsFilter; - if (errorsBox->isChecked()) + } + if (errorsBox->isChecked()) { opts |= ApiTraceFilter::ErrorsQueryFilter; - if (statesBox->isChecked()) + } + 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())); @@ -92,6 +109,17 @@ void SettingsDialog::accept() 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(); } diff --git a/gui/ui/settings.ui b/gui/ui/settings.ui index 748f4d5..1d2da3e 100644 --- a/gui/ui/settings.ui +++ b/gui/ui/settings.ui @@ -2,12 +2,15 @@ <ui version="4.0"> <class>Settings</class> <widget class="QDialog" name="Settings"> + <property name="enabled"> + <bool>true</bool> + </property> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>438</width> - <height>333</height> + <width>571</width> + <height>334</height> </rect> </property> <property name="windowTitle"> @@ -25,34 +28,60 @@ <property name="title"> <string>Hidden Events</string> </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QCheckBox" name="extensionsBox"> - <property name="text"> - <string>Extension queries</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QCheckBox" name="functionsBox"> - <property name="text"> - <string>Function resolution</string> - </property> - </widget> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QCheckBox" name="extensionsBox"> + <property name="text"> + <string>Extension queries</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="functionsBox"> + <property name="text"> + <string>Function resolution</string> + </property> + </widget> + </item> + </layout> </item> - <item row="1" column="0"> - <widget class="QCheckBox" name="errorsBox"> - <property name="text"> - <string>Error queries</string> - </property> - </widget> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QCheckBox" name="errorsBox"> + <property name="text"> + <string>Error queries</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="statesBox"> + <property name="text"> + <string>Extra state queries</string> + </property> + </widget> + </item> + </layout> </item> - <item row="1" column="1"> - <widget class="QCheckBox" name="statesBox"> - <property name="text"> - <string>Extra state queries</string> - </property> - </widget> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QCheckBox" name="customBox"> + <property name="text"> + <string>Custom</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="customEdit"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> </item> </layout> </widget> @@ -109,8 +138,8 @@ <slot>accept()</slot> <hints> <hint type="sourcelabel"> - <x>248</x> - <y>254</y> + <x>252</x> + <y>329</y> </hint> <hint type="destinationlabel"> <x>157</x> @@ -125,8 +154,8 @@ <slot>reject()</slot> <hints> <hint type="sourcelabel"> - <x>316</x> - <y>260</y> + <x>320</x> + <y>329</y> </hint> <hint type="destinationlabel"> <x>286</x> @@ -134,5 +163,21 @@ </hint> </hints> </connection> + <connection> + <sender>customBox</sender> + <signal>toggled(bool)</signal> + <receiver>customEdit</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>63</x> + <y>151</y> + </hint> + <hint type="destinationlabel"> + <x>107</x> + <y>151</y> + </hint> + </hints> + </connection> </connections> </ui> |