Nemo-qml-plugin-calendar timeline for harbour?

I’ve been asked repeatedly about implementing previously available Fahrplan departure times to calendar functionality. Currently that is implemented in dated mkal / kcalendar methods that I’m not so keen to support if there is a middle way. Also, the direct approach won’t get into harbour.

Now, as I understand it, the qml calendar plugin is also still not allowed in harbour? Is there a time line for this?

For the time being I’m probably going to hack a temp file to import method a’la Sailfish.Share API Documentation
But I’d go nemo-qml if there is some chance it will make into harbour in the near future.

1 Like

I’m trying to mitigate a full rewrite of:

My assumption is that the plugin approach wouldn’t require tracking the internals of the Calendar libraries.

Can you explain what you want to achieve here ? I mean, I can read the code, and from a very quick overview, it seems that you would like to add an event to a calendar.

The way it is written looks good to me. You just have to remove the KDateTime stuff that were from KDE3-4 era. Don’t hesitate to ask me whatever you need to understand the code.

The up-to-date way would be:

mKCal::ExtendedCalendar::Ptr calendar( new mKCal::ExtendedCalendar( QTimeZone::utc() ) );
    mKCal::ExtendedStorage::Ptr storage = mKCal::ExtendedCalendar::defaultStorage( calendar );
    if (storage->open()) {
        QString uid = settings.value("Calendar/notebookUID").toString();
        mKCal::Notebook::Ptr notebook = storage->notebook(uid);

        if (!notebook) {
            notebook = storage->defaultNotebook();
        }

        if (notebook) {
            KCalendarCore::Event::Ptr event( new KCalendarCore::Event() );
            event->setSummary(calendarEntryTitle);
            event->setDescription(calendarEntryDesc);
            event->setDtStart( m_result->departureDateTime() );
            event->setDtEnd( m_result->arrivalDateTime() );
            calendar->addEvent( event, notebook->uid() );
            storage->save();
            emit addCalendarEntryComplete(true);
        } else {
            emit addCalendarEntryComplete(false);
        }

Well, I’d need to be able to include the correct libraries, for one :wink:

#elif defined(BUILD_FOR_SAILFISHOS) && defined(BUILD_FOR_OPENREPOS)
#   include <extendedcalendar.h>
#   include <extendedstorage.h>
#   include <kdatetime.h>
#   include <ksystemtimezone.h>
#endif

Something like

PKGCONFIG += mkcal-qt5 kcalcore-qt5
PKGCONFIG += KF5CalendarCore libmkcal-qt5 accounts-qt5

?
And I believe it’s a bit more hairy here:

The include should be the same for mKCal, but nuke the kdatetime ones:

#elif defined(BUILD_FOR_SAILFISHOS) && defined(BUILD_FOR_OPENREPOS)
#   include <extendedcalendar.h>
#   include <extendedstorage.h>
#endif

About getting the list of notebooks, the code looks good to me. Do you have compilation errors with it ?

For the PKGCONFIG variable, it should simply be (for the calendar part, keep accounts-qt5 if you need it besides):

PKGCONFIG += KF5CalendarCore libmkcal-qt5

Yes, but those were related to the deprecated libraries. I’ll try this now. I’ve also just updated from 4.3 to 4.4 targets.

Forgot to ask, new include paths? old:

INCLUDEPATH += /usr/include/mkcal-qt5 /usr/include/kcalcoren-qt5

They should be provided by pkg-config. No need to fiddle with them I think.

Ok, I probably had that wrong:

BuildRequires:  mkcal-qt5-devel
BuildRequires:  kcalcore-qt5-devel

Indeed ; )

BuildRequires:  pkgconfig(libmkcal-qt5)
BuildRequires:  pkgconfig(KF5CalendarCore)

This seems to work:

#elif defined(BUILD_FOR_SAILFISHOS) && defined(BUILD_FOR_OPENREPOS)
#   include <mkcal-qt5/extendedcalendar.h>
#   include <mkcal-qt5/extendedstorage.h>
#endif

But KCalendarCore::Incidence perhaps?
::Event::Ptr event( new KCalendarCore::Event() )
generates no such member errors.

Ah, yes sorry, for explicit events, you need to include #include <KCalendarCore/Event>

Hmmm. That isn’t found.

This:

mKCal::ExtendedCalendar::Ptr calendar( new mKCal::ExtendedCalendar( QTimeZone::utc() ) );

generates ‘implicit instantiation of undefined template’ errors.

It seems that old KTimeZone had a default constructor for string. But not QTimeZone. So create all ExtendedCalendars with QTimeZone::utc() as argument, instead of a string.

Ok, I don’t really understand, but so far it’s going in direction rewrite after I learn the new apis. Thanks anyway!

`<KCalendarCore/Event>`

Is not found with

BuildRequires: pkgconfig(KF5CalendarCore)
in the spec and

PKGCONFIG += KF5CalendarCore libmkcal-qt5 accounts-qt5
in the pro.

Uh, I cannot see why. What is the compilation line that gives the error ?

Since I can’t import KCalendarCore/Event, how could I compile? The other messages vis. the undefined template is a error warning in the sdk.

mKCal::ExtendedCalendar::Ptr calendar( new mKCal::ExtendedCalendar( QTimeZone::utc() ) );
produces the template error. And seems to be the form you’re suggesting

Ah this is in QtCreator you mean ? Then, no idea what is missing. I’ve never used it.

Besides a spelling mistake somewhere, the creation of an ExtendedCalendar object matches its definition in mKCal and the QTimeZone one from QTimeZone Class | Qt Core 5.15.9 :

 explicit ExtendedCalendar(const QTimeZone &timeZone);

Sorry, I’ve no idea what a “template error” means in this context.

To help you further, I’ve forked your repo on Github and did the changes. It is compiling inside the SDK.

Ah, that would explain it. I use the QML live stuff a lot, and the sdk is generally usable.

Could you push your changes so they are visible? My incomplete changes are in the SFOS4 branch.

I created a PR : https://github.com/poetaster/fahrplan/pull/11 You should see it.