diff options
author | Jirka Novak <j.novak@netsystem.cz> | 2021-02-09 11:39:35 +0100 |
---|---|---|
committer | AndersBroman <a.broman58@gmail.com> | 2021-02-09 20:38:22 +0000 |
commit | 698dab4bfe5201e723c325b6d04c1fb6b825b46e (patch) | |
tree | fc8907bd432419b2dc77afdeb3b27badfc97da20 /ui/qt/rtp_stream_dialog.cpp | |
parent | 99c712ff5a2f4d2d52f90d6f3c711ab6c7990a35 (diff) |
RTP Stream Dialog: Selected rows keep selected during recap
When recap is initated, list in RTP Stream dialog is cleared and new list
is read from capture so previously selected rows are deselected.
Patch solves it.
Diffstat (limited to 'ui/qt/rtp_stream_dialog.cpp')
-rw-r--r-- | ui/qt/rtp_stream_dialog.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/ui/qt/rtp_stream_dialog.cpp b/ui/qt/rtp_stream_dialog.cpp index 88b4e2ee96..2bb8815de4 100644 --- a/ui/qt/rtp_stream_dialog.cpp +++ b/ui/qt/rtp_stream_dialog.cpp @@ -315,6 +315,7 @@ RtpStreamDialog::RtpStreamDialog(QWidget &parent, CaptureFile &cf) : RtpStreamDialog::~RtpStreamDialog() { + freeLastSelected(); delete ui; remove_tap_listener_rtpstream(&tapinfo_); } @@ -398,6 +399,19 @@ void RtpStreamDialog::tapReset(rtpstream_tapinfo_t *tapinfo) { RtpStreamDialog *rtp_stream_dialog = dynamic_cast<RtpStreamDialog *>((RtpStreamDialog *)tapinfo->tap_data); if (rtp_stream_dialog) { + rtp_stream_dialog->freeLastSelected(); + /* Copy currently selected rtpstream_ids */ + QTreeWidgetItemIterator iter(rtp_stream_dialog->ui->streamTreeWidget); + while (*iter) { + RtpStreamTreeWidgetItem *rsti = static_cast<RtpStreamTreeWidgetItem*>(*iter); + rtpstream_info_t *stream_info = rsti->streamInfo(); + if ((*iter)->isSelected()) { + rtpstream_id_t *i = (rtpstream_id_t *)g_malloc0(sizeof(rtpstream_id_t)); + rtpstream_id_copy(&stream_info->id, i); + rtp_stream_dialog->last_selected_.append(*i); + } + ++iter; + } /* invalidate items which refer to old strinfo_list items. */ rtp_stream_dialog->ui->streamTreeWidget->clear(); } @@ -422,6 +436,12 @@ void RtpStreamDialog::tapMarkPacket(rtpstream_tapinfo_t *tapinfo, frame_data *fd } } +/* Operator == for rtpstream_id_t */ +bool operator==(rtpstream_id_t const& a, rtpstream_id_t const& b) +{ + return rtpstream_id_equal(&a, &b, RTPSTREAM_ID_EQUAL_SSRC); +} + void RtpStreamDialog::updateStreams() { // string_list is reverse ordered, so we must add @@ -434,9 +454,14 @@ void RtpStreamDialog::updateStreams() // Add any missing items while (cur_stream && cur_stream->data && to_insert_count) { rtpstream_info_t *stream_info = gxx_list_data(rtpstream_info_t*, cur_stream); - new RtpStreamTreeWidgetItem(ui->streamTreeWidget, stream_info); + RtpStreamTreeWidgetItem *rsti = new RtpStreamTreeWidgetItem(ui->streamTreeWidget, stream_info); cur_stream = gxx_list_next(cur_stream); to_insert_count--; + + // Check if item was selected last time. If so, select it + if (-1 != last_selected_.indexOf(stream_info->id)) { + rsti->setSelected(true); + } } // Recalculate values @@ -547,6 +572,17 @@ QList<QVariant> RtpStreamDialog::streamRowData(int row) const return row_data; } +void RtpStreamDialog::freeLastSelected() +{ + /* Free old IDs */ + for(int i=0; i<last_selected_.length(); i++) { + rtpstream_id_t id = last_selected_.at(i); + rtpstream_id_free(&id); + } + /* Clear list and reuse it */ + last_selected_.clear(); +} + void RtpStreamDialog::captureFileClosing() { remove_tap_listener_rtpstream(&tapinfo_); |