location_plat/location_data_harvester_api/inc/locationdatalookupdb.h
changeset 20 cd10d5b85554
child 26 f3533f6eae3f
equal deleted inserted replaced
17:0f22fb80ebba 20:cd10d5b85554
       
     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 
       
   107 /**
       
   108 * Location data lookup database class.
       
   109 */
       
   110 class DLL_EXPORT LocationDataLookupDb : public QObject
       
   111 {
       
   112 	
       
   113 public: // Constructor
       
   114 
       
   115     /**
       
   116     * Constructor
       
   117     */
       
   118     LocationDataLookupDb( QObject *parent = 0 );	
       
   119 
       
   120     /**
       
   121     * Destructor
       
   122     */
       
   123     ~LocationDataLookupDb();  
       
   124 
       
   125     /**
       
   126     * Opens the lookup database.
       
   127     */
       
   128     bool open();
       
   129 
       
   130     /**
       
   131     * Closes the lookup database.
       
   132     */
       
   133     void close();
       
   134 
       
   135     /**
       
   136     * Creates an entry in the lookup table.
       
   137     * @param[in] aLookupItem The lookup item to be created in the database.
       
   138     */
       
   139     void createEntry( const QLookupItem& aLookupItem );
       
   140 
       
   141     /**
       
   142     * Updates an entry in the lookup table.
       
   143     * The source id and type is used to find the entry in db
       
   144     * @param[in] aLookupItem The lookup item to be updated in the database.
       
   145     */
       
   146     void updateEntryBySourceIdAndType( const QLookupItem& aLookupItem );
       
   147 
       
   148     /**
       
   149     * Updates an entry in the lookup table.
       
   150     * The source id and type is used to find the entry in db
       
   151     * @param[in] aLookupItem The lookup item to be updated in the database.
       
   152     */
       
   153     void updateMaptileBySourceIdAndType( quint32 aSourceId, quint32 aSourceType, QString aImagePath );
       
   154 
       
   155     /**
       
   156     * Updates an entry in the lookup table.
       
   157     * The id is used to find the entry in db
       
   158     * @param[in] aLookupItem The lookup item to be updated in the database.
       
   159     */
       
   160     void updateEntryById( const QLookupItem& aLookupItem );
       
   161 
       
   162     /**
       
   163     * Deletes an entry from the lookup table.
       
   164     * The source id and type is used to find the entry in db
       
   165     * @param[in] aLookupItem The lookup item to be deleted from the database.
       
   166     */
       
   167     void deleteEntryBySourceIdAndType( const QLookupItem& aLookupItem );
       
   168 
       
   169     /**
       
   170     * Deletes an entry from the lookup table.
       
   171     * The id is used to find the entry in db
       
   172     * @param[in] aLookupItem The lookup item to be deleted from the database.
       
   173     */
       
   174     void deleteEntryById( const QLookupItem& aLookupItem );
       
   175 
       
   176     /**
       
   177     * Finds an entry in the lookup table.
       
   178     * @param[in/out] aLookupItem The lookup item to be found in the database. The source id and source type 
       
   179     * is passed in the lookup item. If the entry is found, all other fields are updated in the lookup item.
       
   180     * @return true if found, else false
       
   181     */
       
   182     bool findEntryBySourceIdAndType( QLookupItem& aLookupItem );
       
   183 
       
   184     /**
       
   185     * Finds an entry in the lookup table.
       
   186     * @param[in/out] aLookupItem The lookup item to be found in the database. The id is passed 
       
   187     * in the lookup item. If the entry is found, all other fields are updated in the lookup item.
       
   188     * @return true if found, else false
       
   189     */
       
   190     bool findEntryById( QLookupItem& aLookupItem );
       
   191 
       
   192     /**
       
   193     * Finds list of lookup items given a landmark id.
       
   194     * @param[in] aLandmarkId The landmark id to be found in the lookup database.  
       
   195     * @param[out] aLookupItemArray List of lookup entries found.  
       
   196     */
       
   197     void findEntriesByLandmarkId( const quint32 aLandmarkId, 
       
   198             QList<QLookupItem>& aLookupItemArray );
       
   199 
       
   200     /**
       
   201     * Finds list of lookup items given a source type.
       
   202     * @param[in] aSourceType The source type to be found in the lookup database.  
       
   203     * @param[out] aLookupItemArray List of lookup entries found.  
       
   204     */
       
   205     void findEntriesBySourceType( const quint32 aSourceType, 
       
   206             QList<QLookupItem>& aLookupItemArray );
       
   207 
       
   208 
       
   209     /**
       
   210     * Gets list of lookup items.
       
   211     * @param[in] aCollectionId The collection id, whose whose corresponding entries needs to be fetched.
       
   212     *            By default all the entries in the lookup db are fetched.  
       
   213     * @param[out] aLookupItemArray List of lookup entries found.  
       
   214     */
       
   215     void getEntries( QList<QLookupItem>& aLookupItemArray, const quint32 aCollectionId = ESourceInvalid );
       
   216 
       
   217 
       
   218 private:
       
   219 	
       
   220     // fills the lookup entry
       
   221     void fillLookupEntry( QSqlQuery &aRecord, QLookupItem &aLookupItem );
       
   222     
       
   223     // Handle to the items database
       
   224     QSqlDatabase *mDb;
       
   225 };
       
   226 #endif  // LOCATIONDATA_LOOKUPDB_H
       
   227 
       
   228 // End of file
       
   229     
       
   230 
       
   231