forked from osmocom/wireshark
Add button in Qt UAT dialog/frame to remove all UAT entries at once.
Change-Id: If5a172cd69beeb0b9a22eb7f6b9e7cb25f350b49 Reviewed-on: https://code.wireshark.org/review/23968 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
4e3114d01d
commit
61380f9504
|
@ -3990,3 +3990,5 @@ Martin Pool <mbp[AT]sourcefrog.net>.
|
||||||
|
|
||||||
Emanuel Eichhammer <support[AT]qcustomplot.com> granted permission
|
Emanuel Eichhammer <support[AT]qcustomplot.com> granted permission
|
||||||
to use QCustomPlot.
|
to use QCustomPlot.
|
||||||
|
|
||||||
|
Some icons made by Freepik, http://www.freepik.com from https://www.flaticon.com
|
||||||
|
|
|
@ -61,3 +61,5 @@ plus-8.png macOS style add / remove icons. Created by Peter Hosey.
|
||||||
minus-8.png Released under CC-PD.
|
minus-8.png Released under CC-PD.
|
||||||
|
|
||||||
copy-8.png macOS style copy icon.
|
copy-8.png macOS style copy icon.
|
||||||
|
|
||||||
|
delete_list.png by Freepik, http://www.freepik.com from https://www.flaticon.com
|
Binary file not shown.
After Width: | Height: | Size: 564 B |
|
@ -7,6 +7,7 @@
|
||||||
<file>minus-8.png</file>
|
<file>minus-8.png</file>
|
||||||
<file>plus-8.png</file>
|
<file>plus-8.png</file>
|
||||||
<file>copy-8.png</file>
|
<file>copy-8.png</file>
|
||||||
|
<file>delete_list.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/icons">
|
<qresource prefix="/icons">
|
||||||
<file>toolbar/14x14/x-capture-comment-update.png</file>
|
<file>toolbar/14x14/x-capture-comment-update.png</file>
|
||||||
|
|
|
@ -333,6 +333,20 @@ bool UatModel::removeRows(int row, int count, const QModelIndex &/*parent*/)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UatModel::clearAll()
|
||||||
|
{
|
||||||
|
if (rowCount() < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
beginResetModel();
|
||||||
|
uat_clear(uat_);
|
||||||
|
record_errors.clear();
|
||||||
|
dirty_records.clear();
|
||||||
|
uat_->changed = TRUE;
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool UatModel::copyRow(int dst_row, int src_row)
|
bool UatModel::copyRow(int dst_row, int src_row)
|
||||||
{
|
{
|
||||||
if (src_row < 0 || src_row >= rowCount() || dst_row < 0 || dst_row >= rowCount()) {
|
if (src_row < 0 || src_row >= rowCount() || dst_row < 0 || dst_row >= rowCount()) {
|
||||||
|
|
|
@ -55,6 +55,7 @@ public:
|
||||||
|
|
||||||
bool copyRow(int dst_row, int src_row);
|
bool copyRow(int dst_row, int src_row);
|
||||||
bool hasErrors() const;
|
bool hasErrors() const;
|
||||||
|
void clearAll();
|
||||||
|
|
||||||
QModelIndex findRowForColumnContent(QVariant columnContent, int columnToCheckAgainst, int role = Qt::DisplayRole);
|
QModelIndex findRowForColumnContent(QVariant columnContent, int columnToCheckAgainst, int role = Qt::DisplayRole);
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ UatDialog::UatDialog(QWidget *parent, epan_uat *uat) :
|
||||||
|
|
||||||
ui->deleteToolButton->setEnabled(false);
|
ui->deleteToolButton->setEnabled(false);
|
||||||
ui->copyToolButton->setEnabled(false);
|
ui->copyToolButton->setEnabled(false);
|
||||||
|
ui->clearToolButton->setEnabled(false);
|
||||||
ok_button_ = ui->buttonBox->button(QDialogButtonBox::Ok);
|
ok_button_ = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
help_button_ = ui->buttonBox->button(QDialogButtonBox::Help);
|
help_button_ = ui->buttonBox->button(QDialogButtonBox::Help);
|
||||||
|
|
||||||
|
@ -57,6 +58,7 @@ UatDialog::UatDialog(QWidget *parent, epan_uat *uat) :
|
||||||
ui->newToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
ui->newToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
||||||
ui->deleteToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
ui->deleteToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
||||||
ui->copyToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
ui->copyToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
||||||
|
ui->clearToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
||||||
ui->pathLabel->setAttribute(Qt::WA_MacSmallSize, true);
|
ui->pathLabel->setAttribute(Qt::WA_MacSmallSize, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -119,6 +121,8 @@ void UatDialog::setUat(epan_uat *uat)
|
||||||
this, SLOT(modelDataChanged(QModelIndex)));
|
this, SLOT(modelDataChanged(QModelIndex)));
|
||||||
connect(uat_model_, SIGNAL(rowsRemoved(QModelIndex, int, int)),
|
connect(uat_model_, SIGNAL(rowsRemoved(QModelIndex, int, int)),
|
||||||
this, SLOT(modelRowsRemoved()));
|
this, SLOT(modelRowsRemoved()));
|
||||||
|
connect(uat_model_, SIGNAL(modelReset()), this, SLOT(modelRowsReset()));
|
||||||
|
|
||||||
ok_button_->setEnabled(!uat_model_->hasErrors());
|
ok_button_->setEnabled(!uat_model_->hasErrors());
|
||||||
|
|
||||||
if (uat_->help && strlen(uat_->help) > 0) {
|
if (uat_->help && strlen(uat_->help) > 0) {
|
||||||
|
@ -147,15 +151,25 @@ void UatDialog::modelRowsRemoved()
|
||||||
ok_button_->setEnabled(!uat_model_->hasErrors());
|
ok_button_->setEnabled(!uat_model_->hasErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UatDialog::modelRowsReset()
|
||||||
|
{
|
||||||
|
ui->deleteToolButton->setEnabled(false);
|
||||||
|
ui->clearToolButton->setEnabled(false);
|
||||||
|
ui->copyToolButton->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Invoked when a different field is selected. Note: when selecting a different
|
// Invoked when a different field is selected. Note: when selecting a different
|
||||||
// field after editing, this event is triggered after modelDataChanged.
|
// field after editing, this event is triggered after modelDataChanged.
|
||||||
void UatDialog::on_uatTreeView_currentItemChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
void UatDialog::on_uatTreeView_currentItemChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||||
{
|
{
|
||||||
if (current.isValid()) {
|
if (current.isValid()) {
|
||||||
ui->deleteToolButton->setEnabled(true);
|
ui->deleteToolButton->setEnabled(true);
|
||||||
|
ui->clearToolButton->setEnabled(true);
|
||||||
ui->copyToolButton->setEnabled(true);
|
ui->copyToolButton->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
ui->deleteToolButton->setEnabled(false);
|
ui->deleteToolButton->setEnabled(false);
|
||||||
|
ui->clearToolButton->setEnabled(false);
|
||||||
ui->copyToolButton->setEnabled(false);
|
ui->copyToolButton->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,6 +262,13 @@ void UatDialog::on_copyToolButton_clicked()
|
||||||
addRecord(true);
|
addRecord(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UatDialog::on_clearToolButton_clicked()
|
||||||
|
{
|
||||||
|
if (uat_model_) {
|
||||||
|
uat_model_->clearAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UatDialog::applyChanges()
|
void UatDialog::applyChanges()
|
||||||
{
|
{
|
||||||
if (!uat_) return;
|
if (!uat_) return;
|
||||||
|
|
|
@ -52,12 +52,14 @@ public:
|
||||||
private slots:
|
private slots:
|
||||||
void modelDataChanged(const QModelIndex &topLeft);
|
void modelDataChanged(const QModelIndex &topLeft);
|
||||||
void modelRowsRemoved();
|
void modelRowsRemoved();
|
||||||
|
void modelRowsReset();
|
||||||
void on_uatTreeView_currentItemChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
void on_uatTreeView_currentItemChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
void acceptChanges();
|
void acceptChanges();
|
||||||
void rejectChanges();
|
void rejectChanges();
|
||||||
void on_newToolButton_clicked();
|
void on_newToolButton_clicked();
|
||||||
void on_deleteToolButton_clicked();
|
void on_deleteToolButton_clicked();
|
||||||
void on_copyToolButton_clicked();
|
void on_copyToolButton_clicked();
|
||||||
|
void on_clearToolButton_clicked();
|
||||||
void on_buttonBox_helpRequested();
|
void on_buttonBox_helpRequested();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -77,6 +77,21 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="clearToolButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Clear all entries.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../image/toolbar.qrc">
|
||||||
|
<normaloff>:/stock/delete_list.png</normaloff>:/stock/delete_list.png
|
||||||
|
</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
@ -53,6 +53,7 @@ UatFrame::UatFrame(QWidget *parent) :
|
||||||
ui->newToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
ui->newToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
||||||
ui->deleteToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
ui->deleteToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
||||||
ui->copyToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
ui->copyToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
||||||
|
ui->clearToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
||||||
ui->pathLabel->setAttribute(Qt::WA_MacSmallSize, true);
|
ui->pathLabel->setAttribute(Qt::WA_MacSmallSize, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -110,6 +111,7 @@ void UatFrame::setUat(epan_uat *uat)
|
||||||
this, SLOT(modelDataChanged(QModelIndex)));
|
this, SLOT(modelDataChanged(QModelIndex)));
|
||||||
connect(uat_model_, SIGNAL(rowsRemoved(QModelIndex, int, int)),
|
connect(uat_model_, SIGNAL(rowsRemoved(QModelIndex, int, int)),
|
||||||
this, SLOT(modelRowsRemoved()));
|
this, SLOT(modelRowsRemoved()));
|
||||||
|
connect(uat_model_, SIGNAL(modelReset()), this, SLOT(modelRowsReset()));
|
||||||
}
|
}
|
||||||
|
|
||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
|
@ -193,9 +195,11 @@ void UatFrame::on_uatTreeView_currentItemChanged(const QModelIndex ¤t, con
|
||||||
{
|
{
|
||||||
if (current.isValid()) {
|
if (current.isValid()) {
|
||||||
ui->deleteToolButton->setEnabled(true);
|
ui->deleteToolButton->setEnabled(true);
|
||||||
|
ui->clearToolButton->setEnabled(true);
|
||||||
ui->copyToolButton->setEnabled(true);
|
ui->copyToolButton->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
ui->deleteToolButton->setEnabled(false);
|
ui->deleteToolButton->setEnabled(false);
|
||||||
|
ui->clearToolButton->setEnabled(false);
|
||||||
ui->copyToolButton->setEnabled(false);
|
ui->copyToolButton->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +219,13 @@ void UatFrame::modelRowsRemoved()
|
||||||
checkForErrorHint(current, QModelIndex());
|
checkForErrorHint(current, QModelIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UatFrame::modelRowsReset()
|
||||||
|
{
|
||||||
|
ui->deleteToolButton->setEnabled(false);
|
||||||
|
ui->clearToolButton->setEnabled(false);
|
||||||
|
ui->copyToolButton->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
// If the current field has errors, show them.
|
// If the current field has errors, show them.
|
||||||
// Otherwise if the row has not changed, but the previous field has errors, show them.
|
// Otherwise if the row has not changed, but the previous field has errors, show them.
|
||||||
// Otherwise pick the first error in the current row.
|
// Otherwise pick the first error in the current row.
|
||||||
|
@ -279,6 +290,12 @@ void UatFrame::on_copyToolButton_clicked()
|
||||||
addRecord(true);
|
addRecord(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UatFrame::on_clearToolButton_clicked()
|
||||||
|
{
|
||||||
|
if (uat_model_) {
|
||||||
|
uat_model_->clearAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Editor modelines
|
* Editor modelines
|
||||||
*
|
*
|
||||||
|
|
|
@ -60,10 +60,12 @@ private:
|
||||||
private slots:
|
private slots:
|
||||||
void modelDataChanged(const QModelIndex &topLeft);
|
void modelDataChanged(const QModelIndex &topLeft);
|
||||||
void modelRowsRemoved();
|
void modelRowsRemoved();
|
||||||
|
void modelRowsReset();
|
||||||
void on_uatTreeView_currentItemChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
void on_uatTreeView_currentItemChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
void on_newToolButton_clicked();
|
void on_newToolButton_clicked();
|
||||||
void on_deleteToolButton_clicked();
|
void on_deleteToolButton_clicked();
|
||||||
void on_copyToolButton_clicked();
|
void on_copyToolButton_clicked();
|
||||||
|
void on_clearToolButton_clicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UAT_FRAME_H
|
#endif // UAT_FRAME_H
|
||||||
|
|
|
@ -95,6 +95,21 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="clearToolButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Clear all entries.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../image/toolbar.qrc">
|
||||||
|
<normaloff>:/stock/delete_list.png</normaloff>:/stock/delete_list.png
|
||||||
|
</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
Loading…
Reference in New Issue