Fix Qt.UserRole access warning

This commit is contained in:
Veronica Berglyd Olsen
2023-06-05 00:08:11 +02:00
parent 033b9f2a59
commit 2f0ac4fe17
12 changed files with 51 additions and 41 deletions
+8 -6
View File
@@ -53,6 +53,8 @@ class GuiProjectLoad(QDialog):
C_COUNT = 1
C_TIME = 2
D_PATH = Qt.ItemDataRole.UserRole
def __init__(self, mainGui):
super().__init__(parent=mainGui)
@@ -167,7 +169,7 @@ class GuiProjectLoad(QDialog):
selItems = self.listBox.selectedItems()
if selItems:
self.openPath = selItems[0].data(self.C_NAME, Qt.UserRole)
self.openPath = selItems[0].data(self.C_NAME, self.D_PATH)
self.openState = self.OPEN_STATE
self.accept()
@@ -178,7 +180,7 @@ class GuiProjectLoad(QDialog):
"""
selList = self.listBox.selectedItems()
if selList:
self.selPath.setText(selList[0].data(self.C_NAME, Qt.UserRole))
self.selPath.setText(selList[0].data(self.C_NAME, self.D_PATH))
return
def _doBrowse(self):
@@ -232,7 +234,7 @@ class GuiProjectLoad(QDialog):
)
if msgYes:
CONFIG.recentProjects.remove(
selList[0].data(self.C_NAME, Qt.UserRole)
selList[0].data(self.C_NAME, self.D_PATH)
)
self._populateList()
@@ -274,12 +276,12 @@ class GuiProjectLoad(QDialog):
newItem = QTreeWidgetItem([""]*4)
newItem.setIcon(self.C_NAME, nwxIcon)
newItem.setText(self.C_NAME, title)
newItem.setData(self.C_NAME, Qt.UserRole, path)
newItem.setData(self.C_NAME, self.D_PATH, path)
newItem.setText(self.C_COUNT, formatInt(words))
newItem.setText(self.C_TIME, datetime.fromtimestamp(time).strftime("%x %X"))
newItem.setTextAlignment(self.C_NAME, Qt.AlignLeft | Qt.AlignVCenter)
newItem.setTextAlignment(self.C_NAME, Qt.AlignLeft | Qt.AlignVCenter)
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight | Qt.AlignVCenter)
newItem.setTextAlignment(self.C_TIME, Qt.AlignRight | Qt.AlignVCenter)
newItem.setTextAlignment(self.C_TIME, Qt.AlignRight | Qt.AlignVCenter)
newItem.setFont(self.C_TIME, self.mainTheme.guiFontFixed)
self.listBox.addTopLevelItem(newItem)