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

#include <KisSwatch.h>

Public Member Functions

KoColor color () const
 
QString id () const
 
bool isValid () const
 
 KisSwatch ()=default
 
 KisSwatch (const KoColor &color, const QString &name=QString())
 
QString name () const
 
bool operator== (const KisSwatch &rhs) const
 
void setColor (const KoColor &color)
 
void setId (const QString &id)
 
void setName (const QString &name)
 
void setSpotColor (bool spotColor)
 
bool spotColor () const
 
void writeToStream (QDataStream &stream, const QString &groupName, int originalRow, int originalColumn)
 

Static Public Member Functions

static KisSwatch fromByteArray (QByteArray &data)
 
static KisSwatch fromByteArray (QByteArray &data, QString &groupName, int &originalRow, int &originalColumn)
 

Private Attributes

KoColor m_color
 
QString m_id
 
QString m_name
 
bool m_spotColor {false}
 
bool m_valid {false}
 

Detailed Description

Definition at line 17 of file KisSwatch.h.

Constructor & Destructor Documentation

◆ KisSwatch() [1/2]

KisSwatch::KisSwatch ( )
default

◆ KisSwatch() [2/2]

KisSwatch::KisSwatch ( const KoColor & color,
const QString & name = QString() )

Definition at line 14 of file KisSwatch.cpp.

15 : m_color(color)
16 , m_name(name)
17 , m_valid(true)
18{ }
QString m_name
Definition KisSwatch.h:49
KoColor color() const
Definition KisSwatch.h:30
QString name() const
Definition KisSwatch.h:24
bool m_valid
Definition KisSwatch.h:52
KoColor m_color
Definition KisSwatch.h:48

Member Function Documentation

◆ color()

KoColor KisSwatch::color ( ) const
inline

Definition at line 30 of file KisSwatch.h.

30{ return m_color; }

◆ fromByteArray() [1/2]

KisSwatch KisSwatch::fromByteArray ( QByteArray & data)
static

Definition at line 88 of file KisSwatch.cpp.

89{
90 QString s;
91 int x, y;
92 return fromByteArray(data, s, y, x);
93}
static KisSwatch fromByteArray(QByteArray &data, QString &groupName, int &originalRow, int &originalColumn)
Definition KisSwatch.cpp:57

References fromByteArray().

◆ fromByteArray() [2/2]

KisSwatch KisSwatch::fromByteArray ( QByteArray & data,
QString & groupName,
int & originalRow,
int & originalColumn )
static

Definition at line 57 of file KisSwatch.cpp.

58{
59 QDataStream stream(&data, QIODevice::ReadOnly);
60 KisSwatch s;
61 QString name, id;
62 bool spotColor;
63 QString colorXml;
64
65 while (!stream.atEnd()) {
66 stream >> name >> id >> spotColor
67 >> originalRow >> originalColumn
68 >> oldGroupName
69 >> colorXml;
70
71 s.setName(name);
72 s.setId(id);
74
75 QDomDocument doc;
76 doc.setContent(colorXml);
77 QDomElement e = doc.documentElement();
78 QDomElement c = e.firstChildElement();
79 if (!c.isNull()) {
80 QString colorDepthId = c.attribute("bitdepth", Integer8BitsColorDepthID.id());
81 s.setColor(KoColor::fromXML(c, colorDepthId));
82 }
83 }
84
85 return s;
86}
const KoID Integer8BitsColorDepthID("U8", ki18n("8-bit integer/channel"))
void setSpotColor(bool spotColor)
Definition KisSwatch.cpp:38
void setColor(const KoColor &color)
Definition KisSwatch.cpp:32
bool spotColor() const
Definition KisSwatch.h:33
void setId(const QString &id)
Definition KisSwatch.cpp:26
void setName(const QString &name)
Definition KisSwatch.cpp:20
QString id() const
Definition KisSwatch.h:27
static KoColor fromXML(const QDomElement &elt, const QString &channelDepthId)
Definition KoColor.cpp:350
QString id() const
Definition KoID.cpp:63

References KoColor::fromXML(), KoID::id(), id(), Integer8BitsColorDepthID, name(), setColor(), setId(), setName(), setSpotColor(), and spotColor().

◆ id()

QString KisSwatch::id ( ) const
inline

Definition at line 27 of file KisSwatch.h.

27{ return m_id; }
QString m_id
Definition KisSwatch.h:50

◆ isValid()

bool KisSwatch::isValid ( ) const
inline

Definition at line 36 of file KisSwatch.h.

36{ return m_valid; }

◆ name()

QString KisSwatch::name ( ) const
inline

Definition at line 24 of file KisSwatch.h.

24{ return m_name; }

◆ operator==()

bool KisSwatch::operator== ( const KisSwatch & rhs) const
inline

Definition at line 43 of file KisSwatch.h.

43 {
44 return m_color == rhs.m_color && m_name == rhs.m_name;
45 }

References m_color, and m_name.

◆ setColor()

void KisSwatch::setColor ( const KoColor & color)

Definition at line 32 of file KisSwatch.cpp.

33{
34 m_color = color;
35 m_valid = true;
36}

References color(), m_color, and m_valid.

◆ setId()

void KisSwatch::setId ( const QString & id)

Definition at line 26 of file KisSwatch.cpp.

27{
28 m_id = id;
29 m_valid = true;
30}

References id(), m_id, and m_valid.

◆ setName()

void KisSwatch::setName ( const QString & name)

Definition at line 20 of file KisSwatch.cpp.

21{
22 m_name = name;
23 m_valid = true;
24}

References m_name, m_valid, and name().

◆ setSpotColor()

void KisSwatch::setSpotColor ( bool spotColor)

Definition at line 38 of file KisSwatch.cpp.

39{
41 m_valid = true;
42}
bool m_spotColor
Definition KisSwatch.h:51

References m_spotColor, m_valid, and spotColor().

◆ spotColor()

bool KisSwatch::spotColor ( ) const
inline

Definition at line 33 of file KisSwatch.h.

33{ return m_spotColor; }

◆ writeToStream()

void KisSwatch::writeToStream ( QDataStream & stream,
const QString & groupName,
int originalRow,
int originalColumn )

Definition at line 44 of file KisSwatch.cpp.

45{
46 QDomDocument doc;
47 QDomElement root = doc.createElement("Color");
48 root.setAttribute("bitdepth", color().colorSpace()->colorDepthId().id());
49 doc.appendChild(root);
50 color().toXML(doc, root);
51
52 stream << name() << id() << spotColor()
53 << originalRow << originalColumn
54 << groupName << doc.toString();
55}
void toXML(QDomDocument &doc, QDomElement &colorElt) const
Definition KoColor.cpp:304

References color(), id(), name(), spotColor(), and KoColor::toXML().

Member Data Documentation

◆ m_color

KoColor KisSwatch::m_color
private

Definition at line 48 of file KisSwatch.h.

◆ m_id

QString KisSwatch::m_id
private

Definition at line 50 of file KisSwatch.h.

◆ m_name

QString KisSwatch::m_name
private

Definition at line 49 of file KisSwatch.h.

◆ m_spotColor

bool KisSwatch::m_spotColor {false}
private

Definition at line 51 of file KisSwatch.h.

51{false};

◆ m_valid

bool KisSwatch::m_valid {false}
private

Definition at line 52 of file KisSwatch.h.

52{false};

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