eric6/WebBrowser/QtHelp/QtHelpDocumentationDialog.py

Tue, 13 Apr 2021 19:59:17 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 13 Apr 2021 19:59:17 +0200
changeset 8235
78e6d29eb773
parent 8218
7c09585bd960
child 8243
cc717c2ae956
permissions
-rw-r--r--

Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator) (batch 3).

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
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
11
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
12 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
13 from PyQt5.QtWidgets import (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
14 QDialog, QTreeWidgetItem, QListWidgetItem, QInputDialog, QLineEdit
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
15 )
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
16 from PyQt5.QtHelp import QHelpEngineCore
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
18 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
19 from E5Gui.E5Application import e5App
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 535
diff changeset
20
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
21 from .Ui_QtHelpDocumentationDialog import Ui_QtHelpDocumentationDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
23
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 class QtHelpDocumentationDialog(QDialog, Ui_QtHelpDocumentationDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 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
27 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 def __init__(self, engine, parent):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param engine reference to the help engine (QHelpEngine)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param parent reference to the parent widget (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
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
35 super().__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.__engine = engine
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.__mw = parent
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
41 self.__initDocumentsTab()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
42 self.__initFiltersTab()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
43
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
44 self.tabWidget.setCurrentIndex(0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
45
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
46 @pyqtSlot(int)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
47 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
48 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
49 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
50
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
51 @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
52 @type int
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
53 """
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
54 if (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
55 index != 1 and
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
56 (self.__hasChangedFilters() or self.__removedAttributes)
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
57 ):
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
58 yes = E5MessageBox.yesNo(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
59 self,
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
60 self.tr("Unsaved Filter Changes"),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
61 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
62 """ saved?"""),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
63 yesDefault=True)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
64 if yes:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
65 self.on_applyFilterChangesButton_clicked()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
66
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 ## Documentations Tab
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
69 ##################################################################
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 def __initDocumentsTab(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
72 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
73 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
74 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
75 self.documentsList.clear()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
76 self.removeDocumentsButton.setEnabled(False)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
77
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 docs = self.__engine.registeredDocumentations()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.documentsList.addItems(docs)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
80
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.__registeredDocs = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.__unregisteredDocs = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.__tabsToClose = []
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
84
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
85 try:
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
86 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
87 e5App().getObject("PluginManager").getPluginQtHelpFiles()
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
88 )
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
89 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
90 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
91 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
92 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
93 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
94 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
95 self.addPluginButton.setEnabled(bool(self.__pluginHelpDocuments))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 def on_documentsList_itemSelectionChanged(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 Private slot handling a change of the documents selection.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 """
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
102 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
103 len(self.documentsList.selectedItems()) != 0)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 @pyqtSlot()
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
106 def on_addDocumentsButton_clicked(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
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
108 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
109 """
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
110 fileNames = E5FileDialog.getOpenFileNames(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
112 self.tr("Add Documentation"),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 "",
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
114 self.tr("Qt Compressed Help Files (*.qch)"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 if not fileNames:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
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
118 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
119
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 @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
121 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
122 """
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 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
124 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
125 """
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
126 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
127 QtHelpDocumentationSelectionDialog
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
128 )
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
129 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
130 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
131 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
132 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
133 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
134 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
135 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
136 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
137
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 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
139
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
140 @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
141 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
142 """
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 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
144 """
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
145 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
146 QtHelpDocumentationSelectionDialog
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
147 )
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
148 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
149 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
150 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
151 self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
152 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
153
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
154 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
155 """
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 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
157
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 @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
159 @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
160 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 for fileName in fileNames:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 ns = QHelpEngineCore.namespaceName(fileName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 if not ns:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
164 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
165 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
166 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
167 self.tr(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
168 """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
169 """ Qt Help File.""").format(fileName)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 continue
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
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
173 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
174 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
175 )):
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
176 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
177 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
178 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
179 self.tr(
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
180 """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
181 .format(ns)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 continue
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 self.__engine.registerDocumentation(fileName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.documentsList.addItem(ns)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 self.__registeredDocs.append(ns)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 if ns in self.__unregisteredDocs:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 self.__unregisteredDocs.remove(ns)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
190
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
191 self.__initFiltersTab()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 @pyqtSlot()
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
194 def on_removeDocumentsButton_clicked(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 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
197 """
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
198 res = E5MessageBox.yesNo(
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
199 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
200 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
201 self.tr(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
202 """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
203 """sets from the database?"""))
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
204 if not res:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 openedDocs = self.__mw.getSourceFileList()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 items = self.documentsList.selectedItems()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 for item in items:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 ns = item.text()
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
212 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
213 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
214 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
215 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
216 self.tr(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
217 """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
218 """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
219 """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
220 """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
221 icon=E5MessageBox.Warning)
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
222 if not res:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 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
225 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
226 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
227 self.__tabsToClose.append(docId)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 itm = self.documentsList.takeItem(self.documentsList.row(item))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 del itm
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 self.__engine.unregisterDocumentation(ns)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 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
234 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
235 0, QItemSelectionModel.SelectionFlag.ClearAndSelect)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
237 def hasDocumentationChanges(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 """
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
239 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
240 documents.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 @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
243 @rtype bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 """
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
245 return (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
246 len(self.__registeredDocs) > 0 or
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
247 len(self.__unregisteredDocs) > 0
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
248 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 def getTabsToClose(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 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
253
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
254 @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
255 @rtype list of int
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 """
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
257 return self.__tabsToClose
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
258
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 ## Filters Tab
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
261 ##################################################################
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 def __initFiltersTab(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
264 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
265 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
266 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
267 self.removeFiltersButton.setEnabled(False)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
268 self.removeAttributesButton.setEnabled(False)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
269
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
270 # 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
271 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
272 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
273 selectedFiltersText = [
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
274 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
275
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
276 # save the selected attributes
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
277 selectedAttributesText = [
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
278 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
279
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
280 self.filtersList.clear()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
281 self.attributesList.clear()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
282
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
283 helpEngineCore = QHelpEngineCore(self.__engine.collectionFile())
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
284
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
285 self.__removedFilters = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
286 self.__filterMap = {}
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
287 self.__filterMapBackup = {}
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
288 self.__removedAttributes = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
289
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
290 for customFilter in helpEngineCore.customFilters():
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
291 atts = helpEngineCore.filterAttributes(customFilter)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
292 self.__filterMapBackup[customFilter] = atts
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
293 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
294 self.__filterMap[customFilter] = atts
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
295
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
296 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
297 for attr in helpEngineCore.filterAttributes():
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
298 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
299 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
300
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
301 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
302 # restore the selected filters
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
303 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
304 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
305 txt, Qt.MatchFlag.MatchExactly)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
306 for itm in items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
307 itm.setSelected(True)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
308 # restore the current filter
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
309 if currentFilterText:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
310 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
311 Qt.MatchFlag.MatchExactly)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
312 if items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
313 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
314 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
315 # restore the selected attributes
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
316 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
317 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
318 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
319 for itm in items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
320 itm.setSelected(True)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
321 elif self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
322 self.filtersList.setCurrentRow(0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
323
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
324 @pyqtSlot(QListWidgetItem, QListWidgetItem)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
325 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
326 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
327 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
328
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
329 @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
330 @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
331 (QListWidgetItem)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
332 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
333 checkedList = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
334 if current is not None:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
335 checkedList = self.__filterMap[current.text()]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
336 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
337 itm = self.attributesList.topLevelItem(index)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
338 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
339 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
340 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
341 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
342
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
343 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
344 def on_filtersList_itemSelectionChanged(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
345 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
346 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
347 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
348 self.removeFiltersButton.setEnabled(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
349 len(self.filtersList.selectedItems()) > 0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
350
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
351 @pyqtSlot(QTreeWidgetItem, int)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
352 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
353 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
354 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
355
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
356 @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
357 @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
358 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
359 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
360 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
361
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
362 customFilter = self.filtersList.currentItem().text()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
363 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
364 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
365
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
366 newAtts = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
367 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
368 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
369 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
370 newAtts.append(itm.text(0))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
371 self.__filterMap[customFilter] = newAtts
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
372
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
373 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
374 def on_attributesList_itemSelectionChanged(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
375 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
376 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
377 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
378 self.removeAttributesButton.setEnabled(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
379 len(self.attributesList.selectedItems()) != 0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
380
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
381 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
382 def on_addFilterButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
383 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
384 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
385 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
386 customFilter, ok = QInputDialog.getText(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
387 None,
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
388 self.tr("Add Filter"),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
389 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
390 QLineEdit.EchoMode.Normal)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
391 if not customFilter:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
392 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
393
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
394 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
395 self.__filterMap[customFilter] = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
396 self.filtersList.addItem(customFilter)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
397
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
398 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
399 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
400 self.filtersList.setCurrentItem(itm)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
401
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
402 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
403 def on_removeFiltersButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
404 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
405 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
406 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
407 ok = E5MessageBox.yesNo(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
408 self,
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
409 self.tr("Remove Filters"),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
410 self.tr(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
411 """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
412 """from the database?"""))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
413 if not ok:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
414 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
415
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
416 items = self.filtersList.selectedItems()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
417 for item in items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
418 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
419 if itm is None:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
420 continue
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
421
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
422 del self.__filterMap[itm.text()]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
423 self.__removedFilters.append(itm.text())
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
424 del itm
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
425
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
426 if self.filtersList.count():
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
427 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
428 0, QItemSelectionModel.SelectionFlag.ClearAndSelect)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
429
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
430 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
431 def on_removeAttributesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
432 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
433 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
434 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
435 ok = E5MessageBox.yesNo(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
436 self,
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
437 self.tr("Remove Attributes"),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
438 self.tr(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
439 """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
440 """from the database?"""))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
441 if not ok:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
442 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
443
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
444 items = self.attributesList.selectedItems()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
445 for item in items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
446 itm = self.attributesList.takeTopLevelItem(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
447 self.attributesList.indexOfTopLevelItem(item))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
448 if itm is None:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
449 continue
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
450
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
451 attr = itm.text(0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
452 self.__removedAttributes.append(attr)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
453 for customFilter in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
454 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
455 self.__filterMap[customFilter].remove(attr)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
456
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
457 del itm
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
458
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
459 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
460 def on_unusedAttributesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
461 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
462 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
463 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
464 # 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
465 attributes = set()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
466 for customFilter in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
467 attributes |= set(self.__filterMap[customFilter])
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
468
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
469 # 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
470 self.attributesList.clearSelection()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
471 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
472 itm = self.attributesList.topLevelItem(row)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
473 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
474 itm.setSelected(True)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
475
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
476 def __removeAttributes(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
477 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
478 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
479 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
480 try:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
481 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
482 except sqlite3.DatabaseError:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
483 pass # ignore database errors
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
484
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
485 for attr in self.__removedAttributes:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
486 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
487 "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
488 .format(attr))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
489 self.__db.commit()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
490 self.__db.close()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
491
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
492 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
493 def on_applyFilterChangesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
494 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
495 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
496 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
497 if self.__hasChangedFilters():
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
498 for customFilter in self.__removedFilters:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
499 self.__engine.removeCustomFilter(customFilter)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
500 for customFilter in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
501 self.__engine.addCustomFilter(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
502 customFilter, self.__filterMap[customFilter])
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
503
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
504 if self.__removedAttributes:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
505 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
506
4f23ea4af43c QtHelpDocumentationDialog: fixed the apply function which did not reset the change status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7231
diff changeset
507 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
508
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
509 def __hasChangedFilters(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
510 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
511 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
512
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
513 @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
514 @rtype bool
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
515 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
516 filtersChanged = False
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
517 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
518 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
519 else:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
520 for customFilter in self.__filterMapBackup:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
521 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
522 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
523 else:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
524 oldFilterAtts = self.__filterMapBackup[customFilter]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
525 newFilterAtts = self.__filterMap[customFilter]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
526 if len(oldFilterAtts) != len(newFilterAtts):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
527 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
528 else:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
529 for attr in oldFilterAtts:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
530 if attr not in newFilterAtts:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
531 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
532 break
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
533
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
534 if filtersChanged:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
535 break
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
536
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
537 return filtersChanged
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
538
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
539 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
540 def on_resetFilterChangesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
541 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
542 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
543 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
544 self.__initFiltersTab()

eric ide

mercurial