def drop_event(self, event): mimedata = event.mimeData() pos = self.widget.mapToGlobal(event.pos()) possible_conv, selected = self._drop(mimedata, pos) if possible_conv is None: self._compatible = None for mimetype_in, mimetype_out in possible_conv[selected]: try: data, kwds = qtdecode(mimedata, mimetype_in, mimetype_out) kwds['mimedata'] = mimedata self._drop_callbacks[selected](data, **kwds) except CustomException as e: make_error_dialog(e) else: event.acceptProposedAction() return QtGui.QWidget.dropEvent(self.widget, event) self._compatible = None
def drop_event(self, event): mimedata = event.mimeData() pos = self.widget.mapToGlobal(event.pos()) possible_conv, selected = self._drop(mimedata, pos) if possible_conv is None: self._compatible = None for mimetype_in, mimetype_out in possible_conv[selected]: try: data, kwds = qtdecode(mimedata, mimetype_in, mimetype_out) kwds["mimedata"] = mimedata self._drop_callbacks[selected](data, **kwds) except CustomException as e: make_error_dialog(e) else: event.acceptProposedAction() return QtGui.QWidget.dropEvent(self.widget, event) self._compatible = None
def insert_from_mime_data(self, source): cursor = self.widget.textCursor() rect = self.widget.cursorRect() pos = self.widget.viewport().mapToGlobal(rect.center()) possible_conv, selected = self._drop(source, pos=pos) # If not explicitly defined, use widget default drag and drop if not possible_conv: self._compatible = None return super(self.widget.__class__, self.widget).insertFromMimeData(source) for mimetype_in, mimetype_out in possible_conv[selected]: try: data, kwds = qtdecode(source, mimetype_in, mimetype_out) except CustomException as e: make_error_dialog(e) else: kwds['mimedata'] = source kwds['cursor'] = cursor self._drop_callbacks[selected](data, **kwds) self._compatible = None
def insert_from_mime_data(self, source): cursor = self.widget.textCursor() rect = self.widget.cursorRect() pos = self.widget.viewport().mapToGlobal(rect.center()) possible_conv, selected = self._drop(source, pos=pos) # If not explicitly defined, use widget default drag and drop if not possible_conv: self._compatible = None return super(self.widget.__class__, self.widget).insertFromMimeData(source) for mimetype_in, mimetype_out in possible_conv[selected]: try: data, kwds = qtdecode(source, mimetype_in, mimetype_out) except CustomException as e: make_error_dialog(e) else: kwds["mimedata"] = source kwds["cursor"] = cursor self._drop_callbacks[selected](data, **kwds) self._compatible = None