23 #include "collectionattribute.h"
30 class CollectionAttribute::Private
33 Private() : mEnabled(CalEvent::
EMPTY),
34 mStandard(CalEvent::
EMPTY),
37 QColor mBackgroundColour;
38 CalEvent::Types mEnabled;
39 CalEvent::Types mStandard;
44 CollectionAttribute::CollectionAttribute()
50 : Akonadi::Attribute(rhs),
51 d(new Private(*rhs.d))
55 CollectionAttribute::~CollectionAttribute()
64 Attribute::operator=(other);
77 return d->mEnabled &
type;
100 d->mEnabled &= ~type;
101 d->mStandard &= ~type;
108 d->mStandard &= d->mEnabled;
118 return d->mStandard &
type;
137 d->mStandard =
static_cast<CalEvent::Types
>(d->mStandard |
type);
139 d->mStandard =
static_cast<CalEvent::Types
>(d->mStandard & ~type);
153 return d->mBackgroundColour;
158 d->mBackgroundColour = c;
163 return d->mKeepFormat;
168 d->mKeepFormat = keep;
178 return "KAlarmCollection";
183 QByteArray v = QByteArray::number(d->mEnabled) +
' '
184 + QByteArray::number(d->mStandard) +
' '
185 + QByteArray(d->mKeepFormat ?
"1" :
"0") +
' '
186 + QByteArray(d->mBackgroundColour.isValid() ?
"1" :
"0");
187 if (d->mBackgroundColour.isValid())
189 + QByteArray::number(d->mBackgroundColour.red()) +
' '
190 + QByteArray::number(d->mBackgroundColour.green()) +
' '
191 + QByteArray::number(d->mBackgroundColour.blue()) +
' '
192 + QByteArray::number(d->mBackgroundColour.alpha());
204 d->mBackgroundColour = QColor();
205 d->mKeepFormat =
false;
209 const QList<QByteArray> items = data.simplified().split(
' ');
210 int count = items.count();
215 c[0] = items[index++].toInt(&ok);
218 kError() <<
"Invalid alarm types:" << c[0];
221 d->mEnabled =
static_cast<CalEvent::Types
>(c[0]);
226 c[0] = items[index++].toInt(&ok);
229 kError() <<
"Invalid alarm types:" << c[0];
233 d->mStandard =
static_cast<CalEvent::Types
>(c[0]);
238 c[0] = items[index++].toInt(&ok);
241 d->mKeepFormat = c[0];
246 c[0] = items[index++].toInt(&ok);
251 if (count < index + 4)
253 kError() <<
"Invalid number of background color elements";
257 for (
int i = 0; i < 4; ++i)
259 c[i] = items[index++].toInt(&ok);
263 d->mBackgroundColour.setRgb(c[0], c[1], c[2], c[3]);