コード例 #1
0
ファイル: drag_and_drop.py プロジェクト: rjcmarkelz/openalea
 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
コード例 #2
0
ファイル: drag_and_drop.py プロジェクト: gbaty/openalea
 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
コード例 #3
0
ファイル: drag_and_drop.py プロジェクト: rjcmarkelz/openalea
    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
コード例 #4
0
ファイル: drag_and_drop.py プロジェクト: gbaty/openalea
    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