[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nepomuk
Subject:    Re: [Nepomuk] Activities and desktop events - Results from
From:       Sebastian Trüg <trueg () kde ! org>
Date:       2010-08-03 15:57:27
Message-ID: 4C583C67.2040408 () kde ! org
[Download RAW message or body]

On 07/23/2010 10:38 AM, Ivan Čukić wrote:
>> by this score and combine that with the restrictions you list which can
>> all be expressed using a single Term.
> 
> Ok
> 
>> kstandardactions) and add the method and the enum to the
>> Nepomuk::Query::StandardQueries namespace.
> 
> Yet another Ok :)

please check the attached header and tell me if the API is acceptable. I
did not define special standard queries for "fav res of type X" since
that ca easily be done via:

Query q = standardQuery(MostImportantResourcesQuery);
q.setTerm( ResourceTypeTerm(type) && q.term() );

Also I am not quite sure what "for an application" would mean in a query...
- only resources that have an event related to the app
- only resources of supported mimetype or resource type

both do not really seem useful though as IMHO there would be too many
false-negatives.

Cheers,
Sebastian

["standardqueries.h" (text/x-c)]

/*
   This file is part of the Nepomuk KDE project.
   Copyright (C) 2010 Sebastian Trueg <trueg@kde.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) version 3, or any
   later version accepted by the membership of KDE e.V. (or its
   successor approved by the membership of KDE e.V.), which shall
   act as a proxy defined in Section 6 of version 3 of the license.

   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
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _NEPOMUK_STANDARD_QUERIES_H_
#define _NEPOMUK_STANDARD_QUERIES_H_

#include "nepomukquery_export.h"

#include <QtCore/QDate>

namespace Nepomuk {
    namespace Query {
        class Query;

        /**
         * A set of predefined queries that can be created vis standardQuery().
         *
         * \since 4.6
         */
        enum StandardQuery {
            /**
             * Creates a query that returns all files sorted by descending \
                modification date.
             */
            LastModifiedFilesQuery,

            /**
             * Creates a query that returns all resources sorted by descending score \
                (as calculated
             * by the DataMaintenanceService)
             */
            MostImportantResourcesQuery,

            /**
             * Creates a query that returns all files with a usage count of 0
             * sorted by descending modification date.
             */
            NeverOpenedFilesQuery
        };

        /**
         * Modificators to influence the behaviour of dateRangeQuery().
         *
         * \since 4.6
         */
        enum DateRangeFlag {
            /**
             * Query for the modification date (nie:lastModified)
             */
            ModificationDate = 0x1,

            /**
             * Query for the content creation date (nie:contentCreated)
             */
            ContentDate = 0x2,

            /**
             * Query for usage events referring to the resource.
             */
            UsageDate = 0x4,

            /**
             * Query for all possible dates.
             */
            AllDates = ModificationDate|ContentDate|UsageDate
        };
        Q_DECLARE_FLAGS( DateRangeFlags, DateRangeFlag )

        /**
         * Create a standard query as defined by \p query.
         * To get a query that only returns files (this is already true for some of \
                the predefined queries)
         * use something like the following:
         *
         * \code
         * Query::FileQuery query = Query::standardQuery( \
                Query::LastModifiedFilesQuery );
         * \endcode
         *
         * \since 4.6
         */
        NEPOMUK_QUERY_EXPORT Query standardQuery( StandardQuery query );

        /**
         * Create a query that returns resources/files that have been \
                modified/accessed in the range
         * from \p start to \p end. The flags specified in \p dateFlags can be used \
                to influence the
         * type of dates that are queried.
         *
         * \since 4.6
         */
        NEPOMUK_QUERY_EXPORT Query dateRangeQuery( const QDate& start, const QDate& \
end, DateRangeFlags dateFlags = AllDates );  }
}

Q_DECLARE_OPERATOR_FOR_FLAGS( Nepomuk::Query::DateRangeFlags )

#endif



_______________________________________________
Nepomuk mailing list
Nepomuk@kde.org
https://mail.kde.org/mailman/listinfo/nepomuk


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic