Krita Source Code Documentation
Loading...
Searching...
No Matches
KoGenericRegistryModel< T > Class Template Reference

#include <KoGenericRegistryModel.h>

+ Inheritance diagram for KoGenericRegistryModel< T >:

Public Member Functions

QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 
get (const QModelIndex &index) const
 
 KoGenericRegistryModel (KoGenericRegistry< T > *registry)
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
 ~KoGenericRegistryModel () override
 

Private Attributes

KoGenericRegistry< T > * m_registry
 

Detailed Description

template<typename T>
class KoGenericRegistryModel< T >

This is a model that you can use to display the content of a registry.

Parameters
Tis the type of the data in the registry

Definition at line 20 of file KoGenericRegistryModel.h.

Constructor & Destructor Documentation

◆ KoGenericRegistryModel()

template<typename T >
KoGenericRegistryModel< T >::KoGenericRegistryModel ( KoGenericRegistry< T > * registry)

Definition at line 54 of file KoGenericRegistryModel.h.

54 : m_registry(registry)
55{
56}
KoGenericRegistry< T > * m_registry

◆ ~KoGenericRegistryModel()

template<typename T >
KoGenericRegistryModel< T >::~KoGenericRegistryModel ( )
override

Definition at line 59 of file KoGenericRegistryModel.h.

60{
61}

Member Function Documentation

◆ data()

template<typename T >
QVariant KoGenericRegistryModel< T >::data ( const QModelIndex & index,
int role = Qt::DisplayRole ) const
override

When role == Qt::DisplayRole, this function will return the name of the element.

Definition at line 70 of file KoGenericRegistryModel.h.

71{
72 if (!index.isValid()) {
73 return QVariant();
74 }
75 if (role == Qt::DisplayRole || role == Qt::EditRole) {
76 return QVariant(get(index)->name());
77 }
78 return QVariant();
79}
T get(const QModelIndex &index) const
const char * name(StandardAction id)

References get().

◆ get()

template<typename T >
T KoGenericRegistryModel< T >::get ( const QModelIndex & index) const
Returns
the element at the given index

Definition at line 82 of file KoGenericRegistryModel.h.

83{
84 return m_registry->get(m_registry->keys()[index.row()]);
85}

◆ rowCount()

template<typename T >
int KoGenericRegistryModel< T >::rowCount ( const QModelIndex & parent = QModelIndex()) const
override
Returns
the number of elements in the registry

Definition at line 64 of file KoGenericRegistryModel.h.

65{
66 return m_registry->keys().size();
67}

Member Data Documentation

◆ m_registry

template<typename T >
KoGenericRegistry<T>* KoGenericRegistryModel< T >::m_registry
private

Definition at line 49 of file KoGenericRegistryModel.h.


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