QHelpEngineCore 类

The QHelpEngineCore class provides the core functionality of the help system. 更多...

头: #include <QHelpEngineCore>
qmake: QT += help
Since: Qt 4.4
继承: QObject
继承者: QHelpEngine

特性

公共函数

QHelpEngineCore (const QString & collectionFile , QObject * parent = nullptr)
virtual ~QHelpEngineCore ()
bool addCustomFilter (const QString & filterName , const QStringList & 属性 )
bool autoSaveFilter () const
QString collectionFile () const
bool copyCollectionFile (const QString & fileName )
QString currentFilter () const
QStringList customFilters () const
QVariant customValue (const QString & key , const QVariant & defaultValue = QVariant()) const
QString documentationFileName (const QString & namespaceName )
QString error () const
QByteArray fileData (const QUrl & url ) const
QList<QUrl> 文件 (const QString namespaceName , const QStringList & filterAttributes , const QString & extensionFilter = QString())
QList<QStringList> filterAttributeSets (const QString & namespaceName ) const
QStringList filterAttributes () const
QStringList filterAttributes (const QString & filterName ) const
QUrl findFile (const QUrl & url ) const
QMap<QString, QUrl> linksForIdentifier (const QString & id ) const
QMap<QString, QUrl> linksForKeyword (const QString & keyword ) const
bool registerDocumentation (const QString & documentationFileName )
QStringList registeredDocumentations () const
bool removeCustomFilter (const QString & filterName )
bool removeCustomValue (const QString & key )
void setAutoSaveFilter (bool save )
void setCollectionFile (const QString & fileName )
void setCurrentFilter (const QString & filterName )
bool setCustomValue (const QString & key , const QVariant & value )
bool setupData ()
bool unregisterDocumentation (const QString & namespaceName )

信号

void currentFilterChanged (const QString & newFilter )
void readersAboutToBeInvalidated ()
void setupFinished ()
void setupStarted ()
void warning (const QString & msg )

静态公共成员

QVariant metaData (const QString & documentationFileName , const QString & name )
QString namespaceName (const QString & documentationFileName )
const QMetaObject staticMetaObject

额外继承成员

详细描述

The QHelpEngineCore class provides the core functionality of the help system.

在可以使用帮助引擎前,必须初始化它通过调用 setupData (). At the beginning of the setup process the signal setupStarted () is emitted. From this point on until the signal setupFinished () is emitted, is the help data in an undefined meaning unusable state.

The core help engine can be used to perform different tasks. By calling linksForIdentifier () the engine returns URLs specifying the file locations inside the help system. The actual file data can then be retrived by calling fileData (). In contrast to all other functions in this class, linksForIdentifier () depends on the currently set custom filter. Depending on the filter, the function may return different results.

Every help engine can contain any number of custom filters. A custom filter is defined by a name and set of filter attributes and can be added to the help engine by calling addCustomFilter (). Analogous, it is removed by calling removeCustomFilter (). customFilters () returns all defined filters.

The help engine also offers the possibility to set and read values in a persistant way comparable to ini files or Windows registry entries. For more information see setValue() or value().

This class does not offer any GUI components or functionality for indices or contents. If you need one of those use QHelpEngine 代替。

When creating a custom help viewer the viewer can be configured by writing a custom collection file which could contain various keywords to be used to configure the help engine. These keywords and values and their meaning can be found in the help information for creating a custom help collection file for Assistant.

特性文档编制

autoSaveFilter : bool

此特性保持是否 QHelpEngineCore is in auto save filter mode or not.

QHelpEngineCore is in auto save filter mode, the current filter is automatically saved when it is changed by the setCurrentFilter () function. The filter is saved persistently in the help collection file.

By default, this mode is on.

该特性在 Qt 4.5 引入。

访问函数:

bool autoSaveFilter () const
void setAutoSaveFilter (bool save )

collectionFile : QString

This property holds the absolute file name of the collection file currently used.

Setting this property leaves the help engine in an invalid state. It is important to invoke setupData () or any getter function in order to setup the help engine again.

该特性在 Qt 4.5 引入。

访问函数:

QString collectionFile () const
void setCollectionFile (const QString & fileName )

currentFilter : QString

This property holds the name of the custom filter currently applied.

Setting this property will save the new custom filter permanently in the help collection file. To set a custom filter without saving it permanently, disable the auto save filter mode.

该特性在 Qt 4.5 引入。

访问函数:

QString currentFilter () const
void setCurrentFilter (const QString & filterName )

另请参阅 autoSaveFilter ().

成员函数文档编制

QHelpEngineCore:: QHelpEngineCore (const QString & collectionFile , QObject * parent = nullptr)

Constructs a new core help engine with a parent 。帮助引擎所用信息存储于 collectionFile to provide help. If the collection file does not exist yet, it'll be created.

[虚拟] QHelpEngineCore:: ~QHelpEngineCore ()

Destructs the help engine.

bool QHelpEngineCore:: addCustomFilter (const QString & filterName , const QStringList & 属性 )

Adds the new custom filter filterName . The filter attributes are specified by 属性 . If the filter already exists, its attribute set is replaced. The function returns true if the operation succeeded, otherwise it returns false.

另请参阅 customFilters () 和 removeCustomFilter ().

bool QHelpEngineCore:: copyCollectionFile (const QString & fileName )

Creates the file fileName and copies all contents from the current collection file into the newly created file, and returns true if successful; otherwise returns false.

The copying process makes sure that file references to Qt Collection files ( .qch ) files are updated accordingly.

[signal] void QHelpEngineCore:: currentFilterChanged (const QString & newFilter )

This signal is emitted when the current filter is changed to newFilter .

QStringList QHelpEngineCore:: customFilters () const

Returns a list of custom filters.

另请参阅 addCustomFilter () 和 removeCustomFilter ().

QVariant QHelpEngineCore:: customValue (const QString & key , const QVariant & defaultValue = QVariant()) const

Returns the value assigned to the key . If the requested key does not exist, the specified defaultValue 被返回。

另请参阅 setCustomValue () 和 removeCustomValue ().

QString QHelpEngineCore:: documentationFileName (const QString & namespaceName )

Returns the absolute file name of the Qt compressed help file (.qch) identified by the namespaceName . If there is no Qt compressed help file with the specified namespace registered, an empty string is returned.

另请参阅 namespaceName ().

QString QHelpEngineCore:: error () const

Returns a description of the last error that occurred.

QByteArray QHelpEngineCore:: fileData (const QUrl & url ) const

Returns the data of the file specified by url . If the file does not exist, an empty QByteArray 被返回。

另请参阅 findFile ().

QList < QUrl > QHelpEngineCore:: 文件 (const QString namespaceName , const QStringList & filterAttributes , const QString & extensionFilter = QString())

Returns a list of files contained in the Qt compressed help file namespaceName . The files can be filtered by filterAttributes as well as by their extension extensionFilter (e.g. 'html').

QList < QStringList > QHelpEngineCore:: filterAttributeSets (const QString & namespaceName ) const

Returns a list of filter attributes for the different filter sections defined in the Qt compressed help file with the given namespace namespaceName .

QStringList QHelpEngineCore:: filterAttributes () const

Returns a list of all defined filter attributes.

QStringList QHelpEngineCore:: filterAttributes (const QString & filterName ) const

Returns a list of filter attributes used by the custom filter filterName .

QUrl QHelpEngineCore:: findFile (const QUrl & url ) const

Returns an invalid URL if the file url cannot be found. If the file exists, either the same url is returned or a different url if the file is located in a different namespace which is merged via a common virtual folder.

QMap < QString , QUrl > QHelpEngineCore:: linksForIdentifier (const QString & id ) const

Returns documents found for the id . The map contains the document titles and their URLs. The returned map contents depends on the current filter, meaning only the keywords registered for the current filter will be returned.

QMap < QString , QUrl > QHelpEngineCore:: linksForKeyword (const QString & keyword ) const

Returns all documents found for the keyword . The returned map consists of the document titles and their URLs.

该函数在 Qt 4.5 引入。

[static] QVariant QHelpEngineCore:: metaData (const QString & documentationFileName , const QString & name )

Returns the meta data for the Qt compressed help file documentationFileName . If there is no data available for name , an invalid QVariant() is returned. The meta data is defined when creating the Qt compressed help file and cannot be modified later. Common meta data includes e.g. the author of the documentation.

[static] QString QHelpEngineCore:: namespaceName (const QString & documentationFileName )

Returns the namespace name defined for the Qt compressed help file (.qch) specified by its documentationFileName . If the file is not valid, an empty string is returned.

另请参阅 documentationFileName ().

[signal] void QHelpEngineCore:: readersAboutToBeInvalidated ()

bool QHelpEngineCore:: registerDocumentation (const QString & documentationFileName )

Registers the Qt compressed help file (.qch) contained in the file documentationFileName . One compressed help file, uniquely identified by its namespace can only be registered once. True is returned if the registration was successful, otherwise false.

另请参阅 unregisterDocumentation () 和 error ().

QStringList QHelpEngineCore:: registeredDocumentations () const

Returns a list of all registered Qt compressed help files of the current collection file. The returned names are the namespaces of the registered Qt compressed help files (.qch).

bool QHelpEngineCore:: removeCustomFilter (const QString & filterName )

Returns true if the filter filterName was removed successfully, otherwise false.

另请参阅 addCustomFilter () 和 customFilters ().

bool QHelpEngineCore:: removeCustomValue (const QString & key )

移除 key from the settings section in the collection file. Returns true if the value was removed successfully, otherwise false.

另请参阅 customValue () 和 setCustomValue ().

bool QHelpEngineCore:: setCustomValue (const QString & key , const QVariant & value )

Save the value under the key . If the key already exist, the value will be overwritten. Returns true if the value was saved successfully, otherwise false.

另请参阅 customValue () 和 removeCustomValue ().

bool QHelpEngineCore:: setupData ()

Sets up the help engine by processing the information found in the collection file and returns true if successful; otherwise returns false.

By calling the function, the help engine is forced to initialize itself immediately. Most of the times, this function does not have to be called explicitly because getter functions which depend on a correctly set up help engine do that themselves.

注意: qsqlite4.dll needs to be deployed with the application as the help system uses the sqlite driver when loading help collections.

[signal] void QHelpEngineCore:: setupFinished ()

This signal is emitted when the setup is complete.

[signal] void QHelpEngineCore:: setupStarted ()

This signal is emitted when setup is started.

bool QHelpEngineCore:: unregisterDocumentation (const QString & namespaceName )

Unregisters the Qt compressed help file (.qch) identified by its namespaceName from the help collection. Returns true on success, otherwise false.

另请参阅 registerDocumentation () 和 error ().

[signal] void QHelpEngineCore:: warning (const QString & msg )

This signal is emitted when a non critical error occurs. The warning message is stored in msg .