diff options
author | Gerald Combs <gerald@wireshark.org> | 2015-02-26 13:02:06 -0800 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-03-12 16:29:58 +0000 |
commit | 5ab84900881289546a0aa3beb577af5383898e2e (patch) | |
tree | 35718a51fe7e4131877cd19d02995d5f6a118547 /ui/qt/packet_list_model.h | |
parent | 410b40d37145ac217db41ea6bc403c36ab53195d (diff) |
Qt: Allow multiple lines in the packet list.
Remove the setUniformRowHeights(true) call in the PacketList
constructor. This means that the packet list now calculates its height
by querying the Qt::SizeHintRole for every item instead of simply
multiplying item_height * number_of_rows.
Implement SizeHintRole in PacketListModel::data so that size
calculations aren't unbearably slow. We don't have any row text until an
item is drawn (via DisplayRole), so items with multiple lines end up
being rendered twice. Note where we make assumptions on line heights.
Although we call gtk_tree_view_set_fixed_height_mode() in the GTK+ UI we
don't have this problem there. GTK+ is apparently less strict about
enforcing row heights.
Bug: 10924
Change-Id: I98e9f4f5f321c2e03f18498e0a7e7556f88792a1
Reviewed-on: https://code.wireshark.org/review/7430
Petri-Dish: Evan Huus <eapache@gmail.com>
Reviewed-by: Evan Huus <eapache@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/packet_list_model.h')
-rw-r--r-- | ui/qt/packet_list_model.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/ui/qt/packet_list_model.h b/ui/qt/packet_list_model.h index fedde05149..db229ce38b 100644 --- a/ui/qt/packet_list_model.h +++ b/ui/qt/packet_list_model.h @@ -45,14 +45,14 @@ public: explicit PacketListModel(QObject *parent = 0, capture_file *cf = NULL); void setCaptureFile(capture_file *cf); QModelIndex index(int row, int column, - const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &index) const; + const QModelIndex & = QModelIndex()) const; + QModelIndex parent(const QModelIndex &) const; int packetNumberToRow(int packet_num) const; guint recreateVisibleRows(); void clear(); int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex & = QModelIndex()) const; QVariant data(const QModelIndex &index, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; @@ -66,9 +66,10 @@ public: signals: void goToPacket(int); + void itemHeightChanged(const QModelIndex &index) const; public slots: - void setMonospaceFont(const QFont &mono_font); + void setMonospaceFont(const QFont &mono_font, int row_height); void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); private: @@ -79,13 +80,17 @@ private: QVector<PacketListRecord *> physical_rows_; QMap<int, int> number_to_row_; - int header_height_; + int row_height_; + int line_spacing_; static int sort_column_; static int text_sort_column_; static Qt::SortOrder sort_order_; static capture_file *sort_cap_file_; static bool recordLessThan(PacketListRecord *r1, PacketListRecord *r2); + +private slots: + void emitItemHeightChanged(const QModelIndex &index); }; #endif // PACKET_LIST_MODEL_H |