QML Calendar, issues with making a selection

Mark markg85 at gmail.com
Tue Jul 17 13:46:47 UTC 2012


Hi,

I also posted this on Qt interest some 9 days ago, but there doesn't
seem to be much people there that might know a good way to solve this
issue. Thus asking on Plasma since the plasma folks are doing a lot of
QML Development lately as well. My intention with this calendar is to
take the good ideas from iCal and have a modern looking alternative
(replacement?) for KOrganizer.

I'm developing a calendar in QML and thus far it seems to going quite well.
Making a view with 12 months visible or a full month to select a day
isn't an issue. Works wonderful in QML.

The place where i hit real big QML issues (or actually the lack of
components) is when i want to make the day overview. Go to google
calendar or the calendar in your emailing application and you notice
that you can select some cells in the day overview. Those selected
cells will become the "appointment" or event or whatever. That part is
close to impossible to implement in the current QML.

Take this as an example if you don't know what i mean:
http://photos.appleinsider.com/Lionical4.png

What i want to do is the following. I want users to be able to select
some cells in QML which will then be a event and stored somewhere.
Obviously the user can also have overlapping events or multiple events
at the same time - like other calendars allow as well.

The issues i run into are:
- dynamic elements don't have a ID thus that can't be used. That
prevents selecting it and dragging/dropping the event on another date.
- there is no sane way to select some elements in a list or repeater
without doing all kinds of tricks
- once the selection is made, how can i lay an item on top of that
selection? Dynamic element?
- there don't seem to be any elements in QML that are suited for this

So, is Qt 5 going to be of help here in making it easier? I doubt
that. Is there another way how i can make this work? Or do i need to
make special QML elements in C++ that are maintained in C++ as well
(id wise)? I'd hate to make that in C++ if it's even possible. It is
possible with QWidgets, but that kinda defeats the point of using QML.

Right now i only see one possible "kind of clean" way to do this.
Maintain all the events in C++ (which i was already planning on
doing), but also maintaining where every event should be placed in X
and Y. I wasn't planning on doing that before.. So that means that the
C++ side decides where a "event" is going to be placed and how big it
is. The QML side will then simply be used to put an element on those
coordinates. I'm not sure - at all - how this is going to work when i
want to drag/drop an even to some later/earlier point or make the
duration longer/shorter. Originally my plan was to only proved a start
and end time from the C++ side and then use QML to put the elements at
those time slots. That will work somewhat, but will become a real pain
when you have overlapping events since every event is made dynamically
thus i can't reparent or use anything that needs an id. The
"advantage" of C++ here is that i can fairly easy figure out which
components will overlap and apply whatever i want to apply.

I hope this makes some sense since it's quite difficult to describe the issue.
Incase you want to test my current testing code, clone:
git://gitorious.org/qmlcalendar/master.git

in main.qml uncomment:

CalendarDay
{
        anchors.fill: parent
}

And comment the CalenderMonth part.

Cheers,
Mark


More information about the Plasma-devel mailing list