mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
code cleanup: once we find a match, stop checking
This isn't really a useful performance improvement, but it's still better, IMHO, because we don't have a less specific match later on potentially change an already executed match. Because of our coding style the comment covering multiple cases of Pelagic dive computers now is associated just with the first of those entries. I don't see a way to do this differently without being in violation of our coding style, so I'll just keep it like this. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
55bbdc2728
commit
fe6ecb4cd8
1 changed files with 33 additions and 60 deletions
|
@ -34,9 +34,7 @@ static dc_descriptor_t *getDeviceType(QString btName)
|
||||||
// just use a default product that allows the codoe to download from the
|
// just use a default product that allows the codoe to download from the
|
||||||
// user's dive computer
|
// user's dive computer
|
||||||
else product = "OSTC 2";
|
else product = "OSTC 2";
|
||||||
}
|
} else if (btName.startsWith("Predator") ||
|
||||||
|
|
||||||
if (btName.startsWith("Predator") ||
|
|
||||||
btName.startsWith("Petrel") ||
|
btName.startsWith("Petrel") ||
|
||||||
btName.startsWith("Perdix") ||
|
btName.startsWith("Perdix") ||
|
||||||
btName.startsWith("Teric") ||
|
btName.startsWith("Teric") ||
|
||||||
|
@ -51,31 +49,21 @@ static dc_descriptor_t *getDeviceType(QString btName)
|
||||||
if (btName.startsWith("Teric")) product = "Teric";
|
if (btName.startsWith("Teric")) product = "Teric";
|
||||||
if (btName.startsWith("NERD")) product = "Nerd"; // next line might override this
|
if (btName.startsWith("NERD")) product = "Nerd"; // next line might override this
|
||||||
if (btName.startsWith("NERD 2")) product = "Nerd 2";
|
if (btName.startsWith("NERD 2")) product = "Nerd 2";
|
||||||
}
|
} else if (btName.startsWith("EON Steel")) {
|
||||||
|
|
||||||
if (btName.startsWith("EON Steel")) {
|
|
||||||
vendor = "Suunto";
|
vendor = "Suunto";
|
||||||
product = "EON Steel";
|
product = "EON Steel";
|
||||||
}
|
} else if (btName.startsWith("EON Core")) {
|
||||||
|
|
||||||
if (btName.startsWith("EON Core")) {
|
|
||||||
vendor = "Suunto";
|
vendor = "Suunto";
|
||||||
product = "EON Core";
|
product = "EON Core";
|
||||||
}
|
} else if (btName.startsWith("Suunto D5")) {
|
||||||
|
|
||||||
if (btName.startsWith("Suunto D5")) {
|
|
||||||
vendor = "Suunto";
|
vendor = "Suunto";
|
||||||
product = "D5";
|
product = "D5";
|
||||||
}
|
} else if (btName.startsWith("G2") || btName.startsWith("Aladin") || btName.startsWith("HUD")) {
|
||||||
|
|
||||||
if (btName.startsWith("G2") || btName.startsWith("Aladin") || btName.startsWith("HUD")) {
|
|
||||||
vendor = "Scubapro";
|
vendor = "Scubapro";
|
||||||
if (btName.startsWith("G2")) product = "G2";
|
if (btName.startsWith("G2")) product = "G2";
|
||||||
if (btName.startsWith("HUD")) product = "G2 HUD";
|
if (btName.startsWith("HUD")) product = "G2 HUD";
|
||||||
if (btName.startsWith("Aladin")) product = "Aladin Sport Matrix";
|
if (btName.startsWith("Aladin")) product = "Aladin Sport Matrix";
|
||||||
}
|
} else if (btName.startsWith("Mares")) {
|
||||||
|
|
||||||
if (btName.startsWith("Mares")) {
|
|
||||||
vendor = "Mares";
|
vendor = "Mares";
|
||||||
// we don't know which of the dive computers it is,
|
// we don't know which of the dive computers it is,
|
||||||
// so let's just randomly pick one
|
// so let's just randomly pick one
|
||||||
|
@ -83,66 +71,51 @@ static dc_descriptor_t *getDeviceType(QString btName)
|
||||||
// Some we can pick out directly
|
// Some we can pick out directly
|
||||||
if (btName.startsWith("Mares Genius"))
|
if (btName.startsWith("Mares Genius"))
|
||||||
product = "Genius";
|
product = "Genius";
|
||||||
}
|
} else if (btName.startsWith("CARTESIO_")) {
|
||||||
|
|
||||||
if (btName.startsWith("CARTESIO_")) {
|
|
||||||
vendor = "Cressi";
|
vendor = "Cressi";
|
||||||
product = "Cartesio";
|
product = "Cartesio";
|
||||||
}
|
} else if (btName.startsWith("GOA_")) {
|
||||||
|
|
||||||
if (btName.startsWith("GOA_")) {
|
|
||||||
vendor = "Cressi";
|
vendor = "Cressi";
|
||||||
product = "Goa";
|
product = "Goa";
|
||||||
}
|
} else if (btName.contains(QRegularExpression("^FI\\d{6}$"))) {
|
||||||
|
|
||||||
// The Pelagic dive computers (generally branded as Oceanic or Aqualung)
|
// The Pelagic dive computers (generally branded as Oceanic or Aqualung)
|
||||||
// show up with a two-byte model code followed by six bytes of serial
|
// show up with a two-byte model code followed by six bytes of serial
|
||||||
// number. The model code matches the hex model (so "FQ" is 0x4651,
|
// number. The model code matches the hex model (so "FQ" is 0x4651,
|
||||||
// where 'F' is 46h and 'Q' is 51h in ASCII).
|
// where 'F' is 46h and 'Q' is 51h in ASCII).
|
||||||
if (btName.contains(QRegularExpression("^FI\\d{6}$"))) {
|
|
||||||
vendor = "Aqualung";
|
vendor = "Aqualung";
|
||||||
product = "i200c";
|
product = "i200c";
|
||||||
}
|
} else if (btName.contains(QRegularExpression("^FH\\d{6}$"))) {
|
||||||
|
|
||||||
if (btName.contains(QRegularExpression("^FH\\d{6}$"))) {
|
|
||||||
vendor = "Aqualung";
|
vendor = "Aqualung";
|
||||||
product = "i300c";
|
product = "i300c";
|
||||||
}
|
} else if (btName.contains(QRegularExpression("^FQ\\d{6}$"))) {
|
||||||
|
|
||||||
if (btName.contains(QRegularExpression("^FQ\\d{6}$"))) {
|
|
||||||
vendor = "Aqualung";
|
vendor = "Aqualung";
|
||||||
product = "i770R";
|
product = "i770R";
|
||||||
}
|
} else if (btName.contains(QRegularExpression("^FR\\d{6}$"))) {
|
||||||
|
|
||||||
if (btName.contains(QRegularExpression("^FR\\d{6}$"))) {
|
|
||||||
vendor = "Aqualung";
|
vendor = "Aqualung";
|
||||||
product = "i550c";
|
product = "i550c";
|
||||||
}
|
} else if (btName.contains(QRegularExpression("^ER\\d{6}$"))) {
|
||||||
|
|
||||||
if (btName.contains(QRegularExpression("^ER\\d{6}$"))) {
|
|
||||||
vendor = "Oceanic";
|
vendor = "Oceanic";
|
||||||
product = "Pro Plus X";
|
product = "Pro Plus X";
|
||||||
}
|
} else if (btName.contains(QRegularExpression("^FS\\d{6}$"))) {
|
||||||
|
|
||||||
if (btName.contains(QRegularExpression("^FS\\d{6}$"))) {
|
|
||||||
vendor = "Oceanic";
|
vendor = "Oceanic";
|
||||||
product = "Geo 4.0";
|
product = "Geo 4.0";
|
||||||
}
|
} else if (btName.contains(QRegularExpression("^DS\\d{6}"))) {
|
||||||
|
|
||||||
// The Ratio bluetooth name looks like the Pelagic ones,
|
// The Ratio bluetooth name looks like the Pelagic ones,
|
||||||
// but that seems to be just happenstance.
|
// but that seems to be just happenstance.
|
||||||
if (btName.contains(QRegularExpression("^DS\\d{6}"))) {
|
|
||||||
vendor = "Ratio";
|
vendor = "Ratio";
|
||||||
product = "iX3M GPS Easy"; // we don't know which of the GPS models, so set one
|
product = "iX3M GPS Easy"; // we don't know which of the GPS models, so set one
|
||||||
}
|
} else if (btName == "COSMIQ") {
|
||||||
|
|
||||||
if (btName == "COSMIQ") {
|
|
||||||
vendor = "Deepblu";
|
vendor = "Deepblu";
|
||||||
product = "Cosmiq+";
|
product = "Cosmiq+";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vendor.isEmpty() && !product.isEmpty())
|
// check if we found a known dive computer
|
||||||
return descriptorLookup.value(vendor + product);
|
if (!vendor.isEmpty() && !product.isEmpty()) {
|
||||||
|
dc_descriptor_t *lookup = descriptorLookup.value(vendor + product);
|
||||||
|
if (!lookup)
|
||||||
|
qWarning("known dive computer %s not found in descriptorLookup", qPrintable(QString(vendor + product)));
|
||||||
|
return lookup;
|
||||||
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue