diff options
-rw-r--r-- | ui/qt/capture_interfaces_dialog.cpp | 18 | ||||
-rw-r--r-- | ui/qt/interface_tree_model.cpp | 13 | ||||
-rw-r--r-- | ui/qt/interface_tree_model.h | 2 | ||||
-rw-r--r-- | ui/qt/sparkline_delegate.cpp | 12 |
4 files changed, 18 insertions, 27 deletions
diff --git a/ui/qt/capture_interfaces_dialog.cpp b/ui/qt/capture_interfaces_dialog.cpp index d5a15777b8..b4fb9e1713 100644 --- a/ui/qt/capture_interfaces_dialog.cpp +++ b/ui/qt/capture_interfaces_dialog.cpp @@ -648,7 +648,7 @@ void CaptureInterfacesDialog::updateInterfaces() InterfaceTreeWidgetItem *ti = new InterfaceTreeWidgetItem(ui->interfaceTree); ti->setFlags(ti->flags() | Qt::ItemIsEditable); ti->setData(col_interface_, Qt::UserRole, QString(device->name)); - ti->setData(col_traffic_, Qt::UserRole, qVariantFromValue(&ti->points)); + ti->setData(col_traffic_, Qt::UserRole, qVariantFromValue(ti->points)); ti->setText(col_interface_, device->display_name); if (device->no_addresses > 0) { @@ -766,8 +766,8 @@ void CaptureInterfacesDialog::updateStatistics(void) if (device_name.compare(device->display_name) || device->hidden || device->type == IF_PIPE) { continue; } - QList<int> *points = ti->data(col_traffic_, Qt::UserRole).value<QList<int> *>(); - points->append(device->packet_diff); + QList<int> points = ti->data(col_traffic_, Qt::UserRole).value<QList<int> >(); + points.append(device->packet_diff); ti->setData(col_traffic_, Qt::UserRole, qVariantFromValue(points)); } } @@ -1101,14 +1101,14 @@ interface_t *CaptureInterfacesDialog::getDeviceByName(const QString device_name) // bool InterfaceTreeWidgetItem::operator< (const QTreeWidgetItem &other) const { if (treeWidget()->sortColumn() == col_traffic_) { - QList<int> *points = data(col_traffic_, Qt::UserRole).value<QList<int> *>(); - QList<int> *other_points = other.data(col_traffic_, Qt::UserRole).value<QList<int> *>(); + QList<int> points = data(col_traffic_, Qt::UserRole).value<QList<int> >(); + QList<int> other_points = other.data(col_traffic_, Qt::UserRole).value<QList<int> >(); double avg = 0, other_avg = 0; - foreach (int point, *points) { - avg += (double) point / points->length(); + foreach (int point, points) { + avg += (double) point / points.length(); } - foreach (int point, *other_points) { - other_avg += (double) point / other_points->length(); + foreach (int point, other_points) { + other_avg += (double) point / other_points.length(); } return avg < other_avg; } diff --git a/ui/qt/interface_tree_model.cpp b/ui/qt/interface_tree_model.cpp index d55ff7ffe4..78d02b002a 100644 --- a/ui/qt/interface_tree_model.cpp +++ b/ui/qt/interface_tree_model.cpp @@ -338,12 +338,6 @@ void InterfaceTreeModel::interfaceListChanged() { emit beginResetModel(); - QMap<QString, PointList *>::const_iterator it = points.constBegin(); - while(it != points.constEnd()) - { - it.value()->clear(); - ++it; - } points.clear(); emit endResetModel(); @@ -435,9 +429,6 @@ void InterfaceTreeModel::updateStatistic(unsigned int idx) struct pcap_stat stats; - if ( !points.contains(device.name) ) - points.insert(device.name, new PointList()); - diff = 0; if ( capture_stats(stat_cache_, device.name, &stats) ) { @@ -452,7 +443,7 @@ void InterfaceTreeModel::updateStatistic(unsigned int idx) g_array_insert_val(global_capture_opts.all_ifaces, idx, device); } - points[device.name]->append(diff); + points[device.name].append(diff); emit dataChanged(index(idx, IFTREE_COL_STATS), index(idx, IFTREE_COL_STATS)); #else Q_UNUSED(idx); @@ -467,7 +458,7 @@ void InterfaceTreeModel::getPoints(int idx, PointList *pts) interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, idx); if ( points.contains(device.name) ) - pts->append(*points[device.name]); + pts->append(points[device.name]); #else Q_UNUSED(idx); Q_UNUSED(pts); diff --git a/ui/qt/interface_tree_model.h b/ui/qt/interface_tree_model.h index 33daff9eed..a441b39e33 100644 --- a/ui/qt/interface_tree_model.h +++ b/ui/qt/interface_tree_model.h @@ -102,7 +102,7 @@ protected slots: private: QVariant toolTipForInterface(int idx) const; - QMap<QString, PointList *> points; + QMap<QString, PointList> points; #ifdef HAVE_LIBPCAP if_stat_cache_t *stat_cache_; diff --git a/ui/qt/sparkline_delegate.cpp b/ui/qt/sparkline_delegate.cpp index b4e565cc0d..b9935d94e8 100644 --- a/ui/qt/sparkline_delegate.cpp +++ b/ui/qt/sparkline_delegate.cpp @@ -29,7 +29,7 @@ void SparkLineDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - QList<int> *points = qvariant_cast<QList<int> *>(index.data(Qt::UserRole)); + QList<int> points = qvariant_cast<QList<int> >(index.data(Qt::UserRole)); int max = 1; int em_w = option.fontMetrics.height(); int content_w = option.rect.width() - (em_w / 4); @@ -42,19 +42,19 @@ void SparkLineDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt QStyledItemDelegate::paint(painter, option, index); - if (!points || points->isEmpty() || steps < 1.0 || content_h <= 0) { + if (points.isEmpty() || steps < 1.0 || content_h <= 0) { return; } - while((qreal) points->length() > steps) { - points->removeFirst(); + while((qreal) points.length() > steps) { + points.removeFirst(); } - foreach (val, *points) { + foreach (val, points) { if (val > max) max = val; } - foreach (val, *points) { + foreach (val, points) { fpoints.append(QPointF(idx, (qreal) content_h - (val * content_h / max))); idx = idx + step_w; } |