Helpviewer/HelpTocWidget.py

changeset 487
4d41d03d3d00
parent 458
1695e7a2db54
child 501
5c615a85241a
equal deleted inserted replaced
486:e4711a55e482 487:4d41d03d3d00
15 Class implementing a window for showing the QtHelp TOC. 15 Class implementing a window for showing the QtHelp TOC.
16 16
17 @signal linkActivated(const QUrl&) emitted when a TOC entry is activated 17 @signal linkActivated(const QUrl&) emitted when a TOC entry is activated
18 @signal escapePressed() emitted when the ESC key was pressed 18 @signal escapePressed() emitted when the ESC key was pressed
19 """ 19 """
20 linkActivated = pyqtSignal(QUrl)
21 escapePressed = pyqtSignal()
22
20 def __init__(self, engine, mainWindow, parent = None): 23 def __init__(self, engine, mainWindow, parent = None):
21 """ 24 """
22 Constructor 25 Constructor
23 26
24 @param engine reference to the help engine (QHelpEngine) 27 @param engine reference to the help engine (QHelpEngine)
37 40
38 self.__layout = QVBoxLayout(self) 41 self.__layout = QVBoxLayout(self)
39 self.__layout.addWidget(self.__tocWidget) 42 self.__layout.addWidget(self.__tocWidget)
40 43
41 self.__tocWidget.customContextMenuRequested.connect(self.__showContextMenu) 44 self.__tocWidget.customContextMenuRequested.connect(self.__showContextMenu)
42 self.connect(self.__tocWidget, SIGNAL("linkActivated(const QUrl&)"), 45 self.__tocWidget.linkActivated.connect(self.linkActivated)
43 self, SIGNAL("linkActivated(const QUrl&)"))
44 46
45 model = self.__tocWidget.model() 47 model = self.__tocWidget.model()
46 self.connect(model, SIGNAL("contentsCreated()"), self.__expandTOC) 48 model.contentsCreated.connect(self.__expandTOC)
47 49
48 def __expandTOC(self): 50 def __expandTOC(self):
49 """ 51 """
50 Private slot to expand the table of contents. 52 Private slot to expand the table of contents.
51 """ 53 """
79 Protected method handling key press events. 81 Protected method handling key press events.
80 82
81 @param evt reference to the key press event (QKeyEvent) 83 @param evt reference to the key press event (QKeyEvent)
82 """ 84 """
83 if evt.key() == Qt.Key_Escape: 85 if evt.key() == Qt.Key_Escape:
84 self.emit(SIGNAL("escapePressed()")) 86 self.escapePressed.emit()
85 87
86 def eventFilter(self, watched, event): 88 def eventFilter(self, watched, event):
87 """ 89 """
88 Public method called to filter the event queue. 90 Public method called to filter the event queue.
89 91
114 return 116 return
115 117
116 model = self.__tocWidget.model() 118 model = self.__tocWidget.model()
117 itm = model.contentItemAt(index) 119 itm = model.contentItemAt(index)
118 if itm: 120 if itm:
119 self.emit(SIGNAL("linkActivated(const QUrl&)"), itm.url()) 121 self.linkActivated.emit(itm.url())
120 122
121 def syncToContent(self, url): 123 def syncToContent(self, url):
122 """ 124 """
123 Public method to sync the TOC to the displayed page. 125 Public method to sync the TOC to the displayed page.
124 126
148 model = self.__tocWidget.model() 150 model = self.__tocWidget.model()
149 itm = model.contentItemAt(self.__tocWidget.currentIndex()) 151 itm = model.contentItemAt(self.__tocWidget.currentIndex())
150 152
151 act = menu.exec_() 153 act = menu.exec_()
152 if act == curTab: 154 if act == curTab:
153 self.emit(SIGNAL("linkActivated(const QUrl&)"), itm.url()) 155 self.linkActivated.emit(itm.url())
154 elif act == newTab: 156 elif act == newTab:
155 self.__mw.newTab(itm.url()) 157 self.__mw.newTab(itm.url())

eric ide

mercurial