Make Bluetooth naming consistent

Currently, on Linux, after selecting a Bluetooth device the name of the
device is shown. On reopening the download dialog, on the other hand,
the address is shown. In the device selection dialog both are shown.

This patch changes the download dialog such that both, name and address,
are shown. The bulk of the patch introduces the name of the device in
the preferences and DCDeviceData. It has to be noted that DCDeviceData
is an encapsulation of the libdivecomputer device_data_t. Nevertheless,
the new Bluetooth-name field is, at the moment, not passed through to
libdivecomputer.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2017-11-12 12:33:20 +01:00 committed by Dirk Hohndel
parent 0d023068b3
commit de81effb25
9 changed files with 69 additions and 11 deletions

View file

@ -29,6 +29,11 @@ QString DiveComputerSettings::dc_device() const
return prefs.dive_computer.device;
}
QString DiveComputerSettings::dc_device_name() const
{
return prefs.dive_computer.device_name;
}
int DiveComputerSettings::downloadMode() const
{
return prefs.dive_computer.download_mode;
@ -70,6 +75,18 @@ void DiveComputerSettings::setDevice(const QString& device)
prefs.dive_computer.device = copy_string(qPrintable(device));
}
void DiveComputerSettings::setDeviceName(const QString& device_name)
{
if (device_name == prefs.dive_computer.device_name)
return;
QSettings s;
s.beginGroup(group);
s.setValue("dive_computer_device_name", device_name);
free(prefs.dive_computer.device_name);
prefs.dive_computer.device_name = copy_string(qPrintable(device_name));
}
void DiveComputerSettings::setDownloadMode(int mode)
{
if (mode == prefs.dive_computer.download_mode)
@ -2333,6 +2350,7 @@ void SettingsObjectWrapper::load()
GET_TXT("dive_computer_vendor",dive_computer.vendor);
GET_TXT("dive_computer_product", dive_computer.product);
GET_TXT("dive_computer_device", dive_computer.device);
GET_TXT("dive_computer_device_name", dive_computer.device_name);
GET_INT("dive_computer_download_mode", dive_computer.download_mode);
s.endGroup();