Add getFingerprint method to detect all changes in UserMetricSettings

Fixes #3838
This commit is contained in:
Ale Martinez
2021-03-06 16:51:31 -03:00
parent 209470bf8f
commit c726325af6
2 changed files with 18 additions and 19 deletions

View File

@@ -179,11 +179,11 @@ quint16
RideMetric::userMetricFingerprint(QList<UserMetricSettings> these)
{
// run through loaded metrics and compute a fingerprint CRC
QByteArray fingers;
quint16 fingerprint = 0;
foreach(UserMetricSettings x, these)
fingers += x.fingerprint.toLocal8Bit();
fingerprint += x.getFingerprint();
return qChecksum(fingers.constData(), fingers.size());
return fingerprint;
}
QHash<QString,RideMetricPtr>

View File

@@ -45,24 +45,23 @@ class UserMetricSettings {
public:
bool operator!= (UserMetricSettings right) const {
qint16 getFingerprint() const {
// mostly used to see if it changed when editing
if (this->symbol != right.symbol ||
this->name != right.name ||
this->description != right.description ||
this->unitsMetric != right.unitsMetric ||
this->unitsImperial != right.unitsImperial ||
this->conversion != right.conversion ||
this->conversionSum != right.conversionSum ||
this->program != right.program ||
this->precision != right.precision ||
this->istime != right.istime ||
this->aggzero != right.aggzero ||
this->fingerprint != right.fingerprint)
return true;
else
return false;
QByteArray ba = QString(this->symbol +
this->name +
this->description +
this->unitsMetric +
this->unitsImperial +
this->type +
this->precision +
this->aggzero +
this->istime +
this->conversion +
this->conversionSum +
this->program).toUtf8();
return qChecksum(ba, ba.length());
}
QString symbol,