eric6/WebBrowser/QtHelp/QtHelpDocumentationDialog.py

Thu, 15 Apr 2021 18:11:24 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 15 Apr 2021 18:11:24 +0200
changeset 8243
cc717c2ae956
parent 8235
78e6d29eb773
permissions
-rw-r--r--

Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).

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
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
13 from PyQt5.QtCore import pyqtSlot, Qt, QItemSelectionModel
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
14 from PyQt5.QtWidgets import (
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 )
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
17 from PyQt5.QtHelp import QHelpEngineCore
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
19 from E5Gui import E5MessageBox, E5FileDialog
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
20 from E5Gui.E5Application import e5App
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 ):
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
59 yes = E5MessageBox.yesNo(
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 = (
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
88 e5App().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 """
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
111 fileNames = E5FileDialog.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:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
165 E5MessageBox.warning(
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 )):
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
177 E5MessageBox.warning(
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 """
3217
87b8a0745edd Improved the QtHelp management dialogs a little bit to make maintenance a bit easier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
199 res = E5MessageBox.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()):
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
214 res = E5MessageBox.yesNo(
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?"""),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
222 icon=E5MessageBox.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
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
264 def __initFiltersTab(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
265 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
266 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
267 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
268 self.removeFiltersButton.setEnabled(False)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
269 self.removeAttributesButton.setEnabled(False)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
270
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
271 # 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
272 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
273 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
274 selectedFiltersText = [
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
275 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
276
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
277 # save the selected attributes
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
278 selectedAttributesText = [
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
279 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
280
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
281 self.filtersList.clear()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
282 self.attributesList.clear()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
283
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
284 helpEngineCore = QHelpEngineCore(self.__engine.collectionFile())
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
285
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
286 self.__removedFilters = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
287 self.__filterMap = {}
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
288 self.__filterMapBackup = {}
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
289 self.__removedAttributes = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
290
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
291 for customFilter in helpEngineCore.customFilters():
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
292 atts = helpEngineCore.filterAttributes(customFilter)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
293 self.__filterMapBackup[customFilter] = atts
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
294 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
295 self.__filterMap[customFilter] = atts
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
296
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
297 self.filtersList.addItems(sorted(self.__filterMap.keys()))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
298 for attr in helpEngineCore.filterAttributes():
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
299 QTreeWidgetItem(self.attributesList, [attr])
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
300 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
301
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
302 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
303 # restore the selected filters
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
304 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
305 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
306 txt, Qt.MatchFlag.MatchExactly)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
307 for itm in items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
308 itm.setSelected(True)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
309 # restore the current filter
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
310 if currentFilterText:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
311 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
312 Qt.MatchFlag.MatchExactly)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
313 if items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
314 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
315 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
316 # restore the selected attributes
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
317 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
318 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
319 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
320 for itm in items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
321 itm.setSelected(True)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
322 elif self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
323 self.filtersList.setCurrentRow(0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
324
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
325 @pyqtSlot(QListWidgetItem, QListWidgetItem)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
326 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
327 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
328 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
329
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
330 @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
331 @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
332 (QListWidgetItem)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
333 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
334 checkedList = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
335 if current is not None:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
336 checkedList = self.__filterMap[current.text()]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
337 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
338 itm = self.attributesList.topLevelItem(index)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
339 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
340 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
341 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
342 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
343
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
344 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
345 def on_filtersList_itemSelectionChanged(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
346 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
347 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
348 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
349 self.removeFiltersButton.setEnabled(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
350 len(self.filtersList.selectedItems()) > 0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
351
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
352 @pyqtSlot(QTreeWidgetItem, int)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
353 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
354 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
355 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
356
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
357 @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
358 @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
359 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
360 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
361 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
362
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
363 customFilter = self.filtersList.currentItem().text()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
364 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
365 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
366
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
367 newAtts = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
368 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
369 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
370 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
371 newAtts.append(itm.text(0))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
372 self.__filterMap[customFilter] = newAtts
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
373
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
374 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
375 def on_attributesList_itemSelectionChanged(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
376 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
377 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
378 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
379 self.removeAttributesButton.setEnabled(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
380 len(self.attributesList.selectedItems()) != 0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
381
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
382 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
383 def on_addFilterButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
384 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
385 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
386 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
387 customFilter, ok = QInputDialog.getText(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
388 None,
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
389 self.tr("Add Filter"),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
390 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
391 QLineEdit.EchoMode.Normal)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
392 if not customFilter:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
393 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
394
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
395 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
396 self.__filterMap[customFilter] = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
397 self.filtersList.addItem(customFilter)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
398
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
399 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
400 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
401 self.filtersList.setCurrentItem(itm)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
402
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
403 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
404 def on_removeFiltersButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
405 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
406 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
407 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
408 ok = E5MessageBox.yesNo(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
409 self,
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
410 self.tr("Remove Filters"),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
411 self.tr(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
412 """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
413 """from the database?"""))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
414 if not ok:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
415 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
416
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
417 items = self.filtersList.selectedItems()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
418 for item in items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
419 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
420 if itm is None:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
421 continue
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
422
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
423 del self.__filterMap[itm.text()]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
424 self.__removedFilters.append(itm.text())
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
425 del itm
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
426
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
427 if self.filtersList.count():
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
428 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
429 0, QItemSelectionModel.SelectionFlag.ClearAndSelect)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
430
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
431 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
432 def on_removeAttributesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
433 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
434 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
435 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
436 ok = E5MessageBox.yesNo(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
437 self,
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
438 self.tr("Remove Attributes"),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
439 self.tr(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
440 """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
441 """from the database?"""))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
442 if not ok:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
443 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
444
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
445 items = self.attributesList.selectedItems()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
446 for item in items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
447 itm = self.attributesList.takeTopLevelItem(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
448 self.attributesList.indexOfTopLevelItem(item))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
449 if itm is None:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
450 continue
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
451
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
452 attr = itm.text(0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
453 self.__removedAttributes.append(attr)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
454 for customFilter in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
455 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
456 self.__filterMap[customFilter].remove(attr)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
457
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
458 del itm
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 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
461 def on_unusedAttributesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
462 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
463 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
464 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
465 # 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
466 attributes = set()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
467 for customFilter in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
468 attributes |= set(self.__filterMap[customFilter])
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
469
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
470 # 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
471 self.attributesList.clearSelection()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
472 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
473 itm = self.attributesList.topLevelItem(row)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
474 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
475 itm.setSelected(True)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
476
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
477 def __removeAttributes(self):
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 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
480 """
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
481 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
482 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
483
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
484 for attr in self.__removedAttributes:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
485 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
486 "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
487 .format(attr))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
488 self.__db.commit()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
489 self.__db.close()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
490
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
491 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
492 def on_applyFilterChangesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
493 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
494 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
495 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
496 if self.__hasChangedFilters():
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
497 for customFilter in self.__removedFilters:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
498 self.__engine.removeCustomFilter(customFilter)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
499 for customFilter in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
500 self.__engine.addCustomFilter(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
501 customFilter, self.__filterMap[customFilter])
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
502
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
503 if self.__removedAttributes:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
504 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
505
4f23ea4af43c QtHelpDocumentationDialog: fixed the apply function which did not reset the change status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7231
diff changeset
506 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
507
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
508 def __hasChangedFilters(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
509 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
510 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
511
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
512 @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
513 @rtype bool
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
514 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
515 filtersChanged = False
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
516 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
517 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
518 else:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
519 for customFilter in self.__filterMapBackup:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
520 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
521 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
522 else:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
523 oldFilterAtts = self.__filterMapBackup[customFilter]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
524 newFilterAtts = self.__filterMap[customFilter]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
525 if len(oldFilterAtts) != len(newFilterAtts):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
526 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
527 else:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
528 for attr in oldFilterAtts:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
529 if attr not in newFilterAtts:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
530 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
531 break
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
532
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
533 if filtersChanged:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
534 break
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
535
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
536 return filtersChanged
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 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
539 def on_resetFilterChangesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
540 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
541 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
542 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
543 self.__initFiltersTab()

eric ide

mercurial