Commit 77fcad8f authored by Laurent Montel's avatar Laurent Montel 😁

Astyle kdelibs

parent f94dc43c
......@@ -24,13 +24,14 @@
#include <QObject>
#include <EventViews/Prefs>
namespace Akonadi {
namespace Akonadi
{
class ChangeRecorder;
class ETMCalendar;
}
class AkonadiPimDataSource : public QObject,
public PimDataSource
public PimDataSource
{
Q_OBJECT
......@@ -52,5 +53,4 @@ private:
mutable QHash<qint64, QString> mColorCache;
};
#endif
......@@ -55,8 +55,8 @@ public:
}
QVector<CalendarEvents::EventData> callExplodeIncidenceOccurences(const CalendarEvents::EventData &baseEd,
const KCalCore::Incidence::Ptr &incidence,
bool &ok)
const KCalCore::Incidence::Ptr &incidence,
bool &ok)
{
return Visitor::explodeIncidenceOccurences(baseEd, incidence, ok);
}
......@@ -87,7 +87,6 @@ void EventDataVisitorTest::testGenerateUID_data()
<< 42ll << QStringLiteral("Akonadi-42-20160529T154905UTC");
}
void EventDataVisitorTest::testGenerateUID()
{
QFETCH(KCalCore::Incidence::Ptr, incidence);
......@@ -103,8 +102,6 @@ void EventDataVisitorTest::testGenerateUID()
QCOMPARE(result, expectedUID);
}
void EventDataVisitorTest::testIsInRange_data()
{
QTest::addColumn<QDate>("rangeStart");
......@@ -114,11 +111,11 @@ void EventDataVisitorTest::testIsInRange_data()
QTest::addColumn<bool>("expectedResult");
QTest::newRow("single day fully in-range") << QDate(2016, 5, 1) << QDate(2016, 5, 31)
<< QDate(2016, 5, 3) << QDate(2016, 5, 3)
<< true;
<< QDate(2016, 5, 3) << QDate(2016, 5, 3)
<< true;
QTest::newRow("multiday fully in-range") << QDate(2016, 5, 1) << QDate(2016, 5, 31)
<< QDate(2016, 5, 3) << QDate(2016, 5, 15)
<< true;
<< QDate(2016, 5, 3) << QDate(2016, 5, 15)
<< true;
QTest::newRow("multiday start overlap") << QDate(2016, 5, 1) << QDate(2016, 5, 31)
<< QDate(2016, 4, 28) << QDate(2016, 5, 5)
<< true;
......@@ -126,20 +123,20 @@ void EventDataVisitorTest::testIsInRange_data()
<< QDate(2016, 5, 28) << QDate(2016, 6, 5)
<< true;
QTest::newRow("single day range edge start") << QDate(2016, 5, 1) << QDate(2016, 5, 31)
<< QDate(2016, 5, 1) << QDate(2016, 5, 1)
<< true;
<< QDate(2016, 5, 1) << QDate(2016, 5, 1)
<< true;
QTest::newRow("single day range edge end") << QDate(2016, 5, 1) << QDate(2016, 5, 31)
<< QDate(2016, 5, 31) << QDate(2016, 5, 31)
<< true;
<< QDate(2016, 5, 31) << QDate(2016, 5, 31)
<< true;
QTest::newRow("multiday range edge start") << QDate(2016, 5, 1) << QDate(2016, 5, 31)
<< QDate(2016, 5, 1) << QDate(2016, 5, 10)
<< true;
<< QDate(2016, 5, 1) << QDate(2016, 5, 10)
<< true;
QTest::newRow("multiday range edge end") << QDate(2016, 5, 1) << QDate(2016, 5, 31)
<< QDate(2016, 5, 20) << QDate(2016, 5, 31)
<< true;
<< QDate(2016, 5, 20) << QDate(2016, 5, 31)
<< true;
QTest::newRow("single day before range") << QDate(2016, 5, 1) << QDate(2016, 5, 31)
<< QDate(2016, 4, 28) << QDate(2016, 4, 28)
<< false;
<< QDate(2016, 4, 28) << QDate(2016, 4, 28)
<< false;
QTest::newRow("single day after range") << QDate(2016, 5, 1) << QDate(2016, 5, 31)
<< QDate(2016, 6, 4) << QDate(2016, 6, 4)
<< false;
......@@ -165,8 +162,6 @@ void EventDataVisitorTest::testIsInRange()
QCOMPARE(result, expectedResult);
}
void EventDataVisitorTest::testExplodeIncidenceOccurences_data()
{
QTest::addColumn<QDate>("rangeStart");
......@@ -192,7 +187,6 @@ void EventDataVisitorTest::testExplodeIncidenceOccurences_data()
}
}
void EventDataVisitorTest::testExplodeIncidenceOccurences()
{
QFETCH(QDate, rangeStart);
......@@ -215,8 +209,6 @@ void EventDataVisitorTest::testExplodeIncidenceOccurences()
}
}
void EventDataVisitorTest::testEventDataVisitor_data()
{
QTest::addColumn<QDate>("rangeStart");
......@@ -263,8 +255,6 @@ void EventDataVisitorTest::testEventDataVisitor()
}
}
void EventDataVisitorTest::testEventDataIdVisitor_data()
{
QTest::addColumn<QDate>("rangeStart");
......@@ -308,5 +298,4 @@ void EventDataVisitorTest::testEventDataIdVisitor()
QCOMPARE(results, expectedUids);
}
QTEST_MAIN(EventDataVisitorTest)
......@@ -31,7 +31,6 @@ class EventDataVisitorTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testGenerateUID_data();
void testGenerateUID();
......
......@@ -40,5 +40,4 @@ private:
KCalCore::Calendar *mCalendar;
};
#endif
......@@ -36,7 +36,7 @@ void PimEventsPluginTest::initTestCase()
}
bool PimEventsPluginTest::compareEventDataHashes(const DateEventDataHash &actual,
const DateEventDataHash &expected)
const DateEventDataHash &expected)
{
COMPARE(actual.size(), expected.size());
Q_FOREACH (const QDate &resultKey, actual.uniqueKeys()) {
......@@ -82,14 +82,14 @@ DateEventDataHash PimEventsPluginTest::populateCalendar(FakePimDataSource *sourc
}
QVector<CalendarEvents::EventData> PimEventsPluginTest::findEventData(const KCalCore::Event::Ptr &event,
const DateEventDataHash &allData)
const DateEventDataHash &allData)
{
QVector<CalendarEvents::EventData> data;
for (auto it = allData.cbegin(), end = allData.cend(); it != end; ++it) {
// This is a very naive check
if (it->title() == event->summary()
&& it->description() == event->description()
&& it->isAllDay() == event->allDay()) {
&& it->description() == event->description()
&& it->isAllDay() == event->allDay()) {
data.push_back((*it));
}
}
......@@ -97,9 +97,6 @@ QVector<CalendarEvents::EventData> PimEventsPluginTest::findEventData(const KCal
return data;
}
void PimEventsPluginTest::testLoadEventsForDataRange()
{
FakePimDataSource source;
......@@ -131,7 +128,6 @@ void PimEventsPluginTest::testEventAdded()
plugin.loadEventsForDateRange(QDate(2016, 5, 1), QDate(2016, 5, 31));
QCOMPARE(dataReadySpy.size(), 0);
Q_FOREACH (const QString &data, allData) {
TestDataParser parser(data, true);
if (parser.rangeEnd() < QDate(2016, 5, 1) || parser.rangeStart() > QDate(2016, 5, 31)) {
......@@ -204,9 +200,9 @@ void PimEventsPluginTest::testEventModified()
const auto args = eventModifiedSpy.takeFirst();
const auto &resultData = args[0].value<CalendarEvents::EventData>();
const auto expected = std::find_if(expectedData.begin(), expectedData.end(),
[resultData](const CalendarEvents::EventData &e) {
return e.uid() == resultData.uid();
});
[resultData](const CalendarEvents::EventData & e) {
return e.uid() == resultData.uid();
});
QVERIFY(expected != expectedData.end());
expectedData.erase(expected);
QCOMPARE(resultData.title(), QString::fromLatin1("TEST2"));
......@@ -257,9 +253,9 @@ void PimEventsPluginTest::testEventRemoved()
while (!eventRemovedSpy.isEmpty()) {
const QString resultUid = eventRemovedSpy.takeFirst().first().toString();
const auto expected = std::find_if(expectedData.begin(), expectedData.end(),
[resultUid](const CalendarEvents::EventData &e) {
return e.uid() == resultUid;
});
[resultUid](const CalendarEvents::EventData & e) {
return e.uid() == resultUid;
});
QVERIFY(expected != expectedData.end());
expectedData.erase(expected);
}
......@@ -267,5 +263,4 @@ void PimEventsPluginTest::testEventRemoved()
}
}
QTEST_MAIN(PimEventsPluginTest)
......@@ -25,7 +25,8 @@
#include <KCalCore/Event>
class QDate;
namespace CalendarEvents {
namespace CalendarEvents
{
class EventData;
}
class FakePimDataSource;
......@@ -48,7 +49,7 @@ private:
const DateEventDataHash &expected);
DateEventDataHash populateCalendar(FakePimDataSource *source, bool uniqueEventData);
QVector<CalendarEvents::EventData> findEventData(const KCalCore::Event::Ptr &event,
const DateEventDataHash &allData);
const DateEventDataHash &allData);
};
#endif
......@@ -36,14 +36,14 @@ QDebug operator<<(QDebug dbg, const CalendarEvents::EventData &data)
bool operator==(const CalendarEvents::EventData &lhs, const CalendarEvents::EventData &rhs)
{
return lhs.uid() == rhs.uid()
&& lhs.type() == rhs.type()
&& lhs.isAllDay() == rhs.isAllDay()
&& lhs.isMinor() == rhs.isMinor()
&& lhs.title() == rhs.title()
&& lhs.startDateTime() == rhs.startDateTime()
&& lhs.endDateTime() == rhs.endDateTime()
&& lhs.description() == rhs.description()
&& lhs.eventColor() == rhs.eventColor();
&& lhs.type() == rhs.type()
&& lhs.isAllDay() == rhs.isAllDay()
&& lhs.isMinor() == rhs.isMinor()
&& lhs.title() == rhs.title()
&& lhs.startDateTime() == rhs.startDateTime()
&& lhs.endDateTime() == rhs.endDateTime()
&& lhs.description() == rhs.description()
&& lhs.eventColor() == rhs.eventColor();
}
namespace std
......@@ -61,28 +61,28 @@ bool operator<(const CalendarEvents::EventData &lhs, const CalendarEvents::Event
}
#define COMPARE(_actual, _expected) \
{ \
bool ok = false; \
[&]() { \
QCOMPARE(_actual, _expected); \
ok = true; \
}(); \
if (!ok) { \
return false; \
} \
}
{ \
bool ok = false; \
[&]() { \
QCOMPARE(_actual, _expected); \
ok = true; \
}(); \
if (!ok) { \
return false; \
} \
}
#define VERIFY(_cond) \
{ \
bool ok = false; \
[&]() { \
QVERIFY(_cond); \
ok = true; \
}(); \
if (!ok) { \
return false; \
} \
}
{ \
bool ok = false; \
[&]() { \
QVERIFY(_cond); \
ok = true; \
}(); \
if (!ok) { \
return false; \
} \
}
namespace TestUtils
{
......@@ -105,5 +105,4 @@ bool compareEventData(const CalendarEvents::EventData &actual,
}
#endif
......@@ -22,7 +22,7 @@
#include "pimeventsplugin_debug.h"
BaseEventDataVisitor::BaseEventDataVisitor(PimDataSource *dataSource,
const QDate &start, const QDate &end)
const QDate &start, const QDate &end)
: mDataSource(dataSource)
, mStart(start)
, mEnd(end)
......@@ -73,7 +73,7 @@ bool BaseEventDataVisitor::isInRange(const QDate &start, const QDate &end) const
}
QString BaseEventDataVisitor::generateUid(const KCalCore::Incidence::Ptr &incidence,
const KDateTime &recurrenceId) const
const KDateTime &recurrenceId) const
{
// Get a corresponding Akonadi Item: Akonadi ID is the only reliably unique
// and persistent identifier when dealing with incidences from multiple
......@@ -86,15 +86,15 @@ QString BaseEventDataVisitor::generateUid(const KCalCore::Incidence::Ptr &incide
if (recurrenceId.isValid()) {
return QStringLiteral("Akonadi-%1-%2").arg(itemId)
.arg(recurrenceId.toString(QStringLiteral("%Y%m%dT%H%M%S%Z")));
.arg(recurrenceId.toString(QStringLiteral("%Y%m%dT%H%M%S%Z")));
} else {
return QStringLiteral("Akonadi-%1").arg(itemId);
}
}
QVector<CalendarEvents::EventData> BaseEventDataVisitor::explodeIncidenceOccurences(const CalendarEvents::EventData &ed,
const KCalCore::Incidence::Ptr &incidence,
bool &ok)
const KCalCore::Incidence::Ptr &incidence,
bool &ok)
{
Q_ASSERT(incidence->recurs());
......@@ -118,12 +118,9 @@ QVector<CalendarEvents::EventData> BaseEventDataVisitor::explodeIncidenceOccuren
return results;
}
EventDataVisitor::EventDataVisitor(PimDataSource *dataSource,
const QDate &start, const QDate &end)
: BaseEventDataVisitor(dataSource, start , end)
: BaseEventDataVisitor(dataSource, start, end)
{
}
......@@ -131,7 +128,6 @@ EventDataVisitor::~EventDataVisitor()
{
}
const QMultiHash<QDate, CalendarEvents::EventData> &EventDataVisitor::results() const
{
return mResults;
......@@ -179,7 +175,6 @@ void EventDataVisitor::insertResult(const CalendarEvents::EventData &result)
}
}
CalendarEvents::EventData EventDataVisitor::incidenceData(const KCalCore::Incidence::Ptr &incidence) const
{
CalendarEvents::EventData data;
......@@ -214,7 +209,7 @@ bool EventDataIdVisitor::visit(const KCalCore::Todo::Ptr &todo)
return visit(todo.staticCast<KCalCore::Incidence>());
}
bool EventDataIdVisitor::visit(const KCalCore::Incidence::Ptr& incidence)
bool EventDataIdVisitor::visit(const KCalCore::Incidence::Ptr &incidence)
{
if (incidence->recurs()) {
CalendarEvents::EventData ed;
......
......@@ -41,8 +41,8 @@ protected:
bool isInRange(const QDate &start, const QDate &end) const;
QVector<CalendarEvents::EventData> explodeIncidenceOccurences(const CalendarEvents::EventData &ed,
const KCalCore::Incidence::Ptr &incidence,
bool &ok);
const KCalCore::Incidence::Ptr &incidence,
bool &ok);
protected:
PimDataSource *mDataSource;
QDate mStart;
......@@ -72,7 +72,6 @@ private:
};
class EventDataIdVisitor : public BaseEventDataVisitor
{
public:
......@@ -92,5 +91,4 @@ private:
QStringList mResults;
};
#endif
......@@ -49,7 +49,9 @@ PimCalendarsModel::PimCalendarsModel(QObject *parent)
mEtm->setItemPopulationStrategy(Akonadi::EntityTreeModel::NoItemPopulation);
mEtm->setListFilter(Akonadi::CollectionFetchScope::Enabled);
connect(mEtm, &Akonadi::EntityTreeModel::collectionTreeFetched,
this, [this]() { sort(0, Qt::AscendingOrder); });
this, [this]() {
sort(0, Qt::AscendingOrder);
});
setSourceModel(mEtm);
......@@ -86,10 +88,10 @@ QVariant PimCalendarsModel::data(const QModelIndex &index, int role) const
auto attr = col.attribute<Akonadi::EntityDisplayAttribute>();
const QString icon = attr ? attr->iconName() : QString::null;
return QVariantMap{ { QStringLiteral("id"), col.id() },
{ QStringLiteral("name"), col.displayName() },
{ QStringLiteral("enabled"), enabled },
{ QStringLiteral("checked"), mEnabledCalendars.contains(col.id()) },
{ QStringLiteral("iconName"), icon } };
{ QStringLiteral("name"), col.displayName() },
{ QStringLiteral("enabled"), enabled },
{ QStringLiteral("checked"), mEnabledCalendars.contains(col.id()) },
{ QStringLiteral("iconName"), icon } };
}
void PimCalendarsModel::setChecked(qint64 collectionId, bool checked)
......
......@@ -23,7 +23,8 @@
#include <QSortFilterProxyModel>
#include <QSet>
namespace Akonadi {
namespace Akonadi
{
class EntityTreeModel;
}
......@@ -50,5 +51,4 @@ private:
QSet<qint64> mEnabledCalendars;
};
#endif
......@@ -28,8 +28,7 @@ class PimCalendarsPlugin : public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
void registerTypes(const char *uri) Q_DECL_OVERRIDE
{
void registerTypes(const char *uri) Q_DECL_OVERRIDE {
qmlRegisterType<PimCalendarsModel>(uri, 1, 0, "PimCalendarsModel");
}
};
......
......@@ -22,7 +22,8 @@
#include <KCalCore/Incidence>
namespace KCalCore {
namespace KCalCore
{
class Calendar;
}
......
......@@ -22,10 +22,10 @@
#include "akonadipimdatasource.h"
#include "pimeventsplugin_debug.h"
PimEventsPlugin::PimEventsPlugin(QObject* parent)
PimEventsPlugin::PimEventsPlugin(QObject *parent)
: PimEventsPlugin(new AkonadiPimDataSource(), parent)
{
static_cast<AkonadiPimDataSource*>(mDataSource)->setParent(this);
static_cast<AkonadiPimDataSource *>(mDataSource)->setParent(this);
}
PimEventsPlugin::PimEventsPlugin(PimDataSource *dataSource, QObject *parent)
......@@ -37,13 +37,11 @@ PimEventsPlugin::PimEventsPlugin(PimDataSource *dataSource, QObject *parent)
dataSource->calendar()->registerObserver(this);
}
PimEventsPlugin::~PimEventsPlugin()
{
qCDebug(PIMEVENTSPLUGIN_LOG) << "PIM Events Plugin deactivated";
}
void PimEventsPlugin::loadEventsForDateRange(const QDate &startDate, const QDate &endDate)
{
mStart = startDate;
......
......@@ -31,7 +31,7 @@ class ETMCalendar;
class PimDataSource;
class PimEventsPlugin : public CalendarEvents::CalendarEventsPlugin
, public KCalCore::Calendar::CalendarObserver
, public KCalCore::Calendar::CalendarObserver
{
Q_OBJECT
Q_INTERFACES(CalendarEvents::CalendarEventsPlugin)
......@@ -47,7 +47,7 @@ public:
// KCalCore::Calendar::CalendarObserver
void calendarIncidenceChanged(const KCalCore::Incidence::Ptr &incidence) Q_DECL_OVERRIDE;
void calendarIncidenceAdded(const KCalCore::Incidence::Ptr & incidence) Q_DECL_OVERRIDE;
void calendarIncidenceAdded(const KCalCore::Incidence::Ptr &incidence) Q_DECL_OVERRIDE;
// Handle removal before it really happens otherwise we would not be able
// to lookup corresponding Akonadi ID in ETMCalendar
void calendarIncidenceAboutToBeDeleted(const KCalCore::Incidence::Ptr &incidence) Q_DECL_OVERRIDE;
......
......@@ -28,7 +28,7 @@ SettingsChangeNotifier *SettingsChangeNotifier::self()
// short code with long comments makes it look like I know what I'm doing.
const QVariant v = qApp->property(APP_PROPERTY_NAME);
if (v.isValid()) {
return reinterpret_cast<SettingsChangeNotifier*>(v.value<quintptr>());
return reinterpret_cast<SettingsChangeNotifier *>(v.value<quintptr>());
}
SettingsChangeNotifier *notifier = new SettingsChangeNotifier();
......
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