File indexing completed on 2025-01-05 04:59:40
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Kevin Ottens <ervin@kde.org> 0003 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 0007 #ifndef AKONADI_DATASOURCEQUERIES_H 0008 #define AKONADI_DATASOURCEQUERIES_H 0009 0010 #include "domain/datasourcequeries.h" 0011 0012 #include "akonadi/akonadilivequeryhelpers.h" 0013 #include "akonadi/akonadilivequeryintegrator.h" 0014 0015 namespace Akonadi { 0016 0017 class DataSourceQueries : public QObject, public Domain::DataSourceQueries 0018 { 0019 Q_OBJECT 0020 public: 0021 typedef QSharedPointer<DataSourceQueries> Ptr; 0022 0023 typedef Domain::LiveQueryInput<Akonadi::Collection> CollectionInputQuery; 0024 typedef Domain::LiveQueryOutput<Domain::DataSource::Ptr> DataSourceQueryOutput; 0025 typedef Domain::QueryResult<Domain::DataSource::Ptr> DataSourceResult; 0026 0027 typedef Domain::LiveQueryInput<Akonadi::Item> ItemInputQuery; 0028 typedef Domain::LiveQueryOutput<Domain::Project::Ptr> ProjectQueryOutput; 0029 typedef Domain::QueryResult<Domain::Project::Ptr> ProjectResult; 0030 0031 DataSourceQueries(const StorageInterface::Ptr &storage, 0032 const SerializerInterface::Ptr &serializer, 0033 const MonitorInterface::Ptr &monitor); 0034 0035 bool isDefaultSource(Domain::DataSource::Ptr source) const override; 0036 private: 0037 void changeDefaultSource(Domain::DataSource::Ptr source) override; 0038 0039 public: 0040 DataSourceResult::Ptr findTopLevel() const override; 0041 DataSourceResult::Ptr findChildren(Domain::DataSource::Ptr source) const override; 0042 DataSourceResult::Ptr findAllSelected() const override; 0043 ProjectResult::Ptr findProjects(Domain::DataSource::Ptr source) const override; 0044 0045 private: 0046 CollectionInputQuery::PredicateFunction createFetchPredicate(const Collection &root) const; 0047 0048 SerializerInterface::Ptr m_serializer; 0049 LiveQueryHelpers::Ptr m_helpers; 0050 LiveQueryIntegrator::Ptr m_integrator; 0051 0052 mutable DataSourceQueryOutput::Ptr m_findTopLevel; 0053 mutable QHash<Akonadi::Collection::Id, DataSourceQueryOutput::Ptr> m_findChildren; 0054 mutable DataSourceQueryOutput::Ptr m_findAllSelected; 0055 mutable QHash<Akonadi::Collection::Id, ProjectQueryOutput::Ptr> m_findProjects; 0056 }; 0057 0058 } 0059 0060 #endif // AKONADI_DATASOURCEQUERIES_H