diff options
author | Ramin Moussavi <lordrasmus@gmail.com> | 2021-09-05 07:47:52 +0000 |
---|---|---|
committer | AndersBroman <a.broman58@gmail.com> | 2021-09-05 07:47:52 +0000 |
commit | 03a07e4f1b9c774c3aee2d9bdd67fe9381902c19 (patch) | |
tree | bb8c36392a9dac6113663a016402b927d3fd2a01 /ui/qt | |
parent | 86d5606be3d77d689f6b47e0c93165a1123cd58b (diff) |
fix two display issues with remote interfaces window
Diffstat (limited to 'ui/qt')
-rw-r--r-- | ui/qt/manage_interfaces_dialog.cpp | 50 | ||||
-rw-r--r-- | ui/qt/manage_interfaces_dialog.h | 2 |
2 files changed, 48 insertions, 4 deletions
diff --git a/ui/qt/manage_interfaces_dialog.cpp b/ui/qt/manage_interfaces_dialog.cpp index 9dcc486c0d..fb7d1e477d 100644 --- a/ui/qt/manage_interfaces_dialog.cpp +++ b/ui/qt/manage_interfaces_dialog.cpp @@ -559,6 +559,44 @@ void ManageInterfacesDialog::on_addRemote_clicked() dlg->show(); } +int ManageInterfacesDialog::remoteInterfacesExists(char* device_name){ + int exists = 0; + QTreeWidgetItemIterator it(ui->remoteList); + + while (*it) { + QTreeWidgetItem * item = *it; + + if ( 0 == strcmp( device_name , item->text(col_r_host_dev_).toStdString().c_str() ) ){ + exists = 1; + break; + } + it++; + + } + + return exists; +} + +QTreeWidgetItem* ManageInterfacesDialog::getRemoteHostItem( char* name ){ + QTreeWidgetItemIterator it(ui->remoteList); + + while (*it) { + QTreeWidgetItem * item = *it; + + if ( item->text(col_r_host_dev_) == QString( name ) ){ + return item; + } + + it++; + } + + QTreeWidgetItem* item = new QTreeWidgetItem(ui->remoteList); + item->setText(col_r_host_dev_, QString(name)); + item->setExpanded(true); + + return item; +} + void ManageInterfacesDialog::showRemoteInterfaces() { guint i; @@ -570,11 +608,15 @@ void ManageInterfacesDialog::showRemoteInterfaces() QTreeWidgetItem *child; device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i); if (!device->local) { - if (!item || item->text(col_r_host_dev_).compare(device->remote_opts.remote_host_opts.remote_host) != 0) { - item = new QTreeWidgetItem(ui->remoteList); - item->setText(col_r_host_dev_, device->remote_opts.remote_host_opts.remote_host); - item->setExpanded(true); + + // check if the QTreeWidgetItem for that interface already exists + if ( 1 == remoteInterfacesExists( device->name )){ + continue; } + + // get or create the QTreeWidgetItem for the host + item = getRemoteHostItem( device->remote_opts.remote_host_opts.remote_host ); + child = new QTreeWidgetItem(item); child->setCheckState(col_r_show_, device->hidden ? Qt::Unchecked : Qt::Checked); child->setText(col_r_host_dev_, QString(device->name)); diff --git a/ui/qt/manage_interfaces_dialog.h b/ui/qt/manage_interfaces_dialog.h index cfe2ef5c4b..d7a2d4cf73 100644 --- a/ui/qt/manage_interfaces_dialog.h +++ b/ui/qt/manage_interfaces_dialog.h @@ -74,6 +74,8 @@ private slots: void remoteAccepted(); void on_remoteList_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous); void on_remoteList_itemClicked(QTreeWidgetItem *item, int column); + int remoteInterfacesExists(char* device_name); + QTreeWidgetItem* getRemoteHostItem( char* name ); void addRemoteInterfaces(GList *rlist, remote_options *roptions); void updateRemoteInterfaceList(GList *rlist, remote_options *roptions); void setRemoteSettings(interface_t *iface); |