本文整理汇总了Python中PyQt5.QtCore.QModelIndex.internalPointer方法的典型用法代码示例。如果您正苦于以下问题:Python QModelIndex.internalPointer方法的具体用法?Python QModelIndex.internalPointer怎么用?Python QModelIndex.internalPointer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QModelIndex
的用法示例。
在下文中一共展示了QModelIndex.internalPointer方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getItem
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import internalPointer [as 别名]
def getItem(self, index: QModelIndex) -> ProtocolTreeItem:
if index.isValid():
item = index.internalPointer()
if item:
return item
return self.rootItem
示例2: setData
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import internalPointer [as 别名]
def setData(self, index: QModelIndex, value: QVariant, role: int = None):
if not index.isValid():
return False
item = index.internalPointer()
if role == Qt.CheckStateRole:
childrenCount = item.childrenCount()
if childrenCount:
for i in range(childrenCount):
self.setData(index.child(i, 0), value, role = role)
else:
item.selected = bool(value)
self.dataChanged.emit(index, index, [Qt.CheckStateRole])
# recalculate parents
p = index
while True:
p = p.parent()
if p.isValid():
self.dataChanged.emit(p, p, [Qt.CheckStateRole])
else:
break
# success
return True
if role == Qt.EditRole:
assert index.column() == TaskTreeColumn.FileName
item.setNameByUser(value)
self.dataChanged.emit(index, index, [Qt.DisplayRole])
return True
return False
示例3: parent
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import internalPointer [as 别名]
def parent(self, index: QtCore.QModelIndex):
if not index.isValid():
return QtCore.QModelIndex()
item = index.internalPointer().parent
if item == self.root or item is None:
return QtCore.QModelIndex()
else:
return self.createIndex(item.row, 0, item)
示例4: rowCount
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import internalPointer [as 别名]
def rowCount(self, parent: QModelIndex = None, *args, **kwargs):
if not self._root:
return 0
if parent.isValid():
parentItem = parent.internalPointer()
return parentItem.childrenCount()
else:
return self._root.childrenCount()
示例5: data
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import internalPointer [as 别名]
def data(self, index: QtCore.QModelIndex, role=QtCore.Qt.DisplayRole):
if index.isValid():
ip = index.internalPointer()
if index.column() == 0:
if role == QtCore.Qt.DisplayRole:
return ("*" if ip.unfinished() else "") + ip.title()
elif role == QtCore.Qt.ToolTipRole:
return ip.tooltip()
elif role == QtCore.Qt.DecorationRole:
return ip.image()
示例6: parent
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import internalPointer [as 别名]
def parent(self, index: QModelIndex = None):
if not index.isValid():
return QModelIndex()
childItem = index.internalPointer()
parentItem = childItem.parent
if parentItem == self._root:
return QModelIndex()
else:
return self.createIndex(parentItem.siblingNumber(), 0, parentItem)
示例7: data
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import internalPointer [as 别名]
def data(self, index: QModelIndex, role = None):
if not index.isValid():
return None
item = index.internalPointer()
if role == Qt.DisplayRole:
return item.data(index.column())
elif role == Qt.CheckStateRole and index.column() == TaskTreeColumn.FileName:
return item.selected
elif role == Qt.DecorationRole and index.column() == TaskTreeColumn.FileName:
# TODO: use with real icons
from PyQt5.QtGui import QIcon
return QIcon.fromTheme("xware-desktop")
return None
示例8: _indexToItem
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import internalPointer [as 别名]
def _indexToItem(self, index: QModelIndex):
if not index.isValid():
return self._root
else:
return index.internalPointer()
示例9: parentFromIndex
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import internalPointer [as 别名]
def parentFromIndex(self, index):
index = QModelIndex(index) # explicitly convert from QPersistentModelIndex
if index.isValid():
return index.internalPointer()
return self._root
示例10: itemFromIndex
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import internalPointer [as 别名]
def itemFromIndex(self, index):
index = QModelIndex(index) # explicitly convert from QPersistentModelIndex
if index.isValid():
return index.internalPointer().childAt(index.row())
return self._root
示例11: editorWidget
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import internalPointer [as 别名]
#.........这里部分代码省略.........
QWidget.resizeEvent(self, event)
def setScrollBarVisibility(self):
"""
Since the texteEdit scrollBar has been reparented to self, it is not
hidden when stack changes. We have to do it manually.
"""
self.txtEditScrollBar.setVisible(self.stack.currentIndex() == 0)
def setFolderView(self, v):
oldV = self.folderView
if v == "cork":
self.folderView = "cork"
elif v == "outline":
self.folderView = "outline"
else:
self.folderView = "text"
# Saving value
settings.folderView = self.folderView
if oldV != self.folderView and self.currentIndex:
self.setCurrentModelIndex(self.currentIndex)
def setCorkSizeFactor(self, v):
self.corkView.itemDelegate().setCorkSizeFactor(v)
self.redrawCorkItems()
def redrawCorkItems(self):
r = self.corkView.rootIndex()
if r.isValid():
count = r.internalPointer().childCount()
elif self._model:
count = self._model.rootItem.childCount()
else:
count = 0
for c in range(count):
self.corkView.itemDelegate().sizeHintChanged.emit(r.child(c, 0))
def updateTabTitle(self):
"""
`editorWidget` belongs to a `QTabWidget` in a `tabSplitter`. We update
the tab title to reflect that of current item.
"""
# `self._tabWidget` is set by mainEditor when creating tab and `editorWidget`.
# if `editorWidget` is ever used out of `mainEditor`, this could throw
# an error.
if not self._tabWidget:
return
if self.currentIndex.isValid():
item = self.currentIndex.internalPointer()
elif self._model:
item = self._model.rootItem
else:
return
i = self._tabWidget.indexOf(self)
self._tabWidget.setTabText(i, self.ellidedTitle(item.title()))
self._tabWidget.setTabToolTip(i, item.title())
def ellidedTitle(self, title):
示例12: item
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import internalPointer [as 别名]
def item(self, index: QtCore.QModelIndex) -> FileItem:
return index.internalPointer() if index.isValid() else self.root_item
示例13: editorWidget
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import internalPointer [as 别名]
class editorWidget(QWidget, Ui_editorWidget_ui):
toggledSpellcheck = pyqtSignal(bool)
dictChanged = pyqtSignal(str)
def __init__(self, parent):
QWidget.__init__(self, parent)
self.setupUi(self)
self.currentIndex = QModelIndex()
self.currentID = None
self.txtEdits = []
self.scroll.setBackgroundRole(QPalette.Base)
self.toggledSpellcheck.connect(self.txtRedacText.toggleSpellcheck, AUC)
self.dictChanged.connect(self.txtRedacText.setDict, AUC)
self.txtRedacText.setHighlighting(True)
self.currentDict = ""
self.spellcheck = True
self.folderView = "cork"
self.mw = mainWindow()
# def setModel(self, model):
# self._model = model
# self.setView()
def setFolderView(self, v):
oldV = self.folderView
if v == "cork":
self.folderView = "cork"
elif v == "outline":
self.folderView = "outline"
else:
self.folderView = "text"
# Saving value
settings.folderView = self.folderView
if oldV != self.folderView and self.currentIndex:
self.setCurrentModelIndex(self.currentIndex)
def setCorkSizeFactor(self, v):
self.corkView.itemDelegate().setCorkSizeFactor(v)
self.redrawCorkItems()
def redrawCorkItems(self):
r = self.corkView.rootIndex()
if r.isValid():
count = r.internalPointer().childCount()
else:
count = self.mw.mdlOutline.rootItem.childCount()
for c in range(count):
self.corkView.itemDelegate().sizeHintChanged.emit(r.child(c, 0))
def setView(self):
# index = mainWindow().treeRedacOutline.currentIndex()
# Couting the number of other selected items
# sel = []
# for i in mainWindow().treeRedacOutline.selectionModel().selection().indexes():
# if i.column() != 0: continue
# if i not in sel: sel.append(i)
# if len(sel) != 0:
# item = index.internalPointer()
# else:
# index = QModelIndex()
# item = self.mw.mdlOutline.rootItem
# self.currentIndex = index
if self.currentIndex.isValid():
item = self.currentIndex.internalPointer()
else:
item = self.mw.mdlOutline.rootItem
def addTitle(itm):
edt = textEditView(self, html="<h{l}>{t}</h{l}>".format(l=min(itm.level() + 1, 5), t=itm.title()),
autoResize=True)
edt.setFrameShape(QFrame.NoFrame)
self.txtEdits.append(edt)
l.addWidget(edt)
def addLine():
line = QFrame(self.text)
line.setFrameShape(QFrame.HLine)
line.setFrameShadow(QFrame.Sunken)
l.addWidget(line)
def addText(itm):
edt = textEditView(self,
index=itm.index(),
spellcheck=self.spellcheck,
dict=settings.dict,
highlighting=True,
autoResize=True)
edt.setFrameShape(QFrame.NoFrame)
edt.setStyleSheet("background: {};".format(settings.textEditor["background"]))
edt.setStatusTip("{} ({})".format(itm.path(), itm.type()))
self.toggledSpellcheck.connect(edt.toggleSpellcheck, AUC)
self.dictChanged.connect(edt.setDict, AUC)
#.........这里部分代码省略.........