diff options
author | Roland Knall <rknall@gmail.com> | 2019-08-07 11:10:24 +0200 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2019-08-08 11:12:25 +0000 |
commit | 52e111e4d9c6ed16d14b4ee689a80c30082231f2 (patch) | |
tree | fbf78a9b43aafaf0eb2c9bb38ab5d8e15a057fa6 /ui | |
parent | 293b239406e1afe4277039b58442346a66a36c1b (diff) |
Qt: Remove unnecessary label from default copy
Restructures dataPath for PROF_STAT_COPY to ensure correct labeling of
the hintLabel
Bug: 15974
Change-Id: I69f61f4f8db74ca52c3b72d32af2b2bb8b19957d
Reviewed-on: https://code.wireshark.org/review/34202
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/models/profile_model.cpp | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/ui/qt/models/profile_model.cpp b/ui/qt/models/profile_model.cpp index 48c83522ca..a10c18b212 100644 --- a/ui/qt/models/profile_model.cpp +++ b/ui/qt/models/profile_model.cpp @@ -395,32 +395,46 @@ QVariant ProfileModel::dataPath(const QModelIndex &index) const return QVariant(); } case PROF_STAT_COPY: - if (prof->reference) { - ProfileModel * nthis = const_cast<ProfileModel *>(this); - int row = nthis->findByNameAndVisibility(prof->reference, false, true); - profile_def * ref = Q_NULLPTR; - if ( row > 0 && row != index.row() ) - ref = guard(row); - else - row = -1; - - QString msg = tr("Copied from: %1").arg(prof->reference); - - QString appendix; - if ( profile_exists(prof->reference, TRUE) && prof->from_global ) - appendix = tr("system provided"); - else if ( row > 0 && ref && QString(ref->name).compare(prof->reference) != 0 ) - appendix = tr("renamed to %1").arg(ref->name); - else if ( row < 0 ) - appendix = tr("deleted"); + QString msg; - if ( appendix.length() > 0 ) - msg.append(QString(" (%1)").arg(appendix)); + /* this should always be the case, but just as a precaution it is checked */ + if (prof->reference) + { + msg = tr("Copied from: %1").arg(prof->reference); + QString appendix; + + /* A global profile is neither deleted or removed, only system provided is allowed as appendix */ + if ( profile_exists(prof->reference, TRUE) && prof->from_global ) + appendix = tr("system provided"); + /* A default model as reference can neither be deleted or renamed, so skip if the reference was one */ + else if ( ! index.data(ProfileModel::DATA_IS_DEFAULT).toBool() ) + { + /* find all non-global, non-default profiles which are referenced by this one. Those are the only + * ones which could be renamed or deleted */ + int row = const_cast<ProfileModel *>(this)->findByNameAndVisibility(prof->reference, false, true); + if ( row > 0 && row != index.row() ) + { + /* found another profile, so the reference had been renamed, it the status is changed */ + profile_def * ref = guard(row); + if ( ref && ref->status == PROF_STAT_CHANGED ) + appendix = tr("renamed to %1").arg(ref->name); + } + else + { + /* found no other profile, original one had to be deleted */ + appendix = tr("deleted"); + } + + + } + + if ( appendix.length() > 0 ) + msg.append(QString(" (%1)").arg(appendix)); + } return msg; } - break; } return QVariant(); |