Helpviewer/HelpTopicDialog.py

changeset 0
de9c2efb9d02
child 12
1d8dd9706f46
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to select a help topic to display.
8 """
9
10 from PyQt4.QtGui import QDialog
11 from PyQt4.QtCore import pyqtSlot, SIGNAL, QUrl
12
13 from Ui_HelpTopicDialog import Ui_HelpTopicDialog
14
15 class HelpTopicDialog(QDialog, Ui_HelpTopicDialog):
16 """
17 Class implementing a dialog to select a help topic to display.
18 """
19 def __init__(self, parent, keyword, links):
20 """
21 Constructor
22
23 @param parent reference to the parent widget (QWidget)
24 @param keyword keyword for the link set (string)
25 @param links dictionary with help topic as key (string) and
26 URL as value (QUrl)
27 """
28 QDialog.__init__(self, parent)
29 self.setupUi(self)
30
31 self.label.setText(self.trUtf8("Choose a &topic for <b>{0}</b>:")\
32 .format(keyword))
33
34 self.__links = links
35 for topic in self.__links:
36 self.topicsList.addItem(topic)
37 if self.topicsList.count() > 0:
38 self.topicsList.setCurrentRow(0)
39 self.topicsList.setFocus()
40
41 self.connect(self.topicsList, SIGNAL("itemActivated(QListWidgetItem*)"),
42 self.accept)
43
44 def link(self):
45 """
46 Public method to the link of the selected topic.
47
48 @return URL of the selected topic (QUrl)
49 """
50 itm = self.topicsList.currentItem()
51 if itm is None:
52 return QUrl()
53
54 topic = itm.text()
55 if topic == "" or topic not in self.__links:
56 return QUrl()
57
58 return self.__links[topic]

eric ide

mercurial