connect(m_model, &Model::dataReady,
this, &MainWindow::dataReady);
- connect(m_ui->filter, &QLineEdit::textChanged,
- proxy, &QSortFilterProxyModel::setFilterFixedString);
+ connect(m_ui->filterFunction, &QLineEdit::textChanged,
+ proxy, &Proxy::setFunctionFilter);
+ connect(m_ui->filterFile, &QLineEdit::textChanged,
+ proxy, &Proxy::setFileFilter);
+ connect(m_ui->filterModule, &QLineEdit::textChanged,
+ proxy, &Proxy::setModuleFilter);
}
MainWindow::~MainWindow()
</widget>
</item>
<item>
- <widget class="QLineEdit" name="filter">
- <property name="placeholderText">
- <string>filter...</string>
- </property>
+ <widget class="QWidget" name="widget" native="true">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLineEdit" name="filterFunction">
+ <property name="placeholderText">
+ <string>filter by function...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="filterFile">
+ <property name="placeholderText">
+ <string>filter by file...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="filterModule">
+ <property name="placeholderText">
+ <string>filter by module...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
<item>
Proxy::~Proxy() = default;
-bool Proxy::acceptRow(int source_row, const QModelIndex& source_parent) const
+void Proxy::setFunctionFilter(const QString& functionFilter)
+{
+ m_functionFilter = functionFilter;
+ invalidate();
+}
+
+void Proxy::setFileFilter(const QString& fileFilter)
+{
+ m_fileFilter = fileFilter;
+ invalidate();
+}
+
+void Proxy::setModuleFilter(const QString& moduleFilter)
+{
+ m_moduleFilter = moduleFilter;
+ invalidate();
+}
+
+bool Proxy::acceptRow(int sourceRow, const QModelIndex& sourceParent) const
{
auto source = sourceModel();
if (!source) {
return false;
}
- const auto& needle = filterRegExp().pattern();
- if (needle.isEmpty()) {
- return true;
+ if (!m_functionFilter.isEmpty()) {
+ const auto& function = source->index(sourceRow, Model::FunctionColumn, sourceParent).data().toString();
+ if (!function.contains(m_functionFilter)) {
+ return false;
+ }
+ }
+ if (!m_fileFilter.isEmpty()) {
+ const auto& file = source->index(sourceRow, Model::FileColumn, sourceParent).data().toString();
+ if (!file.contains(m_fileFilter)) {
+ return false;
+ }
}
- for (auto column : {Model::FunctionColumn, Model::FileColumn, Model::ModuleColumn}) {
- const auto& haystack = source->index(source_row, column, source_parent).data(Qt::DisplayRole).toString();
- if (haystack.contains(needle)) {
- return true;
+ if (!m_moduleFilter.isEmpty()) {
+ const auto& module = source->index(sourceRow, Model::ModuleColumn, sourceParent).data().toString();
+ if (!module.contains(m_moduleFilter)) {
+ return false;
}
}
- return false;
+ return true;
}
explicit Proxy(QObject* parent);
virtual ~Proxy();
-protected:
+public slots:
+ void setFunctionFilter(const QString& functionFilter);
+ void setFileFilter(const QString& fileFilter);
+ void setModuleFilter(const QString& moduleFilter);
+
+private:
bool acceptRow(int source_row, const QModelIndex& source_parent) const override;
+
+ QString m_functionFilter;
+ QString m_fileFilter;
+ QString m_moduleFilter;
};
#endif // PROXY_H