當前位置: 首頁>>代碼示例>>Python>>正文


Python QTreeView.dragMoveEvent方法代碼示例

本文整理匯總了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)
開發者ID:BobPyron,項目名稱:calibre,代碼行數:39,代碼來源:view.py

示例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)
開發者ID:hashken,項目名稱:calibre,代碼行數:39,代碼來源:view.py


注:本文中的PyQt4.Qt.QTreeView.dragMoveEvent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。