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

#include <SvgSymbolCollectionDocker.h>

+ Inheritance diagram for SvgCollectionModel:

Public Member Functions

QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 
QMimeData * mimeData (const QModelIndexList &indexes) const override
 
QStringList mimeTypes () const override
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
void setIconSize (int size)
 
void setShowDescription (bool showDescription)
 
void setSvgSymbolCollectionResource (QSharedPointer< KoSvgSymbolCollectionResource > resource)
 
Qt::DropActions supportedDragActions () const override
 
 SvgCollectionModel (QObject *parent=0)
 

Private Attributes

int m_iconSize {256}
 
bool m_showDescription {true}
 
QSharedPointer< KoSvgSymbolCollectionResourcem_symbolCollection
 

Detailed Description

Definition at line 26 of file SvgSymbolCollectionDocker.h.

Constructor & Destructor Documentation

◆ SvgCollectionModel()

SvgCollectionModel::SvgCollectionModel ( QObject * parent = 0)
explicit

Definition at line 37 of file SvgSymbolCollectionDocker.cpp.

38 : QAbstractListModel(parent)
39{
40}

Member Function Documentation

◆ data()

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

Definition at line 42 of file SvgSymbolCollectionDocker.cpp.

43{
44 if (!index.isValid() || index.row() > m_symbolCollection->symbols().count()) {
45 return QVariant();
46 }
47
48 switch (role) {
49 case Qt::ToolTipRole:
50 return m_symbolCollection->symbols()[index.row()]->title;
51
52 case Qt::DecorationRole:
53 {
54 QPixmap px = QPixmap::fromImage(m_symbolCollection->symbols()[index.row()]->icon(m_iconSize));
55 QIcon icon(px);
56 return icon;
57 }
58 case Qt::UserRole:
59 return m_symbolCollection->symbols()[index.row()]->id;
60
61 case Qt::DisplayRole:
62 {
64 return m_symbolCollection->symbols()[index.row()]->title;
65 } else {
66 return QVariant();
67 }
68 }
69 default:
70 return QVariant();
71 }
72
73 return QVariant();
74}
QSharedPointer< KoSvgSymbolCollectionResource > m_symbolCollection

References m_iconSize, m_showDescription, and m_symbolCollection.

◆ flags()

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

Definition at line 112 of file SvgSymbolCollectionDocker.cpp.

113{
114 if (index.isValid()) {
115 return QAbstractListModel::flags(index) | Qt::ItemIsDragEnabled;
116 }
117 return QAbstractListModel::flags(index);
118}

◆ mimeData()

QMimeData * SvgCollectionModel::mimeData ( const QModelIndexList & indexes) const
override

Definition at line 82 of file SvgSymbolCollectionDocker.cpp.

83{
84 if (indexes.isEmpty()) {
85 return 0;
86 }
87
88 QModelIndex index = indexes.first();
89
90 if (!index.isValid()) {
91 return 0;
92 }
93
94 if (m_symbolCollection->symbols().isEmpty()) {
95 return 0;
96 }
97
98 QList<KoShape*> shapes;
99 shapes.append(m_symbolCollection->symbols()[index.row()]->shape);
100 KoDrag drag;
101 drag.setSvg(shapes);
102 QMimeData *mimeData = drag.mimeData();
103
104 return mimeData;
105}
bool setSvg(const QList< KoShape * > shapes)
Definition KoDrag.cpp:47
QMimeData * mimeData()
Definition KoDrag.cpp:94
QMimeData * mimeData(const QModelIndexList &indexes) const override

References m_symbolCollection, KoDrag::mimeData(), mimeData(), and KoDrag::setSvg().

◆ mimeTypes()

QStringList SvgCollectionModel::mimeTypes ( ) const
override

Definition at line 107 of file SvgSymbolCollectionDocker.cpp.

108{
109 return QStringList() << SHAPETEMPLATE_MIMETYPE << "image/svg+xml";
110}
QList< QString > QStringList
#define SHAPETEMPLATE_MIMETYPE

References SHAPETEMPLATE_MIMETYPE.

◆ rowCount()

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

Definition at line 76 of file SvgSymbolCollectionDocker.cpp.

77{
78 Q_UNUSED(parent);
79 return m_symbolCollection->symbols().count();
80}

References m_symbolCollection.

◆ setIconSize()

void SvgCollectionModel::setIconSize ( int size)

Definition at line 125 of file SvgSymbolCollectionDocker.cpp.

126{
128}
int size(const Forest< T > &forest)
Definition KisForest.h:1232

References m_iconSize.

◆ setShowDescription()

void SvgCollectionModel::setShowDescription ( bool showDescription)

Definition at line 130 of file SvgSymbolCollectionDocker.cpp.

131{
132 m_showDescription = showDescription;
133}

References m_showDescription.

◆ setSvgSymbolCollectionResource()

void SvgCollectionModel::setSvgSymbolCollectionResource ( QSharedPointer< KoSvgSymbolCollectionResource > resource)

Definition at line 135 of file SvgSymbolCollectionDocker.cpp.

136{
137 m_symbolCollection = resource;
138}

References m_symbolCollection.

◆ supportedDragActions()

Qt::DropActions SvgCollectionModel::supportedDragActions ( ) const
override

Definition at line 120 of file SvgSymbolCollectionDocker.cpp.

121{
122 return Qt::CopyAction;
123}

Member Data Documentation

◆ m_iconSize

int SvgCollectionModel::m_iconSize {256}
private

Definition at line 44 of file SvgSymbolCollectionDocker.h.

44{256};

◆ m_showDescription

bool SvgCollectionModel::m_showDescription {true}
private

Definition at line 45 of file SvgSymbolCollectionDocker.h.

45{true};

◆ m_symbolCollection

QSharedPointer<KoSvgSymbolCollectionResource> SvgCollectionModel::m_symbolCollection
private

Definition at line 43 of file SvgSymbolCollectionDocker.h.


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