From 2fa7e86708860e31d9011364df00e0c92f487241 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Thu, 15 Jun 2017 14:50:49 +0200 Subject: Remove old duplicated code Way back in time this code was copied from downloadfromdcthread, so de-duplicate and call that code instead. Signed-off-by: Anton Lundin --- desktop-widgets/configuredivecomputerdialog.cpp | 48 ++----------------------- desktop-widgets/configuredivecomputerdialog.h | 5 --- 2 files changed, 2 insertions(+), 51 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/configuredivecomputerdialog.cpp b/desktop-widgets/configuredivecomputerdialog.cpp index 2afdf38ce..1dfa27bb9 100644 --- a/desktop-widgets/configuredivecomputerdialog.cpp +++ b/desktop-widgets/configuredivecomputerdialog.cpp @@ -5,6 +5,8 @@ #include "desktop-widgets/mainwindow.h" #include "core/display.h" #include "core/subsurface-qt/SettingsObjectWrapper.h" +// For fill_computer_list, descriptorLookup +#include "core/downloadfromdcthread.h" #include #include @@ -12,13 +14,6 @@ #include #include -struct mydescriptor { - const char *vendor; - const char *product; - dc_family_t type; - unsigned int model; -}; - GasSpinBoxItemDelegate::GasSpinBoxItemDelegate(QObject *parent, column_type type) : QStyledItemDelegate(parent), type(type) { } @@ -417,45 +412,6 @@ void ConfigureDiveComputerDialog::fill_device_list(int dc_type) ui.device->setCurrentIndex(deviceIndex); } -void ConfigureDiveComputerDialog::fill_computer_list() -{ - dc_iterator_t *iterator = NULL; - dc_descriptor_t *descriptor = NULL; - - struct mydescriptor *mydescriptor; - - dc_descriptor_iterator(&iterator); - while (dc_iterator_next(iterator, &descriptor) == DC_STATUS_SUCCESS) { - const char *vendor = dc_descriptor_get_vendor(descriptor); - const char *product = dc_descriptor_get_product(descriptor); - - if (!vendorList.contains(vendor)) - vendorList.append(vendor); - - if (!productList[vendor].contains(product)) - productList[vendor].push_back(product); - - descriptorLookup[QString(vendor) + QString(product)] = descriptor; - } - dc_iterator_free(iterator); - - mydescriptor = (struct mydescriptor *)malloc(sizeof(struct mydescriptor)); - mydescriptor->vendor = "Uemis"; - mydescriptor->product = "Zurich"; - mydescriptor->type = DC_FAMILY_NULL; - mydescriptor->model = 0; - - if (!vendorList.contains("Uemis")) - vendorList.append("Uemis"); - - if (!productList["Uemis"].contains("Zurich")) - productList["Uemis"].push_back("Zurich"); - - descriptorLookup["UemisZurich"] = (dc_descriptor_t *)mydescriptor; - - qSort(vendorList); -} - void ConfigureDiveComputerDialog::populateDeviceDetails() { switch (ui.dcStackedWidget->currentIndex()) { diff --git a/desktop-widgets/configuredivecomputerdialog.h b/desktop-widgets/configuredivecomputerdialog.h index d111b39a6..5451b9b9a 100644 --- a/desktop-widgets/configuredivecomputerdialog.h +++ b/desktop-widgets/configuredivecomputerdialog.h @@ -98,16 +98,11 @@ private: QString logFile; - QStringList vendorList; - QHash productList; - ConfigureDiveComputer *config; device_data_t device_data; void getDeviceData(); - QHash descriptorLookup; void fill_device_list(int dc_type); - void fill_computer_list(); DeviceDetails *deviceDetails; void populateDeviceDetails(); -- cgit v1.2.3-70-g09d2