WebBrowser/QtHelp/QtHelpDocumentationSelectionDialog.py

changeset 5227
5bffd1a6741f
child 5389
9b1c800daff3
equal deleted inserted replaced
5226:7d8cee42ab86 5227:5bffd1a6741f
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2016 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to select QtHelp documentation sets to be
8 installed.
9 """
10
11 from __future__ import unicode_literals
12
13 import os
14
15 from PyQt5.QtCore import Qt
16 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem
17
18 from .Ui_QtHelpDocumentationSelectionDialog import \
19 Ui_QtHelpDocumentationSelectionDialog
20
21
22 class QtHelpDocumentationSelectionDialog(
23 QDialog, Ui_QtHelpDocumentationSelectionDialog):
24 """
25 Class implementing a dialog to select QtHelp documentation sets to be
26 installed.
27 """
28 def __init__(self, helpDocuments, parent=None):
29 """
30 Constructor
31
32 @param helpDocuments dictionary containing the lists of help documents
33 to be shown
34 @type dict of lists of str
35 @param parent reference to the parent widget
36 @type QWidget
37 """
38 super(QtHelpDocumentationSelectionDialog, self).__init__(parent)
39 self.setupUi(self)
40
41 for category in helpDocuments:
42 parentItem = QTreeWidgetItem(self.documentationList, [category])
43 for document in helpDocuments[category]:
44 item = QTreeWidgetItem(parentItem,
45 [os.path.basename(document)])
46 item.setData(0, Qt.UserRole, document)
47 self.documentationList.sortItems(0, Qt.AscendingOrder)
48
49 def getData(self):
50 """
51 Public method to retrieve the selected help documents.
52
53 @return list of QtHelp documentation sets to be installed
54 @rtype list of str
55 """
56 documents = []
57 for item in self.documentationList.selectedItems():
58 fileName = item.data(0, Qt.UserRole)
59 if fileName:
60 documents.append(fileName)
61 return documents

eric ide

mercurial