def mimeData(self, indexes): """Reimplemented to generate MIME data containing the rows of the current selection.""" editor = self._editor selection_mode = editor.factory.selection_mode if selection_mode.startswith("cell"): data = [ self._get_cell_drag_value(index.row(), index.column()) for index in indexes ] elif selection_mode.startswith("column"): columns = sorted(set(index.column() for index in indexes)) data = self._get_columns_drag_value(columns) else: rows = sorted(set(index.row() for index in indexes)) data = self._get_rows_drag_value(rows) mime_data = PyMimeData.coerce(data) # handle re-ordering via internal drags if editor.factory.reorderable: rows = sorted(set([index.row() for index in indexes])) data = QtCore.QByteArray(str(id(self))) for row in rows: data.append(' %i' % row) mime_data.setData(mime_type, data) return mime_data
def mimeData(self, indexes): """ Reimplemented to generate MIME data containing the rows of the current selection. """ mime_data = QtCore.QMimeData() rows = list(set([index.row() for index in indexes])) data = QtCore.QByteArray(str(rows[0])) for row in rows[1:]: data.append(' %i' % row) mime_data.setData(tabular_mime_type, data) return mime_data
def mimeData(self, indexes): """ Reimplemented to generate MIME data containing the rows of the current selection. """ mime_data = QtCore.QMimeData() rows = list({index.row() for index in indexes}) data = QtCore.QByteArray(str(rows[0]).encode("utf8")) for row in rows[1:]: data.append((" %i" % row).encode("utf8")) mime_data.setData(mime_type, data) return mime_data
def update_editor(self): """ Updates the editor when the object trait changes externally to the editor. """ value = self.value if isinstance(value, SVGDocument): string_io = StringIO() ElementTree(value.tree).write(string_io) value = string_io.getvalue() self.control.load(QtCore.QByteArray(value))
def mimeData(self, indexes): """ Reimplemented to generate MIME data containing the rows of the current selection. """ rows = sorted(set([index.row() for index in indexes])) items = [self._editor.adapter.get_drag( self._editor.object, self._editor.name, row) for row in rows] mime_data = PyMimeData.coerce(items) data = QtCore.QByteArray(str(id(self))) for row in rows: data.append(' %i' % row) mime_data.setData(tabular_mime_type, data) return mime_data
def _set_object_data(self, data): mime_data = QtCore.QMimeData() serialized_data = dumps(data.__class__) + dumps(data) mime_data.setData(PYTHON_TYPE, QtCore.QByteArray(serialized_data)) cb.setMimeData(mime_data)