forked from osmocom/wireshark
Qt: Add clear all button to Decode As
Add a clear all button to easily remove all existing entries. Change-Id: I76e7ee2b7b85a9b4e5f9f5a788a89f38f70ee8ce Reviewed-on: https://code.wireshark.org/review/30052 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
6e22ecbc20
commit
b3cb942dbc
|
@ -50,6 +50,9 @@ DecodeAsDialog::DecodeAsDialog(QWidget *parent, capture_file *cf, bool create_ne
|
|||
|
||||
fillTable();
|
||||
|
||||
connect(model_, SIGNAL(modelReset()), this, SLOT(modelRowsReset()));
|
||||
ui->clearToolButton->setEnabled(model_->rowCount() > 0);
|
||||
|
||||
if (create_new)
|
||||
on_newToolButton_clicked();
|
||||
}
|
||||
|
@ -83,14 +86,23 @@ void DecodeAsDialog::resizeColumns()
|
|||
}
|
||||
}
|
||||
|
||||
void DecodeAsDialog::modelRowsReset()
|
||||
{
|
||||
ui->deleteToolButton->setEnabled(false);
|
||||
ui->copyToolButton->setEnabled(false);
|
||||
ui->clearToolButton->setEnabled(false);
|
||||
}
|
||||
|
||||
void DecodeAsDialog::on_decodeAsTreeView_currentItemChanged(const QModelIndex ¤t, const QModelIndex&)
|
||||
{
|
||||
if (current.isValid()) {
|
||||
ui->deleteToolButton->setEnabled(true);
|
||||
ui->copyToolButton->setEnabled(true);
|
||||
ui->clearToolButton->setEnabled(true);
|
||||
} else {
|
||||
ui->deleteToolButton->setEnabled(false);
|
||||
ui->copyToolButton->setEnabled(false);
|
||||
ui->clearToolButton->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,6 +150,11 @@ void DecodeAsDialog::on_copyToolButton_clicked()
|
|||
addRecord(true);
|
||||
}
|
||||
|
||||
void DecodeAsDialog::on_clearToolButton_clicked()
|
||||
{
|
||||
model_->clearAll();
|
||||
}
|
||||
|
||||
void DecodeAsDialog::applyChanges()
|
||||
{
|
||||
model_->applyChanges();
|
||||
|
|
|
@ -47,12 +47,16 @@ private:
|
|||
void fillTable();
|
||||
void resizeColumns();
|
||||
|
||||
public slots:
|
||||
void modelRowsReset();
|
||||
|
||||
private slots:
|
||||
void on_decodeAsTreeView_currentItemChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
|
||||
void on_newToolButton_clicked();
|
||||
void on_deleteToolButton_clicked();
|
||||
void on_copyToolButton_clicked();
|
||||
void on_clearToolButton_clicked();
|
||||
|
||||
void on_buttonBox_clicked(QAbstractButton *button);
|
||||
};
|
||||
|
|
|
@ -62,6 +62,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="clearToolButton">
|
||||
<property name="toolTip">
|
||||
<string>Clear all coloring rules.</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../image/stock_icons.qrc">
|
||||
<normaloff>:/stock/delete_list.png</normaloff>:/stock/delete_list.png</iconset>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
|
|
|
@ -391,6 +391,16 @@ bool DecodeAsModel::removeRows(int row, int count, const QModelIndex &/*parent*/
|
|||
return true;
|
||||
}
|
||||
|
||||
void DecodeAsModel::clearAll()
|
||||
{
|
||||
if (rowCount() < 1)
|
||||
return;
|
||||
|
||||
beginResetModel();
|
||||
decode_as_items_.clear();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
bool DecodeAsModel::copyRow(int dst_row, int src_row)
|
||||
{
|
||||
if (src_row < 0 || src_row >= rowCount() || dst_row < 0 || dst_row >= rowCount()) {
|
||||
|
|
|
@ -72,6 +72,7 @@ public:
|
|||
|
||||
bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
|
||||
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
|
||||
void clearAll();
|
||||
bool copyRow(int dst_row, int src_row);
|
||||
|
||||
static QString entryString(const gchar *table_name, gpointer value);
|
||||
|
|
Loading…
Reference in New Issue