# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1278414628 -10800 # Node ID 8db05346071be65ade0fad000b716c2998ac7814 # Parent 96df3ab410005ab92bf91d22ac229e53a1c51f8c Revision: 201025 Kit: 2010127 diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/bwins/geocodeupdateu.def --- a/locationdataharvester/bwins/geocodeupdateu.def Wed Jun 23 18:07:15 2010 +0300 +++ b/locationdataharvester/bwins/geocodeupdateu.def Tue Jul 06 14:10:28 2010 +0300 @@ -6,7 +6,7 @@ ??1GeocodeUpdate@@UAE@XZ @ 5 NONAME ; GeocodeUpdate::~GeocodeUpdate(void) ?getStaticMetaObject@GeocodeUpdate@@SAABUQMetaObject@@XZ @ 6 NONAME ; struct QMetaObject const & GeocodeUpdate::getStaticMetaObject(void) ?updateGeocodeToContactDB@GeocodeUpdate@@QAE_NIHNN@Z @ 7 NONAME ; bool GeocodeUpdate::updateGeocodeToContactDB(unsigned int, int, double, double) - ?updateGeocodeToCalenderDB@GeocodeUpdate@@QAE_NKNN@Z @ 8 NONAME ; bool GeocodeUpdate::updateGeocodeToCalenderDB(unsigned long, double, double) + ?updateGeocodeToCalenderDB@GeocodeUpdate@@QAE_NABKABN1@Z @ 8 NONAME ; bool GeocodeUpdate::updateGeocodeToCalenderDB(unsigned long const &, double const &, double const &) ??0GeocodeUpdate@@QAE@XZ @ 9 NONAME ; GeocodeUpdate::GeocodeUpdate(void) ?qt_metacall@GeocodeUpdate@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 10 NONAME ; int GeocodeUpdate::qt_metacall(enum QMetaObject::Call, int, void * *) ?eventCompleted@GeocodeUpdate@@IAEXXZ @ 11 NONAME ; void GeocodeUpdate::eventCompleted(void) @@ -16,4 +16,5 @@ ?metaObject@GeocodeUpdate@@UBEPBUQMetaObject@@XZ @ 15 NONAME ; struct QMetaObject const * GeocodeUpdate::metaObject(void) const ?agendautilInstanceCreated@GeocodeUpdate@@AAEXH@Z @ 16 NONAME ; void GeocodeUpdate::agendautilInstanceCreated(int) ?qt_metacast@GeocodeUpdate@@UAEPAXPBD@Z @ 17 NONAME ; void * GeocodeUpdate::qt_metacast(char const *) + ?isGeocodeNotAvailable@GeocodeUpdate@@QAE_NABK@Z @ 18 NONAME ; bool GeocodeUpdate::isGeocodeNotAvailable(unsigned long const &) diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/bwins/maptileserviceu.def --- a/locationdataharvester/bwins/maptileserviceu.def Wed Jun 23 18:07:15 2010 +0300 +++ b/locationdataharvester/bwins/maptileserviceu.def Tue Jul 06 14:10:28 2010 +0300 @@ -8,7 +8,7 @@ ?trUtf8@MapTileService@@SA?AVQString@@PBD0H@Z @ 7 NONAME ; class QString MapTileService::trUtf8(char const *, char const *, int) ??1MapTileService@@UAE@XZ @ 8 NONAME ; MapTileService::~MapTileService(void) ??0MapTileService@@QAE@XZ @ 9 NONAME ; MapTileService::MapTileService(void) - ?getMapTileImage@MapTileService@@QAEHHW4AddressType@1@AAVQString@@@Z @ 10 NONAME ; int MapTileService::getMapTileImage(int, enum MapTileService::AddressType, class QString &) + ?getMapTileImage@MapTileService@@QAEHHW4AddressType@1@AAVQString@@V?$QFlags@W4Orientation@Qt@@@@@Z @ 10 NONAME ; int MapTileService::getMapTileImage(int, enum MapTileService::AddressType, class QString &, class QFlags) ?metaObject@MapTileService@@UBEPBUQMetaObject@@XZ @ 11 NONAME ; struct QMetaObject const * MapTileService::metaObject(void) const ?setMaptileStatus@MapTileService@@QAEXXZ @ 12 NONAME ; void MapTileService::setMaptileStatus(void) ?tr@MapTileService@@SA?AVQString@@PBD0H@Z @ 13 NONAME ; class QString MapTileService::tr(char const *, char const *, int) diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/eabi/geocodeupdateu.def --- a/locationdataharvester/eabi/geocodeupdateu.def Wed Jun 23 18:07:15 2010 +0300 +++ b/locationdataharvester/eabi/geocodeupdateu.def Tue Jul 06 14:10:28 2010 +0300 @@ -5,15 +5,16 @@ _ZN13GeocodeUpdate15createContactdbEv @ 4 NONAME _ZN13GeocodeUpdate16staticMetaObjectE @ 5 NONAME DATA 16 _ZN13GeocodeUpdate19getStaticMetaObjectEv @ 6 NONAME - _ZN13GeocodeUpdate24updateGeocodeToContactDBEjidd @ 7 NONAME - _ZN13GeocodeUpdate25agendautilInstanceCreatedEi @ 8 NONAME - _ZN13GeocodeUpdate25updateGeocodeToCalenderDBEmdd @ 9 NONAME - _ZN13GeocodeUpdateC1Ev @ 10 NONAME - _ZN13GeocodeUpdateC2Ev @ 11 NONAME - _ZN13GeocodeUpdateD0Ev @ 12 NONAME - _ZN13GeocodeUpdateD1Ev @ 13 NONAME - _ZN13GeocodeUpdateD2Ev @ 14 NONAME - _ZNK13GeocodeUpdate10metaObjectEv @ 15 NONAME - _ZTI13GeocodeUpdate @ 16 NONAME - _ZTV13GeocodeUpdate @ 17 NONAME + _ZN13GeocodeUpdate21isGeocodeNotAvailableERKm @ 7 NONAME + _ZN13GeocodeUpdate24updateGeocodeToContactDBEjidd @ 8 NONAME + _ZN13GeocodeUpdate25agendautilInstanceCreatedEi @ 9 NONAME + _ZN13GeocodeUpdate25updateGeocodeToCalenderDBERKmRKdS3_ @ 10 NONAME + _ZN13GeocodeUpdateC1Ev @ 11 NONAME + _ZN13GeocodeUpdateC2Ev @ 12 NONAME + _ZN13GeocodeUpdateD0Ev @ 13 NONAME + _ZN13GeocodeUpdateD1Ev @ 14 NONAME + _ZN13GeocodeUpdateD2Ev @ 15 NONAME + _ZNK13GeocodeUpdate10metaObjectEv @ 16 NONAME + _ZTI13GeocodeUpdate @ 17 NONAME + _ZTV13GeocodeUpdate @ 18 NONAME diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/eabi/maptileserviceu.def --- a/locationdataharvester/eabi/maptileserviceu.def Wed Jun 23 18:07:15 2010 +0300 +++ b/locationdataharvester/eabi/maptileserviceu.def Tue Jul 06 14:10:28 2010 +0300 @@ -2,7 +2,7 @@ _ZN14MapTileService11qt_metacallEN11QMetaObject4CallEiPPv @ 1 NONAME _ZN14MapTileService11qt_metacastEPKc @ 2 NONAME _ZN14MapTileService12publishValueEiNS_11AddressTypeEi @ 3 NONAME - _ZN14MapTileService15getMapTileImageEiNS_11AddressTypeER7QString @ 4 NONAME + _ZN14MapTileService15getMapTileImageEiNS_11AddressTypeER7QString6QFlagsIN2Qt11OrientationEE @ 4 NONAME _ZN14MapTileService15publishCalEntryEi @ 5 NONAME _ZN14MapTileService16setMaptileStatusEv @ 6 NONAME _ZN14MapTileService16staticMetaObjectE @ 7 NONAME DATA 16 diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/geocodeupdate/inc/geocodeupdate.h --- a/locationdataharvester/geocodeupdate/inc/geocodeupdate.h Wed Jun 23 18:07:15 2010 +0300 +++ b/locationdataharvester/geocodeupdate/inc/geocodeupdate.h Tue Jul 06 14:10:28 2010 +0300 @@ -28,6 +28,7 @@ #define GEOCODEUPDATE_EXPORT Q_DECL_IMPORT #endif +class AgendaUtil; // CLASS DECLARATION /** @@ -53,25 +54,41 @@ * @param addressType contact address type. * @param latitude Latitude to be updated. * @param longitude longitude to be updated. + * + * @return Returns true if successfule otherwise false. */ - bool updateGeocodeToContactDB(const quint32 contactId, - const int addressType, const double latitude, - const double longitude); + bool updateGeocodeToContactDB(const quint32 contactId, const int addressType, + const double latitude, const double longitude); /** * Request to update latitude and longitude into calender db. * @param calEntryId calender entry unique id * @param latitude Latitude to be updated. * @param longitude longitude to be updated. + * + * @return Returns true if successfule otherwise false. */ - bool updateGeocodeToCalenderDB(const ulong calEntryId, - const double latitude, const double longitude); + bool updateGeocodeToCalenderDB(const ulong& calEntryId, const double& latitude, + const double& longitude); + + /** + * Request to check if geo-cordinate available or not. + * @param calEntryId calender entry unique id + * @return true, if available otherwise false. + */ + bool isGeocodeNotAvailable(const ulong& calEntryId); + private slots: void agendautilInstanceCreated(int); + signals: void eventCompleted(); + +private: + AgendaUtil *mAgendaUtil; + bool mUtilInstanceCreated; }; #endif // __GEOCODEUPDATE_H__ diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/geocodeupdate/src/geocodeupdate.cpp --- a/locationdataharvester/geocodeupdate/src/geocodeupdate.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationdataharvester/geocodeupdate/src/geocodeupdate.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -1,19 +1,19 @@ /* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * + */ #include #include @@ -34,9 +34,12 @@ // ---------------------------------------------------------------------------- // GeocodeUpdate::GeocodeUpdate() // ---------------------------------------------------------------------------- -GeocodeUpdate::GeocodeUpdate() +GeocodeUpdate::GeocodeUpdate() : + mAgendaUtil(NULL), mUtilInstanceCreated(false) { - + mAgendaUtil = new AgendaUtil(); + connect(mAgendaUtil, SIGNAL(instanceViewCreationCompleted(int)), this, + SLOT(agendautilInstanceCreated(int))); } // ---------------------------------------------------------------------------- @@ -45,7 +48,9 @@ GeocodeUpdate::~GeocodeUpdate() { __TRACE_CALLSTACK; - + if (mUtilInstanceCreated) { + delete mAgendaUtil; + } } // ---------------------------------------------------------------------------- @@ -63,9 +68,8 @@ // CGeocodeUpdate::updateGeocodeToContactDB() // Geo-cordinate updation to contact db // ---------------------------------------------------------------------------- -bool GeocodeUpdate::updateGeocodeToContactDB(const quint32 contactId, - const int addressType, const double latitude, - const double longitude) +bool GeocodeUpdate::updateGeocodeToContactDB(const quint32 contactId, const int addressType, + const double latitude, const double longitude) { __TRACE_CALLSTACK; @@ -75,11 +79,10 @@ MYLOCLOGSTRING("contactManger object created ."); MYLOCLOGSTRING("contactManger object is not null ."); - QContact contact = contactManger->contact( contactId ); + QContact contact = contactManger->contact(contactId); QContactGeoLocation location; - switch (addressType) - { + switch (addressType) { case ESourceContactsPref: { break; @@ -96,14 +99,14 @@ } default: { - return false; + return false; } } location.setLongitude(longitude); location.setLatitude(latitude); contact.saveDetail(&location); - bool ret=false; - ret=contactManger->saveContact(&contact); + bool ret = false; + ret = contactManger->saveContact(&contact); delete contactManger; return ret; } @@ -112,30 +115,49 @@ // CGeocodeUpdate::updateGeocodeToCalenderDB() // Geo-cordinate updation to contact db // ---------------------------------------------------------------------------- -bool GeocodeUpdate::updateGeocodeToCalenderDB(const ulong calEntryId, - const double latitude, const double longitude) +bool GeocodeUpdate::updateGeocodeToCalenderDB(const ulong& calEntryId, const double& latitude, + const double& longitude) { __TRACE_CALLSTACK; - AgendaUtil agendaUtil ; - connect(&agendaUtil , SIGNAL(instanceViewCreationCompleted(int)) ,this ,SLOT(agendautilInstanceCreated(int))); - QEventLoop loop; - connect(this,SIGNAL(eventCompleted()),&loop,SLOT(quit())); - loop.exec(); - AgendaEntry agendaEntry (agendaUtil.fetchById(calEntryId)); - MYLOCLOGSTRING("agenda entry created from calender id ."); - AgendaGeoValue geoValue; - geoValue.setLatLong(latitude,longitude); - MYLOCLOGSTRING("latitude and longitude set to AgendaGeoValue object."); - agendaEntry.setGeoValue(geoValue); - bool ret=false; - ret=agendaUtil.updateEntry(agendaEntry) ; + bool ret = false; + if (mUtilInstanceCreated) { + AgendaEntry agendaEntry(mAgendaUtil->fetchById(calEntryId)); + MYLOCLOGSTRING("agenda entry created from calender id ."); + AgendaGeoValue geoValue; + geoValue.setLatLong(latitude, longitude); + MYLOCLOGSTRING("latitude and longitude set to AgendaGeoValue object."); + agendaEntry.setGeoValue(geoValue); + ret = mAgendaUtil->updateEntry(agendaEntry); + } return ret; } +// ---------------------------------------------------------------------------- +// CGeocodeUpdate::isGeocodeNotAvailable() +// check if geo-cordinate are available for this specific entry id. +// return true , for available otherwise false. +// ---------------------------------------------------------------------------- +bool GeocodeUpdate::isGeocodeNotAvailable(const ulong& calEntryId) +{ + __TRACE_CALLSTACK; + bool ret = false; + if (mUtilInstanceCreated) { + AgendaEntry agendaEntry(mAgendaUtil->fetchById(calEntryId)); + const AgendaGeoValue &geoValue = agendaEntry.geoValue(); + ret = geoValue.isNull(); + } + return ret; +} + +// ---------------------------------------------------------------------------- +// CGeocodeUpdate::agendautilInstanceCreated() +// call back on agendautil instance creation +// ---------------------------------------------------------------------------- void GeocodeUpdate::agendautilInstanceCreated(int status) { - if (AgendaUtil::NoError == status){ + if (AgendaUtil::NoError == status) { + mUtilInstanceCreated = true; emit eventCompleted(); } } diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/inc/mylocationsdefines.h --- a/locationdataharvester/inc/mylocationsdefines.h Wed Jun 23 18:07:15 2010 +0300 +++ b/locationdataharvester/inc/mylocationsdefines.h Tue Jul 06 14:10:28 2010 +0300 @@ -121,6 +121,25 @@ const TInt KBufSize=256; +//Different Maptile sizes for different applications +const int MapTileWidth = 614; +const int MapTileHeight = 250; +const int MaptilePortraitWidth = 334; +const int MaptilePortraitHeight = 250; +const int MaptileContactLandscapeWidth = 382; +const int MaptileContactLandscapeHeight = 128; +const int MaptileCalendarLandscapeWidth = 614; +const int MaptileCalendarLandscapeHeight = 202; +const int MaptileHurriganesWidth = 228; +const int MaptileHurriganesHeight = 170; + +static const char* MAPTILE_IMAGE_PORTRAIT = "_Vertical"; +static const char* MAPTILE_IMAGE_LANDSCAPE = "_Horizontal"; +static const char* MAPTILE_IMAGE_CALENDAR = "_Calendar"; +static const char* MAPTILE_IMAGE_CONTACT = "_Contact"; +static const char* MAPTILE_IMAGE_HURRIGANES = "_Hurriganes"; +static const char* MAPTILE_IMAGE_TYPE = "PNG"; + #endif // __MYLOCATIONSDEFINES_H__ // End of file diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/locationdatalookupdb/locationdatalookupdb.cpp --- a/locationdataharvester/locationdatalookupdb/locationdatalookupdb.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationdataharvester/locationdatalookupdb/locationdatalookupdb.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -25,7 +25,12 @@ #include // database name +#ifdef LOCPICKER_UNIT_TEST +const QString KLocationDataLookupDbName = "c:\\locationdatalookuptestdb.db"; +#else const QString KLocationDataLookupDbName = "c:\\locationdatalookupdb.db"; +#endif + // ================= MEMBER FUNCTIONS ======================= // diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/maptileservice/inc/maptiledblookuptable.h --- a/locationdataharvester/maptileservice/inc/maptiledblookuptable.h Wed Jun 23 18:07:15 2010 +0300 +++ b/locationdataharvester/maptileservice/inc/maptiledblookuptable.h Tue Jul 06 14:10:28 2010 +0300 @@ -23,55 +23,7 @@ #include //RFs #include //RDbNamedDatabase,RDbView -// maptile database column names -_LIT( NCntColUid, "cntuid" ); -_LIT( NAppColFilePath, "filepath" ); -_LIT( NColSource, "source" ); -_LIT( NColMaptileStatus, "fetchingstatus" ); - -// maptile lookup database name -_LIT( KMapTileLookupDatabaseName, "mylocationsmaptilelookup.db" ); - -// maptile database table name -_LIT( KMapTileLookupTable, "cntmaptilelookuptable" ); - -_LIT( KLookupDbPath, "c:\\mylocations\\" ); - -// uid column number -const TInt KColumnUid = 1; -// source type column number -const TInt KColumnSource = 2; -// maptile image path column number -const TInt KColumnFilePath = 3; -// maptile status column number -const TInt KColumnMapTileFetchingStatus = 4; - - -/** - * Maptile database lookup entry - */ -class TLookupItem -{ -public: - // Uid of the source entry - TUint32 iUid; - - // Source type - TUint32 iSource; - - // Landmark uid in the landmarks database - TUint32 iLmId; - - // Uid of the Application - TUint32 iAppUid; - - // File Path - TFileName iFilePath; - - //MK map tile fetching status - TUint32 iFetchingStatus; -}; - +#include "mylocationsdefines.h" /** * CLookupMapTileDatabase class. * This class handles all the operations related to maptile lookup database. diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/maptileservice/inc/maptileservice.h --- a/locationdataharvester/maptileservice/inc/maptileservice.h Wed Jun 23 18:07:15 2010 +0300 +++ b/locationdataharvester/maptileservice/inc/maptileservice.h Tue Jul 06 14:10:28 2010 +0300 @@ -116,10 +116,12 @@ * @param contactId app id * @param sourceType Source address type( Preferred, Home , Work address ) * @param imagePath Maptile image path associated with the app id + * @param orientation Application current orientation. * * @return Returns the maptile fetching status. */ - int getMapTileImage( int Id, AddressType sourceType, QString& imagePath ); + int getMapTileImage( int Id, AddressType sourceType, + QString& imagePath, Qt::Orientations orientation = Qt::Vertical ); public slots: /** diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/maptileservice/src/maptileservice.cpp --- a/locationdataharvester/maptileservice/src/maptileservice.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationdataharvester/maptileservice/src/maptileservice.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -21,6 +21,7 @@ #include #include #include +#include #include "mylocationlogger.h" #include "maptileservice.h" @@ -123,7 +124,8 @@ // Gets the maptile image path associated with a contact. // ----------------------------------------------------------------------------- // -int MapTileService::getMapTileImage( int id, AddressType sourceType, QString& imagePath ) +int MapTileService::getMapTileImage( int id, AddressType sourceType, + QString& imagePath, Qt::Orientations orientation ) { __TRACE_CALLSTACK; @@ -138,15 +140,42 @@ if ( KErrNone == error ) { - //Get the image path - QString imageFile((QChar*)lookupItem.iFilePath.Ptr(), - lookupItem.iFilePath.Length()); - imagePath = imageFile; - maptileStatus = lookupItem.iFetchingStatus; MYLOCLOGSTRING1("getMapTileImage maptileStatus - %d ", maptileStatus ); - - if( maptileStatus == MapTileFetchingNetworkError || + + if( maptileStatus == MapTileFetchingCompleted ) + { + //Get the image path + QString imageFile((QChar*)lookupItem.iFilePath.Ptr(), + lookupItem.iFilePath.Length()); + imagePath = imageFile; + + if( orientation == Qt::Vertical ) + { + imagePath.append( MAPTILE_IMAGE_PORTRAIT ); + } + else + { + if( sourceType == AddressPlain ) + { + imagePath.append( MAPTILE_IMAGE_CALENDAR ); + } + else if ( sourceType == AddressHome || + sourceType == AddressPreference || sourceType == AddressWork ) + { + imagePath.append( MAPTILE_IMAGE_CONTACT ); + } + imagePath.append( MAPTILE_IMAGE_LANDSCAPE ); + } + + //Check if file exist + if( !QFile::exists( imagePath ) ) + { + imagePath.clear(); + maptileStatus = MapTileFetchingUnknownError; + } + } + else if( maptileStatus == MapTileFetchingNetworkError || maptileStatus == MapTileFetchingInProgress ) { switch(sourceType) diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/mylocationsengine/conf/maptilestatuspublisher.qcrml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationdataharvester/mylocationsengine/conf/maptilestatuspublisher.qcrml Tue Jul 06 14:10:28 2010 +0300 @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/mylocationsengine/inc/mylocationsengine.h --- a/locationdataharvester/mylocationsengine/inc/mylocationsengine.h Wed Jun 23 18:07:15 2010 +0300 +++ b/locationdataharvester/mylocationsengine/inc/mylocationsengine.h Tue Jul 06 14:10:28 2010 +0300 @@ -40,6 +40,7 @@ #include "lookupmaptiledb.h" #include "calendernotification.h" #include "mylocationgeotagtimerao.h" +class GeocodeUpdate; class CContactSubscriber; class CCalendarSubscriber; using namespace QTM_NAMESPACE; @@ -61,7 +62,7 @@ CPosLandmark* iLandmarkInfo; //single row address. HBufC* iAddressDetails; - //Contact id + //entry id TInt32 iUId; //Address type TInt32 iAddressType; @@ -192,11 +193,6 @@ void TriggerMaptileRequestL( TContactDbObserverEvent& aEvent ); /** - * Process the contact database event and updates the landmark database - * @param aEvent Provides information about the change event. - */ - void HandlelandmarkDatabaseL( TContactDbObserverEvent& aEvent ); - /** * Process the maptile database event and updates the maptile database * @param aEventType Provides information about the type of request address. * @param aLookupItem Provides information about single address of contact. @@ -284,6 +280,17 @@ * maptile database manipulation. */ void ManipulateMapTileDataBaseL(TLookupItem& aLookupItem); + + /** + * Crop and create multiple maptile images for different applications requirements. + */ + void CreateMultipleMaptiles( const TDesC& aMaptilePath ); + + /** + * Crop the maptile image and save the different files. + */ + void CropAndSaveImage( QString filePath, int width, + int height, QString appType, QString orientationType ); public: //From MMapTileObserver @@ -371,6 +378,9 @@ //Subscribe from calendar CCalendarSubscriber *iCalendarSubscriber; + //Geo-code class instance + GeocodeUpdate *iGeocodeUpdate; + //Last viewed contact id TInt iLastContactId; diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/mylocationsengine/src/lookupmaptiledb.cpp --- a/locationdataharvester/mylocationsengine/src/lookupmaptiledb.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationdataharvester/mylocationsengine/src/lookupmaptiledb.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -14,6 +14,8 @@ * Description: Maptile database lookup table source implementation. * */ +#include +#include #include #include "mylocationlogger.h" @@ -380,7 +382,28 @@ // Delete if no reference to maptile if (!myView.AtRow()) { - ret = iFsSession.Delete(aLookupItem.iFilePath); + QString filePath = QString::fromUtf16( aLookupItem.iFilePath.Ptr(), aLookupItem.iFilePath.Length() ); + //delete all releted maptile + QString temp=filePath; + temp.append(MAPTILE_IMAGE_PORTRAIT); + QFile file; + file.remove(temp); + + temp=filePath; + temp.append(MAPTILE_IMAGE_CONTACT); + temp.append(MAPTILE_IMAGE_LANDSCAPE); + file.remove(temp); + + temp=filePath; + temp.append(MAPTILE_IMAGE_CALENDAR); + temp.append(MAPTILE_IMAGE_LANDSCAPE); + file.remove(temp); + + temp=filePath; + temp.append(MAPTILE_IMAGE_HURRIGANES); + file.remove(temp); + + // ret = iFsSession.Delete(aLookupItem.iFilePath); } CleanupStack::PopAndDestroy(&myView); // myView diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/mylocationsengine/src/maptileinterface.cpp --- a/locationdataharvester/mylocationsengine/src/maptileinterface.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationdataharvester/mylocationsengine/src/maptileinterface.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -32,8 +32,6 @@ const TReal KInvalidLatitudeLongitude = 200.0f; const TInt KStreetLvelZoom = 16; const TInt KCityLevelZoom = 11; -const TInt KMapTileWidth= 330; -const TInt KMapTileHeight= 128; const TInt KImagePathSize=36; const TInt KMapTileWidthHeight = 256 ; _LIT(KFileExtn, ".png"); @@ -155,7 +153,7 @@ zoom = KStreetLvelZoom; } iStreetAvailable = EFalse; - TMapTileParam mapTileparam(aLatitude, aLongitude, zoom, KMapTileWidth, KMapTileHeight ); + TMapTileParam mapTileparam(aLatitude, aLongitude, zoom, MapTileWidth,MapTileHeight ); iMaptileGeocoder->GetMapTileByGeoCodeL( mapTileparam, *iFilePath ); } diff -r 96df3ab41000 -r 8db05346071b locationdataharvester/mylocationsengine/src/mylocationsengine.cpp --- a/locationdataharvester/mylocationsengine/src/mylocationsengine.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationdataharvester/mylocationsengine/src/mylocationsengine.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -17,6 +17,7 @@ */ // INCLUDE FILES +#include #include #include #include @@ -30,7 +31,6 @@ #include "contactsubscriber.h" #include "calendarsubscriber.h" #include "mylocationsengine.h" -#include "mylocationsdefines.h" #include "geocodeupdate.h" //header for GeocodeUpdate class //handle for CMyLocationsHistoryDbObserver class #include "mylocationlogger.h" @@ -91,6 +91,7 @@ MYLOCLOGSTRING("Maptile Db instance created "); + iGeocodeUpdate = new GeocodeUpdate(); iMyLocationThreeAMTimer = CLocationGeoTagTimerAO::NewL(*this); iMyLocationThreeAMTimer->StartTimer(); @@ -233,6 +234,7 @@ iContactManager(NULL), iContactSubscriber(NULL), iCalendarSubscriber(NULL), + iGeocodeUpdate(NULL), iLastContactId( -1 ) , iLastCalendarId( 0 ) { @@ -276,7 +278,8 @@ delete iCalendarSubscriber; - //free the allocated memory + delete iGeocodeUpdate; + for( TInt index = 0; index < iAddressInfo.Count(); index++ ) { delete iAddressInfo[index]; @@ -499,8 +502,7 @@ { __TRACE_CALLSTACK; - GeocodeUpdate geocodeUpdate; - geocodeUpdate.createContactdb(); + iGeocodeUpdate->createContactdb(); iContactsDb = CContactDatabase::OpenL(); // Create CContactChangeNotifier object with 'this' object. iContactChangeNotifier = CContactChangeNotifier::NewL(*iContactsDb,this); @@ -620,27 +622,30 @@ CCalEntry* calEntry = NULL; calEntry = iCalView->FetchL(entryId); CleanupStack::PushL(calEntry); - TPtrC address(calEntry->LocationL()); - if (iMyLocationsDatabaseManager->CheckIfAddressChanged(address, entryId, - ESourceCalendar)) - { - lookupItem.iFilePath.Zero(); - lookupItem.iFetchingStatus = EMapTileFetchingInProgress; - TRAP_IGNORE( iMaptileDatabase->ReSetEntryL(lookupItem) ); - if (address.Length() > 0) + if(iGeocodeUpdate->isGeocodeNotAvailable(entryId)) + { + TPtrC address(calEntry->LocationL()); + if (iMyLocationsDatabaseManager->CheckIfAddressChanged(address, entryId, + ESourceCalendar)) { - RequestMapTileImageL(address, ESourceCalendar, entryId , EChangeModify); - } - else - { - UpdateDatabaseL(NULL, entryId, ESourceCalendar, EEntryDeleted); - } - if ( lookupItem.iFilePath.Length() > 0 ) - { - iMaptileDatabase->DeleteMapTileL(lookupItem); - } - - } + lookupItem.iFilePath.Zero(); + lookupItem.iFetchingStatus = EMapTileFetchingInProgress; + TRAP_IGNORE( iMaptileDatabase->ReSetEntryL(lookupItem) ); + if (address.Length() > 0) + { + RequestMapTileImageL(address, ESourceCalendar, entryId , EChangeModify); + } + else + { + UpdateDatabaseL(NULL, entryId, ESourceCalendar, EEntryDeleted); + } + if ( lookupItem.iFilePath.Length() > 0 ) + { + iMaptileDatabase->DeleteMapTileL(lookupItem); + } + + } + } CleanupStack::PopAndDestroy(calEntry); } @@ -658,169 +663,8 @@ { TriggerMaptileRequestL(aEvent); } - - HandlelandmarkDatabaseL(aEvent); } -// ----------------------------------------------------------------------------- -// CMyLocationsEngine::HandlelandmarkDatabaseL() -// Process the contact database event and updates the landmark database -// ----------------------------------------------------------------------------- -// -void CMyLocationsEngine::HandlelandmarkDatabaseL( - TContactDbObserverEvent& aEvent) -{ - __TRACE_CALLSTACK;// If contact is modified or added, update the mylocations db - if (aEvent.iType == EContactDbObserverEventContactChanged || aEvent.iType - == EContactDbObserverEventContactAdded) - { - - CPosLandmark *preferedAddressLm = NULL; - CPosLandmark *workAddressLm = NULL; - CPosLandmark *homeAddressLm = NULL; - - QContact contactInfo = iContactManager->contact( aEvent.iContactId ); - - //Get the contact name details - QContactName name = contactInfo.detail( QContactName::DefinitionName ); - QString firstName = name.firstName(); - QString lastName = name.lastName(); - TPtrC16 tempPtr1(reinterpret_cast(firstName.utf16())); - TPtrC16 tempPtr2( reinterpret_cast (lastName.utf16())); - - TBuf landmarkName; - landmarkName.Append( tempPtr1 ); - landmarkName.Append( tempPtr2 ); - - TInt itemCount = 0; - - - double longitude, latitude; - - foreach ( QContactAddress address, contactInfo.details() ) - { - QStringList context = address.contexts(); - if ( context.isEmpty() ) // no context - { - //check whether geocordinate available - TBool geoField = IsGeoCoordinateAvailable( - contactInfo, NULL , latitude, longitude ); - if( geoField ) - { - // Get the default/prefered address details - preferedAddressLm = GetContactAddressDetailsLC( address ); - TLocality loc( TCoordinate( latitude, longitude ), 0 ); - // Fill the location details into the landmark object - preferedAddressLm->SetPositionL(loc); - preferedAddressLm->SetLandmarkNameL( landmarkName ); - itemCount++; - - } - } - else if (context.first() == QContactAddress::ContextHome ) - { - //check whether geocordinate available - TBool geoField = IsGeoCoordinateAvailable( - contactInfo, QContactAddress::ContextHome, latitude, longitude ); - if( geoField ) - { - // Get the home address details - homeAddressLm = GetContactAddressDetailsLC( address ); - TLocality loc(TCoordinate( latitude,longitude ), 0); - homeAddressLm->SetPositionL(loc); - homeAddressLm->SetLandmarkNameL( landmarkName ); - itemCount++; - } - } - else if (context.first() == QContactAddress::ContextWork ) - { - //check whether geocordinate available - TBool geoField = IsGeoCoordinateAvailable( - contactInfo, QContactAddress::ContextWork, latitude, longitude ); - if( geoField ) - { - // Get the work address details - workAddressLm = GetContactAddressDetailsLC( address ); - TLocality loc(TCoordinate( latitude, longitude ), 0); - // Fill the location details into the landmark object - workAddressLm->SetPositionL(loc); - workAddressLm->SetLandmarkNameL( landmarkName ); - itemCount++; - } - - } - } - - // if the contact item has no validated address (preferef, home or work) - if (!preferedAddressLm && !workAddressLm && !homeAddressLm) - { - if (aEvent.iType == EContactDbObserverEventContactChanged) - { - // If the contact is a modified one and it might already exist in - // mylocations db, so delete it - UpdateDatabaseL(NULL, - aEvent.iContactId, ESourceContactsPref, - EEntryDeleted); - - UpdateDatabaseL(NULL, - aEvent.iContactId, ESourceContactsHome, - EEntryDeleted); - - UpdateDatabaseL(NULL, - aEvent.iContactId, ESourceContactsWork, - EEntryDeleted); - } - } - else - { - // There is atleast one valid address present. - - // Get the TEntryChangeType for contacts. - TEntryChangeType changeType = MapChangeType( - ESourceContactsPref, aEvent.iType); - - // if prefered address available, update Mylocations. - if (preferedAddressLm) - { - UpdateDatabaseL( - preferedAddressLm, aEvent.iContactId, - ESourceContactsPref, changeType); - } - // if home address available, update Mylocations. - if (homeAddressLm) - { - UpdateDatabaseL(homeAddressLm, - aEvent.iContactId, ESourceContactsHome, changeType); - } - - // if work address available, update Mylocations. - if (workAddressLm) - { - UpdateDatabaseL(workAddressLm, - aEvent.iContactId, ESourceContactsWork, changeType); - } - - CleanupStack::PopAndDestroy( itemCount ); - } - - } - else if (aEvent.iType == EContactDbObserverEventContactDeleted) - { - // the contact is deleted, so delete the corresponding entries from database. - - // delete prefered address in database - UpdateDatabaseL(NULL, aEvent.iContactId, - ESourceContactsPref, EEntryDeleted); - - // delete work address in database - UpdateDatabaseL(NULL, aEvent.iContactId, - ESourceContactsWork, EEntryDeleted); - - // delete home address in database - UpdateDatabaseL(NULL, aEvent.iContactId, - ESourceContactsHome, EEntryDeleted); - } -} // ----------------------------------------------------------------------------- // CMyLocationsEngine::TriggerMaptileRequestL() @@ -835,6 +679,7 @@ // If contact is deleted delete from mylocations db if (aEvent.iType == EContactDbObserverEventContactDeleted) { + //Delete the entries from maptile database lookupItem.iSource = ESourceContactsPref; TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); @@ -844,6 +689,16 @@ lookupItem.iSource = ESourceContactsHome; TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); + // Delete entries from mylocation database + TRAP_IGNORE( UpdateDatabaseL( NULL, aEvent.iContactId, + ESourceContactsPref, EEntryDeleted )); + + TRAP_IGNORE( UpdateDatabaseL( NULL, aEvent.iContactId, + ESourceContactsHome, EEntryDeleted )); + + TRAP_IGNORE( UpdateDatabaseL( NULL, aEvent.iContactId, + ESourceContactsWork, EEntryDeleted ) ); + MYLOCLOGSTRING("EContactDbObserverEventContactDeleted "); return; } @@ -852,7 +707,17 @@ iEventType = aEvent.iType; QContact contactInfo = iContactManager->contact( aEvent.iContactId ); - + //Get the contact name details + QContactName name = contactInfo.detail( QContactName::DefinitionName ); + QString firstName = name.firstName(); + QString lastName = name.lastName(); + TPtrC16 tempPtr1(reinterpret_cast(firstName.utf16())); + TPtrC16 tempPtr2( reinterpret_cast (lastName.utf16())); + + TBuf landmarkName; + landmarkName.Append( tempPtr1 ); + landmarkName.Append( tempPtr2 ); + CPosLandmark *preferedAddressLm = NULL; CPosLandmark *workAddressLm = NULL; CPosLandmark *homeAddressLm = NULL; @@ -900,6 +765,7 @@ lookupItem.iSource = ESourceContactsPref; if (preferedAddressLm) { + preferedAddressLm->SetLandmarkNameL( landmarkName ); MYLOCLOGSTRING("preferedAddressLm address changed" ); if ( iMyLocationsDatabaseManager->CheckIfAddressChanged(*preferedAddressLm, @@ -931,6 +797,7 @@ lookupItem.iSource = ESourceContactsHome; if (homeAddressLm) { + homeAddressLm->SetLandmarkNameL( landmarkName ); MYLOCLOGSTRING("homeAddressLm address changed" ); if ( iMyLocationsDatabaseManager->CheckIfAddressChanged(*homeAddressLm, aEvent.iContactId, ESourceContactsHome) ) @@ -959,6 +826,7 @@ lookupItem.iSource = ESourceContactsWork; if (workAddressLm) { + workAddressLm->SetLandmarkNameL( landmarkName ); MYLOCLOGSTRING("workAddressLm address changed" ); if ( iMyLocationsDatabaseManager->CheckIfAddressChanged(*workAddressLm, aEvent.iContactId, ESourceContactsWork) ) @@ -995,6 +863,7 @@ MYLOCLOGSTRING("EContactDbObserverEventContactAdded" ); if (preferedAddressLm) { + preferedAddressLm->SetLandmarkNameL( landmarkName ); //create entry in the data base and maintain a fetching state. lookupItem.iSource = ESourceContactsPref; iMaptileDatabase->CreateEntryL(lookupItem); @@ -1003,6 +872,7 @@ } if (homeAddressLm) { + homeAddressLm->SetLandmarkNameL( landmarkName ); lookupItem.iSource = ESourceContactsHome; iMaptileDatabase->CreateEntryL(lookupItem); RequestMapTileImageL(*homeAddressLm, ESourceContactsHome, @@ -1010,6 +880,7 @@ } if (workAddressLm) { + workAddressLm->SetLandmarkNameL( landmarkName ); lookupItem.iSource = ESourceContactsWork; iMaptileDatabase->CreateEntryL(lookupItem); RequestMapTileImageL(*workAddressLm, ESourceContactsWork, @@ -1475,6 +1346,14 @@ } } + + + +// ----------------------------------------------------------------------------- +// CMyLocationsEngine::MyLocationThreeAMTimerExpiredL() +// Triggers the maptile fetching at 3.00 for the network failure cases. +// ----------------------------------------------------------------------------- +// void CMyLocationsEngine::MyLocationThreeAMTimerExpiredL() { //Forward the event for maptile fetching only if maptile plugin available @@ -1494,6 +1373,18 @@ case ESourceContactsPref: { QContact contactInfo = iContactManager->contact( iItem.iUid ); + + //Get the contact name details + QContactName name = contactInfo.detail( QContactName::DefinitionName ); + QString firstName = name.firstName(); + QString lastName = name.lastName(); + TPtrC16 tempPtr1(reinterpret_cast(firstName.utf16())); + TPtrC16 tempPtr2( reinterpret_cast (lastName.utf16())); + + TBuf landmarkName; + landmarkName.Append( tempPtr1 ); + landmarkName.Append( tempPtr2 ); + CPosLandmark *addressLm = NULL; foreach ( QContactAddress address, contactInfo.details() ) @@ -1509,6 +1400,7 @@ addressLm = GetContactAddressDetailsLC( address ); if( addressLm ) { + addressLm->SetLandmarkNameL( landmarkName ); RequestMapTileImageL( *addressLm, ( TUidSourceType )iItem.iSource, iItem.iUid, EContactDbObserverEventContactChanged ); CleanupStack::PopAndDestroy( addressLm ); @@ -1571,6 +1463,7 @@ if ( aErrCode == KErrNone ) { + CreateMultipleMaptiles( aMapTilePath ); lookupItem.iFilePath.Copy(aMapTilePath); lookupItem.iFetchingStatus = EMapTileFectchingCompleted; @@ -1669,8 +1562,27 @@ iMaptileDatabase->CreateEntryL(aLookupItem); } } - iMyLocationsDatabaseManager->UpdateMapTilePath( aLookupItem.iUid, aLookupItem.iSource, - aLookupItem.iFilePath ); + if (aLookupItem.iFetchingStatus == EMapTileFetchingUnknownError + || aLookupItem.iFetchingStatus == EMapTileFetchingNetworkError) + { + TRAP_IGNORE( UpdateDatabaseL( NULL, + aLookupItem.iUid, aLookupItem.iSource, EEntryDeleted ) ); + + } + else + { + TPtrC8 ptr(reinterpret_cast(MAPTILE_IMAGE_HURRIGANES)); + HBufC* buffer = NULL; + buffer=HBufC::NewLC(ptr.Length()); + buffer->Des().Copy(ptr); + if(buffer) + { + aLookupItem.iFilePath.Append(*buffer); + } + CleanupStack::PopAndDestroy(buffer); + iMyLocationsDatabaseManager->UpdateMapTilePath(aLookupItem.iUid, + aLookupItem.iSource, aLookupItem.iFilePath); + } } // ----------------------------------------------------------------------------- @@ -1690,7 +1602,9 @@ { //TODO: case ESourceCalendar: - { + { + iGeocodeUpdate->updateGeocodeToCalenderDB(iMapTileRequestQueue[0]->iUId, + aLatitude,aLongitude); CPosLandmark *landmark = NULL; landmark = iMapTileInterface->GetLandMarkDetails(); if (NULL != landmark) @@ -1708,17 +1622,23 @@ case ESourceContactsWork: case ESourceContactsHome: { - GeocodeUpdate geocodeUpdate; - geocodeUpdate.updateGeocodeToContactDB( + iGeocodeUpdate->updateGeocodeToContactDB( iMapTileRequestQueue[0]->iUId, iMapTileRequestQueue[0]->iAddressType, aLatitude, aLongitude); + //Update mylocation database + TRAP_IGNORE( UpdateDatabaseL( + iMapTileRequestQueue[0]->iLandmarkInfo, + iMapTileRequestQueue[0]->iUId, + iMapTileRequestQueue[0]->iAddressType, + MapChangeType( + static_cast( iMapTileRequestQueue[0]->iAddressType ), + iMapTileRequestQueue[0]->iEventType ))); + MYLOCLOGSTRING("Geo-codinate updated to contact db"); break; } }; - - } } @@ -1757,5 +1677,71 @@ } } + +// ----------------------------------------------------------------------------- +// CMyLocationsEngine::CreateMultipleMaptiles() +// ----------------------------------------------------------------------------- +// +void CMyLocationsEngine::CreateMultipleMaptiles( const TDesC& aMaptilePath ) +{ + __TRACE_CALLSTACK; + QString filePath = QString::fromUtf16( aMaptilePath.Ptr(), aMaptilePath.Length() ); + + //Portrait image , common for contacts/calendar/context menu + CropAndSaveImage( filePath, + MaptilePortraitWidth, + MaptilePortraitHeight, + QString(), + QString( MAPTILE_IMAGE_PORTRAIT ) ); + + //Landscape image for contacts + CropAndSaveImage( filePath, + MaptileContactLandscapeWidth, + MaptileContactLandscapeHeight, + QString( MAPTILE_IMAGE_CONTACT ), + QString( MAPTILE_IMAGE_LANDSCAPE ) ); + + //Ladscape image for calendar + CropAndSaveImage( filePath, + MaptileCalendarLandscapeWidth, + MaptileCalendarLandscapeHeight, + QString( MAPTILE_IMAGE_CALENDAR ), + QString( MAPTILE_IMAGE_LANDSCAPE ) ); + + //Image for hurriganes + CropAndSaveImage( filePath, + MaptileHurriganesWidth, + MaptileHurriganesHeight, + QString( MAPTILE_IMAGE_HURRIGANES ), + QString() ); + QFile file(filePath); + file.remove(); +} + + +// ----------------------------------------------------------------------------- +// CMyLocationsEngine::CropAndSaveImage() +// ----------------------------------------------------------------------------- +// +void CMyLocationsEngine::CropAndSaveImage( QString filePath, int width, + int height, QString appType, QString orientationType ) +{ + __TRACE_CALLSTACK; + QImage SourcePNG( filePath ); + QImage sourcePixmap( SourcePNG.convertToFormat(QImage::Format_Indexed8)); + QImage targetPixmap( sourcePixmap.copy( + ( MapTileWidth - width )/2, + ( MapTileHeight - height )/2 , + width, + height ) ); + + QString targetImage; + targetImage.append( filePath ); + targetImage.append( appType ); + targetImage.append( orientationType ); + targetPixmap.save( targetImage, MAPTILE_IMAGE_TYPE ); + +} + //End of file diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/inc/hgwidgetdatamodel.h --- a/locationpickerservice/inc/hgwidgetdatamodel.h Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/inc/hgwidgetdatamodel.h Tue Jul 06 14:10:28 2010 +0300 @@ -51,7 +51,11 @@ //reset the model with new data void resetModel( LocationPickerProxyModel *aProxyModel ); +#ifdef LOCPICKER_UNIT_TEST +public: +#else private: +#endif //Image Type TImageType mImageType; //default Image type diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/inc/locationpickerappwindow.h --- a/locationpickerservice/inc/locationpickerappwindow.h Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/inc/locationpickerappwindow.h Tue Jul 06 14:10:28 2010 +0300 @@ -24,10 +24,9 @@ // Forward declarations class LocationPickerSearchView; class LocationPickerDocumentLoader; -class LocationPickerPotraitView; +class LocationPickerView; class LocationPickerService; class LocationPickerProxyModel; -class LocationPickerLandscapeView; class LocationPickerContent; class LocationPickerAppWindow: public HbMainWindow @@ -41,19 +40,22 @@ // destructor ~LocationPickerAppWindow(); -private: - //Loads the Potrait View - void loadPotrait(); - //Loads landscape View - void loadLandscape(); +#ifdef LOCPICKER_UNIT_TEST +public slots: +#else +private slots: +#endif //Connect the slots for Potrait view - void connectPotraitSlots(); - //Connect the slots for Landscape view - void connectLandscapeSlots(); + void connectSlots(); public slots: // a list item is selected void itemSelected( quint32 aLm ); +#ifdef LOCPICKER_UNIT_TEST +public slots: +#else private slots: +#endif + //activate search view void activateSearchView(); //activate locationpicker view @@ -62,28 +64,23 @@ void changeOrientation( Qt::Orientation ); //complete the service void serviceComplete(); - //sets the category ID during orientation change in collection content - void setCategoryId( quint32 acategoryId ); - //handles orientation change in collection list - void handleCollectionList(); - //handle all List - void allListHandle(); - //clear content models - void clearContentModels(); + //slot to close details dialog (if open) + void closeDetailsDialog(); + +#ifdef LOCPICKER_UNIT_TEST +public: +#else private: +#endif // search view LocationPickerSearchView* mLocationPickerSearchView; //document loader LocationPickerDocumentLoader* mLocationPickerDocumentLoader; //location picker potrait view - LocationPickerPotraitView* mLocationPickerPotraitView; - //location picker landscape view - LocationPickerLandscapeView* mLocationPickerLandscapeView; + LocationPickerView* mLocationPickerView; //locationpicker content LocationPickerContent* mLocationPickerContent; //location picker service; LocationPickerService *mService; - //View Type - TViewType mviewType; }; #endif // LOCATIONPICKERAPPWINDOW_H diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/inc/locationpickercollectioncontent.h --- a/locationpickerservice/inc/locationpickercollectioncontent.h Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/inc/locationpickercollectioncontent.h Tue Jul 06 14:10:28 2010 +0300 @@ -29,19 +29,16 @@ { public: // constructor - LocationPickerCollectionContent( Qt::Orientations aOrientation , quint32 aCollectionid ); + LocationPickerCollectionContent( quint32 aCollectionid ); //Destructor ~LocationPickerCollectionContent(); //get proxy model LocationPickerProxyModel* getProxyModel(); - //get standard model - QStandardItemModel* getStandardModel(); // gets the data pointed to by index and copies to the aValue void getData( QModelIndex aIndex, quint32& aValue ); //return true if location entry is found bool locationFound(); private: - Qt::Orientations mOrientation; LocationPickerProxyModel *mProxyModel; QStandardItemModel *mModel; LocationPickerDataManager *mDataManager; diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/inc/locationpickercollectionlistcontent.h --- a/locationpickerservice/inc/locationpickercollectionlistcontent.h Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/inc/locationpickercollectionlistcontent.h Tue Jul 06 14:10:28 2010 +0300 @@ -29,7 +29,7 @@ public: // constructor - LocationPickerCollectionListContent( Qt::Orientation aOrientation ); + LocationPickerCollectionListContent(); // destructor ~LocationPickerCollectionListContent(); @@ -39,7 +39,6 @@ void getData( QModelIndex aIndex, quint32& aValue ); private: - Qt::Orientation mOrientation; //standard Item Model QStandardItemModel *mModel; //datamanager diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/inc/locationpickercontent.h --- a/locationpickerservice/inc/locationpickercontent.h Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/inc/locationpickercontent.h Tue Jul 06 14:10:28 2010 +0300 @@ -39,20 +39,16 @@ // destructor ~LocationPickerContent(); - //get standard List Model - QStandardItemModel* getStandardListModel(); - //get standard Grid Model QStandardItemModel* getStandardModel(); void createNoEntryDisplay( QStandardItemModel *aModel ); - bool populateModel( Qt::Orientation aOrientation ); + bool populateModel(); private: Qt::Orientations mOrientation; LocationPickerDataManager *mDataManager; - QStandardItemModel *mListModel; QStandardItemModel *mStandardModel; }; diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/inc/locationpickerdatamanager.h --- a/locationpickerservice/inc/locationpickerdatamanager.h Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/inc/locationpickerdatamanager.h Tue Jul 06 14:10:28 2010 +0300 @@ -40,7 +40,7 @@ public: // populates the model with data bool populateModel( QStandardItemModel &aModel, TViewType aViewType, - Qt::Orientations aOrientation,quint32 aCollectionId = 0); + quint32 aCollectionId = 0); // gets the location item void getLocationItem( quint32 aLmId, QLocationPickerItem &aItem ); diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/inc/locationpickerdatamanager_p.h --- a/locationpickerservice/inc/locationpickerdatamanager_p.h Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/inc/locationpickerdatamanager_p.h Tue Jul 06 14:10:28 2010 +0300 @@ -39,7 +39,7 @@ // populates the model with data bool populateModel( QStandardItemModel &aModel, TViewType aViewType, - const Qt::Orientations aOrientation, quint32 aCollectionId = 0 ); + quint32 aCollectionId = 0 ); // gets the location item void getLocationItem( quint32 aLmId, QLocationPickerItem &aItem ); @@ -51,7 +51,6 @@ void populateCollections( QList& aCount ); private: - Qt::Orientations mOrientation; QStandardItemModel *mModel; TViewType mViewType; LocationDataLookupDb *mDb; diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/inc/locationpickerlandscapeview.h --- a/locationpickerservice/inc/locationpickerlandscapeview.h Wed Jun 23 18:07:15 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: LocationPickerLandscapeView declaration -* -*/ - -#ifndef LOCATIONPICKERLANDSCAPEVIEW_H_ -#define LOCATIONPICKERLANDSCAPEVIEW_H_ - - - -#include -#include -#include "locationpickertypes.h" - -//forward declarations -class HbListView; -class QStandardItemModel; -class HbAction; -class QGraphicsLinearLayout; -class HbLabel; -class HgWidgetDataModel; -class HbTextItem; -class HgMediawall; -class QPoint; -class HbMenu; - -class LocationPickerProxyModel; -class LocationPickerCollectionContent; -class LocatipnPickerProxyModel; - - - -/** - * Class defines the location picker view - */ -class LocationPickerLandscapeView : public HbView -{ - - Q_OBJECT -public: - // constructor - LocationPickerLandscapeView( HbDocumentLoader* aLoader ); - // destructor - ~LocationPickerLandscapeView(); -public: - //get the items from docml and connect to respective slots - void init( Qt::Orientation aOrientation, QStandardItemModel *aModel ); - //Set the appropriate model on hgwidget - void manageHgWidget(); - //Create collection list and sets to list view - void setCollectionData( quint32 aCategoryId ); - //Set Ctegory ID - void setCategoryID( quint32 aCategoryId ); - //Get the view type - TViewType getViewType(); - //set the view type - void setViewType( TViewType aViewType ); - //clear collection content - void clearContentModel(); -private slots: - //slot to handle list item actions - void handleActivated( const QModelIndex &aIndex ); - //slots to handle menu action items - void sortDescending(); - void sortAscending(); - void backButtonTriggered(); - //slot to handle search tab - void searchTabTriggered(); - //launch context menu - void launchPopUpMenu(const QModelIndex &aIndex, const QPointF &aPoint); - //handle long press - void handleLongPress(); -public slots: - //slot to handle all tab - void allTabTriggered(); - //slot to handle collection tab - void colectionTabTriggered(); -signals: - void switchToSearchView(); - void handleCollectionList(); - void selectItem( quint32 aLm ); - void completeService(); - void sendCategoryID( quint32 acategoryId ); - void collectionContentExited(); -private: - //document loader - HbDocumentLoader* mDocumentLoader; - //locationPickerProxyModel - LocationPickerProxyModel *mProxyModel; - QStandardItemModel *mStandardModel; - //actions - HbAction *mAllAction; - HbAction *mCollectionAction; - HbAction *mSearchAction; - HbAction *mAscendingAction; - HbAction *mDescendingAction; - //secondary back action - HbAction *mLandscapeBackAction; - //collection content - LocationPickerCollectionContent *mCollectionContent; - //view type - TViewType mViewType ; - //get the collection/category id - quint32 mCategoryId; - //model for hurriganes - HgWidgetDataModel *mModel; - //hurriganes - HgMediawall *mWidget; - //Linear layout - QGraphicsLinearLayout *mLayout; - //text Item to display No Entry - HbTextItem* mEmptyLabel; - QModelIndex mIndex; - //context menu - HbMenu* mLongPressMenu; -}; - -#endif /* LOCATIONPICKERLANDSCAPEVIEW_H_ */ diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/inc/locationpickerpotraitview.h --- a/locationpickerservice/inc/locationpickerpotraitview.h Wed Jun 23 18:07:15 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,131 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: LocationPickerPotraitView declaration -* -*/ - -#ifndef LOCATIONPICKERPOTRAITVIEW_H -#define LOCATIONPICKERPOTRAITVIEW_H - - -#include -#include -#include "locationpickertypes.h" -#include - -#include - -//forward declarations -class HbListView; -class QStandardItemModel; -class LocationPickerProxyModel; -class LocationPickerCollectionListContent; -class LocationPickerCollectionContent; -class HbListViewItem; -class HbAction; -class HbAbstractViewItem; -class HbMenu; -class QPoint; -/** - * Class defines the location picker view - */ -class LocationPickerPotraitView : public HbView -{ - Q_OBJECT -public: - // constructor - LocationPickerPotraitView( HbDocumentLoader* aLoader ); - // destructor - ~LocationPickerPotraitView(); -public: - //disable the tabs - void disableTabs( QStandardItemModel *aModel ); - //get the items from docml and connect to respective slots - void init( bool aPopulated, Qt::Orientation aOrientation, QStandardItemModel *aModel ); - //Set the appropriate model on list view - void manageListView(); - //Create collection list and sets to list view - void setCollectionData( quint32 acategoryId ); - //Set Ctegory ID - void setCategoryID( quint32 acategoryId ); - //Get the view type - TViewType getViewType(); - //set the view type - void setViewType( TViewType aViewType ); - //clear collection Model - void clearContentModel(); -private slots: - //slot to handle list item actions - void handleActivated( const QModelIndex &aIndex ); - //slots to handle menu action items - void sortDescending(); - void sortAscending(); - void backTriggered(); - //slot to handle search tab - void searchTabTriggered(); - //launch context menu - void launchPopUpMenu(HbAbstractViewItem *aItem, const QPointF &aPoint); - //handle long press - void handleLongPress(); -public slots: - //slot to handle all tab - void allTabTriggered(); - //slot to handle collection tab - void colectionTabTriggered(); -signals: - void switchToSearchView(); - void selectItem( quint32 aLm ); - void completeService(); - void sendCategoryID( quint32 aCategoryId ); - void handleAllList(); - void collectionContentExited(); -private: - //document loader - HbDocumentLoader* mDocumentLoader; - // collection list content - LocationPickerCollectionListContent* mLocationPickerCollectionListContent; - //locationPickerProxyModel - LocationPickerProxyModel *mProxyModel; - //standard model - QStandardItemModel *mModel; - //actions - HbAction *mAllAction; - HbAction *mCollectionAction; - HbAction *mSearchAction; - HbAction *mAscendingAction; - HbAction *mDescendingAction; - //secondary back action - HbAction *mPotraitBackAction; - // list view - HbListView *mListView; - //list item - HbListViewItem *mListItem; - //collection content - LocationPickerCollectionContent *mCollectionContent; - //ViewType - TViewType mViewType ; - // get the collection/category id - quint32 mCategoryId; - //label to show current view - QModelIndex mIndex; - //linear Layout - QGraphicsLinearLayout *mLinerLayout; - //label to show detail of view - HbLabel *mColllabel; - //context menu - HbMenu* mLongPressMenu; -}; - - -#endif // LOCATIONPICKERPOTRAITVIEW_H diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/inc/locationpickerproxymodel.h --- a/locationpickerservice/inc/locationpickerproxymodel.h Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/inc/locationpickerproxymodel.h Tue Jul 06 14:10:28 2010 +0300 @@ -31,7 +31,7 @@ public: // constructor - LocationPickerProxyModel( Qt::Orientations aOrientation , QObject *parent = 0 ); + LocationPickerProxyModel( QObject *parent = 0 ); // used to void filterParameterChanged( QString aSearchText ); @@ -45,7 +45,6 @@ private: // search string QString mSearchText; - Qt::Orientations mOrientation; }; diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/inc/locationpickersearchview.h --- a/locationpickerservice/inc/locationpickersearchview.h Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/inc/locationpickersearchview.h Tue Jul 06 14:10:28 2010 +0300 @@ -48,7 +48,11 @@ void init( QStandardItemModel *aModel ); private: void getData( QModelIndex aIndex, quint32& aValue ); +#ifdef LOCPICKER_UNIT_TEST +public slots: +#else private slots: +#endif // slot to perform search void doSearch( QString aCriteria ); // slot to handle select event on a list item @@ -59,12 +63,18 @@ void launchPopUpMenu(HbAbstractViewItem *aItem, const QPointF &aPoint); //handle long press void handleLongPress(); + //delete context menu + void deleteMenu(); signals: //signals to switch current view void switchView(); //signals when any item is selected void selectItem( quint32 aLm ); +#ifdef LOCPICKER_UNIT_TEST +public: +#else private: +#endif //proxymodel used for sort and filter LocationPickerProxyModel *mProxyModel; // model for the view @@ -82,6 +92,8 @@ QModelIndex mIndex; //context menu HbMenu* mLongPressMenu; + //select action + HbAction* mSelectAction; }; diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/inc/locationpickertypes.h --- a/locationpickerservice/inc/locationpickertypes.h Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/inc/locationpickertypes.h Tue Jul 06 14:10:28 2010 +0300 @@ -41,8 +41,6 @@ //Places collection icon const QString KCollectionsPlaces("qtg_small_favorite"); -//Contacts type prefered icon -const QString KContactPrefIcon("qtg_mono_favourites"); //Contacts type home icon const QString KContactHomeIcon("qtg_mono_home"); //Contacts type work icon diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/inc/locationpickerview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationpickerservice/inc/locationpickerview.h Tue Jul 06 14:10:28 2010 +0300 @@ -0,0 +1,171 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: LocationPickerView declaration +* +*/ + +#ifndef LOCATIONPICKERVIEW_H +#define LOCATIONPICKERVIEW_H + + +#include +#include +#include "locationpickertypes.h" +#include +#include + +#include +#include +//forward declarations +class HbListView; +class QStandardItemModel; +class LocationPickerProxyModel; +class LocationPickerCollectionListContent; +class LocationPickerCollectionContent; +class HgWidgetDataModel; +class HbListViewItem; +class HbAction; +class HbAbstractViewItem; +class QPoint; +class HbDialog; +class HbLabel; +/** + * Class defines the location picker view + */ +class LocationPickerView : public HbView +{ + Q_OBJECT +public: + // constructor + LocationPickerView( HbDocumentLoader* aLoader ); + // destructor + ~LocationPickerView(); +public: + //disable the tabs + void disableTabs(); + //get the items from docml and connect to respective slots + void init( Qt::Orientation aOrientation, QStandardItemModel *aModel ); + //Set the appropriate model on list view + void manageListView(); + //create hurriganes widget + void createHurriganesWidget(); + //manage hurriganes view + void manageHgWidget(); + //Create collection list and sets to list view + void setCollectionData( quint32 acategoryId ); + //Get the view type + TViewType getViewType(); + //set the view type + void setViewType( TViewType aViewType ); + //clear collection Model + void clearContentModel(); + void removeDetailsLabel(); + //close the popupdialog + void closeDetailsDialog(); +#ifdef LOCPICKER_UNIT_TEST +public: +#else +private: +#endif + void displayNoEntries(); +#ifdef LOCPICKER_UNIT_TEST +public slots: +#else +private slots: +#endif + //slot to handle list item actions + void handleActivated( const QModelIndex &aIndex ); + //slots to handle menu action items + void sortDescending(); + void sortAscending(); + //handle secondary back action + void backTriggered(); + //slot to handle search tab + void searchTabTriggered(); + //context menu + void launchPopUpMenu( HbAbstractViewItem *aItem, const QPointF &aPoint ); + //launch context menu + void launchPopUpMenu( const QModelIndex &aIndex, const QPointF &aPoint ); + //handle select event + void handleSelect(); + //handle details event + void handleDetails(); + //slot to handle all tab + void allTabTriggered(); + //slot to handle collection tab + void colectionTabTriggered(); + //delete context menu + void deleteMenu(); +signals: + void switchToSearchView(); + void selectItem( quint32 aLm ); + void completeService(); +#ifdef LOCPICKER_UNIT_TEST +public: +#else +private: +#endif + //document loader + HbDocumentLoader* mDocumentLoader; + // collection list content + LocationPickerCollectionListContent* mLocationPickerCollectionListContent; + //locationPickerProxyModel + LocationPickerProxyModel *mProxyModel; + //standard model + QStandardItemModel *mModel; + //actions + HbAction *mAllAction; + HbAction *mCollectionAction; + HbAction *mSearchAction; + HbAction *mAscendingAction; + HbAction *mDescendingAction; + //secondary back action + HbAction *mBackAction; + // list view + HbListView *mListView; + //list item + HbListViewItem *mListItem; + //collection content + LocationPickerCollectionContent *mCollectionContent; + //ViewType + TViewType mViewType ; + // get the collection/category id + quint32 mCategoryId; + //label to show current view + QModelIndex mIndex; + //linear Layout + QGraphicsLinearLayout *mLinerLayout; + //model for hurriganes + HgWidgetDataModel *mHgModel; + //hurriganes + HgWidget *mWidget; + // label to show view details + HbLabel *mColllabel; + //text item to show no entries + HbTextItem* mEmptyLabel; + //pop up dialog to show details + HbDialog* mDialog; + HbLabel* mMapIconLabel; + HbLabel* mTitleLabel; + HbLabel* mAddressMiddle; + HbLabel* mAddressBottom; + HbAction* mDone; + HbMenu* mLongPressMenu; + HbAction* mSelectAction; + HbAction* mDetailsAction; + bool mPopulated; +}; + + +#endif // LOCATIONPICKERVIEW_H diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/locationpickerservice.pro --- a/locationpickerservice/locationpickerservice.pro Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/locationpickerservice.pro Tue Jul 06 14:10:28 2010 +0300 @@ -66,8 +66,7 @@ src/locationpickerservice.cpp \ src/locationpickerdatamanager.cpp \ src/locationpickerdatamanager_p.cpp \ - src/locationpickerpotraitview.cpp \ - src/locationpickerlandscapeview.cpp \ + src/locationpickerview.cpp \ src/locationpickerdocumentloader.cpp \ src/hgwidgetdatamodel.cpp @@ -84,8 +83,7 @@ inc/locationpickerservice.h \ inc/locationpickerdatamanager.h \ inc/locationpickerdatamanager_p.h \ - inc/locationpickerpotraitview.h \ - inc/locationpickerlandscapeview.h \ + inc/locationpickerview.h \ inc/locationpickerdocumentloader.h \ inc/hgwidgetdatamodel.h diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/resources/location.hgmediawall.css --- a/locationpickerservice/resources/location.hgmediawall.css Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/resources/location.hgmediawall.css Tue Jul 06 14:10:28 2010 +0300 @@ -1,18 +1,18 @@ HgMediawall#location[scrollBarPolicy="ScrollBarAlwaysOff"] { layout:layout-noscrollbar; - front-cover-elevation-factor:0.7; + front-cover-elevation-factor:0.5; } HgMediawall#location[!scrollBarPolicy="ScrollBarAlwaysOff"] { layout:layout-scrollbar; - front-cover-elevation-factor:0.7; + front-cover-elevation-factor:0.5; } HgMediawall#location::title { - font-variant:primary; + font-variant:secondary; text-align: center center; left:-var(hb-param-margin-gene-screen); right:var(hb-param-margin-gene-screen); diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/resources/location.hgmediawall.widgetml --- a/locationpickerservice/resources/location.hgmediawall.widgetml Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/resources/location.hgmediawall.widgetml Tue Jul 06 14:10:28 2010 +0300 @@ -21,10 +21,10 @@ - + - - + + diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/resources/locationpicker.qrc --- a/locationpickerservice/resources/locationpicker.qrc Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/resources/locationpicker.qrc Tue Jul 06 14:10:28 2010 +0300 @@ -1,8 +1,8 @@ - locationpickerpotrait.docml - locationpickerlandscape.docml + locationpickerview.docml locationpickersearchview.docml + popupdialog.docml location.hgmediawall.widgetml location.hgmediawall.css diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/resources/locationpickerlandscape.docml --- a/locationpickerservice/resources/locationpickerlandscape.docml Wed Jun 23 18:07:15 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/resources/locationpickerpotrait.docml --- a/locationpickerservice/resources/locationpickerpotrait.docml Wed Jun 23 18:07:15 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/resources/locationpickerview.docml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationpickerservice/resources/locationpickerview.docml Tue Jul 06 14:10:28 2010 +0300 @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/resources/popupdialog.docml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationpickerservice/resources/popupdialog.docml Tue Jul 06 14:10:28 2010 +0300 @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/src/hgwidgetdatamodel.cpp --- a/locationpickerservice/src/hgwidgetdatamodel.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/src/hgwidgetdatamodel.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -76,7 +76,6 @@ // ---------------------------------------------------------------------------- QVariant HgWidgetDataModel::data(const QModelIndex &aIndex, int aRole) const { - Q_ASSERT(aIndex.row()>=0); int row= aIndex.row(); int col = aIndex.column(); //get proxy model index @@ -102,23 +101,24 @@ case Qt::DisplayRole: { QStringList displayText; - QString adressDetail = mProxyModel->data(proxyModelIndex,Qt::DisplayRole).toString(); + QStringList adressDetail = mProxyModel->data(proxyModelIndex,Qt::DisplayRole).toStringList(); + QString displayString = adressDetail[0]+KSeparator+KSpace+adressDetail[1]; QString text(""); - displayText <data(proxyModelIndex,Qt::DecorationRole).toString(); - if (iconName.isNull()) + QString iconName = mProxyModel->data(proxyModelIndex,Qt::UserRole+1).toString(); + if (iconName.isEmpty()) { returnValue = mDefaultImage; } else { - QString adressType = mProxyModel->data(proxyModelIndex,Qt::UserRole+1).toString(); + QString adressType = mProxyModel->data(proxyModelIndex,Qt::UserRole+2).toString(); QPixmap mapPixmap(iconName); int mapWidth = mapPixmap.width(); int mapHeight = mapPixmap.height(); diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/src/locationpickerappwindow.cpp --- a/locationpickerservice/src/locationpickerappwindow.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/src/locationpickerappwindow.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -20,11 +20,10 @@ #include "qlocationpickeritem.h" #include "locationpickersearchview.h" -#include "locationpickerpotraitview.h" +#include "locationpickerview.h" #include "locationpickerservice.h" #include "locationpickerdatamanager.h" #include "locationpickerdocumentloader.h" -#include "locationpickerlandscapeview.h" #include "locationpickercontent.h" // ---------------------------------------------------------------------------- @@ -34,11 +33,9 @@ :HbMainWindow(parent, windowFlags), mLocationPickerSearchView(NULL), mLocationPickerDocumentLoader(NULL), - mLocationPickerPotraitView(NULL), - mLocationPickerLandscapeView(NULL), + mLocationPickerView(NULL), mLocationPickerContent(NULL), - mService(NULL), - mviewType(ELocationPickerContent) + mService(NULL) { // create the service object; mService = new LocationPickerService(this); @@ -46,47 +43,32 @@ //create document loader object mLocationPickerDocumentLoader = new LocationPickerDocumentLoader(); - bool ok = false; - //load the Locationpicker portrait view - mLocationPickerDocumentLoader->load(":/locationpickerpotrait.docml", &ok); + //load the Locationpicker view + mLocationPickerDocumentLoader->load(":/locationpickerview.docml", &ok); Q_ASSERT_X(ok, "locationpickerservice", "invalid DocML file"); //find graphics location picker potrait view - QGraphicsWidget *locationPickerWidget = mLocationPickerDocumentLoader->findWidget("LocationPickerPotraitView"); + QGraphicsWidget *locationPickerWidget = mLocationPickerDocumentLoader->findWidget("LocationPickerView"); Q_ASSERT_X((locationPickerWidget != 0), "locationpickerservice", "invalid DocML file"); - mLocationPickerPotraitView = qobject_cast(locationPickerWidget); - bool populated = mLocationPickerContent->populateModel(Qt::Vertical); - //initialize potrait widgets and connect to respective signals - mLocationPickerPotraitView->init(populated, Qt::Vertical, mLocationPickerContent->getStandardListModel()); - connectPotraitSlots(); + mLocationPickerView = qobject_cast(locationPickerWidget); + bool populated = mLocationPickerContent->populateModel(); + connectSlots(); if(!populated) { - mLocationPickerPotraitView->disableTabs(mLocationPickerContent->getStandardListModel()); - addView( mLocationPickerPotraitView ); - setCurrentView(mLocationPickerPotraitView); + mLocationPickerView->disableTabs(); + addView(mLocationPickerView); + setCurrentView(mLocationPickerView); } else - { - addView( mLocationPickerPotraitView ); - - mLocationPickerDocumentLoader->reset(); - - //load the Locationpicker landscape view - mLocationPickerDocumentLoader->load(":/locationpickerlandscape.docml", &ok); - Q_ASSERT_X(ok, "locationpickerservice", "invalid DocML file"); - //find graphics location picker landscape view - locationPickerWidget = mLocationPickerDocumentLoader->findWidget("LocationPickerLandscapeView"); - Q_ASSERT_X((locationPickerWidget != 0), "locationpickerservice", "invalid DocML file"); - mLocationPickerLandscapeView = qobject_cast(locationPickerWidget); - mLocationPickerContent->populateModel(Qt::Horizontal); - //initialize widgets and connect to respective signals - mLocationPickerLandscapeView->init(Qt::Horizontal, mLocationPickerContent->getStandardModel()); - connectLandscapeSlots(); - addView(mLocationPickerLandscapeView); - //connect to orientationChanged signal - connect(this, SIGNAL(orientationChanged(Qt::Orientation)),this, SLOT(changeOrientation(Qt::Orientation))); - //launch the view in current orientation - changeOrientation(this->orientation()); + { + //initialize potrait widgets and connect to respective signals + mLocationPickerView->init( this->orientation(), mLocationPickerContent->getStandardModel()); + addView( mLocationPickerView ); + setCurrentView(mLocationPickerView); + //connect to orientationChanged signal + connect(this, SIGNAL(orientationChanged(Qt::Orientation)),this, SLOT(changeOrientation(Qt::Orientation))); + connect(this, SIGNAL(aboutToChangeOrientation()),this, SLOT(closeDetailsDialog())); + } } @@ -98,8 +80,7 @@ delete mService; delete mLocationPickerSearchView; delete mLocationPickerDocumentLoader; - delete mLocationPickerPotraitView; - delete mLocationPickerLandscapeView; + delete mLocationPickerView; delete mLocationPickerContent; } @@ -139,35 +120,33 @@ Q_ASSERT_X((mLocationPickerSearchView != 0), "mLocationPickerSearchView", "qobject cast failure"); //initialize the action items and connect to slots - mLocationPickerSearchView->init(mLocationPickerContent->getStandardListModel()); + mLocationPickerSearchView->init(mLocationPickerContent->getStandardModel()); connect(mLocationPickerSearchView,SIGNAL(switchView()),this,SLOT(activateLocationPickerView())); connect(mLocationPickerSearchView,SIGNAL(selectItem( quint32 )),this,SLOT(itemSelected( quint32 ))); addView(mLocationPickerSearchView); } //set LocationPickerSearchview as current view setCurrentView(mLocationPickerSearchView); - mviewType = ELocationPickerSearchView; + } + // ---------------------------------------------------------------------------- // LocationPickerAppWindow::activateLocationPickerView() // ---------------------------------------------------------------------------- void LocationPickerAppWindow::activateLocationPickerView() { - mviewType = ELocationPickerContent; + mLocationPickerView->setViewType( ELocationPickerContent ); //check the orientation and load view accordingly if(this->orientation() == Qt::Horizontal) { - mLocationPickerLandscapeView->setViewType( ELocationPickerContent ); - mLocationPickerLandscapeView->manageHgWidget(); - setCurrentView(mLocationPickerLandscapeView); + mLocationPickerView->manageHgWidget(); } else { - mLocationPickerPotraitView->setViewType( ELocationPickerContent ); - mLocationPickerPotraitView->manageListView(); - setCurrentView( mLocationPickerPotraitView ); + mLocationPickerView->manageListView(); } + setCurrentView(mLocationPickerView); } // ---------------------------------------------------------------------------- @@ -176,129 +155,38 @@ void LocationPickerAppWindow::changeOrientation( Qt::Orientation ) { //check the orientation and load view accordingly - if( orientation() == (Qt::Horizontal )) - { - loadLandscape(); - } - else + if(mLocationPickerView->getViewType()== ELocationPickerCollectionContent || + mLocationPickerView->getViewType()== ELocationPickerContent ) { - loadPotrait(); - } -} - -// ---------------------------------------------------------------------------- -// LocationPickerAppWindow::loadPotrait() -// ---------------------------------------------------------------------------- -void LocationPickerAppWindow::loadPotrait() -{ - //load potrait view except for search view - if(mviewType != ELocationPickerSearchView) - { - if(mLocationPickerLandscapeView->getViewType() == ELocationPickerContent) - { - mLocationPickerPotraitView->setViewType(ELocationPickerContent); - } - mLocationPickerPotraitView->manageListView(); - setCurrentView( mLocationPickerPotraitView ); + if(this->orientation() == Qt::Vertical) + { + mLocationPickerView->manageListView(); + + } + + else if(this->orientation() == Qt::Horizontal) + { + mLocationPickerView->manageHgWidget(); + } } } // ---------------------------------------------------------------------------- -// LocationPickerAppWindow::loadLandscape() -// ---------------------------------------------------------------------------- -void LocationPickerAppWindow::loadLandscape() -{ - if(mviewType != ELocationPickerSearchView) - { - //load landscape view in current potrait content - mLocationPickerLandscapeView->setViewType( mLocationPickerPotraitView->getViewType() ); - //load landscape for all content except collectionlistcontent - if(mLocationPickerPotraitView->getViewType() != ELocationPickerCollectionListContent) - { - mLocationPickerLandscapeView->manageHgWidget(); - setCurrentView(mLocationPickerLandscapeView); - } - } -} - -// ---------------------------------------------------------------------------- -// LocationPickerAppWindow::loadLandscape() +// LocationPickerAppWindow::closeDetailsDialog() // ---------------------------------------------------------------------------- -void LocationPickerAppWindow::connectPotraitSlots() +void LocationPickerAppWindow::closeDetailsDialog() { - connect(mLocationPickerPotraitView,SIGNAL(switchToSearchView()),this,SLOT(activateSearchView())); - connect(mLocationPickerPotraitView,SIGNAL(selectItem( quint32 )),this,SLOT(itemSelected( quint32 ))); - connect(mLocationPickerPotraitView,SIGNAL(completeService()),this,SLOT(serviceComplete())); - connect(mLocationPickerPotraitView,SIGNAL(sendCategoryID( quint32 )),this,SLOT(setCategoryId( quint32 ))); - connect(mLocationPickerPotraitView,SIGNAL(handleAllList()),this,SLOT(allListHandle())); - connect(mLocationPickerPotraitView,SIGNAL(collectionContentExited()),this,SLOT(clearContentModels())); -} - -// ---------------------------------------------------------------------------- -// LocationPickerAppWindow::loadLandscape() -// ---------------------------------------------------------------------------- -void LocationPickerAppWindow::connectLandscapeSlots() -{ - connect(mLocationPickerLandscapeView,SIGNAL(switchToSearchView()),this,SLOT(activateSearchView())); - connect(mLocationPickerLandscapeView,SIGNAL(selectItem( quint32 )),this,SLOT(itemSelected( quint32 ))); - connect(mLocationPickerLandscapeView,SIGNAL(completeService()),this,SLOT(serviceComplete())); - connect(mLocationPickerLandscapeView,SIGNAL(sendCategoryID( quint32 )),this,SLOT(setCategoryId( quint32 ))); - connect(mLocationPickerLandscapeView,SIGNAL(handleCollectionList()),this,SLOT(handleCollectionList())); - connect(mLocationPickerLandscapeView,SIGNAL(collectionContentExited()),this,SLOT(clearContentModels())); + mLocationPickerView->closeDetailsDialog(); } // ---------------------------------------------------------------------------- -// LocationPickerAppWindow::setCategoryId() -// ---------------------------------------------------------------------------- -void LocationPickerAppWindow::setCategoryId( quint32 acategoryId ) -{ - //set the same category id to both views - mLocationPickerPotraitView->setCategoryID(acategoryId); - mLocationPickerLandscapeView->setCategoryID(acategoryId); - //Load the collectioncontent in appropriate orientation - if(orientation() == Qt::Vertical) - { - mviewType = ELocationPickerCollectionContent; - mLocationPickerPotraitView->manageListView(); - setCurrentView( mLocationPickerPotraitView ); - } - else - { - mviewType = ELocationPickerCollectionContent; - loadLandscape(); - } -} - -// ---------------------------------------------------------------------------- -// LocationPickerAppWindow::handleCollectionList() +// LocationPickerAppWindow::connectSlots() // ---------------------------------------------------------------------------- -void LocationPickerAppWindow::handleCollectionList() -{ - //In collection List both view should look same(list) - mLocationPickerPotraitView->setViewType( ELocationPickerCollectionListContent ); - mviewType = ELocationPickerCollectionListContent; - mLocationPickerPotraitView->manageListView(); - setCurrentView( mLocationPickerPotraitView ); -} - -// ---------------------------------------------------------------------------- -// LocationPickerAppWindow::allListHandle() -// ---------------------------------------------------------------------------- -void LocationPickerAppWindow::allListHandle() +void LocationPickerAppWindow::connectSlots() { - //all list after collection list in horizontal orientation - mLocationPickerLandscapeView->setViewType( ELocationPickerContent ); - mLocationPickerLandscapeView->manageHgWidget(); - setCurrentView(mLocationPickerLandscapeView); -} - -// ---------------------------------------------------------------------------- -// LocationPickerAppWindow::clearContentModels() -// ---------------------------------------------------------------------------- -void LocationPickerAppWindow::clearContentModels() -{ - mLocationPickerLandscapeView->clearContentModel(); - mLocationPickerPotraitView->clearContentModel(); + connect(mLocationPickerView,SIGNAL(switchToSearchView()),this,SLOT(activateSearchView())); + connect(mLocationPickerView,SIGNAL(selectItem( quint32 )),this,SLOT(itemSelected( quint32 ))); + connect(mLocationPickerView,SIGNAL(completeService()),this,SLOT(serviceComplete())); } Q_IMPLEMENT_USER_METATYPE(QLocationPickerItem) diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/src/locationpickercollectioncontent.cpp --- a/locationpickerservice/src/locationpickercollectioncontent.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/src/locationpickercollectioncontent.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -27,40 +27,36 @@ // ---------------------------------------------------------------- // LocationPickerCollectionContent::LocationPickerCollectionContent() // ----------------------------------------------------------------- -LocationPickerCollectionContent::LocationPickerCollectionContent( Qt::Orientations aOrientation , quint32 aCollectionId ) - :mOrientation(aOrientation), - mProxyModel(NULL), +LocationPickerCollectionContent::LocationPickerCollectionContent( quint32 aCollectionId ) + :mProxyModel(NULL), mModel(NULL), mDataManager(NULL), mLocationFound(false) { // Create a standard model for the view list mModel = new QStandardItemModel( this ); - if(mModel) + // create data manager to manage data in the model + mDataManager = LocationPickerDataManager::getInstance(); + if( mDataManager->populateModel( *mModel, ELocationPickerCollectionContent, aCollectionId ) ) { - // create data manager to manage data in the model - mDataManager = LocationPickerDataManager::getInstance(); - if( mDataManager->populateModel( *mModel, ELocationPickerCollectionContent, mOrientation , aCollectionId ) ) - { - // Create the proxy model. - mProxyModel = new LocationPickerProxyModel(mOrientation); - mProxyModel->setSourceModel(mModel); - mProxyModel->setDynamicSortFilter(TRUE); - mProxyModel->setSortRole(Qt::DisplayRole); - mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); - // sort - mProxyModel->sort(0, Qt::AscendingOrder); - mLocationFound = true; - } - else - { - // no locations to display. - QStandardItem *modelItem = new QStandardItem(); - modelItem->setData(QVariant(hbTrId("txt_lint_list_no_location_entries_present")), Qt::DisplayRole); - mModel->appendRow( modelItem ); - mLocationFound = false; - } + // Create the proxy model. + mProxyModel = new LocationPickerProxyModel(); + mProxyModel->setSourceModel(mModel); + mProxyModel->setDynamicSortFilter(TRUE); + mProxyModel->setSortRole(Qt::DisplayRole); + mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); + // sort + mProxyModel->sort(0, Qt::AscendingOrder); + mLocationFound = true; } + else + { + // no locations to display. + QStandardItem *modelItem = new QStandardItem(); + modelItem->setData(QVariant(hbTrId("txt_lint_list_no_location_entries_present")), Qt::DisplayRole); + mModel->appendRow( modelItem ); + mLocationFound = false; + } } // ---------------------------------------------------------------- @@ -80,14 +76,6 @@ return mProxyModel; } -// ---------------------------------------------------------------- -// LocationPickerCollectionContent::getStandardModel -// ----------------------------------------------------------------- -QStandardItemModel* LocationPickerCollectionContent::getStandardModel() -{ - return mModel; -} - // ---------------------------------------------------------------------------- // LocationPickerCollectionContent::getData() // ---------------------------------------------------------------------------- diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/src/locationpickercollectionlistcontent.cpp --- a/locationpickerservice/src/locationpickercollectionlistcontent.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/src/locationpickercollectionlistcontent.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -25,9 +25,8 @@ // ---------------------------------------------------------------------- // LocationPickerCollectionListContent::LocationPickerCollectionListContent() // ---------------------------------------------------------------------- -LocationPickerCollectionListContent::LocationPickerCollectionListContent( Qt::Orientation aOrientation ) - :mOrientation(aOrientation), - mModel(NULL), +LocationPickerCollectionListContent::LocationPickerCollectionListContent() + :mModel(NULL), mDataManager(NULL) { // Create a standard model for the view list @@ -36,7 +35,7 @@ { // create data manager to manage data in the model mDataManager = LocationPickerDataManager::getInstance(); - bool populated = mDataManager->populateModel( *mModel, ELocationPickerCollectionListContent, mOrientation ); + bool populated = mDataManager->populateModel( *mModel, ELocationPickerCollectionListContent); if(!populated) { qFatal("Error creating collection"); @@ -56,9 +55,9 @@ // LocationPickerCollectionListContent::getStandardModel // ----------------------------------------------------------------- QStandardItemModel* LocationPickerCollectionListContent::getStandardModel() - { +{ return mModel; - } +} // ---------------------------------------------------------------------------- // LocationPickerCollectionListContent::getData() diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/src/locationpickercontent.cpp --- a/locationpickerservice/src/locationpickercontent.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/src/locationpickercontent.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -29,7 +29,6 @@ // ----------------------------------------------------------------------------- LocationPickerContent::LocationPickerContent() :mDataManager(NULL), - mListModel(NULL), mStandardModel(NULL) { // create data manager to manage data in the model @@ -40,37 +39,19 @@ // ----------------------------------------------------------------------------- // LocationPickerContent::populateModel() // ----------------------------------------------------------------------------- -bool LocationPickerContent::populateModel( Qt::Orientation aOrientation ) +bool LocationPickerContent::populateModel() { bool locationsFound; - if(aOrientation == Qt::Vertical) + // Create a standard model for the list view + mStandardModel = new QStandardItemModel( this ); + if( mDataManager->populateModel( *mStandardModel, ELocationPickerContent ) ) { - // Create a standard model for the list view - mListModel = new QStandardItemModel( this ); - if( mDataManager->populateModel( *mListModel, ELocationPickerContent, aOrientation) ) - { - locationsFound = true; - } - else - { - createNoEntryDisplay(mListModel); - locationsFound = false; - } + locationsFound = true; } - //for landscape view else { - // Create a standard model for the landscape view - mStandardModel = new QStandardItemModel( this ); - if( mDataManager->populateModel(*mStandardModel, ELocationPickerContent, aOrientation) ) - { - locationsFound = true; - } - else - { - createNoEntryDisplay(mStandardModel); - locationsFound = false; - } + createNoEntryDisplay(mStandardModel); + locationsFound = false; } return locationsFound; } @@ -80,17 +61,9 @@ // ----------------------------------------------------------------------------- LocationPickerContent::~LocationPickerContent() { - delete mListModel; delete mStandardModel; } -// ----------------------------------------------------------------------------- -// LocationPickerContent::getStandardListModel() -// ----------------------------------------------------------------------------- -QStandardItemModel* LocationPickerContent::getStandardListModel() -{ - return mListModel; -} // ----------------------------------------------------------------------------- // LocationPickerContent::getStandardModel() diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/src/locationpickerdatamanager.cpp --- a/locationpickerservice/src/locationpickerdatamanager.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/src/locationpickerdatamanager.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -50,10 +50,10 @@ // LocationPickerDataManager::populateModel() // ---------------------------------------------------------------------------- bool LocationPickerDataManager::populateModel( QStandardItemModel &aModel, TViewType aViewType, - Qt::Orientations aOrientation, quint32 aCollectionId ) + quint32 aCollectionId ) { Q_D( LocationPickerDataManager); - return( d->populateModel( aModel, aViewType, aOrientation, aCollectionId) ); + return( d->populateModel( aModel, aViewType, aCollectionId) ); } // ---------------------------------------------------------------------------- diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/src/locationpickerdatamanager_p.cpp --- a/locationpickerservice/src/locationpickerdatamanager_p.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/src/locationpickerdatamanager_p.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -16,9 +16,6 @@ */ #include -#include -#include -#include #include #include #include "locationpickerdatamanager_p.h" @@ -56,11 +53,10 @@ // LocationPickerDataManagerPrivate::populateModel() // ---------------------------------------------------------------------------- bool LocationPickerDataManagerPrivate::populateModel( QStandardItemModel &aModel, - TViewType aViewType, const Qt::Orientations aOrientation, quint32 aCollectionId ) + TViewType aViewType, quint32 aCollectionId ) { mModel = &aModel; mViewType = aViewType; - mOrientation = aOrientation; if( !mDb ) { @@ -112,9 +108,15 @@ } QString lmAddressLine1; QString lmAddressLine2; + QString contextAddress; + QString contextAddressCountry; for( int i = 0; i < aItemArray.count(); i++ ) { + contextAddress.clear(); + contextAddressCountry.clear(); + lmAddressLine1.clear(); + lmAddressLine2.clear(); if( !aItemArray[i].mIsDuplicate ) { @@ -175,6 +177,7 @@ } } } + contextAddress = lmAddressLine2; if( !aItemArray[i].mCountry.isEmpty() ) { if( !addressEmtpy ) @@ -188,79 +191,59 @@ lmAddressLine2 = aItemArray[i].mCountry; addressEmtpy = EFalse; } + contextAddressCountry = aItemArray[i].mCountry; } // set icons based on contact address type QVariantList icons; - + HbIcon adressTypeIcon; QString adressType; bool adressIconPresent = false; if( aItemArray[i].mSourceType == ESourceContactsHome ) { + adressTypeIcon = HbIcon(KContactHomeIcon); adressType = KContactHomeIcon; adressIconPresent = true; } else if( aItemArray[i].mSourceType == ESourceContactsWork ) { + adressTypeIcon = HbIcon(KContactWorkIcon); adressType = KContactWorkIcon; adressIconPresent = true; } - else if( aItemArray[i].mSourceType == ESourceContactsPref ) - { - adressType = KContactPrefIcon; - adressIconPresent = true; - } // create a list item and set to model QStringList addressData; - //create model for grid view in landscape mode - if( mOrientation == Qt::Horizontal && ( mViewType == ELocationPickerCollectionContent || - mViewType == ELocationPickerContent ) ) - { - addressData.clear(); - - QString landscapeIconPath; - - if( QFile::exists( aItemArray[i].mMapTilePath ) ) - { - //draw maptile Icon - - landscapeIconPath = QString( QString( aItemArray[i].mMapTilePath ) ); - } - else - { - //draw dummy icon - landscapeIconPath = QString(""); - } + QString landscapeIconPath; - icons<setData(QVariant(addressData), Qt::DisplayRole); - modelItem->setData( icons[0], Qt::DecorationRole ); - modelItem->setData( aItemArray[i].mId, Qt::UserRole ); - modelItem->setData(adressType,Qt::UserRole+1); - mModel->appendRow( modelItem ); + if( QFile::exists( aItemArray[i].mMapTilePath ) ) + { + //draw maptile Icon + landscapeIconPath = QString( aItemArray[i].mMapTilePath ); } else - { - //create model for list view in potrait mode - addressData.clear(); - HbIcon potraitIcon( KDummyImage ); - icons<setData(QVariant(addressData), Qt::DisplayRole); - modelItem->setData( icons, Qt::DecorationRole ); - modelItem->setData( aItemArray[i].mId, Qt::UserRole ); - mModel->appendRow( modelItem ); + { + //draw dummy icon + landscapeIconPath = QString(""); + } + addressData.clear(); + HbIcon potraitIcon( KDummyImage ); + icons<setData(QVariant(addressData), Qt::DisplayRole); + modelItem->setData( icons, Qt::DecorationRole ); + modelItem->setData( aItemArray[i].mId, Qt::UserRole ); + modelItem->setData(landscapeIconPath,Qt::UserRole+1); + modelItem->setData(adressType,Qt::UserRole+2); + modelItem->setData(QVariant(contextList), Qt::UserRole+3); + + mModel->appendRow( modelItem ); } } @@ -281,16 +264,9 @@ contactCollectionNum.append(" items"); QString contactCollectionName( hbTrId("txt_lint_list_contact_addresses") ); - if( mOrientation == Qt::Vertical) - { - QStringList contact = (QStringList()<setData( QVariant( contact ), Qt::DisplayRole ); - } - else - { - QString contact = contactCollectionName.append(contactCollectionNum); - modelItemContact->setData( QVariant( contact ), Qt::DisplayRole ); - } + + QStringList contact = (QStringList()<setData( QVariant( contact ), Qt::DisplayRole ); modelItemContact->setData( HbIcon ( KCollectionsContacts ), Qt::DecorationRole ); modelItemContact->setData( ESourceLandmarksContactsCat, Qt::UserRole ); diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/src/locationpickerdocumentloader.cpp --- a/locationpickerservice/src/locationpickerdocumentloader.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/src/locationpickerdocumentloader.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -16,9 +16,8 @@ */ #include "locationpickerdocumentloader.h" -#include "locationpickerpotraitview.h" +#include "locationpickerview.h" #include "locationpickersearchview.h" -#include "locationpickerlandscapeview.h" // --------------------------------------------------------------------------- // LocationPickerDocumentLoader::LocationPickerDocumentLoader() @@ -42,17 +41,10 @@ // QObject *LocationPickerDocumentLoader::createObject( const QString& type, const QString &name ) { - //for locationpickerpotraitview - if ( name == LocationPickerPotraitView::staticMetaObject.className() ) + //for locationpickerview + if ( name == LocationPickerView::staticMetaObject.className() ) { - QObject *object = new LocationPickerPotraitView(this); - object->setObjectName( name ); - return object; - } - //for locationpickerlandscapeview - if ( name == LocationPickerLandscapeView::staticMetaObject.className() ) - { - QObject *object = new LocationPickerLandscapeView(this); + QObject *object = new LocationPickerView(this); object->setObjectName( name ); return object; } diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/src/locationpickerlandscapeview.cpp --- a/locationpickerservice/src/locationpickerlandscapeview.cpp Wed Jun 23 18:07:15 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,449 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: LocationPickerLandscapeView implementation -* -*/ - -#include "locationpickerlandscapeview.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "hgwidgetdatamodel.h" -#include "locationpickerproxymodel.h" -#include "locationpickerdatamanager.h" -#include "locationpickercollectionlistcontent.h" -#include "locationpickercollectioncontent.h" - - - -// ---------------------------------------------------- -// LocationPickerLandscapeView::LocationPickerLandscapeView() -// ---------------------------------------------------- -LocationPickerLandscapeView::LocationPickerLandscapeView(HbDocumentLoader* aLoader) - :mDocumentLoader(aLoader), - mAllAction(NULL), - mCollectionAction(NULL), - mSearchAction(NULL), - mAscendingAction(NULL), - mDescendingAction(NULL), - mCollectionContent(NULL), - mViewType(ELocationPickerContent), - mModel(NULL), - mWidget(NULL), - mLayout(NULL), - mEmptyLabel(NULL), - mLongPressMenu(NULL) -{ - // create back action - mLandscapeBackAction = new HbAction(Hb::BackNaviAction); - setNavigationAction(mLandscapeBackAction); - connect(mLandscapeBackAction, SIGNAL(triggered()), this, - SLOT(backButtonTriggered())); - - -} -// ---------------------------------------------------- -// LocationPickerLandscapeView::~LocationPickerLandscapeView() -// ---------------------------------------------------- -LocationPickerLandscapeView::~LocationPickerLandscapeView() -{ - delete mCollectionContent; - delete mAllAction; - delete mCollectionAction; - delete mAscendingAction; - delete mDescendingAction; - delete mWidget; - delete mModel; - delete mLongPressMenu; -} - -// ---------------------------------------------------------------------------- -// LocationPickerLandscapeView::backButtonTriggered() -// ---------------------------------------------------------------------------- -void LocationPickerLandscapeView::backButtonTriggered() -{ - //if current model is collection content, go back to collectionlist content - if(mViewType == ELocationPickerCollectionContent) - { - colectionTabTriggered(); - emit collectionContentExited(); - } - else - { - //complete the service - emit completeService(); - } -} - - -// ---------------------------------------------------- -// LocationPickerLandscapeView::init() -// ---------------------------------------------------- -void LocationPickerLandscapeView::init(Qt::Orientation aOrientation, QStandardItemModel *aModel ) -{ - mStandardModel = aModel; - //create proxy model - mProxyModel = new LocationPickerProxyModel( aOrientation , this ); - mProxyModel->setSourceModel(aModel); - // set sort properties - mProxyModel->setDynamicSortFilter(TRUE); - mProxyModel->setSortRole(Qt::DisplayRole); - mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); - // sort in ascending order - mProxyModel->sort(0, Qt::AscendingOrder); - - //Get HbAction items - HbToolBar* toolbar = new HbToolBar(); - //Create Action Items - mAllAction = new HbAction(); - mAllAction->setIcon(QString("qtg_mono_location")); - mAllAction->setCheckable(true); - mCollectionAction =new HbAction(); - mCollectionAction->setIcon(QString("qtg_mono_location_collection")); - mCollectionAction->setCheckable(true); - mSearchAction = new HbAction(); - mSearchAction->setIcon(QString("qtg_mono_search")); - - toolbar->addAction(mAllAction); - toolbar->addAction(mCollectionAction); - toolbar->addAction(mSearchAction); - this->setToolBar(toolbar); - - mAscendingAction = qobject_cast (mDocumentLoader->findObject( - QString("ascendingAction"))); - mDescendingAction = qobject_cast (mDocumentLoader->findObject( - QString("descendingAction"))); - if( !mAllAction || !mCollectionAction || !mSearchAction || !mAscendingAction || !mDescendingAction) - { - qFatal("Error Reading Docml"); - } - - //connect to slots - connect(mAscendingAction, SIGNAL(triggered()), this, SLOT(sortAscending())); - connect(mDescendingAction, SIGNAL(triggered()), this, - SLOT(sortDescending())); - //connect all action Items to respective slots - connect(mAllAction, SIGNAL(triggered()), this, SLOT(allTabTriggered())); - connect(mCollectionAction, SIGNAL(triggered()), this,SLOT(colectionTabTriggered())); - connect(mSearchAction, SIGNAL(triggered()), this, - SLOT(searchTabTriggered())); - - //hurrriganes widget - QGraphicsWidget *widget = NULL; - widget = mDocumentLoader->findWidget(QString("vertical")); - mLayout = static_cast(widget->layout()); - - mModel = new HgWidgetDataModel( mProxyModel, this ); - mModel->setImageDataType(HgWidgetDataModel::ETypeQImage); - //create MediaWall Object - mWidget = new HgMediawall(); - HbIcon defaultIcon(KDummyImage); - QImage defaultImage = defaultIcon.pixmap().toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied); - mWidget->setDefaultImage(defaultImage); - mWidget->setObjectName("location"); - HbStyleLoader::registerFilePath(":/location.hgmediawall.widgetml"); - HbStyleLoader::registerFilePath(":/location.hgmediawall.css"); - mWidget->enableReflections(false); - mWidget->setFontSpec(HbFontSpec(HbFontSpec::Primary)); - mWidget->setItemSize(QSize(4.6,2)); - connect(this->mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),mWidget, - SLOT(orientationChanged(Qt::Orientation))); - - mWidget->setAcceptTouchEvents(true); - connect(mWidget, SIGNAL(activated(const QModelIndex &)),this, SLOT(handleActivated(const QModelIndex &))); - connect(mWidget, SIGNAL(longPressed(const QModelIndex &, const QPointF &)),this, - SLOT(launchPopUpMenu(const QModelIndex &, const QPointF &))); - mLayout->addItem(mWidget); - mWidget->setModel(mModel); - mWidget->setLongPressEnabled(true); - mWidget->scrollTo(mWidget->currentIndex()); -} - -// ----------------------------------------------------------------------------- -// LocationPickerLandscapeView::manageHgWidget() -// ----------------------------------------------------------------------------- -void LocationPickerLandscapeView::manageHgWidget() -{ - //set the appropriate model - switch(mViewType) - { - case ELocationPickerContent: - { - mModel->resetModel(mProxyModel); - mAllAction->setChecked(true); - mCollectionAction->setChecked(false); - } - break; - case ELocationPickerCollectionContent: - { - setCollectionData(mCategoryId); - mCollectionAction->setChecked(true); - mAllAction->setChecked(false); - } - break; - } -} - -// ----------------------------------------------------------------------------- -// LocationPickerLandscapeView::handleActivated() -// ----------------------------------------------------------------------------- -void LocationPickerLandscapeView::handleActivated(const QModelIndex &aIndex) -{ - //handle the activated signal according to model set - int row= aIndex.row(); - int col = aIndex.column(); - switch(mViewType) - { - case ELocationPickerContent: - { - QModelIndex proxyModelIndex = mProxyModel->index(row,col); - QModelIndex index = mProxyModel->mapToSource( - proxyModelIndex); - quint32 lm = 0; - QStandardItem* item = mStandardModel->item( index.row(), index.column() ); - QVariant var = item->data( Qt::UserRole ); - lm = var.toUInt(); - //item selected, complete request - emit selectItem( lm ); - } - break; - case ELocationPickerCollectionContent: - { - if(!mCollectionContent->getProxyModel()) - { - break; - } - QModelIndex proxyModelIndex = mCollectionContent->getProxyModel()->index(row,col); - QModelIndex index = mCollectionContent->getProxyModel()->mapToSource( - proxyModelIndex); - quint32 lm = 0; - mCollectionContent->getData(index, lm); - emit selectItem(lm); - } - break; - default: - break; - } -} - - - -// ----------------------------------------------------------------------------- -// LocationPickerLandscapeView::sortAscending() -// ----------------------------------------------------------------------------- -void LocationPickerLandscapeView::sortAscending() -{ - //check the model set and do sorting accordingly - if (mViewType == ELocationPickerContent) - { - mProxyModel->sort(0,Qt::AscendingOrder); - mModel->resetModel(mProxyModel); - } - else - { - mCollectionContent->getProxyModel()->sort(0,Qt::AscendingOrder); - mModel->resetModel(mCollectionContent->getProxyModel()); - } - -} - -// ----------------------------------------------------------------------------- -// LocationPickerLandscapeView::sortDescending() -// ----------------------------------------------------------------------------- -void LocationPickerLandscapeView::sortDescending() -{ - //check the model set and do sorting accordingly - if (mViewType == ELocationPickerContent) - { - mProxyModel->sort(0,Qt::DescendingOrder); - mModel->resetModel(mProxyModel); - } - else - { - mCollectionContent->getProxyModel()->sort(0,Qt::DescendingOrder); - mModel->resetModel(mCollectionContent->getProxyModel()); - } -} - -// ----------------------------------------------------------------------------- -// LocationPickerLandscapeView::handleAllTab() -// ----------------------------------------------------------------------------- -void LocationPickerLandscapeView::allTabTriggered() -{ - //execute only if tab is not pressed - if (mAllAction->isChecked()) - { - if(mEmptyLabel) - { - mLayout->removeItem(mEmptyLabel); - mEmptyLabel->hide(); - mLayout->insertItem(0,mWidget); - mWidget->setVisible(true); - delete mEmptyLabel; - mEmptyLabel = NULL; - } - mModel->resetModel(mProxyModel); - } - mAscendingAction->setEnabled(true); - mDescendingAction->setEnabled(true); - mCollectionAction->setChecked(false); - mViewType = ELocationPickerContent; - //delete mCollectionContent if coming back from collectioncontent - if (mCollectionContent) - { - delete mCollectionContent; - mCollectionContent = NULL; - } - else - { - //Keep the tab pressed - mAllAction->setChecked(true); - } - -} - -// ----------------------------------------------------------------------------- -// LocationPickerLandscapeView::handleCollectionTab() -// ----------------------------------------------------------------------------- -void LocationPickerLandscapeView::colectionTabTriggered() -{ - //execute only if tab is not pressed - if (mCollectionAction->isChecked()) - { - mAscendingAction->setDisabled(true); - mDescendingAction->setDisabled(true); - mViewType = ELocationPickerCollectionListContent; - emit handleCollectionList(); - } - else - { - //Keep the tab pressed - mCollectionAction->setChecked(true); - } -} - -// ----------------------------------------------------------------------------- -// LocationPickerLandscapeView::searchTabTriggered() -// ----------------------------------------------------------------------------- -void LocationPickerLandscapeView::searchTabTriggered() -{ - emit switchToSearchView(); -} - -void LocationPickerLandscapeView::setCollectionData( quint32 aCategoryId ) -{ - if(mEmptyLabel) - { - mLayout->removeItem(mEmptyLabel); - mEmptyLabel->hide(); - mLayout->insertItem(0,mWidget); - mWidget->show(); - delete mEmptyLabel; - mEmptyLabel = NULL; - } - if(!mCollectionContent) - { - mCollectionContent = new LocationPickerCollectionContent(Qt::Horizontal , aCategoryId); - } - if(mCollectionContent->locationFound()) - { - mModel->resetModel(mCollectionContent->getProxyModel()); - //Enable the options - mAscendingAction->setEnabled(true); - mDescendingAction->setEnabled(true); - } - else - { - if(!mEmptyLabel) - { - mEmptyLabel = new HbTextItem(hbTrId("txt_lint_list_no_location_entries_present")); - } - mEmptyLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - mEmptyLabel->setFontSpec(HbFontSpec(HbFontSpec::Primary)); - mLayout->removeItem(mWidget); - mWidget->setVisible(false); - mLayout->insertItem(0, mEmptyLabel); - } - - mViewType = ELocationPickerCollectionContent; - - mCollectionAction->setChecked(true); -} - -// ----------------------------------------------------------------------------- -// LocationPickerLandscapeView::setCategoryID() -// ----------------------------------------------------------------------------- -void LocationPickerLandscapeView::setCategoryID( quint32 aCategoryId ) -{ - mCategoryId = aCategoryId; -} - -// ----------------------------------------------------------------------------- -// LocationPickerLandscapeView::getViewType() -// ----------------------------------------------------------------------------- -TViewType LocationPickerLandscapeView::getViewType() -{ - return mViewType; -} - -// ----------------------------------------------------------------------------- -// LocationPickerLandscapeView::setViewType() -// ----------------------------------------------------------------------------- -void LocationPickerLandscapeView::setViewType(TViewType aViewType) -{ - mViewType = aViewType; -} - -// ----------------------------------------------------------------------------- -// LocationPickerLandscapeView::clearContentModel() -// ----------------------------------------------------------------------------- -void LocationPickerLandscapeView::clearContentModel() -{ - if(mCollectionContent) - { - delete mCollectionContent; - mCollectionContent = NULL; - } -} - -// ----------------------------------------------------------------------------- -// LocationPickerLandscapeView::launchPopUpMenu() -// ----------------------------------------------------------------------------- -void LocationPickerLandscapeView::launchPopUpMenu(const QModelIndex &aIndex, const QPointF &aPoint) -{ - mLongPressMenu = new HbMenu(); - mLongPressMenu->setTimeout(HbMenu::NoTimeout); - HbAction* selectAction = mLongPressMenu->addAction(hbTrId("Select")); - mIndex = aIndex; - connect(selectAction, SIGNAL(triggered()), this, SLOT(handleLongPress())); - mLongPressMenu->setPreferredPos(aPoint); - mLongPressMenu->open(); -} - -// ----------------------------------------------------------------------------- -// LocationPickerLandscapeView::handleLongPress() -// ----------------------------------------------------------------------------- -void LocationPickerLandscapeView::handleLongPress() -{ - handleActivated(mIndex); -} diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/src/locationpickerpotraitview.cpp --- a/locationpickerservice/src/locationpickerpotraitview.cpp Wed Jun 23 18:07:15 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,502 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: LocationPickerView implementation -* -*/ - -#include "locationpickerpotraitview.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "locationpickerproxymodel.h" -#include "locationpickerdatamanager.h" -#include "locationpickercontent.h" -#include "locationpickercollectionlistcontent.h" -#include "locationpickercollectioncontent.h" - -// ======== MEMBER FUNCTIONS ======== - -// ---------------------------------------------------- -// LocationPickerPotraitView::LocationPickerView() -// ---------------------------------------------------- -LocationPickerPotraitView::LocationPickerPotraitView( HbDocumentLoader* aLoader ) - :mDocumentLoader(aLoader), - mLocationPickerCollectionListContent(NULL), - mProxyModel(NULL), - mAllAction(NULL), - mCollectionAction(NULL), - mSearchAction(NULL), - mAscendingAction(NULL), - mDescendingAction(NULL), - mListView(NULL), - mCollectionContent(NULL), - mViewType(ELocationPickerContent), - mLinerLayout(NULL), - mColllabel(NULL), - mLongPressMenu(NULL) -{ - // create back action - mPotraitBackAction = new HbAction(Hb::BackNaviAction); - // add back key action - setNavigationAction(mPotraitBackAction); - //connect to slots - connect(mPotraitBackAction, SIGNAL(triggered()), this, - SLOT(backTriggered())); - //create list item - mListItem = new HbListViewItem(); - //set the graphics size - mListItem->setGraphicsSize(HbListViewItem::Thumbnail); -} -// ---------------------------------------------------- -// LocationPickerPotraitView::~LocationPickerView() -// ---------------------------------------------------- -LocationPickerPotraitView::~LocationPickerPotraitView() -{ - delete mCollectionContent; - delete mLocationPickerCollectionListContent; - delete mAllAction; - delete mCollectionAction; - delete mAscendingAction; - delete mDescendingAction; - delete mListView; - delete mLongPressMenu; -} - -// ---------------------------------------------------------------------------- -// LocationPickerPotraitView::backButtonTriggered() -// ---------------------------------------------------------------------------- -void LocationPickerPotraitView::backTriggered() -{ - //if current model is collection content, go back to collectionlist content - if(mViewType == ELocationPickerCollectionContent) - { - colectionTabTriggered(); - emit collectionContentExited(); - } - else - { - //complete the service - emit completeService(); - } - if (mLinerLayout && mColllabel) - { - mColllabel->setPlainText(""); - mLinerLayout->removeItem(mColllabel); - mLinerLayout->updateGeometry(); - update(); - } -} - - -// ---------------------------------------------------- -// LocationPickerPotraitView::init() -// ---------------------------------------------------- -void LocationPickerPotraitView::init( bool aPopulated, Qt::Orientation aOrientation, QStandardItemModel *aModel ) -{ - mModel = aModel; - if(aPopulated) - { - // Create Collection List Content - mLocationPickerCollectionListContent = new LocationPickerCollectionListContent(aOrientation); - //create proxy model - mProxyModel = new LocationPickerProxyModel( aOrientation , this ); - mProxyModel->setSourceModel(aModel); - // set sort properties - mProxyModel->setDynamicSortFilter(TRUE); - mProxyModel->setSortRole(Qt::DisplayRole); - mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); - // sort in ascending order - mProxyModel->sort(0, Qt::AscendingOrder); - } - //Get HbAction items - mListView = qobject_cast (mDocumentLoader->findObject(QString( - "ListView"))); - HbToolBar* toolbar = new HbToolBar(); - //Create Action Items - mAllAction = new HbAction(); - mAllAction->setIcon(QString("qtg_mono_location")); - mAllAction->setCheckable(true); - mCollectionAction =new HbAction(); - mCollectionAction->setIcon(QString("qtg_mono_location_collection")); - mCollectionAction->setCheckable(true); - mSearchAction = new HbAction(); - mSearchAction->setIcon(QString("qtg_mono_search")); - - toolbar->addAction(mAllAction); - toolbar->addAction(mCollectionAction); - toolbar->addAction(mSearchAction); - this->setToolBar(toolbar); - mAscendingAction = qobject_cast (mDocumentLoader->findObject( - QString("ascendingAction"))); - mDescendingAction = qobject_cast (mDocumentLoader->findObject( - QString("descendingAction"))); - if( !mAllAction || !mCollectionAction || !mSearchAction || !mAscendingAction || !mDescendingAction || !mListView) - { - qFatal("Error Reading Docml"); - } - - mColllabel = new HbLabel(); - - //connect to slots - connect(mAscendingAction, SIGNAL(triggered()), this, SLOT(sortAscending())); - connect(mDescendingAction, SIGNAL(triggered()), this, - SLOT(sortDescending())); - //connect all action Items to respective slots - connect(mAllAction, SIGNAL(triggered()), this, SLOT(allTabTriggered())); - connect(mCollectionAction, SIGNAL(triggered()), this,SLOT(colectionTabTriggered())); - connect(mSearchAction, SIGNAL(triggered()), this, - SLOT(searchTabTriggered())); - // connect the signal of the list activated to a slot. - connect(mListView, SIGNAL(activated(const QModelIndex &)), this, SLOT(handleActivated(const QModelIndex &))); - connect(mListView,SIGNAL(longPressed(HbAbstractViewItem*, const QPointF &)),this, - SLOT(launchPopUpMenu(HbAbstractViewItem*, const QPointF &))); -} - -// ---------------------------------------------------- -// LocationPickerPotraitView::manageListView() -// ---------------------------------------------------- -void LocationPickerPotraitView::manageListView() -{ - //set the appropriate model - switch(mViewType) - { - case ELocationPickerContent: - { - mListItem->setGraphicsSize(HbListViewItem::Thumbnail); - mListView->setModel(mProxyModel,mListItem); - mAllAction->setChecked(true); - mCollectionAction->setChecked(false); - mViewType = ELocationPickerContent; - } - break; - case ELocationPickerCollectionListContent: - { - mListItem->setGraphicsSize(HbListViewItem::MediumIcon); - mListView->setModel(mLocationPickerCollectionListContent->getStandardModel(),mListItem); - mCollectionAction->setChecked(true); - mAllAction->setChecked(false); - if(mAscendingAction->isEnabled()) - { - mAscendingAction->setDisabled(true); - mDescendingAction->setDisabled(true); - } - mViewType = ELocationPickerCollectionListContent; - } - break; - case ELocationPickerCollectionContent: - { - setCollectionData(mCategoryId); - mCollectionAction->setChecked(true); - mAllAction->setChecked(false); - mViewType = ELocationPickerCollectionContent; - } - break; - default: - break; - } -} - -// ----------------------------------------------------------------------------- -// LocationPickerPotraitView::disableTabs() -// ----------------------------------------------------------------------------- -void LocationPickerPotraitView::disableTabs( QStandardItemModel *aModel ) -{ - //if no location entries present - mListView->setModel(aModel,mListItem); - mAllAction->setDisabled(true); - mCollectionAction->setDisabled(true); - mSearchAction->setDisabled(true); - mAscendingAction->setDisabled(true); - mDescendingAction->setDisabled(true); -} - -// ----------------------------------------------------------------------------- -// LocationPickerPotraitView::handleActivated() -// ----------------------------------------------------------------------------- -void LocationPickerPotraitView::handleActivated(const QModelIndex &aIndex) -{ - //handle the activated signal according to model set - switch(mViewType) - { - case ELocationPickerContent: - { - if(!mProxyModel) - { - break; - } - QModelIndex index = mProxyModel->mapToSource( - aIndex); - quint32 lm = 0; - QStandardItem* item = mModel->item( index.row(), index.column() ); - QVariant var = item->data( Qt::UserRole ); - lm = var.toUInt(); - //item selected, complete request - emit selectItem( lm ); - } - break; - case ELocationPickerCollectionListContent: - { - mLocationPickerCollectionListContent->getData( - aIndex, mCategoryId ); - mViewType = ELocationPickerCollectionContent; - //send categoryID to set the collection content - emit sendCategoryID(mCategoryId); - } - break; - case ELocationPickerCollectionContent: - { - if(!mCollectionContent->getProxyModel()) - { - break; - } - QModelIndex index = mCollectionContent->getProxyModel()->mapToSource( - aIndex); - quint32 lm = 0; - mCollectionContent->getData(index, lm); - //item selected, complete request - emit selectItem(lm); - } - break; - default: - break; - } -} - -// ----------------------------------------------------------------------------- -// LocationPickerPotraitView::sortAscending() -// ----------------------------------------------------------------------------- -void LocationPickerPotraitView::sortAscending() -{ - //check the model set and do sorting accordingly - if (mViewType == ELocationPickerContent) - { - mProxyModel->sort(0, Qt::AscendingOrder); - } - else - { - mCollectionContent->getProxyModel()->sort(0, Qt::AscendingOrder); - } -} - -// ----------------------------------------------------------------------------- -// LocationPickerPotraitView::sortDescending() -// ----------------------------------------------------------------------------- -void LocationPickerPotraitView::sortDescending() -{ - //check the model set and do sorting accordingly - if (mViewType == ELocationPickerContent) - { - mProxyModel->sort(0, Qt::DescendingOrder); - } - else - { - mCollectionContent->getProxyModel()->sort(0, Qt::DescendingOrder); - } -} - -// ----------------------------------------------------------------------------- -// LocationPickerPotraitView::handleAllTab() -// ----------------------------------------------------------------------------- -void LocationPickerPotraitView::allTabTriggered() -{ - if (mLinerLayout && mColllabel) - { - mColllabel->setPlainText(""); - mLinerLayout->removeItem(mColllabel); - mLinerLayout->updateGeometry(); - update(); - } - //execute only if tab is not pressed - if (mAllAction->isChecked()) - { - mViewType = ELocationPickerContent; - if(this->mainWindow()->orientation() == Qt::Horizontal) - { - //if in landscape send signal to launch grid view - emit handleAllList(); - } - else - { - mListItem->setGraphicsSize(HbListViewItem::Thumbnail); - mListView->setModel(mProxyModel,mListItem); - mCollectionAction->setChecked(false); - } - mAscendingAction->setEnabled(true); - mDescendingAction->setEnabled(true); - //delete mCollectionContent if coming back from collectioncontent - if (mCollectionContent) - { - delete mCollectionContent; - mCollectionContent = NULL; - } - } - else - { - //Keep the tab pressed - mAllAction->setChecked(true); - } - -} - -// ----------------------------------------------------------------------------- -// LocationPickerPotraitView::handleCollectionTab() -// ----------------------------------------------------------------------------- -void LocationPickerPotraitView::colectionTabTriggered() -{ - if (mLinerLayout && (mViewType != ELocationPickerCollectionContent) && mColllabel ) - { - mColllabel->setPlainText(""); - mLinerLayout->removeItem(mColllabel); - mLinerLayout->updateGeometry(); - update(); - } - //execute only if tab is not pressed - if (mCollectionAction->isChecked()) - { - mListItem->setGraphicsSize(HbListViewItem::MediumIcon); - mListView->setModel(mLocationPickerCollectionListContent->getStandardModel(),mListItem); - mAscendingAction->setDisabled(true); - mDescendingAction->setDisabled(true); - mAllAction->setChecked(false); - mViewType = ELocationPickerCollectionListContent; - } - else - { - //Keep the tab pressed - mCollectionAction->setChecked(true); - } -} - -// ----------------------------------------------------------------------------- -// LocationPickerPotraitView::searchTabTriggered() -// ----------------------------------------------------------------------------- -void LocationPickerPotraitView::searchTabTriggered() -{ - emit switchToSearchView(); -} - -// ----------------------------------------------------------------------------- -// LocationPickerPotraitView::setCollectionData() -// ----------------------------------------------------------------------------- -void LocationPickerPotraitView::setCollectionData( quint32 acategoryId ) -{ - QString categoryname; - - switch(acategoryId) - { - - case 1: categoryname = "Landmarks"; - break; - case 8: categoryname = "Contacts"; - break; - case 9: categoryname = "Calender"; - break; - - } - if(!mCollectionContent) - { - mCollectionContent - = new LocationPickerCollectionContent(Qt::Vertical , acategoryId); - } - mListItem->setGraphicsSize(HbListViewItem::Thumbnail); - if(mCollectionContent->locationFound()) - { - mListView->setModel(mCollectionContent->getProxyModel(),mListItem); - //Enable the options - mAscendingAction->setEnabled(true); - mDescendingAction->setEnabled(true); - } - else - { - mListView->setModel(mCollectionContent->getStandardModel(),mListItem); - } - mViewType = ELocationPickerCollectionContent; - - mCollectionAction->setChecked(true); - mLinerLayout = static_cast(widget()->layout()); - - if(mColllabel) - { - mLinerLayout->insertItem(0,mColllabel); - mColllabel->setPlainText(categoryname); - mLinerLayout->updateGeometry(); - update(); - } -} - -// ----------------------------------------------------------------------------- -// LocationPickerPotraitView::setCategoryID() -// ----------------------------------------------------------------------------- -void LocationPickerPotraitView::setCategoryID( quint32 aCategoryId ) -{ - mCategoryId = aCategoryId; -} - -// ----------------------------------------------------------------------------- -// LocationPickerPotraitView::getViewType() -// ----------------------------------------------------------------------------- -TViewType LocationPickerPotraitView::getViewType() -{ - return mViewType; -} - -// ----------------------------------------------------------------------------- -// LocationPickerPotraitView::setViewType() -// ----------------------------------------------------------------------------- -void LocationPickerPotraitView::setViewType(TViewType aViewType) -{ - mViewType = aViewType; -} - - -// ----------------------------------------------------------------------------- -// LocationPickerPotraitView::clearContentModel() -// ----------------------------------------------------------------------------- -void LocationPickerPotraitView::clearContentModel() -{ - if(mCollectionContent) - { - delete mCollectionContent; - mCollectionContent = NULL; - } -} - -// ----------------------------------------------------------------------------- -// LocationPickerPotraitView::launchPopUpMenu() -// ----------------------------------------------------------------------------- -void LocationPickerPotraitView::launchPopUpMenu(HbAbstractViewItem *aItem, const QPointF &aPoint) -{ - mLongPressMenu = new HbMenu(); - mLongPressMenu->setTimeout(HbMenu::NoTimeout); - HbAction* selectAction = mLongPressMenu->addAction(hbTrId("Select")); - mIndex = aItem->modelIndex(); - connect(selectAction, SIGNAL(triggered()), this, SLOT(handleLongPress())); - mLongPressMenu->setPreferredPos(aPoint); - mLongPressMenu->open(); -} - -// ----------------------------------------------------------------------------- -// LocationPickerPotraitView::handleLongPress() -// ----------------------------------------------------------------------------- -void LocationPickerPotraitView::handleLongPress() -{ - handleActivated(mIndex); -} diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/src/locationpickerproxymodel.cpp --- a/locationpickerservice/src/locationpickerproxymodel.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/src/locationpickerproxymodel.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -22,9 +22,8 @@ // LocationPickerProxyModel::LocationPickerProxyModel() // ---------------------------------------------------- -LocationPickerProxyModel::LocationPickerProxyModel( Qt::Orientations aOrientation , QObject *parent ) - :QSortFilterProxyModel(parent), - mOrientation( aOrientation ) +LocationPickerProxyModel::LocationPickerProxyModel( QObject *parent ) + :QSortFilterProxyModel(parent) { } @@ -36,26 +35,16 @@ { // get left and right items data and implement sort logic // return true if left is less than right - QVariant leftData = sourceModel()->data(left); + QVariant leftData = sourceModel()->data(left); QVariant rightData = sourceModel()->data(right); - if( mOrientation == Qt::Vertical ) - { - QStringList leftStringList = leftData.toStringList(); + QStringList leftStringList = leftData.toStringList(); - QStringList rightStringList = rightData.toStringList(); + QStringList rightStringList = rightData.toStringList(); - return QString::compare( QString( leftStringList[0] + " " + leftStringList[1] ), - QString( rightStringList[0] + " " + rightStringList[1] ), Qt::CaseInsensitive ) < 0; - } - else - { - QString leftString = leftData.toString(); + return QString::compare( QString( leftStringList[0] + " " + leftStringList[1] ), + QString( rightStringList[0] + " " + rightStringList[1] ), Qt::CaseInsensitive ) < 0; - QString rightString = rightData.toString(); - - return QString::compare( leftString, rightString, Qt::CaseInsensitive ) < 0; - } } // ---------------------------------------------------- @@ -65,8 +54,7 @@ bool LocationPickerProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const { - if( mOrientation == Qt::Vertical) - { + // implement logic for search. QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent); @@ -74,9 +62,7 @@ QString fullString = " " + stringList[0] + " " + stringList[1]; return (fullString.contains(mSearchText, Qt::CaseInsensitive)); - } - else - return true; + } // ---------------------------------------------------- diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/src/locationpickersearchview.cpp --- a/locationpickerservice/src/locationpickersearchview.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/src/locationpickersearchview.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -42,7 +42,8 @@ mEmptyLabel(NULL), mVerticalLayout(NULL), mDocumentLoader(aLoader), - mLongPressMenu(NULL) + mLongPressMenu(NULL), + mSelectAction(NULL) { } @@ -53,7 +54,6 @@ { delete mProxyModel; delete mEmptyLabel; - delete mLongPressMenu; } // ---------------------------------------------------- @@ -86,7 +86,7 @@ mListView->setItemPrototype( hbListItem ); // Create the proxy model. - mProxyModel = new LocationPickerProxyModel( Qt ::Vertical ); + mProxyModel = new LocationPickerProxyModel(); mProxyModel->setSourceModel(mModel); mListView->setModel(mProxyModel); @@ -172,7 +172,6 @@ aValue = var.toUInt(); } - // ----------------------------------------------------------------------------- // LocationPickerSearchView::launchPopUpMenu() // ----------------------------------------------------------------------------- @@ -180,10 +179,11 @@ { mLongPressMenu = new HbMenu(); mLongPressMenu->setTimeout(HbMenu::NoTimeout); - HbAction* selectAction = mLongPressMenu->addAction(hbTrId("Select")); + mSelectAction = mLongPressMenu->addAction(hbTrId("Select")); mIndex = aItem->modelIndex(); - connect(selectAction, SIGNAL(triggered()),this, SLOT(handleLongPress())); + connect(mSelectAction, SIGNAL(triggered()),this, SLOT(handleLongPress())); mLongPressMenu->setPreferredPos(aPoint); + connect(mLongPressMenu,SIGNAL(aboutToClose ()),this,SLOT(deleteMenu())); mLongPressMenu->open(); } @@ -194,3 +194,14 @@ { handleActivated(mIndex); } + +// ----------------------------------------------------------------------------- +// LocationPickerSearchView::deleteMenu() +// ----------------------------------------------------------------------------- +void LocationPickerSearchView::deleteMenu() +{ + mLongPressMenu->deleteLater(); + mLongPressMenu = NULL; + mSelectAction->deleteLater(); + mSelectAction = NULL; +} diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/src/locationpickerservice.cpp --- a/locationpickerservice/src/locationpickerservice.cpp Wed Jun 23 18:07:15 2010 +0300 +++ b/locationpickerservice/src/locationpickerservice.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -51,11 +51,6 @@ bool ok = completeRequest(mAsyncReqId,mReturn); mAsyncReqId = 0; } - else - { - qApp->quit(); - - } } // ---------------------------------------------------------------------------- // isActive() diff -r 96df3ab41000 -r 8db05346071b locationpickerservice/src/locationpickerview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationpickerservice/src/locationpickerview.cpp Tue Jul 06 14:10:28 2010 +0300 @@ -0,0 +1,770 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: LocationPickerView implementation +* +*/ + +#include "locationpickerview.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "hgwidgetdatamodel.h" +#include "locationpickerproxymodel.h" +#include "locationpickerdatamanager.h" +#include "locationpickercontent.h" +#include "locationpickercollectionlistcontent.h" +#include "locationpickercollectioncontent.h" + +// ======== MEMBER FUNCTIONS ======== + +// ---------------------------------------------------- +// LocationPickerView::LocationPickerView() +// ---------------------------------------------------- +LocationPickerView::LocationPickerView( HbDocumentLoader* aLoader ) + :mDocumentLoader(aLoader), + mLocationPickerCollectionListContent(NULL), + mProxyModel(NULL), + mAllAction(NULL), + mCollectionAction(NULL), + mSearchAction(NULL), + mAscendingAction(NULL), + mDescendingAction(NULL), + mListView(NULL), + mCollectionContent(NULL), + mViewType(ELocationPickerContent), + mLinerLayout(NULL), + mColllabel(NULL), + mEmptyLabel(NULL), + mDialog(NULL), + mMapIconLabel(NULL), + mTitleLabel(NULL), + mAddressMiddle(NULL), + mAddressBottom(NULL), + mLongPressMenu(NULL), + mSelectAction(NULL), + mDetailsAction(NULL), + mPopulated(false) +{ + //Create Action Items + mAllAction = qobject_cast (mDocumentLoader->findObject( + QString("allAction"))); + mCollectionAction = qobject_cast (mDocumentLoader->findObject( + QString("collectionAction"))); + mSearchAction = qobject_cast (mDocumentLoader->findObject( + QString("searchAction"))); + mAscendingAction = qobject_cast (mDocumentLoader->findObject( + QString("ascendingAction"))); + mDescendingAction = qobject_cast (mDocumentLoader->findObject( + QString("descendingAction"))); + if( !mAllAction || !mCollectionAction || !mSearchAction || !mAscendingAction || !mDescendingAction ) + { + qFatal("Error Reading Docml"); + } + // create back action + mBackAction = new HbAction(Hb::BackNaviAction); + // add back key action + setNavigationAction(mBackAction); + //connect to slots + connect(mBackAction, SIGNAL(triggered()), this, + SLOT(backTriggered())); + //create list item + mListItem = new HbListViewItem(); + //set the graphics size + mListItem->setGraphicsSize(HbListViewItem::Thumbnail); +} +// ---------------------------------------------------- +// LocationPickerView::~LocationPickerView() +// ---------------------------------------------------- +LocationPickerView::~LocationPickerView() +{ + delete mListItem; + delete mBackAction; + if(mPopulated) + { + mLinerLayout->removeItem(mListView); + mLinerLayout->removeItem(mWidget); + delete mCollectionContent; + delete mLocationPickerCollectionListContent; + delete mListView; + delete mWidget; + delete mHgModel; + delete mProxyModel; + delete mColllabel; + } +} + +// ---------------------------------------------------------------------------- +// LocationPickerView::backButtonTriggered() +// ---------------------------------------------------------------------------- +void LocationPickerView::backTriggered() +{ + //if current model is collection content, go back to collectionlist content + if(mViewType == ELocationPickerCollectionContent) + { + removeDetailsLabel(); + colectionTabTriggered(); + clearContentModel(); + } + else + { + //complete the service + emit completeService(); + } + +} + + +// ---------------------------------------------------- +// LocationPickerView::init() +// ---------------------------------------------------- +void LocationPickerView::init( Qt::Orientation aOrientation, QStandardItemModel *aModel ) +{ + mPopulated = true; + // Create Collection List Content + mLocationPickerCollectionListContent = new LocationPickerCollectionListContent(); + mModel = aModel; + // Create Collection List Content + mLocationPickerCollectionListContent = new LocationPickerCollectionListContent(); + //create proxy model + mProxyModel = new LocationPickerProxyModel( this ); + mProxyModel->setSourceModel(aModel); + // set sort properties + mProxyModel->setDynamicSortFilter(TRUE); + mProxyModel->setSortRole(Qt::DisplayRole); + mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); + // sort in ascending order + mProxyModel->sort(0, Qt::AscendingOrder); + mLinerLayout = static_cast(widget()->layout()); + //Get HbAction items + mListView = new HbListView(); + mColllabel = new HbLabel(); + createHurriganesWidget(); + mWidget->setModel(mHgModel); + //connect to slots + connect(mAscendingAction, SIGNAL(triggered()), this, SLOT(sortAscending())); + connect(mDescendingAction, SIGNAL(triggered()), this, + SLOT(sortDescending())); + //connect all action Items to respective slots + connect(mAllAction, SIGNAL(triggered()), this, SLOT(allTabTriggered())); + connect(mCollectionAction, SIGNAL(triggered()), this,SLOT(colectionTabTriggered())); + connect(mSearchAction, SIGNAL(triggered()), this, + SLOT(searchTabTriggered())); + // connect the signal of the list activated to a slot. + connect(mListView, SIGNAL(activated(const QModelIndex &)), this, SLOT(handleActivated(const QModelIndex &))); + connect(mListView,SIGNAL(longPressed(HbAbstractViewItem*, const QPointF &)),this, + SLOT(launchPopUpMenu(HbAbstractViewItem*, const QPointF &))); + //set widget according to orientation + if(aOrientation == Qt::Horizontal) + { + manageHgWidget(); + } + else + { + manageListView(); + } +} + + +void LocationPickerView::createHurriganesWidget() +{ + //hurrriganes widget + mHgModel = new HgWidgetDataModel( mProxyModel, this ); + mHgModel->setImageDataType(HgWidgetDataModel::ETypeQImage); + //create MediaWall Object + mWidget = new HgMediawall(); + HbIcon defaultIcon(KDummyImage); + QImage defaultImage = defaultIcon.pixmap().toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied); + mWidget->setDefaultImage(defaultImage); + HgMediawall* mediawall = qobject_cast( mWidget ); + mediawall->setObjectName("location"); + HbStyleLoader::registerFilePath(":/location.hgmediawall.widgetml"); + HbStyleLoader::registerFilePath(":/location.hgmediawall.css"); + mediawall->enableReflections(false); + mediawall->setFontSpec(HbFontSpec(HbFontSpec::Primary)); + mediawall->setItemSize(QSize(4,3)); + connect(this->mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),mWidget, + SLOT(orientationChanged(Qt::Orientation))); + + mWidget->setAcceptTouchEvents(true); + connect(mWidget, SIGNAL(activated(const QModelIndex &)),this, SLOT(handleActivated(const QModelIndex &))); + connect(mWidget, SIGNAL(longPressed(const QModelIndex &, const QPointF &)),this, + SLOT(launchPopUpMenu(const QModelIndex &, const QPointF &))); + mWidget->setLongPressEnabled(true); + mWidget->scrollTo(mWidget->currentIndex()); +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::manageHgWidget() +// ----------------------------------------------------------------------------- +void LocationPickerView::manageHgWidget() +{ + removeDetailsLabel(); + mLinerLayout->removeItem(mListView); + mListView->hide(); + mWidget->show(); + mLinerLayout->updateGeometry(); + //set the appropriate model + switch(mViewType) + { + case ELocationPickerContent: + { + mHgModel->resetModel(mProxyModel); + mAllAction->setChecked(true); + mCollectionAction->setChecked(false); + mLinerLayout->insertItem(1,mWidget); + } + break; + case ELocationPickerCollectionContent: + { + setCollectionData(mCategoryId); + mCollectionAction->setChecked(true); + mAllAction->setChecked(false); + } + break; + } +} + +// ---------------------------------------------------- +// LocationPickerView::manageListView() +// ---------------------------------------------------- +void LocationPickerView::manageListView() +{ + if(mEmptyLabel) + { + removeDetailsLabel(); + } + else + { + mLinerLayout->removeItem(mWidget); + mWidget->hide(); + } + mLinerLayout->insertItem(1,mListView); + mListView->show(); + //set the appropriate model + switch(mViewType) + { + case ELocationPickerContent: + { + mListItem->setGraphicsSize(HbListViewItem::Thumbnail); + mListView->setModel(mProxyModel,mListItem); + mAllAction->setChecked(true); + mCollectionAction->setChecked(false); + mViewType = ELocationPickerContent; + } + break; + case ELocationPickerCollectionListContent: + { + mListView->setModel(mLocationPickerCollectionListContent->getStandardModel(),mListItem); + mCollectionAction->setChecked(true); + mAllAction->setChecked(false); + if(mAscendingAction->isEnabled()) + { + mAscendingAction->setDisabled(true); + mDescendingAction->setDisabled(true); + } + mViewType = ELocationPickerCollectionListContent; + } + break; + case ELocationPickerCollectionContent: + { + mCollectionAction->setChecked(true); + mAllAction->setChecked(false); + mViewType = ELocationPickerCollectionContent; + setCollectionData(mCategoryId); + } + break; + default: + break; + } +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::disableTabs() +// ----------------------------------------------------------------------------- +void LocationPickerView::disableTabs() +{ + //if no location entries present + mLinerLayout = static_cast(widget()->layout()); + mEmptyLabel = new HbTextItem( hbTrId( "txt_lint_list_no_location_entries_present" ) ); + mEmptyLabel->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ); + mEmptyLabel->setFontSpec( HbFontSpec( HbFontSpec::Primary ) ); + mEmptyLabel->setAlignment( Qt::AlignCenter ); + mLinerLayout->insertItem( 1, mEmptyLabel ); + mAllAction->setDisabled( true ); + mCollectionAction->setDisabled( true ); + mSearchAction->setDisabled( true ); + mAscendingAction->setDisabled( true ); + mDescendingAction->setDisabled( true ); +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::handleActivated() +// ----------------------------------------------------------------------------- +void LocationPickerView::handleActivated( const QModelIndex &aIndex ) +{ + QModelIndex index; + QStandardItem* item; + int row= aIndex.row(); + int col = aIndex.column(); + //handle the activated signal according to model set + switch(mViewType) + { + case ELocationPickerContent: + { + if(mainWindow()->orientation() == Qt::Vertical) + { + index = mProxyModel->mapToSource( + aIndex); + item = mModel->item( index.row(), index.column() ); + } + else + { + QModelIndex proxyModelIndex = mProxyModel->index(row,col); + index = mProxyModel->mapToSource( + proxyModelIndex); + item = mModel->item( index.row(), index.column() ); + } + QVariant var = item->data( Qt::UserRole ); + quint32 lm = var.toUInt(); + //item selected, complete request + emit selectItem( lm ); + } + break; + case ELocationPickerCollectionListContent: + { + mLocationPickerCollectionListContent->getData( + aIndex, mCategoryId ); + setCollectionData(mCategoryId); + mViewType = ELocationPickerCollectionContent; + } + break; + case ELocationPickerCollectionContent: + { + if(mainWindow()->orientation() == Qt::Vertical) + { + index = mCollectionContent->getProxyModel()->mapToSource( + aIndex); + } + else + { + QModelIndex proxyModelIndex = mCollectionContent->getProxyModel()->index(row,col); + index = mCollectionContent->getProxyModel()->mapToSource( + proxyModelIndex); + } + quint32 lm = 0; + mCollectionContent->getData(index, lm); + //item selected, complete request + emit selectItem(lm); + } + break; + default: + break; + } +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::sortAscending() +// ----------------------------------------------------------------------------- +void LocationPickerView::sortAscending() +{ + //check the model set and do sorting accordingly + if (mViewType == ELocationPickerContent) + { + mProxyModel->sort( 0, Qt::AscendingOrder ); + if(mainWindow()->orientation()==Qt::Horizontal) + mHgModel->resetModel(mProxyModel); + } + else + { + mCollectionContent->getProxyModel()->sort( 0, Qt::AscendingOrder ); + if(mainWindow()->orientation()==Qt::Horizontal) + mHgModel->resetModel(mCollectionContent->getProxyModel()); + } +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::sortDescending() +// ----------------------------------------------------------------------------- +void LocationPickerView::sortDescending() +{ + //check the model set and do sorting accordingly + if (mViewType == ELocationPickerContent) + { + mProxyModel->sort(0, Qt::DescendingOrder); + if(mainWindow()->orientation()==Qt::Horizontal) + mHgModel->resetModel(mProxyModel); + } + else + { + mCollectionContent->getProxyModel()->sort( 0, Qt::DescendingOrder ); + if(mainWindow()->orientation()==Qt::Horizontal) + mHgModel->resetModel(mCollectionContent->getProxyModel()); + } +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::allTabTriggered() +// ----------------------------------------------------------------------------- +void LocationPickerView::allTabTriggered() +{ + removeDetailsLabel(); + //execute only if tab is not pressed + if (mAllAction->isChecked()) + { + mViewType = ELocationPickerContent; + mCollectionAction->setChecked(false); + mAscendingAction->setEnabled(true); + mDescendingAction->setEnabled(true); + //delete mCollectionContent if coming back from collectioncontent + if (mCollectionContent) + { + delete mCollectionContent; + mCollectionContent = NULL; + } + if(mainWindow()->orientation() == Qt::Vertical) + { + manageListView(); + } + else + { + manageHgWidget(); + } + } + else + { + //Keep the tab pressed + mAllAction->setChecked(true); + } + +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::colectionTabTriggered() +// ----------------------------------------------------------------------------- +void LocationPickerView::colectionTabTriggered() +{ + mListItem->setGraphicsSize(HbListViewItem::MediumIcon); + removeDetailsLabel(); + //execute only if tab is not pressed + if (mCollectionAction->isChecked()) + { + mAscendingAction->setDisabled(true); + mDescendingAction->setDisabled(true); + mAllAction->setChecked(false); + mViewType = ELocationPickerCollectionListContent; + manageListView(); + } + else + { + //Keep the tab pressed + mCollectionAction->setChecked(true); + } +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::searchTabTriggered() +// ----------------------------------------------------------------------------- +void LocationPickerView::searchTabTriggered() +{ + emit switchToSearchView(); +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::setCollectionData() +// ----------------------------------------------------------------------------- +void LocationPickerView::setCollectionData( quint32 acategoryId ) +{ + if(!mCollectionContent) + { + mCollectionContent + = new LocationPickerCollectionContent( acategoryId ); + } + + if(mainWindow()->orientation() == Qt::Vertical) + { + QString categoryname; + removeDetailsLabel(); + switch(acategoryId) + { + + case 1: categoryname = "Landmarks"; + break; + case 8: categoryname = "Contacts"; + break; + case 9: categoryname = "Calender"; + break; + } + if(mCollectionContent->locationFound()) + { + mListView->setModel( mCollectionContent->getProxyModel(),mListItem ); + //Enable the options + mAscendingAction->setEnabled(true); + mDescendingAction->setEnabled(true); + mListItem->setGraphicsSize(HbListViewItem::Thumbnail); + } + else + { + displayNoEntries(); + } + mCollectionAction->setChecked(true); + + if(mColllabel) + { + mLinerLayout->insertItem(0,mColllabel); + mColllabel->setPlainText(categoryname); + mColllabel->show(); + } + } + else + { + if(mCollectionContent->locationFound()) + { + mHgModel->resetModel( mCollectionContent->getProxyModel() ); + //Enable the options + mAscendingAction->setEnabled(true); + mDescendingAction->setEnabled(true); + mLinerLayout->removeItem(mListView); + mListView->hide(); + mLinerLayout->insertItem(1,mWidget); + mWidget->show(); + mLinerLayout->updateGeometry(); + } + else + { + displayNoEntries(); + } + } + mViewType = ELocationPickerCollectionContent; +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::getViewType() +// ----------------------------------------------------------------------------- +TViewType LocationPickerView::getViewType() +{ + return mViewType; +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::setViewType() +// ----------------------------------------------------------------------------- +void LocationPickerView::setViewType( TViewType aViewType ) +{ + mViewType = aViewType; +} + + +// ----------------------------------------------------------------------------- +// LocationPickerView::clearContentModel() +// ----------------------------------------------------------------------------- +void LocationPickerView::clearContentModel() +{ + if(mCollectionContent) + { + delete mCollectionContent; + mCollectionContent = NULL; + } +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::launchPopUpMenu() +// ----------------------------------------------------------------------------- +void LocationPickerView::launchPopUpMenu( HbAbstractViewItem *aItem, const QPointF &aPoint ) +{ + mLongPressMenu = new HbMenu(); + mLongPressMenu->setTimeout(HbMenu::NoTimeout); + connect(mLongPressMenu,SIGNAL(aboutToClose ()),this,SLOT(deleteMenu())); + mSelectAction = mLongPressMenu->addAction(hbTrId("Select")); + if( mViewType == ELocationPickerCollectionContent || mViewType == ELocationPickerContent ) + { + mDetailsAction = mLongPressMenu->addAction(hbTrId("txt_lint_list_details")); + connect(mDetailsAction, SIGNAL(triggered()), this, SLOT(handleDetails())); + } + mIndex = aItem->modelIndex(); + connect(mSelectAction, SIGNAL(triggered()), this, SLOT(handleSelect())); + mLongPressMenu->setPreferredPos(aPoint); + mLongPressMenu->open(); +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::launchPopUpMenu() +// ----------------------------------------------------------------------------- +void LocationPickerView::launchPopUpMenu( const QModelIndex &aIndex, const QPointF &aPoint ) +{ + mLongPressMenu = new HbMenu(); + mLongPressMenu->setTimeout(HbMenu::NoTimeout); + connect(mLongPressMenu,SIGNAL(aboutToClose ()),this,SLOT(deleteMenu())); + mSelectAction = mLongPressMenu->addAction(hbTrId("Select")); + mIndex = aIndex; + connect(mSelectAction, SIGNAL(triggered()), this, SLOT(handleSelect())); + mLongPressMenu->setPreferredPos(aPoint); + mLongPressMenu->open(); +} +// ----------------------------------------------------------------------------- +// LocationPickerView::handleSelect() +// ----------------------------------------------------------------------------- +void LocationPickerView::handleSelect() +{ + handleActivated(mIndex); +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::deleteMenu() +// ----------------------------------------------------------------------------- +void LocationPickerView::deleteMenu() +{ + mLongPressMenu->deleteLater(); + mLongPressMenu = NULL; + mSelectAction->deleteLater(); + mSelectAction = NULL; + mDetailsAction->deleteLater(); + mDetailsAction = NULL; + +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::handleSelect() +// ----------------------------------------------------------------------------- +void LocationPickerView::handleDetails() +{ + HbDocumentLoader* loader = new HbDocumentLoader(); + + bool ok = false; + //load the popup dialog + loader->load(":/popupdialog.docml", &ok); + Q_ASSERT_X(ok,"locationpickerservice","invalid DocML file"); + //find graphics popup dialog + QGraphicsWidget *popUpDialog = loader->findWidget("dialog"); + Q_ASSERT_X((popUpDialog != 0), "locationpickerservice", "invalid DocML file"); + mDialog = qobject_cast(popUpDialog); + mMapIconLabel = qobject_cast(loader->findWidget("mapLabel")); + mTitleLabel = qobject_cast(loader->findWidget("titleLabel")); + mAddressMiddle = qobject_cast(loader->findWidget("addressMiddle")); + mAddressBottom = qobject_cast(loader->findWidget("addressBottom")); + mDone = qobject_cast(loader->findObject(QString("action"))); + mTitleLabel->setFontSpec(HbFontSpec(HbFontSpec::Primary)); + mDialog->setDismissPolicy(HbDialog::NoDismiss); + mDialog->setTimeout(HbDialog::NoTimeout); + connect(mDone, SIGNAL(triggered()), this, SLOT(closeDetailsDialog())); + QStringList adressDetail; + QString iconName; + mMapIconLabel->setAlignment(Qt::AlignCenter); + if(mViewType == ELocationPickerContent) + { + adressDetail = mProxyModel->data(mIndex,Qt::UserRole+3).toStringList(); + iconName = mProxyModel->data(mIndex,Qt::UserRole+1).toString(); + } + else + { + adressDetail = mCollectionContent->getProxyModel()->data(mIndex,Qt::UserRole+3).toStringList(); + iconName = mCollectionContent->getProxyModel()->data(mIndex,Qt::UserRole+1).toString(); + } + if(iconName.isEmpty()) + { + mMapIconLabel->setIcon(KDummyImage); + } + else + { + mMapIconLabel->setIcon(HbIcon(iconName)); + } + + if(adressDetail[0].isEmpty() && adressDetail[1].isEmpty()) + { + mTitleLabel->setPlainText(adressDetail[2]); + mAddressMiddle->setPlainText(QString("")); + mAddressBottom->setPlainText(QString("")); + } + else if(adressDetail[0].isEmpty()) + { + mTitleLabel->setPlainText(adressDetail[1]); + mAddressMiddle->setPlainText(adressDetail[2]); + mAddressBottom->setPlainText(QString("")); + } + else if (adressDetail[1].isEmpty()) + { + mTitleLabel->setPlainText(adressDetail[0]); + mAddressMiddle->setPlainText(adressDetail[2]); + mAddressBottom->setPlainText(QString("")); + } + else + { + mTitleLabel->setPlainText(adressDetail[0]); + mAddressMiddle->setPlainText(adressDetail[1]); + mAddressBottom->setPlainText(adressDetail[2]); + } + + mDialog->open(); + delete loader; +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::closeDetailsDialog() +// ----------------------------------------------------------------------------- +void LocationPickerView::closeDetailsDialog() +{ + if(mDialog) + { + mDialog->close(); + delete mDialog; + mDialog = NULL; + } +} +// ----------------------------------------------------------------------------- +// LocationPickerView::displayNoEntries() +// ----------------------------------------------------------------------------- +void LocationPickerView::displayNoEntries() +{ + if(!mEmptyLabel) + { + mEmptyLabel = new HbTextItem(hbTrId("txt_lint_list_no_location_entries_present")); + mEmptyLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + mEmptyLabel->setFontSpec(HbFontSpec(HbFontSpec::Primary)); + mEmptyLabel->setAlignment(Qt::AlignCenter); + mLinerLayout->removeItem(mListView); + mListView->hide(); + mWidget->setVisible(false); + mLinerLayout->insertItem(0, mEmptyLabel); + } + +} + +// ----------------------------------------------------------------------------- +// LocationPickerView::removeDetailsLabel() +// ----------------------------------------------------------------------------- +void LocationPickerView::removeDetailsLabel() +{ + if (mLinerLayout && mColllabel) + { + mColllabel->setPlainText(""); + mLinerLayout->removeItem(mColllabel); + mColllabel->hide(); + } + if(mEmptyLabel) + { + mLinerLayout->removeItem(mEmptyLabel); + mEmptyLabel->hide(); + delete mEmptyLabel; + mEmptyLabel = NULL; + } +} +