Skip to content

Commit

Permalink
Merge branch 'jb10055' into 'master'
Browse files Browse the repository at this point in the history
[nemo-qml-plugin-calendar] Emit error if event cannot be loaded. Contributes to JB#10055

See merge request mer-core/nemo-qml-plugin-calendar!63
  • Loading branch information
chriadam committed Nov 17, 2020
2 parents f317834 + 8ba27b0 commit c850001
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/calendareventquery.cpp
Expand Up @@ -37,7 +37,7 @@
#include "calendarutils.h"

CalendarEventQuery::CalendarEventQuery()
: mIsComplete(true), mOccurrence(0), mAttendeesCached(false)
: mIsComplete(true), mOccurrence(0), mAttendeesCached(false), mEventError(false)
{
connect(CalendarManager::instance(), SIGNAL(dataUpdated()), this, SLOT(refresh()));
connect(CalendarManager::instance(), SIGNAL(storageModified()), this, SLOT(refresh()));
Expand Down Expand Up @@ -161,7 +161,7 @@ void CalendarEventQuery::componentComplete()
refresh();
}

void CalendarEventQuery::doRefresh(CalendarData::Event event)
void CalendarEventQuery::doRefresh(CalendarData::Event event, bool eventError)
{
// The value of mUid may have changed, verify that we got what we asked for
if (event.isValid() && (event.uniqueId != mUid || event.recurrenceId != mRecurrenceId))
Expand Down Expand Up @@ -212,6 +212,16 @@ void CalendarEventQuery::doRefresh(CalendarData::Event event)
mAttendeesCached = true;
emit attendeesChanged();
}

if (mEventError != eventError) {
mEventError = eventError;
emit eventErrorChanged();
}
}

bool CalendarEventQuery::eventError() const
{
return mEventError;
}

KDateTime CalendarEventQuery::recurrenceId()
Expand Down
7 changes: 6 additions & 1 deletion src/calendareventquery.h
Expand Up @@ -100,6 +100,7 @@ class CalendarEventQuery : public QObject, public QQmlParserStatus
Q_PROPERTY(QObject *event READ event NOTIFY eventChanged)
Q_PROPERTY(QObject *occurrence READ occurrence NOTIFY occurrenceChanged)
Q_PROPERTY(QList<QObject*> attendees READ attendees NOTIFY attendeesChanged)
Q_PROPERTY(bool eventError READ eventError NOTIFY eventErrorChanged)

public:
CalendarEventQuery();
Expand All @@ -121,10 +122,12 @@ class CalendarEventQuery : public QObject, public QQmlParserStatus

QList<QObject*> attendees();

bool eventError() const;

virtual void classBegin();
virtual void componentComplete();

void doRefresh(CalendarData::Event event);
void doRefresh(CalendarData::Event event, bool eventError);

signals:
void uniqueIdChanged();
Expand All @@ -133,6 +136,7 @@ class CalendarEventQuery : public QObject, public QQmlParserStatus
void occurrenceChanged();
void attendeesChanged();
void startTimeChanged();
void eventErrorChanged();

// Indicates that the event UID has changed in database, event has been moved between notebooks.
// The property uniqueId will not be changed, the data pointer properties event and occurrence
Expand All @@ -151,6 +155,7 @@ private slots:
CalendarData::Event mEvent;
CalendarEventOccurrence *mOccurrence;
bool mAttendeesCached;
bool mEventError;
QList<CalendarData::Attendee> mAttendees;
};

Expand Down
12 changes: 11 additions & 1 deletion src/calendarmanager.cpp
Expand Up @@ -465,9 +465,19 @@ void CalendarManager::doAgendaAndQueryRefresh()
if (event.uniqueId.isEmpty()
&& !mLoadedQueries.contains(eventUid)
&& !missingUidList.contains(eventUid)) {
// we haven't yet loaded this event from storage.
missingUidList << eventUid;
query->doRefresh(event, false);
} else if (event.uniqueId.isEmpty() && mLoadedQueries.contains(eventUid)) {
// the event was unable to be loaded from storage,
// even though we have attempted to load its data.
// most likely, the event has been deleted.
query->doRefresh(event, true);
} else {
// we have loaded this event from storage.
// refresh the query based on the loaded event data.
query->doRefresh(event, false);
}
query->doRefresh(event);

if (mResetPending && !missingUidList.contains(eventUid))
missingUidList << eventUid;
Expand Down

0 comments on commit c850001

Please sign in to comment.