landmarks/locationlandmarks/localsearchprov/inc/EPos_CPosLmLocalTextSearch.h
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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: Class for handling text search.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPOSLMLOCALTEXTSEARCH_H
       
    20 #define CPOSLMLOCALTEXTSEARCH_H
       
    21 
       
    22 #include "EPos_CPosLmLocalSearchHandler.h"
       
    23 
       
    24 class CPosLmLocalDatabase;
       
    25 class CPosLmTextCriteria;
       
    26 
       
    27 /**
       
    28 *  Class for handling text search.
       
    29 */
       
    30 class CPosLmLocalTextSearch : public CPosLmLocalSearchHandler
       
    31     {
       
    32     public:  // Constructors and destructor
       
    33 
       
    34         /**
       
    35         * Two-phased constructor.
       
    36         *
       
    37         * @param[in] aDbAccess The access handle to the database to search.
       
    38         * @param[in] aCriteria The criteria for the searching.
       
    39         * @param[in] aSortPref A sort preference object.
       
    40         * @param[in] aDisplayData The displayable data.
       
    41         * @param[in] aMaxNumOfMatches The max number of items that will be
       
    42         *   searched for.
       
    43         */
       
    44         static CPosLmLocalTextSearch* NewL(
       
    45             CPosLmLocalDatabase& aDatabase,
       
    46             const CPosLmSearchCriteria& aCriteria,
       
    47             const TPosLmLocalSortPref& aSortPref,
       
    48             CPosLmDisplayData* aDisplayData,
       
    49             TInt aMaxNumOfMatches );
       
    50 
       
    51 	   /**
       
    52         * Two-phased constructor.
       
    53         *
       
    54         * @param[in] aDbAccess The access handle to the database to search.
       
    55         * @param[in] aCriteria The array of the criterias, for the searching.
       
    56         * @param[in] aSortPref A sort preference object.
       
    57         * @param[in] aDisplayData The displayable data.
       
    58         * @param[in] aMaxNumOfMatches The max number of items that will be
       
    59         *   searched for.
       
    60         */
       
    61 	   static CPosLmLocalTextSearch* NewL(
       
    62             CPosLmLocalDatabase& aDatabase,
       
    63             const RPointerArray<CPosLmSearchCriteria>& aCriteria,
       
    64             const TPosLmLocalSortPref& aSortPref,
       
    65             CPosLmDisplayData* aDisplayData,
       
    66             TInt aMaxNumOfMatches );
       
    67             
       
    68         /**
       
    69         * Destructor.
       
    70         */
       
    71         ~CPosLmLocalTextSearch();
       
    72 
       
    73     public: // New functions
       
    74 
       
    75         /**
       
    76         * Validates that the criteria is correct according to the search API.
       
    77         * Leaves if the criteria is missing a search text.
       
    78         *
       
    79         * @param[in] aCriteria The criteria to validate.
       
    80         */
       
    81         static void ValidateCriteriaL(
       
    82             const CPosLmTextCriteria& aCriteria
       
    83         );
       
    84         
       
    85         /**
       
    86         *set the composition type. it is used when more then one search pattern is provided while constructing
       
    87         @param[in] aType The composition type
       
    88         */
       
    89         
       
    90         void SetCompositionType(TInt atype);
       
    91     public: // From CPosLmLocalSearchHandler.
       
    92 
       
    93         /** @return ETrue. */
       
    94         TBool IsValidForLandmarkSearch() const;
       
    95 
       
    96 		
       
    97         /**
       
    98         * @param[in][out] aProgress Will be set to the progress of the search when
       
    99         * the step has finished.
       
   100         * @return @p KPosLmOperationNotComplete if the step has completed but
       
   101         *   more steps are needed before the search has finished,
       
   102         *   @p KErrNone if the search has finished successfully.
       
   103         */
       
   104         TInt NextStepL( TReal32& aProgress );
       
   105 
       
   106     protected:
       
   107 
       
   108     private:
       
   109 
       
   110     	void PrepareSearchL();
       
   111     	void PrepareFieldSearchL( RDbView& aView );
       
   112 
       
   113         HBufC* CreatePosFieldQueryLC();
       
   114         HBufC* CreateAttributeQueryLC();
       
   115 
       
   116         void UnsortedSearchL();
       
   117         void SortedLimitedSearchL();
       
   118         void SortedUnlimitedSearchL();
       
   119         
       
   120         void InsertMatchIndexL( TUint aIndex, RDbRowSet* aDataRow = NULL );
       
   121         void AddMatchIndexL( TUint aIndex, RDbRowSet* aDataRow = NULL );
       
   122         
       
   123         /**
       
   124         * C++ default constructor.
       
   125         * @param[in] aDbAccess The access handle to the database to search.
       
   126         * @param[in] aCriteria The criteria for the searching.
       
   127         * @param[in] aSortPref A sort preference object.
       
   128         * @param[in] aMaxNumOfMatches The max number of items that will be
       
   129         *   searched for.
       
   130         */
       
   131         CPosLmLocalTextSearch(
       
   132             CPosLmLocalDatabase& aDatabase,
       
   133             const CPosLmSearchCriteria& aCriteria,
       
   134             const TPosLmLocalSortPref& aSortPref,
       
   135             TInt aMaxNumOfMatches );
       
   136 
       
   137         /**
       
   138         * By default Symbian 2nd phase constructor is private.
       
   139         * @param[in] aCriteria The criteria for the searching.
       
   140         * @param[in] aDisplayData The displayable data.
       
   141         */
       
   142         void ConstructL(
       
   143             const CPosLmSearchCriteria& aCriteria,
       
   144             CPosLmDisplayData* aDisplayData );
       
   145             
       
   146          /**
       
   147         * By default Symbian 2nd phase constructor is private.
       
   148         * @param[in] aCriteria The array of the criterias, for the searching.
       
   149         * @param[in] aDisplayData The displayable data.
       
   150         */
       
   151         void ConstructL(
       
   152             const RPointerArray<CPosLmSearchCriteria>& aCriteria,
       
   153             CPosLmDisplayData* aDisplayData );
       
   154 
       
   155         // By default, prohibit copy constructor
       
   156         CPosLmLocalTextSearch( const CPosLmLocalTextSearch& );
       
   157         // Prohibit assigment operator
       
   158         CPosLmLocalTextSearch& operator= ( const CPosLmLocalTextSearch& );
       
   159         
       
   160         TBool MatchText(TPtrC text); 
       
   161         
       
   162 
       
   163     private:
       
   164 
       
   165         enum TPosTextSearchStatus
       
   166             {
       
   167             ESearchNotStarted = 0,
       
   168             
       
   169             EPrepareUnsortedSearch,
       
   170             EUnsortedAttributeSearch,
       
   171             EPrepareUnsortedFieldSearch,
       
   172             EUnsortedFieldSearch,
       
   173             
       
   174             EPrepareSortedLimitedSearch,
       
   175             EPrepareSortedLimitedAttributeSearch,
       
   176             ESortedLimitedAttributeSearch,
       
   177             ESortedLimitedFieldSearch,
       
   178             
       
   179             EPrepareUnlimitedSearch,
       
   180             EPrepareUnlimitedFieldSearch,
       
   181             EUnlimitedAttributeSearch,
       
   182             EUnlimitedFieldSearch,
       
   183 
       
   184             ESearchCompleted
       
   185             };
       
   186 
       
   187         TPosTextSearchStatus iSearchStatus;
       
   188 
       
   189         TBool iPositionFieldSearch;
       
   190 
       
   191         TBool iAttributeSearch;
       
   192 
       
   193         TBool iSortSearch;
       
   194 
       
   195         CPosLandmark::TAttributes   iAttributes;
       
   196         RArray<TUint>               iFields;
       
   197         RPointerArray<HBufC>        iTextPattern;
       
   198         
       
   199         
       
   200         RArray<TUint>               iMatchIndexes;
       
   201         RArray<TUint>				iFieldMatches;
       
   202         
       
   203         TInt						iCompositionType;
       
   204     };
       
   205 
       
   206 #endif      // CPOSLMLOCALTEXTSEARCH_H
       
   207