# eric5.Helpviewer.OpenSearch.OpenSearchManager

Module implementing a manager for open search engines.

### Global Attributes

None

### Classes

OpenSearchManager | Class implementing a manager for open search engines.

### Functions

None

## OpenSearchManager

Class implementing a manager for open search engines.

### Signals

changed()
  emitted to indicate a change
currentEngineChanged()
  emitted to indicate a change of the current search engine

### Derived from

QObject

### Class Attributes

None

### Class Methods

None

### Methods

OpenSearchManager | Constructor
__addEngineByEngine | Private method to add a new search engine given a reference to an engine.
__addEngineByFile | Private method to add a new search engine given a filename.
__addEngineByUrl | Private method to add a new search engine given its URL.
__confirmAddition | Private method to confirm the addition of a new search engine.
__engineFromUrlAvailable | Private slot to add a search engine from the net.
addEngine | Public method to add a new search engine.
allEnginesNames | Public method to get a list of all engine names.
close | Public method to close the open search engines manager.
convertKeywordSearchToUrl | Public method to get the search URL for a keyword search.
currentEngine | Public method to get a reference to the current engine.
currentEngineName | Public method to get the name of the current search engine.
engine | Public method to get a reference to the named engine.
engineExists | Public method to check, if an engine exists.
engineForKeyword | Public method to get the engine for a keyword.
enginesChanged | Public slot to tell the search engine manager, that something has changed.
enginesCount | Public method to get the number of available engines.
enginesDirectory | Public method to determine the directory containing the search engine descriptions.
generateEngineFileName | Public method to generate a valid engine file name.
keywordsForEngine | Public method to get the keywords for a given engine.
load | Public method to load the search engines configuration.
loadDirectory | Public method to load the search engine definitions from files.
removeEngine | Public method to remove an engine.
restoreDefaults | Public method to restore the default search engines.
save | Public method to save the search engines configuration.
saveDirectory | Public method to save the search engine definitions to files.
setCurrentEngine | Public method to set the current engine.
setCurrentEngineName | Public method to set the current engine by name.
setEngineForKeyword | Public method to set the engine for a keyword.
setKeywordsForEngine | Public method to set the keywords for an engine.

### Static Methods

None

#### OpenSearchManager (Constructor)

OpenSearchManager(parent=None)

Constructor

parent
  reference to the parent object (QObject)

#### OpenSearchManager.__addEngineByEngine

__addEngineByEngine(engine)

Private method to add a new search engine given a reference to an engine.

engine
  reference to an engine object (OpenSearchEngine)

Returns:
  flag indicating success (boolean)

#### OpenSearchManager.__addEngineByFile

__addEngineByFile(filename)

Private method to add a new search engine given a filename.

filename
  name of a file containing the engine definition (string)

Returns:
  flag indicating success (boolean)

#### OpenSearchManager.__addEngineByUrl

__addEngineByUrl(url)

Private method to add a new search engine given its URL.

url
  URL of the engine definition file (QUrl)

Returns:
  flag indicating success (boolean)

#### OpenSearchManager.__confirmAddition

__confirmAddition(engine)

Private method to confirm the addition of a new search engine.

engine
  reference to the engine to be added (OpenSearchEngine)

Returns:
  flag indicating the engine shall be added (boolean)

#### OpenSearchManager.__engineFromUrlAvailable

__engineFromUrlAvailable()

Private slot to add a search engine from the net.

#### OpenSearchManager.addEngine

addEngine(engine)

Public method to add a new search engine.

engine
  URL of the engine definition file (QUrl) or name of a file containing the engine definition (string) or reference to an engine object (OpenSearchEngine)

Returns:
  flag indicating success (boolean)

#### OpenSearchManager.allEnginesNames

allEnginesNames()

Public method to get a list of all engine names.

Returns:
  sorted list of all engine names (list of strings)

#### OpenSearchManager.close

close()

Public method to close the open search engines manager.

#### OpenSearchManager.convertKeywordSearchToUrl

convertKeywordSearchToUrl(keywordSearch)

Public method to get the search URL for a keyword search.

keywordSearch
  search string for keyword search (string)

Returns:
  search URL (QUrl)

#### OpenSearchManager.currentEngine

currentEngine()

Public method to get a reference to the current engine.

Returns:
  reference to the current engine (OpenSearchEngine)

#### OpenSearchManager.currentEngineName

currentEngineName()

Public method to get the name of the current search engine.

Returns:
  name of the current search engine (string)

#### OpenSearchManager.engine

engine(name)

Public method to get a reference to the named engine.

name
  name of the engine (string)

Returns:
  reference to the engine (OpenSearchEngine)

#### OpenSearchManager.engineExists

engineExists(name)

Public method to check, if an engine exists.

name
  name of the engine (string)

Returns:
  flag indicating an existing engine (boolean)

#### OpenSearchManager.engineForKeyword

engineForKeyword(keyword)

Public method to get the engine for a keyword.

keyword
  keyword to get engine for (string)

Returns:
  reference to the search engine object (OpenSearchEngine)

#### OpenSearchManager.enginesChanged

enginesChanged()

Public slot to tell the search engine manager, that something has changed.

#### OpenSearchManager.enginesCount

enginesCount()

Public method to get the number of available engines.

Returns:
  number of engines (integer)

#### OpenSearchManager.enginesDirectory

enginesDirectory()

Public method to determine the directory containing the search engine descriptions.

Returns:
  directory name (string)

#### OpenSearchManager.generateEngineFileName

generateEngineFileName(engineName)

Public method to generate a valid engine file name.

engineName
  name of the engine (string)

Returns:
  valid engine file name (string)

#### OpenSearchManager.keywordsForEngine

keywordsForEngine(engine)

Public method to get the keywords for a given engine.

engine
  reference to the search engine object (OpenSearchEngine)

Returns:
  list of keywords (list of strings)

#### OpenSearchManager.load

load()

Public method to load the search engines configuration.

#### OpenSearchManager.loadDirectory

loadDirectory(dirName)

Public method to load the search engine definitions from files.

dirName
  name of the directory to load the files from (string)

Returns:
  flag indicating success (boolean)

#### OpenSearchManager.removeEngine

removeEngine(name)

Public method to remove an engine.

name
  name of the engine (string)

#### OpenSearchManager.restoreDefaults

restoreDefaults()

Public method to restore the default search engines.

#### OpenSearchManager.save

save()

Public method to save the search engines configuration.

#### OpenSearchManager.saveDirectory

saveDirectory(dirName)

Public method to save the search engine definitions to files.

dirName
  name of the directory to write the files to (string)

#### OpenSearchManager.setCurrentEngine

setCurrentEngine(engine)

Public method to set the current engine.

engine
  reference to the new current engine (OpenSearchEngine)

#### OpenSearchManager.setCurrentEngineName

setCurrentEngineName(name)

Public method to set the current engine by name.

name
  name of the new current engine (string)

#### OpenSearchManager.setEngineForKeyword

setEngineForKeyword(keyword, engine)

Public method to set the engine for a keyword.

keyword
  keyword to get engine for (string)
engine
  reference to the search engine object (OpenSearchEngine) or None to remove the keyword

#### OpenSearchManager.setKeywordsForEngine

setKeywordsForEngine(engine, keywords)

Public method to set the keywords for an engine.

engine
  reference to the search engine object (OpenSearchEngine)
keywords
  list of keywords (list of strings)

Up