summaryrefslogtreecommitdiffstats
path: root/ui/qt/sequence_dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ui/qt/sequence_dialog.cpp50
1 files changed, 33 insertions, 17 deletions
diff --git a/ui/qt/sequence_dialog.cpp b/ui/qt/sequence_dialog.cpp
index 2f5b5ede..e5fb7b87 100644
--- a/ui/qt/sequence_dialog.cpp
+++ b/ui/qt/sequence_dialog.cpp
@@ -66,14 +66,14 @@ typedef struct {
SequenceInfo *info;
} sequence_items_t;
-SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, SequenceInfo *info) :
+SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, SequenceInfo *info, bool voipFeatures) :
WiresharkDialog(parent, cf),
ui(new Ui::SequenceDialog),
info_(info),
num_items_(0),
packet_num_(0),
sequence_w_(1),
- voipFeaturesEnabled(false)
+ voipFeaturesEnabled(voipFeatures)
{
QAction *action;
@@ -189,6 +189,11 @@ SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, SequenceInfo *i
close_bt->setDefault(true);
}
+ enableVoIPFeatures();
+
+ // Enable or disable VoIP features before adding the ProgressFrame,
+ // because the layout position depends on whether player_button_ is
+ // visible.
ProgressFrame::addToButtonBox(ui->buttonBox, &parent);
loadGeometry(parent.width(), parent.height() * 4 / 5);
@@ -200,10 +205,7 @@ SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, SequenceInfo *i
connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(diagramClicked(QMouseEvent*)));
connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*)));
connect(sp, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheeled(QWheelEvent*)));
-
- // Button must be enabled by VoIP dialogs
- player_button_->setVisible(false);
- player_button_->setEnabled(false);
+ connect(sp, &QCustomPlot::afterLayout, this, &SequenceDialog::layoutAxisLabels);
}
SequenceDialog::~SequenceDialog()
@@ -214,10 +216,10 @@ SequenceDialog::~SequenceDialog()
void SequenceDialog::enableVoIPFeatures()
{
- voipFeaturesEnabled = true;
- player_button_->setVisible(true);
- ui->actionSelectRtpStreams->setVisible(true);
- ui->actionDeselectRtpStreams->setVisible(true);
+ player_button_->setVisible(voipFeaturesEnabled);
+ ui->actionSelectRtpStreams->setVisible(voipFeaturesEnabled);
+ ui->actionDeselectRtpStreams->setVisible(voipFeaturesEnabled);
+ // Buttons and actions are enabled when valid call selected
}
void SequenceDialog::updateWidgets()
@@ -535,12 +537,20 @@ void SequenceDialog::panAxes(int x_pixels, int y_pixels)
double v_pan = 0.0;
h_pan = sp->xAxis2->range().size() * x_pixels / sp->xAxis2->axisRect()->width();
+ // The nodes are placed on integer x values from 0 to num_nodes - 1.
+ // We allow 0.5 of margin around a node (also reflected in the
+ // horizontalScrollBar range.)
if (h_pan < 0) {
h_pan = qMax(h_pan, min_left_ - sp->xAxis2->range().lower);
} else {
- h_pan = qMin(h_pan, info_->sainfo()->num_nodes - sp->xAxis2->range().upper);
+ h_pan = qMin(h_pan, info_->sainfo()->num_nodes - 0.5 - sp->xAxis2->range().upper);
}
+ if (sp->yAxis->rangeReversed()) {
+ // For reversed axes, lower still references the mathemathetically
+ // smaller number than upper, so reverse the direction.
+ y_pixels = -y_pixels;
+ }
v_pan = sp->yAxis->range().size() * y_pixels / sp->yAxis->axisRect()->height();
if (v_pan < 0) {
v_pan = qMax(v_pan, min_top_ - sp->yAxis->range().lower);
@@ -548,7 +558,7 @@ void SequenceDialog::panAxes(int x_pixels, int y_pixels)
v_pan = qMin(v_pan, num_items_ - sp->yAxis->range().upper);
}
- if (h_pan && !(sp->xAxis2->range().contains(min_left_) && sp->xAxis2->range().contains(info_->sainfo()->num_nodes))) {
+ if (h_pan && !(sp->xAxis2->range().contains(min_left_) && sp->xAxis2->range().contains(info_->sainfo()->num_nodes - 0.5))) {
sp->xAxis2->moveRange(h_pan);
sp->replot();
}
@@ -586,13 +596,21 @@ void SequenceDialog::resetAxes(bool keep_lower)
ui->verticalScrollBar->setRange((rmin - 1.0) * 100, (num_items_ - 0.5 - rmin) * 100);
yAxisChanged(sp->yAxis->range());
+ sp->replot(QCustomPlot::rpQueuedReplot);
+}
+
+void SequenceDialog::layoutAxisLabels()
+{
// It would be exceedingly handy if we could do one or both of the
// following:
// - Position an axis label above its axis inline with the tick labels.
// - Anchor a QCPItemText to one of the corners of a QCPAxis.
- // Neither of those appear to be possible, so we first call replot in
- // order to lay out our X axes, place our labels, the call replot again.
- sp->replot(QCustomPlot::rpQueuedReplot);
+ // Neither of those appear to be possible, so we place our labels using
+ // absolute positioning immediately after the layout size and positions
+ // are set, and right before the replot (or print) draw step occurs,
+ // using the new QCustomPlot 2.1.0 QCustomPlot::afterLayout signal.
+
+ QCustomPlot *sp = ui->sequencePlot;
QRect axis_rect = sp->axisRect()->rect();
@@ -606,8 +624,6 @@ void SequenceDialog::resetAxes(bool keep_lower)
+ sp->yAxis2->tickLabelPadding()
+ sp->yAxis2->offset(),
axis_rect.top() / 2);
-
- sp->replot(QCustomPlot::rpRefreshHint);
}
void SequenceDialog::resetView()