本文整理汇总了Python中PyQt4.QtGui.QDirModel.data方法的典型用法代码示例。如果您正苦于以下问题:Python QDirModel.data方法的具体用法?Python QDirModel.data怎么用?Python QDirModel.data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QDirModel
的用法示例。
在下文中一共展示了QDirModel.data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: data
# 需要导入模块: from PyQt4.QtGui import QDirModel [as 别名]
# 或者: from PyQt4.QtGui.QDirModel import data [as 别名]
def data(self, index, role=Qt.DisplayRole):
"""
This is called when mouse-over of the dirmodel sections
"""
if index.isValid() and (index.column() == 0) and (role == Qt.CheckStateRole):
dir_now = unicode(self.filePath(index))
partial = self.__partial_check(dir_now)
if partial is not None:
return partial
elif dir_now in self.check_list['includes']:
return Qt.Checked
elif self.recursive is True:
par_dir = "/".join(unicode(dir_now).split("/")[:-1])
# the item is checked only if we have stored its path
if dir_now in self.check_list['excludes']:
return Qt.Unchecked
elif par_dir in self.check_list['excludes']:
return Qt.Unchecked
else:
# Recursively go down directory from parent to
# see if it should be included
checker = dir_now.split("/")
for val in range(1, len(checker)):
dir_part = "/".join(checker[:val+1])
if dir_part in self.check_list['includes']:
return Qt.Checked
# Nothing found
return Qt.Unchecked
else:
return Qt.Unchecked
# Standard QDirModel functionality
else:
return QDirModel.data(self, index, role)