[share-like-connect] dataengine/providers/activities: restore the 2 steps connection to activity
Marco Martin
notmart at gmail.com
Thu Sep 29 19:06:45 UTC 2011
So,
little explanation around this (and yes, can still be reverted before or even
after monday)
this restores the 2 steps behaviour for connecting to activities: it has been
reeally briefly discussed at the workshop (i wished it was actually toroughly
discussed :/)
https://bugs.kde.org/show_bug.cgi?id=282832
basically, there isn't any way to link an open resource with slc to any
activity that isn't the current (you can't even switch to the other, because
the open window would disappear) that's the reason this 2 step behaviour.
one thing that is still missing and would be needed to be really completed is
to send the window as well to all the newly connected activities (correct me
if i'm wrong but there still isn't api from kwin?)
Cheers,
Marco Martin
On Thursday 29 September 2011, Marco Martin wrote:
> Git commit 23fe50dd3b511356c0b67f67927af1b3aa16ffda by Marco Martin.
> Committed on 29/09/2011 at 20:26.
> Pushed by mart into branch 'master'.
>
> restore the 2 steps connection to activity
>
> CCMAIL:active at kde.org
>
> M +36 -27 dataengine/providers/activities/activitiesProvider.cpp
> M +0 -3 dataengine/providers/activities/activitiesProvider.h
>
> http://commits.kde.org/share-like-connect/23fe50dd3b511356c0b67f67927af1b3a
> a16ffda
>
> diff --git a/dataengine/providers/activities/activitiesProvider.cpp
> b/dataengine/providers/activities/activitiesProvider.cpp index
> d35dd87..baccf1d 100644
> --- a/dataengine/providers/activities/activitiesProvider.cpp
> +++ b/dataengine/providers/activities/activitiesProvider.cpp
> @@ -50,24 +50,6 @@ SLC::Provider::Actions
> ActivitiesProvider::actionsFor(const QVariantHash &conten return NoAction;
> }
>
> -QString ActivitiesProvider::actionName(const QVariantHash &content, Action
> action) -{
> - Nepomuk::Resource acRes(m_activityConsumer->currentActivity(),
> Nepomuk::Vocabulary::KEXT::Activity()); -
> - if (content.value("Window ID").toInt() > 0) {
> - QUrl url(content.value("URI").toString());
> - Nepomuk::Resource res(url.toString());
> -
> - if (res.exists() && res.isRelatedOf().contains(acRes)) {
> - return i18n("Disconnect from activity");
> - } else {
> - return i18n("Connect to activity");
> - }
> - }
> -
> - return Provider::actionName(content, action);
> -}
> -
> QVariant ActivitiesProvider::executeAction(SLC::Provider::Action action,
> const QVariantHash &content, const QVariantHash ¶meters) {
> if (action != Connect) {
> @@ -75,7 +57,7 @@ QVariant
> ActivitiesProvider::executeAction(SLC::Provider::Action action, const Q }
>
> const QString resourceUrl = content["URI"].toString();
> - QString activityId = m_activityConsumer->currentActivity();
> + QStringList activityIds = parameters["Targets"].toStringList();
>
> //find out what activities if any this resource is connected to
> //TODO: restrict the query to only activities, but they aren't part of
> the ontology yet @@ -90,6 +72,32 @@ QVariant
> ActivitiesProvider::executeAction(SLC::Provider::Action action, const Q
> activities.insert(resource.property(QUrl("http://nepomuk.kde.org/ontologie
> s/2010/11/29/kext#activityIdentifier")).toString()); }
>
> + //first step
> + if (activityIds.isEmpty()) {
> +
> + //list activities
> + QList<QVariant> result;
> + QVariantHash item;
> + item["target"] = m_activityConsumer->currentActivity();
> + item["name"] = i18n("Current activity");
> + item["connected"] =
> activities.contains(m_activityConsumer->currentActivity()); +
> result << item;
> +
> + foreach (const QString &activity,
> m_activityConsumer->listActivities()) { + Activities::Info
> *info = new Activities::Info(activity); + QVariantHash item;
> + item["target"] = activity;
> + item["name"] = info->name();
> + item["connected"] = activities.contains(activity);
> + //kDebug() << "Found activity: " << activity << info->name();
> +
> + result << item;
> + delete info;
> + }
> + return result;
> + }
> +
> + //second step
> QUrl typeUrl;
>
> Nepomuk::Resource fileRes(resourceUrl);
> @@ -110,16 +118,17 @@ QVariant
> ActivitiesProvider::executeAction(SLC::Provider::Action action, const Q }
> }
>
> - Nepomuk::Resource acRes(activityId,
> Nepomuk::Vocabulary::KEXT::Activity()); - //remove connection
> - if (activities.contains(activityId)) {
> - acRes.removeProperty(Soprano::Vocabulary::NAO::isRelated(),
> fileRes); - //add connection
> - } else {
> - acRes.addProperty(Soprano::Vocabulary::NAO::isRelated(), fileRes);
> + foreach (const QString &activityId, activityIds) {
> + Nepomuk::Resource acRes(activityId,
> Nepomuk::Vocabulary::KEXT::Activity()); + //remove connection
> + if (activities.contains(activityId)) {
> + acRes.removeProperty(Soprano::Vocabulary::NAO::isRelated(),
> fileRes); + //add connection
> + } else {
> + acRes.addProperty(Soprano::Vocabulary::NAO::isRelated(),
> fileRes); + }
> }
>
> -
> return true;
> }
>
> diff --git a/dataengine/providers/activities/activitiesProvider.h
> b/dataengine/providers/activities/activitiesProvider.h index
> f64e0fe..168f504 100644
> --- a/dataengine/providers/activities/activitiesProvider.h
> +++ b/dataengine/providers/activities/activitiesProvider.h
> @@ -35,9 +35,6 @@ public:
> Actions actionsFor(const QVariantHash &content) const;
>
> QVariant executeAction(SLC::Provider::Action action, const
> QVariantHash &content, const QVariantHash ¶meters); -
> - QString actionName(const QVariantHash &content, Action action);
> -
> private:
> Activities::Consumer *m_activityConsumer;
> };
> _______________________________________________
> Active mailing list
> Active at kde.org
> https://mail.kde.org/mailman/listinfo/active
--
Marco Martin
More information about the Active
mailing list