# 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
# def get_devices():
#     serials = RtlSdr.get_device_serial_addresses()


class TUNER_TYPE(enum.Enum):
    UNKNOWN     = 0
    E4000       = 1
    FC0012      = 2
    FC0013      = 3
    FC2580      = 4
    R820T       = 5
    R828D       = 6


class DeviceInfo(GenericQObject):
    _n_text = Signal()
    _n_device_index = Signal()
    _n_device_serial = Signal()
    _n_tuner_type = Signal()
    _n_gains = Signal()
    def __init__(self, *args):
        self._device_index = None
        self._device_serial = None
        self._tuner_type = None
        self._gains = []
        super().__init__(*args)

    def _g_text(self): return str(self)
    text = Property(str, _g_text, notify=_n_text)


# 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

# def get_devices():
#     serials = RtlSdr.get_device_serial_addresses()


class TUNER_TYPE(enum.Enum):
    UNKNOWN     = 0
    E4000       = 1
    FC0012      = 2
    FC0013      = 3
    FC2580      = 4
    R820T       = 5
    R828D       = 6


class DeviceInfo(GenericQObject):
    _n_text = Signal()
    _n_device_index = Signal()
    _n_device_serial = Signal()
    _n_tuner_type = Signal()
    _n_gains = Signal()
    def __init__(self, *args):
        self._device_index = None
        self._device_serial = None
        self._tuner_type = None
        self._gains = []
        super().__init__(*args)

    def _g_text(self): return str(self)
    text = Property(str, _g_text, notify=_n_text)


    def _g_device_index(self): return self._device_index