Qt: Add copy from another profile in UAT dialogs
Add a new button to UAT dialogs to copy entries from another profile. Change-Id: I641ba764d8738f738466529d74d4a21ff13075a0 Reviewed-on: https://code.wireshark.org/review/30028 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
This commit is contained in:
parent
84a0eccebd
commit
75c46e80bf
|
@ -10960,9 +10960,9 @@ static void dof_register(void)
|
|||
"A table of secrets for different identities.",
|
||||
identsecret_uat);
|
||||
|
||||
uat_load(secmode_uat, &uat_load_err);
|
||||
uat_load(seckey_uat, &uat_load_err);
|
||||
uat_load(identsecret_uat, &uat_load_err);
|
||||
uat_load(secmode_uat, NULL, &uat_load_err);
|
||||
uat_load(seckey_uat, NULL, &uat_load_err);
|
||||
uat_load(identsecret_uat, NULL, &uat_load_err);
|
||||
}
|
||||
|
||||
static void dof_handoff(void)
|
||||
|
|
|
@ -529,7 +529,7 @@ void uat_load_all(void) {
|
|||
|
||||
if (!u->loaded) {
|
||||
err = NULL;
|
||||
if (!uat_load(u, &err)) {
|
||||
if (!uat_load(u, NULL, &err)) {
|
||||
report_failure("Error loading table '%s': %s",u->name,err);
|
||||
g_free(err);
|
||||
}
|
||||
|
|
|
@ -301,12 +301,13 @@ void uat_cleanup(void);
|
|||
/** Populate a uat using its file.
|
||||
*
|
||||
* @param uat_in Pointer to a uat. Must not be NULL.
|
||||
* @param filename Filename to load, NULL to fetch from current profile.
|
||||
* @param err Upon failure, points to an error string.
|
||||
*
|
||||
* @return TRUE on success, FALSE on failure.
|
||||
*/
|
||||
WS_DLL_PUBLIC
|
||||
gboolean uat_load(uat_t* uat_in, char** err);
|
||||
gboolean uat_load(uat_t* uat_in, const gchar *filename, char** err);
|
||||
|
||||
/** Create or update a single uat entry using a string.
|
||||
*
|
||||
|
|
|
@ -357,13 +357,19 @@ comment #[^\n]*\n
|
|||
DIAG_ON_FLEX
|
||||
|
||||
gboolean
|
||||
uat_load(uat_t *uat, char **errx)
|
||||
uat_load(uat_t *uat, const gchar *filename, char **errx)
|
||||
{
|
||||
gchar *fname = uat_get_actual_filename(uat, FALSE);
|
||||
gchar *fname;
|
||||
FILE *in;
|
||||
yyscan_t scanner;
|
||||
uat_load_scanner_state_t state;
|
||||
|
||||
if (filename) {
|
||||
fname = g_strdup(filename);
|
||||
} else {
|
||||
fname = uat_get_actual_filename(uat, FALSE);
|
||||
}
|
||||
|
||||
if (!fname) {
|
||||
UAT_UPDATE(uat);
|
||||
|
||||
|
|
|
@ -1134,7 +1134,7 @@ void IOGraphDialog::loadProfileGraphs()
|
|||
io_graph_fields);
|
||||
|
||||
char* err = NULL;
|
||||
if (!uat_load(iog_uat_, &err)) {
|
||||
if (!uat_load(iog_uat_, NULL, &err)) {
|
||||
report_failure("Error while loading %s: %s. Default graph values will be used", iog_uat_->name, err);
|
||||
g_free(err);
|
||||
uat_clear(iog_uat_);
|
||||
|
|
|
@ -44,6 +44,13 @@ void UatModel::loadUat(epan_uat * uat)
|
|||
}
|
||||
}
|
||||
|
||||
void UatModel::reloadUat()
|
||||
{
|
||||
beginResetModel();
|
||||
loadUat(uat_);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
Qt::ItemFlags UatModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
bool copyRow(int dst_row, int src_row);
|
||||
bool moveRow(int src_row, int dst_row);
|
||||
|
||||
void reloadUat();
|
||||
bool hasErrors() const;
|
||||
void clearAll();
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ void SCTPChunkStatisticsDialog::on_actionChunkTypePreferences_triggered()
|
|||
uat_t *uat = prefs_get_uat_value(pref);
|
||||
uat_clear(uat);
|
||||
|
||||
if (!uat_load(uat, &err)) {
|
||||
if (!uat_load(uat, NULL, &err)) {
|
||||
/* XXX - report this through the GUI */
|
||||
g_log(NULL, G_LOG_LEVEL_WARNING, "Error loading table '%s': %s", uat->name, err);
|
||||
g_free(err);
|
||||
|
|
|
@ -16,11 +16,13 @@
|
|||
#include "ui/help_url.h"
|
||||
#include <wsutil/report_message.h>
|
||||
|
||||
#include <ui/qt/widgets/copy_from_profile_button.h>
|
||||
#include <ui/qt/utils/qt_ui_utils.h>
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QPushButton>
|
||||
#include <QUrl>
|
||||
#include <QMenu>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -39,6 +41,12 @@ UatDialog::UatDialog(QWidget *parent, epan_uat *uat) :
|
|||
ok_button_ = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||
help_button_ = ui->buttonBox->button(QDialogButtonBox::Help);
|
||||
|
||||
if (uat->from_profile) {
|
||||
QPushButton *copy_button = new CopyFromProfileButton(uat->filename);
|
||||
ui->buttonBox->addButton(copy_button, QDialogButtonBox::ApplyRole);
|
||||
connect(copy_button->menu(), SIGNAL(triggered(QAction *)), this, SLOT(copyFromProfile(QAction *)));
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
ui->newToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
||||
ui->deleteToolButton->setAttribute(Qt::WA_MacSmallSize, true);
|
||||
|
@ -77,6 +85,20 @@ UatDialog::~UatDialog()
|
|||
delete uat_model_;
|
||||
}
|
||||
|
||||
void UatDialog::copyFromProfile(QAction *action)
|
||||
{
|
||||
QString filename = action->data().toString();
|
||||
|
||||
gchar *err = NULL;
|
||||
if (uat_load(uat_, filename.toUtf8().constData(), &err)) {
|
||||
uat_->changed = TRUE;
|
||||
uat_model_->reloadUat();
|
||||
} else {
|
||||
report_failure("Error while loading %s: %s", uat_->name, err);
|
||||
g_free(err);
|
||||
}
|
||||
}
|
||||
|
||||
void UatDialog::setUat(epan_uat *uat)
|
||||
{
|
||||
QString title(tr("Unknown User Accessible Table"));
|
||||
|
@ -152,7 +174,7 @@ void UatDialog::modelRowsRemoved()
|
|||
void UatDialog::modelRowsReset()
|
||||
{
|
||||
ui->deleteToolButton->setEnabled(false);
|
||||
ui->clearToolButton->setEnabled(false);
|
||||
ui->clearToolButton->setEnabled(uat_model_->rowCount() != 0);
|
||||
ui->copyToolButton->setEnabled(false);
|
||||
ui->moveUpToolButton->setEnabled(false);
|
||||
ui->moveDownToolButton->setEnabled(false);
|
||||
|
@ -344,7 +366,7 @@ void UatDialog::rejectChanges()
|
|||
if (uat_->changed) {
|
||||
gchar *err = NULL;
|
||||
uat_clear(uat_);
|
||||
if (!uat_load(uat_, &err)) {
|
||||
if (!uat_load(uat_, NULL, &err)) {
|
||||
report_failure("Error while loading %s: %s", uat_->name, err);
|
||||
g_free(err);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
void setUat(struct epan_uat *uat = NULL);
|
||||
|
||||
private slots:
|
||||
void copyFromProfile(QAction *action);
|
||||
void modelDataChanged(const QModelIndex &topLeft);
|
||||
void modelRowsRemoved();
|
||||
void modelRowsReset();
|
||||
|
|
|
@ -145,7 +145,7 @@ void UatFrame::rejectChanges()
|
|||
if (uat_->changed) {
|
||||
gchar *err = NULL;
|
||||
uat_clear(uat_);
|
||||
if (!uat_load(uat_, &err)) {
|
||||
if (!uat_load(uat_, NULL, &err)) {
|
||||
report_failure("Error while loading %s: %s", uat_->name, err);
|
||||
g_free(err);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue