forked from osmocom/wireshark
Qt: fixes to 'Edit Column' dialog
- set field name and occurrence when editing a custom column - convert occurrence number to a QString - disable OK button when syntax is incorrect or empty for a custom column - update syntax state when opening the edit dialog or when switching between custom and normal column Bug: 11433 Change-Id: Ia8424474dd250c78a0b503e0e9d89c322f4f86a9 Reviewed-on: https://code.wireshark.org/review/11705 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
This commit is contained in:
parent
5f4c9b2bb2
commit
a4981a279a
|
@ -57,24 +57,41 @@ ColumnEditorFrame::~ColumnEditorFrame()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void ColumnEditorFrame::setFields(int index)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
if (index == COL_CUSTOM) {
|
||||
ui->fieldNameLineEdit->setText(saved_field_);
|
||||
ui->fieldNameLineEdit->checkFieldName(saved_field_);
|
||||
ui->occurrenceLineEdit->setText(saved_occurrence_);
|
||||
ui->occurrenceLineEdit->checkInteger(saved_occurrence_);
|
||||
if ((ui->fieldNameLineEdit->syntaxState() != SyntaxLineEdit::Valid) ||
|
||||
(ui->occurrenceLineEdit->syntaxState() != SyntaxLineEdit::Valid)) {
|
||||
ok = false;
|
||||
}
|
||||
} else {
|
||||
ui->fieldNameLineEdit->clear();
|
||||
ui->fieldNameLineEdit->setSyntaxState(SyntaxLineEdit::Empty);
|
||||
ui->occurrenceLineEdit->clear();
|
||||
ui->occurrenceLineEdit->setSyntaxState(SyntaxLineEdit::Empty);
|
||||
}
|
||||
ui->okButton->setEnabled(ok);
|
||||
}
|
||||
|
||||
void ColumnEditorFrame::editColumn(int column)
|
||||
{
|
||||
cur_column_ = column;
|
||||
ui->titleLineEdit->setText(get_column_title(column));
|
||||
saved_field_ = get_column_custom_field(column);
|
||||
saved_occurrence_ = get_column_custom_occurrence(column);
|
||||
saved_occurrence_ = QString::number(get_column_custom_occurrence(column));
|
||||
ui->typeComboBox->setCurrentIndex(get_column_format(column));
|
||||
setFields(ui->typeComboBox->currentIndex());
|
||||
}
|
||||
|
||||
void ColumnEditorFrame::on_typeComboBox_activated(int index)
|
||||
{
|
||||
if (index == COL_CUSTOM) {
|
||||
ui->fieldNameLineEdit->setText(saved_field_);
|
||||
ui->occurrenceLineEdit->setText(saved_occurrence_);
|
||||
} else {
|
||||
ui->fieldNameLineEdit->clear();
|
||||
ui->occurrenceLineEdit->clear();
|
||||
}
|
||||
setFields(index);
|
||||
}
|
||||
|
||||
void ColumnEditorFrame::on_fieldNameLineEdit_textEdited(const QString &field)
|
||||
|
@ -86,7 +103,10 @@ void ColumnEditorFrame::on_fieldNameLineEdit_textEdited(const QString &field)
|
|||
}
|
||||
|
||||
bool ok = true;
|
||||
if (ui->fieldNameLineEdit->syntaxState() == SyntaxLineEdit::Invalid) ok = false;
|
||||
if ((ui->fieldNameLineEdit->syntaxState() == SyntaxLineEdit::Invalid) ||
|
||||
((ui->typeComboBox->currentIndex() == COL_CUSTOM) &&
|
||||
(ui->occurrenceLineEdit->syntaxState() == SyntaxLineEdit::Empty)))
|
||||
ok = false;
|
||||
ui->okButton->setEnabled(ok);
|
||||
|
||||
saved_field_ = field;
|
||||
|
@ -101,7 +121,10 @@ void ColumnEditorFrame::on_occurrenceLineEdit_textEdited(const QString &occurren
|
|||
}
|
||||
|
||||
bool ok = true;
|
||||
if (ui->occurrenceLineEdit->syntaxState() == SyntaxLineEdit::Invalid) ok = false;
|
||||
if ((ui->occurrenceLineEdit->syntaxState() == SyntaxLineEdit::Invalid) ||
|
||||
((ui->typeComboBox->currentIndex() == COL_CUSTOM) &&
|
||||
(ui->occurrenceLineEdit->syntaxState() == SyntaxLineEdit::Empty)))
|
||||
ok = false;
|
||||
ui->okButton->setEnabled(ok);
|
||||
|
||||
saved_occurrence_ = occurrence;
|
||||
|
|
|
@ -49,10 +49,10 @@ private slots:
|
|||
|
||||
private:
|
||||
Ui::ColumnEditorFrame *ui;
|
||||
|
||||
int cur_column_;
|
||||
QString saved_field_;
|
||||
QString saved_occurrence_;
|
||||
void setFields(int index);
|
||||
};
|
||||
|
||||
#endif // COLUMN_EDITOR_FRAME_H
|
||||
|
|
Loading…
Reference in New Issue