eric7/WebBrowser/QtHelp/HelpIndexWidget.py

branch
eric7
changeset 8565
207b47c2eed9
parent 8564
c48137b0d7ba
child 8685
b0669ce1066d
equal deleted inserted replaced
8564:c48137b0d7ba 8565:207b47c2eed9
99 elif modifiers & Qt.KeyboardModifier.ShiftModifier: 99 elif modifiers & Qt.KeyboardModifier.ShiftModifier:
100 self.newWindow.emit(document.url) 100 self.newWindow.emit(document.url)
101 else: 101 else:
102 self.openUrl.emit(document.url) 102 self.openUrl.emit(document.url)
103 103
104 def __documentsActivated(self, documents, keyword): 104 def __documentsActivated(self, documents, helpKeyword):
105 """ 105 """
106 Private slot to handle the activation of an entry with multiple help 106 Private slot to handle the activation of an entry with multiple help
107 documents. 107 documents.
108 108
109 @param documents list of help document link data structures 109 @param documents list of help document link data structures
110 @type list of QHelpLink 110 @type list of QHelpLink
111 @param keyword keyword for the entry 111 @param helpKeyword keyword for the entry
112 @type str 112 @type str
113 """ 113 """
114 modifiers = QApplication.keyboardModifiers() 114 modifiers = QApplication.keyboardModifiers()
115 document = ( 115 document = (
116 documents[0] 116 documents[0]
117 if len(documents) == 1 else 117 if len(documents) == 1 else
118 self.__selectDocument(documents, keyword) 118 self.__selectDocument(documents, helpKeyword)
119 ) 119 )
120 self.__documentActivated(document, keyword, modifiers) 120 self.__documentActivated(document, helpKeyword, modifiers)
121 121
122 def __selectDocument(self, documents, keyword): 122 def __selectDocument(self, documents, helpKeyword):
123 """ 123 """
124 Private method to give the user a chance to select among the 124 Private method to give the user a chance to select among the
125 given documents. 125 given documents.
126 126
127 @param documents list of help document link data structures 127 @param documents list of help document link data structures
128 @type list of QHelpLink 128 @type list of QHelpLink
129 @param keyword keyword for the documents 129 @param helpKeyword keyword for the documents
130 @type str 130 @type str
131 @return selected document 131 @return selected document
132 @rtype QHelpLink 132 @rtype QHelpLink
133 """ 133 """
134 document = QHelpLink() 134 document = QHelpLink()
135 from .HelpTopicDialog import HelpTopicDialog 135 from .HelpTopicDialog import HelpTopicDialog
136 dlg = HelpTopicDialog(self, keyword, documents) 136 dlg = HelpTopicDialog(self, helpKeyword, documents)
137 if dlg.exec() == QDialog.DialogCode.Accepted: 137 if dlg.exec() == QDialog.DialogCode.Accepted:
138 document = dlg.document() 138 document = dlg.document()
139 return document 139 return document
140 140
141 def __filterIndices(self, indexFilter): 141 def __filterIndices(self, indexFilter):
223 menu.move(self.__index.mapToGlobal(pos)) 223 menu.move(self.__index.mapToGlobal(pos))
224 224
225 act = menu.exec() 225 act = menu.exec()
226 model = self.__index.model() 226 model = self.__index.model()
227 if model is not None: 227 if model is not None:
228 keyword = model.data(idx, Qt.ItemDataRole.DisplayRole) 228 helpKeyword = model.data(idx, Qt.ItemDataRole.DisplayRole)
229 links = model.linksForKeyword(keyword) 229 helpLinks = self.__engine.documentsForKeyword(helpKeyword, "")
230 if len(links) == 1: 230 if len(helpLinks) == 1:
231 link = QUrl(links[list(links.keys())[0]]) 231 link = helpLinks[0].url
232 else: 232 else:
233 link = self.__selectLink(links, keyword) 233 link = self.__selectDocument(helpLinks, helpKeyword)
234 234
235 if not link.isEmpty() and link.isValid(): 235 if not link.isEmpty() and link.isValid():
236 if act == curTab: 236 if act == curTab:
237 self.openUrl.emit(link) 237 self.openUrl.emit(link)
238 elif act == newTab: 238 elif act == newTab:

eric ide

mercurial