Skip to content

Commit 37a8496

Browse files
committed
Implement filter logic for topic filtering
1 parent d521d3c commit 37a8496

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

src/publisher_select_dialog.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "publisher_select_dialog.h"
2+
#include <QStringList>
3+
4+
void PublisherSelectDialog::on_lineEditFilter_textChanged(const QString &search_string)
5+
{
6+
QStringList spaced_items = search_string.split(' ');
7+
8+
for (const auto &pair : _topic_widgets)
9+
{
10+
const std::string &topic_name = pair.first;
11+
QLabel *label = pair.second.first;
12+
QCheckBox *checkbox = pair.second.second;
13+
14+
QString name = QString::fromStdString(topic_name);
15+
bool toHide = false;
16+
17+
for (const auto &item : spaced_items)
18+
{
19+
if (!name.contains(item, Qt::CaseInsensitive))
20+
{
21+
toHide = true;
22+
break;
23+
}
24+
}
25+
26+
label->setVisible(!toHide);
27+
checkbox->setVisible(!toHide);
28+
}
29+
}

0 commit comments

Comments
 (0)