Qt: Add missing multi-field column validation
GTK already has it, but Qt forgot about it, so multi-field custom column works ok if previously saved in GTK-shark. Invalid validation prevent from modifying and saving multi-field custom column in Qt version. While at it, rename "custom field" to "custom fields" to ensure we think about multi-field custom column. Change-Id: I99588150ccb38be11b75f5dd5b0f6443e7055ebb Reviewed-on: https://code.wireshark.org/review/12685 Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
7e0ec2c8eb
commit
9bb3f6be4c
|
@ -630,7 +630,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
|||
get_ber_identifier@Base 1.9.1
|
||||
get_ber_length@Base 1.9.1
|
||||
get_column_char_width@Base 1.9.1
|
||||
get_column_custom_field@Base 1.9.1
|
||||
get_column_custom_fields@Base 2.1.0
|
||||
get_column_custom_occurrence@Base 1.9.1
|
||||
get_column_format@Base 1.9.1
|
||||
get_column_format_from_str@Base 1.9.1
|
||||
|
@ -1184,7 +1184,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
|||
sctp_port_to_display@Base 1.99.2
|
||||
serv_name_lookup@Base 2.1.0
|
||||
set_actual_length@Base 1.9.1
|
||||
set_column_custom_field@Base 1.9.1
|
||||
set_column_custom_fields@Base 2.1.0
|
||||
set_column_custom_occurrence@Base 1.9.1
|
||||
set_column_format@Base 1.9.1
|
||||
set_column_resolved@Base 1.9.1
|
||||
|
|
|
@ -48,9 +48,9 @@ typedef struct {
|
|||
gint col_fmt; /**< Format of column */
|
||||
gboolean *fmt_matx; /**< Specifies which formats apply to a column */
|
||||
gchar *col_title; /**< Column titles */
|
||||
gchar *col_custom_field; /**< Custom column field */
|
||||
gchar *col_custom_fields; /**< Custom column fields */
|
||||
gint col_custom_occurrence;/**< Custom column field occurrence */
|
||||
GSList *col_custom_field_ids; /**< Custom column field id */
|
||||
GSList *col_custom_fields_ids;/**< Custom column fields id */
|
||||
struct epan_dfilter *col_custom_dfilter; /**< Compiled custom column field */
|
||||
const gchar *col_data; /**< Column data */
|
||||
gchar *col_buf; /**< Buffer into which to copy data for column */
|
||||
|
|
|
@ -55,7 +55,7 @@ col_setup(column_info *cinfo, const gint num_cols)
|
|||
cinfo->col_first = g_new(int, NUM_COL_FMTS);
|
||||
cinfo->col_last = g_new(int, NUM_COL_FMTS);
|
||||
for (i = 0; i < num_cols; i++) {
|
||||
cinfo->columns[i].col_custom_field_ids = NULL;
|
||||
cinfo->columns[i].col_custom_fields_ids = NULL;
|
||||
}
|
||||
cinfo->col_expr.col_expr = g_new(const gchar*, num_cols + 1);
|
||||
cinfo->col_expr.col_expr_val = g_new(gchar*, num_cols + 1);
|
||||
|
@ -75,13 +75,13 @@ col_custom_ids_free_wrapper(gpointer data, gpointer user_data _U_)
|
|||
}
|
||||
|
||||
static void
|
||||
col_custom_field_ids_free(GSList** custom_field_id)
|
||||
col_custom_fields_ids_free(GSList** custom_fields_id)
|
||||
{
|
||||
if (*custom_field_id != NULL) {
|
||||
g_slist_foreach(*custom_field_id, col_custom_ids_free_wrapper, NULL);
|
||||
g_slist_free(*custom_field_id);
|
||||
if (*custom_fields_id != NULL) {
|
||||
g_slist_foreach(*custom_fields_id, col_custom_ids_free_wrapper, NULL);
|
||||
g_slist_free(*custom_fields_id);
|
||||
}
|
||||
*custom_field_id = NULL;
|
||||
*custom_fields_id = NULL;
|
||||
}
|
||||
|
||||
/* Cleanup all the data structures for constructing column data; undoes
|
||||
|
@ -96,12 +96,12 @@ col_cleanup(column_info *cinfo)
|
|||
col_item = &cinfo->columns[i];
|
||||
g_free(col_item->fmt_matx);
|
||||
g_free(col_item->col_title);
|
||||
g_free(col_item->col_custom_field);
|
||||
g_free(col_item->col_custom_fields);
|
||||
dfilter_free(col_item->col_custom_dfilter);
|
||||
/* col_item->col_data points to col_buf or static memory */
|
||||
g_free(col_item->col_buf);
|
||||
g_free(cinfo->col_expr.col_expr_val[i]);
|
||||
col_custom_field_ids_free(&col_item->col_custom_field_ids);
|
||||
col_custom_fields_ids_free(&col_item->col_custom_fields_ids);
|
||||
}
|
||||
|
||||
g_free(cinfo->columns);
|
||||
|
@ -305,10 +305,10 @@ void col_custom_set_edt(epan_dissect_t *edt, column_info *cinfo)
|
|||
i <= cinfo->col_last[COL_CUSTOM]; i++) {
|
||||
col_item = &cinfo->columns[i];
|
||||
if (col_item->fmt_matx[COL_CUSTOM] &&
|
||||
col_item->col_custom_field &&
|
||||
col_item->col_custom_field_ids) {
|
||||
col_item->col_custom_fields &&
|
||||
col_item->col_custom_fields_ids) {
|
||||
col_item->col_data = col_item->col_buf;
|
||||
cinfo->col_expr.col_expr[i] = epan_custom_set(edt, col_item->col_custom_field_ids,
|
||||
cinfo->col_expr.col_expr[i] = epan_custom_set(edt, col_item->col_custom_fields_ids,
|
||||
col_item->col_custom_occurrence,
|
||||
col_item->col_buf,
|
||||
cinfo->col_expr.col_expr_val[i],
|
||||
|
@ -331,17 +331,17 @@ col_custom_prime_edt(epan_dissect_t *edt, column_info *cinfo)
|
|||
int i_list = 0;
|
||||
|
||||
col_item = &cinfo->columns[i];
|
||||
col_custom_field_ids_free(&col_item->col_custom_field_ids);
|
||||
col_custom_fields_ids_free(&col_item->col_custom_fields_ids);
|
||||
|
||||
if (col_item->fmt_matx[COL_CUSTOM] &&
|
||||
col_item->col_custom_dfilter) {
|
||||
epan_dissect_prime_dfilter(edt, col_item->col_custom_dfilter);
|
||||
if (col_item->col_custom_field) {
|
||||
if (col_item->col_custom_fields) {
|
||||
gchar **fields;
|
||||
guint i_field = 0;
|
||||
|
||||
/* Not using a GRegex here would improve performance. */
|
||||
fields = g_regex_split(cinfo->prime_regex, col_item->col_custom_field,
|
||||
fields = g_regex_split(cinfo->prime_regex, col_item->col_custom_fields,
|
||||
G_REGEX_MATCH_ANCHORED);
|
||||
|
||||
for (i_field =0; i_field < g_strv_length(fields); i_field += 1) {
|
||||
|
@ -355,8 +355,8 @@ col_custom_prime_edt(epan_dissect_t *edt, column_info *cinfo)
|
|||
|
||||
idx = g_new(int, 1);
|
||||
*idx = id;
|
||||
col_item->col_custom_field_ids =
|
||||
g_slist_insert(col_item->col_custom_field_ids, idx, i_list);
|
||||
col_item->col_custom_fields_ids =
|
||||
g_slist_insert(col_item->col_custom_fields_ids, idx, i_list);
|
||||
i_list += 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -728,7 +728,7 @@ set_column_resolved(const gint col, gboolean resolved)
|
|||
}
|
||||
|
||||
const gchar *
|
||||
get_column_custom_field(const gint col)
|
||||
get_column_custom_fields(const gint col)
|
||||
{
|
||||
GList *clp = g_list_nth(prefs.col_list, col);
|
||||
fmt_data *cfmt;
|
||||
|
@ -738,11 +738,11 @@ get_column_custom_field(const gint col)
|
|||
|
||||
cfmt = (fmt_data *) clp->data;
|
||||
|
||||
return(cfmt->custom_field);
|
||||
return(cfmt->custom_fields);
|
||||
}
|
||||
|
||||
void
|
||||
set_column_custom_field(const gint col, const char *custom_field)
|
||||
set_column_custom_fields(const gint col, const char *custom_fields)
|
||||
{
|
||||
GList *clp = g_list_nth(prefs.col_list, col);
|
||||
fmt_data *cfmt;
|
||||
|
@ -752,8 +752,8 @@ set_column_custom_field(const gint col, const char *custom_field)
|
|||
|
||||
cfmt = (fmt_data *) clp->data;
|
||||
|
||||
g_free (cfmt->custom_field);
|
||||
cfmt->custom_field = g_strdup (custom_field);
|
||||
g_free (cfmt->custom_fields);
|
||||
cfmt->custom_fields = g_strdup (custom_fields);
|
||||
}
|
||||
|
||||
gint
|
||||
|
@ -797,8 +797,8 @@ get_column_tooltip(const gint col)
|
|||
cfmt = (fmt_data *) clp->data;
|
||||
|
||||
if (cfmt->fmt == COL_CUSTOM) {
|
||||
header_field_info *hfi = proto_registrar_get_byname(cfmt->custom_field);
|
||||
/* Check if this is a valid custom_field */
|
||||
header_field_info *hfi = proto_registrar_get_byname(cfmt->custom_fields);
|
||||
/* Check if this is a valid custom_fields */
|
||||
if (hfi != NULL) {
|
||||
if (hfi->parent != -1) {
|
||||
/* Prefix with protocol name */
|
||||
|
@ -811,7 +811,7 @@ get_column_tooltip(const gint col)
|
|||
tooltip_text = g_strdup_printf("%s (%s)", hfi->name, hfi->abbrev);
|
||||
}
|
||||
} else {
|
||||
tooltip_text = g_strdup_printf("Unknown Field: %s", get_column_custom_field(col));
|
||||
tooltip_text = g_strdup_printf("Unknown Field: %s", get_column_custom_fields(col));
|
||||
}
|
||||
} else {
|
||||
tooltip_text = g_strdup(col_format_desc(cfmt->fmt));
|
||||
|
@ -835,17 +835,17 @@ build_column_format_array(column_info *cinfo, const gint num_cols, const gboolea
|
|||
col_item->col_title = g_strdup(get_column_title(i));
|
||||
|
||||
if (col_item->col_fmt == COL_CUSTOM) {
|
||||
col_item->col_custom_field = g_strdup(get_column_custom_field(i));
|
||||
col_item->col_custom_fields = g_strdup(get_column_custom_fields(i));
|
||||
col_item->col_custom_occurrence = get_column_custom_occurrence(i);
|
||||
if(!dfilter_compile(col_item->col_custom_field, &col_item->col_custom_dfilter, NULL)) {
|
||||
if(!dfilter_compile(col_item->col_custom_fields, &col_item->col_custom_dfilter, NULL)) {
|
||||
/* XXX: Should we issue a warning? */
|
||||
g_free(col_item->col_custom_field);
|
||||
col_item->col_custom_field = NULL;
|
||||
g_free(col_item->col_custom_fields);
|
||||
col_item->col_custom_fields = NULL;
|
||||
col_item->col_custom_occurrence = 0;
|
||||
col_item->col_custom_dfilter = NULL;
|
||||
}
|
||||
} else {
|
||||
col_item->col_custom_field = NULL;
|
||||
col_item->col_custom_fields = NULL;
|
||||
col_item->col_custom_occurrence = 0;
|
||||
col_item->col_custom_dfilter = NULL;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ extern "C" {
|
|||
typedef struct _fmt_data {
|
||||
gchar *title; /* title of the column */
|
||||
int fmt; /* format of column */
|
||||
gchar *custom_field; /* field name for COL_CUSTOM */
|
||||
gchar *custom_fields; /* fields names for COL_CUSTOM */
|
||||
gint custom_occurrence; /* optional ordinal of occurrence of that field */
|
||||
gboolean visible; /* if FALSE, hide this column */
|
||||
gboolean resolved; /* if TRUE, show a more human-readable name */
|
||||
|
@ -64,9 +64,9 @@ gboolean get_column_resolved(const gint);
|
|||
WS_DLL_PUBLIC
|
||||
void set_column_resolved(const gint, gboolean);
|
||||
WS_DLL_PUBLIC
|
||||
const gchar *get_column_custom_field(const gint);
|
||||
const gchar *get_column_custom_fields(const gint);
|
||||
WS_DLL_PUBLIC
|
||||
void set_column_custom_field(const gint, const char *);
|
||||
void set_column_custom_fields(const gint, const char *);
|
||||
WS_DLL_PUBLIC
|
||||
gint get_column_custom_occurrence(const gint);
|
||||
WS_DLL_PUBLIC
|
||||
|
|
62
epan/prefs.c
62
epan/prefs.c
|
@ -1557,10 +1557,10 @@ column_hidden_to_str_cb(pref_t* pref, gboolean default_val)
|
|||
while (clp) {
|
||||
gchar *prefs_fmt;
|
||||
cfmt = (fmt_data *) clp->data;
|
||||
if ((cfmt->fmt == COL_CUSTOM) && (cfmt->custom_field)) {
|
||||
if ((cfmt->fmt == COL_CUSTOM) && (cfmt->custom_fields)) {
|
||||
prefs_fmt = g_strdup_printf("%s:%s:%d:%c",
|
||||
col_format_to_string(cfmt->fmt),
|
||||
cfmt->custom_field,
|
||||
cfmt->custom_fields,
|
||||
cfmt->custom_occurrence,
|
||||
cfmt->resolved ? 'R' : 'U');
|
||||
} else {
|
||||
|
@ -1646,11 +1646,11 @@ column_format_init_cb(pref_t* pref, GList** value)
|
|||
dest_cfmt = g_new(fmt_data,1);
|
||||
dest_cfmt->title = g_strdup(src_cfmt->title);
|
||||
dest_cfmt->fmt = src_cfmt->fmt;
|
||||
if (src_cfmt->custom_field) {
|
||||
dest_cfmt->custom_field = g_strdup(src_cfmt->custom_field);
|
||||
if (src_cfmt->custom_fields) {
|
||||
dest_cfmt->custom_fields = g_strdup(src_cfmt->custom_fields);
|
||||
dest_cfmt->custom_occurrence = src_cfmt->custom_occurrence;
|
||||
} else {
|
||||
dest_cfmt->custom_field = NULL;
|
||||
dest_cfmt->custom_fields = NULL;
|
||||
dest_cfmt->custom_occurrence = 0;
|
||||
}
|
||||
dest_cfmt->visible = src_cfmt->visible;
|
||||
|
@ -1681,11 +1681,11 @@ column_format_reset_cb(pref_t* pref)
|
|||
dest_cfmt = g_new(fmt_data,1);
|
||||
dest_cfmt->title = g_strdup(src_cfmt->title);
|
||||
dest_cfmt->fmt = src_cfmt->fmt;
|
||||
if (src_cfmt->custom_field) {
|
||||
dest_cfmt->custom_field = g_strdup(src_cfmt->custom_field);
|
||||
if (src_cfmt->custom_fields) {
|
||||
dest_cfmt->custom_fields = g_strdup(src_cfmt->custom_fields);
|
||||
dest_cfmt->custom_occurrence = src_cfmt->custom_occurrence;
|
||||
} else {
|
||||
dest_cfmt->custom_field = NULL;
|
||||
dest_cfmt->custom_fields = NULL;
|
||||
dest_cfmt->custom_occurrence = 0;
|
||||
}
|
||||
dest_cfmt->visible = src_cfmt->visible;
|
||||
|
@ -1734,7 +1734,7 @@ column_format_set_cb(pref_t* pref, const gchar* value, gboolean* changed _U_)
|
|||
try_convert_to_custom_column(&col_l_elt->data);
|
||||
} else {
|
||||
/* We don't need the custom column field on this pass. */
|
||||
g_free(cfmt_check.custom_field);
|
||||
g_free(cfmt_check.custom_fields);
|
||||
}
|
||||
|
||||
/* Go past the format. */
|
||||
|
@ -1799,8 +1799,8 @@ column_format_is_default_cb(pref_t* pref)
|
|||
def_cfmt = (fmt_data *) def_col->data;
|
||||
if ((g_strcmp0(cfmt->title, def_cfmt->title) != 0) ||
|
||||
(cfmt->fmt != def_cfmt->fmt) ||
|
||||
(((cfmt->fmt == COL_CUSTOM) && (cfmt->custom_field)) &&
|
||||
((g_strcmp0(cfmt->custom_field, def_cfmt->custom_field) != 0) ||
|
||||
(((cfmt->fmt == COL_CUSTOM) && (cfmt->custom_fields)) &&
|
||||
((g_strcmp0(cfmt->custom_fields, def_cfmt->custom_fields) != 0) ||
|
||||
(cfmt->resolved != def_cfmt->resolved)))) {
|
||||
is_default = FALSE;
|
||||
break;
|
||||
|
@ -1828,10 +1828,10 @@ column_format_to_str_cb(pref_t* pref, gboolean default_val)
|
|||
while (clp) {
|
||||
cfmt = (fmt_data *) clp->data;
|
||||
col_l = g_list_append(col_l, g_strdup(cfmt->title));
|
||||
if ((cfmt->fmt == COL_CUSTOM) && (cfmt->custom_field)) {
|
||||
if ((cfmt->fmt == COL_CUSTOM) && (cfmt->custom_fields)) {
|
||||
prefs_fmt = g_strdup_printf("%s:%s:%d:%c",
|
||||
col_format_to_string(cfmt->fmt),
|
||||
cfmt->custom_field,
|
||||
cfmt->custom_fields,
|
||||
cfmt->custom_occurrence,
|
||||
cfmt->resolved ? 'R' : 'U');
|
||||
} else {
|
||||
|
@ -2865,7 +2865,7 @@ parse_column_format(fmt_data *cfmt, const char *fmt)
|
|||
gchar **cust_format_info;
|
||||
char *p;
|
||||
int col_fmt;
|
||||
gchar *col_custom_field = NULL;
|
||||
gchar *col_custom_fields = NULL;
|
||||
long col_custom_occurrence = 0;
|
||||
gboolean col_resolved = TRUE;
|
||||
|
||||
|
@ -2877,17 +2877,17 @@ parse_column_format(fmt_data *cfmt, const char *fmt)
|
|||
/* Yes. */
|
||||
col_fmt = COL_CUSTOM;
|
||||
cust_format_info = g_strsplit(&fmt[cust_format_len+1],":",3); /* add 1 for ':' */
|
||||
col_custom_field = g_strdup(cust_format_info[0]);
|
||||
if (col_custom_field && cust_format_info[1]) {
|
||||
col_custom_fields = g_strdup(cust_format_info[0]);
|
||||
if (col_custom_fields && cust_format_info[1]) {
|
||||
col_custom_occurrence = strtol(cust_format_info[1], &p, 10);
|
||||
if (p == cust_format_info[1] || *p != '\0') {
|
||||
/* Not a valid number. */
|
||||
g_free(col_custom_field);
|
||||
g_free(col_custom_fields);
|
||||
g_strfreev(cust_format_info);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (col_custom_field && cust_format_info[1] && cust_format_info[2]) {
|
||||
if (col_custom_fields && cust_format_info[1] && cust_format_info[2]) {
|
||||
col_resolved = (cust_format_info[2][0] == 'U') ? FALSE : TRUE;
|
||||
}
|
||||
g_strfreev(cust_format_info);
|
||||
|
@ -2898,7 +2898,7 @@ parse_column_format(fmt_data *cfmt, const char *fmt)
|
|||
}
|
||||
|
||||
cfmt->fmt = col_fmt;
|
||||
cfmt->custom_field = col_custom_field;
|
||||
cfmt->custom_fields = col_custom_fields;
|
||||
cfmt->custom_occurrence = (int)col_custom_occurrence;
|
||||
cfmt->resolved = col_resolved;
|
||||
return TRUE;
|
||||
|
@ -3074,7 +3074,7 @@ pre_init_prefs(void)
|
|||
parse_column_format(cfmt, col_fmt[(i * 2) + 1]);
|
||||
cfmt->visible = TRUE;
|
||||
cfmt->resolved = TRUE;
|
||||
cfmt->custom_field = NULL;
|
||||
cfmt->custom_fields = NULL;
|
||||
cfmt->custom_occurrence = 0;
|
||||
prefs.col_list = g_list_append(prefs.col_list, cfmt);
|
||||
}
|
||||
|
@ -3724,8 +3724,8 @@ prefs_is_column_visible(const gchar *cols_hidden, fmt_data *cfmt)
|
|||
*/
|
||||
if (cfmt->fmt != cfmt_hidden.fmt) {
|
||||
/* No. */
|
||||
g_free(cfmt_hidden.custom_field);
|
||||
cfmt_hidden.custom_field = NULL;
|
||||
g_free(cfmt_hidden.custom_fields);
|
||||
cfmt_hidden.custom_fields = NULL;
|
||||
continue;
|
||||
}
|
||||
if (cfmt->fmt == COL_CUSTOM) {
|
||||
|
@ -3733,18 +3733,18 @@ prefs_is_column_visible(const gchar *cols_hidden, fmt_data *cfmt)
|
|||
* A custom column has to have the
|
||||
* same custom field and occurrence.
|
||||
*/
|
||||
if (cfmt_hidden.custom_field && cfmt->custom_field) {
|
||||
if (strcmp(cfmt->custom_field,
|
||||
cfmt_hidden.custom_field) != 0) {
|
||||
if (cfmt_hidden.custom_fields && cfmt->custom_fields) {
|
||||
if (strcmp(cfmt->custom_fields,
|
||||
cfmt_hidden.custom_fields) != 0) {
|
||||
/* Different fields. */
|
||||
g_free(cfmt_hidden.custom_field);
|
||||
cfmt_hidden.custom_field = NULL;
|
||||
g_free(cfmt_hidden.custom_fields);
|
||||
cfmt_hidden.custom_fields = NULL;
|
||||
continue;
|
||||
}
|
||||
if (cfmt->custom_occurrence != cfmt_hidden.custom_occurrence) {
|
||||
/* Different occurrences. */
|
||||
g_free(cfmt_hidden.custom_field);
|
||||
cfmt_hidden.custom_field = NULL;
|
||||
g_free(cfmt_hidden.custom_fields);
|
||||
cfmt_hidden.custom_fields = NULL;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -3754,7 +3754,7 @@ prefs_is_column_visible(const gchar *cols_hidden, fmt_data *cfmt)
|
|||
* OK, they match, so it's one of the hidden fields,
|
||||
* hence not visible.
|
||||
*/
|
||||
g_free(cfmt_hidden.custom_field);
|
||||
g_free(cfmt_hidden.custom_fields);
|
||||
g_free(cols);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -5020,7 +5020,7 @@ free_col_info(GList *list)
|
|||
cfmt = (fmt_data *)list->data;
|
||||
|
||||
g_free(cfmt->title);
|
||||
g_free(cfmt->custom_field);
|
||||
g_free(cfmt->custom_fields);
|
||||
g_free(cfmt);
|
||||
list = g_list_next(list);
|
||||
}
|
||||
|
|
|
@ -593,7 +593,7 @@ get_filter_from_packet_list_row_and_column(gpointer data)
|
|||
strlen(cfile.cinfo.col_expr.col_expr_val[column]) != 0) {
|
||||
/* leak a little; is there a safe wmem_ scope here? */
|
||||
if (cfile.cinfo.columns[column].col_fmt == COL_CUSTOM) {
|
||||
header_field_info *hfi = proto_registrar_get_byname(cfile.cinfo.columns[column].col_custom_field);
|
||||
header_field_info *hfi = proto_registrar_get_byname(cfile.cinfo.columns[column].col_custom_fields);
|
||||
if (hfi && hfi->parent == -1) {
|
||||
/* Protocol only */
|
||||
buf = g_strdup(cfile.cinfo.col_expr.col_expr[column]);
|
||||
|
|
|
@ -5117,13 +5117,13 @@ rebuild_visible_columns_menu (void)
|
|||
cfmt = (fmt_data *) clp->data;
|
||||
if (cfmt->title[0]) {
|
||||
if (cfmt->fmt == COL_CUSTOM) {
|
||||
title = g_strdup_printf ("%s (%s)", cfmt->title, cfmt->custom_field);
|
||||
title = g_strdup_printf ("%s (%s)", cfmt->title, cfmt->custom_fields);
|
||||
} else {
|
||||
title = g_strdup_printf ("%s (%s)", cfmt->title, col_format_desc (cfmt->fmt));
|
||||
}
|
||||
} else {
|
||||
if (cfmt->fmt == COL_CUSTOM) {
|
||||
title = g_strdup_printf ("(%s)", cfmt->custom_field);
|
||||
title = g_strdup_printf ("(%s)", cfmt->custom_fields);
|
||||
} else {
|
||||
title = g_strdup_printf ("(%s)", col_format_desc (cfmt->fmt));
|
||||
}
|
||||
|
|
|
@ -178,9 +178,9 @@ col_title_change_ok (GtkWidget *w, gpointer parent_w)
|
|||
}
|
||||
|
||||
if (cur_fmt == COL_CUSTOM) {
|
||||
const gchar *custom_field = get_column_custom_field(col_id);
|
||||
if ((custom_field && strcmp (name, custom_field) != 0) || (custom_field == NULL)) {
|
||||
set_column_custom_field (col_id, name);
|
||||
const gchar *custom_fields = get_column_custom_fields(col_id);
|
||||
if ((custom_fields && strcmp (name, custom_fields) != 0) || (custom_fields == NULL)) {
|
||||
set_column_custom_fields(col_id, name);
|
||||
recreate = TRUE;
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ col_details_edit_dlg (gint col_id, GtkTreeViewColumn *col)
|
|||
cur_fmt = get_column_format (col_id);
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(format_cmb), cur_fmt);
|
||||
if (cur_fmt == COL_CUSTOM) {
|
||||
gtk_entry_set_text(GTK_ENTRY(field_te), get_column_custom_field(col_id));
|
||||
gtk_entry_set_text(GTK_ENTRY(field_te), get_column_custom_fields(col_id));
|
||||
g_snprintf(custom_occurrence_str, sizeof(custom_occurrence_str), "%d", get_column_custom_occurrence(col_id));
|
||||
gtk_entry_set_text(GTK_ENTRY(occurrence_te), custom_occurrence_str);
|
||||
}
|
||||
|
@ -1629,7 +1629,7 @@ packet_list_recent_write_all(FILE *rf)
|
|||
for (col = 0; col < num_cols; col++) {
|
||||
col_fmt = get_column_format(col);
|
||||
if (col_fmt == COL_CUSTOM) {
|
||||
fprintf (rf, " %%Cus:%s,", get_column_custom_field(col));
|
||||
fprintf (rf, " %%Cus:%s,", get_column_custom_fields(col));
|
||||
} else {
|
||||
fprintf (rf, " %s,", col_format_to_string(col_fmt));
|
||||
}
|
||||
|
|
|
@ -935,7 +935,7 @@ packet_list_compare_custom(gint sort_id, gint text_sort_id, PacketListRecord *a,
|
|||
{
|
||||
header_field_info *hfi;
|
||||
|
||||
hfi = proto_registrar_get_byname(cfile.cinfo.columns[sort_id].col_custom_field);
|
||||
hfi = proto_registrar_get_byname(cfile.cinfo.columns[sort_id].col_custom_fields);
|
||||
|
||||
if (hfi == NULL) {
|
||||
return frame_data_compare(cfile.epan, a->fdata, b->fdata, COL_NUMBER);
|
||||
|
|
|
@ -179,15 +179,15 @@ column_prefs_show(GtkWidget *prefs_window) {
|
|||
cfmt = (fmt_data *) clp->data;
|
||||
if (cfmt->fmt == COL_CUSTOM) {
|
||||
if (cfmt->custom_occurrence) {
|
||||
fmt = g_strdup_printf("%s (%s#%d)", col_format_desc(cfmt->fmt), cfmt->custom_field, cfmt->custom_occurrence);
|
||||
fmt = g_strdup_printf("%s (%s#%d)", col_format_desc(cfmt->fmt), cfmt->custom_fields, cfmt->custom_occurrence);
|
||||
} else {
|
||||
fmt = g_strdup_printf("%s (%s)", col_format_desc(cfmt->fmt), cfmt->custom_field);
|
||||
fmt = g_strdup_printf("%s (%s)", col_format_desc(cfmt->fmt), cfmt->custom_fields);
|
||||
}
|
||||
} else {
|
||||
if (cfmt->custom_field) {
|
||||
/* Delete custom_field from previous changes */
|
||||
g_free (cfmt->custom_field);
|
||||
cfmt->custom_field = NULL;
|
||||
if (cfmt->custom_fields) {
|
||||
/* Delete custom_fields from previous changes */
|
||||
g_free (cfmt->custom_fields);
|
||||
cfmt->custom_fields = NULL;
|
||||
cfmt->custom_occurrence = 0;
|
||||
}
|
||||
fmt = g_strdup_printf("%s", col_format_desc(cfmt->fmt));
|
||||
|
@ -480,7 +480,7 @@ column_list_select_cb(GtkTreeSelection *sel, gpointer data _U_)
|
|||
g_signal_handler_block (field_te, column_field_changed_handler_id);
|
||||
g_signal_handler_block (occurrence_te, column_occurrence_changed_handler_id);
|
||||
if (cfmt->fmt == COL_CUSTOM) {
|
||||
gtk_entry_set_text(GTK_ENTRY(field_te), cfmt->custom_field);
|
||||
gtk_entry_set_text(GTK_ENTRY(field_te), cfmt->custom_fields);
|
||||
gtk_widget_set_sensitive(field_lb, TRUE);
|
||||
gtk_widget_set_sensitive(field_te, TRUE);
|
||||
g_snprintf(custom_occurrence_str, sizeof(custom_occurrence_str), "%d", cfmt->custom_occurrence);
|
||||
|
@ -569,17 +569,17 @@ column_menu_changed_cb(GtkWidget *w, gpointer data) {
|
|||
|
||||
} else if (cur_cb_fmt == COL_CUSTOM) {
|
||||
/* Changing from non-custom to custom */
|
||||
if (cfmt->custom_field == NULL)
|
||||
cfmt->custom_field = g_strdup("");
|
||||
if (cfmt->custom_fields == NULL)
|
||||
cfmt->custom_fields = g_strdup("");
|
||||
/* The following doesn't trigger a call to menu_field_changed_cb() */
|
||||
gtk_entry_set_text(GTK_ENTRY(field_te), cfmt->custom_field);
|
||||
gtk_entry_set_text(GTK_ENTRY(field_te), cfmt->custom_fields);
|
||||
g_snprintf(custom_occurrence_str, sizeof(custom_occurrence_str), "%d", cfmt->custom_occurrence);
|
||||
gtk_entry_set_text(GTK_ENTRY(occurrence_te), custom_occurrence_str);
|
||||
|
||||
if (cfmt->custom_occurrence) {
|
||||
fmt = g_strdup_printf("%s (%s#%d)", col_format_desc(cur_cb_fmt), cfmt->custom_field, cfmt->custom_occurrence);
|
||||
fmt = g_strdup_printf("%s (%s#%d)", col_format_desc(cur_cb_fmt), cfmt->custom_fields, cfmt->custom_occurrence);
|
||||
} else {
|
||||
fmt = g_strdup_printf("%s (%s)", col_format_desc(cur_cb_fmt), cfmt->custom_field);
|
||||
fmt = g_strdup_printf("%s (%s)", col_format_desc(cur_cb_fmt), cfmt->custom_fields);
|
||||
}
|
||||
gtk_widget_set_sensitive(field_lb, TRUE);
|
||||
gtk_widget_set_sensitive(field_te, TRUE);
|
||||
|
@ -627,7 +627,7 @@ column_field_changed_cb(GtkEditable *te, gpointer data) {
|
|||
field = gtk_editable_get_chars(te, 0, -1);
|
||||
gtk_tree_model_get(model, &iter, DATA_COLUMN, &clp, -1);
|
||||
cfmt = (fmt_data *) clp->data;
|
||||
if (strcmp(cfmt->custom_field, field) == 0) {
|
||||
if (strcmp(cfmt->custom_fields, field) == 0) {
|
||||
return; /* no action req'd */
|
||||
}
|
||||
|
||||
|
@ -640,8 +640,8 @@ column_field_changed_cb(GtkEditable *te, gpointer data) {
|
|||
|
||||
gtk_list_store_set(GTK_LIST_STORE(model), &iter, FORMAT_COLUMN, fmt, -1);
|
||||
g_free(fmt);
|
||||
g_free(cfmt->custom_field);
|
||||
cfmt->custom_field = field;
|
||||
g_free(cfmt->custom_fields);
|
||||
cfmt->custom_fields = field;
|
||||
cfile.columns_changed = TRUE;
|
||||
}
|
||||
|
||||
|
@ -680,9 +680,9 @@ column_occurrence_changed_cb(GtkEditable *te, gpointer data) {
|
|||
|
||||
/* The user has entered a new value in the field occurrence entry box: make the req'd changes */
|
||||
if (occurrence) {
|
||||
fmt = g_strdup_printf("%s (%s#%d)", col_format_desc(cfmt->fmt), cfmt->custom_field, occurrence);
|
||||
fmt = g_strdup_printf("%s (%s#%d)", col_format_desc(cfmt->fmt), cfmt->custom_fields, occurrence);
|
||||
} else {
|
||||
fmt = g_strdup_printf("%s (%s)", col_format_desc(cfmt->fmt), cfmt->custom_field);
|
||||
fmt = g_strdup_printf("%s (%s)", col_format_desc(cfmt->fmt), cfmt->custom_fields);
|
||||
}
|
||||
|
||||
gtk_list_store_set(GTK_LIST_STORE(model), &iter, FORMAT_COLUMN, fmt, -1);
|
||||
|
|
|
@ -54,7 +54,7 @@ right_justify_column (gint col, capture_file *cf)
|
|||
break;
|
||||
|
||||
case COL_CUSTOM:
|
||||
hfi = proto_registrar_get_byname(cf->cinfo.columns[col].col_custom_field);
|
||||
hfi = proto_registrar_get_byname(cf->cinfo.columns[col].col_custom_fields);
|
||||
/* Check if this is a valid field and we have no strings lookup table */
|
||||
if ((hfi != NULL) && ((hfi->strings == NULL) || !get_column_resolved(col))) {
|
||||
/* Check for bool, framenum and decimal/octal integer types */
|
||||
|
@ -84,7 +84,7 @@ resolve_column (gint col, capture_file *cf)
|
|||
switch (cf->cinfo.columns[col].col_fmt) {
|
||||
|
||||
case COL_CUSTOM:
|
||||
hfi = proto_registrar_get_byname(cf->cinfo.columns[col].col_custom_field);
|
||||
hfi = proto_registrar_get_byname(cf->cinfo.columns[col].col_custom_fields);
|
||||
/* Check if this is a valid field */
|
||||
if (hfi != NULL) {
|
||||
/* Check if we have an OID or a strings table with integer values */
|
||||
|
|
|
@ -316,7 +316,7 @@ prefs_store_ext(const char * module_name, const char *pref_name, const char *pre
|
|||
}
|
||||
|
||||
gint
|
||||
column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_field, gint custom_occurrence)
|
||||
column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_fields, gint custom_occurrence)
|
||||
{
|
||||
GList *clp;
|
||||
fmt_data *cfmt, *last_cfmt;
|
||||
|
@ -330,13 +330,13 @@ column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_field,
|
|||
*/
|
||||
cfmt->title = g_strdup(title);
|
||||
cfmt->fmt = fmt;
|
||||
cfmt->custom_field = g_strdup(custom_field);
|
||||
cfmt->custom_fields = g_strdup(custom_fields);
|
||||
cfmt->custom_occurrence = custom_occurrence;
|
||||
cfmt->resolved = TRUE;
|
||||
|
||||
colnr = g_list_length(prefs.col_list);
|
||||
|
||||
if (custom_field) {
|
||||
if (custom_fields) {
|
||||
cfmt->visible = TRUE;
|
||||
clp = g_list_last(prefs.col_list);
|
||||
last_cfmt = (fmt_data *) clp->data;
|
||||
|
@ -365,7 +365,7 @@ column_prefs_remove_link(GList *col_link)
|
|||
cfmt = (fmt_data *) col_link->data;
|
||||
|
||||
g_free(cfmt->title);
|
||||
g_free(cfmt->custom_field);
|
||||
g_free(cfmt->custom_fields);
|
||||
g_free(cfmt);
|
||||
prefs.col_list = g_list_remove_link(prefs.col_list, col_link);
|
||||
}
|
||||
|
|
|
@ -63,17 +63,17 @@ void ColumnEditorFrame::setFields(int index)
|
|||
bool ok = true;
|
||||
|
||||
if (index == COL_CUSTOM) {
|
||||
ui->fieldNameLineEdit->setText(saved_field_);
|
||||
ui->fieldNameLineEdit->checkFieldName(saved_field_);
|
||||
ui->fieldsNameLineEdit->setText(saved_fields_);
|
||||
ui->fieldsNameLineEdit->checkCustomColumn(saved_fields_);
|
||||
ui->occurrenceLineEdit->setText(saved_occurrence_);
|
||||
ui->occurrenceLineEdit->checkInteger(saved_occurrence_);
|
||||
if ((ui->fieldNameLineEdit->syntaxState() != SyntaxLineEdit::Valid) ||
|
||||
if ((ui->fieldsNameLineEdit->syntaxState() != SyntaxLineEdit::Valid) ||
|
||||
(ui->occurrenceLineEdit->syntaxState() != SyntaxLineEdit::Valid)) {
|
||||
ok = false;
|
||||
}
|
||||
} else {
|
||||
ui->fieldNameLineEdit->clear();
|
||||
ui->fieldNameLineEdit->setSyntaxState(SyntaxLineEdit::Empty);
|
||||
ui->fieldsNameLineEdit->clear();
|
||||
ui->fieldsNameLineEdit->setSyntaxState(SyntaxLineEdit::Empty);
|
||||
ui->occurrenceLineEdit->clear();
|
||||
ui->occurrenceLineEdit->setSyntaxState(SyntaxLineEdit::Empty);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ void ColumnEditorFrame::editColumn(int column)
|
|||
{
|
||||
cur_column_ = column;
|
||||
ui->titleLineEdit->setText(get_column_title(column));
|
||||
saved_field_ = get_column_custom_field(column);
|
||||
saved_fields_ = get_column_custom_fields(column);
|
||||
saved_occurrence_ = QString::number(get_column_custom_occurrence(column));
|
||||
ui->typeComboBox->setCurrentIndex(get_column_format(column));
|
||||
setFields(ui->typeComboBox->currentIndex());
|
||||
|
@ -95,22 +95,22 @@ void ColumnEditorFrame::on_typeComboBox_activated(int index)
|
|||
setFields(index);
|
||||
}
|
||||
|
||||
void ColumnEditorFrame::on_fieldNameLineEdit_textEdited(const QString &field)
|
||||
void ColumnEditorFrame::on_fieldsNameLineEdit_textEdited(const QString &fields)
|
||||
{
|
||||
ui->fieldNameLineEdit->checkFieldName(field);
|
||||
ui->fieldsNameLineEdit->checkCustomColumn(fields);
|
||||
if (ui->typeComboBox->currentIndex() != COL_CUSTOM) {
|
||||
ui->typeComboBox->setCurrentIndex(COL_CUSTOM);
|
||||
ui->occurrenceLineEdit->setText(saved_occurrence_);
|
||||
}
|
||||
|
||||
bool ok = true;
|
||||
if ((ui->fieldNameLineEdit->syntaxState() == SyntaxLineEdit::Invalid) ||
|
||||
if ((ui->fieldsNameLineEdit->syntaxState() == SyntaxLineEdit::Invalid) ||
|
||||
((ui->typeComboBox->currentIndex() == COL_CUSTOM) &&
|
||||
(ui->occurrenceLineEdit->syntaxState() == SyntaxLineEdit::Empty)))
|
||||
ok = false;
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
|
||||
|
||||
saved_field_ = field;
|
||||
saved_fields_ = fields;
|
||||
}
|
||||
|
||||
void ColumnEditorFrame::on_occurrenceLineEdit_textEdited(const QString &occurrence)
|
||||
|
@ -118,7 +118,7 @@ void ColumnEditorFrame::on_occurrenceLineEdit_textEdited(const QString &occurren
|
|||
ui->occurrenceLineEdit->checkInteger(occurrence);
|
||||
if (ui->typeComboBox->currentIndex() != COL_CUSTOM) {
|
||||
ui->typeComboBox->setCurrentIndex(COL_CUSTOM);
|
||||
ui->fieldNameLineEdit->setText(saved_field_);
|
||||
ui->fieldsNameLineEdit->setText(saved_fields_);
|
||||
}
|
||||
|
||||
bool ok = true;
|
||||
|
@ -145,8 +145,8 @@ void ColumnEditorFrame::on_buttonBox_accepted()
|
|||
set_column_title(cur_column_, col_str.constData());
|
||||
set_column_format(cur_column_, ui->typeComboBox->currentIndex());
|
||||
if (ui->typeComboBox->currentIndex() == COL_CUSTOM) {
|
||||
col_str = ui->fieldNameLineEdit->text().toUtf8();
|
||||
set_column_custom_field(cur_column_, col_str.constData());
|
||||
col_str = ui->fieldsNameLineEdit->text().toUtf8();
|
||||
set_column_custom_fields(cur_column_, col_str.constData());
|
||||
if (!ui->occurrenceLineEdit->text().isEmpty()) {
|
||||
set_column_custom_occurrence(cur_column_, ui->occurrenceLineEdit->text().toInt());
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ signals:
|
|||
|
||||
private slots:
|
||||
void on_typeComboBox_activated(int index);
|
||||
void on_fieldNameLineEdit_textEdited(const QString &field);
|
||||
void on_fieldsNameLineEdit_textEdited(const QString &fields);
|
||||
void on_occurrenceLineEdit_textEdited(const QString &occurrence);
|
||||
void on_buttonBox_rejected();
|
||||
void on_buttonBox_accepted();
|
||||
|
@ -50,7 +50,7 @@ private slots:
|
|||
private:
|
||||
Ui::ColumnEditorFrame *ui;
|
||||
int cur_column_;
|
||||
QString saved_field_;
|
||||
QString saved_fields_;
|
||||
QString saved_occurrence_;
|
||||
void setFields(int index);
|
||||
};
|
||||
|
|
|
@ -75,12 +75,12 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Field Name</string>
|
||||
<string>Fields</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="SyntaxLineEdit" name="fieldNameLineEdit"/>
|
||||
<widget class="SyntaxLineEdit" name="fieldsNameLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
const int visible_col_ = 0;
|
||||
const int title_col_ = 1;
|
||||
const int type_col_ = 2;
|
||||
const int custom_field_col_ = 3;
|
||||
const int custom_fields_col_ = 3;
|
||||
const int custom_occurrence_col_ = 4;
|
||||
|
||||
ColumnPreferencesFrame::ColumnPreferencesFrame(QWidget *parent) :
|
||||
|
@ -58,7 +58,7 @@ ColumnPreferencesFrame::ColumnPreferencesFrame(QWidget *parent) :
|
|||
ui->setupUi(this);
|
||||
|
||||
int one_em = ui->columnTreeWidget->fontMetrics().height();
|
||||
ui->columnTreeWidget->setColumnWidth(custom_field_col_, one_em * 10);
|
||||
ui->columnTreeWidget->setColumnWidth(custom_fields_col_, one_em * 10);
|
||||
ui->columnTreeWidget->setColumnWidth(custom_occurrence_col_, one_em * 5);
|
||||
|
||||
ui->columnTreeWidget->setMinimumWidth(one_em * 20);
|
||||
|
@ -72,7 +72,7 @@ ColumnPreferencesFrame::ColumnPreferencesFrame(QWidget *parent) :
|
|||
|
||||
for (GList *cur = g_list_first(prefs.col_list); cur != NULL && cur->data != NULL; cur = cur->next) {
|
||||
fmt_data *cfmt = (fmt_data *) cur->data;
|
||||
addColumn(cfmt->visible, cfmt->title, cfmt->fmt, cfmt->custom_field, cfmt->custom_occurrence);
|
||||
addColumn(cfmt->visible, cfmt->title, cfmt->fmt, cfmt->custom_fields, cfmt->custom_occurrence);
|
||||
}
|
||||
|
||||
connect(ui->columnTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(updateWidgets()));
|
||||
|
@ -106,7 +106,7 @@ void ColumnPreferencesFrame::unstash()
|
|||
if (cfmt->fmt == COL_CUSTOM) {
|
||||
bool ok;
|
||||
int occurrence = (*it)->text(custom_occurrence_col_).toInt(&ok);
|
||||
cfmt->custom_field = qstring_strdup((*it)->text(custom_field_col_));
|
||||
cfmt->custom_fields = qstring_strdup((*it)->text(custom_fields_col_));
|
||||
cfmt->custom_occurrence = ok ? occurrence : 0;
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ void ColumnPreferencesFrame::unstash()
|
|||
old_cfmt->fmt != cfmt->fmt ||
|
||||
old_cfmt->visible != cfmt->visible ||
|
||||
(old_cfmt->fmt == COL_CUSTOM && (
|
||||
g_strcmp0(old_cfmt->custom_field, cfmt->custom_field) != 0 ||
|
||||
g_strcmp0(old_cfmt->custom_fields, cfmt->custom_fields) != 0 ||
|
||||
old_cfmt->custom_occurrence != cfmt->custom_occurrence))) {
|
||||
changed = true;
|
||||
}
|
||||
|
@ -156,8 +156,8 @@ void ColumnPreferencesFrame::keyPressEvent(QKeyEvent *evt)
|
|||
case title_col_:
|
||||
columnTitleEditingFinished();
|
||||
break;
|
||||
case custom_field_col_:
|
||||
customFieldEditingFinished();
|
||||
case custom_fields_col_:
|
||||
customFieldsEditingFinished();
|
||||
columnTypeCurrentIndexChanged(new_idx);
|
||||
break;
|
||||
case custom_occurrence_col_:
|
||||
|
@ -191,7 +191,7 @@ void ColumnPreferencesFrame::keyPressEvent(QKeyEvent *evt)
|
|||
QFrame::keyPressEvent(evt);
|
||||
}
|
||||
|
||||
void ColumnPreferencesFrame::addColumn(bool visible, const char *title, int fmt, const char *custom_field, int custom_occurrence)
|
||||
void ColumnPreferencesFrame::addColumn(bool visible, const char *title, int fmt, const char *custom_fields, int custom_occurrence)
|
||||
{
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(ui->columnTreeWidget);
|
||||
|
||||
|
@ -202,7 +202,7 @@ void ColumnPreferencesFrame::addColumn(bool visible, const char *title, int fmt,
|
|||
item->setText(type_col_, col_format_desc(fmt));
|
||||
item->setData(type_col_, Qt::UserRole, QVariant(fmt));
|
||||
if (fmt == COL_CUSTOM) {
|
||||
item->setText(custom_field_col_, custom_field);
|
||||
item->setText(custom_fields_col_, custom_fields);
|
||||
item->setText(custom_occurrence_col_, QString::number(custom_occurrence));
|
||||
}
|
||||
|
||||
|
@ -228,8 +228,8 @@ void ColumnPreferencesFrame::on_columnTreeWidget_currentItemChanged(QTreeWidgetI
|
|||
ui->columnTreeWidget->removeItemWidget(previous, type_col_);
|
||||
previous->setText(type_col_, col_format_desc(previous->data(type_col_, Qt::UserRole).toInt()));
|
||||
}
|
||||
if (previous && ui->columnTreeWidget->itemWidget(previous, custom_field_col_)) {
|
||||
ui->columnTreeWidget->removeItemWidget(previous, custom_field_col_);
|
||||
if (previous && ui->columnTreeWidget->itemWidget(previous, custom_fields_col_)) {
|
||||
ui->columnTreeWidget->removeItemWidget(previous, custom_fields_col_);
|
||||
}
|
||||
if (previous && ui->columnTreeWidget->itemWidget(previous, custom_occurrence_col_)) {
|
||||
ui->columnTreeWidget->removeItemWidget(previous, custom_occurrence_col_);
|
||||
|
@ -269,13 +269,13 @@ void ColumnPreferencesFrame::on_columnTreeWidget_itemActivated(QTreeWidgetItem *
|
|||
editor = cur_combo_box_;
|
||||
break;
|
||||
}
|
||||
case custom_field_col_:
|
||||
case custom_fields_col_:
|
||||
{
|
||||
SyntaxLineEdit *syntax_edit = new SyntaxLineEdit();
|
||||
saved_col_string_ = item->text(custom_field_col_);
|
||||
saved_col_string_ = item->text(custom_fields_col_);
|
||||
connect(syntax_edit, SIGNAL(textChanged(QString)),
|
||||
syntax_edit, SLOT(checkFieldName(QString)));
|
||||
connect(syntax_edit, SIGNAL(editingFinished()), this, SLOT(customFieldEditingFinished()));
|
||||
syntax_edit, SLOT(checkCustomColumn(QString)));
|
||||
connect(syntax_edit, SIGNAL(editingFinished()), this, SLOT(customFieldsEditingFinished()));
|
||||
editor = cur_line_edit_ = syntax_edit;
|
||||
|
||||
saved_combo_idx_ = item->data(type_col_, Qt::UserRole).toInt();
|
||||
|
@ -358,18 +358,18 @@ void ColumnPreferencesFrame::columnTypeCurrentIndexChanged(int index)
|
|||
item->setText(type_col_, col_format_desc(index));
|
||||
|
||||
if (index != COL_CUSTOM) {
|
||||
item->setText(custom_field_col_, "");
|
||||
item->setText(custom_fields_col_, "");
|
||||
item->setText(custom_occurrence_col_, "");
|
||||
}
|
||||
}
|
||||
|
||||
void ColumnPreferencesFrame::customFieldEditingFinished()
|
||||
void ColumnPreferencesFrame::customFieldsEditingFinished()
|
||||
{
|
||||
QTreeWidgetItem *item = ui->columnTreeWidget->currentItem();
|
||||
if (!cur_line_edit_ || !item) return;
|
||||
|
||||
item->setText(custom_field_col_, cur_line_edit_->text());
|
||||
ui->columnTreeWidget->removeItemWidget(item, custom_field_col_);
|
||||
item->setText(custom_fields_col_, cur_line_edit_->text());
|
||||
ui->columnTreeWidget->removeItemWidget(item, custom_fields_col_);
|
||||
}
|
||||
|
||||
void ColumnPreferencesFrame::customOccurrenceEditingFinished()
|
||||
|
|
|
@ -54,7 +54,7 @@ private:
|
|||
QComboBox *cur_combo_box_;
|
||||
int saved_combo_idx_;
|
||||
|
||||
void addColumn(bool visible, const char *title, int fmt, const char *custom_field, int custom_occurrence);
|
||||
void addColumn(bool visible, const char *title, int fmt, const char *custom_fields, int custom_occurrence);
|
||||
|
||||
private slots:
|
||||
void updateWidgets(void);
|
||||
|
@ -64,7 +64,7 @@ private slots:
|
|||
void comboDestroyed();
|
||||
void columnTitleEditingFinished();
|
||||
void columnTypeCurrentIndexChanged(int index);
|
||||
void customFieldEditingFinished();
|
||||
void customFieldsEditingFinished();
|
||||
void customOccurrenceEditingFinished();
|
||||
void on_newToolButton_clicked();
|
||||
void on_deleteToolButton_clicked();
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Field Name</string>
|
||||
<string>Fields</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
|
|
|
@ -848,7 +848,7 @@ void PacketList::writeRecent(FILE *rf) {
|
|||
}
|
||||
col_fmt = get_column_format(col);
|
||||
if (col_fmt == COL_CUSTOM) {
|
||||
fprintf (rf, " %%Cus:%s,", get_column_custom_field(col));
|
||||
fprintf (rf, " %%Cus:%s,", get_column_custom_fields(col));
|
||||
} else {
|
||||
fprintf (rf, " %s,", col_format_to_string(col_fmt));
|
||||
}
|
||||
|
@ -903,7 +903,7 @@ QString PacketList::getFilterFromRowAndColumn()
|
|||
if (strlen(cap_file_->cinfo.col_expr.col_expr[ctx_column_]) != 0 &&
|
||||
strlen(cap_file_->cinfo.col_expr.col_expr_val[ctx_column_]) != 0) {
|
||||
if (cap_file_->cinfo.columns[ctx_column_].col_fmt == COL_CUSTOM) {
|
||||
header_field_info *hfi = proto_registrar_get_byname(cap_file_->cinfo.columns[ctx_column_].col_custom_field);
|
||||
header_field_info *hfi = proto_registrar_get_byname(cap_file_->cinfo.columns[ctx_column_].col_custom_fields);
|
||||
if (hfi && hfi->parent == -1) {
|
||||
/* Protocol only */
|
||||
filter.append(cap_file_->cinfo.col_expr.col_expr[ctx_column_]);
|
||||
|
|
|
@ -370,7 +370,7 @@ bool PacketListModel::recordLessThan(PacketListRecord *r1, PacketListRecord *r2)
|
|||
header_field_info *hfi;
|
||||
|
||||
// Column comes from custom data
|
||||
hfi = proto_registrar_get_byname(sort_cap_file_->cinfo.columns[sort_column_].col_custom_field);
|
||||
hfi = proto_registrar_get_byname(sort_cap_file_->cinfo.columns[sort_column_].col_custom_fields);
|
||||
|
||||
if (hfi == NULL) {
|
||||
cmp_val = frame_data_compare(sort_cap_file_->epan, r1->frameData(), r2->frameData(), COL_NUMBER);
|
||||
|
|
|
@ -180,6 +180,32 @@ void SyntaxLineEdit::checkFieldName(QString field)
|
|||
}
|
||||
}
|
||||
|
||||
void SyntaxLineEdit::checkCustomColumn(QString fields)
|
||||
{
|
||||
gchar **splitted_fields;
|
||||
guint i_field;
|
||||
if (fields.isEmpty()) {
|
||||
setSyntaxState(SyntaxLineEdit::Empty);
|
||||
return;
|
||||
}
|
||||
|
||||
splitted_fields = g_regex_split_simple(" *([^ \\|]+) *(?:(?:\\|\\|)|(?:or))? *",
|
||||
fields.toUtf8().constData(), G_REGEX_ANCHORED, G_REGEX_MATCH_ANCHORED);
|
||||
|
||||
for (i_field =0; i_field < g_strv_length(splitted_fields); i_field += 1) {
|
||||
if (splitted_fields[i_field] && *splitted_fields[i_field]) {
|
||||
if (proto_check_field_name(splitted_fields[i_field]) != 0) {
|
||||
setSyntaxState(SyntaxLineEdit::Invalid);
|
||||
g_strfreev(splitted_fields);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
g_strfreev(splitted_fields);
|
||||
|
||||
checkDisplayFilter(fields);
|
||||
}
|
||||
|
||||
void SyntaxLineEdit::checkInteger(QString number)
|
||||
{
|
||||
if (number.isEmpty()) {
|
||||
|
|
|
@ -57,6 +57,7 @@ public slots:
|
|||
// Built-in syntax checks. Connect textChanged to these as needed.
|
||||
void checkDisplayFilter(QString filter);
|
||||
void checkFieldName(QString field);
|
||||
void checkCustomColumn(QString fields);
|
||||
void checkInteger(QString number);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1355,7 +1355,7 @@ recent_get_column_width(gint col)
|
|||
|
||||
cfmt = get_column_format(col);
|
||||
if (cfmt == COL_CUSTOM) {
|
||||
cfield = get_column_custom_field(col);
|
||||
cfield = get_column_custom_fields(col);
|
||||
}
|
||||
|
||||
col_l = g_list_first(recent.col_width_list);
|
||||
|
@ -1383,7 +1383,7 @@ recent_set_column_width(gint col, gint width)
|
|||
|
||||
cfmt = get_column_format(col);
|
||||
if (cfmt == COL_CUSTOM) {
|
||||
cfield = get_column_custom_field(col);
|
||||
cfield = get_column_custom_fields(col);
|
||||
}
|
||||
|
||||
col_l = g_list_first(recent.col_width_list);
|
||||
|
@ -1423,7 +1423,7 @@ recent_get_column_xalign(gint col)
|
|||
|
||||
cfmt = get_column_format(col);
|
||||
if (cfmt == COL_CUSTOM) {
|
||||
cfield = get_column_custom_field(col);
|
||||
cfield = get_column_custom_fields(col);
|
||||
}
|
||||
|
||||
col_l = g_list_first(recent.col_width_list);
|
||||
|
@ -1451,7 +1451,7 @@ recent_set_column_xalign(gint col, gchar xalign)
|
|||
|
||||
cfmt = get_column_format(col);
|
||||
if (cfmt == COL_CUSTOM) {
|
||||
cfield = get_column_custom_field(col);
|
||||
cfield = get_column_custom_fields(col);
|
||||
}
|
||||
|
||||
col_l = g_list_first(recent.col_width_list);
|
||||
|
|
Loading…
Reference in New Issue