本文整理匯總了Python中PyQt4.Qt.QTreeView.dragMoveEvent方法的典型用法代碼示例。如果您正苦於以下問題:Python QTreeView.dragMoveEvent方法的具體用法?Python QTreeView.dragMoveEvent怎麽用?Python QTreeView.dragMoveEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt4.Qt.QTreeView
的用法示例。
在下文中一共展示了QTreeView.dragMoveEvent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: dragMoveEvent
# 需要導入模塊: from PyQt4.Qt import QTreeView [as 別名]
# 或者: from PyQt4.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).toPyObject()
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)
示例2: dragMoveEvent
# 需要導入模塊: from PyQt4.Qt import QTreeView [as 別名]
# 或者: from PyQt4.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).toPyObject()
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)