diff -r 2c54b51f39c4 -r bb2d3e476f29 calendarui/views/dayview/src/calendaymodel.cpp --- a/calendarui/views/dayview/src/calendaymodel.cpp Mon Jul 26 13:54:38 2010 +0530 +++ b/calendarui/views/dayview/src/calendaymodel.cpp Mon Aug 09 18:30:52 2010 +0530 @@ -15,99 +15,92 @@ * */ - - +// System includes #include #include + +// User includes #include "calendaymodel.h" /*! - BC Day Model constructor - \a date defined day for which entries will be fetched \a services is handle to - organizer services \a parent + BC Day Model constructor + \a date defined day for which entries will be fetched \a services is handle to + organizer services \a parent */ -CalenDayModel::CalenDayModel(const QDateTime &date, MCalenServices &services, - QObject *parent) - : QAbstractListModel(parent), mServices(services) +CalenDayModel::CalenDayModel(const QDateTime &date, MCalenServices &services, QObject *parent) : + QAbstractListModel(parent), mServices(services) { - if (date.isValid()) - { - loadAndStoreInstances(date); - } + if (date.isValid()) { + loadAndStoreInstances(date); + } } /* - \reimp + \reimp */ -int CalenDayModel::rowCount( const QModelIndex &parent ) const +int CalenDayModel::rowCount(const QModelIndex &parent) const { Q_UNUSED( parent ) return mEntryList.count(); } /* - \reimp + \reimp */ QVariant CalenDayModel::data(const QModelIndex &index, int role) const { - if (!index.isValid()) - { + if (!index.isValid()) { return QVariant(); - } + } - if (index.row() >= mEntryList.count()) - { + if (index.row() >= mEntryList.count()) { return QVariant(); - } + } - if (role == CalenDayEntry) - { + if (role == CalenDayEntry) { return mEntryList.at(index.row()); - } - else - { + } + else { return QVariant(); - } + } } /*! - Resets model. Old events are removed. Evenets for given day are fetched. - \a date defined day for which entries will be fetched + Resets model. Old events are removed. Evenets for given day are fetched. + \a date defined day for which entries will be fetched */ void CalenDayModel::refreshModel(const QDateTime &date) { - beginResetModel(); - loadAndStoreInstances(date); - endResetModel(); -} - - -/*! - Fetches entries via. organizer API and stores it in member container - */ -void CalenDayModel::loadAndStoreInstances(const QDateTime &date) -{ - mDateTime = date; - //Filter flags - AgendaUtil::FilterFlags filter = AgendaUtil::FilterFlags( - AgendaUtil::IncludeAppointments | AgendaUtil::IncludeEvents); - QList list; - // Fetch the instance list from the agenda interface - list = mServices.agendaInterface()->createEntryIdListForDay(date, filter); - - mEntryList.clear(); - - foreach(AgendaEntry entry, list) - { - mEntryList.append(QVariant::fromValue(entry)); - } + beginResetModel(); + loadAndStoreInstances(date); + endResetModel(); } /*! - Retruns date (day). Model holds events for this day. + Fetches entries via. organizer API and stores it in member container + */ +void CalenDayModel::loadAndStoreInstances(const QDateTime &date) +{ + mDateTime = date; + //Filter flags + AgendaUtil::FilterFlags filter = AgendaUtil::FilterFlags(AgendaUtil::IncludeAppointments + | AgendaUtil::IncludeEvents); + QList list; + // Fetch the instance list from the agenda interface + list = mServices.agendaInterface()->createEntryIdListForDay(date, filter); + + mEntryList.clear(); + + foreach(AgendaEntry entry, list){ + mEntryList.append(QVariant::fromValue(entry)); + } +} + +/*! + Retruns date (day). Model holds events for this day. */ QDateTime CalenDayModel::modelDate() const { - return mDateTime; + return mDateTime; }