diff --git a/libshvvisu/include/shv/visu/logview/logsortfilterproxymodel.h b/libshvvisu/include/shv/visu/logview/logsortfilterproxymodel.h index c00b3f94..57283ed4 100644 --- a/libshvvisu/include/shv/visu/logview/logsortfilterproxymodel.h +++ b/libshvvisu/include/shv/visu/logview/logsortfilterproxymodel.h @@ -18,16 +18,18 @@ class SHVVISU_DECL_EXPORT LogSortFilterProxyModel : public QSortFilterProxyModel explicit LogSortFilterProxyModel(QObject *parent = nullptr); void setChannelFilter(const std::optional &filter); - void setShvPathColumn(int column); + void setChannelFilterPathColumn(int column); void setValueColumn(int column); void setFulltextFilter(const shv::visu::timeline::FullTextFilter &filter); + void setFulltextFilterPathColumn(int column); bool filterAcceptsRow(int source_rrow, const QModelIndex &source_parent) const override; private: std::optional m_channelFilter; shv::visu::timeline::FullTextFilter m_fulltextFilter; - int m_shvPathColumn = -1; + int m_channelFilterPathColumn = -1; + int m_fulltextFilterPathColumn = -1; int m_valueColumn = -1; }; } diff --git a/libshvvisu/src/logview/dlgloginspector.cpp b/libshvvisu/src/logview/dlgloginspector.cpp index dd8197e1..9b5c2c5e 100644 --- a/libshvvisu/src/logview/dlgloginspector.cpp +++ b/libshvvisu/src/logview/dlgloginspector.cpp @@ -164,7 +164,8 @@ DlgLogInspector::DlgLogInspector(const QString &shv_path, QWidget *parent) : m_logModel = new LogModel(this); m_logSortFilterProxy = new shv::visu::logview::LogSortFilterProxyModel(this); - m_logSortFilterProxy->setShvPathColumn(LogModel::ColPath); + m_logSortFilterProxy->setChannelFilterPathColumn(LogModel::ColPath); + m_logSortFilterProxy->setFulltextFilterPathColumn(LogModel::ColPath); m_logSortFilterProxy->setValueColumn(LogModel::ColValue); m_logSortFilterProxy->setSourceModel(m_logModel); ui->tblData->setModel(m_logSortFilterProxy); diff --git a/libshvvisu/src/logview/logsortfilterproxymodel.cpp b/libshvvisu/src/logview/logsortfilterproxymodel.cpp index 519e086d..bd6fd146 100644 --- a/libshvvisu/src/logview/logsortfilterproxymodel.cpp +++ b/libshvvisu/src/logview/logsortfilterproxymodel.cpp @@ -17,9 +17,9 @@ void LogSortFilterProxyModel::setChannelFilter(const std::optional= 0) { - QModelIndex ix = sourceModel()->index(source_row, m_shvPathColumn, source_parent); + if (m_channelFilterPathColumn >= 0) { + QModelIndex ix = sourceModel()->index(source_row, m_channelFilterPathColumn, source_parent); is_row_accepted = (m_channelFilter) ? m_channelFilter.value().isPathPermitted(sourceModel()->data(ix).toString()) : true; - - if (is_row_accepted && !m_fulltextFilter.pattern().isEmpty()) { - bool is_fulltext_filter_matched = m_fulltextFilter.matches(sourceModel()->data(ix).toString()); - - if (m_valueColumn >= 0) { - ix = sourceModel()->index(source_row, m_valueColumn, source_parent); - is_fulltext_filter_matched = is_fulltext_filter_matched || m_fulltextFilter.matches(sourceModel()->data(ix).toString()); - } - is_row_accepted = is_row_accepted && is_fulltext_filter_matched; + } + if (is_row_accepted && !m_fulltextFilter.pattern().isEmpty()) { + bool path_matches = true; + bool value_matches = true; + if (m_fulltextFilterPathColumn >= 0) { + QModelIndex ix = sourceModel()->index(source_row, m_fulltextFilterPathColumn, source_parent); + path_matches = m_fulltextFilter.matches(sourceModel()->data(ix).toString()); } + if (m_valueColumn >= 0) { + QModelIndex ix = sourceModel()->index(source_row, m_valueColumn, source_parent); + value_matches = m_fulltextFilter.matches(sourceModel()->data(ix).toString()); + } + is_row_accepted = path_matches || value_matches; } - return is_row_accepted; }