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 KoColorDisplayRendererInterface > m_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}
void sigPaletteModified()
sigPaletteModified emitted when palette associated with the model is modified
QPointer< const KoColorDisplayRendererInterface > m_displayRenderer
static KoColorDisplayRendererInterface * instance()

References 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 301 of file KisPaletteModel.cpp.

302{
303 QScopedValueRollback editMarker(m_editing, true);
304 beginInsertRows(QModelIndex(), rowCount(), rowCount() + _rowCount);
305 m_colorSet->addGroup(groupName, _columnCount, _rowCount);
306 endInsertRows();
307 return m_colorSet->getGroup(groupName);
308}
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 293 of file KisPaletteModel.cpp.

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

References m_editing.

◆ clear() [1/2]

void KisPaletteModel::clear ( )

Definition at line 326 of file KisPaletteModel.cpp.

327{
328 m_colorSet->clear();
329}

◆ clear() [2/2]

void KisPaletteModel::clear ( int defaultColumnsCount)

Definition at line 331 of file KisPaletteModel.cpp.

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

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 340 of file KisPaletteModel.cpp.

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

References CheckSlotRole, GroupNameRole, and RowInGroupRole.

◆ dataForSwatch()

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

Definition at line 365 of file KisPaletteModel.cpp.

366{
367 KisSwatchGroupSP group = m_colorSet->getGroup(idx.row());
368 Q_ASSERT(group);
369 int rowInGroup = rowNumberInGroup(idx.row());
370 bool entryPresent = group->checkSwatchExists(idx.column(), rowInGroup);
371 KisSwatch entry;
372 if (entryPresent) {
373 entry = group->getSwatch(idx.column(), rowInGroup);
374 }
375 switch (role) {
376 case Qt::ToolTipRole:
377 case Qt::DisplayRole: {
378 return entryPresent ? entry.name() + "\n(" + KoColor::toQString(entry.color()) + ")" : i18n("Empty slot");
379 }
380 case Qt::BackgroundRole: {
381 QColor color(0, 0, 0, 0);
382 if (entryPresent) {
383 color = m_displayRenderer->toQColor(entry.color());
384 }
385 return QBrush(color);
386 }
387 case GroupNameRole: {
388 return group->name();
389 }
390 case CheckSlotRole: {
391 return entryPresent;
392 }
393 case RowInGroupRole: {
394 return rowInGroup;
395 }
396 default: {
397 return QVariant();
398 }
399 }
400}
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:656

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 485 of file KisPaletteModel.cpp.

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

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 469 of file KisPaletteModel.cpp.

470{
471 if (!m_colorSet) return {};
472 KisSwatchGroup::SwatchInfo info = m_colorSet->getClosestSwatchInfo(compare);
473 return createIndex(indexRowForInfo(info), info.column, m_colorSet->getGroup(info.group).data());
474}
int indexRowForInfo(const KisSwatchGroup::SwatchInfo &info)

References indexRowForInfo().

◆ indexRowForInfo()

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

Definition at line 476 of file KisPaletteModel.cpp.

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

◆ 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 if (m_colorSet) {
111 m_colorSet->disconnect(this);
112 }
113 m_colorSet = colorSet;
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)
KoColorSetSP colorSet() const
void sigPaletteChanged()
sigPaletteChanged emitted when the palette associated with the model is changed for another palette

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

◆ setColumnCount()

void KisPaletteModel::setColumnCount ( int colCount)

Definition at line 321 of file KisPaletteModel.cpp.

322{
323 m_colorSet->setColumnCount(colCount);
324}

◆ 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 402 of file KisPaletteModel.cpp.

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

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

◆ setRowCountForGroup()

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

Definition at line 310 of file KisPaletteModel.cpp.

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

References m_editing, and rowCount().

◆ setSwatch()

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

Definition at line 276 of file KisPaletteModel.cpp.

277{
279
280 if (m_colorSet->isGroupTitleRow(index.row())) return;
281
282 Q_ASSERT(index.column() < m_colorSet->columnCount());
283 Q_ASSERT(index.column() < columnCount());
284
285 KisSwatchGroupSP group = m_colorSet->getGroup(index.row());
286 Q_ASSERT(group);
287
288 m_colorSet->addSwatch(entry, group->name(), index.column(), rowNumberInGroup(index.row()));
289
290 Q_EMIT dataChanged(index, index);
291}
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128

References columnCount(), index(), KIS_SAFE_ASSERT_RECOVER_RETURN, 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 416 of file KisPaletteModel.cpp.

417{
418 beginResetModel();
419 endResetModel();
420}

◆ slotEntryChanged

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

Definition at line 455 of file KisPaletteModel.cpp.

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

References index().

◆ slotExternalPaletteModified()

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

Definition at line 461 of file KisPaletteModel.cpp.

462{
463 if (resource && resource == m_colorSet) {
466 }
467}

References slotDisplayConfigurationChanged(), and slotPaletteModified().

◆ slotLayoutAboutToChange

void KisPaletteModel::slotLayoutAboutToChange ( )
privateslot

Definition at line 440 of file KisPaletteModel.cpp.

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

References m_editing.

◆ slotLayoutChanged

void KisPaletteModel::slotLayoutChanged ( )
privateslot

Definition at line 448 of file KisPaletteModel.cpp.

449{
450 if (!m_editing) {
451 endResetModel();
452 }
453}

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 422 of file KisPaletteModel.cpp.

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

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: