本文整理汇总了Python中PyQt5.Qt.QTreeView.dragMoveEvent方法的典型用法代码示例。如果您正苦于以下问题:Python QTreeView.dragMoveEvent方法的具体用法?Python QTreeView.dragMoveEvent怎么用?Python QTreeView.dragMoveEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QTreeView
的用法示例。
在下文中一共展示了QTreeView.dragMoveEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dragMoveEvent
# 需要导入模块: from PyQt5.Qt import QTreeView [as 别名]
# 或者: from PyQt5.Qt.QTreeView import dragMoveEvent [as 别名]
def dragMoveEvent(self, event):
QTreeView.dragMoveEvent(self, event)
self.setDropIndicatorShown(False)
index = self.indexAt(event.pos())
if not index.isValid():
return
src_is_tb = event.mimeData().hasFormat('application/calibre+from_tag_browser')
item = index.data(Qt.UserRole)
if item.type == TagTreeItem.ROOT:
return
flags = self._model.flags(index)
if item.type == TagTreeItem.TAG and flags & Qt.ItemIsDropEnabled:
self.setDropIndicatorShown(not src_is_tb)
return
if item.type == TagTreeItem.CATEGORY and not item.is_gst:
fm_dest = self.db.metadata_for_field(item.category_key)
if fm_dest['kind'] == 'user':
if src_is_tb:
if event.dropAction() == Qt.MoveAction:
data = bytes(event.mimeData().data('application/calibre+from_tag_browser'))
src = json_loads(data)
for s in src:
if s[0] == TagTreeItem.TAG and \
(not s[1].startswith('@') or s[2]):
return
self.setDropIndicatorShown(True)
return
md = event.mimeData()
if hasattr(md, 'column_name'):
fm_src = self.db.metadata_for_field(md.column_name)
if md.column_name in ['authors', 'publisher', 'series'] or \
(fm_src['is_custom'] and (
(fm_src['datatype'] in ['series', 'text', 'enumeration'] and not fm_src['is_multiple']) or (
fm_src['datatype'] == 'composite' and fm_src['display'].get('make_category', False)))):
self.setDropIndicatorShown(True)
示例2: dragMoveEvent
# 需要导入模块: from PyQt5.Qt import QTreeView [as 别名]
# 或者: from PyQt5.Qt.QTreeView import dragMoveEvent [as 别名]
def dragMoveEvent(self, event):
QTreeView.dragMoveEvent(self, event)
self.setDropIndicatorShown(False)
index = self.indexAt(event.pos())
if not index.isValid():
return
src_is_tb = event.mimeData().hasFormat("application/calibre+from_tag_browser")
item = index.data(Qt.UserRole)
if item.type == TagTreeItem.ROOT:
return
flags = self._model.flags(index)
if item.type == TagTreeItem.TAG and flags & Qt.ItemIsDropEnabled:
self.setDropIndicatorShown(not src_is_tb)
return
if item.type == TagTreeItem.CATEGORY and not item.is_gst:
fm_dest = self.db.metadata_for_field(item.category_key)
if fm_dest["kind"] == "user":
if src_is_tb:
if event.dropAction() == Qt.MoveAction:
data = str(event.mimeData().data("application/calibre+from_tag_browser"))
src = cPickle.loads(data)
for s in src:
if s[0] == TagTreeItem.TAG and (not s[1].startswith("@") or s[2]):
return
self.setDropIndicatorShown(True)
return
md = event.mimeData()
if hasattr(md, "column_name"):
fm_src = self.db.metadata_for_field(md.column_name)
if md.column_name in ["authors", "publisher", "series"] or (
fm_src["is_custom"]
and (
(fm_src["datatype"] in ["series", "text", "enumeration"] and not fm_src["is_multiple"])
or (fm_src["datatype"] == "composite" and fm_src["display"].get("make_category", False))
)
):
self.setDropIndicatorShown(True)