diff --git a/akonadi/calendar/calfilterpartstatusproxymodel_p.cpp b/akonadi/calendar/calfilterpartstatusproxymodel_p.cpp index a649dc0b8..ddad21432 100644 --- a/akonadi/calendar/calfilterpartstatusproxymodel_p.cpp +++ b/akonadi/calendar/calfilterpartstatusproxymodel_p.cpp @@ -1,138 +1,142 @@ /* Copyright (c) 2014 Sandro Knauß This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "calfilterpartstatusproxymodel_p.h" #include "utils_p.h" #include #include #include #include #include #include #include #include using namespace Akonadi; class CalFilterPartStatusProxyModel::Private { public: explicit Private() : mFilterVirtual(false) , mIdentityManager(/*ro=*/ true) { } bool mFilterVirtual; QList mBlockedStatusList; KPIMIdentities::IdentityManager mIdentityManager; }; void CalFilterPartStatusProxyModel::slotIdentitiesChanged() { emit invalidate(); } CalFilterPartStatusProxyModel::CalFilterPartStatusProxyModel(QObject *parent) : QSortFilterProxyModel(parent) , d(new Private()) { connect(&(d->mIdentityManager), SIGNAL(changed()), SLOT(slotIdentitiesChanged())); } CalFilterPartStatusProxyModel::~CalFilterPartStatusProxyModel() { delete d; } const QList &CalFilterPartStatusProxyModel::blockedStatusList() const { return d->mBlockedStatusList; } void CalFilterPartStatusProxyModel::setBlockedStatusList(const QList &blockStatusList) { d->mBlockedStatusList = blockStatusList; } bool CalFilterPartStatusProxyModel::filterVirtual() const { return d->mFilterVirtual; } void CalFilterPartStatusProxyModel::setFilterVirtual(bool filterVirtual) { d->mFilterVirtual = filterVirtual; } bool CalFilterPartStatusProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { const QModelIndex idx = sourceModel()->index(source_row, 0, source_parent); if (!idx.isValid()) return false; const Akonadi::Item item = idx.data(Akonadi::EntityTreeModel::ItemRole).value(); if (!item.isValid()) { return false; } const KCalCore::Incidence::Ptr incidence = CalendarUtils::incidence(item); if (!incidence) { return false; } const Akonadi::Collection col = idx.data(Akonadi::EntityTreeModel::ParentCollectionRole).value(); const QString calendarNamespace = incidence->customProperty("VOLATILE", "CALENDARNAMESPACE"); //Wait until the namespace is available, we can't filter reliably before if (calendarNamespace.isNull()) { return false; } //If this incidence is in a shared user collection, then we don't care about the attendee status if (!col.isVirtual() && calendarNamespace.toLower() == "user") { return true; } //If this incidence is in a shared user collection, but we've found it over the search collection, then we ignore it. if (col.isVirtual() && calendarNamespace.toLower() == "user") { return false; } // Incidences from virtual collections are always ok if (!d->mFilterVirtual && col.isVirtual()) { return true; } + if (CalendarUtils::thatIsMe(incidence->organizer()->email())) { + return true; + } + foreach (const KCalCore::Attendee::Ptr &attendee, incidence->attendees()) { if ( CalendarUtils::thatIsMe(attendee) ) { if ( d->mBlockedStatusList.contains(attendee->status()) ) { return false; } else { return true; } } } // We are not attendee, so we accept the incidence return true; }