# Path: asammdf/gui/widgets/tree_numeric.py
# class NumericTreeWidget(QtWidgets.QTreeWidget):
#     add_channels_request = QtCore.pyqtSignal(list)
#     items_rearranged = QtCore.pyqtSignal()
#     items_deleted = QtCore.pyqtSignal(list)
# 
#     def __init__(self, *args, **kwargs):
# 
#         super().__init__(*args, **kwargs)
# 
#         self.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
#         self.setAcceptDrops(True)
#         self.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
#         self.setEditTriggers(QtWidgets.QAbstractItemView.DoubleClicked)
# 
#         self.header().sortIndicatorChanged.connect(self.handle_sorting_changed)
#         self.itemDoubleClicked.connect(self.handle_item_double_click)
# 
#         self._handles_double_click = True
#         self.set_double_clicked_enabled(True)
# 
#     def set_double_clicked_enabled(self, state):
#         self._handles_double_click = bool(state)
# 
#     def keyPressEvent(self, event):
#         key = event.key()
#         if (
#             event.key() == QtCore.Qt.Key_Delete
#             and event.modifiers() == QtCore.Qt.NoModifier
#         ):
#             selected = reversed(self.selectedItems())
#             names = [(item.mdf_uuid, item.text(0)) for item in selected]
#             for item in selected:
#                 if item.parent() is None:
#                     index = self.indexFromItem(item).row()
#                     self.takeTopLevelItem(index)
#                 else:
#                     item.parent().removeChild(item)
#             self.items_deleted.emit(names)
#         else:
#             super().keyPressEvent(event)
# 
#     def startDrag(self, supportedActions):
#         selected_items = self.selectedItems()
# 
#         mimeData = QtCore.QMimeData()
# 
#         data = []
# 
#         for item in selected_items:
# 
#             entry = item.entry
# 
#             if entry == (-1, -1):
#                 info = {
#                     "name": item.name,
#                     "computation": item.computation,
#                 }
#             else:
#                 info = item.name
# 
#             ranges = [dict(e) for e in item.ranges]
# 
#             for range_info in ranges:
#                 range_info["color"] = range_info["color"].color().name()
# 
#             data.append(
#                 (
#                     info,
#                     *item.entry,
#                     str(item.mdf_uuid),
#                     "channel",
#                     ranges,
#                 )
#             )
# 
#         data = json.dumps(data).encode("utf-8")
# 
#         mimeData.setData("application/octet-stream-asammdf", QtCore.QByteArray(data))
# 
#         drag = QtGui.QDrag(self)
#         drag.setMimeData(mimeData)
#         drag.exec(QtCore.Qt.CopyAction)
# 
#     def dragEnterEvent(self, e):
#         e.accept()
# 
#     def dropEvent(self, e):
# 
#         if e.source() is self:
#             super().dropEvent(e)
#             self.items_rearranged.emit()
#         else:
#             data = e.mimeData()
#             if data.hasFormat("application/octet-stream-asammdf"):
#                 names = extract_mime_names(data)
#                 self.add_channels_request.emit(names)
#             else:
#                 super().dropEvent(e)
# 
#     def handle_item_double_click(self, item, column):
#         if self._handles_double_click:
#             dlg = RangeEditor(
#                 item.name,
#                 ranges=item.ranges,
#                 parent=self,
#                 brush=True,
#             )
#             dlg.exec_()
#             if dlg.pressed_button == "apply":
#                 item.ranges = dlg.result
#                 item.check_signal_range()
# 
#     def handle_sorting_changed(self, index, order):
#         iterator = QtWidgets.QTreeWidgetItemIterator(self)
#         while iterator.value():
#             item = iterator.value()
#             iterator += 1
# 
#             item._sorting_column = index


from PyQt5 import QtCore, QtGui, QtWidgets
from asammdf.gui.widgets.tree_numeric import NumericTreeWidget
from . import resource_rc

        self.gridLayout_2 = QtWidgets.QGridLayout()
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.label_4 = QtWidgets.QLabel(NumericDisplay)
        self.label_4.setObjectName("label_4")
        self.gridLayout_2.addWidget(self.label_4, 0, 0, 1, 1)
        self.mode_selection = QtWidgets.QComboBox(NumericDisplay)
        self.mode_selection.setObjectName("mode_selection")
        self.mode_selection.addItem("")
        self.mode_selection.addItem("")
        self.gridLayout_2.addWidget(self.mode_selection, 1, 0, 1, 1)
        self.label_5 = QtWidgets.QLabel(NumericDisplay)
        self.label_5.setObjectName("label_5")
        self.gridLayout_2.addWidget(self.label_5, 0, 1, 1, 1)
        self.format_selection = QtWidgets.QComboBox(NumericDisplay)
        self.format_selection.setObjectName("format_selection")
        self.format_selection.addItem("")
        self.format_selection.addItem("")
        self.format_selection.addItem("")
        self.gridLayout_2.addWidget(self.format_selection, 1, 1, 1, 1)
        self.label_6 = QtWidgets.QLabel(NumericDisplay)
        self.label_6.setObjectName("label_6")
        self.gridLayout_2.addWidget(self.label_6, 0, 2, 1, 1)
        self.float_precision = QtWidgets.QSpinBox(NumericDisplay)
        self.float_precision.setPrefix("")
        self.float_precision.setMaximum(15)
        self.float_precision.setProperty("value", 3)
        self.float_precision.setObjectName("float_precision")
        self.gridLayout_2.addWidget(self.float_precision, 1, 2, 1, 1)
        self.gridLayout_2.setColumnStretch(2, 1)
        self.verticalLayout.addLayout(self.gridLayout_2)

# Path: asammdf/gui/widgets/tree_numeric.py
# class NumericTreeWidget(QtWidgets.QTreeWidget):
#     add_channels_request = QtCore.pyqtSignal(list)
#     items_rearranged = QtCore.pyqtSignal()
#     items_deleted = QtCore.pyqtSignal(list)
# 
#     def __init__(self, *args, **kwargs):
# 
#         super().__init__(*args, **kwargs)
# 
#         self.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
#         self.setAcceptDrops(True)
#         self.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
#         self.setEditTriggers(QtWidgets.QAbstractItemView.DoubleClicked)
# 
#         self.header().sortIndicatorChanged.connect(self.handle_sorting_changed)
#         self.itemDoubleClicked.connect(self.handle_item_double_click)
# 
#         self._handles_double_click = True
#         self.set_double_clicked_enabled(True)
# 
#     def set_double_clicked_enabled(self, state):
#         self._handles_double_click = bool(state)
# 
#     def keyPressEvent(self, event):
#         key = event.key()
#         if (
#             event.key() == QtCore.Qt.Key_Delete
#             and event.modifiers() == QtCore.Qt.NoModifier
#         ):
#             selected = reversed(self.selectedItems())
#             names = [(item.mdf_uuid, item.text(0)) for item in selected]
#             for item in selected:
#                 if item.parent() is None:
#                     index = self.indexFromItem(item).row()
#                     self.takeTopLevelItem(index)
#                 else:
#                     item.parent().removeChild(item)
#             self.items_deleted.emit(names)
#         else:
#             super().keyPressEvent(event)
# 
#     def startDrag(self, supportedActions):
#         selected_items = self.selectedItems()
# 
#         mimeData = QtCore.QMimeData()
# 
#         data = []
# 
#         for item in selected_items:
# 
#             entry = item.entry
# 
#             if entry == (-1, -1):
#                 info = {
#                     "name": item.name,
#                     "computation": item.computation,
#                 }
#             else:
#                 info = item.name
# 
#             ranges = [dict(e) for e in item.ranges]
# 
#             for range_info in ranges:
#                 range_info["color"] = range_info["color"].color().name()
# 
#             data.append(
#                 (
#                     info,
#                     *item.entry,
#                     str(item.mdf_uuid),
#                     "channel",
#                     ranges,
#                 )
#             )
# 
#         data = json.dumps(data).encode("utf-8")
# 
#         mimeData.setData("application/octet-stream-asammdf", QtCore.QByteArray(data))
# 
#         drag = QtGui.QDrag(self)
#         drag.setMimeData(mimeData)
#         drag.exec(QtCore.Qt.CopyAction)
# 
#     def dragEnterEvent(self, e):
#         e.accept()
# 
#     def dropEvent(self, e):
# 
#         if e.source() is self:
#             super().dropEvent(e)
#             self.items_rearranged.emit()
#         else:
#             data = e.mimeData()
#             if data.hasFormat("application/octet-stream-asammdf"):
#                 names = extract_mime_names(data)
#                 self.add_channels_request.emit(names)
#             else:
#                 super().dropEvent(e)
# 
#     def handle_item_double_click(self, item, column):
#         if self._handles_double_click:
#             dlg = RangeEditor(
#                 item.name,
#                 ranges=item.ranges,
#                 parent=self,
#                 brush=True,
#             )
#             dlg.exec_()
#             if dlg.pressed_button == "apply":
#                 item.ranges = dlg.result
#                 item.check_signal_range()
# 
#     def handle_sorting_changed(self, index, order):
#         iterator = QtWidgets.QTreeWidgetItemIterator(self)
#         while iterator.value():
#             item = iterator.value()
#             iterator += 1
# 
#             item._sorting_column = index


# Path: asammdf/gui/ui/numeric.py
from PyQt5 import QtCore, QtGui, QtWidgets
from asammdf.gui.widgets.tree_numeric import NumericTreeWidget
from . import resource_rc

        self.gridLayout_2 = QtWidgets.QGridLayout()
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.label_4 = QtWidgets.QLabel(NumericDisplay)
        self.label_4.setObjectName("label_4")
        self.gridLayout_2.addWidget(self.label_4, 0, 0, 1, 1)
        self.mode_selection = QtWidgets.QComboBox(NumericDisplay)
        self.mode_selection.setObjectName("mode_selection")
        self.mode_selection.addItem("")
        self.mode_selection.addItem("")
        self.gridLayout_2.addWidget(self.mode_selection, 1, 0, 1, 1)
        self.label_5 = QtWidgets.QLabel(NumericDisplay)
        self.label_5.setObjectName("label_5")
        self.gridLayout_2.addWidget(self.label_5, 0, 1, 1, 1)
        self.format_selection = QtWidgets.QComboBox(NumericDisplay)
        self.format_selection.setObjectName("format_selection")
        self.format_selection.addItem("")
        self.format_selection.addItem("")
        self.format_selection.addItem("")
        self.gridLayout_2.addWidget(self.format_selection, 1, 1, 1, 1)
        self.label_6 = QtWidgets.QLabel(NumericDisplay)
        self.label_6.setObjectName("label_6")
        self.gridLayout_2.addWidget(self.label_6, 0, 2, 1, 1)
        self.float_precision = QtWidgets.QSpinBox(NumericDisplay)
        self.float_precision.setPrefix("")
        self.float_precision.setMaximum(15)
        self.float_precision.setProperty("value", 3)
        self.float_precision.setObjectName("float_precision")
        self.gridLayout_2.addWidget(self.float_precision, 1, 2, 1, 1)
        self.gridLayout_2.setColumnStretch(2, 1)
        self.verticalLayout.addLayout(self.gridLayout_2)

        self.channels = NumericTreeWidget(NumericDisplay)
