Commit 76c56cc4 authored by Dimitris Kardarakos's avatar Dimitris Kardarakos
Browse files

Fix class name conflict

As mentioned in #13, in KCalendarCore, the Conference class has been added, inducing a conflict with the already existing Conference class of Kongress. This commit addresses this conflict.
parent 8d42bec7
......@@ -25,8 +25,9 @@
#include <KConfigGroup>
#include <QFile>
#include <QDebug>
#include <KCalCore/FileStorage>
AlarmsModel::AlarmsModel(QObject *parent) : QAbstractListModel(parent), mMemoryCalendars(QVector<MemoryCalendar::Ptr>()), mFileStorages(QVector<FileStorage::Ptr>()), mAlarms(Alarm::List()), mCalendarFiles(QStringList()), mParams(QHash<QString, QVariant>())
AlarmsModel::AlarmsModel(QObject *parent) : QAbstractListModel(parent), mMemoryCalendars(QVector<KCalendarCore::MemoryCalendar::Ptr>()), mFileStorages(QVector<KCalendarCore::FileStorage::Ptr>()), mAlarms(KCalendarCore::Alarm::List()), mCalendarFiles(QStringList()), mParams(QHash<QString, QVariant>())
{
connect(this, &AlarmsModel::paramsChanged, this, &AlarmsModel::loadAlarms);
}
......@@ -84,13 +85,13 @@ void AlarmsModel::loadAlarms()
openLoadStorages();
int cnt = 0;
QVector<MemoryCalendar::Ptr>::const_iterator itr = mMemoryCalendars.constBegin();
QVector<KCalendarCore::MemoryCalendar::Ptr>::const_iterator itr = mMemoryCalendars.constBegin();
while (itr != mMemoryCalendars.constEnd()) {
QDateTime from = mPeriod["from"].toDateTime();
QDateTime to = mPeriod["to"].toDateTime();
qDebug() << "loadAlarms:\tLooking for alarms in calendar #" << cnt << ", from" << from.toString("dd.MM.yyyy hh:mm:ss") << "to" << to.toString("dd.MM.yyyy hh:mm:ss");
Alarm::List calendarAlarms;
KCalendarCore::Alarm::List calendarAlarms;
if (from.isValid() && to.isValid()) {
calendarAlarms = (*itr)->alarms(from, to, true);
......@@ -119,8 +120,8 @@ void AlarmsModel::setCalendars()
qDebug() << "\nsetCalendars";
QStringList::const_iterator itr = mCalendarFiles.constBegin();
while (itr != mCalendarFiles.constEnd()) {
MemoryCalendar::Ptr calendar(new MemoryCalendar(QTimeZone::systemTimeZoneId()));
FileStorage::Ptr storage(new FileStorage(calendar));
KCalendarCore::MemoryCalendar::Ptr calendar(new KCalendarCore::MemoryCalendar(QTimeZone::systemTimeZoneId()));
KCalendarCore::FileStorage::Ptr storage(new KCalendarCore::FileStorage(calendar));
storage->setFileName(*itr);
if (!(storage->fileName().isNull())) {
qDebug() << "setCalendars:\t" << "Appending calendar" << *itr;
......@@ -152,7 +153,7 @@ void AlarmsModel::setParams(const QHash<QString, QVariant> &parameters)
void AlarmsModel::openLoadStorages()
{
QVector<FileStorage::Ptr>::const_iterator itr = mFileStorages.constBegin();
QVector<KCalendarCore::FileStorage::Ptr>::const_iterator itr = mFileStorages.constBegin();
while (itr != mFileStorages.constEnd()) {
if ((*itr)->open()) {
qDebug() << "loadAlarms:\t" << (*itr)->fileName() << "opened";
......@@ -167,7 +168,7 @@ void AlarmsModel::openLoadStorages()
void AlarmsModel::closeStorages()
{
QVector<FileStorage::Ptr>::const_iterator itr = mFileStorages.constBegin();
QVector<KCalendarCore::FileStorage::Ptr>::const_iterator itr = mFileStorages.constBegin();
while (itr != mFileStorages.constEnd()) {
if ((*itr)->close()) {
qDebug() << "loadAlarms:\t" << (*itr)->fileName() << "closed";
......@@ -178,8 +179,8 @@ void AlarmsModel::closeStorages()
QDateTime AlarmsModel::parentStartDt(const int idx) const
{
Alarm::Ptr alarm = mAlarms.at(idx);
Duration offsetDuration;
KCalendarCore::Alarm::Ptr alarm = mAlarms.at(idx);
KCalendarCore::Duration offsetDuration;
QDateTime alarmTime = mAlarms.at(idx)->time();
if (alarm->hasStartOffset()) {
offsetDuration = alarm->startOffset();
......
......@@ -24,12 +24,10 @@
#define ALARMSMODEL_H
#include <QAbstractListModel>
#include <QVariantMap>
#include <KCalendarCore/Alarm>
#include <KCalendarCore/MemoryCalendar>
#include <KCalendarCore/FileStorage>
#include <QVariantMap>
using namespace KCalendarCore;
/**
* @brief Model that serves the alarms found in a set of calendar files for a specific time period, as set in the model input parameters
......@@ -80,9 +78,9 @@ private:
QDateTime parentStartDt(const int idx) const;
QVariantMap mPeriod;
QVector<MemoryCalendar::Ptr> mMemoryCalendars;
QVector<FileStorage::Ptr> mFileStorages;
Alarm::List mAlarms;
QVector<KCalendarCore::MemoryCalendar::Ptr> mMemoryCalendars;
QVector<KCalendarCore::FileStorage::Ptr> mFileStorages;
KCalendarCore::Alarm::List mAlarms;
QStringList mCalendarFiles;
QHash<QString, QVariant> mParams;
......
......@@ -25,14 +25,12 @@
#include "alarmsmodel.h"
#include "notificationhandler.h"
#include "kongressacadaptor.h"
#include <KSharedConfig>
#include <KConfigGroup>
#include <QDebug>
#include <QVariantMap>
#include <KSharedConfig>
#include <KConfigGroup>
#include <KLocalizedString>
using namespace KCalendarCore;
CalAlarmClient::CalAlarmClient(QObject *parent)
: QObject(parent), mAlarmsModel(new AlarmsModel()), mNotificationHandler(new NotificationHandler())
{
......
......@@ -29,6 +29,7 @@
class AlarmsModel;
class NotificationHandler;
/**
* @brief Client that orchestrates the parsing of calendars and the display of notifications for event alarms. It exposes a D-Bus Interface containing a set of callable methods.
*
......
......@@ -17,16 +17,15 @@
*/
#include "calendarcontroller.h"
#include <KLocalizedString>
#include <KConfig>
#include <KConfigGroup>
#include <QDebug>
#include <QRegExp>
#include <QDir>
#include <QFile>
#include <QJsonDocument>
#include <QJsonObject>
#include <KLocalizedString>
#include <KConfig>
#include <KConfigGroup>
class CalendarController::Private
{
......@@ -38,7 +37,7 @@ public:
};
CalendarController::CalendarController(QObject *parent)
: QObject(parent), m_storages(QMap<QString, FileStorage::Ptr>()), m_calendars(QMap<QString, MemoryCalendar::Ptr>()), m_downloadManager(new DonwloadManager), d(new Private)
: QObject(parent), m_storages(QMap<QString, KCalendarCore::FileStorage::Ptr>()), m_calendars(QMap<QString, KCalendarCore::MemoryCalendar::Ptr>()), m_downloadManager(new DonwloadManager), d(new Private)
{
loadSavedConferences();
connect(&(m_downloadManager->networkManager), SIGNAL(finished(QNetworkReply*)), SLOT(downloadFinished(QNetworkReply*)));
......@@ -149,14 +148,14 @@ QString CalendarController::filenameToPath(const QString &calendarId)
return basePath + "/kongress_" + calendarId + ".ics";
}
MemoryCalendar::Ptr CalendarController::createLocalCalendar(const QString &calendarId, const QByteArray &timeZoneId)
KCalendarCore::MemoryCalendar::Ptr CalendarController::createLocalCalendar(const QString &calendarId, const QByteArray &timeZoneId)
{
auto m_fullpath = calendarFile(calendarId);
auto tzId = QTimeZone::availableTimeZoneIds().contains(timeZoneId) ? timeZoneId : QTimeZone::systemTimeZoneId();
MemoryCalendar::Ptr calendar(new MemoryCalendar(tzId));
KCalendarCore::MemoryCalendar::Ptr calendar(new KCalendarCore::MemoryCalendar(tzId));
qDebug() << "Memory calendar " << calendarId << "(local) with timezone " << tzId << " has been created";
FileStorage::Ptr storage(new FileStorage(calendar));
KCalendarCore::FileStorage::Ptr storage(new KCalendarCore::FileStorage(calendar));
storage->setFileName(m_fullpath);
QFile calendarFile(m_fullpath);
......@@ -179,8 +178,8 @@ QVariantMap CalendarController::importCalendar(const QString &calendarId, const
QVariantMap result;
result["success"] = QVariant(false);
MemoryCalendar::Ptr calendar(new MemoryCalendar(QTimeZone::systemTimeZoneId()));
FileStorage::Ptr storage(new FileStorage(calendar));
KCalendarCore::MemoryCalendar::Ptr calendar(new KCalendarCore::MemoryCalendar(QTimeZone::systemTimeZoneId()));
KCalendarCore::FileStorage::Ptr storage(new KCalendarCore::FileStorage(calendar));
QVariantMap canCreateCheck = canCreateFile(calendarId);
......@@ -291,9 +290,9 @@ void CalendarController::downloadFinished(QNetworkReply *reply)
auto tz = availableTimezones.contains(m_downloadManager->calendarTzId) ? m_downloadManager->calendarTzId : QTimeZone::systemTimeZoneId();
addTzIdToConfig(m_downloadManager->calendarId, tz);
MemoryCalendar::Ptr calendar(new MemoryCalendar(tz));
KCalendarCore::MemoryCalendar::Ptr calendar(new KCalendarCore::MemoryCalendar(tz));
qDebug() << "Memory calendar " << m_downloadManager->calendarId << " (online) with timezone " << tz << " has been created";
FileStorage::Ptr storage(new FileStorage(calendar));
KCalendarCore::FileStorage::Ptr storage(new KCalendarCore::FileStorage(calendar));
storage->setFileName(filePath);
if (storage->load()) {
......@@ -325,7 +324,7 @@ bool CalendarController::saveToDisk(const QString &filename, QIODevice *data)
return true;
}
MemoryCalendar::Ptr CalendarController::memoryCalendar(const QString &calendarId) const
KCalendarCore::MemoryCalendar::Ptr CalendarController::memoryCalendar(const QString &calendarId) const
{
if (m_calendars.contains(calendarId)) {
return m_calendars[calendarId];
......@@ -369,8 +368,8 @@ void CalendarController::loadSavedConferences()
}
auto tz = tzIdFromConfig(calendarId);
MemoryCalendar::Ptr calendar(new MemoryCalendar(tz));
FileStorage::Ptr storage(new FileStorage(calendar));
KCalendarCore::MemoryCalendar::Ptr calendar(new KCalendarCore::MemoryCalendar(tz));
KCalendarCore::FileStorage::Ptr storage(new KCalendarCore::FileStorage(calendar));
storage->setFileName(filePath);
if (storage->load()) {
......
......@@ -26,8 +26,6 @@
#include <KCalendarCore/FileStorage>
#include <KCalendarCore/MemoryCalendar>
using namespace KCalendarCore;
struct DonwloadManager {
QString calendarId;
QByteArray calendarTzId;
......@@ -48,8 +46,8 @@ public:
QString calendars() const;
QString calendarFile(const QString &calendarId);
MemoryCalendar::Ptr createLocalCalendar(const QString &calendarId, const QByteArray &timeZoneId);
MemoryCalendar::Ptr memoryCalendar(const QString &calendarId) const;
KCalendarCore::MemoryCalendar::Ptr createLocalCalendar(const QString &calendarId, const QByteArray &timeZoneId);
KCalendarCore::MemoryCalendar::Ptr memoryCalendar(const QString &calendarId) const;
void createCalendarFromUrl(const QString &calendarId, const QUrl &url, const QByteArray &timeZoneId);
QVariantMap importCalendar(const QString &calendarId, const QString &sourcePath);
void deleteCalendar(const QString &calendarId);
......@@ -74,8 +72,8 @@ private:
void addTzIdToConfig(const QString &calendarId, const QByteArray &timeZoneId);
QByteArray tzIdFromConfig(const QString &calendarId) const;
QMap<QString, FileStorage::Ptr> m_storages;
QMap<QString, MemoryCalendar::Ptr> m_calendars;
QMap<QString, KCalendarCore::FileStorage::Ptr> m_storages;
QMap<QString, KCalendarCore::MemoryCalendar::Ptr> m_calendars;
DonwloadManager *m_downloadManager;
class Private;
......
......@@ -19,10 +19,10 @@
#include "eventcontroller.h"
#include "calendarcontroller.h"
#include "localcalendar.h"
#include <QDebug>
#include <KCalendarCore/Event>
#include <KCalendarCore/MemoryCalendar>
#include <KLocalizedString>
#include <QDebug>
EventController::EventController(QObject *parent) : QObject(parent), m_cal_controller(nullptr) {}
......@@ -48,9 +48,9 @@ void EventController::remove(LocalCalendar *calendar, const QVariantMap &eventDa
qDebug() << "Deleting event from calendar " << calendar->calendarId();
MemoryCalendar::Ptr memoryCalendar = calendar->memorycalendar();
KCalendarCore::MemoryCalendar::Ptr memoryCalendar = calendar->memorycalendar();
QString uid = eventData["uid"].toString();
Event::Ptr event = memoryCalendar->event(uid);
KCalendarCore::Event::Ptr event = memoryCalendar->event(uid);
memoryCalendar->deleteEvent(event);
bool deleted = false;
......@@ -76,13 +76,13 @@ QVariantMap EventController::addEdit(LocalCalendar *calendar, const QVariantMap
qDebug() << "\naddEdit:\tCreating event to calendar " << calendar->calendarId();
MemoryCalendar::Ptr memoryCalendar = calendar->memorycalendar();
KCalendarCore::MemoryCalendar::Ptr memoryCalendar = calendar->memorycalendar();
QDateTime now = QDateTime::currentDateTime();
QString uid = eventData["uid"].toString();
Event::Ptr event = memoryCalendar->event(uid);
KCalendarCore::Event::Ptr event = memoryCalendar->event(uid);
if (event == nullptr) {
event = Event::Ptr(new Event());
event = KCalendarCore::Event::Ptr(new KCalendarCore::Event());
}
event->setUid(uid);
......
......@@ -22,11 +22,9 @@
#include <KCalendarCore/MemoryCalendar>
#include <KLocalizedString>
using namespace KCalendarCore;
EventModel::EventModel(QObject *parent) :
QAbstractListModel(parent),
m_events(Event::List()),
m_events(KCalendarCore::Event::List()),
m_filterdt(QDate()),
m_category(QString()),
m_local_calendar(nullptr)
......@@ -247,18 +245,18 @@ void EventModel::loadEvents()
m_events.clear();
if (m_local_calendar != nullptr && m_local_calendar->memorycalendar() != nullptr && m_filterdt.isValid()) {
m_events = m_local_calendar->memorycalendar()->rawEventsForDate(m_filterdt, m_local_calendar->memorycalendar()->timeZone(), EventSortStartDate, SortDirectionAscending);
m_events = m_local_calendar->memorycalendar()->rawEventsForDate(m_filterdt, m_local_calendar->memorycalendar()->timeZone(), KCalendarCore::EventSortStartDate, KCalendarCore::SortDirectionAscending);
}
if (m_local_calendar != nullptr && m_local_calendar->memorycalendar() != nullptr && m_filterdt.isNull()) {
m_events = m_local_calendar->memorycalendar()->rawEvents(EventSortStartDate, SortDirectionAscending);
m_events = m_local_calendar->memorycalendar()->rawEvents(KCalendarCore::EventSortStartDate, KCalendarCore::SortDirectionAscending);
}
if (m_local_calendar != nullptr && !(m_category.isEmpty())) {
QStringList categories(m_category);
CalFilter *filter = new CalFilter();
KCalendarCore::CalFilter *filter = new KCalendarCore::CalFilter();
filter->setCategoryList(categories);
filter->setCriteria(CalFilter::ShowCategories);
filter->setCriteria(KCalendarCore::CalFilter::ShowCategories);
filter->apply(&m_events);
}
......@@ -289,7 +287,7 @@ int EventModel::repeatStopAfter(const int idx) const
ushort EventModel::repeatPeriodType(const int idx) const
{
if (!(m_events.at(idx)->recurs())) {
return Recurrence::rNone;
return KCalendarCore::Recurrence::rNone;
}
return m_events.at(idx)->recurrence()->recurrenceType();
......
......@@ -22,8 +22,6 @@
#include <QAbstractListModel>
#include <KCalendarCore/Event>
using namespace KCalendarCore;
class LocalCalendar;
class EventModel : public QAbstractListModel
......@@ -120,7 +118,7 @@ private:
QString formatStartEndTime(const QDateTime &startDtTime, const QDateTime &endDtTime) const;
QString formatStartEndDt(const QDateTime &startDtTime, const QDateTime &endDtTime, bool allDay) const;
Event::List m_events;
KCalendarCore::Event::List m_events;
QDate m_filterdt;
QString m_category;
LocalCalendar *m_local_calendar;
......
......@@ -23,8 +23,12 @@
#include "incidencealarmsmodel.h"
#include "localcalendar.h"
#include <QVector>
#include <KLocalizedString>
#include <QDebug>
#include <KLocalizedString>
#include <KCalendarCore/Alarm>
#include <KCalendarCore/Duration>
#include <KCalendarCore/MemoryCalendar>
#include <KCalendarCore/Incidence>
IncidenceAlarmsModel::IncidenceAlarmsModel(QObject *parent) : QAbstractListModel(parent), mAlarms(QVariantList())
{
......@@ -61,12 +65,12 @@ void IncidenceAlarmsModel::addAlarm(const int secondsFromStart)
QHash<QString, QVariant> alarmMap;
if (secondsFromStart % 86400 == 0) {
alarmMap["startOffsetValue"] = -1 * secondsFromStart / 86400;
alarmMap["startOffsetType"] = Duration::Days;
alarmMap["startOffsetType"] = KCalendarCore::Duration::Days;
} else {
alarmMap["startOffsetValue"] = -1 * secondsFromStart;
alarmMap["startOffsetType"] = Duration::Seconds;
alarmMap["startOffsetType"] = KCalendarCore::Duration::Seconds;
}
alarmMap["actionType"] = Alarm::Type::Display;
alarmMap["actionType"] = KCalendarCore::Alarm::Type::Display;
mAlarms.append(alarmMap);
endInsertRows();
......@@ -120,9 +124,9 @@ void IncidenceAlarmsModel::loadPersistentAlarms()
LocalCalendar *localCalendar = mAlarmProperties["calendar"].value<LocalCalendar *>();
QString uid = mAlarmProperties["uid"].toString();
MemoryCalendar::Ptr memCalendar;
Incidence::Ptr alarmIncidence;
Alarm::List persistentAlarms = Alarm::List();
KCalendarCore::MemoryCalendar::Ptr memCalendar;
KCalendarCore::Incidence::Ptr alarmIncidence;
KCalendarCore::Alarm::List persistentAlarms = KCalendarCore::Alarm::List();
qDebug() << "\nloadPersistentAlarms: uid" << uid;
......@@ -135,7 +139,7 @@ void IncidenceAlarmsModel::loadPersistentAlarms()
persistentAlarms = alarmIncidence->alarms();
}
Alarm::List::const_iterator alarmItr = persistentAlarms.constBegin();
KCalendarCore::Alarm::List::const_iterator alarmItr = persistentAlarms.constBegin();
while (alarmItr != persistentAlarms.constEnd()) {
QHash<QString, QVariant> alarmMap;
......@@ -163,10 +167,10 @@ QString IncidenceAlarmsModel::alarmStartOffsetType(const int idx) const
int durationType = alarm["startOffsetType"].value<int>();
switch (durationType) {
case Duration::Type::Days: {
case KCalendarCore::Duration::Type::Days: {
return QString(i18n("days before start"));
}
case Duration::Type::Seconds: {
case KCalendarCore::Duration::Type::Seconds: {
return QString(i18n("seconds before start"));
}
default: {
......@@ -211,7 +215,7 @@ QString IncidenceAlarmsModel::displayText(const int idx) const
if (durationValue == 0) {
return i18n("At start time");
}
if (durationType == Duration::Type::Days) {
if (durationType == KCalendarCore::Duration::Type::Days) {
return i18np("1 day before start", "%1 days before start", durationValue);
}
......
......@@ -20,8 +20,6 @@
#define INCIDENCEALARMSMODEL_H
#include <QAbstractListModel>
#include <KCalendarCore/Alarm>
#include <KCalendarCore/Duration>
#include <QVariantList>
#include <QVariantMap>
#include <QHash>
......
......@@ -23,8 +23,6 @@
#include <QMetaType>
#include <KLocalizedString>
using namespace KCalendarCore;
LocalCalendar::LocalCalendar(QObject *parent)
: QObject(parent), m_calendarInfo(QVariantMap()), m_calendar(nullptr), m_cal_controller(nullptr)
{
......@@ -32,7 +30,7 @@ LocalCalendar::LocalCalendar(QObject *parent)
LocalCalendar::~LocalCalendar() = default;
MemoryCalendar::Ptr LocalCalendar::memorycalendar() const
KCalendarCore::MemoryCalendar::Ptr LocalCalendar::memorycalendar() const
{
return m_calendar;
}
......
......@@ -20,10 +20,8 @@
#define LOCALCALENDAR_H
#include <QSharedPointer>
#include <KCalendarCore/MemoryCalendar>
#include <QVariantMap>
using namespace KCalendarCore;
#include <KCalendarCore/MemoryCalendar>
class CalendarController;
......@@ -31,7 +29,7 @@ class LocalCalendar : public QObject
{
Q_OBJECT
Q_PROPERTY(QVariantMap calendarInfo READ calendarInfo WRITE setCalendarInfo NOTIFY calendarInfoChanged)
Q_PROPERTY(QSharedPointer<MemoryCalendar> memorycalendar READ memorycalendar NOTIFY memorycalendarChanged)
Q_PROPERTY(QSharedPointer<KCalendarCore::MemoryCalendar> memorycalendar READ memorycalendar NOTIFY memorycalendarChanged)
Q_PROPERTY(QStringList categories READ categories NOTIFY categoriesChanged)
Q_PROPERTY(QString loadDateStr READ loadDateStr NOTIFY loadDateStrChanged)
Q_PROPERTY(CalendarController *calendarController READ calendarController WRITE setCalendarController NOTIFY calendarControllerChanged)
......@@ -43,7 +41,7 @@ public:
QVariantMap calendarInfo() const;
void setCalendarInfo(const QVariantMap &calendarInfoMap);
MemoryCalendar::Ptr memorycalendar() const;
KCalendarCore::MemoryCalendar::Ptr memorycalendar() const;
QStringList categories() const;
CalendarController *calendarController() const;
......@@ -66,7 +64,7 @@ Q_SIGNALS:
private:
QVariantMap m_calendarInfo;
MemoryCalendar::Ptr m_calendar;
KCalendarCore::MemoryCalendar::Ptr m_calendar;
CalendarController *m_cal_controller;
};
#endif // LOCALCALENDAR_H
......
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