searchui/indevicehandler/inc/indevicehandler.h
changeset 0 ccd0fd43f247
child 2 208a4ba3894c
equal deleted inserted replaced
-1:000000000000 0:ccd0fd43f247
       
     1 /*
       
     2  * Copyright (c) 2009 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:  Declaration of the inDeviceHandler.
       
    15  *
       
    16  */
       
    17 #ifndef INDEVICEHANDLER_H
       
    18 #define INDEVICEHANDLER_H
       
    19 
       
    20 #include <QtCore>
       
    21 #include <qcoreapplication.h>
       
    22 #include <qdebug.h>
       
    23 #include "Search_global.h"
       
    24 
       
    25 #ifdef BUILD_INDEVICEHANDLER
       
    26 #define SEARCH_INDEVICEHANDLER Q_DECL_EXPORT
       
    27 #else
       
    28 #define SEARCH_INDEVICEHANDLER Q_DECL_IMPORT
       
    29 #endif
       
    30 
       
    31 #ifndef DEFAULT_SEARCH_FIELD
       
    32 #define DEFAULT_SEARCH_FIELD "_aggregate"
       
    33 #endif
       
    34 
       
    35 class QCPixSearcher;
       
    36 class QCPixDocument;
       
    37 
       
    38 SEARCH_CLASS(SearchInDeviceHandlerTest)
       
    39 
       
    40 /**
       
    41  * InDeviceHandler is an interface class for UI and
       
    42  * CPix engine.
       
    43  */
       
    44 class SEARCH_INDEVICEHANDLER InDeviceHandler : public QObject
       
    45     {
       
    46 Q_OBJECT
       
    47 public:
       
    48 
       
    49     /**
       
    50      * Constructor.
       
    51      * @since S60 ?S60_version.
       
    52      */
       
    53     InDeviceHandler();
       
    54 
       
    55     /**
       
    56      * Destructor.
       
    57      * @since S60 ?S60_version.
       
    58      */
       
    59     ~InDeviceHandler();
       
    60 
       
    61 signals:
       
    62 
       
    63     /**
       
    64      * Signalled when search completes synchronusly 
       
    65      * error and number of results will be returned    
       
    66      */
       
    67     void handleSearchResult(int, int);
       
    68 
       
    69     /**
       
    70      * Signalled when search completes unsynchronusly
       
    71      * error and number of results will be returned     
       
    72      */
       
    73     void handleAsyncSearchResult(int, int);
       
    74 
       
    75     /**
       
    76      * Signalled when user requests for the result item
       
    77      * error and result item will be returned
       
    78      */
       
    79     void handleDocument(int aError, QCPixDocument* aDoc);
       
    80 
       
    81 private slots:
       
    82 
       
    83     /**
       
    84      * slot connects to QCPixSearcher to get the status of search results 
       
    85      * @since S60 ?S60_version.
       
    86      * @param aError error code.
       
    87      * @param aEstimatedResultCount number of results
       
    88      */
       
    89 
       
    90     void getSearchResult(int aError, int aEstimatedResultCount);
       
    91 
       
    92     /**
       
    93      * slot connects to QCPixSearcher to get the result item 
       
    94      * @since S60 ?S60_version.
       
    95      * @param aError error code.
       
    96      * @param aDocument result item
       
    97      */
       
    98     void getDocumentAsync(int aError, QCPixDocument* aDocument);
       
    99 
       
   100 public:
       
   101 
       
   102     /**
       
   103      * returns the result item synchronously.
       
   104      * @since S60 ?S60_version.
       
   105      * @param aIndex index 
       
   106      */
       
   107     QCPixDocument* getDocumentAtIndex(int aIndex);
       
   108 
       
   109     /**
       
   110      * returns the result item asynchronously.
       
   111      * @since S60 ?S60_version.
       
   112      * @param aIndex index 
       
   113      */
       
   114     void getDocumentAsyncAtIndex(int aIndex);
       
   115 
       
   116     /**
       
   117      * initate the search synchronously.
       
   118      * @since S60 ?S60_version.
       
   119      * @param aSearchString search keyword 
       
   120      */
       
   121     void search(QString aSearchString);
       
   122 
       
   123     /**
       
   124      * initate the search asynchronously.
       
   125      * @since S60 ?S60_version.
       
   126      * @param aSearchAsyncString search keyword
       
   127      * @param aDefaultSearchField search criteria
       
   128      */
       
   129     void searchAsync(QString aSearchAsyncString, QString aDefaultSearchField =
       
   130             NULL);
       
   131 
       
   132     /**
       
   133      * cancels the outstanding search
       
   134      * @since S60 ?S60_version.
       
   135      */
       
   136     void cancelLastSearch();
       
   137 
       
   138     /**
       
   139      * returns the number of results on current search
       
   140      * @since S60 ?S60_version.
       
   141      */
       
   142     int getSearchResultCount();
       
   143 
       
   144     /**
       
   145      * prepare the search on specified category
       
   146      * @since S60 ?S60_version.
       
   147      * @param aCategory database name
       
   148      */
       
   149     void setCategory(QString aCategory);
       
   150 
       
   151     /**
       
   152      * return the status whether the specified category is set 
       
   153      * and ready for search
       
   154      * @since S60 ?S60_version.
       
   155      */
       
   156     bool isPrepared();
       
   157 
       
   158 private:
       
   159 
       
   160     /**
       
   161      * interface for CPix.
       
   162      * Own.
       
   163      */
       
   164     QCPixSearcher *mSearchInterface;
       
   165 
       
   166     /**
       
   167      * number of results on current search.        
       
   168      */
       
   169     int mSearchResultCount;
       
   170 
       
   171 SEARCH_FRIEND_CLASS    (SearchInDeviceHandlerTest)
       
   172     };
       
   173 
       
   174 #endif //INDEVICEHANDLER_H