src/eric7/WebBrowser/QtHelp/HelpTopicDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9653
e67609152c5e
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
16 16
17 class HelpTopicDialog(QDialog, Ui_HelpTopicDialog): 17 class HelpTopicDialog(QDialog, Ui_HelpTopicDialog):
18 """ 18 """
19 Class implementing a dialog to select a help topic to display. 19 Class implementing a dialog to select a help topic to display.
20 """ 20 """
21
21 def __init__(self, parent, helpKeyword, documents): 22 def __init__(self, parent, helpKeyword, documents):
22 """ 23 """
23 Constructor 24 Constructor
24 25
25 @param parent reference to the parent widget 26 @param parent reference to the parent widget
26 @type QWidget 27 @type QWidget
27 @param helpKeyword keyword for the link set 28 @param helpKeyword keyword for the link set
28 @type str 29 @type str
29 @param documents list of help document link data structures 30 @param documents list of help document link data structures
30 @type list of QHelpLink 31 @type list of QHelpLink
31 """ 32 """
32 super().__init__(parent) 33 super().__init__(parent)
33 self.setupUi(self) 34 self.setupUi(self)
34 35
35 self.label.setText(self.tr("Choose a &topic for <b>{0}</b>:") 36 self.label.setText(
36 .format(helpKeyword)) 37 self.tr("Choose a &topic for <b>{0}</b>:").format(helpKeyword)
37 38 )
39
38 for document in documents: 40 for document in documents:
39 itm = QListWidgetItem(document.title, self.topicsList) 41 itm = QListWidgetItem(document.title, self.topicsList)
40 itm.setData(Qt.ItemDataRole.UserRole, document.url) 42 itm.setData(Qt.ItemDataRole.UserRole, document.url)
41 if self.topicsList.count() > 0: 43 if self.topicsList.count() > 0:
42 self.topicsList.setCurrentRow(0) 44 self.topicsList.setCurrentRow(0)
43 self.topicsList.setFocus() 45 self.topicsList.setFocus()
44 46
45 self.topicsList.itemActivated.connect(self.accept) 47 self.topicsList.itemActivated.connect(self.accept)
46 48
47 def document(self): 49 def document(self):
48 """ 50 """
49 Public method to retrieve the selected help topic. 51 Public method to retrieve the selected help topic.
50 52
51 @return help document link for the selected help topic 53 @return help document link for the selected help topic
52 @rtype QHelpLink 54 @rtype QHelpLink
53 """ 55 """
54 document = QHelpLink() 56 document = QHelpLink()
55 57
56 itm = self.topicsList.currentItem() 58 itm = self.topicsList.currentItem()
57 if itm is not None: 59 if itm is not None:
58 document.title = itm.text() 60 document.title = itm.text()
59 document.url = itm.data(Qt.ItemDataRole.UserRole) 61 document.url = itm.data(Qt.ItemDataRole.UserRole)
60 62
61 return document 63 return document

eric ide

mercurial