Skip to content

Commit

Permalink
[nemo-qml-plugin-calendar] Wait for completion before populating Agen…
Browse files Browse the repository at this point in the history
…daModel
  • Loading branch information
Aaron Kennedy committed Jul 10, 2013
1 parent f4f842a commit cf8fe38
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/calendaragendamodel.cpp
Expand Up @@ -43,7 +43,7 @@

NemoCalendarAgendaModel::NemoCalendarAgendaModel(QObject *parent)
: QAbstractListModel(parent), mBuffer(0), mRefreshingModel(false),
mRerefreshNeeded(false)
mRerefreshNeeded(false), mIsComplete(true)
{
mRoleNames[EventObjectRole] = "event";
mRoleNames[OccurrenceObjectRole] = "occurrence";
Expand Down Expand Up @@ -103,6 +103,9 @@ void NemoCalendarAgendaModel::setEndDate(const QDate &endDate)

void NemoCalendarAgendaModel::refresh()
{
if (!mIsComplete)
return;

if (mRefreshingModel) {
mRerefreshNeeded = true;
return;
Expand Down Expand Up @@ -271,3 +274,13 @@ QVariant NemoCalendarAgendaModel::data(const QModelIndex &index, int role) const
}
}

void NemoCalendarAgendaModel::classBegin()
{
mIsComplete = false;
}

void NemoCalendarAgendaModel::componentComplete()
{
mIsComplete = true;
refresh();
}
8 changes: 7 additions & 1 deletion src/calendaragendamodel.h
Expand Up @@ -34,14 +34,16 @@
#define CALENDARAGENDAMODEL_H

#include <QDate>
#include <QQmlParserStatus>
#include <QAbstractListModel>

class NemoCalendarEvent;
class NemoCalendarEventOccurrence;

class NemoCalendarAgendaModel : public QAbstractListModel
class NemoCalendarAgendaModel : public QAbstractListModel, public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(QDate startDate READ startDate WRITE setStartDate NOTIFY startDateChanged)
Q_PROPERTY(QDate endDate READ endDate WRITE setEndDate NOTIFY endDateChanged)
Expand Down Expand Up @@ -76,6 +78,9 @@ class NemoCalendarAgendaModel : public QAbstractListModel
int rowCount(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role) const;

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

signals:
void countChanged();
void startDateChanged();
Expand All @@ -102,6 +107,7 @@ private slots:

bool mRefreshingModel:1;
bool mRerefreshNeeded:1;
bool mIsComplete:1;
};

#endif // CALENDARAGENDAMODEL_H

0 comments on commit cf8fe38

Please sign in to comment.