KTextTemplate::TagLibraryInterface Class

class KTextTemplate::TagLibraryInterface

The TagLibraryInterface returns available tags and filters from libraries. More...

Header: #include <KTextTemplate/TagLibraryInterface>
CMake: find_package(KF6 REQUIRED COMPONENTS TextTemplate)
target_link_libraries(mytarget PRIVATE KF6::TextTemplate)

Public Functions

virtual QHash<QString, KTextTemplate::Filter *> filters(const QString &name = {})
virtual QHash<QString, KTextTemplate::AbstractNodeFactory *> nodeFactories(const QString &name = {})

Detailed Description

This interface must be implemented in tag and filter libraries.

The implementation will usually be very simple.

class MyTagLibrary : public QObject, public TagLibraryInterface
{
  Q_OBJECT
  Q_INTERFACES( KTextTemplate::TagLibraryInterface )
public:
  MyTagLibrary( QObject *parent = {} )
      : QObject( parent ) {
  }

  QHash<QString, AbstractNodeFactory*>
  nodeFactories(const QString &name = {}) {
    Q_UNUSED( name );
    QHash<QString, AbstractNodeFactory*> nodeFactories;
    nodeFactories.insert( "mytag1", new MyTag1() );
    nodeFactories.insert( "mytag2", new MyTag2() );
    return nodeFactories;
  }

  QHash<QString, Filter*> filters( const QString &name = {} ) {
    Q_UNUSED( name );

    QHash<QString, Filter*> filters;

    filters.insert( "myfilter1", new MyFilter1() );
    filters.insert( "myfilter2", new MyFilter2() );

    return filters;
  }
};

Member Function Documentation

[virtual] QHash<QString, KTextTemplate::Filter *> TagLibraryInterface::filters(const QString &name = {})

Returns the Filter implementations available in this library.

[virtual] QHash<QString, KTextTemplate::AbstractNodeFactory *> TagLibraryInterface::nodeFactories(const QString &name = {})

Returns the AbstractNodeFactory implementations available in this library.