Changeset 2fa7e86 in subsurface


Ignore:
Timestamp:
Jun 21, 2017, 6:43:15 PM (5 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
d97055d
Parents:
996fda1
git-author:
Anton Lundin <glance@…> (06/15/17 05:50:49)
git-committer:
Dirk Hohndel <dirk@…> (06/21/17 18:43:15)
Message:

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 <glance@…>

Location:
desktop-widgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • desktop-widgets/configuredivecomputerdialog.cpp

    rdb39f1a r2fa7e86  
    66#include "core/display.h"
    77#include "core/subsurface-qt/SettingsObjectWrapper.h"
     8// For fill_computer_list, descriptorLookup
     9#include "core/downloadfromdcthread.h"
    810
    911#include <QFileDialog>
     
    1214#include <QNetworkReply>
    1315#include <QProgressDialog>
    14 
    15 struct mydescriptor {
    16         const char *vendor;
    17         const char *product;
    18         dc_family_t type;
    19         unsigned int model;
    20 };
    2116
    2217GasSpinBoxItemDelegate::GasSpinBoxItemDelegate(QObject *parent, column_type type) : QStyledItemDelegate(parent), type(type)
     
    416411        if (deviceIndex >= 0)
    417412                ui.device->setCurrentIndex(deviceIndex);
    418 }
    419 
    420 void ConfigureDiveComputerDialog::fill_computer_list()
    421 {
    422         dc_iterator_t *iterator = NULL;
    423         dc_descriptor_t *descriptor = NULL;
    424 
    425         struct mydescriptor *mydescriptor;
    426 
    427         dc_descriptor_iterator(&iterator);
    428         while (dc_iterator_next(iterator, &descriptor) == DC_STATUS_SUCCESS) {
    429                 const char *vendor = dc_descriptor_get_vendor(descriptor);
    430                 const char *product = dc_descriptor_get_product(descriptor);
    431 
    432                 if (!vendorList.contains(vendor))
    433                         vendorList.append(vendor);
    434 
    435                 if (!productList[vendor].contains(product))
    436                         productList[vendor].push_back(product);
    437 
    438                 descriptorLookup[QString(vendor) + QString(product)] = descriptor;
    439         }
    440         dc_iterator_free(iterator);
    441 
    442         mydescriptor = (struct mydescriptor *)malloc(sizeof(struct mydescriptor));
    443         mydescriptor->vendor = "Uemis";
    444         mydescriptor->product = "Zurich";
    445         mydescriptor->type = DC_FAMILY_NULL;
    446         mydescriptor->model = 0;
    447 
    448         if (!vendorList.contains("Uemis"))
    449                 vendorList.append("Uemis");
    450 
    451         if (!productList["Uemis"].contains("Zurich"))
    452                 productList["Uemis"].push_back("Zurich");
    453 
    454         descriptorLookup["UemisZurich"] = (dc_descriptor_t *)mydescriptor;
    455 
    456         qSort(vendorList);
    457413}
    458414
  • desktop-widgets/configuredivecomputerdialog.h

    r4cbf64b r2fa7e86  
    9999        QString logFile;
    100100
    101         QStringList vendorList;
    102         QHash<QString, QStringList> productList;
    103 
    104101        ConfigureDiveComputer *config;
    105102        device_data_t device_data;
    106103        void getDeviceData();
    107104
    108         QHash<QString, dc_descriptor_t *> descriptorLookup;
    109105        void fill_device_list(int dc_type);
    110         void fill_computer_list();
    111106
    112107        DeviceDetails *deviceDetails;
Note: See TracChangeset for help on using the changeset viewer.