8#include "expirecollectionattribute.h"
14ExpireCollectionAttribute::ExpireCollectionAttribute() =
default;
16QByteArray ExpireCollectionAttribute::type()
const
18 static const QByteArray sType(
"expirationcollectionattribute");
22ExpireCollectionAttribute *ExpireCollectionAttribute::clone()
const
24 auto expireAttr =
new ExpireCollectionAttribute();
25 expireAttr->setAutoExpire(mExpireMessages);
26 expireAttr->setUnreadExpireAge(mUnreadExpireAge);
27 expireAttr->setUnreadExpireUnits(mUnreadExpireUnits);
28 expireAttr->setReadExpireAge(mReadExpireAge);
29 expireAttr->setReadExpireUnits(mReadExpireUnits);
30 expireAttr->setExpireAction(mExpireAction);
31 expireAttr->setExpireToFolderId(mExpireToFolderId);
32 expireAttr->setExpireMessagesWithValidDate(mExpireMessagesWithValidDate);
36void ExpireCollectionAttribute::setAutoExpire(
bool enabled)
38 mExpireMessages = enabled;
41bool ExpireCollectionAttribute::isAutoExpire()
const
43 return mExpireMessages;
46void ExpireCollectionAttribute::setUnreadExpireAge(
int age)
48 if (age >= 0 && age != mUnreadExpireAge) {
49 mUnreadExpireAge = age;
53int ExpireCollectionAttribute::unreadExpireAge()
const
55 return mUnreadExpireAge;
58void ExpireCollectionAttribute::setUnreadExpireUnits(ExpireUnits units)
60 if (units >= ExpireNever && units < ExpireMaxUnits) {
61 mUnreadExpireUnits = units;
65void ExpireCollectionAttribute::setReadExpireAge(
int age)
67 if (age >= 0 && age != mReadExpireAge) {
72int ExpireCollectionAttribute::readExpireAge()
const
74 return mReadExpireAge;
77void ExpireCollectionAttribute::setReadExpireUnits(ExpireUnits units)
79 if (units >= ExpireNever && units <= ExpireMaxUnits) {
80 mReadExpireUnits = units;
84void ExpireCollectionAttribute::setExpireAction(ExpireAction a)
89ExpireCollectionAttribute::ExpireAction ExpireCollectionAttribute::expireAction()
const
96 mExpireToFolderId = id;
101 return mExpireToFolderId;
104ExpireCollectionAttribute::ExpireUnits ExpireCollectionAttribute::unreadExpireUnits()
const
106 return mUnreadExpireUnits;
109ExpireCollectionAttribute::ExpireUnits ExpireCollectionAttribute::readExpireUnits()
const
111 return mReadExpireUnits;
114bool ExpireCollectionAttribute::operator==(
const ExpireCollectionAttribute &other)
const
116 return (mExpireMessages == other.isAutoExpire()) && (mUnreadExpireAge == other.unreadExpireAge()) && (mReadExpireAge == other.readExpireAge())
117 && (mUnreadExpireUnits == other.unreadExpireUnits()) && (mReadExpireUnits == other.readExpireUnits()) && (mExpireAction == other.expireAction())
118 && (mExpireToFolderId == other.expireToFolderId()) && (mExpireMessagesWithValidDate == other.expireMessagesWithValidDate());
121int ExpireCollectionAttribute::daysToExpire(
int number, ExpireCollectionAttribute::ExpireUnits units)
124 case ExpireCollectionAttribute::ExpireDays:
126 case ExpireCollectionAttribute::ExpireWeeks:
128 case ExpireCollectionAttribute::ExpireMonths:
137bool ExpireCollectionAttribute::expireMessagesWithValidDate()
const
139 return mExpireMessagesWithValidDate;
142void ExpireCollectionAttribute::setExpireMessagesWithValidDate(
bool expireMessagesWithValidDate)
144 mExpireMessagesWithValidDate = expireMessagesWithValidDate;
147void ExpireCollectionAttribute::daysToExpire(
int &unreadDays,
int &readDays)
const
149 unreadDays = ExpireCollectionAttribute::daysToExpire(unreadExpireAge(), unreadExpireUnits());
150 readDays = ExpireCollectionAttribute::daysToExpire(readExpireAge(), readExpireUnits());
153QByteArray ExpireCollectionAttribute::serialized()
const
158 s << mExpireToFolderId;
159 s << static_cast<int>(mExpireAction);
160 s << static_cast<int>(mReadExpireUnits);
162 s << static_cast<int>(mUnreadExpireUnits);
163 s << mUnreadExpireAge;
164 s << mExpireMessages;
165 s << mExpireMessagesWithValidDate;
170void ExpireCollectionAttribute::deserialize(
const QByteArray &data)
173 s >> mExpireToFolderId;
176 mExpireAction =
static_cast<ExpireCollectionAttribute::ExpireAction
>(action);
179 mReadExpireUnits =
static_cast<ExpireCollectionAttribute::ExpireUnits
>(valUnitRead);
183 mUnreadExpireUnits =
static_cast<ExpireCollectionAttribute::ExpireUnits
>(valUnitUnread);
184 s >> mUnreadExpireAge;
185 s >> mExpireMessages;
186 s >> mExpireMessagesWithValidDate;
191 d <<
" mExpireMessages " << t.isAutoExpire();
192 d <<
" mUnreadExpireAge " << t.unreadExpireAge();
193 d <<
" mReadExpireAge " << t.readExpireAge();
194 d <<
" mUnreadExpireUnits " << t.unreadExpireUnits();
195 d <<
" mReadExpireUnits " << t.readExpireUnits();
196 d <<
" mExpireAction " << t.expireAction();
197 d <<
" mExpireToFolderId " << t.expireToFolderId();
198 d <<
" mExpireMessagesWithValidDate " << t.expireMessagesWithValidDate();
QDebug operator<<(QDebug dbg, const DcrawInfoContainer &c)
KIOCORE_EXPORT QString number(KIO::filesize_t size)