diff options
author | Roland Knall <rknall@gmail.com> | 2019-07-22 17:03:46 +0200 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2019-07-22 15:58:35 +0000 |
commit | a96d6c4ceafdf7c6c930e2fbefc8d0274348df27 (patch) | |
tree | 4b0bff9ef9d4d7cb815d35b3202d3ce6105f4d83 | |
parent | 8892da8a472c96960723b7cdfda8f1f25d6ffeef (diff) |
Qt: Stop profile import when action pending
When a reset/delete/add/rename action is pending, profiles
cannot be imported.
Change-Id: I4521b8a265ec4346b7028bc5a7173fd531be24c2
Reviewed-on: https://code.wireshark.org/review/34057
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
-rw-r--r-- | ui/qt/models/profile_model.cpp | 19 | ||||
-rw-r--r-- | ui/qt/models/profile_model.h | 2 | ||||
-rw-r--r-- | ui/qt/profile_dialog.cpp | 8 |
3 files changed, 29 insertions, 0 deletions
diff --git a/ui/qt/models/profile_model.cpp b/ui/qt/models/profile_model.cpp index 31c1ad7552..d8639721c9 100644 --- a/ui/qt/models/profile_model.cpp +++ b/ui/qt/models/profile_model.cpp @@ -164,6 +164,25 @@ GList *ProfileModel::at(int row) const return entry(prof); } +bool ProfileModel::changesPending() const +{ + if ( reset_default_ ) + return true; + + if ( g_list_length(edited_profile_list()) != g_list_length(current_profile_list()) ) + return true; + + bool pending = false; + GList *fl_entry = edited_profile_list(); + while (fl_entry && fl_entry->data && ! pending) { + profile_def *profile = reinterpret_cast<profile_def *>(fl_entry->data); + pending = ( profile->status == PROF_STAT_NEW || profile->status == PROF_STAT_CHANGED || profile->status == PROF_STAT_COPY ); + fl_entry = gxx_list_next(fl_entry); + } + + return pending; +} + int ProfileModel::rowCount(const QModelIndex &) const { return profiles_.count(); diff --git a/ui/qt/models/profile_model.h b/ui/qt/models/profile_model.h index 42aeaa748a..1e7246a02b 100644 --- a/ui/qt/models/profile_model.h +++ b/ui/qt/models/profile_model.h @@ -90,6 +90,8 @@ public: GList * at(int row) const; + bool changesPending() const; + #ifdef HAVE_MINIZIP int importProfilesFromZip(QString filename, int *skippedCnt = Q_NULLPTR); #endif diff --git a/ui/qt/profile_dialog.cpp b/ui/qt/profile_dialog.cpp index 6254ab6ec0..5eeb288853 100644 --- a/ui/qt/profile_dialog.cpp +++ b/ui/qt/profile_dialog.cpp @@ -180,6 +180,8 @@ void ProfileDialog::updateWidgets() bool enable_del = false; bool enable_ok = true; + pd_ui_->btnImport->setEnabled( ! model_->changesPending() ); + QModelIndex index = sort_model_->mapToSource(pd_ui_->profileTreeView->currentIndex()); if ( index.column() != ProfileModel::COL_NAME ) index = index.sibling(index.row(), ProfileModel::COL_NAME); @@ -249,6 +251,8 @@ void ProfileDialog::on_newToolButton_clicked() pd_ui_->profileTreeView->edit(ridx); currentItemChanged(); } + else + updateWidgets(); } void ProfileDialog::on_deleteToolButton_clicked() @@ -259,6 +263,8 @@ void ProfileDialog::on_deleteToolButton_clicked() QModelIndex newIdx = sort_model_->mapFromSource(model_->index(0, 0)); pd_ui_->profileTreeView->setCurrentIndex(newIdx); + + updateWidgets(); } void ProfileDialog::on_copyToolButton_clicked() @@ -279,6 +285,8 @@ void ProfileDialog::on_copyToolButton_clicked() pd_ui_->profileTreeView->edit(sort_model_->mapFromSource(ridx)); currentItemChanged(); } + else + updateWidgets(); } void ProfileDialog::on_buttonBox_accepted() |