Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Macros | Functions
qt_ui_utils.h File Reference
#include <config.h>
#include <glib.h>
#include "ui/rtp_stream.h"
#include <QString>

Go to the source code of this file.

Macros

#define RECENT_KEY_CAPTURE_FILE   "recent.capture_file"
 
#define RECENT_KEY_REMOTE_HOST   "recent.remote_host"
 
#define gxx_list_next(list)   ((list) ? ((reinterpret_cast<GList *>(list))->next) : Q_NULLPTR)
 
#define gxx_constlist_next(list)   ((list) ? ((reinterpret_cast<const GList *>(list))->next) : Q_NULLPTR)
 
#define gxx_list_previous(list)   ((list) ? ((reinterpret_cast<GList *>(list))->prev) : Q_NULLPTR)
 
#define gxx_constlist_previous(list)   ((list) ? ((reinterpret_cast<const GList *>(list))->prev) : Q_NULLPTR)
 
#define gxx_list_data(type, list)   ((list) ? ((reinterpret_cast<type>(list->data))) : Q_NULLPTR)
 

Functions

char * qstring_strdup (QString q_string)
 
QString gchar_free_to_qstring (char *glib_string)
 
QByteArray gchar_free_to_qbytearray (char *glib_string)
 
QByteArray gstring_free_to_qbytearray (GString *glib_gstring)
 
QByteArray gbytearray_free_to_qbytearray (GByteArray *glib_array)
 
const QString int_to_qstring (qint64 value, int field_width=0, int base=10)
 
const QString address_to_qstring (const struct _address *address, bool enclose=false)
 
const QString address_to_display_qstring (const struct _address *address)
 
const QString val_to_qstring (const uint32_t val, const struct _value_string *vs, const char *fmt) G_GNUC_PRINTF(3
 
const QString const QString val_ext_to_qstring (const uint32_t val, struct _value_string_ext *vse, const char *fmt) G_GNUC_PRINTF(3
 
const QString const QString const QString range_to_qstring (const range_string *range)
 
const QString bits_s_to_qstring (const double bits_s)
 
const QString file_size_to_qstring (const int64_t size)
 
const QString time_t_to_qstring (time_t ti_time)
 
QString html_escape (const QString plain_string)
 
void smooth_font_size (QFont &font)
 
bool qActionLessThan (const QAction *a1, const QAction *a2)
 
bool qStringCaseLessThan (const QString &s1, const QString &s2)
 
void desktop_show_in_folder (const QString file_path)
 
bool rect_on_screen (const QRect &rect)
 
void set_action_shortcuts_visible_in_context_menu (QList< QAction * > actions)
 
QVector< rtpstream_id_t * > qvector_rtpstream_ids_copy (QVector< rtpstream_id_t * > stream_ids)
 
void qvector_rtpstream_ids_free (QVector< rtpstream_id_t * > stream_ids)
 
QString make_filter_based_on_rtpstream_id (QVector< rtpstream_id_t * > stream_ids)
 
QString openDialogInitialDir ()
 Return the last directory that had been opened.
 
void storeLastDir (QString dir)
 Store the directory as last directory being used.
 

Detailed Description

Declarations of Qt-specific UI utility routines

Wireshark - Network traffic analyzer By Gerald Combs geral.nosp@m.d@wi.nosp@m.resha.nosp@m.rk.o.nosp@m.rg Copyright 1998 Gerald Combs

SPDX-License-Identifier: GPL-2.0-or-later

Utility functions for working with the Wireshark and GLib APIs.

Function Documentation

◆ address_to_display_qstring()

const QString address_to_display_qstring ( const struct _address address)

Convert an address to a QString using address_to_display().

Parameters
addressA pointer to an address.
Returns
A QString representation of the address. May be the null string (QString())

◆ address_to_qstring()

const QString address_to_qstring ( const struct _address address,
bool  enclose = false 
)

Convert an address to a QString using address_to_str().

Parameters
addressA pointer to an address.
encloseEnclose IPv6 addresses in square brackets.
Returns
A QString representation of the address. May be the null string (QString())

◆ bits_s_to_qstring()

const QString bits_s_to_qstring ( const double  bits_s)

Convert a bits per second value to a human-readable QString using format_size().

Parameters
bits_sThe value to convert to string.
Returns
A QString representation of the data rate in SI units.

◆ desktop_show_in_folder()

void desktop_show_in_folder ( const QString  file_path)

Given the path to a file, open its containing folder in the desktop shell. Highlight the file if possible.

Parameters
file_pathPath to the file.

◆ file_size_to_qstring()

const QString file_size_to_qstring ( const int64_t  size)

Convert a file size value to a human-readable QString using format_size().

Parameters
sizeThe value to convert to string.
Returns
A QString representation of the file size in SI units.

◆ gbytearray_free_to_qbytearray()

QByteArray gbytearray_free_to_qbytearray ( GByteArray *  glib_array)

Transfer ownership of a GbyteArray to a newly constructed QByteArray

Parameters
glib_arrayA GByteArray or NULL. Will be freed.
Returns
A QByteArray instance created from the input array.

◆ gchar_free_to_qbytearray()

QByteArray gchar_free_to_qbytearray ( char *  glib_string)

Transfer ownership of a GLib character string to a newly constructed QString

Parameters
glib_stringA string allocated with g_malloc() or NULL. Will be freed.
Returns
A QByteArray instance created from the input string.

◆ gchar_free_to_qstring()

QString gchar_free_to_qstring ( char *  glib_string)

Transfer ownership of a GLib character string to a newly constructed QString

Parameters
glib_stringA string allocated with g_malloc() or NULL. Will be freed.
Returns
A QString instance created from the input string.

◆ gstring_free_to_qbytearray()

QByteArray gstring_free_to_qbytearray ( GString *  glib_gstring)

Transfer ownership of a GLib character string to a newly constructed QByteArray

Parameters
glib_gstringA string allocated with g_malloc() or NULL. Will be freed.
Returns
A QByteArray instance created from the input string.

◆ html_escape()

QString html_escape ( const QString  plain_string)

Escape HTML metacharacters in a string.

Parameters
plain_stringString to convert.
Returns
A QString with escaped metacharacters.

◆ int_to_qstring()

const QString int_to_qstring ( qint64  value,
int  field_width = 0,
int  base = 10 
)

Convert an integer to a formatted string representation.

Parameters
valueThe integer to format.
field_widthWidth of the output, not including any base prefix. Output will be zero-padded.
baseNumber base between 2 and 36 (limited by QString::arg).
Returns
A QString representation of the integer

◆ make_filter_based_on_rtpstream_id()

QString make_filter_based_on_rtpstream_id ( QVector< rtpstream_id_t * >  stream_ids)

Make display filter from list of rtpstream_id

Parameters
stream_idsList of ids
Returns
Filter or empty string

◆ openDialogInitialDir()

QString openDialogInitialDir ( )

Return the last directory that had been opened.

This can be influenced by prefs.gui_fileopen_style which will allow to either open the real last dir or have the user set one specifically.

Returns
a reference to that directory.

◆ qActionLessThan()

bool qActionLessThan ( const QAction *  a1,
const QAction *  a2 
)

Compare the text of two QActions. Useful for passing to std::sort.

Parameters
a1First action
a2Second action

◆ qstring_strdup()

char * qstring_strdup ( QString  q_string)

Create a glib-compatible copy of a QString.

Parameters
q_stringA QString.
Returns
A copy of the QString. UTF-8 allocated with g_malloc().

◆ qStringCaseLessThan()

bool qStringCaseLessThan ( const QString &  s1,
const QString &  s2 
)

Compare two QStrings, ignoring case. Useful for passing to std::sort.

Parameters
s1First string
s2Second string

◆ qvector_rtpstream_ids_copy()

QVector< rtpstream_id_t * > qvector_rtpstream_ids_copy ( QVector< rtpstream_id_t * >  stream_ids)

Create copy of all rtpstream_ids to new QVector => caller must release it with qvector_rtpstream_ids_free()

Parameters
stream_idsList of infos
Returns
Vector of rtpstream_ids

◆ qvector_rtpstream_ids_free()

void qvector_rtpstream_ids_free ( QVector< rtpstream_id_t * >  stream_ids)

Free all rtpstream_ids in QVector

Parameters
stream_idsList of infos

◆ range_to_qstring()

const QString const QString const QString range_to_qstring ( const range_string range)

Convert a range to a QString using range_convert_range().

Parameters
rangeA pointer to a range_string struct.
Returns
A QString representation of the range_string. May be the null string (QString())

◆ rect_on_screen()

bool rect_on_screen ( const QRect &  rect)

Test to see if a rect is visible on screen.

Parameters
rectThe rect to test, typically a "recent.gui_geometry_*" setting.
Returns
true if the rect is completely enclosed by one of the display screens, false otherwise.

◆ set_action_shortcuts_visible_in_context_menu()

void set_action_shortcuts_visible_in_context_menu ( QList< QAction * >  actions)

Set the "shortcutVisibleInContextMenu" property to true for a list of qactions.

Parameters
actionsThe actions to make visible.

◆ smooth_font_size()

void smooth_font_size ( QFont &  font)

Round the current size of a font up to its next "smooth" size. If a smooth size can't be found the font is left unchanged.

Parameters
fontThe font to smooth.

◆ time_t_to_qstring()

const QString time_t_to_qstring ( time_t  ti_time)

Convert a time_t value to a human-readable QString using QDateTime.

Parameters
ti_timeThe value to convert.
Returns
A QString representation of the file size in SI units.

◆ val_ext_to_qstring()

const QString const QString val_ext_to_qstring ( const uint32_t  val,
struct _value_string_ext vse,
const char *  fmt 
)

Convert a value_string_ext to a QString using val_to_str_ext_wmem().

Parameters
valThe value to convert to string.
vsevalue_string_ext array.
fmtFormatting for value not in array.
Returns
A QString representation of the value_string_ext.

◆ val_to_qstring()

const QString val_to_qstring ( const uint32_t  val,
const struct _value_string vs,
const char *  fmt 
)

Convert a value_string to a QString using val_to_str_wmem().

Parameters
valThe value to convert to string.
vsvalue_string array.
fmtFormatting for value not in array.
Returns
A QString representation of the value_string.