# Path: wwb_scanner/ui/pyside/utils.py
# class GenericQObject(QtCore.QObject):
#     def _generic_property_changed(self, attr, old_value, new_value):
#         pass
#     def _generic_setter(self, attr, value):
#         cur_value = getattr(self, attr)
#         if cur_value == value:
#             return
#         setattr(self, attr, value)
#         sig_name = f'_n{attr}'
#         sig = getattr(self, sig_name)
#         sig.emit()
#         self._generic_property_changed(attr, cur_value, value)


import enum
import logging
from rtlsdr import RtlSdr
from PySide2 import QtCore, QtQml
from PySide2.QtCore import Signal, Property
from wwb_scanner.ui.pyside.utils import GenericQObject
    tuner_type = Property(str, _g_tuner_type, _s_tuner_type, notify=_n_tuner_type)

    def _g_gains(self): return self._gains
    def _s_gains(self, value): self._generic_setter('_gains', value)
    gains = Property('QVariantList', _g_gains, _s_gains, notify=_n_gains)

    def _get_info_from_device(self, sdr):
        tuner_type = sdr.get_tuner_type()
        self.tuner_type = TUNER_TYPE(tuner_type).name
        self.gains = [g / 10 for g in sdr.gain_values]
        self._n_text.emit()
    def get_info_from_device_index(self, device_index):
        self.device_index = device_index
        if self.device_serial is None:
            self.device_serial = RtlSdr.get_device_serial_addresses()[device_index]
        sdr = RtlSdr(device_index)
        self._get_info_from_device(sdr)
        sdr.close()
    def get_info_from_device_serial(self, device_serial):
        self.device_serial = device_serial
        if self.device_index is None:
            self.device_index = RtlSdr.get_device_index_by_serial(device_serial)
        sdr = RtlSdr(device_serial=device_serial)
        self._get_info_from_device(sdr)
        sdr.close()
    def __repr__(self):
        return f'<{self.__class__}: {self}>'
    def __str__(self):
        return f'{self.tuner_type} - {self.device_index} ({self.device_serial})'


# Path: wwb_scanner/ui/pyside/utils.py
# class GenericQObject(QtCore.QObject):
#     def _generic_property_changed(self, attr, old_value, new_value):
#         pass
#     def _generic_setter(self, attr, value):
#         cur_value = getattr(self, attr)
#         if cur_value == value:
#             return
#         setattr(self, attr, value)
#         sig_name = f'_n{attr}'
#         sig = getattr(self, sig_name)
#         sig.emit()
#         self._generic_property_changed(attr, cur_value, value)


# Path: wwb_scanner/ui/pyside/device_config.py
import enum
import logging
from rtlsdr import RtlSdr
from PySide2 import QtCore, QtQml
from PySide2.QtCore import Signal, Property
from wwb_scanner.ui.pyside.utils import GenericQObject

    tuner_type = Property(str, _g_tuner_type, _s_tuner_type, notify=_n_tuner_type)

    def _g_gains(self): return self._gains
    def _s_gains(self, value): self._generic_setter('_gains', value)
    gains = Property('QVariantList', _g_gains, _s_gains, notify=_n_gains)

    def _get_info_from_device(self, sdr):
        tuner_type = sdr.get_tuner_type()
        self.tuner_type = TUNER_TYPE(tuner_type).name
        self.gains = [g / 10 for g in sdr.gain_values]
        self._n_text.emit()
    def get_info_from_device_index(self, device_index):
        self.device_index = device_index
        if self.device_serial is None:
            self.device_serial = RtlSdr.get_device_serial_addresses()[device_index]
        sdr = RtlSdr(device_index)
        self._get_info_from_device(sdr)
        sdr.close()
    def get_info_from_device_serial(self, device_serial):
        self.device_serial = device_serial
        if self.device_index is None:
            self.device_index = RtlSdr.get_device_index_by_serial(device_serial)
        sdr = RtlSdr(device_serial=device_serial)
        self._get_info_from_device(sdr)
        sdr.close()
    def __repr__(self):
        return f'<{self.__class__}: {self}>'
    def __str__(self):
        return f'{self.tuner_type} - {self.device_index} ({self.device_serial})'


class DeviceInfoList(GenericQObject):