Commit ca840100 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Astyle kdelibs

parent fb5ab431
......@@ -165,7 +165,7 @@ void AlarmText::setTodo(const KCalCore::Todo::Ptr &todo)
KDateTime due = todo->dtDue(false); // fetch the next due date
if (todo->hasStartDate() && todo->dtStart() != due) {
d->mTime = todo->allDay() ? KLocale::global()->formatDate(due.date(), KLocale::ShortDate)
: KLocale::global()->formatDateTime(due.dateTime());
: KLocale::global()->formatDateTime(due.dateTime());
}
}
}
......@@ -182,44 +182,44 @@ QString AlarmText::Private::displayText() const
{
QString text;
switch (mType) {
case Email:
// Format the email into a text alarm
setUpTranslations();
text = mFromPrefix + QLatin1Char('\t') + mFrom + QLatin1Char('\n');
text += mToPrefix + QLatin1Char('\t') + mTo + QLatin1Char('\n');
if (!mCc.isEmpty()) {
text += mCcPrefix + QLatin1Char('\t') + mCc + QLatin1Char('\n');
}
if (!mTime.isEmpty()) {
text += mDatePrefix + QLatin1Char('\t') + mTime + QLatin1Char('\n');
}
text += mSubjectPrefix + QLatin1Char('\t') + mSubject;
if (!mBody.isEmpty()) {
text += QLatin1String("\n\n");
text += mBody;
}
break;
case Todo:
// Format the todo into a text alarm
setUpTranslations();
if (!mSubject.isEmpty()) {
text = mTitlePrefix + QLatin1Char('\t') + mSubject + QLatin1Char('\n');
}
if (!mTo.isEmpty()) {
text += mLocnPrefix + QLatin1Char('\t') + mTo + QLatin1Char('\n');
}
if (!mTime.isEmpty()) {
text += mDuePrefix + QLatin1Char('\t') + mTime + QLatin1Char('\n');
}
if (!mBody.isEmpty()) {
if (!text.isEmpty()) {
text += QLatin1Char('\n');
}
text += mBody;
case Email:
// Format the email into a text alarm
setUpTranslations();
text = mFromPrefix + QLatin1Char('\t') + mFrom + QLatin1Char('\n');
text += mToPrefix + QLatin1Char('\t') + mTo + QLatin1Char('\n');
if (!mCc.isEmpty()) {
text += mCcPrefix + QLatin1Char('\t') + mCc + QLatin1Char('\n');
}
if (!mTime.isEmpty()) {
text += mDatePrefix + QLatin1Char('\t') + mTime + QLatin1Char('\n');
}
text += mSubjectPrefix + QLatin1Char('\t') + mSubject;
if (!mBody.isEmpty()) {
text += QLatin1String("\n\n");
text += mBody;
}
break;
case Todo:
// Format the todo into a text alarm
setUpTranslations();
if (!mSubject.isEmpty()) {
text = mTitlePrefix + QLatin1Char('\t') + mSubject + QLatin1Char('\n');
}
if (!mTo.isEmpty()) {
text += mLocnPrefix + QLatin1Char('\t') + mTo + QLatin1Char('\n');
}
if (!mTime.isEmpty()) {
text += mDuePrefix + QLatin1Char('\t') + mTime + QLatin1Char('\n');
}
if (!mBody.isEmpty()) {
if (!text.isEmpty()) {
text += QLatin1Char('\n');
}
break;
default:
break;
text += mBody;
}
break;
default:
break;
}
return !text.isEmpty() ? text : mBody;
}
......@@ -319,47 +319,47 @@ QString AlarmText::summary(const KAEvent &event, int maxLines, bool *truncated)
static const QRegExp localfile(QLatin1String("^file:/+"));
QString text;
switch (event.actionSubType()) {
case KAEvent::AUDIO:
text = event.audioFile();
if (localfile.indexIn(text) >= 0) {
text = text.mid(localfile.matchedLength() - 1);
}
break;
case KAEvent::EMAIL:
text = event.emailSubject();
break;
case KAEvent::COMMAND:
text = event.cleanText();
if (localfile.indexIn(text) >= 0) {
text = text.mid(localfile.matchedLength() - 1);
case KAEvent::AUDIO:
text = event.audioFile();
if (localfile.indexIn(text) >= 0) {
text = text.mid(localfile.matchedLength() - 1);
}
break;
case KAEvent::EMAIL:
text = event.emailSubject();
break;
case KAEvent::COMMAND:
text = event.cleanText();
if (localfile.indexIn(text) >= 0) {
text = text.mid(localfile.matchedLength() - 1);
}
break;
case KAEvent::FILE:
text = event.cleanText();
break;
case KAEvent::MESSAGE: {
text = event.cleanText();
// If the message is the text of an email, return its headers or just subject line
QString subject = emailHeaders(text, (maxLines <= 1));
if (!subject.isNull()) {
if (truncated) {
*truncated = true;
}
break;
case KAEvent::FILE:
text = event.cleanText();
break;
case KAEvent::MESSAGE: {
text = event.cleanText();
// If the message is the text of an email, return its headers or just subject line
QString subject = emailHeaders(text, (maxLines <= 1));
if (!subject.isNull()) {
return subject;
}
if (maxLines == 1) {
// If the message is the text of a todo, return either the
// title/description or the whole text.
subject = Private::todoTitle(text);
if (!subject.isEmpty()) {
if (truncated) {
*truncated = true;
}
return subject;
}
if (maxLines == 1) {
// If the message is the text of a todo, return either the
// title/description or the whole text.
subject = Private::todoTitle(text);
if (!subject.isEmpty()) {
if (truncated) {
*truncated = true;
}
return subject;
}
}
break;
}
break;
}
}
if (truncated) {
*truncated = false;
......@@ -427,15 +427,15 @@ QString AlarmText::fromCalendarText(const QString &text, bool &email)
const QStringList lines = text.split(QLatin1Char('\n'), QString::SkipEmptyParts);
const int maxn = lines.count();
if (maxn >= MAIL_MIN_LINES
&& lines[MAIL_FROM_LINE].startsWith(Private::mFromPrefixEn)
&& lines[MAIL_TO_LINE].startsWith(Private::mToPrefixEn)) {
&& lines[MAIL_FROM_LINE].startsWith(Private::mFromPrefixEn)
&& lines[MAIL_TO_LINE].startsWith(Private::mToPrefixEn)) {
int n = MAIL_CC_LINE;
if (lines[MAIL_CC_LINE].startsWith(Private::mCcPrefixEn)) {
++n;
}
if (maxn > n + 1
&& lines[n].startsWith(Private::mDatePrefixEn)
&& lines[n + 1].startsWith(Private::mSubjectPrefixEn)) {
&& lines[n].startsWith(Private::mDatePrefixEn)
&& lines[n + 1].startsWith(Private::mSubjectPrefixEn)) {
Private::setUpTranslations();
QString dispText;
dispText = Private::mFromPrefix + lines[MAIL_FROM_LINE].mid(Private::mFromPrefixEn.length()) + QLatin1Char('\n');
......@@ -468,15 +468,15 @@ QString AlarmText::toCalendarText(const QString &text)
const QStringList lines = text.split(QLatin1Char('\n'), QString::SkipEmptyParts);
const int maxn = lines.count();
if (maxn >= MAIL_MIN_LINES
&& lines[MAIL_FROM_LINE].startsWith(Private::mFromPrefix)
&& lines[MAIL_TO_LINE].startsWith(Private::mToPrefix)) {
&& lines[MAIL_FROM_LINE].startsWith(Private::mFromPrefix)
&& lines[MAIL_TO_LINE].startsWith(Private::mToPrefix)) {
int n = MAIL_CC_LINE;
if (lines[MAIL_CC_LINE].startsWith(Private::mCcPrefix)) {
++n;
}
if (maxn > n + 1
&& lines[n].startsWith(Private::mDatePrefix)
&& lines[n + 1].startsWith(Private::mSubjectPrefix)) {
&& lines[n].startsWith(Private::mDatePrefix)
&& lines[n + 1].startsWith(Private::mSubjectPrefix)) {
// Format the email into a text alarm
QString calText;
calText = Private::mFromPrefixEn + lines[MAIL_FROM_LINE].mid(Private::mFromPrefix.length()) + QLatin1Char('\n');
......@@ -537,15 +537,15 @@ int AlarmText::Private::emailHeaderCount(const QStringList &lines)
setUpTranslations();
const int maxn = lines.count();
if (maxn >= MAIL_MIN_LINES
&& lines[MAIL_FROM_LINE].startsWith(mFromPrefix)
&& lines[MAIL_TO_LINE].startsWith(mToPrefix)) {
&& lines[MAIL_FROM_LINE].startsWith(mFromPrefix)
&& lines[MAIL_TO_LINE].startsWith(mToPrefix)) {
int n = MAIL_CC_LINE;
if (lines[MAIL_CC_LINE].startsWith(mCcPrefix)) {
++n;
}
if (maxn > n + 1
&& lines[n].startsWith(mDatePrefix)
&& lines[n + 1].startsWith(mSubjectPrefix)) {
&& lines[n].startsWith(mDatePrefix)
&& lines[n + 1].startsWith(mSubjectPrefix)) {
return n + 2;
}
}
......
......@@ -31,9 +31,9 @@ class CollectionAttribute::Private
{
public:
Private()
: mEnabled(CalEvent::EMPTY),
mStandard(CalEvent::EMPTY),
mKeepFormat(false) {}
: mEnabled(CalEvent::EMPTY),
mStandard(CalEvent::EMPTY),
mKeepFormat(false) {}
QColor mBackgroundColour; // background color for collection and its alarms
CalEvent::Types mEnabled; // which alarm types the collection is enabled for
......@@ -84,12 +84,12 @@ CalEvent::Types CollectionAttribute::enabled() const
void CollectionAttribute::setEnabled(CalEvent::Type type, bool enabled)
{
switch (type) {
case CalEvent::ACTIVE:
case CalEvent::ARCHIVED:
case CalEvent::TEMPLATE:
break;
default:
return;
case CalEvent::ACTIVE:
case CalEvent::ARCHIVED:
case CalEvent::TEMPLATE:
break;
default:
return;
}
if (enabled) {
d->mEnabled |= type;
......@@ -108,12 +108,12 @@ void CollectionAttribute::setEnabled(CalEvent::Types types)
bool CollectionAttribute::isStandard(CalEvent::Type type) const
{
switch (type) {
case CalEvent::ACTIVE:
case CalEvent::ARCHIVED:
case CalEvent::TEMPLATE:
return d->mStandard & type;
default:
return false;
case CalEvent::ACTIVE:
case CalEvent::ARCHIVED:
case CalEvent::TEMPLATE:
return d->mStandard & type;
default:
return false;
}
}
......@@ -125,17 +125,17 @@ CalEvent::Types CollectionAttribute::standard() const
void CollectionAttribute::setStandard(CalEvent::Type type, bool standard)
{
switch (type) {
case CalEvent::ACTIVE:
case CalEvent::ARCHIVED:
case CalEvent::TEMPLATE:
if (standard) {
d->mStandard = static_cast<CalEvent::Types>(d->mStandard | type);
} else {
d->mStandard = static_cast<CalEvent::Types>(d->mStandard & ~type);
}
break;
default:
break;
case CalEvent::ACTIVE:
case CalEvent::ARCHIVED:
case CalEvent::TEMPLATE:
if (standard) {
d->mStandard = static_cast<CalEvent::Types>(d->mStandard | type);
} else {
d->mStandard = static_cast<CalEvent::Types>(d->mStandard & ~type);
}
break;
default:
break;
}
}
......@@ -177,15 +177,15 @@ QByteArray CollectionAttribute::name()
QByteArray CollectionAttribute::serialized() const
{
QByteArray v = QByteArray::number(d->mEnabled) + ' '
+ QByteArray::number(d->mStandard) + ' '
+ QByteArray(d->mKeepFormat ? "1" : "0") + ' '
+ QByteArray(d->mBackgroundColour.isValid() ? "1" : "0");
+ QByteArray::number(d->mStandard) + ' '
+ QByteArray(d->mKeepFormat ? "1" : "0") + ' '
+ QByteArray(d->mBackgroundColour.isValid() ? "1" : "0");
if (d->mBackgroundColour.isValid())
v += ' '
+ QByteArray::number(d->mBackgroundColour.red()) + ' '
+ QByteArray::number(d->mBackgroundColour.green()) + ' '
+ QByteArray::number(d->mBackgroundColour.blue()) + ' '
+ QByteArray::number(d->mBackgroundColour.alpha());
+ QByteArray::number(d->mBackgroundColour.red()) + ' '
+ QByteArray::number(d->mBackgroundColour.green()) + ' '
+ QByteArray::number(d->mBackgroundColour.blue()) + ' '
+ QByteArray::number(d->mBackgroundColour.alpha());
qCDebug(KALARMCAL_LOG) << v;
return v;
}
......
......@@ -103,7 +103,7 @@ QByteArray CompatibilityAttribute::name()
QByteArray CompatibilityAttribute::serialized() const
{
const QByteArray v = QByteArray::number(d->mCompatibility) + ' '
+ QByteArray::number(d->mVersion);
+ QByteArray::number(d->mVersion);
qCDebug(KALARMCAL_LOG) << v;
return v;
}
......
......@@ -100,16 +100,16 @@ void EventAttribute::deserialize(const QByteArray &data)
int c[1];
const QList<QByteArray> items = data.simplified().split(' ');
switch (items.count()) {
case 1:
c[0] = items[0].toInt(&ok);
if (!ok || (c[0] & ~(KAEvent::CMD_ERROR | KAEvent::CMD_ERROR_PRE | KAEvent::CMD_ERROR_POST))) {
return;
}
d->mCommandError = static_cast<KAEvent::CmdErrType>(c[0]);
break;
default:
break;
case 1:
c[0] = items[0].toInt(&ok);
if (!ok || (c[0] & ~(KAEvent::CMD_ERROR | KAEvent::CMD_ERROR_PRE | KAEvent::CMD_ERROR_POST))) {
return;
}
d->mCommandError = static_cast<KAEvent::CmdErrType>(c[0]);
break;
default:
break;
}
}
......
......@@ -59,7 +59,7 @@ uint identityUoid(const QString &identityUoidOrName)
if (!ok || identityManager()->identityForUoid(id).isNull()) {
identityManager(); // fetch it if not already done
for (KIdentityManagement::IdentityManager::ConstIterator it = mIdentityManager->begin();
it != mIdentityManager->end(); ++it) {
it != mIdentityManager->end(); ++it) {
if ((*it).identityName() == identityUoidOrName) {
id = (*it).uoid();
break;
......
......@@ -295,12 +295,12 @@ QString uid(const QString &id, Type status)
if (status != oldType && i > 0) {
QString part;
switch (status) {
case ARCHIVED: part = staticStrings->ARCHIVED_UID; break;
case DISPLAYING: part = staticStrings->DISPLAYING_UID; break;
case ACTIVE:
case TEMPLATE:
case EMPTY:
default: part = QLatin1String("-"); break;
case ARCHIVED: part = staticStrings->ARCHIVED_UID; break;
case DISPLAYING: part = staticStrings->DISPLAYING_UID; break;
case ACTIVE:
case TEMPLATE:
case EMPTY:
default: part = QLatin1String("-"); break;
}
result.replace(i, len, part);
}
......@@ -387,13 +387,13 @@ void setStatus(const Event::Ptr &event, Type status, const QString &param)
}
QString text;
switch (status) {
case ACTIVE: text = staticStrings->ACTIVE_STATUS; break;
case TEMPLATE: text = staticStrings->TEMPLATE_STATUS; break;
case ARCHIVED: text = staticStrings->ARCHIVED_STATUS; break;
case DISPLAYING: text = staticStrings->DISPLAYING_STATUS; break;
default:
event->removeCustomProperty(KACalendar::APPNAME, staticStrings->STATUS_PROPERTY);
return;
case ACTIVE: text = staticStrings->ACTIVE_STATUS; break;
case TEMPLATE: text = staticStrings->TEMPLATE_STATUS; break;
case ARCHIVED: text = staticStrings->ARCHIVED_STATUS; break;
case DISPLAYING: text = staticStrings->DISPLAYING_STATUS; break;
default:
event->removeCustomProperty(KACalendar::APPNAME, staticStrings->STATUS_PROPERTY);
return;
}
if (!param.isEmpty()) {
text += QLatin1Char(';') + param;
......@@ -435,10 +435,10 @@ Types types(const QStringList &mimeTypes)
QString mimeType(Type type)
{
switch (type) {
case ACTIVE: return MIME_ACTIVE;
case ARCHIVED: return MIME_ARCHIVED;
case TEMPLATE: return MIME_TEMPLATE;
default: return QString();
case ACTIVE: return MIME_ACTIVE;
case ARCHIVED: return MIME_ARCHIVED;
case TEMPLATE: return MIME_TEMPLATE;
default: return QString();
}
}
......
This diff is collapsed.
......@@ -20,4 +20,3 @@
#include "kalarmcal_debug.h"
Q_LOGGING_CATEGORY(KALARMCAL_LOG, "log_kalarmcal")
......@@ -23,5 +23,5 @@
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(KALARMCAL_LOG)
#endif
#endif
This diff is collapsed.
......@@ -146,15 +146,15 @@ int Repetition::intervalSeconds() const
int Repetition::nextRepeatCount(const KDateTime &from, const KDateTime &preDateTime) const
{
return d->mInterval.isDaily()
? from.daysTo(preDateTime) / d->mInterval.asDays() + 1
: static_cast<int>(from.secsTo_long(preDateTime) / d->mInterval.asSeconds()) + 1;
? from.daysTo(preDateTime) / d->mInterval.asDays() + 1
: static_cast<int>(from.secsTo_long(preDateTime) / d->mInterval.asSeconds()) + 1;
}
int Repetition::previousRepeatCount(const KDateTime &from, const KDateTime &afterDateTime) const
{
return d->mInterval.isDaily()
? from.daysTo(afterDateTime.addSecs(-1)) / d->mInterval.asDays()
: static_cast<int>((from.secsTo_long(afterDateTime) - 1) / d->mInterval.asSeconds());
? from.daysTo(afterDateTime.addSecs(-1)) / d->mInterval.asDays()
: static_cast<int>((from.secsTo_long(afterDateTime) - 1) / d->mInterval.asSeconds());
}
} // namespace KAlarmCal
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment