WebBrowser/QtHelp/QtHelpDocumentationSelectionDialog.py

Thu, 10 Jan 2019 14:18:48 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 10 Jan 2019 14:18:48 +0100
changeset 6645
ad476851d7e0
parent 6048
82ad8ec9548c
permissions
-rw-r--r--

Updated copyright for 2019.

5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
3 # Copyright (c) 2016 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to select QtHelp documentation sets to be
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 installed.
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from __future__ import unicode_literals
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
12 try:
5624
cdd346d8858b Removed a bunch of __IGNORE_WARNING_M131__ markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
13 str = unicode
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
14 except NameError:
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
15 pass
5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import os
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
18 import shutil
5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
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
20 from PyQt5.QtCore import pyqtSlot, Qt
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
21 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QTreeWidgetItem
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
22
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
23 from E5Gui import E5MessageBox
5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 from .Ui_QtHelpDocumentationSelectionDialog import \
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Ui_QtHelpDocumentationSelectionDialog
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 class QtHelpDocumentationSelectionDialog(
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 QDialog, Ui_QtHelpDocumentationSelectionDialog):
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 Class implementing a dialog to select QtHelp documentation sets to be
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 installed.
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
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
35 AddMode = "Add"
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
36 ManageMode = "Manage"
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
37
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
38 def __init__(self, helpDocuments, mode, parent=None):
5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 Constructor
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 @param helpDocuments dictionary containing the lists of help documents
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 to be shown
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 @type dict of lists of str
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
45 @param mode mode of the dialog
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
46 @type str
5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 @param parent reference to the parent widget
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 @type QWidget
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 super(QtHelpDocumentationSelectionDialog, self).__init__(parent)
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.setupUi(self)
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
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
53 if mode == 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
54 self.buttonBox.button(QDialogButtonBox.Close).hide()
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
55 else:
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
56 self.buttonBox.button(QDialogButtonBox.Ok).hide()
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
57 self.buttonBox.button(QDialogButtonBox.Cancel).hide()
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
58
5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 for category in helpDocuments:
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 parentItem = QTreeWidgetItem(self.documentationList, [category])
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 for document in helpDocuments[category]:
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 item = QTreeWidgetItem(parentItem,
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 [os.path.basename(document)])
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 item.setData(0, Qt.UserRole, document)
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
65 parentItem.setData(0, Qt.UserRole, os.path.dirname(document))
5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.documentationList.sortItems(0, Qt.AscendingOrder)
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
67
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
68 self.on_documentationList_itemSelectionChanged()
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
69
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
70 @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
71 def on_documentationList_itemSelectionChanged(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
72 """
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
73 Private slot handling the selection of items.
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
74 """
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
75 selectedCategoriesCount = 0
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
76 selectedDocumentSetCount = 0
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
77 for itm in self.documentationList.selectedItems():
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
78 if itm.parent() is None:
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
79 selectedCategoriesCount += 1
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
80 else:
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
81 selectedDocumentSetCount += 1
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
82
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
83 self.deleteButton.setEnabled(selectedDocumentSetCount > 0)
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
84 self.deleteCategoryButton.setEnabled(selectedCategoriesCount > 0)
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
85
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
86 @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
87 def on_deleteButton_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
88 """
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
89 Private slot to delete the selected documentation sets.
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
90 """
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
91 yes = E5MessageBox.yesNo(
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
92 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
93 self.tr("Delete Documentation Sets"),
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
94 self.tr("""Shall the selected documentation sets really be"""
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
95 """ deleted?"""))
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
96 if yes:
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
97 for itm in self.documentationList.selectedItems():
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
98 if itm.parent is None:
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
99 # it is a category item, skip it
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
100 continue
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
101
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
102 category = itm.parent()
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
103 fileName = itm.data(0, Qt.UserRole)
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
104 try:
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
105 os.remove(fileName)
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
106 except OSError as err:
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
107 E5MessageBox.warning(
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
108 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
109 self.tr("Delete Documentation Sets"),
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
110 self.tr("""<p>The documentation set <b>{0}</b> could"""
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
111 """ not be deleted.</p><p>Reason: {1}</p>""")
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
112 .format(fileName, str(err)))
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
113 continue
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
114
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
115 category.removeChild(itm)
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
116 del itm
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
117
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
118 if category.childCount() == 0:
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
119 self.__deleteCategory(category)
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
120
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
121 @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
122 def on_deleteCategoryButton_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
123 """
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 Private slot to delete the selected documentation set categories.
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 """
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 yes = E5MessageBox.yesNo(
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,
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
128 self.tr("Delete Documentation Sets"),
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
129 self.tr("""Shall the selected documentation set categories"""
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
130 """ really be deleted?"""))
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
131 if yes:
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
132 categories = []
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
133 for itm in self.documentationList.selectedItems():
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
134 if itm.parent() is None:
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 categories.append(itm)
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 for category in categories:
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 self.__deleteCategory(category)
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
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 @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
140 def on_deleteAllButton_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
141 """
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 Private slot to delete all documentation sets.
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
143 """
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
144 yes = E5MessageBox.yesNo(
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 self.tr("Delete Documentation Sets"),
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 self.tr("""Shall all documentation sets really be deleted?"""))
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
148 if yes:
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
149 categories = []
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
150 for index in range(self.documentationList.topLevelItemCount()):
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
151 categories.append(
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
152 self.documentationList.topLevelItem(index))
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
153 for category in categories:
9db3fd0b1c72 Added functionality to the web browsers to manage the plug-in provided documentation sets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
154 self.__deleteCategory(category)
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
155
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
156 def __deleteCategory(self, category):
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
157 """
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
158 Private method to delete a category.
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
159
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
160 @param category reference to the category item
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
161 @type QTreeWidgetItem
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
162 """
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
163 categoryDir = category.data(0, Qt.UserRole)
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
164 shutil.rmtree(categoryDir, True)
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
165
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
166 self.documentationList.takeTopLevelItem(
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
167 self.documentationList.indexOfTopLevelItem(category))
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
168 del category
5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 def getData(self):
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 """
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 Public method to retrieve the selected help documents.
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 @return list of QtHelp documentation sets to be installed
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 @rtype list of str
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 """
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 documents = []
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 for item in self.documentationList.selectedItems():
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 fileName = item.data(0, Qt.UserRole)
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 if fileName:
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 documents.append(fileName)
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 return documents

eric ide

mercurial