Commit 71e8612e authored by David Jarvie's avatar David Jarvie
Browse files

Clarifications, formatting

parent c46ae6eb
......@@ -31,6 +31,7 @@ using namespace KCalCore;
#include <AkonadiCore/collection.h>
#include <KHolidays/HolidayRegion>
using namespace KHolidays;
#include <kconfiggroup.h>
#include <QtTest>
......@@ -398,8 +399,8 @@ void KAEventTest::flags()
QVERIFY(!event.emailBcc());
}
{
const KAEvent::Flags flags(KAEvent::CONFIRM_ACK | KAEvent::SPEAK);
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags | KAEvent::EXCL_HOLIDAYS);
const KAEvent::Flags flags(KAEvent::CONFIRM_ACK | KAEvent::SPEAK | KAEvent::EXCL_HOLIDAYS);
KAEvent event(dt, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, flags);
QVERIFY(!event.startDateTime().isDateOnly());
QCOMPARE(event.flags(), flags);
QVERIFY(!event.repeatAtLogin());
......@@ -409,7 +410,7 @@ void KAEventTest::flags()
QVERIFY(event.confirmAck());
QVERIFY(event.speak());
QVERIFY(!event.autoClose());
QVERIFY(!event.holidaysExcluded());
QVERIFY(event.holidaysExcluded());
QVERIFY(!event.repeatSound());
QVERIFY(!event.copyToKOrganizer());
QVERIFY(!event.workTimeOnly());
......
......@@ -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;
}
}
......
......@@ -124,7 +124,7 @@ void CompatibilityAttribute::deserialize(const QByteArray &data)
// 0: calendar format compatibility
const int c = items[index++].toInt(&ok);
const KACalendar::Compat AllCompat(KACalendar::Current | KACalendar::Converted | KACalendar::Convertible | KACalendar::Incompatible | KACalendar::Unknown);
if (!ok || (c & AllCompat) != c) {
if (!ok || (c & static_cast<int>(AllCompat)) != c) {
qCritical() << "Invalid compatibility:" << c;
return;
}
......
......@@ -415,7 +415,7 @@ Type type(const QString &mimeType)
Types types(const QStringList &mimeTypes)
{
Types types = nullptr;
Types types = 0;
for (const QString &type : mimeTypes) {
if (type == MIME_ACTIVE) {
types |= ACTIVE;
......
......@@ -1670,6 +1670,8 @@ QString KADateTime::toString(const QString &format) const
case LocalZone:
tz = QTimeZone::systemTimeZone();
break;
default:
break;
}
// fall through to OffsetFromUTC
case OffsetFromUTC: {
......
This diff is collapsed.
......@@ -216,7 +216,8 @@ public:
EXEC_IN_XTERM = 0x800, //!< execute the command in a terminal window
SPEAK = 0x1000, //!< speak the message when the alarm is displayed
COPY_KORGANIZER = 0x2000, //!< KOrganizer should hold a copy of the event
EXCL_HOLIDAYS = 0x4000, //!< don't trigger the alarm on holidays
EXCL_HOLIDAYS = 0x4000, //!< don't trigger the alarm on holidays. Only valid
//!< if a holiday region has been set by setHolidays().
WORK_TIME_ONLY = 0x8000, //!< trigger the alarm only during working hours
DISPLAY_COMMAND = 0x10000, //!< display command output in the alarm window
REMINDER_ONCE = 0x20000 //!< only trigger the reminder on the first recurrence
......
......@@ -136,7 +136,7 @@ KARecurrence &KARecurrence::operator=(const KARecurrence &r)
bool KARecurrence::operator==(const KARecurrence &r) const
{
return d->mRecurrence == r.d->mRecurrence
&& d->mFeb29Type == r.d->mFeb29Type;
&& d->mFeb29Type == r.d->mFeb29Type;
}
KARecurrence::Feb29Type KARecurrence::feb29Type() const
......@@ -258,10 +258,10 @@ bool KARecurrence::Private::init(RecurrenceRule::PeriodType recurType, int freq,
}
KADateTime startdt = start;
if (recurType == RecurrenceRule::rYearly
&& (feb29Type == Feb29_Feb28 || feb29Type == Feb29_Mar1)) {
&& (feb29Type == Feb29_Feb28 || feb29Type == Feb29_Mar1)) {
int year = startdt.date().year();
if (!QDate::isLeapYear(year)
&& startdt.date().dayOfYear() == (feb29Type == Feb29_Mar1 ? 60 : 59)) {
&& startdt.date().dayOfYear() == (feb29Type == Feb29_Mar1 ? 60 : 59)) {
/* The event start date is February 28th or March 1st, but it
* is a recurrence on February 29th (recurring on February 28th
* or March 1st in non-leap years). Adjust the start date to
......@@ -361,8 +361,8 @@ void KARecurrence::Private::fix()
// This is the second rule.
// Ensure that it can be combined with the first one.
if (days[0] != 29
|| rrule->frequency() != rrules[0]->frequency()
|| rrule->startDt() != rrules[0]->startDt()) {
|| rrule->frequency() != rrules[0]->frequency()
|| rrule->startDt() != rrules[0]->startDt()) {
break;
}
}
......@@ -383,8 +383,8 @@ void KARecurrence::Private::fix()
// This is the second rule.
// Ensure that it can be combined with the first one.
if (day == days[0] || (day == -1 && days[0] == 60)
|| rrule->frequency() != rrules[0]->frequency()
|| rrule->startDt() != rrules[0]->startDt()) {
|| rrule->frequency() != rrules[0]->frequency()
|| rrule->startDt() != rrules[0]->startDt()) {
break;
}
}
......@@ -960,7 +960,7 @@ int KARecurrence::Private::combineDurations(const RecurrenceRule *rrule1, const
const RecurrenceRule *rr1; // earlier end date
const RecurrenceRule *rr2; // later end date
if (end2.isValid()
&& (!end1.isValid() || end1.date() > end2.date())) {
&& (!end1.isValid() || end1.date() > end2.date())) {
// Swap the two rules to make rr1 have the earlier end date
rr1 = rrule2;
rr2 = rrule1;
......@@ -1298,14 +1298,14 @@ KARecurrence::Type KARecurrence::type(const RecurrenceRule *rrule)
bool KARecurrence::dailyType(const RecurrenceRule *rrule)
{
if (rrule->recurrenceType() != RecurrenceRule::rDaily
|| !rrule->bySeconds().isEmpty()
|| !rrule->byMinutes().isEmpty()
|| !rrule->byHours().isEmpty()
|| !rrule->byWeekNumbers().isEmpty()
|| !rrule->byMonthDays().isEmpty()
|| !rrule->byMonths().isEmpty()
|| !rrule->bySetPos().isEmpty()
|| !rrule->byYearDays().isEmpty()) {
|| !rrule->bySeconds().isEmpty()
|| !rrule->byMinutes().isEmpty()
|| !rrule->byHours().isEmpty()
|| !rrule->byWeekNumbers().isEmpty()
|| !rrule->byMonthDays().isEmpty()
|| !rrule->byMonths().isEmpty()
|| !rrule->bySetPos().isEmpty()
|| !rrule->byYearDays().isEmpty()) {
return false;
}
const QList<RecurrenceRule::WDayPos> days = rrule->byDays();
......
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