# Path: asammdf/gui/utils.py
# def extract_mime_names(data):
#     def fix_comparison_name(data):
#         for i, (
#             name,
#             group_index,
#             channel_index,
#             mdf_uuid,
#             item_type,
#             ranges,
#         ) in enumerate(data):
#             if item_type == "channel":
#                 if (group_index, channel_index) != (-1, -1):
#                     name = COMPARISON_NAME.match(name).group("name").strip()
#                     data[i][0] = name
#             else:
#                 fix_comparison_name(channel_index)
# 
#     names = []
#     if data.hasFormat("application/octet-stream-asammdf"):
#         data = bytes(data.data("application/octet-stream-asammdf")).decode("utf-8")
#         data = json.loads(data)
#         fix_comparison_name(data)
#         names = data
# 
#     return names


import json
from struct import pack
from PyQt5 import QtCore, QtGui, QtWidgets
from ..utils import extract_mime_names
                pack(
                    f"<12s3q{len(info)}s",
                    str(item.mdf_uuid).encode("ascii"),
                    entry[0],
                    entry[1],
                    len(info),
                    info,
                )
            )

        mimeData.setData(
            "application/octet-stream-asammdf", QtCore.QByteArray(b"".join(data))
        )

        drag = QtGui.QDrag(self)
        drag.setMimeData(mimeData)
        drag.exec(QtCore.Qt.CopyAction)

    def dragEnterEvent(self, e):
        if e.mimeData().hasFormat("application/octet-stream-asammdf"):
            e.accept()
        super().dragEnterEvent(e)

    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"):

# Path: asammdf/gui/utils.py
# def extract_mime_names(data):
#     def fix_comparison_name(data):
#         for i, (
#             name,
#             group_index,
#             channel_index,
#             mdf_uuid,
#             item_type,
#             ranges,
#         ) in enumerate(data):
#             if item_type == "channel":
#                 if (group_index, channel_index) != (-1, -1):
#                     name = COMPARISON_NAME.match(name).group("name").strip()
#                     data[i][0] = name
#             else:
#                 fix_comparison_name(channel_index)
# 
#     names = []
#     if data.hasFormat("application/octet-stream-asammdf"):
#         data = bytes(data.data("application/octet-stream-asammdf")).decode("utf-8")
#         data = json.loads(data)
#         fix_comparison_name(data)
#         names = data
# 
#     return names


# Path: asammdf/gui/widgets/list.py
import json
from struct import pack
from PyQt5 import QtCore, QtGui, QtWidgets
from ..utils import extract_mime_names

                pack(
                    f"<12s3q{len(info)}s",
                    str(item.mdf_uuid).encode("ascii"),
                    entry[0],
                    entry[1],
                    len(info),
                    info,
                )
            )

        mimeData.setData(
            "application/octet-stream-asammdf", QtCore.QByteArray(b"".join(data))
        )

        drag = QtGui.QDrag(self)
        drag.setMimeData(mimeData)
        drag.exec(QtCore.Qt.CopyAction)

    def dragEnterEvent(self, e):
        if e.mimeData().hasFormat("application/octet-stream-asammdf"):
            e.accept()
        super().dragEnterEvent(e)

    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)