Fix PacketList::goToPacket work correctly. Minor screen graph

improvements.

svn path=/trunk/; revision=51808
This commit is contained in:
Gerald Combs 2013-09-07 00:33:41 +00:00
parent ac93afc00b
commit f9a9753d01
4 changed files with 18 additions and 6 deletions

View File

@ -717,8 +717,9 @@ void PacketList::goLastPacket(void) {
// XXX We can jump to the wrong packet if a display filter is applied
void PacketList::goToPacket(int packet) {
if (packet > 0 && packet <= packet_list_model_->rowCount()) {
setCurrentIndex(packet_list_model_->index(packet - 1, 0));
int row = packet_list_model_->packetNumberToRow(packet);
if (row > 0) {
setCurrentIndex(packet_list_model_->index(row, 0));
}
}

View File

@ -72,6 +72,11 @@ QModelIndex PacketListModel::parent(const QModelIndex &index) const
return QModelIndex();
}
int PacketListModel::packetNumberToRow(int packet_num) const
{
return number_to_row_.value(packet_num, -1);
}
guint PacketListModel::recreateVisibleRows()
{
int pos = visible_rows_.count() + 1;
@ -79,11 +84,13 @@ guint PacketListModel::recreateVisibleRows()
beginResetModel();
visible_rows_.clear();
number_to_row_.clear();
endResetModel();
beginInsertRows(QModelIndex(), pos, pos);
foreach (record, physical_rows_) {
if (record->getFdata()->flags.passed_dfilter || record->getFdata()->flags.ref_time) {
visible_rows_ << record;
number_to_row_[record->getFdata()->num] = visible_rows_.count() - 1;
}
}
endInsertRows();
@ -98,6 +105,7 @@ void PacketListModel::clear() {
beginResetModel();
physical_rows_.clear();
visible_rows_.clear();
number_to_row_.clear();
endResetModel();
}
@ -316,6 +324,7 @@ gint PacketListModel::appendPacket(frame_data *fdata)
if (fdata->flags.passed_dfilter || fdata->flags.ref_time) {
beginInsertRows(QModelIndex(), pos, pos);
visible_rows_ << record;
number_to_row_[fdata->num] = visible_rows_.count() - 1;
endInsertRows();
} else {
pos = -1;

View File

@ -49,6 +49,7 @@ public:
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int packetNumberToRow(int packet_num) const;
guint recreateVisibleRows();
void setColorEnabled(bool enable_color);
void clear();
@ -73,6 +74,7 @@ private:
QList<QString> col_names_;
QVector<PacketListRecord *> visible_rows_;
QVector<PacketListRecord *> physical_rows_;
QMap<int, int> number_to_row_;
QFont pl_font_;
int header_height_;

View File

@ -326,7 +326,7 @@ void TCPStreamDialog::initializeThroughput()
{
QString dlg_title = QString(tr("Throughput")) + streamDescription();
#ifdef MA_1_SECOND
dlg_title.append(tr(" (1 s MA)"));
dlg_title.append(tr(" (1s MA)"));
#else
dlg_title.append(QString(tr(" (%1 segment MA)")).arg(moving_avg_period_));
#endif
@ -426,7 +426,6 @@ void TCPStreamDialog::toggleTracerStyle(bool force_default)
tstyle = QCPItemTracer::tsCircle;
tr_color.setAlphaF(1.0);
tr_pen.setWidthF(1.5);
tr_pen.color().setAlphaF(1.0);
} else {
tr_color.setAlphaF(0.5);
tr_pen.setWidthF(1.0);
@ -453,11 +452,11 @@ void TCPStreamDialog::graphClicked(QMouseEvent *event)
// using a QTimer instead.
void TCPStreamDialog::mouseMoved(QMouseEvent *event)
{
double ts = tracer_->position->key();
struct segment *packet_seg = NULL;
packet_num_ = 0;
if (event && tracer_->graph() && tracer_->position->axisRect()->rect().contains(event->pos())) {
double ts = tracer_->position->key();
packet_seg = segment_map_.value(ts, NULL);
}
@ -470,9 +469,10 @@ void TCPStreamDialog::mouseMoved(QMouseEvent *event)
tracer_->setVisible(true);
packet_num_ = packet_seg->num;
QString hint = QString(tr("<small><i>%1 %2 (len %3 seq %4 ack %5 win %6)</i></small>"))
QString hint = QString(tr("<small><i>%1 %2 (%3s len %4 seq %5 ack %6 win %7)</i></small>"))
.arg(cap_file_ ? tr("Click to select packet") : tr("Packet"))
.arg(packet_num_)
.arg(QString::number(ts, 'g', 4))
.arg(packet_seg->th_seglen)
.arg(packet_seg->th_seq)
.arg(packet_seg->th_ack)