Akonadi Calendar Dataengine
Aaron J. Seigo
aseigo at kde.org
Tue Apr 6 21:07:50 CEST 2010
On April 6, 2010, Frederik Gladhorn wrote:
> What if I get a second sourceRequestEvent() for the same source string? Do
if the source already exists, it won't get called again.
sourceRequestEvent is *only* called when the source does not exist. once it
exists, calls are made to updateSourEvent as needed (e.g. due to a connected
visualization requesting a polling interval when calling connectSource). the
DataEngine may also decide to update the source on its own.
there are a few issues i see in the current code in playground:
a) eventData["StartDate"] = model->index(row,
Akonadi::CalendarModel::DateTimeStart).data().toDateTime().toString();
that last toString() probably isn't needed. puting the QDateTime object in
there is just fine.
b) this is in akonadiCalendarSourceRequest, but it should be in
initAkonadiCalendar (to avoid multiple connections):
connect(m_calendarModel, SIGNAL(rowsInserted(QModelIndex, int , int )),
this, SLOT(calendarModelRowsInserted(QModelIndex,int,int)));
c) when a source is requested, akonadiCalendarSourceRequest is called. this
creates a new Akonadi::DateRangeFilterProxyModel and that remains around for
the lifetime of the engine.
what i'd recommend here is creating a subclass of Plasma::DataContainer that
has the Akonadi::DateRangeFilterProxyModel as a member. then in
sourceRequetEvent, the engine could just do something like:
initAkonadiCalendar();
addSource(new AkonadiDateRangeSource(name, start, end));
return true;
this hypothetical AkonadiDateRangeSource class would subclass
Plasma::DataContainer, call setObjectName(name) in its constructor, connect
the signals to itself which call setData() on itself as appropriate and then
setNeedsUpdate() (which schedules the signals for the visualizations that are
connected).
this way, when the source goes out of use (e.g. all the visualizations
disconnect from it) then the Akonadi::DateRangeFilterProxyModel would also get
deleted. it would also move all of the Akonadi code related to the events date
ranges out into its own class (nice for code clarity)
--
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA EE75 D6B7 2EB1 A7F1 DB43
KDE core developer sponsored by Qt Development Frameworks
More information about the Plasma-devel
mailing list