Skip to content

Commit 2fe2af5

Browse files
committed
Update filter to work with table rows
1 parent b40db76 commit 2fe2af5

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

src/publisher_select_dialog.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
#include "publisher_select_dialog.h"
22
#include <QStringList>
3+
#include <QTableWidgetItem>
4+
#include <QAbstractItemView>
35

46
void PublisherSelectDialog::on_lineEditFilter_textChanged(const QString &search_string)
57
{
68
QStringList spaced_items = search_string.split(' ');
79

8-
for (const auto &pair : _topic_widgets)
10+
for (int row = 0; row < _ui->listTopics->rowCount(); row++)
911
{
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);
12+
auto item = _ui->listTopics->item(row, 0);
13+
QString name = item->text();
1514
bool toHide = false;
1615

1716
for (const auto &item : spaced_items)
@@ -22,8 +21,12 @@ void PublisherSelectDialog::on_lineEditFilter_textChanged(const QString &search_
2221
break;
2322
}
2423
}
25-
26-
label->setVisible(!toHide);
27-
checkbox->setVisible(!toHide);
24+
_ui->listTopics->setRowHidden(row, toHide);
2825
}
2926
}
27+
28+
void PublisherSelectDialog::on_listTopics_itemSelectionChanged()
29+
{
30+
QModelIndexList indexes = _ui->listTopics->selectionModel()->selectedIndexes();
31+
_ui->buttonBox->setEnabled(indexes.size() > 0);
32+
}

0 commit comments

Comments
 (0)