diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-11-25 12:50:46 -0600 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2017-12-07 19:00:35 +0000 |
commit | be8a40005328d74815491b3536b85fe9e532243e (patch) | |
tree | c74b76c0f462d6772be046cb6f07d669acbb045a /ui/qt/utils/field_information.cpp | |
parent | f8b19c6eecbf241ecede5b85811a772469cea0df (diff) |
Qt: Use QTextLayout in ByteViewText.
Use QTextLayout to draw each line in ByteViewText instead of drawing
fragments ourselves. Build our pixel-to-byte-offset map when we draw our
first line, which should hopefully make it more accurate. This should
fix layout and hover issues on some systems.
Start moving common code to DataPrinter.
Mark prefs.gui_hex_dump_highlight_style GTK+ only.
Bug: 11844
Change-Id: Ifda16ae7dc1a5ea22570c0bfd0eb20cee621bfc9
Reviewed-on: https://code.wireshark.org/review/24717
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui/qt/utils/field_information.cpp')
-rw-r--r-- | ui/qt/utils/field_information.cpp | 51 |
1 files changed, 8 insertions, 43 deletions
diff --git a/ui/qt/utils/field_information.cpp b/ui/qt/utils/field_information.cpp index fc58222101..aac03277c5 100644 --- a/ui/qt/utils/field_information.cpp +++ b/ui/qt/utils/field_information.cpp @@ -4,19 +4,7 @@ * By Gerald Combs <gerald@wireshark.org> * Copyright 1998 Gerald Combs * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * SPDX-License-Identifier: GPL-2.0+ */ #include <stdint.h> @@ -87,29 +75,22 @@ bool FieldInformation::tvbContains(FieldInformation *child) FieldInformation::Position FieldInformation::position() const { - Position pos = {-1, -1, -1}; + Position pos = {-1, -1}; if ( fi_ && fi_->ds_tvb ) { - guint len = tvb_captured_length(fi_->ds_tvb); + int len = (int) tvb_captured_length(fi_->ds_tvb); pos.start = fi_->start; pos.length = fi_->length; - if (pos.start >= 0 && pos.length > 0 && (guint)pos.start < len) - { - pos.end = pos.start + pos.length; - } - else + if (pos.start < 0 || pos.length < 0 || pos.start >= len) { - if ( fi_->appendix_start >= 0 && fi_->appendix_length > 0 && (guint)fi_->appendix_start < len ) + if ( fi_->appendix_start >= 0 && fi_->appendix_length > 0 && fi_->appendix_start < len ) { pos.start = fi_->appendix_start; - pos.end = fi_->appendix_start + fi_->appendix_length; + pos.length = fi_->appendix_length; } } - - if (pos.end != -1 && (guint)pos.end > len) - pos.end = len; } return pos; @@ -117,31 +98,16 @@ FieldInformation::Position FieldInformation::position() const FieldInformation::Position FieldInformation::appendix() const { - Position pos = {-1, -1, -1}; + Position pos = {-1, -1}; if ( fi_ && fi_->ds_tvb ) { - guint len = tvb_captured_length(fi_->ds_tvb); - pos.start = fi_->appendix_start; pos.length = fi_->appendix_length; - - if (pos.start >= 0 && pos.length > 0 && (guint)pos.start < len) - pos.end = pos.start + pos.length; - - /* sanity check with total field length */ - if ( position().end == -1 ) - { - pos.start = -1; - pos.end = -1; - } - - if (pos.end != -1 && (guint)pos.end > len) - pos.end = len; } return pos; } -#include <QDebug> + QByteArray FieldInformation::printableData() { QByteArray data; @@ -154,7 +120,6 @@ QByteArray FieldInformation::printableData() int length = pos.length; if ( length > rem_length ) length = rem_length; -qDebug() << "Bin hier"; uint8_t * dataSet = (uint8_t *)tvb_memdup(wmem_file_scope(), fi_->ds_tvb, pos.start, length ); data = QByteArray::fromRawData((char *)dataSet, length); } |