194 |
194 |
195 if self.__recentSearchesItem and \ |
195 if self.__recentSearchesItem and \ |
196 self.__recentSearchesItem.index().row() == index.row(): |
196 self.__recentSearchesItem.index().row() == index.row(): |
197 return False |
197 return False |
198 |
198 |
199 self.__searchEdit.setText(index.data().toString()) |
199 self.__searchEdit.setText(index.data()) |
200 return True |
200 return True |
201 |
201 |
202 def __textEdited(self, txt): |
202 def __textEdited(self, txt): |
203 """ |
203 """ |
204 Private slot to handle changes of the search text. |
204 Private slot to handle changes of the search text. |
246 osm = HelpWebSearchWidget.openSearchManager() |
246 osm = HelpWebSearchWidget.openSearchManager() |
247 engineNames = osm.allEnginesNames() |
247 engineNames = osm.allEnginesNames() |
248 for engineName in engineNames: |
248 for engineName in engineNames: |
249 engine = osm.engine(engineName) |
249 engine = osm.engine(engineName) |
250 action = OpenSearchEngineAction(engine, self.__enginesMenu) |
250 action = OpenSearchEngineAction(engine, self.__enginesMenu) |
251 action.setData(QVariant(engineName)) |
251 action.setData(engineName) |
252 self.connect(action, SIGNAL("triggered()"), self.__changeCurrentEngine) |
252 self.connect(action, SIGNAL("triggered()"), self.__changeCurrentEngine) |
253 self.__enginesMenu.addAction(action) |
253 self.__enginesMenu.addAction(action) |
254 |
254 |
255 if osm.currentEngineName() == engineName: |
255 if osm.currentEngineName() == engineName: |
256 action.setCheckable(True) |
256 action.setCheckable(True) |
281 else: |
281 else: |
282 title = ct.title() |
282 title = ct.title() |
283 |
283 |
284 action = self.__enginesMenu.addAction(self.trUtf8("Add '{0}'").format(title), |
284 action = self.__enginesMenu.addAction(self.trUtf8("Add '{0}'").format(title), |
285 self.__addEngineFromUrl) |
285 self.__addEngineFromUrl) |
286 action.setData(QVariant(url)) |
286 action.setData(url) |
287 action.setIcon(ct.icon()) |
287 action.setIcon(ct.icon()) |
288 |
288 |
289 self.__enginesMenu.addSeparator() |
289 self.__enginesMenu.addSeparator() |
290 self.__enginesMenu.addAction(self.mw.searchEnginesAction()) |
290 self.__enginesMenu.addAction(self.mw.searchEnginesAction()) |
291 |
291 |
297 """ |
297 """ |
298 Private slot to handle the selection of a search engine. |
298 Private slot to handle the selection of a search engine. |
299 """ |
299 """ |
300 action = self.sender() |
300 action = self.sender() |
301 if action is not None: |
301 if action is not None: |
302 name = action.data().toString() |
302 name = action.data() |
303 HelpWebSearchWidget.openSearchManager().setCurrentEngineName(name) |
303 HelpWebSearchWidget.openSearchManager().setCurrentEngineName(name) |
304 |
304 |
305 def __addEngineFromUrl(self): |
305 def __addEngineFromUrl(self): |
306 """ |
306 """ |
307 Private slot to add a search engine given it's URL. |
307 Private slot to add a search engine given it's URL. |
308 """ |
308 """ |
309 action = self.sender() |
309 action = self.sender() |
310 if action is not None: |
310 if action is not None: |
311 variant = action.data() |
311 url = action.data() |
312 if not variant.canConvert(QVariant.Url): |
312 if not isinstance(url, QUrl): |
313 return |
313 return |
314 url = variant.toUrl() |
|
315 |
314 |
316 HelpWebSearchWidget.openSearchManager().addEngine(url) |
315 HelpWebSearchWidget.openSearchManager().addEngine(url) |
317 |
316 |
318 def __searchButtonClicked(self): |
317 def __searchButtonClicked(self): |
319 """ |
318 """ |
343 def saveSearches(self): |
342 def saveSearches(self): |
344 """ |
343 """ |
345 Public method to save the recently performed web searches. |
344 Public method to save the recently performed web searches. |
346 """ |
345 """ |
347 Preferences.Prefs.settings.setValue('Help/WebSearches', |
346 Preferences.Prefs.settings.setValue('Help/WebSearches', |
348 QVariant(self.__recentSearches)) |
347 self.__recentSearches) |
349 |
348 |
350 def __loadSearches(self): |
349 def __loadSearches(self): |
351 """ |
350 """ |
352 Public method to load the recently performed web searches. |
351 Public method to load the recently performed web searches. |
353 """ |
352 """ |
354 searches = Preferences.Prefs.settings.value('Help/WebSearches') |
353 searches = Preferences.Prefs.settings.value('Help/WebSearches') |
355 if searches.isValid(): |
354 if searches is not None: |
356 self.__recentSearches = searches.toStringList() |
355 self.__recentSearches = searches |
357 |
356 |
358 @classmethod |
357 @classmethod |
359 def openSearchManager(cls): |
358 def openSearchManager(cls): |
360 """ |
359 """ |
361 Class method to get a reference to the opensearch manager object. |
360 Class method to get a reference to the opensearch manager object. |