Commit 13f86a94 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

run git clang-format

parent 776b4b69
......@@ -16,7 +16,7 @@
#include <QTest>
#include <QTimeZone>
QTEST_MAIN(DndFactoryTest) // clipboard() needs GUI
QTEST_MAIN(DndFactoryTest) // clipboard() needs GUI
using namespace KCalendarCore;
using namespace KCalUtils;
......
......@@ -9,14 +9,14 @@
#include "testincidenceformatter.h"
#include "test_config.h"
#include "incidenceformatter.h"
#include "grantleetemplatemanager_p.h"
#include "incidenceformatter.h"
#include <KCalendarCore/Event>
#include <KCalendarCore/FreeBusy>
#include <KCalendarCore/ICalFormat>
#include <KCalendarCore/Todo>
#include <KCalendarCore/Journal>
#include <KCalendarCore/FreeBusy>
#include <KCalendarCore/Todo>
#include <KLocalizedString>
......@@ -73,87 +73,75 @@ void IncidenceFormatterTest::testRecurrenceString()
QTime tim(12, 0, 0);
QDateTime kdt(day, tim, Qt::UTC);
e1->setDtStart(kdt);
e1->setDtEnd(kdt.addSecs(60 * 60)); // 1hr event
e1->setDtEnd(kdt.addSecs(60 * 60)); // 1hr event
QCOMPARE(IncidenceFormatter::recurrenceString(e1), i18n("No recurrence"));
Recurrence *r1 = e1->recurrence();
r1->setDaily(1);
r1->setEndDateTime(kdt.addDays(5)); // ends 5 days from now
r1->setEndDateTime(kdt.addDays(5)); // ends 5 days from now
QString endDateStr = QLocale().toString(kdt.addDays(5).toLocalTime(), QLocale::ShortFormat);
QCOMPARE(IncidenceFormatter::recurrenceString(e1),
i18n("Recurs daily until %1", endDateStr));
QCOMPARE(IncidenceFormatter::recurrenceString(e1), i18n("Recurs daily until %1", endDateStr));
r1->setFrequency(2);
QCOMPARE(IncidenceFormatter::recurrenceString(e1),
i18n("Recurs every 2 days until %1", endDateStr));
QCOMPARE(IncidenceFormatter::recurrenceString(e1), i18n("Recurs every 2 days until %1", endDateStr));
r1->addExDate(kdt.addDays(1).date());
QString exDateStr = QLocale().toString(kdt.addDays(1).date(), QLocale::ShortFormat);
QCOMPARE(IncidenceFormatter::recurrenceString(e1),
i18n("Recurs every 2 days until %1 (excluding %2)", endDateStr, exDateStr));
QCOMPARE(IncidenceFormatter::recurrenceString(e1), i18n("Recurs every 2 days until %1 (excluding %2)", endDateStr, exDateStr));
r1->addExDate(kdt.addDays(3).date());
QString exDateStr2 = QLocale().toString(kdt.addDays(3).date(), QLocale::ShortFormat);
QCOMPARE(IncidenceFormatter::recurrenceString(e1),
i18n("Recurs every 2 days until %1 (excluding %2,%3)", endDateStr, exDateStr, exDateStr2));
QCOMPARE(IncidenceFormatter::recurrenceString(e1), i18n("Recurs every 2 days until %1 (excluding %2,%3)", endDateStr, exDateStr, exDateStr2));
// TEST: An daily recurrence, with datetime exclusions //
Event::Ptr e2 = Event::Ptr(new Event());
e2->setDtStart(kdt);
e2->setDtEnd(kdt.addSecs(60 * 60)); // 1hr event
e2->setDtEnd(kdt.addSecs(60 * 60)); // 1hr event
Recurrence *r2 = e2->recurrence();
r2->setDaily(1);
r2->setEndDate(kdt.addDays(5).date()); // ends 5 days from now
QCOMPARE(IncidenceFormatter::recurrenceString(e2),
i18n("Recurs daily until %1", endDateStr));
r2->setEndDate(kdt.addDays(5).date()); // ends 5 days from now
QCOMPARE(IncidenceFormatter::recurrenceString(e2), i18n("Recurs daily until %1", endDateStr));
r2->setFrequency(2);
QCOMPARE(IncidenceFormatter::recurrenceString(e2),
i18n("Recurs every 2 days until %1", endDateStr));
QCOMPARE(IncidenceFormatter::recurrenceString(e2), i18n("Recurs every 2 days until %1", endDateStr));
r2->addExDateTime(kdt.addDays(1));
QCOMPARE(IncidenceFormatter::recurrenceString(e2),
i18n("Recurs every 2 days until %1 (excluding %2)", endDateStr, exDateStr));
QCOMPARE(IncidenceFormatter::recurrenceString(e2), i18n("Recurs every 2 days until %1 (excluding %2)", endDateStr, exDateStr));
r2->addExDate(kdt.addDays(3).date());
QCOMPARE(IncidenceFormatter::recurrenceString(e2),
i18n("Recurs every 2 days until %1 (excluding %2,%3)", endDateStr, exDateStr, exDateStr2));
QCOMPARE(IncidenceFormatter::recurrenceString(e2), i18n("Recurs every 2 days until %1 (excluding %2,%3)", endDateStr, exDateStr, exDateStr2));
// TEST: An hourly recurrence, with exclusions //
Event::Ptr e3 = Event::Ptr(new Event());
e3->setDtStart(kdt);
e3->setDtEnd(kdt.addSecs(60 * 60)); // 1hr event
e3->setDtEnd(kdt.addSecs(60 * 60)); // 1hr event
Recurrence *r3 = e3->recurrence();
r3->setHourly(1);
r3->setEndDateTime(kdt.addSecs(5 * 60 * 60)); // ends 5 hrs from now
r3->setEndDateTime(kdt.addSecs(5 * 60 * 60)); // ends 5 hrs from now
endDateStr = QLocale().toString(r3->endDateTime().toLocalTime(), QLocale::ShortFormat);
QCOMPARE(IncidenceFormatter::recurrenceString(e3),
i18n("Recurs hourly until %1", endDateStr));
QCOMPARE(IncidenceFormatter::recurrenceString(e3), i18n("Recurs hourly until %1", endDateStr));
r3->setFrequency(2);
QCOMPARE(IncidenceFormatter::recurrenceString(e3),
i18n("Recurs every 2 hours until %1", endDateStr));
QCOMPARE(IncidenceFormatter::recurrenceString(e3), i18n("Recurs every 2 hours until %1", endDateStr));
r3->addExDateTime(kdt.addSecs(1 * 60 * 60));
QString hourStr = QLocale().toString(QTime(13, 0), QLocale::ShortFormat);
QCOMPARE(IncidenceFormatter::recurrenceString(e3),
i18n("Recurs every 2 hours until %1 (excluding %2)", endDateStr, hourStr));
QCOMPARE(IncidenceFormatter::recurrenceString(e3), i18n("Recurs every 2 hours until %1 (excluding %2)", endDateStr, hourStr));
r3->addExDateTime(kdt.addSecs(3 * 60 * 60));
QString hourStr2 = QLocale().toString(QTime(15, 0), QLocale::ShortFormat);
QCOMPARE(IncidenceFormatter::recurrenceString(e3),
i18n("Recurs every 2 hours until %1 (excluding %2,%3)", endDateStr, hourStr, hourStr2));
QCOMPARE(IncidenceFormatter::recurrenceString(e3), i18n("Recurs every 2 hours until %1 (excluding %2,%3)", endDateStr, hourStr, hourStr2));
// qDebug() << "recurrenceString=" << IncidenceFormatter::recurrenceString( e3 );
// qDebug() << "recurrenceString=" << IncidenceFormatter::recurrenceString( e3 );
}
KCalendarCore::Calendar::Ptr IncidenceFormatterTest::loadCalendar(const QString &name)
......@@ -170,15 +158,15 @@ KCalendarCore::Calendar::Ptr IncidenceFormatterTest::loadCalendar(const QString
bool IncidenceFormatterTest::validateHtml(const QString &name, const QString &_html)
{
QString html = QStringLiteral("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
" <head>\n"
" <title></title>\n"
" <style></style>\n"
" </head>\n"
"<body>")
+ _html
+ QStringLiteral("</body>\n</html>");
QString html = QStringLiteral(
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
" <head>\n"
" <title></title>\n"
" <style></style>\n"
" </head>\n"
"<body>")
+ _html + QStringLiteral("</body>\n</html>");
const QString outFileName = QStringLiteral(TEST_DATA_DIR "/%1.out").arg(name);
const QString htmlFileName = QStringLiteral(TEST_DATA_DIR "/%1.out.html").arg(name);
......@@ -191,14 +179,8 @@ bool IncidenceFormatterTest::validateHtml(const QString &name, const QString &_h
// validate xml and pretty-print for comparison
// TODO add proper cmake check for xmllint and diff
const QStringList args = {
QStringLiteral("--format"),
QStringLiteral("--encode"),
QStringLiteral("UTF8"),
QStringLiteral("--output"),
htmlFileName,
outFileName
};
const QStringList args =
{QStringLiteral("--format"), QStringLiteral("--encode"), QStringLiteral("UTF8"), QStringLiteral("--output"), htmlFileName, outFileName};
const int result = QProcess::execute(QStringLiteral("xmllint"), args);
return result == 0;
......@@ -230,11 +212,7 @@ bool IncidenceFormatterTest::compareHtml(const QString &name)
}
// compare to reference file
const QStringList args = {
QStringLiteral("-u"),
referenceFileName,
htmlFileName
};
const QStringList args = {QStringLiteral("-u"), referenceFileName, htmlFileName};
QProcess proc;
proc.setProcessChannelMode(QProcess::ForwardedChannels);
......@@ -424,13 +402,10 @@ void IncidenceFormatterTest::testFormatIcalInvitation()
QVERIFY(eventFile.open(QIODevice::ReadOnly));
const QByteArray data = eventFile.readAll();
const QString html = IncidenceFormatter::formatICalInvitation(QString::fromUtf8(data),
calendar,
&helper)
.replace(btnBg, QStringLiteral("btnBg"))
.replace(btnFg, QStringLiteral("btnFg"))
.replace(btnBdr, QStringLiteral("btnBdr"))
;
const QString html = IncidenceFormatter::formatICalInvitation(QString::fromUtf8(data), calendar, &helper)
.replace(btnBg, QStringLiteral("btnBg"))
.replace(btnFg, QStringLiteral("btnFg"))
.replace(btnBdr, QStringLiteral("btnBdr"));
QVERIFY(validateHtml(name, html));
QVERIFY(compareHtml(name));
......
......@@ -33,8 +33,7 @@ void StringifyTest::testIncidenceStrings()
QVERIFY(Stringify::incidenceSecrecy(Incidence::SecrecyPublic) == i18n("Public"));
QVERIFY(Stringify::incidenceSecrecy(Incidence::SecrecyPrivate) == i18n("Private"));
QVERIFY(
Stringify::incidenceSecrecy(Incidence::SecrecyConfidential) == i18n("Confidential"));
QVERIFY(Stringify::incidenceSecrecy(Incidence::SecrecyConfidential) == i18n("Confidential"));
QVERIFY(Stringify::incidenceStatus(Incidence::StatusTentative) == i18n("Tentative"));
QVERIFY(Stringify::incidenceStatus(Incidence::StatusConfirmed) == i18n("Confirmed"));
......@@ -66,12 +65,12 @@ void StringifyTest::testAttendeeStrings()
void StringifyTest::testDateTimeStrings()
{
//TODO
// TODO
}
void StringifyTest::testUTCoffsetStrings()
{
QTimeZone tz1(5 * 60 * 60); //5 hrs
QTimeZone tz1(5 * 60 * 60); // 5 hrs
QCOMPARE(Stringify::tzUTCOffsetStr(tz1), QStringLiteral("+05:00"));
QTimeZone tz2(-5 * 60 * 60); //-5 hrs
......@@ -80,16 +79,16 @@ void StringifyTest::testUTCoffsetStrings()
QTimeZone tz3(0);
QCOMPARE(Stringify::tzUTCOffsetStr(tz3), QStringLiteral("+00:00"));
QTimeZone tz4(30 * 60 * 60); //30 hrs -- out-of-range
QTimeZone tz4(30 * 60 * 60); // 30 hrs -- out-of-range
QCOMPARE(Stringify::tzUTCOffsetStr(tz4), QStringLiteral("+00:00"));
QTimeZone tz5((5 * 60 * 60) + (30 * 60)); //5:30
QTimeZone tz5((5 * 60 * 60) + (30 * 60)); // 5:30
QCOMPARE(Stringify::tzUTCOffsetStr(tz5), QStringLiteral("+05:30"));
QTimeZone tz6(-((11 * 60 * 60) + (59 * 60))); //-11:59
QCOMPARE(Stringify::tzUTCOffsetStr(tz6), QStringLiteral("-11:59"));
QTimeZone tz7(12 * 60 * 60); //12:00
QTimeZone tz7(12 * 60 * 60); // 12:00
QCOMPARE(Stringify::tzUTCOffsetStr(tz7), QStringLiteral("+12:00"));
QTimeZone tz8(-((12 * 60 * 60) + (59 * 60))); //-12:59
......
......@@ -6,8 +6,8 @@
#include "testtodotooltip.h"
#include <KCalendarCore/Todo>
#include "incidenceformatter.h"
#include <KCalendarCore/Todo>
#include <QRegularExpression>
#include <QTest>
......@@ -15,29 +15,29 @@
// Standard values for to-dos.
static const bool ALL_DAY = true;
static const bool RECURS = true;
static const QDateTime START_DT { QDate(2222, 6, 10), QTime(11, 0, 0) };
static const QDateTime DUE_DT { QDate(2222, 6, 12), QTime(11, 30, 0) };
static const QDate AS_OF_DATE { 2222, 6, 12 };
static const QString SUMMARY { QStringLiteral("Do something") };
static const QString CAL_NAME { QStringLiteral("A calendar") };
static const QDateTime START_DT{QDate(2222, 6, 10), QTime(11, 0, 0)};
static const QDateTime DUE_DT{QDate(2222, 6, 12), QTime(11, 30, 0)};
static const QDate AS_OF_DATE{2222, 6, 12};
static const QString SUMMARY{QStringLiteral("Do something")};
static const QString CAL_NAME{QStringLiteral("A calendar")};
// Field names in tool tips.
static const QString CALENDAR { QStringLiteral("Calendar") };
static const QString START { QStringLiteral("Start") };
static const QString DUE { QStringLiteral("Due") };
static const QString PERCENT { QStringLiteral("Percent Done") };
static const QString COMPLETED { QStringLiteral("Completed") };
static const QString DURATION { QStringLiteral("Duration") };
static const QString RECURRENCE { QStringLiteral("Recurrence") };
static const QString PRIORITY { QStringLiteral("Priority") };
static const QString CALENDAR{QStringLiteral("Calendar")};
static const QString START{QStringLiteral("Start")};
static const QString DUE{QStringLiteral("Due")};
static const QString PERCENT{QStringLiteral("Percent Done")};
static const QString COMPLETED{QStringLiteral("Completed")};
static const QString DURATION{QStringLiteral("Duration")};
static const QString RECURRENCE{QStringLiteral("Recurrence")};
static const QString PRIORITY{QStringLiteral("Priority")};
// Common expected field values in tool tips.
static const QString EXPECTED_RECURRENCE { QStringLiteral("Recurs every 7 days until") };
static const QString EXPECTED_DURATION_DAYS { QStringLiteral("3 days") };
static const QString EXPECTED_DURATION_DT { QStringLiteral("2 days 30 minutes") };
static const QString EXPECTED_PCT100 { QStringLiteral("100%") };
static const QString EXPECTED_PCT50 { QStringLiteral("50%") };
static const QString EXPECTED_PCT0 { QStringLiteral("0%") };
static const QString EXPECTED_RECURRENCE{QStringLiteral("Recurs every 7 days until")};
static const QString EXPECTED_DURATION_DAYS{QStringLiteral("3 days")};
static const QString EXPECTED_DURATION_DT{QStringLiteral("2 days 30 minutes")};
static const QString EXPECTED_PCT100{QStringLiteral("100%")};
static const QString EXPECTED_PCT50{QStringLiteral("50%")};
static const QString EXPECTED_PCT0{QStringLiteral("0%")};
using namespace KCalUtils::IncidenceFormatter;
......@@ -46,7 +46,7 @@ using namespace KCalUtils::IncidenceFormatter;
// Other to-do fields are fixed.
static KCalendarCore::Todo::Ptr makeToDo(bool allday, bool recurs, QDateTime dtStart, QDateTime dtDue)
{
KCalendarCore::Todo::Ptr todo {new KCalendarCore::Todo };
KCalendarCore::Todo::Ptr todo{new KCalendarCore::Todo};
todo->setSummary(SUMMARY);
todo->setDtStart(dtStart);
todo->setDtDue(dtDue);
......@@ -66,8 +66,7 @@ static QString plain(QString s)
return s.replace(QStringLiteral("&nbsp;"), QStringLiteral(" "))
.replace(QStringLiteral("<hr>"), QStringLiteral("\n---\n"))
.replace(QStringLiteral("<br>"), QStringLiteral("\n"))
.remove(QRegularExpression(QStringLiteral("<[/a-z]+>")))
;
.remove(QRegularExpression(QStringLiteral("<[/a-z]+>")));
}
// Return a regular expression that matches a field name and value.
......@@ -77,7 +76,8 @@ static QRegularExpression field(const QString &name, const QString &value)
}
// Return a regular expression that matches just a field name.
static QRegularExpression field(const QString &name) {
static QRegularExpression field(const QString &name)
{
return QRegularExpression(QStringLiteral("\\b%1:").arg(name));
}
......@@ -122,7 +122,7 @@ void TestTodoToolTip::testNonrecurring()
QVERIFY(toolTip.contains(QRegularExpression(SUMMARY)));
QVERIFY(toolTip.contains(field(CALENDAR, CAL_NAME)));
QVERIFY(toolTip.contains(field(PERCENT, EXPECTED_PCT50 )));
QVERIFY(toolTip.contains(field(PERCENT, EXPECTED_PCT50)));
QVERIFY(!toolTip.contains(field(COMPLETED)));
QVERIFY(!toolTip.contains(field(RECURRENCE)));
if (dtStart.isValid()) {
......@@ -189,60 +189,53 @@ void TestTodoToolTip::testRecurringOnDate_data()
QTest::addColumn<QString>("dur");
// Test the tool tip for each day of each occurrence of all-day to-dos.
QTest::newRow("All day, 1st occurrence, day 1") << ALL_DAY << START_DT << DUE_DT
<< START_DT.date() << EXPECTED_PCT100 << 0 << EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 1st occurrence, day 2") << ALL_DAY << START_DT << DUE_DT
<< START_DT.date().addDays(1) << EXPECTED_PCT100 << 0 << EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 1st occurrence, day 3") << ALL_DAY << START_DT << DUE_DT
<< DUE_DT.date() << EXPECTED_PCT100 << 0 << EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 1st occurrence, only day") << ALL_DAY << DUE_DT << DUE_DT
<< DUE_DT.date() << EXPECTED_PCT100 << 0 << QStringLiteral("1 day");
QTest::newRow("All day, 2nd occurrence, day 1") << ALL_DAY << START_DT << DUE_DT
<< START_DT.date().addDays(7) << EXPECTED_PCT50 << 7 << EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 2nd occurrence, day 2") << ALL_DAY << START_DT << DUE_DT
<< START_DT.date().addDays(8) << EXPECTED_PCT50 << 7 << EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 2nd occurrence, day 3") << ALL_DAY << START_DT << DUE_DT
<< DUE_DT.date().addDays(7) << EXPECTED_PCT50 << 7 << EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 2nd occurrence, only day") << ALL_DAY << DUE_DT << DUE_DT
<< DUE_DT.date().addDays(7) << EXPECTED_PCT50 << 7 << QStringLiteral("1 day");
QTest::newRow("All day, 3rd occurrence, day 1") << ALL_DAY << START_DT << DUE_DT
<< START_DT.date().addDays(14) << EXPECTED_PCT0 << 14 << EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 3rd occurrence, day 2") << ALL_DAY << START_DT << DUE_DT
<< START_DT.date().addDays(15) << EXPECTED_PCT0 << 14 << EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 3rd occurrence, day 3") << ALL_DAY << START_DT << DUE_DT
<< DUE_DT.date().addDays(14) << EXPECTED_PCT0 << 14 << EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 3rd occurrence, only day") << ALL_DAY << DUE_DT << DUE_DT
<< DUE_DT.date().addDays(14) << EXPECTED_PCT0 << 14 << QStringLiteral("1 day");
QTest::newRow("All day, 1st occurrence, day 1") << ALL_DAY << START_DT << DUE_DT << START_DT.date() << EXPECTED_PCT100 << 0 << EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 1st occurrence, day 2") << ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(1) << EXPECTED_PCT100 << 0
<< EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 1st occurrence, day 3") << ALL_DAY << START_DT << DUE_DT << DUE_DT.date() << EXPECTED_PCT100 << 0 << EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 1st occurrence, only day") << ALL_DAY << DUE_DT << DUE_DT << DUE_DT.date() << EXPECTED_PCT100 << 0 << QStringLiteral("1 day");
QTest::newRow("All day, 2nd occurrence, day 1") << ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(7) << EXPECTED_PCT50 << 7
<< EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 2nd occurrence, day 2") << ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(8) << EXPECTED_PCT50 << 7
<< EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 2nd occurrence, day 3") << ALL_DAY << START_DT << DUE_DT << DUE_DT.date().addDays(7) << EXPECTED_PCT50 << 7
<< EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 2nd occurrence, only day")
<< ALL_DAY << DUE_DT << DUE_DT << DUE_DT.date().addDays(7) << EXPECTED_PCT50 << 7 << QStringLiteral("1 day");
QTest::newRow("All day, 3rd occurrence, day 1") << ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(14) << EXPECTED_PCT0 << 14
<< EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 3rd occurrence, day 2") << ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(15) << EXPECTED_PCT0 << 14
<< EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 3rd occurrence, day 3") << ALL_DAY << START_DT << DUE_DT << DUE_DT.date().addDays(14) << EXPECTED_PCT0 << 14
<< EXPECTED_DURATION_DAYS;
QTest::newRow("All day, 3rd occurrence, only day")
<< ALL_DAY << DUE_DT << DUE_DT << DUE_DT.date().addDays(14) << EXPECTED_PCT0 << 14 << QStringLiteral("1 day");
// Test the tool tip for each day of each occurrence of time-of-day to-dos.
QTest::newRow("Timed, 1st occurrence, day 1") << !ALL_DAY << START_DT << DUE_DT
<< START_DT.date() << EXPECTED_PCT100 << 0 << EXPECTED_DURATION_DT;
QTest::newRow("Timed, 1st occurrence, day 2") << !ALL_DAY << START_DT << DUE_DT
<< START_DT.date().addDays(1) << EXPECTED_PCT100 << 0 << EXPECTED_DURATION_DT;
QTest::newRow("Timed, 1st occurrence, day 3") << !ALL_DAY << START_DT << DUE_DT
<< DUE_DT.date() << EXPECTED_PCT100 << 0 << EXPECTED_DURATION_DT;
QTest::newRow("Timed, 1st occurrence, only day") << !ALL_DAY << START_DT.addDays(2) << DUE_DT
<< DUE_DT.date() << EXPECTED_PCT100 << 0 << QStringLiteral("30 minutes");
QTest::newRow("Timed, 2nd occurrence, day 1") << !ALL_DAY << START_DT << DUE_DT
<< START_DT.date().addDays(7) << EXPECTED_PCT50 << 7 << EXPECTED_DURATION_DT;
QTest::newRow("Timed, 2nd occurrence, day 2") << !ALL_DAY << START_DT << DUE_DT
<< START_DT.date().addDays(8) << EXPECTED_PCT50 << 7 << EXPECTED_DURATION_DT;
QTest::newRow("Timed, 2nd occurrence, day 3") << !ALL_DAY << START_DT << DUE_DT
<< DUE_DT.date().addDays(7) << EXPECTED_PCT50 << 7 << EXPECTED_DURATION_DT;
QTest::newRow("Timed, 2nd occurrence, only day") << !ALL_DAY << START_DT.addDays(2) << DUE_DT
<< DUE_DT.date().addDays(7) << EXPECTED_PCT50 << 7 << QStringLiteral("30 minutes");
QTest::newRow("Timed, 3rd occurrence, day 1") << !ALL_DAY << START_DT << DUE_DT
<< START_DT.date().addDays(14) << EXPECTED_PCT0 << 14 << EXPECTED_DURATION_DT;
QTest::newRow("Timed, 3rd occurrence, day 2") << !ALL_DAY << START_DT << DUE_DT
<< START_DT.date().addDays(15) << EXPECTED_PCT0 << 14 << EXPECTED_DURATION_DT;
QTest::newRow("Timed, 3rd occurrence, day 3") << !ALL_DAY << START_DT << DUE_DT
<< DUE_DT.date().addDays(14) << EXPECTED_PCT0 << 14 << EXPECTED_DURATION_DT;
QTest::newRow("Timed, 3rd occurrence, only day") << !ALL_DAY << START_DT.addDays(2) << DUE_DT
<< DUE_DT.date().addDays(14) << EXPECTED_PCT0 << 14 << QStringLiteral("30 minutes");
QTest::newRow("Timed, 1st occurrence, day 1") << !ALL_DAY << START_DT << DUE_DT << START_DT.date() << EXPECTED_PCT100 << 0 << EXPECTED_DURATION_DT;
QTest::newRow("Timed, 1st occurrence, day 2") << !ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(1) << EXPECTED_PCT100 << 0
<< EXPECTED_DURATION_DT;
QTest::newRow("Timed, 1st occurrence, day 3") << !ALL_DAY << START_DT << DUE_DT << DUE_DT.date() << EXPECTED_PCT100 << 0 << EXPECTED_DURATION_DT;
QTest::newRow("Timed, 1st occurrence, only day") << !ALL_DAY << START_DT.addDays(2) << DUE_DT << DUE_DT.date() << EXPECTED_PCT100 << 0
<< QStringLiteral("30 minutes");
QTest::newRow("Timed, 2nd occurrence, day 1") << !ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(7) << EXPECTED_PCT50 << 7
<< EXPECTED_DURATION_DT;
QTest::newRow("Timed, 2nd occurrence, day 2") << !ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(8) << EXPECTED_PCT50 << 7
<< EXPECTED_DURATION_DT;
QTest::newRow("Timed, 2nd occurrence, day 3") << !ALL_DAY << START_DT << DUE_DT << DUE_DT.date().addDays(7) << EXPECTED_PCT50 << 7 << EXPECTED_DURATION_DT;
QTest::newRow("Timed, 2nd occurrence, only day") << !ALL_DAY << START_DT.addDays(2) << DUE_DT << DUE_DT.date().addDays(7) << EXPECTED_PCT50 << 7
<< QStringLiteral("30 minutes");
QTest::newRow("Timed, 3rd occurrence, day 1") << !ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(14) << EXPECTED_PCT0 << 14
<< EXPECTED_DURATION_DT;
QTest::newRow("Timed, 3rd occurrence, day 2") << !ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(15) << EXPECTED_PCT0 << 14
<< EXPECTED_DURATION_DT;
QTest::newRow("Timed, 3rd occurrence, day 3") << !ALL_DAY << START_DT << DUE_DT << DUE_DT.date().addDays(14) << EXPECTED_PCT0 << 14 << EXPECTED_DURATION_DT;
QTest::newRow("Timed, 3rd occurrence, only day") << !ALL_DAY << START_DT.addDays(2) << DUE_DT << DUE_DT.date().addDays(14) << EXPECTED_PCT0 << 14
<< QStringLiteral("30 minutes");
}
// Test for the values of tool tip fields, or their absence, for specific dates
......@@ -277,7 +270,7 @@ void TestTodoToolTip::testAlldayRecurringNoDate()
QVERIFY(toolTip.contains(QRegularExpression(SUMMARY)));
QVERIFY(toolTip.contains(field(CALENDAR, CAL_NAME)));
QVERIFY(toolTip.contains(field(PERCENT, EXPECTED_PCT50 )));
QVERIFY(toolTip.contains(field(PERCENT, EXPECTED_PCT50)));
QVERIFY(!toolTip.contains(field(COMPLETED)));
QVERIFY(toolTip.contains(field(START, dateTimeToString(START_DT.addDays(7), ALL_DAY, false))));
QVERIFY(toolTip.contains(field(DUE, dateTimeToString(DUE_DT.addDays(7), ALL_DAY, false))));
......@@ -293,7 +286,7 @@ void TestTodoToolTip::testTimedRecurringNoDate()
QVERIFY(toolTip.contains(QRegularExpression(SUMMARY)));
QVERIFY(toolTip.contains(field(CALENDAR, CAL_NAME)));
QVERIFY(toolTip.contains(field(PERCENT, EXPECTED_PCT50 )));
QVERIFY(toolTip.contains(field(PERCENT, EXPECTED_PCT50)));
QVERIFY(!toolTip.contains(field(COMPLETED)));
QVERIFY(toolTip.contains(field(START, dateTimeToString(START_DT.addDays(7), !ALL_DAY, false))));
QVERIFY(toolTip.contains(field(DUE, dateTimeToString(DUE_DT.addDays(7), !ALL_DAY, false))));
......@@ -310,7 +303,7 @@ void TestTodoToolTip::testAlldayRecurringNeverDue()
QVERIFY(toolTip.contains(QRegularExpression(SUMMARY)));
QVERIFY(toolTip.contains(field(CALENDAR, CAL_NAME)));
QVERIFY(toolTip.contains(field(PERCENT, EXPECTED_PCT50 )));
QVERIFY(toolTip.contains(field(PERCENT, EXPECTED_PCT50)));
QVERIFY(!toolTip.contains(field(COMPLETED)));
QVERIFY(toolTip.contains(field(START, dateTimeToString(START_DT.addDays(7), ALL_DAY, false))));
QVERIFY(!toolTip.contains(field(DUE)));
......@@ -327,7 +320,7 @@ void TestTodoToolTip::testTimedRecurringNeverDue()
QVERIFY(toolTip.contains(QRegularExpression(SUMMARY)));
QVERIFY(toolTip.contains(field(CALENDAR, CAL_NAME)));
QVERIFY(toolTip.contains(field(PERCENT, EXPECTED_PCT50 )));
QVERIFY(toolTip.contains(field(PERCENT, EXPECTED_PCT50)));
QVERIFY(toolTip.contains(field(START, dateTimeToString(START_DT.addDays(7), !ALL_DAY, false))));
QVERIFY(!toolTip.contains(field(DUE)));
QVERIFY(!toolTip.contains(field(DURATION)));
......@@ -339,8 +332,8 @@ void TestTodoToolTip::testTimedRecurringNeverDue()
void TestTodoToolTip::testAlldayRecurringDone()
{
auto todo = makeToDo(ALL_DAY, RECURS, START_DT, DUE_DT);
todo->setCompleted(START_DT.addDays(14)); // Complete the second occurrence.
todo->setCompleted(START_DT.addMonths(1)); // Complete the third occurrence.
todo->setCompleted(START_DT.addDays(14)); // Complete the second occurrence.
todo->setCompleted(START_DT.addMonths(1)); // Complete the third occurrence.
auto toolTip = plain(toolTipStr(CAL_NAME, todo, AS_OF_DATE, false));
QVERIFY(toolTip.contains(field(COMPLETED, dateTimeToString(START_DT.addMonths(1), ALL_DAY, false))));
......@@ -356,8 +349,8 @@ void TestTodoToolTip::testAlldayRecurringDone()
void TestTodoToolTip::testTimedRecurringDone()
{
auto todo = makeToDo(!ALL_DAY, RECURS, START_DT, DUE_DT);
todo->setCompleted(START_DT.addDays(14)); // Complete the second occurrence.
todo->setCompleted(START_DT.addMonths(1)); // Complete the third occurrence.
todo->setCompleted(START_DT.addDays(14)); // Complete the second occurrence.
todo->setCompleted(START_DT.addMonths(1)); // Complete the third occurrence.
auto toolTip = plain(toolTipStr(CAL_NAME, todo, AS_OF_DATE, false));
QVERIFY(toolTip.contains(field(COMPLETED, dateTimeToString(START_DT.addMonths(1), !ALL_DAY, false))));
......
......@@ -30,15 +30,15 @@
#include <KUrlMimeData>
#include <QUrl>
#include <QMimeData>
#include <QApplication>
#include <QClipboard>
#include <QDrag>
#include <QDate>
#include <QIcon>
#include <QWidget>
#include <QDrag>
#include <QDropEvent>
#include <QIcon>
#include <QMimeData>
#include <QTimeZone>
#include <QWidget>
using namespace KCalendarCore;
using namespace KCalUtils;
......@@ -151,7 +151,7 @@ QMimeData *DndFactory::createMimeData(const Incidence::Ptr &incidence)
{
MemoryCalendar::Ptr cal(new MemoryCalendar(d->mCalendar->timeZone()));
Incidence::Ptr i(incidence->clone());
//strip recurrence id's, We don't want to drag the exception but the occurrence.
// strip recurrence id's, We don't want to drag the exception but the occurrence.
i->setRecurrenceId({});
cal->addIncidence(i);
......@@ -184,8 +184,7 @@ MemoryCalendar::Ptr DndFactory::createDropCalendar(const QMimeData *mimeData)
if (mimeData) {
MemoryCalendar::Ptr calendar(new MemoryCalendar(QTimeZone::systemTimeZone()));
if (ICalDrag::fromMimeData(mimeData, calendar)
|| VCalDrag::fromMimeData(mimeData, calendar)) {
if (ICalDrag::fromMimeData(mimeData, calendar) || VCalDrag::fromMimeData(mimeData, calendar)) {
return calendar;
}
}
......@@ -205,7 +204,7 @@ MemoryCalendar::Ptr DndFactory::createDropCalendar(QDropEvent *dropEvent)
Event::Ptr DndFactory::createDropEvent(const QMimeData *mimeData)
{
//qCDebug(KCALUTILS_LOG);
// qCDebug(KCALUTILS_LOG);
Event::Ptr event;
MemoryCalendar::Ptr calendar(createDropCalendar(mimeData));
......@@ -231,7 +230,7 @@ Event::Ptr DndFactory::createDropEvent(QDropEvent *dropEvent)
Todo::Ptr DndFactory::createDropTodo(const QMimeData *mimeData)
{
//qCDebug(KCALUTILS_LOG);
// qCDebug(KCALUTILS_LOG);
Todo::Ptr todo;
MemoryCalendar::Ptr calendar(createDropCalendar(mimeData));
......@@ -329,8 +328,7 @@ Incidence::List DndFactory::pasteIncidences(const QDateTime &newDateTime, PasteF
Incidence::List::ConstIterator it;
const Incidence::List incidences = calendar->incidences();
Incidence::List::ConstIterator end(incidences.constEnd());
for (it = incidences.constBegin();
it != end; ++it) {
for (it = incidences.constBegin(); it != end; ++it) {
Incidence::Ptr incidence = d->pasteIncidence(*it, newDateTime, pasteOptions);
if (incidence) {
list.append(incidence);
......