15 Class implementing a window for showing the QtHelp index. |
15 Class implementing a window for showing the QtHelp index. |
16 |
16 |
17 @signal linkActivated(const QUrl&) emitted when a search result entry is activated |
17 @signal linkActivated(const QUrl&) emitted when a search result 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 search engine (QHelpSearchEngine) |
27 @param engine reference to the help search engine (QHelpSearchEngine) |
38 self.__layout.addWidget(self.__query) |
41 self.__layout.addWidget(self.__query) |
39 self.__layout.addWidget(self.__result) |
42 self.__layout.addWidget(self.__result) |
40 |
43 |
41 self.setFocusProxy(self.__query) |
44 self.setFocusProxy(self.__query) |
42 |
45 |
43 self.connect(self.__query, SIGNAL("search()"), |
46 self.__query.search.connect(self.__search) |
44 self.__search) |
47 self.__result.requestShowLink.connect(self.linkActivated) |
45 self.connect(self.__result, SIGNAL("requestShowLink(const QUrl&)"), |
|
46 self, SIGNAL("linkActivated(const QUrl&)")) |
|
47 |
48 |
48 self.connect(self.__engine, SIGNAL("searchingStarted()"), |
49 self.__engine.searchingStarted.connect(self.__searchingStarted) |
49 self.__searchingStarted) |
50 self.__engine.searchingFinished.connect(self.__searchingFinished) |
50 self.connect(self.__engine, SIGNAL("searchingFinished(int)"), |
|
51 self.__searchingFinished) |
|
52 |
51 |
53 self.__browser = self.__result.findChildren(QTextBrowser)[0] |
52 self.__browser = self.__result.findChildren(QTextBrowser)[0] |
54 if self.__browser: |
53 if self.__browser: |
55 self.__browser.viewport().installEventFilter(self) |
54 self.__browser.viewport().installEventFilter(self) |
56 |
55 |
99 Protected method handling key press events. |
98 Protected method handling key press events. |
100 |
99 |
101 @param evt reference to the key press event (QKeyEvent) |
100 @param evt reference to the key press event (QKeyEvent) |
102 """ |
101 """ |
103 if evt.key() == Qt.Key_Escape: |
102 if evt.key() == Qt.Key_Escape: |
104 self.emit(SIGNAL("escapePressed()")) |
103 self.escapePressed.emit() |
105 else: |
104 else: |
106 evt.ignore() |
105 evt.ignore() |
107 |
106 |
108 def contextMenuEvent(self, evt): |
107 def contextMenuEvent(self, evt): |
109 """ |
108 """ |
129 curTab = menu.addAction(self.trUtf8("Open Link")) |
128 curTab = menu.addAction(self.trUtf8("Open Link")) |
130 newTab = menu.addAction(self.trUtf8("Open Link in New Tab")) |
129 newTab = menu.addAction(self.trUtf8("Open Link in New Tab")) |
131 menu.move(evt.globalPos()) |
130 menu.move(evt.globalPos()) |
132 act = menu.exec_() |
131 act = menu.exec_() |
133 if act == curTab: |
132 if act == curTab: |
134 self.emit(SIGNAL("linkActivated(const QUrl&)"), link) |
133 self.linkActivated.emit(link) |
135 elif act == newTab: |
134 elif act == newTab: |
136 self.__mw.newTab(link) |
135 self.__mw.newTab(link) |