Commit 82bbe77c authored by David Jarvie's avatar David Jarvie
Browse files

Convert merged kalarmcal files for use within kalarm repo

Remove unused functions and variables
parent 9e560f10
Pipeline #151021 passed with stage
in 2 minutes and 56 seconds
......@@ -19,7 +19,6 @@ add_library(kalarmprivate)
target_sources(kalarmprivate PRIVATE
${kalarmcal_common_SRCS}
akonadi.cpp
alarmtext.cpp
datetime.cpp
identities.cpp
......@@ -30,7 +29,6 @@ target_sources(kalarmprivate PRIVATE
repetition.cpp
version.cpp
akonadi.h
alarmtext.h
datetime.h
identities.h
......
/*!
* @mainpage The KAlarm client library
* @mainpage The KAlarm calendar library
*
* @section purpose Purpose
*
......@@ -25,9 +25,6 @@
* QDateTime. The DateTime class is similar to KADateTime but with a
* configurable start-of-day time for date-only times.
*
* Three Akonadi attributes, for Collections and Items, are provided by
* CollectionAttribute, CompatibilityAttribute and EventAttribute classes.
*
* @authors
* David Jarvie \<djarvie@kde.org\>
*
......@@ -35,5 +32,5 @@
* @lgpl
*/
// DOXYGEN_PROJECTNAME=KAlarm Library
// DOXYGEN_PROJECTNAME=KAlarm Calendar Library
// DOXYGEN_REFERENCES=kdecore kcalendarcore kholidays kpimidentities akonadi
/*
* akonadi.cpp - Akonadi object functions
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* Program: kalarm
* SPDX-FileCopyrightText: 2011-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "akonadi.h"
#include "kaevent.h"
#include <Akonadi/Item>
namespace KAlarmCal
{
/******************************************************************************
* Initialise an Item with the event.
* Note that the event is not updated with the Item ID.
* Reply = true if successful,
* false if event's category does not match collection's mime types.
*/
bool setItemPayload(Akonadi::Item& item, const KAEvent& event, const QStringList& collectionMimeTypes)
{
QString mimetype;
switch (event.category())
{
case CalEvent::ACTIVE: mimetype = MIME_ACTIVE; break;
case CalEvent::ARCHIVED: mimetype = MIME_ARCHIVED; break;
case CalEvent::TEMPLATE: mimetype = MIME_TEMPLATE; break;
default: Q_ASSERT(0); return false;
}
if (!collectionMimeTypes.contains(mimetype))
return false;
item.setMimeType(mimetype);
item.setPayload<KAEvent>(event);
return true;
}
}
// vim: et sw=4:
/*
* akonadi.h - Akonadi object functions
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* Program: kalarm
* SPDX-FileCopyrightText: 2011, 2019 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once
#include "kalarmcal_export.h"
#include <QStringList>
namespace Akonadi
{
class Item;
}
namespace KAlarmCal
{
class KAEvent;
/** Initialise an Akonadi::Item with the event's data.
* Note that the event is not updated with the Item ID, and the Item is not
* added to the Collection.
* @param item the Item to initialise.
* @param event the event whose data will be used to initialise the Item.
* @param collectionMimeTypes the mime types for the Collection which will contain the Item.
* @return @c true if successful; @c false if the event's category does not match the
* collection's mime types.
*/
KALARMCAL_EXPORT bool setItemPayload(Akonadi::Item& item, const KAEvent& event, const QStringList& collectionMimeTypes);
}
// vim: et sw=4:
......@@ -16,8 +16,6 @@
#include <KCalendarCore/Calendar>
#include <KCalendarCore/Event>
#include <Akonadi/Collection>
#include <QByteArray>
#include <QStringList>
#include <QDebug>
......@@ -36,7 +34,7 @@ extern const QLatin1String KALARMCAL_EXPORT MIME_ARCHIVED; //!< The mime type f
extern const QLatin1String KALARMCAL_EXPORT MIME_TEMPLATE; //!< The mime type for KAlarm alarm templates
/** Declaration type for a calendar resource ID. */
using ResourceId = Akonadi::Collection::Id;
using ResourceId = qint64;
/**
* @short Class representing attributes of a KAlarm calendar.
......
......@@ -242,7 +242,6 @@ public:
QString mEventID; // UID: KCalendarCore::Event unique ID
QMap<QByteArray, QString> mCustomProperties; // KCalendarCore::Event's non-KAlarm custom properties
Akonadi::Item::Id mItemId{-1}; // Akonadi::Item ID for this event
mutable ResourceId mResourceId{-1}; // ID of resource containing the event, or for a displaying event,
// saved resource ID (not the resource the event is in)
QString mName; // name of the alarm
......@@ -1012,7 +1011,6 @@ void KAEventPrivate::copy(const KAEventPrivate& event)
mCommandError = event.mCommandError;
mEventID = event.mEventID;
mCustomProperties = event.mCustomProperties;
mItemId = event.mItemId;
mResourceId = event.mResourceId;
mName = event.mName;
mText = event.mText;
......@@ -1678,33 +1676,12 @@ void KAEvent::setResourceId(ResourceId id)
d->mResourceId = id;
}
void KAEvent::setResourceId_const(ResourceId id) const
{
d->mResourceId = id;
}
ResourceId KAEvent::resourceId() const
{
// A displaying alarm contains the event's original resource ID
return d->mDisplaying ? -1 : d->mResourceId;
}
void KAEvent::setCollectionId(Akonadi::Collection::Id id)
{
setResourceId(id);
}
void KAEvent::setCollectionId_const(Akonadi::Collection::Id id) const
{
setResourceId_const(id);
}
Akonadi::Collection::Id KAEvent::collectionId() const
{
// A displaying alarm contains the event's original collection ID
return d->mDisplaying ? -1 : d->mResourceId;
}
void KAEvent::setCompatibility(KACalendar::Compat c)
{
d->mCompatibility = c;
......@@ -3337,7 +3314,6 @@ bool KAEventPrivate::setDisplaying(const KAEventPrivate& event, KAAlarm::Type al
*this = event;
// Change the event ID to avoid duplicating the same unique ID as the original event
setCategory(CalEvent::DISPLAYING);
mItemId = -1; // the display event doesn't have an associated Item
mResourceId = resourceId; // original resource ID which contained the event
mDisplayingDefer = showDefer;
mDisplayingEdit = showEdit;
......@@ -3694,8 +3670,7 @@ bool KAEventPrivate::compare(const KAEventPrivate& other, KAEvent::Comparison co
}
if (comparison & KAEvent::Compare::UserSettable)
{
if (mItemId != other.mItemId
|| mResourceId != other.mResourceId)
if (mResourceId != other.mResourceId)
return false;
}
if (comparison & KAEvent::Compare::CurrentState)
......@@ -3928,7 +3903,6 @@ void KAEventPrivate::dumpDebug() const
qCDebug(KALARMCAL_LOG) << "-- mArchiveRepeatAtLogin:" << mArchiveRepeatAtLogin;
qCDebug(KALARMCAL_LOG) << "-- mConfirmAck:" << mConfirmAck;
qCDebug(KALARMCAL_LOG) << "-- mEnabled:" << mEnabled;
qCDebug(KALARMCAL_LOG) << "-- mItemId:" << mItemId;
qCDebug(KALARMCAL_LOG) << "-- mResourceId:" << mResourceId;
qCDebug(KALARMCAL_LOG) << "-- mCompatibility:" << mCompatibility;
qCDebug(KALARMCAL_LOG) << "-- mReadOnly:" << mReadOnly;
......
......@@ -17,7 +17,6 @@
#include "kacalendar.h"
#include "repetition.h"
#include <Akonadi/Collection>
#include <Akonadi/Item>
#include <KCalendarCore/Calendar>
#include <KCalendarCore/Person>
......@@ -439,38 +438,9 @@ public:
/** Return the revision number of the event (SEQUENCE property in iCalendar). */
int revision() const;
/** Set the ID of the Akonadi Collection which contains the event.
* @see setResourceId() is the generic form of this method.
*/
void setCollectionId(Akonadi::Collection::Id id);
/** Set the ID of the calendar resource which contains the event. */
void setResourceId(ResourceId id);
/** Set the ID of the Akonadi Collection which contains the event.
* @warning This is a const method, which means that any other instance
* which references the same shared data will also be
* updated. It is designed to be used when a KAEvent is
* being created from an Akonadi Item, to avoid unnecessary
* copying. Use with caution!
* @see setResourceId_const() is the generic form of this method.
*/
void setCollectionId_const(Akonadi::Collection::Id id) const;
/** Set the ID of the Akonadi Collection which contains the event.
* @warning This is a const method, which means that any other instance
* which references the same shared data will also be
* updated. It is designed to be used when a KAEvent is
* being created from an Akonadi Item, to avoid unnecessary
* copying. Use with caution!
*/
void setResourceId_const(ResourceId id) const;
/** Return the ID of the Akonadi Collection which contains the event.
* @see resourceId() is the generic form of this method.
*/
Akonadi::Collection::Id collectionId() const;
/** Return the ID of the calendar resource which contains the event. */
ResourceId resourceId() const;
......
......@@ -44,8 +44,8 @@ public:
/** Return whether calendar migration/creation at initialisation has completed. */
static bool isMigrationComplete();
/** Check for, and remove, any duplicate Akonadi resources, i.e. those which
* use the same calendar file/directory.
/** Check for, and remove, any duplicate resources, i.e. those which use
* the same calendar file/directory.
*/
static void removeDuplicateResources();
......
......@@ -11,6 +11,7 @@
#include "kalarmcalendar/kacalendar.h"
#include <Akonadi/ServerManager>
#include <Akonadi/Collection>
class KJob;
namespace Akonadi { class CollectionFetchJob; }
......
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