File indexing completed on 2024-05-19 16:38:22

0001 /*
0002     SPDX-FileCopyrightText: 2015, 2016 Ivan Cukic <ivan.cukic(at)kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef KACTIVITIES_STATS_TERMS_H
0008 #define KACTIVITIES_STATS_TERMS_H
0009 
0010 #include <initializer_list>
0011 
0012 #include <QDate>
0013 #include <QString>
0014 #include <QStringList>
0015 
0016 #include "kactivitiesstats_export.h"
0017 
0018 namespace KActivities
0019 {
0020 namespace Stats
0021 {
0022 /**
0023  * @namespace KActivities::Stats::Terms
0024  * Provides enums and strucss to use.for building queries with @c Query.
0025  */
0026 namespace Terms
0027 {
0028 /**
0029  * Enumerator specifying the ordering in which the
0030  * results of the query should be listed
0031  */
0032 enum KACTIVITIESSTATS_EXPORT Order {
0033     HighScoredFirst, ///< Resources with the highest scores first
0034     RecentlyUsedFirst, ///< Recently used resources first
0035     RecentlyCreatedFirst, ///< Recently created resources first
0036     OrderByUrl, ///< Order by uri, alphabetically
0037     OrderByTitle, ///< Order by uri, alphabetically
0038 };
0039 
0040 /**
0041  * Which resources should be returned
0042  */
0043 enum KACTIVITIESSTATS_EXPORT Select {
0044     LinkedResources, ///< Resources linked to an activity, or globally
0045     UsedResources, ///< Resources that have been accessed
0046     AllResources, ///< Combined set of accessed and linked resources
0047 };
0048 
0049 /**
0050  * @struct KActivities::Stats::Terms::Limit terms.h <KActivities/Stats/Terms>
0051  *
0052  * How many items do you need?
0053  */
0054 struct KACTIVITIESSTATS_EXPORT Limit {
0055     Limit(int value);
0056     static Limit all();
0057     int value;
0058 };
0059 
0060 /**
0061  * @struct KActivities::Stats::Terms::Offset terms.h <KActivities/Stats/Terms>
0062  *
0063  * How many items to skip?
0064  * This can be specified only if limit is also set to a finite value.
0065  */
0066 struct KACTIVITIESSTATS_EXPORT Offset {
0067     Offset(int value);
0068     int value;
0069 };
0070 
0071 /**
0072  * @struct KActivities::Stats::Terms::Type terms.h <KActivities/Stats/Terms>
0073  *
0074  * Term to filter the resources according to their types
0075  */
0076 struct KACTIVITIESSTATS_EXPORT Type {
0077     /**
0078      * Show resources of any type
0079      */
0080     static Type any();
0081     /**
0082      * Show non-directory resources
0083      */
0084     static Type files();
0085     /**
0086      * Show directory resources aka folders
0087      */
0088     static Type directories();
0089 
0090     inline Type(std::initializer_list<QString> types)
0091         : values(types)
0092     {
0093     }
0094 
0095     Type(QStringList types);
0096     Type(QString type);
0097 
0098     const QStringList values;
0099 };
0100 
0101 /**
0102  * @struct KActivities::Stats::Terms::Agent terms.h <KActivities/Stats/Terms>
0103  *
0104  * Term to filter the resources according the agent (application) which
0105  * accessed it
0106  */
0107 struct KACTIVITIESSTATS_EXPORT Agent {
0108     /**
0109      * Show resources accessed/linked by any application
0110      */
0111     static Agent any();
0112 
0113     /**
0114      * Show resources not tied to a specific agent
0115      */
0116     static Agent global();
0117 
0118     /**
0119      * Show resources accessed/linked by the current application
0120      */
0121     static Agent current();
0122 
0123     inline Agent(std::initializer_list<QString> agents)
0124         : values(agents)
0125     {
0126     }
0127 
0128     Agent(QStringList agents);
0129     Agent(QString agent);
0130 
0131     const QStringList values;
0132 };
0133 
0134 /**
0135  * @struct KActivities::Stats::Terms::Activity terms.h <KActivities/Stats/Terms>
0136  *
0137  * Term to filter the resources according the activity in which they
0138  * were accessed
0139  */
0140 struct KACTIVITIESSTATS_EXPORT Activity {
0141     /**
0142      * Show resources accessed in / linked to any activity
0143      */
0144     static Activity any();
0145 
0146     /**
0147      * Show resources linked to all activities
0148      */
0149     static Activity global();
0150 
0151     /**
0152      * Show resources linked to all activities
0153      */
0154     static Activity current();
0155 
0156     inline Activity(std::initializer_list<QString> activities)
0157         : values(activities)
0158     {
0159     }
0160 
0161     Activity(QStringList activities);
0162     Activity(QString activity);
0163 
0164     const QStringList values;
0165 };
0166 
0167 /**
0168  * @struct KActivities::Stats::Terms::Url terms.h <KActivities/Stats/Terms>
0169  *
0170  * Url filtering.
0171  */
0172 struct KACTIVITIESSTATS_EXPORT Url {
0173     /**
0174      * Show only resources that start with the specified prefix
0175      */
0176     static Url startsWith(const QString &prefix);
0177 
0178     /**
0179      * Show resources that contain the specified infix
0180      */
0181     static Url contains(const QString &infix);
0182 
0183     /**
0184      * Show local files
0185      */
0186     static Url localFile();
0187 
0188     /**
0189      * Show local files, smb, fish, ftp and sftp
0190      */
0191     static Url file();
0192 
0193     inline Url(std::initializer_list<QString> urlPatterns)
0194         : values(urlPatterns)
0195     {
0196     }
0197 
0198     Url(QStringList urlPatterns);
0199     Url(QString urlPattern);
0200 
0201     const QStringList values;
0202 };
0203 
0204 /**
0205  * @struct KActivities::Stats::Terms::Date terms.h <KActivities/Stats/Terms>
0206  *
0207  * On which start access date do you want to filter ?
0208  */
0209 struct KACTIVITIESSTATS_EXPORT Date {
0210     Date(QDate value);
0211     Date(QDate start, QDate end);
0212 
0213     static Date today();
0214     static Date yesterday();
0215     static Date currentWeek();
0216     static Date previousWeek();
0217     static Date fromString(QString);
0218 
0219     QDate start, end;
0220 };
0221 
0222 } // namespace Terms
0223 
0224 } // namespace Stats
0225 } // namespace KActivities
0226 
0227 KACTIVITIESSTATS_EXPORT
0228 QDebug operator<<(QDebug dbg, const KActivities::Stats::Terms::Order &order);
0229 
0230 KACTIVITIESSTATS_EXPORT
0231 QDebug operator<<(QDebug dbg, const KActivities::Stats::Terms::Select &select);
0232 
0233 KACTIVITIESSTATS_EXPORT
0234 QDebug operator<<(QDebug dbg, const KActivities::Stats::Terms::Type &type);
0235 
0236 KACTIVITIESSTATS_EXPORT
0237 QDebug operator<<(QDebug dbg, const KActivities::Stats::Terms::Agent &agent);
0238 
0239 KACTIVITIESSTATS_EXPORT
0240 QDebug operator<<(QDebug dbg, const KActivities::Stats::Terms::Activity &activity);
0241 
0242 KACTIVITIESSTATS_EXPORT
0243 QDebug operator<<(QDebug dbg, const KActivities::Stats::Terms::Url &url);
0244 
0245 KACTIVITIESSTATS_EXPORT
0246 QDebug operator<<(QDebug dbg, const KActivities::Stats::Terms::Limit &limit);
0247 
0248 KACTIVITIESSTATS_EXPORT
0249 QDebug operator<<(QDebug dbg, const KActivities::Stats::Terms::Offset &offset);
0250 
0251 KACTIVITIESSTATS_EXPORT
0252 QDebug operator<<(QDebug dbg, const KActivities::Stats::Terms::Date &date);
0253 
0254 #endif // KACTIVITIES_STATS_TERMS_H