eric7/WebBrowser/QtHelp/QtHelpDocumentationDialog.py

Thu, 10 Jun 2021 19:32:22 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 10 Jun 2021 19:32:22 +0200
branch
eric7
changeset 8421
cd4eee7f1d28
parent 8358
144a6b854f70
permissions
-rw-r--r--

QtHelp: changed the code to not use deprecated methods anymore.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
3 # Copyright (c) 2009 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to manage the QtHelp documentation database.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
10 import sqlite3
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8235
diff changeset
11 import contextlib
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
12
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
13 from PyQt6.QtCore import pyqtSlot, Qt, QItemSelectionModel
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
14 from PyQt6.QtWidgets import (
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
15 QDialog, QTreeWidgetItem, QListWidgetItem, QInputDialog, QLineEdit
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
16 )
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
17 from PyQt6.QtHelp import QHelpEngineCore
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
8358
144a6b854f70 Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8356
diff changeset
19 from EricWidgets import EricMessageBox, EricFileDialog
144a6b854f70 Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8356
diff changeset
20 from EricWidgets.EricApplication import ericApp
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 535
diff changeset
21
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
22 from .Ui_QtHelpDocumentationDialog import Ui_QtHelpDocumentationDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
24
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 class QtHelpDocumentationDialog(QDialog, Ui_QtHelpDocumentationDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Class implementing a dialog to manage the QtHelp documentation database.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 def __init__(self, engine, parent):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param engine reference to the help engine (QHelpEngine)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param parent reference to the parent widget (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
36 super().__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.__engine = engine
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.__mw = parent
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
42 self.__initDocumentsTab()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
43 self.__initFiltersTab()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
44
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
45 self.tabWidget.setCurrentIndex(0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
46
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
47 @pyqtSlot(int)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
48 def on_tabWidget_currentChanged(self, index):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
49 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
50 Private slot handling a change of the current tab.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
51
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
52 @param index index of the current tab
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
53 @type int
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
54 """
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
55 if (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
56 index != 1 and
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
57 (self.__hasChangedFilters() or self.__removedAttributes)
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
58 ):
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
59 yes = EricMessageBox.yesNo(
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
60 self,
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
61 self.tr("Unsaved Filter Changes"),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
62 self.tr("""The page contains unsaved changes. Shall they be"""
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
63 """ saved?"""),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
64 yesDefault=True)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
65 if yes:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
66 self.on_applyFilterChangesButton_clicked()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
67
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
68 ##################################################################
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
69 ## Documentations Tab
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
70 ##################################################################
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
71
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
72 def __initDocumentsTab(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
73 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
74 Private method to initialize the documents tab.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
75 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
76 self.documentsList.clear()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
77 self.removeDocumentsButton.setEnabled(False)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
78
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 docs = self.__engine.registeredDocumentations()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.documentsList.addItems(docs)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
81
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.__registeredDocs = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.__unregisteredDocs = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.__tabsToClose = []
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
85
5224
7454861e4106 Corrected a bug using a class variable, harmonized the code and moved the QtHelp stuff to a separate directory so the files can be used from both variants.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4875
diff changeset
86 try:
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
87 self.__pluginHelpDocuments = (
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
88 ericApp().getObject("PluginManager").getPluginQtHelpFiles()
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
89 )
5224
7454861e4106 Corrected a bug using a class variable, harmonized the code and moved the QtHelp stuff to a separate directory so the files can be used from both variants.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4875
diff changeset
90 except KeyError:
7454861e4106 Corrected a bug using a class variable, harmonized the code and moved the QtHelp stuff to a separate directory so the files can be used from both variants.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4875
diff changeset
91 from PluginManager.PluginManager import PluginManager
6629
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
92 pluginManager = PluginManager(self, doLoadPlugins=False)
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
93 pluginManager.loadDocumentationSetPlugins()
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
94 pluginManager.activatePlugins()
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
95 self.__pluginHelpDocuments = pluginManager.getPluginQtHelpFiles()
5224
7454861e4106 Corrected a bug using a class variable, harmonized the code and moved the QtHelp stuff to a separate directory so the files can be used from both variants.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4875
diff changeset
96 self.addPluginButton.setEnabled(bool(self.__pluginHelpDocuments))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 def on_documentsList_itemSelectionChanged(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 Private slot handling a change of the documents selection.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 """
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
103 self.removeDocumentsButton.setEnabled(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
104 len(self.documentsList.selectedItems()) != 0)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 @pyqtSlot()
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
107 def on_addDocumentsButton_clicked(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 """
5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
109 Private slot to add QtHelp documents to the help database.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
111 fileNames = EricFileDialog.getOpenFileNames(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
113 self.tr("Add Documentation"),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 "",
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
115 self.tr("Qt Compressed Help Files (*.qch)"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 if not fileNames:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
119 self.__registerDocumentations(fileNames)
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
120
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
121 @pyqtSlot()
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
122 def on_addPluginButton_clicked(self):
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
123 """
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
124 Private slot to add QtHelp documents provided by plug-ins to
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
125 the help database.
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
126 """
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
127 from .QtHelpDocumentationSelectionDialog import (
5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
128 QtHelpDocumentationSelectionDialog
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
129 )
5393
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
130 dlg = QtHelpDocumentationSelectionDialog(
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
131 self.__pluginHelpDocuments,
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
132 QtHelpDocumentationSelectionDialog.AddMode,
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
133 self)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
134 if dlg.exec() == QDialog.DialogCode.Accepted:
5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
135 documents = dlg.getData()
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
136 if not documents:
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
137 return
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
138
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
139 self.__registerDocumentations(documents)
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
140
5393
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
141 @pyqtSlot()
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
142 def on_managePluginButton_clicked(self):
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
143 """
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
144 Private slot to manage the QtHelp documents provided by plug-ins.
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
145 """
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
146 from .QtHelpDocumentationSelectionDialog import (
5393
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
147 QtHelpDocumentationSelectionDialog
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
148 )
5393
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
149 dlg = QtHelpDocumentationSelectionDialog(
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
150 self.__pluginHelpDocuments,
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
151 QtHelpDocumentationSelectionDialog.ManageMode,
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
152 self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
153 dlg.exec()
5393
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
154
5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
155 def __registerDocumentations(self, fileNames):
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
156 """
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
157 Private method to register a given list of documentations.
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
158
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
159 @param fileNames list of documentation files to be registered
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
160 @type list of str
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5224
diff changeset
161 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 for fileName in fileNames:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 ns = QHelpEngineCore.namespaceName(fileName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 if not ns:
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
165 EricMessageBox.warning(
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
166 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
167 self.tr("Add Documentation"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
168 self.tr(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
169 """The file <b>{0}</b> is not a valid"""
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
170 """ Qt Help File.""").format(fileName)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 continue
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
174 if len(self.documentsList.findItems(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
175 ns, Qt.MatchFlag.MatchFixedString
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
176 )):
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
177 EricMessageBox.warning(
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
178 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
179 self.tr("Add Documentation"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
180 self.tr(
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
181 """The namespace <b>{0}</b> is already registered.""")
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
182 .format(ns)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 continue
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.__engine.registerDocumentation(fileName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 self.documentsList.addItem(ns)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 self.__registeredDocs.append(ns)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 if ns in self.__unregisteredDocs:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 self.__unregisteredDocs.remove(ns)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
191
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
192 self.__initFiltersTab()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 @pyqtSlot()
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
195 def on_removeDocumentsButton_clicked(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 Private slot to remove a document from the help database.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
199 res = EricMessageBox.yesNo(
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
200 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
201 self.tr("Remove Documentation"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
202 self.tr(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
203 """Do you really want to remove the selected documentation """
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
204 """sets from the database?"""))
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
205 if not res:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 openedDocs = self.__mw.getSourceFileList()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 items = self.documentsList.selectedItems()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 for item in items:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 ns = item.text()
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
213 if ns in list(openedDocs.values()):
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
214 res = EricMessageBox.yesNo(
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
215 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
216 self.tr("Remove Documentation"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
217 self.tr(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
218 """Some documents currently opened reference the """
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
219 """documentation you are attempting to remove. """
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
220 """Removing the documentation will close those """
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
221 """documents. Remove anyway?"""),
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
222 icon=EricMessageBox.Warning)
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
223 if not res:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 self.__unregisteredDocs.append(ns)
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5393
diff changeset
226 for docId in openedDocs:
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5393
diff changeset
227 if openedDocs[docId] == ns and docId not in self.__tabsToClose:
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5393
diff changeset
228 self.__tabsToClose.append(docId)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 itm = self.documentsList.takeItem(self.documentsList.row(item))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 del itm
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 self.__engine.unregisterDocumentation(ns)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 if self.documentsList.count():
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
235 self.documentsList.setCurrentRow(
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
236 0, QItemSelectionModel.SelectionFlag.ClearAndSelect)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
238 def hasDocumentationChanges(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 """
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
240 Public slot to test the dialog for changes of configured QtHelp
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
241 documents.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 @return flag indicating presence of changes
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
244 @rtype bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 """
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
246 return (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
247 len(self.__registeredDocs) > 0 or
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
248 len(self.__unregisteredDocs) > 0
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
249 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 def getTabsToClose(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 Public method to get the list of tabs to close.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
255 @return list of tab ids to be closed
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
256 @rtype list of int
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 """
880
52ed20236a1c Added the option to not use the native file dialog to prevent crashes on Linux.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
258 return self.__tabsToClose
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
259
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
260 ##################################################################
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
261 ## Filters Tab
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
262 ##################################################################
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
263
8421
cd4eee7f1d28 QtHelp: changed the code to not use deprecated methods anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
264 # TODO: change this to use the new QHelpFilterSettingsWidget class
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
265 def __initFiltersTab(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
266 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
267 Private method to initialize the filters tab.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
268 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
269 self.removeFiltersButton.setEnabled(False)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
270 self.removeAttributesButton.setEnabled(False)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
271
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
272 # save the current and selected filters
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
273 currentFilter = self.filtersList.currentItem()
8235
78e6d29eb773 Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator) (batch 3).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
274 currentFilterText = currentFilter.text() if currentFilter else ""
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
275 selectedFiltersText = [
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
276 itm.text() for itm in self.filtersList.selectedItems()]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
277
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
278 # save the selected attributes
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
279 selectedAttributesText = [
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
280 itm.text(0) for itm in self.attributesList.selectedItems()]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
281
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
282 self.filtersList.clear()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
283 self.attributesList.clear()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
284
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
285 helpEngineCore = QHelpEngineCore(self.__engine.collectionFile())
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
286 helpFilterEngine = helpEngineCore.filterEngine()
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
287
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
288 self.__removedFilters = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
289 self.__filterMap = {}
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
290 self.__filterMapBackup = {}
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
291 self.__removedAttributes = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
292
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
293 for filterName in helpFilterEngine.filters():
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
294 filterData = helpFilterEngine.filterData(filterName)
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
295 self.__filterMapBackup[filterName] = filterData
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
296 if filterName not in self.__filterMap:
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
297 self.__filterMap[filterName] = filterData
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
298
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
299 self.filtersList.addItems(sorted(self.__filterMap.keys()))
8421
cd4eee7f1d28 QtHelp: changed the code to not use deprecated methods anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
300 for component in helpFilterEngine.availableComponents():
cd4eee7f1d28 QtHelp: changed the code to not use deprecated methods anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
301 QTreeWidgetItem(self.attributesList, [component])
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
302 self.attributesList.sortItems(0, Qt.SortOrder.AscendingOrder)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
303
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
304 if selectedFiltersText or currentFilterText or selectedAttributesText:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
305 # restore the selected filters
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
306 for txt in selectedFiltersText:
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
307 items = self.filtersList.findItems(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
308 txt, Qt.MatchFlag.MatchExactly)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
309 for itm in items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
310 itm.setSelected(True)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
311 # restore the current filter
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
312 if currentFilterText:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
313 items = self.filtersList.findItems(currentFilterText,
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
314 Qt.MatchFlag.MatchExactly)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
315 if items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
316 self.filtersList.setCurrentItem(
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
317 items[0], QItemSelectionModel.SelectionFlag.NoUpdate)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
318 # restore the selected attributes
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
319 for txt in selectedAttributesText:
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
320 items = self.attributesList.findItems(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
321 txt, Qt.MatchFlag.MatchExactly, 0)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
322 for itm in items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
323 itm.setSelected(True)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
324 elif self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
325 self.filtersList.setCurrentRow(0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
326
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
327 @pyqtSlot(QListWidgetItem, QListWidgetItem)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
328 def on_filtersList_currentItemChanged(self, current, previous):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
329 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
330 Private slot to update the attributes depending on the current filter.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
331
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
332 @param current reference to the current item (QListWidgetitem)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
333 @param previous reference to the previous current item
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
334 (QListWidgetItem)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
335 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
336 checkedList = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
337 if current is not None:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
338 checkedList = self.__filterMap[current.text()]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
339 for index in range(0, self.attributesList.topLevelItemCount()):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
340 itm = self.attributesList.topLevelItem(index)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
341 if itm.text(0) in checkedList:
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
342 itm.setCheckState(0, Qt.CheckState.Checked)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
343 else:
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
344 itm.setCheckState(0, Qt.CheckState.Unchecked)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
345
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
346 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
347 def on_filtersList_itemSelectionChanged(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
348 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
349 Private slot handling a change of selected filters.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
350 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
351 self.removeFiltersButton.setEnabled(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
352 len(self.filtersList.selectedItems()) > 0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
353
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
354 @pyqtSlot(QTreeWidgetItem, int)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
355 def on_attributesList_itemChanged(self, item, column):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
356 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
357 Private slot to handle a change of an attribute.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
358
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
359 @param item reference to the changed item (QTreeWidgetItem)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
360 @param column column containing the change (integer)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
361 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
362 if self.filtersList.currentItem() is None:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
363 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
364
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
365 customFilter = self.filtersList.currentItem().text()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
366 if customFilter not in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
367 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
368
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
369 newAtts = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
370 for index in range(0, self.attributesList.topLevelItemCount()):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
371 itm = self.attributesList.topLevelItem(index)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
372 if itm.checkState(0) == Qt.CheckState.Checked:
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
373 newAtts.append(itm.text(0))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
374 self.__filterMap[customFilter] = newAtts
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
375
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
376 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
377 def on_attributesList_itemSelectionChanged(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
378 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
379 Private slot handling the selection of attributes.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
380 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
381 self.removeAttributesButton.setEnabled(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
382 len(self.attributesList.selectedItems()) != 0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
383
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
384 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
385 def on_addFilterButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
386 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
387 Private slot to add a new filter.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
388 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
389 customFilter, ok = QInputDialog.getText(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
390 None,
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
391 self.tr("Add Filter"),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
392 self.tr("Filter name:"),
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
393 QLineEdit.EchoMode.Normal)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
394 if not customFilter:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
395 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
396
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
397 if customFilter not in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
398 self.__filterMap[customFilter] = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
399 self.filtersList.addItem(customFilter)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
400
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
401 itm = self.filtersList.findItems(
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
402 customFilter, Qt.MatchFlag.MatchCaseSensitive)[0]
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
403 self.filtersList.setCurrentItem(itm)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
404
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
405 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
406 def on_removeFiltersButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
407 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
408 Private slot to remove the selected filters.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
409 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
410 ok = EricMessageBox.yesNo(
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
411 self,
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
412 self.tr("Remove Filters"),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
413 self.tr(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
414 """Do you really want to remove the selected filters """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
415 """from the database?"""))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
416 if not ok:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
417 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
418
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
419 items = self.filtersList.selectedItems()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
420 for item in items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
421 itm = self.filtersList.takeItem(self.filtersList.row(item))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
422 if itm is None:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
423 continue
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
424
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
425 del self.__filterMap[itm.text()]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
426 self.__removedFilters.append(itm.text())
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
427 del itm
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
428
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
429 if self.filtersList.count():
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
430 self.filtersList.setCurrentRow(
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
431 0, QItemSelectionModel.SelectionFlag.ClearAndSelect)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
432
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
433 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
434 def on_removeAttributesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
435 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
436 Private slot to remove the selected filter attributes.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
437 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
438 ok = EricMessageBox.yesNo(
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
439 self,
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
440 self.tr("Remove Attributes"),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
441 self.tr(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
442 """Do you really want to remove the selected attributes """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
443 """from the database?"""))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
444 if not ok:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
445 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
446
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
447 items = self.attributesList.selectedItems()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
448 for item in items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
449 itm = self.attributesList.takeTopLevelItem(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
450 self.attributesList.indexOfTopLevelItem(item))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
451 if itm is None:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
452 continue
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
453
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
454 attr = itm.text(0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
455 self.__removedAttributes.append(attr)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
456 for customFilter in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
457 if attr in self.__filterMap[customFilter]:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
458 self.__filterMap[customFilter].remove(attr)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
459
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
460 del itm
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
461
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
462 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
463 def on_unusedAttributesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
464 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
465 Private slot to select all unused attributes.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
466 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
467 # step 1: determine all used attributes
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
468 attributes = set()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
469 for customFilter in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
470 attributes |= set(self.__filterMap[customFilter])
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
471
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
472 # step 2: select all unused attribute items
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
473 self.attributesList.clearSelection()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
474 for row in range(self.attributesList.topLevelItemCount()):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
475 itm = self.attributesList.topLevelItem(row)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
476 if itm.text(0) not in attributes:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
477 itm.setSelected(True)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
478
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
479 def __removeAttributes(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
480 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
481 Private method to remove attributes from the Qt Help database.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
482 """
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8235
diff changeset
483 with contextlib.suppress(sqlite3.DatabaseError):
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
484 self.__db = sqlite3.connect(self.__engine.collectionFile())
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
485
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
486 for attr in self.__removedAttributes:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
487 self.__db.execute(
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
488 "DELETE FROM FilterAttributeTable WHERE Name = '{0}'" # secok
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
489 .format(attr))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
490 self.__db.commit()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
491 self.__db.close()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
492
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
493 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
494 def on_applyFilterChangesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
495 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
496 Private slot to apply the filter changes.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
497 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
498 if self.__hasChangedFilters():
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
499 for customFilter in self.__removedFilters:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
500 self.__engine.removeCustomFilter(customFilter)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
501 for customFilter in self.__filterMap:
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
502 self.__engine.addFilterData(
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
503 customFilter, self.__filterMap[customFilter])
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
504
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
505 if self.__removedAttributes:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
506 self.__removeAttributes()
7235
4f23ea4af43c QtHelpDocumentationDialog: fixed the apply function which did not reset the change status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7231
diff changeset
507
4f23ea4af43c QtHelpDocumentationDialog: fixed the apply function which did not reset the change status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7231
diff changeset
508 self.__initFiltersTab()
4f23ea4af43c QtHelpDocumentationDialog: fixed the apply function which did not reset the change status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7231
diff changeset
509
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
510 def __hasChangedFilters(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
511 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
512 Private method to determine, if there are filter changes.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
513
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
514 @return flag indicating the presence of filter changes
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
515 @rtype bool
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
516 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
517 filtersChanged = False
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
518 if len(self.__filterMapBackup) != len(self.__filterMap):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
519 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
520 else:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
521 for customFilter in self.__filterMapBackup:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
522 if customFilter not in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
523 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
524 else:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
525 oldFilterAtts = self.__filterMapBackup[customFilter]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
526 newFilterAtts = self.__filterMap[customFilter]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
527 if len(oldFilterAtts) != len(newFilterAtts):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
528 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
529 else:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
530 for attr in oldFilterAtts:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
531 if attr not in newFilterAtts:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
532 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
533 break
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
534
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
535 if filtersChanged:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
536 break
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
537
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
538 return filtersChanged
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
539
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
540 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
541 def on_resetFilterChangesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
542 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
543 Private slot to forget the filter changes and reset the tab.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
544 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
545 self.__initFiltersTab()

eric ide

mercurial