Krita Source Code Documentation
Loading...
Searching...
No Matches
TasksetModel Class Reference

#include <tasksetmodel.h>

+ Inheritance diagram for TasksetModel:

Public Slots

void clear ()
 

Public Member Functions

QAction * actionFromIndex (const QModelIndex &index)
 
QVector< QAction * > actions ()
 
void addAction (QAction *action)
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
 TasksetModel (QObject *parent=0)
 
 ~TasksetModel () override
 

Private Attributes

QVector< QAction * > m_actions
 

Detailed Description

Definition at line 15 of file tasksetmodel.h.

Constructor & Destructor Documentation

◆ TasksetModel()

TasksetModel::TasksetModel ( QObject * parent = 0)

Definition at line 13 of file tasksetmodel.cpp.

13 : QAbstractTableModel(parent)
14{
15}

◆ ~TasksetModel()

TasksetModel::~TasksetModel ( )
override

Definition at line 17 of file tasksetmodel.cpp.

18{
19}

Member Function Documentation

◆ actionFromIndex()

QAction * TasksetModel::actionFromIndex ( const QModelIndex & index)

Definition at line 77 of file tasksetmodel.cpp.

78{
79 if(index.isValid()) {
80 return m_actions.at(index.row());
81 }
82 return 0;
83}
QVector< QAction * > m_actions

References m_actions.

◆ actions()

QVector< QAction * > TasksetModel::actions ( )

Definition at line 72 of file tasksetmodel.cpp.

73{
74 return m_actions;
75}

References m_actions.

◆ addAction()

void TasksetModel::addAction ( QAction * action)

Definition at line 65 of file tasksetmodel.cpp.

66{
67 m_actions.append(action);
68 beginResetModel();
69 endResetModel();
70}

References m_actions.

◆ clear

void TasksetModel::clear ( )
slot

Definition at line 85 of file tasksetmodel.cpp.

86{
87 m_actions.clear();
88 beginResetModel();
89 endResetModel();
90}

References m_actions.

◆ columnCount()

int TasksetModel::columnCount ( const QModelIndex & parent = QModelIndex()) const
override

Definition at line 54 of file tasksetmodel.cpp.

55{
56 return 1;
57}

◆ data()

QVariant TasksetModel::data ( const QModelIndex & index,
int role = Qt::DisplayRole ) const
override

Definition at line 21 of file tasksetmodel.cpp.

22{
23 if (index.isValid()) {
24
25 switch (role) {
26 case Qt::DisplayRole:
27 {
28 return m_actions.at(index.row())->iconText();
29 }
30 case Qt::DecorationRole:
31 {
32 const QIcon icon = m_actions.at(index.row())->icon();
33 if (icon.isNull()) {
34 return KisIconUtils::loadIcon("tools-wizard");
35 }
36 return icon;
37 }
38 }
39 }
40 return QVariant();
41}
QIcon loadIcon(const QString &name)

References KisIconUtils::loadIcon(), and m_actions.

◆ flags()

Qt::ItemFlags TasksetModel::flags ( const QModelIndex & index) const
override

Definition at line 59 of file tasksetmodel.cpp.

60{
61 Qt::ItemFlags flags = /*Qt::ItemIsSelectable |*/ Qt::ItemIsEnabled;
62 return flags;
63}
Qt::ItemFlags flags(const QModelIndex &index) const override

References flags().

◆ headerData()

QVariant TasksetModel::headerData ( int section,
Qt::Orientation orientation,
int role = Qt::DisplayRole ) const
override

Definition at line 43 of file tasksetmodel.cpp.

44{
45 return i18n("Task");
46}

◆ rowCount()

int TasksetModel::rowCount ( const QModelIndex & parent = QModelIndex()) const
override

Definition at line 49 of file tasksetmodel.cpp.

50{
51 return m_actions.count();
52}

References m_actions.

Member Data Documentation

◆ m_actions

QVector<QAction*> TasksetModel::m_actions
private

Definition at line 35 of file tasksetmodel.h.


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