eric6/WebBrowser/QtHelp/QtHelpDocumentationDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

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 """
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
35 super(QtHelpDocumentationDialog, self).__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)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
133 if dlg.exec() == QDialog.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
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 if len(self.documentsList.findItems(ns, Qt.MatchFixedString)):
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
174 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
175 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
176 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
177 self.tr(
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
178 """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
179 .format(ns)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 continue
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 self.__engine.registerDocumentation(fileName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 self.documentsList.addItem(ns)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 self.__registeredDocs.append(ns)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 if ns in self.__unregisteredDocs:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 self.__unregisteredDocs.remove(ns)
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
188
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
189 self.__initFiltersTab()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 @pyqtSlot()
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
192 def on_removeDocumentsButton_clicked(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 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
195 """
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
196 res = E5MessageBox.yesNo(
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
197 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
198 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
199 self.tr(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
200 """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
201 """sets from the database?"""))
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
202 if not res:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 openedDocs = self.__mw.getSourceFileList()
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 items = self.documentsList.selectedItems()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 for item in items:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 ns = item.text()
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
210 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
211 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
212 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
213 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
214 self.tr(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
215 """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
216 """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
217 """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
218 """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
219 icon=E5MessageBox.Warning)
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
220 if not res:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 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
223 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
224 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
225 self.__tabsToClose.append(docId)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 itm = self.documentsList.takeItem(self.documentsList.row(item))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 del itm
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 self.__engine.unregisterDocumentation(ns)
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 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
232 self.documentsList.setCurrentRow(
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
233 0, QItemSelectionModel.ClearAndSelect)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
235 def hasDocumentationChanges(self):
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 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
238 documents.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 @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
241 @rtype bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 """
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
243 return (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
244 len(self.__registeredDocs) > 0 or
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
245 len(self.__unregisteredDocs) > 0
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7235
diff changeset
246 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 def getTabsToClose(self):
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 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
251
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
252 @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
253 @rtype list of int
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 """
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
255 return self.__tabsToClose
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
256
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
257 ##################################################################
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
258 ## Filters Tab
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
259 ##################################################################
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
260
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
261 def __initFiltersTab(self):
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 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
264 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
265 self.removeFiltersButton.setEnabled(False)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
266 self.removeAttributesButton.setEnabled(False)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
267
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
268 # 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
269 currentFilter = self.filtersList.currentItem()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
270 if currentFilter:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
271 currentFilterText = currentFilter.text()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
272 else:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
273 currentFilterText = ""
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
274 selectedFiltersText = [
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
275 itm.text() for itm in self.filtersList.selectedItems()]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
276
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
277 # save the selected attributes
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
278 selectedAttributesText = [
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
279 itm.text(0) for itm in self.attributesList.selectedItems()]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
280
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
281 self.filtersList.clear()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
282 self.attributesList.clear()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
283
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
284 helpEngineCore = QHelpEngineCore(self.__engine.collectionFile())
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
285
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
286 self.__removedFilters = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
287 self.__filterMap = {}
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
288 self.__filterMapBackup = {}
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
289 self.__removedAttributes = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
290
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
291 for customFilter in helpEngineCore.customFilters():
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
292 atts = helpEngineCore.filterAttributes(customFilter)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
293 self.__filterMapBackup[customFilter] = atts
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
294 if customFilter not in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
295 self.__filterMap[customFilter] = atts
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
296
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
297 self.filtersList.addItems(sorted(self.__filterMap.keys()))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
298 for attr in helpEngineCore.filterAttributes():
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
299 QTreeWidgetItem(self.attributesList, [attr])
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
300 self.attributesList.sortItems(0, Qt.AscendingOrder)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
301
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
302 if selectedFiltersText or currentFilterText or selectedAttributesText:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
303 # restore the selected filters
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
304 for txt in selectedFiltersText:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
305 items = self.filtersList.findItems(txt, Qt.MatchExactly)
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,
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
311 Qt.MatchExactly)
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(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
314 items[0], QItemSelectionModel.NoUpdate)
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:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
317 items = self.attributesList.findItems(txt, Qt.MatchExactly, 0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
318 for itm in items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
319 itm.setSelected(True)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
320 elif self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
321 self.filtersList.setCurrentRow(0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
322
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
323 @pyqtSlot(QListWidgetItem, QListWidgetItem)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
324 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
325 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
326 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
327
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
328 @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
329 @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
330 (QListWidgetItem)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
331 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
332 checkedList = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
333 if current is not None:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
334 checkedList = self.__filterMap[current.text()]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
335 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
336 itm = self.attributesList.topLevelItem(index)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
337 if itm.text(0) in checkedList:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
338 itm.setCheckState(0, Qt.Checked)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
339 else:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
340 itm.setCheckState(0, Qt.Unchecked)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
341
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
342 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
343 def on_filtersList_itemSelectionChanged(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
344 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
345 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
346 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
347 self.removeFiltersButton.setEnabled(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
348 len(self.filtersList.selectedItems()) > 0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
349
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
350 @pyqtSlot(QTreeWidgetItem, int)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
351 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
352 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
353 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
354
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
355 @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
356 @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
357 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
358 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
359 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
360
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
361 customFilter = self.filtersList.currentItem().text()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
362 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
363 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
364
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
365 newAtts = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
366 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
367 itm = self.attributesList.topLevelItem(index)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
368 if itm.checkState(0) == Qt.Checked:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
369 newAtts.append(itm.text(0))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
370 self.__filterMap[customFilter] = newAtts
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
371
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
372 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
373 def on_attributesList_itemSelectionChanged(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
374 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
375 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
376 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
377 self.removeAttributesButton.setEnabled(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
378 len(self.attributesList.selectedItems()) != 0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
379
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
380 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
381 def on_addFilterButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
382 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
383 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
384 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
385 customFilter, ok = QInputDialog.getText(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
386 None,
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
387 self.tr("Add Filter"),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
388 self.tr("Filter name:"),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
389 QLineEdit.Normal)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
390 if not customFilter:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
391 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
392
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
393 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
394 self.__filterMap[customFilter] = []
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
395 self.filtersList.addItem(customFilter)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
396
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
397 itm = self.filtersList.findItems(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
398 customFilter, Qt.MatchCaseSensitive)[0]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
399 self.filtersList.setCurrentItem(itm)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
400
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
401 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
402 def on_removeFiltersButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
403 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
404 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
405 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
406 ok = E5MessageBox.yesNo(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
407 self,
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
408 self.tr("Remove Filters"),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
409 self.tr(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
410 """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
411 """from the database?"""))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
412 if not ok:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
413 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
414
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
415 items = self.filtersList.selectedItems()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
416 for item in items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
417 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
418 if itm is None:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
419 continue
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
420
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
421 del self.__filterMap[itm.text()]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
422 self.__removedFilters.append(itm.text())
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
423 del itm
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
424
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
425 if self.filtersList.count():
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
426 self.filtersList.setCurrentRow(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
427 0, QItemSelectionModel.ClearAndSelect)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
428
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
429 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
430 def on_removeAttributesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
431 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
432 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
433 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
434 ok = E5MessageBox.yesNo(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
435 self,
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
436 self.tr("Remove Attributes"),
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
437 self.tr(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
438 """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
439 """from the database?"""))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
440 if not ok:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
441 return
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
442
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
443 items = self.attributesList.selectedItems()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
444 for item in items:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
445 itm = self.attributesList.takeTopLevelItem(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
446 self.attributesList.indexOfTopLevelItem(item))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
447 if itm is None:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
448 continue
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
449
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
450 attr = itm.text(0)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
451 self.__removedAttributes.append(attr)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
452 for customFilter in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
453 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
454 self.__filterMap[customFilter].remove(attr)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
455
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
456 del itm
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
457
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
458 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
459 def on_unusedAttributesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
460 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
461 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
462 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
463 # 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
464 attributes = set()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
465 for customFilter in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
466 attributes |= set(self.__filterMap[customFilter])
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
467
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
468 # 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
469 self.attributesList.clearSelection()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
470 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
471 itm = self.attributesList.topLevelItem(row)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
472 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
473 itm.setSelected(True)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
474
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
475 def __removeAttributes(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
476 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
477 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
478 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
479 try:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
480 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
481 except sqlite3.DatabaseError:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
482 pass # ignore database errors
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
483
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
484 for attr in self.__removedAttributes:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
485 self.__db.execute(
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
486 "DELETE FROM FilterAttributeTable WHERE Name = '{0}'" # secok
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
487 .format(attr))
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
488 self.__db.commit()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
489 self.__db.close()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
490
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
491 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
492 def on_applyFilterChangesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
493 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
494 Private slot to apply the filter changes.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
495 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
496 if self.__hasChangedFilters():
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
497 for customFilter in self.__removedFilters:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
498 self.__engine.removeCustomFilter(customFilter)
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
499 for customFilter in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
500 self.__engine.addCustomFilter(
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
501 customFilter, self.__filterMap[customFilter])
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
502
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
503 if self.__removedAttributes:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
504 self.__removeAttributes()
7235
4f23ea4af43c QtHelpDocumentationDialog: fixed the apply function which did not reset the change status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7231
diff changeset
505
4f23ea4af43c QtHelpDocumentationDialog: fixed the apply function which did not reset the change status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7231
diff changeset
506 self.__initFiltersTab()
4f23ea4af43c QtHelpDocumentationDialog: fixed the apply function which did not reset the change status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7231
diff changeset
507
7231
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
508 def __hasChangedFilters(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
509 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
510 Private method to determine, if there are filter changes.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
511
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
512 @return flag indicating the presence of filter changes
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
513 @rtype bool
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
514 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
515 filtersChanged = False
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
516 if len(self.__filterMapBackup) != len(self.__filterMap):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
517 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
518 else:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
519 for customFilter in self.__filterMapBackup:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
520 if customFilter not in self.__filterMap:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
521 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
522 else:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
523 oldFilterAtts = self.__filterMapBackup[customFilter]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
524 newFilterAtts = self.__filterMap[customFilter]
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
525 if len(oldFilterAtts) != len(newFilterAtts):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
526 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
527 else:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
528 for attr in oldFilterAtts:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
529 if attr not in newFilterAtts:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
530 filtersChanged = True
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
531 break
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
532
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
533 if filtersChanged:
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
534 break
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
535
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
536 return filtersChanged
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
537
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
538 @pyqtSlot()
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
539 def on_resetFilterChangesButton_clicked(self):
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
540 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
541 Private slot to forget the filter changes and reset the tab.
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
542 """
0dcb92a9687d QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
543 self.__initFiltersTab()

eric ide

mercurial