aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorRoland Knall <rknall@gmail.com>2019-08-13 10:32:05 +0200
committerAnders Broman <a.broman58@gmail.com>2019-08-13 10:49:40 +0000
commitbc2b1a9a72139740c030e923868bb8091f943821 (patch)
treee7a22991823a26c143e5820bbcf5072dd7ebf033 /ui
parent2cf962b8a38987428290f21e71a2117f7617649b (diff)
Qt: Remove unnecessary const_cast's
Change-Id: I566cb963b919f6de91a809661856beadd1d4a14a Reviewed-on: https://code.wireshark.org/review/34264 Reviewed-by: Roland Knall <rknall@gmail.com> Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/models/profile_model.cpp16
-rw-r--r--ui/qt/models/profile_model.h6
2 files changed, 11 insertions, 11 deletions
diff --git a/ui/qt/models/profile_model.cpp b/ui/qt/models/profile_model.cpp
index f642abf837..f522e183aa 100644
--- a/ui/qt/models/profile_model.cpp
+++ b/ui/qt/models/profile_model.cpp
@@ -370,7 +370,7 @@ bool ProfileModel::checkInvalid(const QModelIndex &index) const
if ( ! prof )
return false;
- int ref = const_cast<ProfileModel *>(this)->findAsReference(prof->name);
+ int ref = this->findAsReference(prof->name);
if ( ref == index.row() )
return false;
@@ -387,7 +387,7 @@ bool ProfileModel::checkDuplicate(const QModelIndex &index, bool isOriginalToDup
if ( ! prof || ( ! isOriginalToDuplicate && prof->status == PROF_STAT_EXISTS ) )
return false;
- QList<int> rows = const_cast<ProfileModel *>(this)->findAllByNameAndVisibility(prof->name, prof->is_global, false);
+ QList<int> rows = this->findAllByNameAndVisibility(prof->name, prof->is_global, false);
int found = 0;
profile_def * check = Q_NULLPTR;
for(int cnt = 0; cnt < rows.count(); cnt++)
@@ -461,7 +461,7 @@ QVariant ProfileModel::dataPath(const QModelIndex &index) const
if ( checkInvalid(index) )
{
- int ref = const_cast<ProfileModel *>(this)->findAsReference(prof->name);
+ int ref = this->findAsReference(prof->name);
if ( ref != index.row() && ref >= 0 )
{
profile_def * prof = guard(ref);
@@ -541,7 +541,7 @@ QVariant ProfileModel::dataPath(const QModelIndex &index) const
{
/* find a non-global, non-default profile which could be 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);
+ int row = this->findByNameAndVisibility(prof->reference, false, true);
profile_def * ref = guard(row);
/* The reference is itself a copy of the original, therefore it is not accepted */
@@ -669,7 +669,7 @@ int ProfileModel::findByName(QString name)
return row;
}
-int ProfileModel::findAsReference(QString reference)
+int ProfileModel::findAsReference(QString reference) const
{
int found = -1;
if ( reference.length() <= 0 )
@@ -685,13 +685,13 @@ int ProfileModel::findAsReference(QString reference)
return found;
}
-int ProfileModel::findByNameAndVisibility(QString name, bool isGlobal, bool searchReference)
+int ProfileModel::findByNameAndVisibility(QString name, bool isGlobal, bool searchReference) const
{
QList<int> result = findAllByNameAndVisibility(name, isGlobal, searchReference);
return result.count() == 0 ? -1 : result.at(0);
}
-QList<int> ProfileModel::findAllByNameAndVisibility(QString name, bool isGlobal, bool searchReference)
+QList<int> ProfileModel::findAllByNameAndVisibility(QString name, bool isGlobal, bool searchReference) const
{
QList<int> result;
@@ -880,7 +880,7 @@ void ProfileModel::doResetModel(bool reset_import)
QModelIndex ProfileModel::activeProfile() const
{
- QList<int> rows = const_cast<ProfileModel *>(this)->findAllByNameAndVisibility(set_profile_, false, true);
+ QList<int> rows = this->findAllByNameAndVisibility(set_profile_, false, true);
foreach ( int row, rows )
{
profile_def * prof = profiles_.at(row);
diff --git a/ui/qt/models/profile_model.h b/ui/qt/models/profile_model.h
index e6faad643f..9b7fa88854 100644
--- a/ui/qt/models/profile_model.h
+++ b/ui/qt/models/profile_model.h
@@ -105,7 +105,7 @@ public:
int importProfilesFromDir(QString filename, int *skippedCnt = Q_NULLPTR, bool fromZip = false, QStringList *result = Q_NULLPTR);
static bool checkNameValidity(QString name, QString *msg = Q_NULLPTR);
- QList<int> findAllByNameAndVisibility(QString name, bool isGlobal = false, bool searchReference = false);
+ QList<int> findAllByNameAndVisibility(QString name, bool isGlobal = false, bool searchReference = false) const;
void markAsImported(QStringList importedItems);
bool clearImported(QString *msg = Q_NULLPTR);
@@ -136,8 +136,8 @@ private:
profile_def * guard(int row) const;
GList * entry(profile_def *) const;
- int findByNameAndVisibility(QString name, bool isGlobal = false, bool searchReference = false);
- int findAsReference(QString reference);
+ int findByNameAndVisibility(QString name, bool isGlobal = false, bool searchReference = false) const;
+ int findAsReference(QString reference) const;
#ifdef HAVE_MINIZIP
static bool acceptFile(QString fileName, int fileSize);