searchsrv_plat/cpix_search_api/inc/cpixdocument.h
changeset 13 fcb2a58c181b
child 23 d4d56f5e7c55
equal deleted inserted replaced
11:7c6f43cd91cf 13:fcb2a58c181b
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Qt search document APIs
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef _CPIXDOCUMENT_H
       
    19 #define _CPIXDOCUMENT_H
       
    20 
       
    21 #ifdef BUILD_DLL
       
    22 #define DLL_EXPORT Q_DECL_EXPORT
       
    23 #else
       
    24 #define DLL_EXPORT Q_DECL_IMPORT
       
    25 #endif
       
    26 
       
    27 /**
       
    28  * @file
       
    29  * @ingroup Qt Search ClientAPI
       
    30  * @brief Contains CpixDocument APIs
       
    31  */
       
    32 
       
    33 #include <QObject>
       
    34 #include <cpixcommon.h>
       
    35 
       
    36 //Forward  Declaration
       
    37 class CpixDocumentPrivate;
       
    38 class CpixDocumentField;
       
    39 
       
    40 /**
       
    41  * @brief Represents the document returned as a result of a search query.
       
    42  * @ingroup ClientAPI
       
    43  * 
       
    44  * Link against: cpixsearch.lib 
       
    45  */
       
    46 class DLL_EXPORT CpixDocument: public QObject
       
    47     {
       
    48     Q_OBJECT
       
    49 public:
       
    50     //@TODO: The following enums are copied over from S60. They need to 
       
    51     // be moved to a common file so that they can be shared by s60, qt and openc.
       
    52     /**
       
    53      * TStored defines wheter the value is stored to database.
       
    54      * If value is stored to database, it can be retrieved from search result. 
       
    55      */
       
    56     enum Stored
       
    57         {
       
    58         StoreYes = 1,
       
    59         StoreNo = 2
       
    60         };
       
    61 
       
    62     /**
       
    63      * TIndexed defines how the value of the field is indexed. 
       
    64      * If value is indexed, it can be searched. 
       
    65      */
       
    66     enum Indexed
       
    67         {
       
    68         IndexNo = 16,
       
    69         IndexTokenized = 32,
       
    70         IndexUnTokenized = 64
       
    71         };
       
    72 
       
    73     /**
       
    74      * TAggregated defines how the value of the field are exposed 
       
    75      * for aggregation. Aggregated field can be found with generic searches. 
       
    76      * If aggregation is not specified, all indexed field are aggeregated by
       
    77      * default. Note: that also non-indexed fields can be aggregated.
       
    78      */
       
    79     enum Aggregated
       
    80         {
       
    81         AggregateNo = 1<<30,
       
    82         AggregateYes = 1<<31,
       
    83         AggregateDefault = 0
       
    84         };
       
    85     /**
       
    86      * By default, field value is stored to database and it's indexed as tokenized strings.
       
    87      */
       
    88     static const int DefaultConfig = StoreYes | IndexTokenized | AggregateDefault;
       
    89 
       
    90     static const float KDefaultBoost; 
       
    91 
       
    92 public:
       
    93     /**
       
    94        * Constructor.
       
    95        * Creates a CpixDocument object and return a pointer to the created object.
       
    96        * @return A pointer to the created instance of CpixDocument.
       
    97        */
       
    98     static CpixDocument* newInstance();
       
    99 
       
   100     /**
       
   101      * Destructor
       
   102      */
       
   103     virtual ~CpixDocument();
       
   104     
       
   105     /**
       
   106      * Getter: Gets the document identifier.
       
   107      * @return document identifier.
       
   108      */
       
   109     QString docId() const;
       
   110     
       
   111     /**
       
   112      * Getter: Gets the document excert.
       
   113      * @return document excerpt.
       
   114      */
       
   115     QString excerpt() const;
       
   116     
       
   117     /**
       
   118      * Getter: Gets the document's base app class.
       
   119      * @return document's base app class.
       
   120      */
       
   121     QString baseAppClass() const;
       
   122 
       
   123     /**
       
   124      * Getter: Gets the field at aIndex in the document.
       
   125      * @param aIndex index of the field that is to be retrieved.
       
   126      * @return CpixDocumentField that was at aIndex.
       
   127      */
       
   128     const CpixDocumentField& field( const int aIndex ) const THROWS_EXCEPTION;
       
   129     
       
   130     /**
       
   131      * Getter: Gets the field count.
       
   132      * @return The number of the fields in the document.
       
   133      */
       
   134     int fieldCount() const;
       
   135     
       
   136     /**
       
   137      * Setter: Sets the document identifier for the document.
       
   138      * @param aDocId the document identifier to be set.
       
   139      */
       
   140     void setDocId(const QString aDocId);
       
   141     
       
   142     /**
       
   143      * Setter: Sets the excerpt for the document.
       
   144      * @param aExcerpt the excerpt to be set.
       
   145      */
       
   146     void setExcerpt(const QString aExcerpt);
       
   147     
       
   148     /**
       
   149      * Setter: Sets the base app class for the document.
       
   150      * @param aBaseAppClass the base app class to be set.
       
   151      */
       
   152     void setBaseAppClass(const QString aBaseAppClass);
       
   153 
       
   154     /**
       
   155      * Setter: Adds a field with aName, aValue and aConfig to the document.
       
   156      * @param aName The name of the field
       
   157      * @param aValue The value of the field
       
   158      * @param aConfig The config of the field
       
   159      * @return the CpixDocumentField that was added to the document.
       
   160      */
       
   161     void addField(const QString aName, const QString aValue, const int aConfig = CpixDocument::DefaultConfig);
       
   162 
       
   163 private:
       
   164     /**
       
   165      * Default constructor
       
   166      */
       
   167     CpixDocument();
       
   168 
       
   169 private:
       
   170     CpixDocumentPrivate* const iPvtImpl;
       
   171 	Q_DECLARE_PRIVATE_D( iPvtImpl, CpixDocument )
       
   172     };
       
   173 
       
   174 #endif //_CPIXDOCUMENT_H