mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
import: turn C-string in device_data_t into std::strings
It was never clear what was a pointer to a static string from libdivecomputer and what was allocated. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
0915c1ce43
commit
01306224ff
15 changed files with 120 additions and 129 deletions
|
|
@ -476,23 +476,22 @@ QString extractBluetoothAddress(const QString &address)
|
|||
return m.captured(0);
|
||||
}
|
||||
|
||||
QString extractBluetoothNameAddress(const QString &address, QString &name)
|
||||
std::pair<QString, QString> extractBluetoothNameAddress(const QString &address)
|
||||
{
|
||||
// sometimes our device text is of the form "name (address)", sometimes it's just "address"
|
||||
// let's simply return the address
|
||||
name = QString();
|
||||
QString extractedAddress = extractBluetoothAddress(address);
|
||||
if (extractedAddress == address.trimmed())
|
||||
return address;
|
||||
return { address, QString() };
|
||||
|
||||
QRegularExpression re("^([^()]+)\\(([^)]*\\))$");
|
||||
QRegularExpressionMatch m = re.match(address);
|
||||
if (m.hasMatch()) {
|
||||
name = m.captured(1).trimmed();
|
||||
return extractedAddress;
|
||||
QString name = m.captured(1).trimmed();
|
||||
return { extractedAddress, name };
|
||||
}
|
||||
report_info("can't parse address %s", qPrintable(address));
|
||||
return QString();
|
||||
return { QString(), QString() };
|
||||
}
|
||||
|
||||
void saveBtDeviceInfo(const QString &devaddr, QBluetoothDeviceInfo deviceInfo)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue