Source code for openalea.oalab.testing.drag_and_drop
###############################################################################
# -*- coding: utf-8 -*-
# -*- python -*-
#
#
# OpenAlea.OALab: Multi-Paradigm GUI
#
# Copyright 2015 INRIA - CIRAD - INRA
#
# File author(s): Guillaume Baty <guillaume.baty@inria.fr>
#
# File contributor(s):
#
# Distributed under the Cecill-C License.
# See accompanying file LICENSE.txt or copy at
# http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.html
#
# OpenAlea WebSite : http://openalea.gforge.inria.fr
#
###############################################################################
from openalea.vpltk.qt import QtGui
# Load SampleCustomData, associated codecs and register its
from openalea.oalab.testing.mimedata import SampleCustomData
from openalea.oalab.service.drag_and_drop import add_drop_callback, add_drag_format, encode_to_qmimedata
[docs]class DragModel(QtGui.QStandardItemModel):
def __init__(self):
QtGui.QStandardItemModel.__init__(self)
self._lst = list('abc')
for l in self._lst:
self.appendRow(QtGui.QStandardItem(l))
# Define all type of data managed by this model
add_drag_format(self, "custom/data", icon=":/images/resources/openalealogo.png")
[docs] def mimeData(self, indices):
for index in indices:
row = index.row()
data = SampleCustomData(row, self._lst[row])
return encode_to_qmimedata(data, 'custom/data')