本文整理汇总了Python中PyQt4.QtGui.QListView.setDefaultDropAction方法的典型用法代码示例。如果您正苦于以下问题:Python QListView.setDefaultDropAction方法的具体用法?Python QListView.setDefaultDropAction怎么用?Python QListView.setDefaultDropAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QListView
的用法示例。
在下文中一共展示了QListView.setDefaultDropAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWDataSort
# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import setDefaultDropAction [as 别名]
class OWDataSort(OWWidget):
contextHandlers = {
"": DomainContextHandler(
"", ["sortroles"]
)
}
settingsList = ["autoCommit"]
def __init__(self, parent=None, signalManger=None, title="Data Sort"):
super(OWDataSort, self).__init__(parent, signalManger, title,
wantMainArea=False)
#: Mapping (feature.name, feature.var_type) to (sort_index, sort_order)
#: where sirt index is the position of the feature in the sortByModel
#: and sort_order the Qt.SortOrder flag
self.sortroles = {}
self.autoCommit = False
self._outputChanged = False
box = OWGUI.widgetBox(self.controlArea, "Sort By Features")
self.sortByView = QListView()
self.sortByView.setItemDelegate(SortParamDelegate(self))
self.sortByView.setSelectionMode(QListView.ExtendedSelection)
self.sortByView.setDragDropMode(QListView.DragDrop)
self.sortByView.setDefaultDropAction(Qt.MoveAction)
self.sortByView.viewport().setAcceptDrops(True)
self.sortByModel = VariableListModel(
flags=Qt.ItemIsEnabled | Qt.ItemIsSelectable |
Qt.ItemIsDragEnabled | Qt.ItemIsEditable
)
self.sortByView.setModel(self.sortByModel)
box.layout().addWidget(self.sortByView)
box = OWGUI.widgetBox(self.controlArea, "Unused Features")
self.unusedView = QListView()
self.unusedView.setSelectionMode(QListView.ExtendedSelection)
self.unusedView.setDragDropMode(QListView.DragDrop)
self.unusedView.setDefaultDropAction(Qt.MoveAction)
self.unusedView.viewport().setAcceptDrops(True)
self.unusedModel = VariableListModel(
flags=Qt.ItemIsEnabled | Qt.ItemIsSelectable |
Qt.ItemIsDragEnabled
)
self.unusedView.setModel(self.unusedModel)
box.layout().addWidget(self.unusedView)
box = OWGUI.widgetBox(self.controlArea, "Output")
cb = OWGUI.checkBox(box, self, "autoCommit", "Auto commit")
b = OWGUI.button(box, self, "Commit", callback=self.commit)
OWGUI.setStopper(self, b, cb, "_outputChanged", callback=self.commit)
def setData(self, data):
"""
Set the input data.
"""
self._storeRoles()
self.closeContext("")
self.data = data
if data is not None:
self.openContext("", data)
domain = data.domain
features = (domain.variables + domain.class_vars +
domain.get_metas().values())
sort_by = []
unused = []
for feat in features:
hint = self.sortroles.get((feat.name, feat.var_type), None)
if hint is not None:
index, order = hint
sort_by.append((feat, index, order))
else:
unused.append(feat)
sort_by = sorted(sort_by, key=itemgetter(1))
self.sortByModel[:] = [feat for feat, _, _ in sort_by]
self.unusedModel[:] = unused
# Restore the sort orders
for i, (_, _, order) in enumerate(sort_by):
index = self.sortByModel.index(i, 0)
self.sortByModel.setData(index, order, SortOrderRole)
self.commit()
def _invalidate(self):
if self.autoCommit:
self.commit()
else:
self._outputChanged = True
def _sortingParams(self):
params = []
#.........这里部分代码省略.........