forked from osmocom/wireshark
Qt: Add resolved button to Edit Columns
Add the ability to set custom columns as resolved/unresolved via the Edit Column frame, if the column fields support it. Related to #15394.
This commit is contained in:
parent
774a7f0eee
commit
09800da792
|
@ -228,6 +228,35 @@ column_prefs_has_custom(const gchar *custom_field)
|
|||
return colnr;
|
||||
}
|
||||
|
||||
gboolean
|
||||
column_prefs_custom_resolve(const gchar* custom_field)
|
||||
{
|
||||
gchar **fields;
|
||||
header_field_info *hfi;
|
||||
bool resolve = false;
|
||||
|
||||
fields = g_regex_split_simple(COL_CUSTOM_PRIME_REGEX, custom_field,
|
||||
(GRegexCompileFlags) (G_REGEX_ANCHORED | G_REGEX_RAW),
|
||||
G_REGEX_MATCH_ANCHORED);
|
||||
|
||||
for (guint i = 0; i < g_strv_length(fields); i++) {
|
||||
if (fields[i] && *fields[i]) {
|
||||
hfi = proto_registrar_get_byname(fields[i]);
|
||||
if (hfi && ((hfi->type == FT_OID) || (hfi->type == FT_REL_OID) || (hfi->type == FT_BOOLEAN) ||
|
||||
((hfi->strings != NULL) &&
|
||||
(IS_FT_INT(hfi->type) || IS_FT_UINT(hfi->type)))))
|
||||
{
|
||||
resolve = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_strfreev(fields);
|
||||
|
||||
return resolve;
|
||||
}
|
||||
|
||||
void
|
||||
column_prefs_remove_link(GList *col_link)
|
||||
{
|
||||
|
|
|
@ -80,6 +80,21 @@ gint column_prefs_add_custom(gint fmt, const gchar *title,
|
|||
*/
|
||||
gint column_prefs_has_custom(const gchar *custom_field);
|
||||
|
||||
/** Check if a custom column's data can be displayed differently
|
||||
* resolved or unresolved, e.g. it has a field with a value string.
|
||||
*
|
||||
* This is for when adding or editing custom columns. Compare with
|
||||
* resolve_column() in packet_list_utils.h, which is for columns
|
||||
* that have already been added.
|
||||
*
|
||||
* @param custom_field column custom field
|
||||
*
|
||||
* @return TRUE if a custom column with the field description
|
||||
* would support being displayed differently resolved or unresolved,
|
||||
* FALSE otherwise.
|
||||
*/
|
||||
gboolean column_prefs_custom_resolve(const gchar *custom_field);
|
||||
|
||||
/** Remove a column.
|
||||
*
|
||||
* @param col_link Column list entry
|
||||
|
|
|
@ -46,6 +46,8 @@ ColumnEditorFrame::ColumnEditorFrame(QWidget *parent) :
|
|||
|
||||
connect(ui->fieldsNameLineEdit, &FieldFilterEdit::textChanged,
|
||||
ui->fieldsNameLineEdit, &FieldFilterEdit::checkCustomColumn);
|
||||
connect(ui->fieldsNameLineEdit, &FieldFilterEdit::textChanged,
|
||||
this, &ColumnEditorFrame::checkCanResolve);
|
||||
}
|
||||
|
||||
ColumnEditorFrame::~ColumnEditorFrame()
|
||||
|
@ -76,6 +78,7 @@ void ColumnEditorFrame::setFields(int index)
|
|||
ui->fieldsNameLineEdit->setSyntaxState(SyntaxLineEdit::Empty);
|
||||
ui->occurrenceLineEdit->clear();
|
||||
ui->occurrenceLineEdit->setSyntaxState(SyntaxLineEdit::Empty);
|
||||
ui->resolvedCheckBox->setEnabled(false);
|
||||
}
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
|
||||
}
|
||||
|
@ -87,6 +90,7 @@ void ColumnEditorFrame::editColumn(int column)
|
|||
saved_fields_ = get_column_custom_fields(column);
|
||||
saved_occurrence_ = QString::number(get_column_custom_occurrence(column));
|
||||
ui->typeComboBox->setCurrentIndex(get_column_format(column));
|
||||
ui->resolvedCheckBox->setChecked(get_column_resolved(column));
|
||||
setFields(ui->typeComboBox->currentIndex());
|
||||
}
|
||||
|
||||
|
@ -152,6 +156,9 @@ void ColumnEditorFrame::on_buttonBox_accepted()
|
|||
if (!ui->occurrenceLineEdit->text().isEmpty()) {
|
||||
set_column_custom_occurrence(cur_column_, ui->occurrenceLineEdit->text().toInt());
|
||||
}
|
||||
if (ui->resolvedCheckBox->isEnabled()) {
|
||||
set_column_resolved(cur_column_, ui->resolvedCheckBox->isChecked());
|
||||
}
|
||||
}
|
||||
prefs_main_write();
|
||||
emit columnEdited();
|
||||
|
@ -180,3 +187,12 @@ void ColumnEditorFrame::keyPressEvent(QKeyEvent *event)
|
|||
|
||||
AccordionFrame::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void ColumnEditorFrame::checkCanResolve()
|
||||
{
|
||||
if (ui->fieldsNameLineEdit->syntaxState() == SyntaxLineEdit::Valid && column_prefs_custom_resolve(ui->fieldsNameLineEdit->text().toUtf8().constData())) {
|
||||
ui->resolvedCheckBox->setEnabled(true);
|
||||
} else {
|
||||
ui->resolvedCheckBox->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class ColumnEditorFrame : public AccordionFrame
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ColumnEditorFrame(QWidget *parent = 0);
|
||||
explicit ColumnEditorFrame(QWidget *parent = nullptr);
|
||||
~ColumnEditorFrame();
|
||||
void editColumn(int column);
|
||||
|
||||
|
@ -38,6 +38,7 @@ private slots:
|
|||
void on_occurrenceLineEdit_textEdited(const QString &occurrence);
|
||||
void on_buttonBox_rejected();
|
||||
void on_buttonBox_accepted();
|
||||
void checkCanResolve(void);
|
||||
|
||||
private:
|
||||
bool syntaxIsValid(void);
|
||||
|
|
|
@ -105,6 +105,19 @@
|
|||
<item>
|
||||
<widget class="SyntaxLineEdit" name="occurrenceLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="resolvedCheckBox">
|
||||
<property name="text">
|
||||
<string>Resolve Names:</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><p>Show human-readable strings instead of raw values for fields. Only applicable to custom columns with fields that have value strings.</p></body></html></string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
|
|
Loading…
Reference in New Issue