Commit 2f6b3aa2 authored by David Jarvie's avatar David Jarvie
Browse files

Fix erroneous output of terminal error message on disabling a calendar

parent c131ef34
Pipeline #57350 skipped
KAlarm Change Log
=== Version 3.2.0 (KDE Applications 21.04) --- 19 February 2021 ===
=== Version 3.2.0 (KDE Applications 21.04) --- 2 April 2021 ===
* Remove KAlarm Akonadi resource code.
* Rename Preferences 'Edit' tab to 'Alarm Defaults'.
* Add default sound volume setting to Preferences dialogue.
* Fix erroneous output of terminal error message on disabling a calendar.
=== Version 3.1.3 (KDE Applications 20.12.3) --- 19 February 2021 ===
* Fix error creating alarm from command line if the only active alarm calendar is not the default [KDE Bug 417108].
......
......@@ -257,9 +257,9 @@ QList<KAEvent> Resource::events() const
return mResource.isNull() ? QList<KAEvent>() : mResource->events();
}
KAEvent Resource::event(const QString& eventId) const
KAEvent Resource::event(const QString& eventId, bool allowDisabled) const
{
return mResource.isNull() ? KAEvent() : mResource->event(eventId);
return mResource.isNull() ? KAEvent() : mResource->event(eventId, allowDisabled);
}
bool Resource::containsEvent(const QString& eventId) const
......
......@@ -314,9 +314,11 @@ public:
/** Return the event with the given ID, provided its alarm type is enabled for
* the resource.
* @param eventId ID of the event to return.
* @param allowDisabled Return the event even if its alarm type is disabled.
* @return The event, or invalid event if not found or alarm type is disabled.
*/
KAEvent event(const QString& eventId) const;
KAEvent event(const QString& eventId, bool allowDisabled = false) const;
/** Return whether the resource contains the event whose ID is given, provided
* the event's alarm type is enabled for the resource.
......
/*
* resourcetype.cpp - base class for an alarm calendar resource type
* Program: kalarm
* SPDX-FileCopyrightText: 2019-2020 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2019-2021 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -114,11 +114,11 @@ QList<KAEvent> ResourceType::events() const
* Return the event with the given ID, provided its alarm type is enabled for
* the resource.
*/
KAEvent ResourceType::event(const QString& eventId) const
KAEvent ResourceType::event(const QString& eventId, bool allowDisabled) const
{
auto it = mEvents.constFind(eventId);
if (it != mEvents.constEnd()
&& (it.value().category() & enabledTypes()))
&& (allowDisabled || (it.value().category() & enabledTypes())))
return it.value();
return KAEvent();
}
......
......@@ -353,9 +353,11 @@ public:
/** Return the event with the given ID, provided its alarm type is enabled for
* the resource.
* @param eventId ID of the event to return.
* @param allowDisabled Return the event even if its alarm type is disabled.
* @return The event, or invalid event if not found or alarm type is disabled.
*/
KAEvent event(const QString& eventId) const;
KAEvent event(const QString& eventId, bool allowDisabled = false) const;
using QObject::event; // prevent "hidden" warning
/** Return whether the resource contains the event whose ID is given, provided
......
......@@ -93,7 +93,7 @@ void ResourcesCalendar::removeKAEvents(ResourceId key, bool closing, CalEvent::T
QSet<QString>& eventIds = rit.value();
for (auto it = eventIds.constBegin(); it != eventIds.constEnd(); ++it)
{
const KAEvent event = resource.event(*it);
const KAEvent event = resource.event(*it, true);
bool remove = (event.resourceId() != key);
if (remove)
qCCritical(KALARM_LOG) << "ResourcesCalendar::removeKAEvents: Event" << event.id() << ", resource" << event.resourceId() << "Indexed under resource" << key;
......
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