From 156e4ae27e6a85b1473e51dcfa6a2df640112ccd Mon Sep 17 00:00:00 2001 From: abcd Date: Tue, 13 Apr 2010 23:32:22 +1000 Subject: Start adding in an example for documentation snippets Also modify qlandmarkfetchrequest, qlandmarksaverequest, and qlandmarkcategorysaverequest so they are a bit easier to use. --- .../qtlandmarksdocsample/qtlandmarksdocsample.cpp | 376 +++++++++++++++++++++ 1 file changed, 376 insertions(+) create mode 100644 doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp (limited to 'doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp') diff --git a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp new file mode 100644 index 0000000000..c774fcc823 --- /dev/null +++ b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp @@ -0,0 +1,376 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "requestexample.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +QTM_USE_NAMESPACE +QLandmarkCategoryId categoryId; + +//! [Adding a category and landmark asynchronously] +//Save a category asynchronously +void RequestExample::categorySaveRequest() +{ + QLandmarkCategory cafes; + cafes.setName("Cafes"); + cafes.setDescription("Small diners"); + cafes.setIconUrl(QUrl("cafe.png")); + + //catSaveRequest was created with catSaveRequest = new QLandmarkCategorySaveRequest() + //in the ctor + catSaveRequest->setManager(lmManager); //lmManager is a QLandmarkManager* + catSaveRequest->appendCategory(cafes); + + connect(catSaveRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), this, + SLOT(categorySaveRequestHandler(QLandmarkAbstractRequest::State))); + if (!catSaveRequest->start()) + qDebug() << "Unable to save category error code: " << catSaveRequest->error(); + else + qDebug() << "Saveing category; awaiting results..."; +} + +void RequestExample::categorySaveRequestHandler(QLandmarkAbstractRequest::State state) +{ + if (state == QLandmarkAbstractRequest::FinishedState) { + if (catSaveRequest->error() == QLandmarkManager::NoError) { + qDebug() << "Category save succesfully completed"; + catSaveRequest->clearCategories(); + } + else { + qDebug() << "Category save was unsuccessful"; + } + } +} + +//Save a landmark asynchronously +void RequestExample::landmarkSaveRequest() +{ + //Creating and saving a landmark + QLandmark monks; + monks.setName("Monk's cafe"); + monks.setCoordinate(QGeoCoordinate(40.81, 73.97)); + + QGeoAddress address; + address.setThoroughfareNumber("2880"); + address.setThoroughfareName("112th Street"); + address.setCity("New York City"); + address.setState("New York"); + address.setCountry("United States"); + address.setCountryCode("US"); + monks.setAddress(address); + + //lmSaveRequest was created with lmSaveRequest = new QLandmarkSaveRequest() + //in the ctor + lmSaveRequest->setManager(lmManager); //lmManager is a QLandmarkManager* + lmSaveRequest->appendLandmark(monks); + + monks.setDescription("Jerry's favourite diner"); + + connect(lmSaveRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), this, + SLOT(landmarkSaveRequestHandler(QLandmarkAbstractRequest::State))); + if (!lmSaveRequest->start()) + qDebug() << "Unable to save landmark error code: " << lmSaveRequest->error(); + else + qDebug() << "Saving landmark; awaiting results..."; +} + +void RequestExample::landmarkSaveRequestHandler(QLandmarkAbstractRequest::State state) +{ + if (state == QLandmarkAbstractRequest::FinishedState) { + if (lmSaveRequest->error() == QLandmarkManager::NoError) { + qDebug() << "Landmark save succesfully completed"; + lmSaveRequest->clearLandmarks(); + } + else { + qDebug() << "Landmark save was unsuccessful"; + } + } +} +//! [Adding a category and landmark asynchronously] + +//! [fetch categories and landmarks asynchronously] +//Fetch categories asynchronously +void RequestExample::categoryFetchRequest() +{ + //catFetchRequest was created with catFetchRequest = new QLandmarkCategoryFetchRequest() + //in the ctor + catFetchRequest->setManager(lmManager); //lmManager is a QLandmarkManager* + + connect(catFetchRequest, SIGNAL(resultsAvailable()), this, SLOT(printCategories())); + connect(catFetchRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), + this, SLOT(categoryFetchHandlerRequest(QLandmarkAbstractRequest::State))); + + if(!catFetchRequest->start()) { + qDebug() << "Unable to request categories, error code:" << catFetchRequest->error(); + QCoreApplication::exit(0); + } else { + qDebug() << "Requested categories, awaiting results..."; + } +} + +void RequestExample::printCategories() +{ + QList categories = catFetchRequest->categories(); + for( ;previousLastIndex < categories.size(); ++previousLastIndex) { + qDebug() << "Found category: " << categories.at(previousLastIndex).name(); + } +} + +void RequestExample::categoryFetchHandlerRequest(QLandmarkAbstractRequest::State state) +{ + if (state == QLandmarkAbstractRequest::FinishedState) { + previousLastIndex = 0; + if (catFetchRequest->error() == QLandmarkManager::NoError) { + qDebug() << "Category fetch succesfully completed"; + } + else { + qDebug() << "Category fetch was unsuccessful"; + } + } +} + +//Fetch landmarks asynchronously +void RequestExample::landmarkFetchRequest() +{ + QLandmarkCategoryFilter filter; + //categoryId is a previously retrieved QLandmarkCategoryId + filter.setCategoryId(categoryId); + + //lmFetchRequest was created with lmFetchRequest = new QLandmarkFetchRequest() + //in the ctor + lmFetchRequest->setManager(lmManager); //lmManager is a QLandmarkManager* + lmFetchRequest->setFilter(filter); + lmFetchRequest->setSorting(QLandmarkNameSort(Qt::AscendingOrder)); + + connect(lmFetchRequest, SIGNAL(resultsAvailable()), this, SLOT(printLandmarks())); + connect(lmFetchRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), + this, SLOT(landmarkFetchHandlerRequest(QLandmarkAbstractRequest::State))); + + if(!lmFetchRequest->start()) { + qDebug() << "Unable to request landmarks, error code:" << lmFetchRequest->error(); + QCoreApplication::exit(0); + } else { + qDebug() << "Requested landmarks, awaiting results..."; + } +} + +void RequestExample::printLandmarks() +{ + QList results = lmFetchRequest->landmarks(); + for( ;previousLastIndex < results.size(); ++previousLastIndex) { + qDebug() << "Found landmark: " << results.at(previousLastIndex).name(); + } +} + +void RequestExample::landmarkFetchHandlerRequest(QLandmarkAbstractRequest::State state) +{ + if (state == QLandmarkAbstractRequest::FinishedState) { + previousLastIndex = 0; + if (lmFetchRequest->error() == QLandmarkManager::NoError) { + qDebug() << "Landmark fetch succesfully completed"; + } + else { + qDebug() << "Landmark fetch was unsuccessful"; + } + } +} +//! [fetch categories and landmarks asynchronously] + + //! [Adding a category and landmark synchronously] +void addLandmarkAndCategory(QLandmarkManager *lm) +{ + //Creating and saving a category + QLandmarkCategory cafes; + cafes.setName("Cafes"); + cafes.setDescription("Small diners"); + cafes.setIconUrl(QUrl("cafe.png")); + lm->saveCategory(&cafes); + + + //Creating and saving a landmark + QLandmark monks; + monks.setName("Monk's cafe"); + monks.setCoordinate(QGeoCoordinate(40.81, 73.97)); + + QGeoAddress address; + address.setThoroughfareNumber("2880"); + address.setThoroughfareName("112th Street"); + address.setCity("New York City"); + address.setState("New York"); + address.setCountry("United States"); + address.setCountryCode("US"); + monks.setAddress(address); + + monks.setDescription("Jerry's favourite diner"); + monks.addCategory(cafes.id()); + + lm->saveLandmark(&monks); +} +//! [Adding a category and landmark synchronously] + +//! [fetch categories and landmarks synchronously] +//Fetch categories synchronously +void categoryFetch(QLandmarkManager *lm) +{ + //retrieval of categories by id. + QList categoryIds = lm->categoryIds(); + foreach(QLandmarkCategoryId id, categoryIds) { + qDebug() << "Found category: " << lm->category(id).name(); + } + + //retrieval of categories directly. + QList categories = lm->categories(); + foreach(QLandmarkCategory category, categories) { + qDebug() << "Found category: " << category.name(); + } +} + +//Fetch landmarks synchronously +void landmarkFetch(QLandmarkManager *lm) +{ + QLandmarkCategoryFilter filter; + //categoryId is a previously retrieved QLandmarkCategoryId + filter.setCategoryId(categoryId); + + //retrieval via ids + QList landmarkIds; + landmarkIds = lm->landmarkIds(filter, QLandmarkNameSort(Qt::AscendingOrder)); + foreach(QLandmarkId id, landmarkIds) { + qDebug() << "Found landmark:" << lm->landmark(id).name(); + } + + //retrieval of landmark objects directly + QList landmarks; + landmarks = lm->landmarks(filter, QLandmarkNameSort(Qt::AscendingOrder)); + foreach(QLandmark landmark, landmarks) { + qDebug() << "Found landmark:" << landmark.name(); + } +} +//! [fetch categories and landmarks synchronously] + +void filterByName(QLandmarkManager *lm) +{ + QLandmarkNameFilter filter("Monk's cafe"); + QList matchingIds = lm->landmarkIds(filter); + + if (matchingIds.count() == 0) { + qDebug() << "No matches found"; + } else { + QLandmark match = lm->landmark(matchingIds.at(0)); + qDebug() << "Match found coordinates are:" << match.coordinate().toString(); + } +} + +void filterByProximity(QLandmarkManager *lm) +{ + QGeoCoordinate origin(41,74); + QLandmarkProximityFilter filter(origin, 5000); + QList matchingIds = lm->landmarkIds(filter, QLandmarkDistanceSort(origin, Qt::AscendingOrder)); + + if(matchingIds.count() == 0) { + qDebug() << "No matches found"; + } else { + QLandmark matchingLandmark; + foreach(QLandmarkId id, matchingIds) { + matchingLandmark = lm->landmark(id); + qDebug() << "Match found, name: " << matchingLandmark.name(); + } + } + +} + +void listAllCategories(QLandmarkManager *lm) +{ + QList categoryIds = lm->categoryIds(); + foreach(QLandmarkCategoryId id, categoryIds) { + qDebug() << lm->category(id).name(); + } + + QList categories = lm->categories(); + foreach(QLandmarkCategory category, categories) { + qDebug() << category.name(); + } + +} + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + QLandmarkManager *lm = new QLandmarkManager(); + //Synchronous API examples + addLandmarkAndCategory(lm); + categoryFetch(lm); + landmarkFetch(lm); + filterByName(lm); + filterByProximity(lm); + + //Asynchronous API example + RequestExample re; + QTimer::singleShot(10, &re, SLOT(categorySaveRequest())); + QTimer::singleShot(10, &re, SLOT(landmarkSaveRequest())); + QTimer::singleShot(10, &re, SLOT(categoryFetchRequest())); + QTimer::singleShot(10, &re, SLOT(landmarkFetchRequest())); + + app.exec(); + + delete lm; + return 0; +} -- cgit v1.2.3 From 43d7b5fe90a24ac84364d5878db2947b17d35c0e Mon Sep 17 00:00:00 2001 From: abcd Date: Wed, 14 Apr 2010 15:09:05 +1000 Subject: Don't use the convenience headers in the qtlandmarkdocsample for now Compile fails because the conveience headers are only installed after a make install step. Therefore there are missing headers during the make step. --- .../qtlandmarksdocsample/qtlandmarksdocsample.cpp | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp') diff --git a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp index c774fcc823..61a34e7801 100644 --- a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp +++ b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp @@ -41,20 +41,20 @@ #include "requestexample.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -- cgit v1.2.3 From a5cc0a2382bdae7761ce34f9e967935094f01338 Mon Sep 17 00:00:00 2001 From: abcd Date: Thu, 15 Apr 2010 16:03:28 +1000 Subject: Update examples to not use resultsAvailable() on request objects Because the request results are sorted, using a previousLastIndex and resultsAvailable() signal to be incrementally notified of new results does not work, and so should be removed from the examples --- .../qtlandmarksdocsample/qtlandmarksdocsample.cpp | 85 ++++++++++------------ 1 file changed, 40 insertions(+), 45 deletions(-) (limited to 'doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp') diff --git a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp index 61a34e7801..7cb474aa82 100644 --- a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp +++ b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp @@ -65,8 +65,8 @@ QTM_USE_NAMESPACE QLandmarkCategoryId categoryId; -//! [Adding a category and landmark asynchronously] -//Save a category asynchronously + +//! [Add category asynchronously req] void RequestExample::categorySaveRequest() { QLandmarkCategory cafes; @@ -86,7 +86,9 @@ void RequestExample::categorySaveRequest() else qDebug() << "Saveing category; awaiting results..."; } +//! [Add category asynchronously req] +//! [Add category asynchronously handler] void RequestExample::categorySaveRequestHandler(QLandmarkAbstractRequest::State state) { if (state == QLandmarkAbstractRequest::FinishedState) { @@ -99,8 +101,9 @@ void RequestExample::categorySaveRequestHandler(QLandmarkAbstractRequest::State } } } +//! [Add category asynchronously handler] -//Save a landmark asynchronously +//! [Add landmark asynchronously] void RequestExample::landmarkSaveRequest() { //Creating and saving a landmark @@ -110,10 +113,7 @@ void RequestExample::landmarkSaveRequest() QGeoAddress address; address.setThoroughfareNumber("2880"); - address.setThoroughfareName("112th Street"); - address.setCity("New York City"); - address.setState("New York"); - address.setCountry("United States"); + // ... address.setCountryCode("US"); monks.setAddress(address); @@ -131,7 +131,9 @@ void RequestExample::landmarkSaveRequest() else qDebug() << "Saving landmark; awaiting results..."; } +//! [Add landmark asynchronously] +//! [Add landmark asynchronously handler] void RequestExample::landmarkSaveRequestHandler(QLandmarkAbstractRequest::State state) { if (state == QLandmarkAbstractRequest::FinishedState) { @@ -144,17 +146,16 @@ void RequestExample::landmarkSaveRequestHandler(QLandmarkAbstractRequest::State } } } -//! [Adding a category and landmark asynchronously] +//! [Add landmark asynchronously handler] -//! [fetch categories and landmarks asynchronously] //Fetch categories asynchronously void RequestExample::categoryFetchRequest() { + //! [Retrieve categories asynchronously] //catFetchRequest was created with catFetchRequest = new QLandmarkCategoryFetchRequest() //in the ctor catFetchRequest->setManager(lmManager); //lmManager is a QLandmarkManager* - connect(catFetchRequest, SIGNAL(resultsAvailable()), this, SLOT(printCategories())); connect(catFetchRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), this, SLOT(categoryFetchHandlerRequest(QLandmarkAbstractRequest::State))); @@ -164,32 +165,31 @@ void RequestExample::categoryFetchRequest() } else { qDebug() << "Requested categories, awaiting results..."; } + //! [Retrieve categories asynchronously] } -void RequestExample::printCategories() -{ - QList categories = catFetchRequest->categories(); - for( ;previousLastIndex < categories.size(); ++previousLastIndex) { - qDebug() << "Found category: " << categories.at(previousLastIndex).name(); - } -} - +//! [Retrieve categories asynchronously handler] void RequestExample::categoryFetchHandlerRequest(QLandmarkAbstractRequest::State state) { if (state == QLandmarkAbstractRequest::FinishedState) { previousLastIndex = 0; if (catFetchRequest->error() == QLandmarkManager::NoError) { + QList categories = catFetchRequest->categories(); qDebug() << "Category fetch succesfully completed"; + for(int i=0; i < categories.count(); ++i) { + qDebug() << categories[i].name(); + } } else { qDebug() << "Category fetch was unsuccessful"; } } } +//! [Retrieve categories asynchronously handler] -//Fetch landmarks asynchronously void RequestExample::landmarkFetchRequest() { + //! [Retrieve landmarks asynchronously] QLandmarkCategoryFilter filter; //categoryId is a previously retrieved QLandmarkCategoryId filter.setCategoryId(categoryId); @@ -200,7 +200,6 @@ void RequestExample::landmarkFetchRequest() lmFetchRequest->setFilter(filter); lmFetchRequest->setSorting(QLandmarkNameSort(Qt::AscendingOrder)); - connect(lmFetchRequest, SIGNAL(resultsAvailable()), this, SLOT(printLandmarks())); connect(lmFetchRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), this, SLOT(landmarkFetchHandlerRequest(QLandmarkAbstractRequest::State))); @@ -210,42 +209,39 @@ void RequestExample::landmarkFetchRequest() } else { qDebug() << "Requested landmarks, awaiting results..."; } + //! [Retrieve landmarks asynchronously] } -void RequestExample::printLandmarks() -{ - QList results = lmFetchRequest->landmarks(); - for( ;previousLastIndex < results.size(); ++previousLastIndex) { - qDebug() << "Found landmark: " << results.at(previousLastIndex).name(); - } -} - +//! [Retrieve landmarks asynchronously handler] void RequestExample::landmarkFetchHandlerRequest(QLandmarkAbstractRequest::State state) { if (state == QLandmarkAbstractRequest::FinishedState) { previousLastIndex = 0; if (lmFetchRequest->error() == QLandmarkManager::NoError) { qDebug() << "Landmark fetch succesfully completed"; + QList landmarks = lmFetchRequest->landmarks(); + for(int i=0; i < landmarks.count(); ++i) { + qDebug() << landmarks[i].name(); + } } else { qDebug() << "Landmark fetch was unsuccessful"; } } } -//! [fetch categories and landmarks asynchronously] +//! [Retrieve landmarks asynchronously handler] - //! [Adding a category and landmark synchronously] void addLandmarkAndCategory(QLandmarkManager *lm) { - //Creating and saving a category +//! [Add category synchronously] QLandmarkCategory cafes; cafes.setName("Cafes"); cafes.setDescription("Small diners"); cafes.setIconUrl(QUrl("cafe.png")); - lm->saveCategory(&cafes); + lm->saveCategory(&cafes); //lm is a QLandmarkManager * +//! [Add category synchronously] - - //Creating and saving a landmark +//! [Add landmark synchronously] QLandmark monks; monks.setName("Monk's cafe"); monks.setCoordinate(QGeoCoordinate(40.81, 73.97)); @@ -262,30 +258,30 @@ void addLandmarkAndCategory(QLandmarkManager *lm) monks.setDescription("Jerry's favourite diner"); monks.addCategory(cafes.id()); - lm->saveLandmark(&monks); + lm->saveLandmark(&monks); //lm is a QLandmarkManager* + //! [Add landmark synchronously] } -//! [Adding a category and landmark synchronously] -//! [fetch categories and landmarks synchronously] -//Fetch categories synchronously void categoryFetch(QLandmarkManager *lm) { - //retrieval of categories by id. + //! [Retrieve categories synchronously by id] QList categoryIds = lm->categoryIds(); foreach(QLandmarkCategoryId id, categoryIds) { qDebug() << "Found category: " << lm->category(id).name(); } + //! [Retrieve categories synchronously by id] - //retrieval of categories directly. + //! [Retrieve categories synchronously] QList categories = lm->categories(); foreach(QLandmarkCategory category, categories) { qDebug() << "Found category: " << category.name(); } + //! [Retrieve categories synchronously] } -//Fetch landmarks synchronously void landmarkFetch(QLandmarkManager *lm) { + //! [Retrieve landmarks synchronously by id] QLandmarkCategoryFilter filter; //categoryId is a previously retrieved QLandmarkCategoryId filter.setCategoryId(categoryId); @@ -296,15 +292,16 @@ void landmarkFetch(QLandmarkManager *lm) foreach(QLandmarkId id, landmarkIds) { qDebug() << "Found landmark:" << lm->landmark(id).name(); } + //! [Retrieve landmarks synchronously by id] - //retrieval of landmark objects directly + //! [Retrieve landmarks synchronously] QList landmarks; landmarks = lm->landmarks(filter, QLandmarkNameSort(Qt::AscendingOrder)); foreach(QLandmark landmark, landmarks) { qDebug() << "Found landmark:" << landmark.name(); } + //! [Retrieve landmarks synchronously] } -//! [fetch categories and landmarks synchronously] void filterByName(QLandmarkManager *lm) { @@ -334,7 +331,6 @@ void filterByProximity(QLandmarkManager *lm) qDebug() << "Match found, name: " << matchingLandmark.name(); } } - } void listAllCategories(QLandmarkManager *lm) @@ -348,7 +344,6 @@ void listAllCategories(QLandmarkManager *lm) foreach(QLandmarkCategory category, categories) { qDebug() << category.name(); } - } int main(int argc, char *argv[]) -- cgit v1.2.3 From bafebd0e1506811978b20efc1302cc089fdca27c Mon Sep 17 00:00:00 2001 From: abcd Date: Thu, 15 Apr 2010 16:51:42 +1000 Subject: Replace append and remove functions from the save requests Use a set function instead to a set a single landmark or category --- .../qtlandmarksdocsample/qtlandmarksdocsample.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp') diff --git a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp index 7cb474aa82..b42869f525 100644 --- a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp +++ b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp @@ -64,7 +64,8 @@ QTM_USE_NAMESPACE QLandmarkCategoryId categoryId; - +QLandmark landmark; +QLandmarkCategory landmarkCategory; //! [Add category asynchronously req] void RequestExample::categorySaveRequest() @@ -77,7 +78,7 @@ void RequestExample::categorySaveRequest() //catSaveRequest was created with catSaveRequest = new QLandmarkCategorySaveRequest() //in the ctor catSaveRequest->setManager(lmManager); //lmManager is a QLandmarkManager* - catSaveRequest->appendCategory(cafes); + catSaveRequest->setCategory(cafes); connect(catSaveRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), this, SLOT(categorySaveRequestHandler(QLandmarkAbstractRequest::State))); @@ -94,7 +95,6 @@ void RequestExample::categorySaveRequestHandler(QLandmarkAbstractRequest::State if (state == QLandmarkAbstractRequest::FinishedState) { if (catSaveRequest->error() == QLandmarkManager::NoError) { qDebug() << "Category save succesfully completed"; - catSaveRequest->clearCategories(); } else { qDebug() << "Category save was unsuccessful"; @@ -120,7 +120,7 @@ void RequestExample::landmarkSaveRequest() //lmSaveRequest was created with lmSaveRequest = new QLandmarkSaveRequest() //in the ctor lmSaveRequest->setManager(lmManager); //lmManager is a QLandmarkManager* - lmSaveRequest->appendLandmark(monks); + lmSaveRequest->setLandmark(monks); monks.setDescription("Jerry's favourite diner"); @@ -139,7 +139,6 @@ void RequestExample::landmarkSaveRequestHandler(QLandmarkAbstractRequest::State if (state == QLandmarkAbstractRequest::FinishedState) { if (lmSaveRequest->error() == QLandmarkManager::NoError) { qDebug() << "Landmark save succesfully completed"; - lmSaveRequest->clearLandmarks(); } else { qDebug() << "Landmark save was unsuccessful"; @@ -346,6 +345,15 @@ void listAllCategories(QLandmarkManager *lm) } } +void deleteLandmarkAndCategory(QLandmarkManager *lm) +{ + //landmarkCategory is a previously retrieved QLandmarkCategory + lm->removeCategory(landmarkCategory.id()); + + //landmark is a previously retrieved QLandmark object + lm->removeLandmark(landmark.id()); +} + int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); -- cgit v1.2.3 From d0dc58c0e5fc8a714266453976e643fd5750ee65 Mon Sep 17 00:00:00 2001 From: abcd Date: Thu, 15 Apr 2010 19:01:35 +1000 Subject: Add in landmark removal examples --- .../qtlandmarksdocsample/qtlandmarksdocsample.cpp | 85 ++++++++++++++++++++-- 1 file changed, 78 insertions(+), 7 deletions(-) (limited to 'doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp') diff --git a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp index b42869f525..9e0111bc05 100644 --- a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp +++ b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp @@ -65,7 +65,7 @@ QTM_USE_NAMESPACE QLandmarkCategoryId categoryId; QLandmark landmark; -QLandmarkCategory landmarkCategory; +QLandmarkCategory category; //! [Add category asynchronously req] void RequestExample::categorySaveRequest() @@ -156,7 +156,7 @@ void RequestExample::categoryFetchRequest() catFetchRequest->setManager(lmManager); //lmManager is a QLandmarkManager* connect(catFetchRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), - this, SLOT(categoryFetchHandlerRequest(QLandmarkAbstractRequest::State))); + this, SLOT(categoryFetchRequestHandler(QLandmarkAbstractRequest::State))); if(!catFetchRequest->start()) { qDebug() << "Unable to request categories, error code:" << catFetchRequest->error(); @@ -168,7 +168,7 @@ void RequestExample::categoryFetchRequest() } //! [Retrieve categories asynchronously handler] -void RequestExample::categoryFetchHandlerRequest(QLandmarkAbstractRequest::State state) +void RequestExample::categoryFetchRequestHandler(QLandmarkAbstractRequest::State state) { if (state == QLandmarkAbstractRequest::FinishedState) { previousLastIndex = 0; @@ -200,7 +200,7 @@ void RequestExample::landmarkFetchRequest() lmFetchRequest->setSorting(QLandmarkNameSort(Qt::AscendingOrder)); connect(lmFetchRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), - this, SLOT(landmarkFetchHandlerRequest(QLandmarkAbstractRequest::State))); + this, SLOT(landmarkFetchRequestHandler(QLandmarkAbstractRequest::State))); if(!lmFetchRequest->start()) { qDebug() << "Unable to request landmarks, error code:" << lmFetchRequest->error(); @@ -212,7 +212,7 @@ void RequestExample::landmarkFetchRequest() } //! [Retrieve landmarks asynchronously handler] -void RequestExample::landmarkFetchHandlerRequest(QLandmarkAbstractRequest::State state) +void RequestExample::landmarkFetchRequestHandler(QLandmarkAbstractRequest::State state) { if (state == QLandmarkAbstractRequest::FinishedState) { previousLastIndex = 0; @@ -230,6 +230,71 @@ void RequestExample::landmarkFetchHandlerRequest(QLandmarkAbstractRequest::State } //! [Retrieve landmarks asynchronously handler] +//! [Remove category asynchronously] +void RequestExample::categoryRemoveRequest() +{ + //catRemoveRequest was created with catRemoveRequest = new QLandmarkCategoryRemoveRequest() + //in the ctor + catRemoveRequest->setManager(lmManager); //lmManager is a QLandmarkManager* + catRemoveRequest->setCategoryId(category.id()); //category is a previously retrieved QLandmarkCategory + + connect(catRemoveRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), + this, SLOT(categoryRemoveRequestHandler(QLandmarkAbstractRequest::State))); + + if(!catRemoveRequest->start()) { + qDebug() << "Unable to request category removal, error code:" << catRemoveRequest->error(); + QCoreApplication::exit(0); + } else { + qDebug() << "Requested category removal, awaiting results..."; + } +} +//! [Remove category asynchronously] + +//! [Remove category asynchronously handler] +void RequestExample::categoryRemoveRequestHandler(QLandmarkAbstractRequest::State state) +{ + if (state == QLandmarkAbstractRequest::FinishedState) { + if (catRemoveRequest->error() == QLandmarkManager::NoError) { + qDebug() << "Category remove succesfully completed"; + } + else { + qDebug() << "Category remove was unsuccessful"; + } + } +} +//! [Remove category asynchronously handler] + +//! [Remove landmark asynchronously] +void RequestExample::landmarkRemoveRequest() +{ + //lmRemoveRequest was created with lmRemoveRequest = new QLandmarkSaveRequest() + //in the ctor + lmRemoveRequest->setManager(lmManager); //lmManager is a QLandmarkManager* + lmRemoveRequest->setLandmarkId(landmark.id()); //landmark is a previously retrieved QLandmark + + connect(lmRemoveRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), this, + SLOT(landmarkRemoveRequestHandler(QLandmarkAbstractRequest::State))); + if (!lmRemoveRequest->start()) + qDebug() << "Unable to remove landmark, error code: " << lmSaveRequest->error(); + else + qDebug() << "Removing landmark; awaiting results..."; +} +//! [Remove landmark asynchronously] + +//! [Remove landmark asynchronously handler] +void RequestExample::landmarkRemoveRequestHandler(QLandmarkAbstractRequest::State state) +{ + if (state == QLandmarkAbstractRequest::FinishedState) { + if (lmRemoveRequest->error() == QLandmarkManager::NoError) { + qDebug() << "Landmark removal succesfully completed"; + } + else { + qDebug() << "Landmark removal was unsuccessful"; + } + } +} +//! [Remove landmark asynchronously handler] + void addLandmarkAndCategory(QLandmarkManager *lm) { //! [Add category synchronously] @@ -347,11 +412,15 @@ void listAllCategories(QLandmarkManager *lm) void deleteLandmarkAndCategory(QLandmarkManager *lm) { - //landmarkCategory is a previously retrieved QLandmarkCategory - lm->removeCategory(landmarkCategory.id()); + //! [Remove category synchronously] + //category is a previously retrieved QLandmarkCategory object + lm->removeCategory(category.id()); + //! [Remove category synchronously] + //! [Remove landmark synchronously] //landmark is a previously retrieved QLandmark object lm->removeLandmark(landmark.id()); + //! [Remove landmark synchronously] } int main(int argc, char *argv[]) @@ -371,6 +440,8 @@ int main(int argc, char *argv[]) QTimer::singleShot(10, &re, SLOT(landmarkSaveRequest())); QTimer::singleShot(10, &re, SLOT(categoryFetchRequest())); QTimer::singleShot(10, &re, SLOT(landmarkFetchRequest())); + QTimer::singleShot(10, &re, SLOT(categoryRemoveRequest())); + QTimer::singleShot(10, &re, SLOT(landmarkRemoveRequest())); app.exec(); -- cgit v1.2.3 From be5d797d8407f6979bfbf6f992c2ee3afa2ff82b Mon Sep 17 00:00:00 2001 From: abcd Date: Thu, 15 Apr 2010 20:04:28 +1000 Subject: Try fix windows compile of example by changing the includes Can't use system style includes because the include files are not available at make time. The include files are only available after make install. --- .../qtlandmarksdocsample/qtlandmarksdocsample.cpp | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp') diff --git a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp index 9e0111bc05..77d398040b 100644 --- a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp +++ b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp @@ -41,20 +41,20 @@ #include "requestexample.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "qlandmark.h" +#include "qlandmarkmanager.h" +#include "qgeoaddress.h" +#include "qlandmarknamefilter.h" +#include "qlandmarknamesort.h" +#include "qlandmarkproximityfilter.h" +#include "qlandmarkdistancesort.h" +#include "qlandmarkcategoryid.h" +#include "qgeocoordinate.h" +#include "qlandmarkcategory.h" +#include "qlandmarkboxfilter.h" +#include "qlandmarkfetchrequest.h" +#include "qlandmarkcategorysaverequest.h" +#include "qlandmarkcategoryfilter.h" #include #include -- cgit v1.2.3 From 8a74f3371a7204e3202dfa42a669ecf1562f9140 Mon Sep 17 00:00:00 2001 From: David Laing Date: Wed, 21 Apr 2010 14:27:02 +1000 Subject: Added support for an Sqlite backend for landmarks. This also involved fleshing out the filter and sort classes. --- doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp') diff --git a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp index 77d398040b..037da02e2c 100644 --- a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp +++ b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp @@ -352,7 +352,8 @@ void landmarkFetch(QLandmarkManager *lm) //retrieval via ids QList landmarkIds; - landmarkIds = lm->landmarkIds(filter, QLandmarkNameSort(Qt::AscendingOrder)); + QLandmarkNameSort sortOrder(Qt::AscendingOrder); + landmarkIds = lm->landmarkIds(&filter, &sortOrder); foreach(QLandmarkId id, landmarkIds) { qDebug() << "Found landmark:" << lm->landmark(id).name(); } @@ -360,7 +361,7 @@ void landmarkFetch(QLandmarkManager *lm) //! [Retrieve landmarks synchronously] QList landmarks; - landmarks = lm->landmarks(filter, QLandmarkNameSort(Qt::AscendingOrder)); + landmarks = lm->landmarks(&filter, &sortOrder); foreach(QLandmark landmark, landmarks) { qDebug() << "Found landmark:" << landmark.name(); } @@ -370,7 +371,7 @@ void landmarkFetch(QLandmarkManager *lm) void filterByName(QLandmarkManager *lm) { QLandmarkNameFilter filter("Monk's cafe"); - QList matchingIds = lm->landmarkIds(filter); + QList matchingIds = lm->landmarkIds(&filter); if (matchingIds.count() == 0) { qDebug() << "No matches found"; @@ -384,7 +385,8 @@ void filterByProximity(QLandmarkManager *lm) { QGeoCoordinate origin(41,74); QLandmarkProximityFilter filter(origin, 5000); - QList matchingIds = lm->landmarkIds(filter, QLandmarkDistanceSort(origin, Qt::AscendingOrder)); + QLandmarkDistanceSort sort(origin, Qt::AscendingOrder); + QList matchingIds = lm->landmarkIds(&filter, &sort); if(matchingIds.count() == 0) { qDebug() << "No matches found"; -- cgit v1.2.3 From ff5cd8c94aae3f328d1a37a87f84f71c829fb845 Mon Sep 17 00:00:00 2001 From: abcd Date: Thu, 22 Apr 2010 11:52:53 +1000 Subject: Fix compile caused by broken example --- .../qtlandmarksdocsample/qtlandmarksdocsample.cpp | 35 ++++++++++------------ 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp') diff --git a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp index 037da02e2c..a88ad793c0 100644 --- a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp +++ b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp @@ -75,9 +75,8 @@ void RequestExample::categorySaveRequest() cafes.setDescription("Small diners"); cafes.setIconUrl(QUrl("cafe.png")); - //catSaveRequest was created with catSaveRequest = new QLandmarkCategorySaveRequest() - //in the ctor - catSaveRequest->setManager(lmManager); //lmManager is a QLandmarkManager* + //catSaveRequest was created with catSaveRequest = new QLandmarkCategorySaveRequest(lmManager) + //in the ctor, where lmManager is a QLandmarkManager * catSaveRequest->setCategory(cafes); connect(catSaveRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), this, @@ -117,9 +116,8 @@ void RequestExample::landmarkSaveRequest() address.setCountryCode("US"); monks.setAddress(address); - //lmSaveRequest was created with lmSaveRequest = new QLandmarkSaveRequest() - //in the ctor - lmSaveRequest->setManager(lmManager); //lmManager is a QLandmarkManager* + //lmSaveRequest was created with lmSaveRequest = new QLandmarkSaveRequest(lmManager) + //in the ctor, where lmManager is a QLandamrkManager constructor lmSaveRequest->setLandmark(monks); monks.setDescription("Jerry's favourite diner"); @@ -151,9 +149,8 @@ void RequestExample::landmarkSaveRequestHandler(QLandmarkAbstractRequest::State void RequestExample::categoryFetchRequest() { //! [Retrieve categories asynchronously] - //catFetchRequest was created with catFetchRequest = new QLandmarkCategoryFetchRequest() - //in the ctor - catFetchRequest->setManager(lmManager); //lmManager is a QLandmarkManager* + //catFetchRequest was created with catFetchRequest = new QLandmarkCategoryFetchRequest(lmManager) + //in the ctor, where lmManager is a QLandmarkManager* connect(catFetchRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), this, SLOT(categoryFetchRequestHandler(QLandmarkAbstractRequest::State))); @@ -190,14 +187,14 @@ void RequestExample::landmarkFetchRequest() { //! [Retrieve landmarks asynchronously] QLandmarkCategoryFilter filter; + QLandmarkNameSort sort(Qt::AscendingOrder); //categoryId is a previously retrieved QLandmarkCategoryId filter.setCategoryId(categoryId); - //lmFetchRequest was created with lmFetchRequest = new QLandmarkFetchRequest() - //in the ctor - lmFetchRequest->setManager(lmManager); //lmManager is a QLandmarkManager* - lmFetchRequest->setFilter(filter); - lmFetchRequest->setSorting(QLandmarkNameSort(Qt::AscendingOrder)); + //lmFetchRequest was created with lmFetchRequest = new QLandmarkFetchRequest(lmManager) + //in the ctor, where lmManager is a QLandmarkManger * + lmFetchRequest->setFilter(&filter); + lmFetchRequest->setSorting(&sort); connect(lmFetchRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), this, SLOT(landmarkFetchRequestHandler(QLandmarkAbstractRequest::State))); @@ -233,9 +230,8 @@ void RequestExample::landmarkFetchRequestHandler(QLandmarkAbstractRequest::State //! [Remove category asynchronously] void RequestExample::categoryRemoveRequest() { - //catRemoveRequest was created with catRemoveRequest = new QLandmarkCategoryRemoveRequest() - //in the ctor - catRemoveRequest->setManager(lmManager); //lmManager is a QLandmarkManager* + //catRemoveRequest was created with catRemoveRequest = new QLandmarkCategoryRemoveRequest(lmManager) + //in the ctor, where lmManager is a QLandmarkManager* catRemoveRequest->setCategoryId(category.id()); //category is a previously retrieved QLandmarkCategory connect(catRemoveRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), @@ -267,9 +263,8 @@ void RequestExample::categoryRemoveRequestHandler(QLandmarkAbstractRequest::Stat //! [Remove landmark asynchronously] void RequestExample::landmarkRemoveRequest() { - //lmRemoveRequest was created with lmRemoveRequest = new QLandmarkSaveRequest() - //in the ctor - lmRemoveRequest->setManager(lmManager); //lmManager is a QLandmarkManager* + //lmRemoveRequest was created with lmRemoveRequest = new QLandmarkSaveRequest(lmManager) + //in the ctor, where lmManager is a QLandmarkManager* lmRemoveRequest->setLandmarkId(landmark.id()); //landmark is a previously retrieved QLandmark connect(lmRemoveRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), this, -- cgit v1.2.3 From f0e86d3e1d4df8b35fe65abffdb9b2ccd517c9ef Mon Sep 17 00:00:00 2001 From: abcd Date: Wed, 5 May 2010 11:36:22 +1000 Subject: Refactor filters and sort orders to have value semantics Filters are now passed by reference and not by pointer. Modifying filters to have value type behaviour while also being polymorphic is quite suspect, but seems to be the least worst option. --- doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp') diff --git a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp index a88ad793c0..b1831dcd64 100644 --- a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp +++ b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp @@ -193,7 +193,7 @@ void RequestExample::landmarkFetchRequest() //lmFetchRequest was created with lmFetchRequest = new QLandmarkFetchRequest(lmManager) //in the ctor, where lmManager is a QLandmarkManger * - lmFetchRequest->setFilter(&filter); + lmFetchRequest->setFilter(filter); lmFetchRequest->setSorting(&sort); connect(lmFetchRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), @@ -348,7 +348,7 @@ void landmarkFetch(QLandmarkManager *lm) //retrieval via ids QList landmarkIds; QLandmarkNameSort sortOrder(Qt::AscendingOrder); - landmarkIds = lm->landmarkIds(&filter, &sortOrder); + landmarkIds = lm->landmarkIds(filter, &sortOrder); foreach(QLandmarkId id, landmarkIds) { qDebug() << "Found landmark:" << lm->landmark(id).name(); } @@ -356,7 +356,7 @@ void landmarkFetch(QLandmarkManager *lm) //! [Retrieve landmarks synchronously] QList landmarks; - landmarks = lm->landmarks(&filter, &sortOrder); + landmarks = lm->landmarks(filter, &sortOrder); foreach(QLandmark landmark, landmarks) { qDebug() << "Found landmark:" << landmark.name(); } @@ -366,7 +366,7 @@ void landmarkFetch(QLandmarkManager *lm) void filterByName(QLandmarkManager *lm) { QLandmarkNameFilter filter("Monk's cafe"); - QList matchingIds = lm->landmarkIds(&filter); + QList matchingIds = lm->landmarkIds(filter); if (matchingIds.count() == 0) { qDebug() << "No matches found"; @@ -381,7 +381,7 @@ void filterByProximity(QLandmarkManager *lm) QGeoCoordinate origin(41,74); QLandmarkProximityFilter filter(origin, 5000); QLandmarkDistanceSort sort(origin, Qt::AscendingOrder); - QList matchingIds = lm->landmarkIds(&filter, &sort); + QList matchingIds = lm->landmarkIds(filter, &sort); if(matchingIds.count() == 0) { qDebug() << "No matches found"; -- cgit v1.2.3 From 89788fca7ff9e1b3ea5db1f4180387d50283c664 Mon Sep 17 00:00:00 2001 From: abcd Date: Wed, 5 May 2010 14:12:45 +1000 Subject: Pass in sort orders by reference. Also fix the constructor of qlandmarkcategory to explicitly initialize members so that the sqlite manager unit tests pass --- doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp') diff --git a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp index b1831dcd64..0674311f0c 100644 --- a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp +++ b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp @@ -194,7 +194,7 @@ void RequestExample::landmarkFetchRequest() //lmFetchRequest was created with lmFetchRequest = new QLandmarkFetchRequest(lmManager) //in the ctor, where lmManager is a QLandmarkManger * lmFetchRequest->setFilter(filter); - lmFetchRequest->setSorting(&sort); + lmFetchRequest->setSorting(sort); connect(lmFetchRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), this, SLOT(landmarkFetchRequestHandler(QLandmarkAbstractRequest::State))); @@ -348,7 +348,7 @@ void landmarkFetch(QLandmarkManager *lm) //retrieval via ids QList landmarkIds; QLandmarkNameSort sortOrder(Qt::AscendingOrder); - landmarkIds = lm->landmarkIds(filter, &sortOrder); + landmarkIds = lm->landmarkIds(filter, sortOrder); foreach(QLandmarkId id, landmarkIds) { qDebug() << "Found landmark:" << lm->landmark(id).name(); } @@ -356,7 +356,7 @@ void landmarkFetch(QLandmarkManager *lm) //! [Retrieve landmarks synchronously] QList landmarks; - landmarks = lm->landmarks(filter, &sortOrder); + landmarks = lm->landmarks(filter, sortOrder); foreach(QLandmark landmark, landmarks) { qDebug() << "Found landmark:" << landmark.name(); } @@ -381,7 +381,7 @@ void filterByProximity(QLandmarkManager *lm) QGeoCoordinate origin(41,74); QLandmarkProximityFilter filter(origin, 5000); QLandmarkDistanceSort sort(origin, Qt::AscendingOrder); - QList matchingIds = lm->landmarkIds(filter, &sort); + QList matchingIds = lm->landmarkIds(filter, sort); if(matchingIds.count() == 0) { qDebug() << "No matches found"; -- cgit v1.2.3 From daecd3a72d73847f1e9200edc70dbdabde3d16c4 Mon Sep 17 00:00:00 2001 From: abcd Date: Wed, 12 May 2010 22:26:04 +1000 Subject: Rename QLandmark categories related functions to have Id(s) in them This is to be a more accurate description of what those functions do. --- doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp') diff --git a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp index 0674311f0c..046698e1d0 100644 --- a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp +++ b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp @@ -315,7 +315,7 @@ void addLandmarkAndCategory(QLandmarkManager *lm) monks.setAddress(address); monks.setDescription("Jerry's favourite diner"); - monks.addCategory(cafes.id()); + monks.addCategoryId(cafes.id()); lm->saveLandmark(&monks); //lm is a QLandmarkManager* //! [Add landmark synchronously] -- cgit v1.2.3 From 7f63f0aca19eda69e48b3d724a2fb3c2ec893eda Mon Sep 17 00:00:00 2001 From: abcd Date: Thu, 13 May 2010 00:02:36 +1000 Subject: rename id functions to landmarkId and categoryId The longer names are more readable. --- doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp') diff --git a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp index 046698e1d0..d6d9a86012 100644 --- a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp +++ b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp @@ -232,7 +232,7 @@ void RequestExample::categoryRemoveRequest() { //catRemoveRequest was created with catRemoveRequest = new QLandmarkCategoryRemoveRequest(lmManager) //in the ctor, where lmManager is a QLandmarkManager* - catRemoveRequest->setCategoryId(category.id()); //category is a previously retrieved QLandmarkCategory + catRemoveRequest->setCategoryId(category.categoryId()); //category is a previously retrieved QLandmarkCategory connect(catRemoveRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), this, SLOT(categoryRemoveRequestHandler(QLandmarkAbstractRequest::State))); @@ -265,7 +265,7 @@ void RequestExample::landmarkRemoveRequest() { //lmRemoveRequest was created with lmRemoveRequest = new QLandmarkSaveRequest(lmManager) //in the ctor, where lmManager is a QLandmarkManager* - lmRemoveRequest->setLandmarkId(landmark.id()); //landmark is a previously retrieved QLandmark + lmRemoveRequest->setLandmarkId(landmark.landmarkId()); //landmark is a previously retrieved QLandmark connect(lmRemoveRequest, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)), this, SLOT(landmarkRemoveRequestHandler(QLandmarkAbstractRequest::State))); @@ -315,7 +315,7 @@ void addLandmarkAndCategory(QLandmarkManager *lm) monks.setAddress(address); monks.setDescription("Jerry's favourite diner"); - monks.addCategoryId(cafes.id()); + monks.addCategoryId(cafes.categoryId()); lm->saveLandmark(&monks); //lm is a QLandmarkManager* //! [Add landmark synchronously] @@ -411,12 +411,12 @@ void deleteLandmarkAndCategory(QLandmarkManager *lm) { //! [Remove category synchronously] //category is a previously retrieved QLandmarkCategory object - lm->removeCategory(category.id()); + lm->removeCategory(category.categoryId()); //! [Remove category synchronously] //! [Remove landmark synchronously] //landmark is a previously retrieved QLandmark object - lm->removeLandmark(landmark.id()); + lm->removeLandmark(landmark.landmarkId()); //! [Remove landmark synchronously] } -- cgit v1.2.3 From e17d69a753fd5336f51d080a77b0bb3990974513 Mon Sep 17 00:00:00 2001 From: abcd Date: Fri, 2 Jul 2010 15:48:59 +1000 Subject: Improve QLandmarkManager documentation --- .../qtlandmarksdocsample/qtlandmarksdocsample.cpp | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp') diff --git a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp index d6d9a86012..7cb25fb43b 100644 --- a/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp +++ b/doc/src/snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp @@ -319,6 +319,16 @@ void addLandmarkAndCategory(QLandmarkManager *lm) lm->saveLandmark(&monks); //lm is a QLandmarkManager* //! [Add landmark synchronously] + + { + QLandmarkManager *landmarkManager; + //! [Add landmark synchronously simple] + QLandmark monks; + monks.setName("Monk's cafe"); + //.. + landmarkManager->saveLandmark(&monks); + //! [Add landmark synchronously simple] + } } void categoryFetch(QLandmarkManager *lm) @@ -336,6 +346,13 @@ void categoryFetch(QLandmarkManager *lm) qDebug() << "Found category: " << category.name(); } //! [Retrieve categories synchronously] + + { + QLandmarkManager *landmarkManager; + //! [Retrieve categories synchronously simple] + QList categories = landmarkManager->categories(); + //! [Retrieve categories synchronously simple] + } } void landmarkFetch(QLandmarkManager *lm) @@ -361,6 +378,30 @@ void landmarkFetch(QLandmarkManager *lm) qDebug() << "Found landmark:" << landmark.name(); } //! [Retrieve landmarks synchronously] + + { + QLandmarkManager *landmarkManager; + //! [Retrieve landmarks by proximity synchronously] + QGeoCoordinate coordinate(54.0, 23.1); + + QLandmarkProximityFilter filter; + filter.setCoordinate(coordinate); + filter.setRadius(5000); + + QLandmarkDistanceSort distanceSort; + distanceSort.setCoordinate(coordinate); + distanceSort.setDirection(Qt::AscendingOrder); + + QLandmarkFetchHint fetchHint; + fetchHint.setMaxItems(5); + + landmarkManager->landmarks(filter, sortOrder, fetchHint); + //! [Retrieve landmarks by proximity synchronously] + + //! [Retrieve all landmarks synchronously] + landmarkManager->landmarks(); + //! [Retrieve all landmarks synchronously] + } } void filterByName(QLandmarkManager *lm) @@ -418,12 +459,34 @@ void deleteLandmarkAndCategory(QLandmarkManager *lm) //landmark is a previously retrieved QLandmark object lm->removeLandmark(landmark.landmarkId()); //! [Remove landmark synchronously] + + { + QLandmarkManager *landmarkManager; + //! [Remove landmark synchronously simple] + landmarkManager->removeLandmark(landmark.landmarkId()); + //! [Remove landmark synchronously simple] + } +} + +void importExportLandmark() { + QLandmarkManager *landmarkManager; + //! [ImportExport landmark simple] + landmarkManager->importLandmarks("places.gpx"); + + landmarkManager->exportLandmarks("myplaces.gpx"); + //! [ImportExport landmark simple] } int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QLandmarkManager *lm = new QLandmarkManager(); + + //! [Instantiate default QLandmarkManager] + QLandmarkManager *landmarkManager = new QLandmarkManager(); + //! [Instantiate default QLandmarkManager] + Q_UNUSED(landmarkManager); + //Synchronous API examples addLandmarkAndCategory(lm); categoryFetch(lm); -- cgit v1.2.3