aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Knall <rknall@gmail.com>2017-11-12 11:29:13 +0100
committerRoland Knall <rknall@gmail.com>2017-11-12 17:18:44 +0000
commite13e2df9a1278903c66292a4f7b823c707b30cb3 (patch)
treea1831fd454f638fd1fcd13b6cea763a72deac0ab
parent447291d84a63d3e707fd00111ba465e5c230c849 (diff)
Qt: Rename packetSelection to frameSelected
In order to consolidate the interfaces between certain parts of the UI, the signal emitted after a frame change has occured, has to include the number of the frame. This led to two signals for frame change, and therefore packetSelection is to be removed. Change-Id: I24e0e0890291d2243935b0c48387beb66904bfa3 Reviewed-on: https://code.wireshark.org/review/24377 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
-rw-r--r--ui/qt/byte_view_tab.cpp76
-rw-r--r--ui/qt/byte_view_tab.h3
-rw-r--r--ui/qt/main_status_bar.cpp3
-rw-r--r--ui/qt/main_status_bar.h2
-rw-r--r--ui/qt/main_window.cpp16
-rw-r--r--ui/qt/main_window.h2
-rw-r--r--ui/qt/packet_dialog.cpp2
-rw-r--r--ui/qt/packet_list.cpp14
-rw-r--r--ui/qt/packet_list.h3
-rw-r--r--ui/qt/proto_tree.cpp2
-rw-r--r--ui/qt/utils/frame_information.cpp7
-rw-r--r--ui/qt/utils/frame_information.h1
-rw-r--r--ui/qt/widgets/byte_view_text.cpp1
-rw-r--r--ui/qt/wireless_timeline.cpp6
-rw-r--r--ui/qt/wireless_timeline.h2
15 files changed, 81 insertions, 59 deletions
diff --git a/ui/qt/byte_view_tab.cpp b/ui/qt/byte_view_tab.cpp
index d5018d0f98..699f6f33b3 100644
--- a/ui/qt/byte_view_tab.cpp
+++ b/ui/qt/byte_view_tab.cpp
@@ -62,34 +62,38 @@ void ByteViewTab::connectToMainWindow()
wsApp->mainWindow(), SIGNAL(fieldHighlight(FieldInformation *)));
/* Connect change of packet selection */
- connect(wsApp->mainWindow(), SIGNAL(packetSelectionChanged()), this, SLOT(packetSelectionChanged()));
+ connect(wsApp->mainWindow(), SIGNAL(frameSelected(int)), this, SLOT(selectedFrameChanged(int)));
connect(wsApp->mainWindow(), SIGNAL(setCaptureFile(capture_file*)), this, SLOT(setCaptureFile(capture_file*)));
connect(wsApp->mainWindow(), SIGNAL(fieldSelected(FieldInformation *)), this, SLOT(selectedFieldChanged(FieldInformation *)));
}
void ByteViewTab::addTab(const char *name, tvbuff_t *tvb) {
- if ( ! tvb || ! cap_file_ )
- return;
-
if (count() == 1) { // Remove empty placeholder.
ByteViewText *cur_text = qobject_cast<ByteViewText *>(currentWidget());
if (cur_text && cur_text->isEmpty()) delete currentWidget();
}
- packet_char_enc encoding = (packet_char_enc)cap_file_->current_frame->flags.encoding;
+ packet_char_enc encoding = PACKET_CHAR_ENC_CHAR_ASCII;
+ if ( cap_file_ && cap_file_->current_frame )
+ encoding = (packet_char_enc)cap_file_->current_frame->flags.encoding;
- QByteArray data((const char *) tvb_memdup(wmem_file_scope(), tvb, 0, -1), tvb_captured_length(tvb));
+ QByteArray data;
+ if ( tvb )
+ data = QByteArray((const char *) tvb_memdup(wmem_file_scope(), tvb, 0, -1), tvb_captured_length(tvb));
ByteViewText * byte_view_text = new ByteViewText(data, encoding, this);
byte_view_text->setAccessibleName(name);
byte_view_text->setMonospaceFont(wsApp->monospaceFont());
- byte_view_text->setProperty(tvb_data_property, VariantPointer<tvbuff_t>::asQVariant(tvb));
+ if ( tvb )
+ {
+ byte_view_text->setProperty(tvb_data_property, VariantPointer<tvbuff_t>::asQVariant(tvb));
- connect(wsApp, SIGNAL(zoomMonospaceFont(QFont)), byte_view_text, SLOT(setMonospaceFont(QFont)));
+ connect(wsApp, SIGNAL(zoomMonospaceFont(QFont)), byte_view_text, SLOT(setMonospaceFont(QFont)));
- connect(byte_view_text, SIGNAL(byteHovered(int)), this, SLOT(byteViewTextHovered(int)));
- connect(byte_view_text, SIGNAL(byteSelected(int)), this, SLOT(byteViewTextMarked(int)));
+ connect(byte_view_text, SIGNAL(byteHovered(int)), this, SLOT(byteViewTextHovered(int)));
+ connect(byte_view_text, SIGNAL(byteSelected(int)), this, SLOT(byteViewTextMarked(int)));
+ }
int idx = QTabWidget::addTab(byte_view_text, name);
byte_view_text->setProperty("tab_index", qVariantFromValue(idx));
@@ -97,27 +101,6 @@ void ByteViewTab::addTab(const char *name, tvbuff_t *tvb) {
QTabWidget::setTabToolTip(idx, name);
}
-void ByteViewTab::packetSelectionChanged()
-{
- if ( ! cap_file_ || ! cap_file_->edt )
- return;
-
- // Remove tabs (as these refer to stale tvbs) and free resources.
- clear();
- qDeleteAll(findChildren<ByteViewText *>());
-
- GSList *src_le;
- for (src_le = cap_file_->edt->pi.data_src; src_le != NULL; src_le = src_le->next) {
- struct data_source *source;
- char* source_name;
- source = (struct data_source *)src_le->data;
- source_name = get_data_source_name(source);
- addTab(source_name, get_data_source_tvb(source));
- wmem_free(NULL, source_name);
- }
- setCurrentIndex(0);
-}
-
void ByteViewTab::byteViewTextHovered(int idx)
{
if ( idx >= 0 && cap_file_ && cap_file_->edt )
@@ -179,7 +162,7 @@ ByteViewText * ByteViewTab::findByteViewTextForTvb(tvbuff_t * search_tvb, int *
{
found = true;
}
- else
+ else if ( stored )
{
if ( stored->length >= length && tvb_memeql(search_tvb, 0, stored->real_data, length ) == 0 )
{
@@ -222,10 +205,35 @@ void ByteViewTab::setTabsVisible() {
void ByteViewTab::selectedFrameChanged(int frameNum)
{
- Q_UNUSED(frameNum);
+ clear();
+ qDeleteAll(findChildren<ByteViewText *>());
+
+ if ( frameNum > 0 )
+ {
+ if ( ! cap_file_ || ! cap_file_->edt )
+ return;
+
+ /* This code relies on a dissection, which had happened somewhere else. It also does not
+ * really check, if the dissection happened for the correct frame. In the future we might
+ * rewrite this for directly calling the dissection engine here. */
+ GSList *src_le;
+ for (src_le = cap_file_->edt->pi.data_src; src_le != NULL; src_le = src_le->next) {
+ struct data_source *source;
+ char* source_name;
+ source = (struct data_source *)src_le->data;
+ source_name = get_data_source_name(source);
+ addTab(source_name, get_data_source_tvb(source));
+ wmem_free(NULL, source_name);
+ }
+ }
+ else
+ addTab("PlaceHolder", 0);
+
+ setCurrentIndex(0);
}
-void ByteViewTab::selectedFieldChanged(FieldInformation *selected) {
+void ByteViewTab::selectedFieldChanged(FieldInformation *selected)
+{
ByteViewText * byte_view_text = 0;
diff --git a/ui/qt/byte_view_tab.h b/ui/qt/byte_view_tab.h
index b1b8708211..19737dd383 100644
--- a/ui/qt/byte_view_tab.h
+++ b/ui/qt/byte_view_tab.h
@@ -48,9 +48,8 @@ public slots:
/* Set the capture file */
void setCaptureFile(capture_file *cf);
/* Creates the tabs and data, depends on an dissection which has already run */
- void packetSelectionChanged();
-
void selectedFrameChanged(int);
+ /* Selects or marks a field */
void selectedFieldChanged(FieldInformation *);
signals:
diff --git a/ui/qt/main_status_bar.cpp b/ui/qt/main_status_bar.cpp
index 2e3bad3377..b524ab856d 100644
--- a/ui/qt/main_status_bar.cpp
+++ b/ui/qt/main_status_bar.cpp
@@ -471,8 +471,9 @@ void MainStatusBar::popProgressStatus()
progress_frame_.hide();
}
-void MainStatusBar::packetSelectionChanged()
+void MainStatusBar::selectedFrameChanged(int frameNum)
{
+ Q_UNUSED(frameNum);
showCaptureStatistics();
}
diff --git a/ui/qt/main_status_bar.h b/ui/qt/main_status_bar.h
index 00d98db3e4..89272c8d50 100644
--- a/ui/qt/main_status_bar.h
+++ b/ui/qt/main_status_bar.h
@@ -98,7 +98,7 @@ public slots:
void pushProgressStatus(const QString &message, bool animate, bool terminate_is_stop = false, gboolean *stop_flag = NULL);
void updateProgressStatus(int value);
void popProgressStatus();
- void packetSelectionChanged();
+ void selectedFrameChanged(int);
void updateCaptureStatistics(capture_session * cap_session);
void updateCaptureFixedStatistics(capture_session * cap_session);
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 3ed70e3f35..72bfeb2ba5 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -497,8 +497,8 @@ MainWindow::MainWindow(QWidget *parent) :
main_ui_->wirelessTimelineWidget->setPacketList(packet_list_);
connect(packet_list_, SIGNAL(fieldSelected(FieldInformation *)),
this, SIGNAL(fieldSelected(FieldInformation *)));
- connect(packet_list_, SIGNAL(packetSelectionChanged()),
- this, SIGNAL(packetSelectionChanged()));
+ connect(packet_list_, SIGNAL(frameSelected(int)),
+ this, SIGNAL(frameSelected(int)));
connect(packet_list_->packetListModel(), SIGNAL(bgColorizationProgress(int,int)),
main_ui_->wirelessTimelineWidget, SLOT(bgColorizationProgress(int,int)));
@@ -663,10 +663,10 @@ MainWindow::MainWindow(QWidget *parent) :
packet_list_, SLOT(setCaptureFile(capture_file*)));
connect(this, SIGNAL(setCaptureFile(capture_file*)),
proto_tree_, SLOT(setCaptureFile(capture_file*)));
- connect(this, SIGNAL(packetSelectionChanged()),
- main_ui_->wirelessTimelineWidget, SLOT(packetSelectionChanged()));
- connect(this, SIGNAL(packetSelectionChanged()),
- main_ui_->statusBar, SLOT(packetSelectionChanged()));
+ connect(this, SIGNAL(frameSelected(int)),
+ main_ui_->wirelessTimelineWidget, SLOT(selectedFrameChanged(int)));
+ connect(this, SIGNAL(frameSelected(int)),
+ main_ui_->statusBar, SLOT(selectedFrameChanged(int)));
connect(wsApp, SIGNAL(zoomMonospaceFont(QFont)),
packet_list_, SLOT(setMonospaceFont(QFont)));
@@ -693,8 +693,8 @@ MainWindow::MainWindow(QWidget *parent) :
connect(main_ui_->actionViewCollapseAll, SIGNAL(triggered()),
proto_tree_, SLOT(collapseAll()));
- connect(packet_list_, SIGNAL(packetSelectionChanged()),
- this, SLOT(setMenusForSelectedPacket()));
+ connect(packet_list_, SIGNAL(frameSelected(int)),
+ this, SIGNAL(frameSelected(int)));
connect(packet_list_, SIGNAL(packetDissectionChanged()),
this, SLOT(redissectPackets()));
connect(packet_list_, SIGNAL(showColumnPreferences(PreferencesDialog::PreferencesPane)),
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index efae934015..14ad8225b5 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -271,7 +271,7 @@ signals:
void fieldSelected(FieldInformation *);
void fieldHighlight(FieldInformation *);
- void packetSelectionChanged();
+ void frameSelected(int);
public slots:
// in main_window_slots.cpp
diff --git a/ui/qt/packet_dialog.cpp b/ui/qt/packet_dialog.cpp
index afd5224228..ea17a20cd4 100644
--- a/ui/qt/packet_dialog.cpp
+++ b/ui/qt/packet_dialog.cpp
@@ -72,7 +72,7 @@ PacketDialog::PacketDialog(QWidget &parent, CaptureFile &cf, frame_data *fdata)
byte_view_tab_ = new ByteViewTab(ui->packetSplitter);
byte_view_tab_->setCaptureFile(cap_file_.capFile());
- byte_view_tab_->packetSelectionChanged();
+ byte_view_tab_->selectedFrameChanged(0);
ui->packetSplitter->setStretchFactor(1, 0);
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index 2c6a26d780..aa49d88275 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -484,10 +484,13 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS
if (!cap_file_) return;
+ int row = 0;
+
if (selected.isEmpty()) {
cf_unselect_packet(cap_file_);
} else {
- int row = selected.first().top();
+ /* Framenumbers should allways reflect real frame numbers (can't start at 0) */
+ row = selected.first().top() + 1;
cf_select_packet(cap_file_, row);
}
@@ -501,7 +504,7 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS
related_packet_delegate_.clear();
if (proto_tree_) proto_tree_->clear();
- emit packetSelectionChanged();
+ emit frameSelected(row);
if (!cap_file_->edt) {
viewport()->update();
@@ -537,7 +540,7 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS
cap_file_->edt->tvb);
}
- if (fi && proto_tree_) {
+ if (fi) {
emit fieldSelected(new FieldInformation(fi, this));
}
} else if (!cap_file_->search_in_progress && proto_tree_) {
@@ -588,7 +591,10 @@ void PacketList::contextMenuEvent(QContextMenuEvent *event)
ctx_column_ = columnAt(event->x());
// Set menu sensitivity for the current column and set action data.
- emit packetSelectionChanged();
+ if ( frameData )
+ emit frameSelected(frameData->frameNum());
+ else
+ emit frameSelected(0);
ctx_menu_.exec(event->globalPos());
ctx_column_ = -1;
diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h
index 5b69f9ec8e..93714844ce 100644
--- a/ui/qt/packet_list.h
+++ b/ui/qt/packet_list.h
@@ -150,14 +150,13 @@ private:
signals:
void packetDissectionChanged();
- void packetSelectionChanged();
void showColumnPreferences(PreferencesDialog::PreferencesPane start_pane);
void editColumn(int column);
void packetListScrolled(bool at_end);
void showProtocolPreferences(const QString module_name);
void editProtocolPreference(struct preference *pref, struct pref_module *module);
- void selectedFrameChanged(int);
+ void frameSelected(int frameNum);
void fieldSelected(FieldInformation *);
public slots:
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp
index a34b3896aa..401d948cf8 100644
--- a/ui/qt/proto_tree.cpp
+++ b/ui/qt/proto_tree.cpp
@@ -469,8 +469,6 @@ void ProtoTree::updateSelectionStatus(QTreeWidgetItem* item)
* also require special checks for -1 to be added.
*/
- } else {
- emit fieldSelected(NULL);
}
}
diff --git a/ui/qt/utils/frame_information.cpp b/ui/qt/utils/frame_information.cpp
index 0b4116d2bc..303076bdfe 100644
--- a/ui/qt/utils/frame_information.cpp
+++ b/ui/qt/utils/frame_information.cpp
@@ -89,6 +89,13 @@ frame_data * FrameInformation::frameData() const
return fi_;
}
+unsigned int FrameInformation::frameNum() const
+{
+ if ( ! fi_ )
+ return 0;
+ return fi_->num;
+}
+
QByteArray FrameInformation::printableData()
{
QByteArray data;
diff --git a/ui/qt/utils/frame_information.h b/ui/qt/utils/frame_information.h
index 79403ce8fc..01a2234150 100644
--- a/ui/qt/utils/frame_information.h
+++ b/ui/qt/utils/frame_information.h
@@ -49,6 +49,7 @@ public:
bool isValid();
frame_data * frameData() const;
+ unsigned int frameNum() const;
QByteArray printableData();
diff --git a/ui/qt/widgets/byte_view_text.cpp b/ui/qt/widgets/byte_view_text.cpp
index 95575140ed..93612e514b 100644
--- a/ui/qt/widgets/byte_view_text.cpp
+++ b/ui/qt/widgets/byte_view_text.cpp
@@ -165,6 +165,7 @@ void ByteViewText::markProtocol(int start, int end)
void ByteViewText::markField(int start, int end)
{
f_bound_ = QPair<guint, guint>(qMax(0, start), qMax(0, end));
+ scrollToByte(start);
f_bound_save_ = f_bound_;
viewport()->update();
}
diff --git a/ui/qt/wireless_timeline.cpp b/ui/qt/wireless_timeline.cpp
index 4a556a72ae..d440e84f83 100644
--- a/ui/qt/wireless_timeline.cpp
+++ b/ui/qt/wireless_timeline.cpp
@@ -199,8 +199,10 @@ void WirelessTimeline::clip_tsf()
}
-void WirelessTimeline::packetSelectionChanged()
+void WirelessTimeline::selectedFrameChanged(int frameNum)
{
+ Q_UNUSED(frameNum);
+
if (isHidden())
return;
@@ -302,7 +304,7 @@ void WirelessTimeline::captureFileReadFinished()
zoom_level = 0;
show();
- packetSelectionChanged();
+ selectedFrameChanged(0);
// TODO: show or ungrey the toolbar controls
update();
}
diff --git a/ui/qt/wireless_timeline.h b/ui/qt/wireless_timeline.h
index 0f549e370c..1eebe3145b 100644
--- a/ui/qt/wireless_timeline.h
+++ b/ui/qt/wireless_timeline.h
@@ -78,7 +78,7 @@ protected:
public slots:
void bgColorizationProgress(int first, int last);
- void packetSelectionChanged();
+ void selectedFrameChanged(int frameNum);
void appInitialized();
protected: