eric7/WebBrowser/QtHelp/QtHelpDocumentationDialog.py

branch
eric7
changeset 8356
68ec9c3d4de5
parent 8318
962bce857696
child 8358
144a6b854f70
equal deleted inserted replaced
8355:8a7677a63c8d 8356:68ec9c3d4de5
14 from PyQt6.QtWidgets import ( 14 from PyQt6.QtWidgets import (
15 QDialog, QTreeWidgetItem, QListWidgetItem, QInputDialog, QLineEdit 15 QDialog, QTreeWidgetItem, QListWidgetItem, QInputDialog, QLineEdit
16 ) 16 )
17 from PyQt6.QtHelp import QHelpEngineCore 17 from PyQt6.QtHelp import QHelpEngineCore
18 18
19 from E5Gui import E5MessageBox, E5FileDialog 19 from E5Gui import EricMessageBox, EricFileDialog
20 from E5Gui.E5Application import e5App 20 from E5Gui.EricApplication import ericApp
21 21
22 from .Ui_QtHelpDocumentationDialog import Ui_QtHelpDocumentationDialog 22 from .Ui_QtHelpDocumentationDialog import Ui_QtHelpDocumentationDialog
23 23
24 24
25 class QtHelpDocumentationDialog(QDialog, Ui_QtHelpDocumentationDialog): 25 class QtHelpDocumentationDialog(QDialog, Ui_QtHelpDocumentationDialog):
54 """ 54 """
55 if ( 55 if (
56 index != 1 and 56 index != 1 and
57 (self.__hasChangedFilters() or self.__removedAttributes) 57 (self.__hasChangedFilters() or self.__removedAttributes)
58 ): 58 ):
59 yes = E5MessageBox.yesNo( 59 yes = EricMessageBox.yesNo(
60 self, 60 self,
61 self.tr("Unsaved Filter Changes"), 61 self.tr("Unsaved Filter Changes"),
62 self.tr("""The page contains unsaved changes. Shall they be""" 62 self.tr("""The page contains unsaved changes. Shall they be"""
63 """ saved?"""), 63 """ saved?"""),
64 yesDefault=True) 64 yesDefault=True)
83 self.__unregisteredDocs = [] 83 self.__unregisteredDocs = []
84 self.__tabsToClose = [] 84 self.__tabsToClose = []
85 85
86 try: 86 try:
87 self.__pluginHelpDocuments = ( 87 self.__pluginHelpDocuments = (
88 e5App().getObject("PluginManager").getPluginQtHelpFiles() 88 ericApp().getObject("PluginManager").getPluginQtHelpFiles()
89 ) 89 )
90 except KeyError: 90 except KeyError:
91 from PluginManager.PluginManager import PluginManager 91 from PluginManager.PluginManager import PluginManager
92 pluginManager = PluginManager(self, doLoadPlugins=False) 92 pluginManager = PluginManager(self, doLoadPlugins=False)
93 pluginManager.loadDocumentationSetPlugins() 93 pluginManager.loadDocumentationSetPlugins()
106 @pyqtSlot() 106 @pyqtSlot()
107 def on_addDocumentsButton_clicked(self): 107 def on_addDocumentsButton_clicked(self):
108 """ 108 """
109 Private slot to add QtHelp documents to the help database. 109 Private slot to add QtHelp documents to the help database.
110 """ 110 """
111 fileNames = E5FileDialog.getOpenFileNames( 111 fileNames = EricFileDialog.getOpenFileNames(
112 self, 112 self,
113 self.tr("Add Documentation"), 113 self.tr("Add Documentation"),
114 "", 114 "",
115 self.tr("Qt Compressed Help Files (*.qch)")) 115 self.tr("Qt Compressed Help Files (*.qch)"))
116 if not fileNames: 116 if not fileNames:
160 @type list of str 160 @type list of str
161 """ 161 """
162 for fileName in fileNames: 162 for fileName in fileNames:
163 ns = QHelpEngineCore.namespaceName(fileName) 163 ns = QHelpEngineCore.namespaceName(fileName)
164 if not ns: 164 if not ns:
165 E5MessageBox.warning( 165 EricMessageBox.warning(
166 self, 166 self,
167 self.tr("Add Documentation"), 167 self.tr("Add Documentation"),
168 self.tr( 168 self.tr(
169 """The file <b>{0}</b> is not a valid""" 169 """The file <b>{0}</b> is not a valid"""
170 """ Qt Help File.""").format(fileName) 170 """ Qt Help File.""").format(fileName)
172 continue 172 continue
173 173
174 if len(self.documentsList.findItems( 174 if len(self.documentsList.findItems(
175 ns, Qt.MatchFlag.MatchFixedString 175 ns, Qt.MatchFlag.MatchFixedString
176 )): 176 )):
177 E5MessageBox.warning( 177 EricMessageBox.warning(
178 self, 178 self,
179 self.tr("Add Documentation"), 179 self.tr("Add Documentation"),
180 self.tr( 180 self.tr(
181 """The namespace <b>{0}</b> is already registered.""") 181 """The namespace <b>{0}</b> is already registered.""")
182 .format(ns) 182 .format(ns)
194 @pyqtSlot() 194 @pyqtSlot()
195 def on_removeDocumentsButton_clicked(self): 195 def on_removeDocumentsButton_clicked(self):
196 """ 196 """
197 Private slot to remove a document from the help database. 197 Private slot to remove a document from the help database.
198 """ 198 """
199 res = E5MessageBox.yesNo( 199 res = EricMessageBox.yesNo(
200 self, 200 self,
201 self.tr("Remove Documentation"), 201 self.tr("Remove Documentation"),
202 self.tr( 202 self.tr(
203 """Do you really want to remove the selected documentation """ 203 """Do you really want to remove the selected documentation """
204 """sets from the database?""")) 204 """sets from the database?"""))
209 209
210 items = self.documentsList.selectedItems() 210 items = self.documentsList.selectedItems()
211 for item in items: 211 for item in items:
212 ns = item.text() 212 ns = item.text()
213 if ns in list(openedDocs.values()): 213 if ns in list(openedDocs.values()):
214 res = E5MessageBox.yesNo( 214 res = EricMessageBox.yesNo(
215 self, 215 self,
216 self.tr("Remove Documentation"), 216 self.tr("Remove Documentation"),
217 self.tr( 217 self.tr(
218 """Some documents currently opened reference the """ 218 """Some documents currently opened reference the """
219 """documentation you are attempting to remove. """ 219 """documentation you are attempting to remove. """
220 """Removing the documentation will close those """ 220 """Removing the documentation will close those """
221 """documents. Remove anyway?"""), 221 """documents. Remove anyway?"""),
222 icon=E5MessageBox.Warning) 222 icon=EricMessageBox.Warning)
223 if not res: 223 if not res:
224 return 224 return
225 self.__unregisteredDocs.append(ns) 225 self.__unregisteredDocs.append(ns)
226 for docId in openedDocs: 226 for docId in openedDocs:
227 if openedDocs[docId] == ns and docId not in self.__tabsToClose: 227 if openedDocs[docId] == ns and docId not in self.__tabsToClose:
405 @pyqtSlot() 405 @pyqtSlot()
406 def on_removeFiltersButton_clicked(self): 406 def on_removeFiltersButton_clicked(self):
407 """ 407 """
408 Private slot to remove the selected filters. 408 Private slot to remove the selected filters.
409 """ 409 """
410 ok = E5MessageBox.yesNo( 410 ok = EricMessageBox.yesNo(
411 self, 411 self,
412 self.tr("Remove Filters"), 412 self.tr("Remove Filters"),
413 self.tr( 413 self.tr(
414 """Do you really want to remove the selected filters """ 414 """Do you really want to remove the selected filters """
415 """from the database?""")) 415 """from the database?"""))
433 @pyqtSlot() 433 @pyqtSlot()
434 def on_removeAttributesButton_clicked(self): 434 def on_removeAttributesButton_clicked(self):
435 """ 435 """
436 Private slot to remove the selected filter attributes. 436 Private slot to remove the selected filter attributes.
437 """ 437 """
438 ok = E5MessageBox.yesNo( 438 ok = EricMessageBox.yesNo(
439 self, 439 self,
440 self.tr("Remove Attributes"), 440 self.tr("Remove Attributes"),
441 self.tr( 441 self.tr(
442 """Do you really want to remove the selected attributes """ 442 """Do you really want to remove the selected attributes """
443 """from the database?""")) 443 """from the database?"""))

eric ide

mercurial