eric6/WebBrowser/QtHelp/QtHelpDocumentationDialog.py

Fri, 13 Sep 2019 18:54:34 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 13 Sep 2019 18:54:34 +0200
changeset 7231
0dcb92a9687d
parent 7229
53054eb5b15a
child 7235
4f23ea4af43c
permissions
-rw-r--r--

QtHelpDocumentationDialog: moved the QtHelpFiltersDialog functionality into this one.

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

eric ide

mercurial