Skip to content

Commit

Permalink
[nemo-qml-plugin-calendar] Add count property to agenda model
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Kennedy committed Jun 19, 2013
1 parent 102346f commit 9680f37
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/calendaragendamodel.cpp
Expand Up @@ -90,6 +90,9 @@ void NemoCalendarAgendaModel::load()

beginResetModel();
qDeleteAll(mEvents);

int oldSize = mEvents.size();

mEvents.clear();
mEvents.reserve(eventList.size());

Expand All @@ -99,6 +102,14 @@ void NemoCalendarAgendaModel::load()
}

endResetModel();

if (oldSize != mEvents.size())
emit countChanged();
}

int NemoCalendarAgendaModel::count() const
{
return mEvents.size();
}

int NemoCalendarAgendaModel::rowCount(const QModelIndex &index) const
Expand Down
6 changes: 5 additions & 1 deletion src/calendaragendamodel.h
Expand Up @@ -41,6 +41,8 @@ class NemoCalendarEvent;
class NemoCalendarAgendaModel : public NemoCalendarAbstractModel
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(QDate startDate READ startDate WRITE setStartDate NOTIFY startDateChanged)

public:
enum {
Expand All @@ -52,14 +54,16 @@ class NemoCalendarAgendaModel : public NemoCalendarAbstractModel
explicit NemoCalendarAgendaModel(QObject *parent = 0);
virtual ~NemoCalendarAgendaModel();

Q_PROPERTY(QDate startDate READ startDate WRITE setStartDate NOTIFY startDateChanged)
QDate startDate() const;
void setStartDate(const QDate &startDate);

int count() const;

int rowCount(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role) const;

signals:
void countChanged();
void startDateChanged();

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
Expand Down

0 comments on commit 9680f37

Please sign in to comment.