#include <KisUniqueColorSet.h>
Definition at line 18 of file KisUniqueColorSet.h.
◆ KisUniqueColorSet() [1/2]
| KisUniqueColorSet::KisUniqueColorSet |
( |
QObject * | parent = nullptr | ) |
|
|
explicit |
◆ ~KisUniqueColorSet()
| KisUniqueColorSet::~KisUniqueColorSet |
( |
| ) |
|
|
override |
Definition at line 56 of file KisUniqueColorSet.cpp.
57{
58 for (ColorEntry *entry:
d->history) {
59 delete entry;
60 }
61}
References d.
◆ KisUniqueColorSet() [2/2]
| KisUniqueColorSet::KisUniqueColorSet |
( |
const KisUniqueColorSet & | rhs, |
|
|
QObject * | parent = nullptr ) |
◆ addColor()
| void KisUniqueColorSet::addColor |
( |
const KoColor & | color | ) |
|
Definition at line 70 of file KisUniqueColorSet.cpp.
71{
72 auto hashEntry =
d->colorHash.find(
color);
73 if (hashEntry !=
d->colorHash.end()) {
74 auto historyEl = std::lower_bound(
d->history.begin(),
d->history.end(), *hashEntry, &
ColorEntry::less);
75 if (historyEl !=
d->history.end()) {
76 int oldPos = historyEl -
d->history.begin();
77 if (historyEl ==
d->history.begin()) {
79 return;
80 }
81 ColorEntry *node = *historyEl;
82 d->history.erase(historyEl);
84 d->history.push_front(node);
86 }
87 else {
88 qDebug() << "inconsistent color history state!";
89 }
90 }
91 else {
92 ColorEntry *entry;
93 if (
d->history.size() >=
d->maxSize) {
94 entry =
d->history.back();
95 d->history.pop_back();
98 entry->key = ++
d->key;
100 }
101 else {
102 entry =
new ColorEntry {
color, ++
d->key};
103 }
104 d->colorHash.insert(
color, entry);
105 d->history.push_front(entry);
107 }
108}
void sigColorRemoved(int position)
void sigColorAdded(int position)
KoColor color(int index) const
void sigColorMoved(int from, int to)
static bool less(const KisUniqueColorSet::ColorEntry *lhs, const KisUniqueColorSet::ColorEntry *rhs)
References KisUniqueColorSet::ColorEntry::color, color(), d, KisUniqueColorSet::ColorEntry::key, KIS_ASSERT, KisUniqueColorSet::ColorEntry::less(), sigColorAdded(), sigColorMoved(), and sigColorRemoved().
◆ clear
| void KisUniqueColorSet::clear |
( |
| ) |
|
|
slot |
Definition at line 140 of file KisUniqueColorSet.cpp.
141{
142 for (ColorEntry *entry:
d->history) {
143 delete entry;
144 }
146 d->colorHash.clear();
149}
References d, and sigReset().
◆ color()
| KoColor KisUniqueColorSet::color |
( |
int | index | ) |
const |
Definition at line 110 of file KisUniqueColorSet.cpp.
111{
112 if (index < 0 || index >=
static_cast<int>(
d->history.size())) {
114 }
115 return d->history.at(index)->color;
116}
References d.
◆ colorList()
Definition at line 123 of file KisUniqueColorSet.cpp.
124{
126 for (
int i = 0; i < static_cast<int>(
d->history.size()); i++) {
127 colors.append(
d->history.at(i)->color);
128 }
129 return colors;
130}
References d.
◆ setColorList()
◆ sigColorAdded
| void KisUniqueColorSet::sigColorAdded |
( |
int | position | ) |
|
|
signal |
◆ sigColorMoved
| void KisUniqueColorSet::sigColorMoved |
( |
int | from, |
|
|
int | to ) |
|
signal |
◆ sigColorRemoved
| void KisUniqueColorSet::sigColorRemoved |
( |
int | position | ) |
|
|
signal |
◆ sigReset
| void KisUniqueColorSet::sigReset |
( |
| ) |
|
|
signal |
◆ size()
| int KisUniqueColorSet::size |
( |
| ) |
const |
| QScopedPointer<Private> KisUniqueColorSet::d |
|
private |
The documentation for this class was generated from the following files: