location_plat/location_data_harvester_api/inc/locationdatalookupdb.h
branchRCL_3
changeset 17 1fc85118c3ae
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
       
     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: defines api for lookup database.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef LOCATIONDATA_LOOKUPDB_H
       
    20 #define LOCATIONDATA_LOOKUPDB_H
       
    21 
       
    22 // DLL_EXPORT macro definition
       
    23 #ifdef BUILD_DLL
       
    24 #define DLL_EXPORT Q_DECL_EXPORT
       
    25 #else
       
    26 #define DLL_EXPORT Q_DECL_IMPORT
       
    27 #endif
       
    28 
       
    29 
       
    30 
       
    31 // INCLUDES
       
    32 #include <QObject>
       
    33 #include <locationservicedefines.h>
       
    34 
       
    35 class QSqlDatabase;
       
    36 class QSqlQuery;
       
    37 
       
    38 class QLookupItem
       
    39 {
       
    40     
       
    41 public:
       
    42     
       
    43     enum IconType
       
    44     {
       
    45         /** Icon type default */
       
    46         EIconTypeDefault,
       
    47         /** Icon type from gallery */
       
    48         EIconTypeGallery,
       
    49         /** Icon type from flicker */
       
    50         EIconTypeFlicker,
       
    51         /** Icon type from contact thumbnail */
       
    52         EIconTypeContactThumbnail,
       
    53         /** Icon type maptile */
       
    54         EIconTypeMapTile
       
    55     };
       
    56     
       
    57 public:
       
    58     // unique id of the entry
       
    59     quint32 mId;
       
    60 
       
    61     // flag to identify if the entry is a duplicate
       
    62     quint32 mIsDuplicate;
       
    63 
       
    64     // Uid of the source entry
       
    65     quint32 mSourceUid;
       
    66 
       
    67     // Source type
       
    68     quint32 mSourceType;
       
    69 
       
    70     // Dest uid in the landmarks database
       
    71     quint32 mDestId;
       
    72    
       
    73     // name
       
    74     QString mName;
       
    75 
       
    76     // Street
       
    77     QString mStreet;
       
    78 
       
    79     // Postal code
       
    80     QString mPostalCode;
       
    81 
       
    82     // City
       
    83     QString mCity;
       
    84 
       
    85     // State
       
    86     QString mState;
       
    87 
       
    88     // Country
       
    89     QString mCountry;
       
    90     
       
    91     // latitude
       
    92     double mLatitude;
       
    93     
       
    94     // longitude
       
    95     double mLongitude;
       
    96     
       
    97     // icon type
       
    98     quint32 mIconType;
       
    99     
       
   100     // icon path
       
   101     QString mIconPath;
       
   102 
       
   103     // map tile path
       
   104     QString mMapTilePath;
       
   105     
       
   106     //One line address
       
   107     QString mSingleLineAddress;
       
   108 };
       
   109 
       
   110 /**
       
   111 * Location data lookup database class.
       
   112 */
       
   113 class DLL_EXPORT LocationDataLookupDb : public QObject
       
   114 {
       
   115 	
       
   116 public: // Constructor
       
   117 
       
   118     /**
       
   119     * Constructor
       
   120     */
       
   121     LocationDataLookupDb( QObject *parent = 0 );	
       
   122 
       
   123     /**
       
   124     * Destructor
       
   125     */
       
   126     ~LocationDataLookupDb();  
       
   127 
       
   128     /**
       
   129     * Opens the lookup database.
       
   130     */
       
   131     bool open();
       
   132 
       
   133     /**
       
   134     * Closes the lookup database.
       
   135     */
       
   136     void close();
       
   137 
       
   138     /**
       
   139     * Creates an entry in the lookup table.
       
   140     * @param[in] aLookupItem The lookup item to be created in the database.
       
   141     */
       
   142     void createEntry( QLookupItem& aLookupItem );
       
   143 
       
   144     /**
       
   145     * Updates an entry in the lookup table.
       
   146     * The source id and type is used to find the entry in db
       
   147     * @param[in] aLookupItem The lookup item to be updated in the database.
       
   148     */
       
   149     void updateEntryBySourceIdAndType( const QLookupItem& aLookupItem );
       
   150 
       
   151     /**
       
   152     * Updates an entry in the lookup table.
       
   153     * The source id and type is used to find the entry in db
       
   154     * @param[in] aLookupItem The lookup item to be updated in the database.
       
   155     */
       
   156     void updateMaptileBySourceIdAndType( quint32 aSourceId, quint32 aSourceType, QString aImagePath );
       
   157 
       
   158     /**
       
   159     * Updates an entry in the lookup table.
       
   160     * The id is used to find the entry in db
       
   161     * @param[in] aLookupItem The lookup item to be updated in the database.
       
   162     */
       
   163     void updateEntryById( const QLookupItem& aLookupItem );
       
   164 
       
   165     /**
       
   166     * Deletes an entry from the lookup table.
       
   167     * The source id and type is used to find the entry in db
       
   168     * @param[in] aLookupItem The lookup item to be deleted from the database.
       
   169     */
       
   170     void deleteEntryBySourceIdAndType( const QLookupItem& aLookupItem );
       
   171 
       
   172     /**
       
   173     * Finds an entry in the lookup table.
       
   174     * @param[in/out] aLookupItem The lookup item to be found in the database. The source id and source type 
       
   175     * is passed in the lookup item. If the entry is found, all other fields are updated in the lookup item.
       
   176     * @return true if found, else false
       
   177     */
       
   178     bool findEntryBySourceIdAndType( QLookupItem& aLookupItem );
       
   179 
       
   180     /**
       
   181     * Finds an entry in the lookup table.
       
   182     * @param[in/out] aLookupItem The lookup item to be found in the database. The id is passed 
       
   183     * in the lookup item. If the entry is found, all other fields are updated in the lookup item.
       
   184     * @return true if found, else false
       
   185     */
       
   186     bool findEntryById( QLookupItem& aLookupItem );
       
   187 
       
   188     /**
       
   189     * Finds list of lookup items given a landmark id.
       
   190     * @param[in] aLandmarkId The landmark id to be found in the lookup database.  
       
   191     * @param[out] aLookupItemArray List of lookup entries found.  
       
   192     */
       
   193     void findEntriesByLandmarkId( const quint32 aLandmarkId, 
       
   194             QList<QLookupItem>& aLookupItemArray );
       
   195 
       
   196    /**
       
   197     * Gets list of lookup items.
       
   198     * @param[in] aCollectionId The collection id, whose whose corresponding entries needs to be fetched.
       
   199     *            By default all the entries in the lookup db are fetched.  
       
   200     * @param[out] aLookupItemArray List of lookup entries found.  
       
   201     */
       
   202     void getEntries( QList<QLookupItem>& aLookupItemArray, const quint32 aCollectionId = ESourceInvalid );
       
   203     
       
   204    /**
       
   205     * Gets count  of lookup items.
       
   206 	* @param[in/out] aCount  The number of items in lookup table for the collection id
       
   207     * @param[in] aCollectionId The collection id, whose whose corresponding entries needs to be fetched.
       
   208     *            By default all the entries in the lookup db are fetched.  
       
   209     */
       
   210     void getCount( QList<int>& aCount,const quint32 aCollectionId = ESourceInvalid );
       
   211 
       
   212    /**
       
   213     * Gets single line address
       
   214     * @param mId , id of the entry
       
   215     * @param mSourceType , type of entry
       
   216     * @return QString , address associated with cuurent id and type  
       
   217     */
       
   218     QString getAddressDetails( quint32 mId , quint32 mSourceType );
       
   219     
       
   220     /**
       
   221     * Gets single line address
       
   222     * @param id , id of the entry
       
   223     * @param sourceType , type of entry
       
   224     * @param name , name of entry
       
   225     */
       
   226     void updateEntryNameByIdAndType(quint32 id, quint32 sourceType , QString name);
       
   227     
       
   228 private:
       
   229 	
       
   230     // fills the lookup entry
       
   231     void fillLookupEntry( QSqlQuery &aRecord, QLookupItem &aLookupItem );    
       
   232     
       
   233     // Handle to the items database
       
   234     QSqlDatabase *mDb;
       
   235 
       
   236     // Flag to indicate if db is open
       
   237     bool mDbOpen;
       
   238 };
       
   239 #endif  // LOCATIONDATA_LOOKUPDB_H
       
   240 
       
   241 // End of file
       
   242     
       
   243 
       
   244