def _filter_drag_end(self, event):
        source = self.filterTreeWidget.currentItem()
        source_name = source.text(0)
        target = self.filterTreeWidget.itemAt(event.pos())

        source_top, source_group = self._get_filter_item_coords(source)
        parent = target.parent()
        if parent:
            if parent.parent():
                target_top = parent.parent().text(0)
                target_group = parent.text(0)
            else:
                target_top = parent.text(0)
                if target.data(1, Qt.UserRole) == \
                        self.FilterTreeRoleGroup:
                    target_group = target.text(0)
                else:
                    target_group = None
        else:
            target_top = target.text(0)
            target_group = None

        # Find drop position
        target_index = self.filterTreeWidget.indexAt(event.pos())
        target_height = self.filterTreeWidget.rowHeight(target_index)
        pos = event.pos()
        pos.setY((pos.y() - target_height / 2))
        item_above_target = self.filterTreeWidget.itemAt(pos)
        above_target = item_above_target.text(0) if item_above_target \
            else None

        item = self.filter_managers[source_top].get_item(source_name,
                                                         source_group)
        try:
            self.filter_managers[source_top].remove_item(source_name,
                                                         source_group)
            if target_group:
                self.filter_managers[target_top].add_item(item, source_name,
                                                          target_group)
            else:
                self.filter_managers[target_top].add_item(item, source_name)
        except __HOLE__ as e:
            QMessageBox.critical(self, 'Error moving item', str(e))
            return

        self.filter_managers[target_top].move_item(source_name, above_target,
                                                   target_group)

        self.populate_filter_tree()
        self.filters_changed.emit(source_top)

    # Method injection into the filter tree (to enable custom drag and drop
    # behavior)
dataset/ETHPy150Open rproepp/spykeviewer/spykeviewer/ui/filter_dock.py/FilterDock._filter_drag_end