Skip to content

Commit

Permalink
Qt: fix time shift
Browse files Browse the repository at this point in the history
Add a timeShifted signal to TimeShiftDialog and use it to update the
packet list and model. Add drawCurrentPacket to PacketList so that we
can do a more thorough job of redrawing the current packet and tree.

Bug: 11575
Change-Id: I960d8cdbf6872e3f71007cb4d2bbd5457f268257
Reviewed-on: https://code.wireshark.org/review/11068
Reviewed-by: Pascal Quantin <[email protected]>
Petri-Dish: Pascal Quantin <[email protected]>
Tested-by: Petri Dish Buildbot <[email protected]>
Reviewed-by: Gerald Combs <[email protected]>
  • Loading branch information
geraldcombs committed Oct 19, 2015
1 parent 6f9801a commit a0113a5
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 7 deletions.
1 change: 1 addition & 0 deletions ui/qt/main_window_slots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,7 @@ void MainWindow::on_actionEditTimeShift_triggered()
TimeShiftDialog ts_dialog(this, capture_file_.capFile());
connect(this, SIGNAL(setCaptureFile(capture_file*)),
&ts_dialog, SLOT(setCaptureFile(capture_file*)));
connect(&ts_dialog, SIGNAL(timeShifted()), packet_list_, SLOT(applyTimeShift()));
ts_dialog.exec();
}

Expand Down
23 changes: 17 additions & 6 deletions ui/qt/packet_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,18 +615,22 @@ void PacketList::initHeaderContextMenu()
}
}

void PacketList::drawCurrentPacket()
{
QModelIndex current_index = currentIndex();
setCurrentIndex(QModelIndex());
if (current_index.isValid()) {
setCurrentIndex(current_index);
}
}

// Redraw the packet list and detail. Called from many places.
// XXX We previously re-selected the packet here, but that seems to cause
// automatic scrolling problems.
void PacketList::redrawVisiblePackets() {
if (!cap_file_) return;

if (cap_file_->edt && cap_file_->edt->tree) {
proto_tree_->fillProtocolTree(cap_file_->edt->tree);
}

update();
header()->update();
drawCurrentPacket();
}

// prefs.col_list has changed.
Expand Down Expand Up @@ -1067,6 +1071,13 @@ void PacketList::unsetAllTimeReferences()
create_far_overlay_ = true;
}

void PacketList::applyTimeShift()
{
packet_list_model_->applyTimeShift();
redrawVisiblePackets();
// XXX emit packetDissectionChanged(); ?
}

void PacketList::showHeaderMenu(QPoint pos)
{
header_ctx_column_ = header()->logicalIndexAt(pos);
Expand Down
2 changes: 2 additions & 0 deletions ui/qt/packet_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ protected slots:
void setColumnVisibility();
int sizeHintForColumn(int column) const;
void initHeaderContextMenu();
void drawCurrentPacket();

signals:
void packetDissectionChanged();
Expand All @@ -147,6 +148,7 @@ public slots:
void ignoreAllDisplayedFrames(bool set);
void setTimeReference();
void unsetAllTimeReferences();
void applyTimeShift();
void redrawVisiblePackets();
void columnsChanged();
void fieldsChanged(capture_file *cf);
Expand Down
6 changes: 6 additions & 0 deletions ui/qt/packet_list_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ void PacketListModel::unsetAllFrameRefTime()
dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}

void PacketListModel::applyTimeShift()
{
resetColumns();
dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}

void PacketListModel::setMaximiumRowHeight(int height)
{
max_row_height_ = height;
Expand Down
1 change: 1 addition & 0 deletions ui/qt/packet_list_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class PacketListModel : public QAbstractItemModel
void setDisplayedFrameIgnore(gboolean set);
void toggleFrameRefTime(const QModelIndex &rt_index);
void unsetAllFrameRefTime();
void applyTimeShift();

void setMaximiumRowHeight(int height);

Expand Down
8 changes: 7 additions & 1 deletion ui/qt/time_shift_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,13 @@ void TimeShiftDialog::applyTimeShift()
} else if (ts_ui_->unshiftAllButton->isChecked()) {
err_str = time_shift_undo(cap_file_);
}
if (err_str) syntax_err_ = err_str;

if (err_str) {
syntax_err_ = err_str;
} else {
emit timeShifted();
}

enableWidgets();
}

Expand Down
3 changes: 3 additions & 0 deletions ui/qt/time_shift_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class TimeShiftDialog : public QDialog
public slots:
void setCaptureFile(capture_file *cf) { cap_file_ = cf; }

signals:
void timeShifted();

private:
Ui::TimeShiftDialog *ts_ui_;
capture_file *cap_file_;
Expand Down

0 comments on commit a0113a5

Please sign in to comment.