QLanguageFactory Class Reference
[Language framework]

A class managing language definitions. More...

Inheritance diagram for QLanguageFactory:

Inheritance graph
[legend]

List of all members.
 QLanguageFactory (QFormatScheme *fmt, QObject *p=0)
 Empty constructor.
virtual ~QLanguageFactory ()
 Empty destructor.
QStringList languages () const
QStringList fileFilters () const
const LangData & languageData (const QString &lang)
 Lookup language data for a matching language.
void addDefinitionPath (const QString &path)
 Fetches syntax definitions from files in path.
void addLanguage (const LangData &d)
 Adds a language to the factory.
void addLanguageDefinition (QLanguageDefinition *l)
 Registers a new completion engine.
void addCompletionEngine (QCodeCompletionEngine *e)
 Registers a new completion engine.
virtual void setLanguage (QEditor *e, const QString &f)

Classes

struct  LangData

Public Member Functions

QFormatSchemedefaultFormatScheme () const


Detailed Description

A class managing language definitions.

It stores language definitions, added programmatically or found in XML files, in specified locations and only if generic components are built-in. From these definitions, QLanguageFactory generates matchers, indenters and highlighters for a text editor, according to a file name.

See also:
QLanguageDefinition

Member Function Documentation

void QLanguageFactory::addCompletionEngine ( QCodeCompletionEngine *  e  )  [slot]

Registers a new completion engine.

Note:
This engine will NOT be used if there are no language definition for the language it supports...

void QLanguageFactory::addLanguage ( const LangData &  d  )  [slot]

Adds a language to the factory.

Parameters:
d language data
Note:
The language data will overwrite any existing one for the same language

Referenced by addDefinitionPath().

void QLanguageFactory::addLanguageDefinition ( QLanguageDefinition l  )  [slot]

Registers a new completion engine.

Note:
This engine will NOT be used if there are no language definition for the language it supports...

QStringList QLanguageFactory::fileFilters (  )  const

Returns:
a list of file filters supported by this factory
Note:
This list is NEVER empty and the last item is always "All files (*)"

const QLanguageFactory::LangData & QLanguageFactory::languageData ( const QString &  lang  ) 

Lookup language data for a matching language.

The primary purpose of this function is to make it easy to create configuration dialogs (mainly for format schemes). Beware though : some language may use the default format scheme. It is recommended to check for that before modifying a format scheme or users might be surprised...

Warning:
This function will lead to crashes if you pass it a language name not contained in languages().

QStringList QLanguageFactory::languages (  )  const

Returns:
a list of languages supported by this factory

void QLanguageFactory::setLanguage ( QEditor e,
const QString &  file 
) [virtual, slot]

Parameters:
e target editor
file filename displayed by the editor
The file parameter may actuall be either a filename, an extension or the name of the language, checked in that order.

If it is a filename, complete extension as higher priority than simple extension (see QFileInfo suffix() and completeSuffix()).

Matches are first done case-sensitively.

If no matching language definition is found for all three possible interpretations of the file parameter, the same search is done case-insensitively.

If no matching language is found the previous language definition/completion engine of the editor are removed, leaving it blank, and the format scheme of the document is set to the defaultFormatScheme()

References QEditor::document(), QEditor::highlight(), QEditor::languageDefinition(), QEditor::setCompletionEngine(), QDocument::setFormatScheme(), and QEditor::setLanguageDefinition().


The documentation for this class was generated from the following files:

Generated on Sun Feb 15 22:50:20 2009 for QCodeEdit by  doxygen 1.5.7.1