forked from osmocom/wireshark
Qt: Properly hide the choosen model from external views
This moves the append function to the model, where it makes more sense. Change-Id: Iea9ccaf0672e8ad05454b4c35c303ca7dc2e6373 Reviewed-on: https://code.wireshark.org/review/33843 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
parent
62ca0a609b
commit
2fd549551c
|
@ -43,8 +43,28 @@
|
|||
#include <wsutil/time_util.h>
|
||||
#endif
|
||||
|
||||
static PacketListModel * glbl_plist_model = Q_NULLPTR;
|
||||
static const int reserved_packets_ = 100000;
|
||||
|
||||
guint
|
||||
packet_list_append(column_info *, frame_data *fdata)
|
||||
{
|
||||
if (!glbl_plist_model)
|
||||
return 0;
|
||||
|
||||
/* fdata should be filled with the stuff we need
|
||||
* strings are built at display time.
|
||||
*/
|
||||
return glbl_plist_model->appendPacket(fdata);
|
||||
}
|
||||
|
||||
void
|
||||
packet_list_recreate_visible_rows(void)
|
||||
{
|
||||
if ( glbl_plist_model )
|
||||
glbl_plist_model->recreateVisibleRows();
|
||||
}
|
||||
|
||||
PacketListModel::PacketListModel(QObject *parent, capture_file *cf) :
|
||||
QAbstractItemModel(parent),
|
||||
number_to_row_(QVector<int>()),
|
||||
|
@ -52,6 +72,8 @@ PacketListModel::PacketListModel(QObject *parent, capture_file *cf) :
|
|||
max_line_count_(1),
|
||||
idle_dissection_row_(0)
|
||||
{
|
||||
Q_ASSERT(glbl_plist_model == Q_NULLPTR);
|
||||
glbl_plist_model = this;
|
||||
setCaptureFile(cf);
|
||||
|
||||
physical_rows_.reserve(reserved_packets_);
|
||||
|
|
|
@ -90,20 +90,6 @@ const int max_comments_to_fetch_ = 20000000; // Arbitrary
|
|||
const int tail_update_interval_ = 100; // Milliseconds.
|
||||
const int overlay_update_interval_ = 100; // 250; // Milliseconds.
|
||||
|
||||
guint
|
||||
packet_list_append(column_info *, frame_data *fdata)
|
||||
{
|
||||
if (!gbl_cur_packet_list)
|
||||
return 0;
|
||||
|
||||
/* fdata should be filled with the stuff we need
|
||||
* strings are built at display time.
|
||||
*/
|
||||
guint visible_pos;
|
||||
|
||||
visible_pos = gbl_cur_packet_list->packetListModel()->appendPacket(fdata);
|
||||
return visible_pos;
|
||||
}
|
||||
|
||||
// Copied from ui/gtk/packet_list.c
|
||||
void packet_list_resize_column(gint col)
|
||||
|
@ -128,13 +114,18 @@ packet_list_select_first_row(void)
|
|||
gboolean
|
||||
packet_list_select_row_from_data(frame_data *fdata_needle)
|
||||
{
|
||||
if ( !gbl_cur_packet_list )
|
||||
if ( ! gbl_cur_packet_list || ! gbl_cur_packet_list->model())
|
||||
return FALSE;
|
||||
|
||||
gbl_cur_packet_list->packetListModel()->flushVisibleRows();
|
||||
int row = gbl_cur_packet_list->packetListModel()->visibleIndexOf(fdata_needle);
|
||||
PacketListModel * model = qobject_cast<PacketListModel *>(gbl_cur_packet_list->model());
|
||||
|
||||
if ( ! model )
|
||||
return FALSE;
|
||||
|
||||
model->flushVisibleRows();
|
||||
int row = model->visibleIndexOf(fdata_needle);
|
||||
if (row >= 0) {
|
||||
gbl_cur_packet_list->setCurrentIndex(gbl_cur_packet_list->packetListModel()->index(row, 0));
|
||||
gbl_cur_packet_list->setCurrentIndex(model->index(row, 0));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -175,19 +166,6 @@ packet_list_thaw(void)
|
|||
packets_bar_update();
|
||||
}
|
||||
|
||||
void
|
||||
packet_list_recreate_visible_rows(void)
|
||||
{
|
||||
if ( !gbl_cur_packet_list )
|
||||
return;
|
||||
|
||||
PacketListModel * model = qobject_cast<PacketListModel *>(gbl_cur_packet_list->model());
|
||||
|
||||
if (model) {
|
||||
model->recreateVisibleRows();
|
||||
}
|
||||
}
|
||||
|
||||
frame_data *
|
||||
packet_list_get_row_data(gint row)
|
||||
{
|
||||
|
@ -404,10 +382,6 @@ void PacketList::setProtoTree (ProtoTree *proto_tree) {
|
|||
&related_packet_delegate_, SLOT(addRelatedFrame(int,ft_framenum_type_t)));
|
||||
}
|
||||
|
||||
PacketListModel *PacketList::packetListModel() const {
|
||||
return packet_list_model_;
|
||||
}
|
||||
|
||||
void PacketList::selectionChanged (const QItemSelection & selected, const QItemSelection & deselected)
|
||||
{
|
||||
QTreeView::selectionChanged(selected, deselected);
|
||||
|
|
|
@ -33,7 +33,6 @@ class PacketList : public QTreeView
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit PacketList(QWidget *parent = 0);
|
||||
PacketListModel *packetListModel() const;
|
||||
QMenu *conversationMenu() { return &conv_menu_; }
|
||||
QMenu *colorizeMenu() { return &colorize_menu_; }
|
||||
void setProtoTree(ProtoTree *proto_tree);
|
||||
|
|
Loading…
Reference in New Issue