Helpviewer/QtHelpDocumentationSelectionDialog.py

Sat, 16 Feb 2019 10:26:04 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 16 Feb 2019 10:26:04 +0100
branch
maintenance
changeset 6763
dc60316673af
parent 6645
ad476851d7e0
permissions
-rw-r--r--

changelog: added a change log entry for 19.02.1.
(grafted from c5a61d7afc9c574919c3b8d076f4dafec0fac049)

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)
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67
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
68 @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
69 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
70 """
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 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
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 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
74 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
75 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
76 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
77 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
78 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
79 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
80
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 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
82 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
83
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 @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
85 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
86 """
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 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
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 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
90 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
91 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
92 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
93 """ 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
94 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
95 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
96 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
97 # 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
98 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
99
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 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
101 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
102 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
103 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
104 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
105 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
106 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
107 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
108 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
109 """ 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
110 .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
111 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
112
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 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
114 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
115
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 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
117 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
118
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 @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
120 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
121 """
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 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
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 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
125 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
126 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
127 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
128 """ 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
129 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
130 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
131 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
132 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
133 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
134 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
135 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
136
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 @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
138 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
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 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
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 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
143 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
144 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
145 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
146 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
147 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
148 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
149 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
150 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
151 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
152 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
153
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 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
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 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
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 @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
159 @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
160 """
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 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
162 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
163
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 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
165 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
166 del 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
167
5227
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 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
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 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
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 @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
173 @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
174 """
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 documents = []
5bffd1a6741f Added a dialog to select QtHelp documents provided by plug-ins for installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 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
177 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
178 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
179 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
180 return documents

eric ide

mercurial