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

The KisPaletteModel class This, together with KisPaletteView and KisPaletteDelegate forms a mvc way to access kocolorsets. A display renderer is given to this model to convert KoColor to QColor when colors are requested. More...

#include <KisPaletteModel.h>

+ Inheritance diagram for KisPaletteModel:

Public Types

enum  AdditionalRoles { IsGroupNameRole = Qt::UserRole + 1 , CheckSlotRole , GroupNameRole , RowInGroupRole }
 

Signals

void sigPaletteChanged ()
 sigPaletteChanged emitted when the palette associated with the model is changed for another palette
 
void sigPaletteModified ()
 sigPaletteModified emitted when palette associated with the model is modified
 

Public Member Functions

KisSwatchGroupSP addGroup (const QString &groupName, int columnCount=KisSwatchGroup::DEFAULT_COLUMN_COUNT, int rowCount=KisSwatchGroup::DEFAULT_ROW_COUNT)
 
void addSwatch (const KisSwatch &entry, const QString &groupName=KoColorSet::GLOBAL_GROUP_NAME)
 
void changeGroupName (const QString &groupName, const QString &newName)
 
void clear ()
 
void clear (int defaultColumnsCount)
 
KoColorSetSP colorSet () const
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 
bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 
KisSwatch getSwatch (const QModelIndex &index) const
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
 
QModelIndex indexForClosest (const KoColor &compare)
 
 KisPaletteModel (QObject *parent=0)
 
QMimeData * mimeData (const QModelIndexList &indexes) const override
 
QStringList mimeTypes () const override
 
void removeGroup (const QString &groupName, bool keepColors)
 
void removeSwatch (const QModelIndex &index, bool keepColors=true)
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
void setColorSet (KoColorSetSP colorSet)
 
void setColumnCount (int colCount)
 
void setDisplayRenderer (const KoColorDisplayRendererInterface *displayRenderer)
 
void setRowCountForGroup (const QString &groupName, int rowCount)
 
void setSwatch (const KisSwatch &entry, const QModelIndex &index)
 
void slotExternalPaletteModified (QSharedPointer< KoColorSet > resource)
 
Qt::DropActions supportedDropActions () const override
 
 ~KisPaletteModel () override
 

Private Slots

void slotDisplayConfigurationChanged ()
 
void slotEntryChanged (int column, int row)
 
void slotLayoutAboutToChange ()
 
void slotLayoutChanged ()
 
void slotPaletteModified ()
 

Private Member Functions

QVariant dataForGroupNameRow (const QModelIndex &idx, int role) const
 
QVariant dataForSwatch (const QModelIndex &idx, int role) const
 
int indexRowForInfo (const KisSwatchGroup::SwatchInfo &info)
 
int rowNumberInGroup (int rowInModel) const
 

Private Attributes

 : KoColorSetSP m_colorSet
 
QPointer< const KoColorDisplayRendererInterfacem_displayRenderer
 
bool m_editing {false}
 

Friends

class TestKisPaletteModel
 

Detailed Description

The KisPaletteModel class This, together with KisPaletteView and KisPaletteDelegate forms a mvc way to access kocolorsets. A display renderer is given to this model to convert KoColor to QColor when colors are requested.

Definition at line 27 of file KisPaletteModel.h.

Member Enumeration Documentation

◆ AdditionalRoles

Enumerator
IsGroupNameRole 
CheckSlotRole 
GroupNameRole 
RowInGroupRole 

Definition at line 42 of file KisPaletteModel.h.

Constructor & Destructor Documentation

◆ KisPaletteModel()

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

Definition at line 25 of file KisPaletteModel.cpp.

26 : QAbstractTableModel(parent)
27 , m_colorSet(0)
29{
30 connect(this, SIGNAL(sigPaletteModified()), SLOT(slotPaletteModified()));
31}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void sigPaletteModified()
sigPaletteModified emitted when palette associated with the model is modified
QPointer< const KoColorDisplayRendererInterface > m_displayRenderer
static KoColorDisplayRendererInterface * instance()

References connect(), sigPaletteModified(), and slotPaletteModified().

◆ ~KisPaletteModel()

KisPaletteModel::~KisPaletteModel ( )
override

Definition at line 33 of file KisPaletteModel.cpp.

34{
35}

Member Function Documentation

◆ addGroup()

KisSwatchGroupSP KisPaletteModel::addGroup ( const QString & groupName,
int columnCount = KisSwatchGroup::DEFAULT_COLUMN_COUNT,
int rowCount = KisSwatchGroup::DEFAULT_ROW_COUNT )

Definition at line 299 of file KisPaletteModel.cpp.

300{
301 QScopedValueRollback editMarker(m_editing, true);
302 beginInsertRows(QModelIndex(), rowCount(), rowCount() + _rowCount);
303 m_colorSet->addGroup(groupName, _columnCount, _rowCount);
304 endInsertRows();
305 return m_colorSet->getGroup(groupName);
306}
int rowCount(const QModelIndex &parent=QModelIndex()) const override

References m_editing, and rowCount().

◆ addSwatch()

void KisPaletteModel::addSwatch ( const KisSwatch & entry,
const QString & groupName = KoColorSet::GLOBAL_GROUP_NAME )

Definition at line 135 of file KisPaletteModel.cpp.

136{
137 beginInsertRows(QModelIndex(), rowCount(), rowCount() + 1);
138 m_colorSet->addSwatch(entry, groupName);
139 endInsertRows();
140}

References rowCount().

◆ changeGroupName()

void KisPaletteModel::changeGroupName ( const QString & groupName,
const QString & newName )

Definition at line 291 of file KisPaletteModel.cpp.

292{
293 QScopedValueRollback editMarker(m_editing, true);
294 beginResetModel();
295 m_colorSet->changeGroupName(groupName, newName);
296 endResetModel();
297}

References m_editing.

◆ clear() [1/2]

void KisPaletteModel::clear ( )

Definition at line 324 of file KisPaletteModel.cpp.

325{
326 m_colorSet->clear();
327}

◆ clear() [2/2]

void KisPaletteModel::clear ( int defaultColumnsCount)

Definition at line 329 of file KisPaletteModel.cpp.

330{
331 QScopedValueRollback editMarker(m_editing, true);
332 beginResetModel();
333 m_colorSet->clear();
334 m_colorSet->setColumnCount(defaultColumnsCount);
335 endResetModel();
336}

References m_editing.

◆ colorSet()

KoColorSetSP KisPaletteModel::colorSet ( ) const

Definition at line 124 of file KisPaletteModel.cpp.

125{
126 return m_colorSet;
127}

◆ columnCount()

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

Definition at line 57 of file KisPaletteModel.cpp.

58{
59 if (m_colorSet && m_colorSet->columnCount() > 0) {
60 return m_colorSet->columnCount();
61 }
62 if (!m_colorSet) {
63 return 0;
64 }
65 return 16;
66}

◆ data()

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

Definition at line 37 of file KisPaletteModel.cpp.

38{
39 if (!index.isValid()) { return QVariant(); }
40 bool groupNameRow = m_colorSet->isGroupTitleRow(index.row());
41 if (role == IsGroupNameRole) {
42 return groupNameRow;
43 }
44 if (groupNameRow) {
45 return dataForGroupNameRow(index, role);
46 } else {
47 return dataForSwatch(index, role);
48 }
49}
QVariant dataForSwatch(const QModelIndex &idx, int role) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QVariant dataForGroupNameRow(const QModelIndex &idx, int role) const

References dataForGroupNameRow(), dataForSwatch(), index(), and IsGroupNameRole.

◆ dataForGroupNameRow()

QVariant KisPaletteModel::dataForGroupNameRow ( const QModelIndex & idx,
int role ) const
private

Definition at line 338 of file KisPaletteModel.cpp.

339{
340 KisSwatchGroupSP group = m_colorSet->getGroup(idx.row());
341 Q_ASSERT(group);
342 QString groupName = group->name();
343 switch (role) {
344 case Qt::ToolTipRole:
345 case Qt::DisplayRole: {
346 return groupName;
347 }
348 case GroupNameRole: {
349 return groupName;
350 }
351 case CheckSlotRole: {
352 return true;
353 }
354 case RowInGroupRole: {
355 return -1;
356 }
357 default: {
358 return QVariant();
359 }
360 }
361}

References CheckSlotRole, GroupNameRole, and RowInGroupRole.

◆ dataForSwatch()

QVariant KisPaletteModel::dataForSwatch ( const QModelIndex & idx,
int role ) const
private

Definition at line 363 of file KisPaletteModel.cpp.

364{
365 KisSwatchGroupSP group = m_colorSet->getGroup(idx.row());
366 Q_ASSERT(group);
367 int rowInGroup = rowNumberInGroup(idx.row());
368 bool entryPresent = group->checkSwatchExists(idx.column(), rowInGroup);
369 KisSwatch entry;
370 if (entryPresent) {
371 entry = group->getSwatch(idx.column(), rowInGroup);
372 }
373 switch (role) {
374 case Qt::ToolTipRole:
375 case Qt::DisplayRole: {
376 return entryPresent ? entry.name() + "\n(" + KoColor::toQString(entry.color()) + ")" : i18n("Empty slot");
377 }
378 case Qt::BackgroundRole: {
379 QColor color(0, 0, 0, 0);
380 if (entryPresent) {
381 color = m_displayRenderer->toQColor(entry.color());
382 }
383 return QBrush(color);
384 }
385 case GroupNameRole: {
386 return group->name();
387 }
388 case CheckSlotRole: {
389 return entryPresent;
390 }
391 case RowInGroupRole: {
392 return rowInGroup;
393 }
394 default: {
395 return QVariant();
396 }
397 }
398}
int rowNumberInGroup(int rowInModel) const
KoColor color() const
Definition KisSwatch.h:30
QString name() const
Definition KisSwatch.h:24
static QString toQString(const KoColor &color)
toQString create a user-visible string of the channel names and the channel values
Definition KoColor.cpp:655

References CheckSlotRole, KisSwatch::color(), GroupNameRole, m_displayRenderer, KisSwatch::name(), RowInGroupRole, rowNumberInGroup(), and KoColor::toQString().

◆ dropMimeData()

bool KisPaletteModel::dropMimeData ( const QMimeData * data,
Qt::DropAction action,
int row,
int column,
const QModelIndex & parent )
override

Definition at line 170 of file KisPaletteModel.cpp.

172{
173 Q_UNUSED(row);
174 Q_UNUSED(column);
175 if (!data->hasFormat("krita/x-colorsetentry") && !data->hasFormat("krita/x-colorsetgroup")) {
176 return false;
177 }
178 if (action == Qt::IgnoreAction) {
179 return false;
180 }
181
182 QModelIndex finalIndex = parent;
183 if (!finalIndex.isValid()) { return false; }
184
185 if (data->hasFormat("krita/x-colorsetgroup")) {
186 QScopedValueRollback editMarker(m_editing, true);
187 QByteArray encodedData = data->data("krita/x-colorsetgroup");
188 QDataStream stream(&encodedData, QIODevice::ReadOnly);
189
190 while (!stream.atEnd()) {
191 QString groupNameDroppedOn = qvariant_cast<QString>(finalIndex.data(GroupNameRole));
192 if (groupNameDroppedOn == KoColorSet::GLOBAL_GROUP_NAME) {
193 return false;
194 }
195 QString groupNameDragged;
196 stream >> groupNameDragged;
197 KisSwatchGroupSP groupDragged = m_colorSet->getGroup(groupNameDragged);
198 int start = m_colorSet->startRowForGroup(groupNameDragged);
199 int end = start + groupDragged->rowCount();
200 if (!beginMoveRows(QModelIndex(), start, end, QModelIndex(), m_colorSet->startRowForGroup(groupNameDroppedOn))) {
201 return false;
202 }
203 m_colorSet->moveGroup(groupNameDragged, groupNameDroppedOn);
204 endMoveRows();
205 }
206 return true;
207 }
208
209 if (qvariant_cast<bool>(finalIndex.data(KisPaletteModel::IsGroupNameRole))) {
210 return true;
211 }
212
213
214 if (data->hasFormat("krita/x-colorsetentry")) {
215 QByteArray encodedData = data->data("krita/x-colorsetentry");
216 QString oldGroupName;
217 int oriRow;
218 int oriColumn;
219 KisSwatch entry = KisSwatch::fromByteArray(encodedData, oldGroupName, oriRow, oriColumn);
220
221 if (action == Qt::MoveAction){
222 KisSwatchGroupSP g = m_colorSet->getGroup(oldGroupName);
223 if (g) {
224 if (qvariant_cast<bool>(finalIndex.data(KisPaletteModel::CheckSlotRole))) {
225 m_colorSet->addSwatch(getSwatch(finalIndex), g->name(), oriColumn, oriRow);
226 } else {
227 m_colorSet->removeSwatch(oriColumn, oriRow, g);
228 }
229 }
230 setSwatch(entry, finalIndex);
231 }
232
233 return true;
234 }
235
236 return false;
237}
KisSwatch getSwatch(const QModelIndex &index) const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
void setSwatch(const KisSwatch &entry, const QModelIndex &index)
static KisSwatch fromByteArray(QByteArray &data, QString &groupName, int &originalRow, int &originalColumn)
Definition KisSwatch.cpp:57
static const QString GLOBAL_GROUP_NAME
Definition KoColorSet.h:33
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:327

References CheckSlotRole, data(), KisSwatch::fromByteArray(), getSwatch(), KoColorSet::GLOBAL_GROUP_NAME, GroupNameRole, IsGroupNameRole, m_editing, and setSwatch().

◆ flags()

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

Definition at line 68 of file KisPaletteModel.cpp.

69{
70 if (index.isValid()) {
71 return Qt::ItemIsSelectable |
72 Qt::ItemIsEnabled |
73 Qt::ItemIsUserCheckable |
74 Qt::ItemIsDragEnabled |
75 Qt::ItemIsDropEnabled;
76 }
77 return Qt::ItemIsDropEnabled;
78}

References index().

◆ getSwatch()

KisSwatch KisPaletteModel::getSwatch ( const QModelIndex & index) const

Definition at line 482 of file KisPaletteModel.cpp.

483{
484 if (index.row() >= rowCount()) return KisSwatch();
485 if (index.row() < 0) return KisSwatch();
486
487 return m_colorSet->getColorGlobal(index.column(), index.row());
488}

References index(), and rowCount().

◆ index()

QModelIndex KisPaletteModel::index ( int row,
int column,
const QModelIndex & parent = QModelIndex() ) const
override

Definition at line 80 of file KisPaletteModel.cpp.

81{
82 Q_UNUSED(parent);
83
84 KisSwatchGroupSP group = 0;
85 if (m_colorSet) {
86 group = m_colorSet->getGroup(row);
87 }
88 else {
89 return {};
90 }
91
92 if (!group) {
93 qDebug() << "no group for row" << row << "col" << column << "total rows in model" << rowCount() << "rows in colorset" << m_colorSet->rowCountWithTitles();
94 return QModelIndex();
95 }
96 //KIS_ASSERT_RECOVER_RETURN_VALUE(group, QModelIndex());
97 QModelIndex idx = createIndex(row, column);
98 Q_ASSERT(idx.column() < columnCount());
99 Q_ASSERT(idx.row() < rowCount());
100 return idx;
101}
int columnCount(const QModelIndex &parent=QModelIndex()) const override

References columnCount(), and rowCount().

◆ indexForClosest()

QModelIndex KisPaletteModel::indexForClosest ( const KoColor & compare)

Definition at line 467 of file KisPaletteModel.cpp.

468{
469 KisSwatchGroup::SwatchInfo info = colorSet()->getClosestSwatchInfo(compare);
470 return createIndex(indexRowForInfo(info), info.column, colorSet()->getGroup(info.group).data());
471}
int indexRowForInfo(const KisSwatchGroup::SwatchInfo &info)
KoColorSetSP colorSet() const

References colorSet(), and indexRowForInfo().

◆ indexRowForInfo()

int KisPaletteModel::indexRowForInfo ( const KisSwatchGroup::SwatchInfo & info)
private

Definition at line 473 of file KisPaletteModel.cpp.

474{
475 int groupRow = m_colorSet->startRowForGroup(info.group);
476 if (info.group.isEmpty()) {
477 return groupRow + info.row;
478 }
479 return groupRow + info.row + 1;
480}

◆ mimeData()

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

Definition at line 239 of file KisPaletteModel.cpp.

240{
241 QMimeData *mimeData = new QMimeData();
242 QByteArray encodedData;
243
244 QDataStream stream(&encodedData, QIODevice::WriteOnly);
245 QModelIndex index = indexes.last();
246 if (index.isValid() && qvariant_cast<bool>(index.data(CheckSlotRole))) {
247 QString mimeTypeName = "krita/x-colorsetentry";
248 if (qvariant_cast<bool>(index.data(IsGroupNameRole))==false) {
249 KisSwatch entry = getSwatch(index);
250 QString groupName = qvariant_cast<QString>(index.data(KisPaletteModel::GroupNameRole));
251 entry.writeToStream(stream,
252 groupName,
253 rowNumberInGroup(index.row()),
254 index.column());
255 } else {
256 mimeTypeName = "krita/x-colorsetgroup";
257 QString groupName = qvariant_cast<QString>(index.data(GroupNameRole));
258 stream << groupName;
259 }
260 mimeData->setData(mimeTypeName, encodedData);
261 }
262
263 return mimeData;
264}
QMimeData * mimeData(const QModelIndexList &indexes) const override
void writeToStream(QDataStream &stream, const QString &groupName, int originalRow, int originalColumn)
Definition KisSwatch.cpp:44

References CheckSlotRole, getSwatch(), GroupNameRole, index(), IsGroupNameRole, mimeData(), rowNumberInGroup(), and KisSwatch::writeToStream().

◆ mimeTypes()

QStringList KisPaletteModel::mimeTypes ( ) const
override

Definition at line 266 of file KisPaletteModel.cpp.

267{
268 return QStringList() << "krita/x-colorsetentry" << "krita/x-colorsetgroup";
269}
QList< QString > QStringList

◆ removeGroup()

void KisPaletteModel::removeGroup ( const QString & groupName,
bool keepColors )

Definition at line 159 of file KisPaletteModel.cpp.

160{
161 QScopedValueRollback editMarker(m_editing, true);
162 int removeStart = m_colorSet->startRowForGroup(groupName);
163 int removedRowCount = m_colorSet->getGroup(groupName)->rowCount();
164
165 beginRemoveRows(QModelIndex(), removeStart, removeStart + removedRowCount);
166 m_colorSet->removeGroup(groupName, keepColors);
167 endRemoveRows();
168}

References m_editing.

◆ removeSwatch()

void KisPaletteModel::removeSwatch ( const QModelIndex & index,
bool keepColors = true )

Definition at line 142 of file KisPaletteModel.cpp.

143{
144 if (!index.isValid()) { return; }
145
146 KisSwatchGroupSP group = m_colorSet->getGroup(index.row());
147 if (!qvariant_cast<bool>(data(index, IsGroupNameRole))) {
148 m_colorSet->removeSwatch(index.column(),
149 rowNumberInGroup(index.row()),
150 group);
151 Q_EMIT dataChanged(index, index);
152 } else {
153 int groupNameRow = m_colorSet->startRowForGroup(group->name());
154 QString groupName = m_colorSet->getGroup(groupNameRow)->name();
155 removeGroup(groupName, keepColors);
156 }
157}
void removeGroup(const QString &groupName, bool keepColors)

References data(), index(), IsGroupNameRole, removeGroup(), and rowNumberInGroup().

◆ rowCount()

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

Definition at line 51 of file KisPaletteModel.cpp.

52{
53 if (!m_colorSet) return 0;
54 return m_colorSet->rowCountWithTitles();
55}

◆ rowNumberInGroup()

int KisPaletteModel::rowNumberInGroup ( int rowInModel) const
private

Definition at line 129 of file KisPaletteModel.cpp.

130{
131 return m_colorSet->rowNumberInGroup(rowInModel);
132}

◆ setColorSet()

void KisPaletteModel::setColorSet ( KoColorSetSP colorSet)

Definition at line 103 of file KisPaletteModel.cpp.

104{
105 if (colorSet == m_colorSet) {
106 return;
107 }
108
109 beginResetModel();
110 m_colorSet = colorSet;
111 if (m_colorSet) {
112 m_colorSet->disconnect(this);
113 }
114 if (colorSet) {
115 connect(colorSet.data(), SIGNAL(modified()), this, SIGNAL(sigPaletteModified()));
116 connect(colorSet.data(), SIGNAL(layoutChanged()), this, SLOT(slotLayoutChanged()));
117 connect(colorSet.data(), SIGNAL(layoutAboutToChange()), this, SLOT(slotLayoutAboutToChange()));
118 connect(colorSet.data(), SIGNAL(entryChanged(int,int)), this, SLOT(slotEntryChanged(int,int)));
119 }
120 endResetModel();
121 Q_EMIT sigPaletteChanged();
122}
void slotEntryChanged(int column, int row)
void sigPaletteChanged()
sigPaletteChanged emitted when the palette associated with the model is changed for another palette

References colorSet(), connect(), sigPaletteChanged(), sigPaletteModified(), slotEntryChanged(), slotLayoutAboutToChange(), and slotLayoutChanged().

◆ setColumnCount()

void KisPaletteModel::setColumnCount ( int colCount)

Definition at line 319 of file KisPaletteModel.cpp.

320{
321 m_colorSet->setColumnCount(colCount);
322}

◆ setDisplayRenderer()

void KisPaletteModel::setDisplayRenderer ( const KoColorDisplayRendererInterface * displayRenderer)

Installs a display renderer object for a palette that will convert the KoColor to the displayable QColor. Default is the dumb renderer.

Definition at line 400 of file KisPaletteModel.cpp.

401{
402 if (displayRenderer) {
403 if (m_displayRenderer) {
404 disconnect(m_displayRenderer, 0, this, 0);
405 }
406 m_displayRenderer = displayRenderer;
407 connect(m_displayRenderer, SIGNAL(displayConfigurationChanged()),
408 SLOT(slotDisplayConfigurationChanged()), Qt::UniqueConnection);
409 } else {
411 }
412}
void slotDisplayConfigurationChanged()

References connect(), KoDumbColorDisplayRenderer::instance(), m_displayRenderer, and slotDisplayConfigurationChanged().

◆ setRowCountForGroup()

void KisPaletteModel::setRowCountForGroup ( const QString & groupName,
int rowCount )

Definition at line 308 of file KisPaletteModel.cpp.

309{
310 QScopedValueRollback editMarker(m_editing, true);
311 beginResetModel();
312 KisSwatchGroupSP g = m_colorSet->getGroup(groupName);
313 if (g) {
314 g->setRowCount(rowCount);
315 }
316 endResetModel();
317}

References m_editing, and rowCount().

◆ setSwatch()

void KisPaletteModel::setSwatch ( const KisSwatch & entry,
const QModelIndex & index )

Definition at line 276 of file KisPaletteModel.cpp.

277{
278 if (m_colorSet->isGroupTitleRow(index.row())) return;
279
280 Q_ASSERT(index.column() < m_colorSet->columnCount());
281 Q_ASSERT(index.column() < columnCount());
282
283 KisSwatchGroupSP group = m_colorSet->getGroup(index.row());
284 Q_ASSERT(group);
285
286 m_colorSet->addSwatch(entry, group->name(), index.column(), rowNumberInGroup(index.row()));
287
288 Q_EMIT dataChanged(index, index);
289}

References columnCount(), index(), and rowNumberInGroup().

◆ sigPaletteChanged

void KisPaletteModel::sigPaletteChanged ( )
signal

sigPaletteChanged emitted when the palette associated with the model is changed for another palette

◆ sigPaletteModified

void KisPaletteModel::sigPaletteModified ( )
signal

sigPaletteModified emitted when palette associated with the model is modified

◆ slotDisplayConfigurationChanged

void KisPaletteModel::slotDisplayConfigurationChanged ( )
privateslot

Definition at line 414 of file KisPaletteModel.cpp.

415{
416 beginResetModel();
417 endResetModel();
418}

◆ slotEntryChanged

void KisPaletteModel::slotEntryChanged ( int column,
int row )
privateslot

Definition at line 453 of file KisPaletteModel.cpp.

454{
455 QModelIndex index = createIndex(row, column);
456 Q_EMIT dataChanged(index, index);
457}

References index().

◆ slotExternalPaletteModified()

void KisPaletteModel::slotExternalPaletteModified ( QSharedPointer< KoColorSet > resource)

Definition at line 459 of file KisPaletteModel.cpp.

460{
461 if (resource && resource == m_colorSet) {
464 }
465}

References slotDisplayConfigurationChanged(), and slotPaletteModified().

◆ slotLayoutAboutToChange

void KisPaletteModel::slotLayoutAboutToChange ( )
privateslot

Definition at line 438 of file KisPaletteModel.cpp.

439{
440 // when m_editing is true, we have the information about model changes and don't need to reset
441 if (!m_editing) {
442 beginResetModel();
443 }
444}

References m_editing.

◆ slotLayoutChanged

void KisPaletteModel::slotLayoutChanged ( )
privateslot

Definition at line 446 of file KisPaletteModel.cpp.

447{
448 if (!m_editing) {
449 endResetModel();
450 }
451}

References m_editing.

◆ slotPaletteModified

void KisPaletteModel::slotPaletteModified ( )
privateslot

Until we implement resource->convertToSerializable() we should explicitly convert all the palettes into Krita internal format

Definition at line 420 of file KisPaletteModel.cpp.

421{
426 if (m_colorSet->paletteType() != KoColorSet::KPL || m_colorSet->paletteType() != KoColorSet::GPL) {
427 m_colorSet->setPaletteType(KoColorSet::KPL);
428 }
429
430 if (m_colorSet->paletteType() == KoColorSet::KPL) {
431 m_colorSet->setFilename(QFileInfo(m_colorSet->filename()).completeBaseName() + ".kpl");
432 }
433 else if (m_colorSet->paletteType() == KoColorSet::GPL) {
434 m_colorSet->setFilename(QFileInfo(m_colorSet->filename()).completeBaseName() + ".gpl");
435 }
436}

References KoColorSet::GPL, and KoColorSet::KPL.

◆ supportedDropActions()

Qt::DropActions KisPaletteModel::supportedDropActions ( ) const
override

Definition at line 271 of file KisPaletteModel.cpp.

272{
273 return Qt::MoveAction;
274}

Friends And Related Symbol Documentation

◆ TestKisPaletteModel

friend class TestKisPaletteModel
friend

Definition at line 129 of file KisPaletteModel.h.

Member Data Documentation

◆ __pad0__

KisPaletteModel::__pad0__
private

Definition at line 135 of file KisPaletteModel.h.

◆ m_displayRenderer

QPointer<const KoColorDisplayRendererInterface> KisPaletteModel::m_displayRenderer
private

Definition at line 139 of file KisPaletteModel.h.

◆ m_editing

bool KisPaletteModel::m_editing {false}
private

Definition at line 140 of file KisPaletteModel.h.

140{false};

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