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

#include <KoMarkerModel.h>

+ Inheritance diagram for KoMarkerModel:

Public Member Functions

int addTemporaryMarker (KoMarker *marker)
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 
 KoMarkerModel (const QList< KoMarker * > markers, KoFlake::MarkerPosition position, QObject *parent=0)
 
QVariant marker (int index, int role=Qt::UserRole) const
 
int markerIndex (KoMarker *marker) const
 
KoFlake::MarkerPosition position () const
 
void removeTemporaryMarker ()
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
int temporaryMarkerPosition () const
 
 ~KoMarkerModel () override
 

Private Attributes

KoFlake::MarkerPosition m_markerPosition
 
QList< QExplicitlySharedDataPointer< KoMarker > > m_markers
 
int m_temporaryMarkerPosition
 

Detailed Description

Definition at line 17 of file KoMarkerModel.h.

Constructor & Destructor Documentation

◆ KoMarkerModel()

KoMarkerModel::KoMarkerModel ( const QList< KoMarker * > markers,
KoFlake::MarkerPosition position,
QObject * parent = 0 )

Definition at line 15 of file KoMarkerModel.cpp.

16 : QAbstractListModel(parent)
19{
20 Q_FOREACH (KoMarker *marker, markers) {
21 m_markers.append(QExplicitlySharedDataPointer<KoMarker>(marker));
22 }
23}
int m_temporaryMarkerPosition
QList< QExplicitlySharedDataPointer< KoMarker > > m_markers
QVariant marker(int index, int role=Qt::UserRole) const
KoFlake::MarkerPosition m_markerPosition
KoFlake::MarkerPosition position() const

References m_markers, and marker().

◆ ~KoMarkerModel()

KoMarkerModel::~KoMarkerModel ( )
override

Definition at line 25 of file KoMarkerModel.cpp.

26{
27}

Member Function Documentation

◆ addTemporaryMarker()

int KoMarkerModel::addTemporaryMarker ( KoMarker * marker)

Definition at line 64 of file KoMarkerModel.cpp.

65{
68 }
69
70 m_temporaryMarkerPosition = m_markers.size() > 0 ? 1 : 0;
71 beginInsertRows(QModelIndex(), m_temporaryMarkerPosition, m_temporaryMarkerPosition);
72 m_markers.prepend(QExplicitlySharedDataPointer<KoMarker>(marker));
73
74 endInsertRows();
75
77}
void removeTemporaryMarker()

References m_markers, m_temporaryMarkerPosition, marker(), and removeTemporaryMarker().

◆ data()

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

Definition at line 35 of file KoMarkerModel.cpp.

36{
37 if (!index.isValid()) {
38 return QVariant();
39 }
40
41 switch(role) {
42 case Qt::DecorationRole:
43 if (index.row() < m_markers.size()) {
44 return QVariant::fromValue<KoMarker*>(m_markers.at(index.row()).data());
45 }
46 return QVariant();
47 case Qt::SizeHintRole:
48 return QSize(80,30);
49 default:
50 return QVariant();
51 }
52}

References m_markers.

◆ marker()

QVariant KoMarkerModel::marker ( int index,
int role = Qt::UserRole ) const

Definition at line 94 of file KoMarkerModel.cpp.

95{
96 if (index < 0){
97 return QVariant();
98 }
99
100 switch(role) {
101 case Qt::DecorationRole:
102 if (index< m_markers.size()) {
103 return QVariant::fromValue<KoMarker*>(m_markers.at(index).data());
104 }
105 return QVariant();
106 case Qt::SizeHintRole:
107 return QSize(80, 30);
108 default:
109 return QVariant();
110 }
111}

References m_markers.

◆ markerIndex()

int KoMarkerModel::markerIndex ( KoMarker * marker) const

Definition at line 54 of file KoMarkerModel.cpp.

55{
56 for (int i = 0; i < m_markers.size(); i++) {
57 if (m_markers[i] == marker) return i;
58 if (m_markers[i] && marker && *m_markers[i] == *marker) return i;
59 }
60
61 return false;
62}

References m_markers, and marker().

◆ position()

KoFlake::MarkerPosition KoMarkerModel::position ( ) const

Definition at line 113 of file KoMarkerModel.cpp.

114{
115 return m_markerPosition;
116}

References m_markerPosition.

◆ removeTemporaryMarker()

void KoMarkerModel::removeTemporaryMarker ( )

Definition at line 79 of file KoMarkerModel.cpp.

80{
82 beginRemoveRows(QModelIndex(), m_temporaryMarkerPosition, m_temporaryMarkerPosition);
85 endRemoveRows();
86 }
87}

References m_markers, and m_temporaryMarkerPosition.

◆ rowCount()

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

Definition at line 29 of file KoMarkerModel.cpp.

30{
31 Q_UNUSED(parent);
32 return m_markers.count();
33}

References m_markers.

◆ temporaryMarkerPosition()

int KoMarkerModel::temporaryMarkerPosition ( ) const

Definition at line 89 of file KoMarkerModel.cpp.

90{
92}

References m_temporaryMarkerPosition.

Member Data Documentation

◆ m_markerPosition

KoFlake::MarkerPosition KoMarkerModel::m_markerPosition
private

Definition at line 40 of file KoMarkerModel.h.

◆ m_markers

QList<QExplicitlySharedDataPointer<KoMarker> > KoMarkerModel::m_markers
private

Definition at line 39 of file KoMarkerModel.h.

◆ m_temporaryMarkerPosition

int KoMarkerModel::m_temporaryMarkerPosition
private

Definition at line 41 of file KoMarkerModel.h.


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