Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /* |
---|---|
2 | This file is part of the Nepomuk KDE project. |
3 | Copyright (C) 2010 Sebastian Trueg <trueg@kde.org> |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2.1 of the License, or (at your option) version 3, or any |
9 | later version accepted by the membership of KDE e.V. (or its |
10 | successor approved by the membership of KDE e.V.), which shall |
11 | act as a proxy defined in Section 6 of version 3 of the license. |
12 | |
13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Lesser General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Lesser General Public |
19 | License along with this library. If not, see <http://www.gnu.org/licenses/>. |
20 | */ |
21 | |
22 | #ifndef _NEPOMUK2_STANDARD_QUERIES_H_ |
23 | #define _NEPOMUK2_STANDARD_QUERIES_H_ |
24 | |
25 | #include "nepomuk_export.h" |
26 | #include "term.h" |
27 | |
28 | class QDate; |
29 | |
30 | namespace Nepomuk2 { |
31 | namespace Query { |
32 | class Query; |
33 | |
34 | /** |
35 | * A set of predefined queries that can be created via standardQuery(). |
36 | * |
37 | * \since 4.6 |
38 | */ |
39 | enum StandardQuery { |
40 | /** |
41 | * Creates a query that returns all files sorted by descending modification date. |
42 | * |
43 | * The subterm parameter can be used to specify an application restricting the results |
44 | * to files created/opened with that application. |
45 | */ |
46 | LastModifiedFilesQuery, |
47 | |
48 | /** |
49 | * Creates a query that returns all resources sorted by descending score (as calculated |
50 | * by the DataMaintenanceService) |
51 | * |
52 | * The subterm parameter can be used to specify an application restricting the results |
53 | * to files created/opened with that application. |
54 | */ |
55 | MostImportantResourcesQuery, |
56 | |
57 | /** |
58 | * Creates a query that returns all files with a usage count of 0 |
59 | * sorted by descending modification date. |
60 | */ |
61 | NeverOpenedFilesQuery, |
62 | |
63 | /** |
64 | * Get the resources related to a specific activity. Use a ResourceTerm referring to |
65 | * the activity as parameter in standardQuery. |
66 | */ |
67 | ResourcesForActivityQuery |
68 | }; |
69 | |
70 | |
71 | /** |
72 | * Modificators to influence the behaviour of dateRangeQuery(). |
73 | * |
74 | * \since 4.6 |
75 | */ |
76 | enum DateRangeFlag { |
77 | /** |
78 | * Query for the modification date (nie:lastModified) |
79 | */ |
80 | ModificationDate = 0x1, |
81 | |
82 | /** |
83 | * Query for the content creation date (nie:contentCreated) |
84 | */ |
85 | ContentDate = 0x2, |
86 | |
87 | /** |
88 | * Query for usage events referring to the resource. |
89 | */ |
90 | UsageDate = 0x4, |
91 | |
92 | /** |
93 | * Query for all possible dates. |
94 | */ |
95 | AllDates = ModificationDate|ContentDate|UsageDate |
96 | }; |
97 | Q_DECLARE_FLAGS( DateRangeFlags, DateRangeFlag ) |
98 | |
99 | /** |
100 | * Create a standard query as defined by \p query. |
101 | * |
102 | * \param query The query to be generated. See StandardQuery. |
103 | * \param subterm An optional subterm used for specific types of standard queries that need |
104 | * a parameter like ResourcesForActivityQuery. |
105 | * |
106 | * To get a query that only returns files (this is already true for some of the predefined queries) |
107 | * use something like the following: |
108 | * |
109 | * \code |
110 | * Query::FileQuery query = Query::standardQuery( Query::LastModifiedFilesQuery ); |
111 | * \endcode |
112 | * |
113 | * Be aware that queries can be combined. One can for example get the most important files related |
114 | * to an activity as follows: |
115 | * |
116 | * \code |
117 | * Query query = Query::standardQuery( Query::ResourcesForActivityQuery, myActivity ) |
118 | * && Query::standardQuery( Query::MostImportantResourcesQuery ); |
119 | * \endcode |
120 | * |
121 | * \since 4.6 |
122 | */ |
123 | NEPOMUK_EXPORT Query standardQuery( StandardQuery query, const Term& subterm = Term() ); |
124 | |
125 | /** |
126 | * Create a query that returns resources/files that have been modified/accessed in the range |
127 | * from \p start to \p end (including both full days). The flags specified in \p dateFlags can be used to influence the |
128 | * type of dates that are queried. |
129 | * |
130 | * \param start The start date of the range, if invalid no start is used, i.e. everything before \p end matches. |
131 | * \param end The end date of the range, if invalid no end is used, i.e. everything after \p start matches. |
132 | * \param dateFlags Optional flags to influence the final query. |
133 | * |
134 | * \since 4.6 |
135 | */ |
136 | NEPOMUK_EXPORT Query dateRangeQuery( const QDate& start, const QDate& end, DateRangeFlags dateFlags = AllDates ); |
137 | } |
138 | } |
139 | |
140 | Q_DECLARE_OPERATORS_FOR_FLAGS( Nepomuk2::Query::DateRangeFlags ) |
141 | |
142 | #endif |
143 |
Warning: That file was not part of the compilation database. It may have many parsing errors.