Skip to content

Commit

Permalink
backup
Browse files Browse the repository at this point in the history
Signed-off-by: André L. V. Loureiro <loureiro.andrew@gmail.com>
  • Loading branch information
alvloureiro authored and André Loureiro committed Mar 5, 2012
1 parent e5ee3a5 commit 2a50748
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
6 changes: 6 additions & 0 deletions PopupDialog.qml
Expand Up @@ -6,12 +6,18 @@ Item {
height: 100
width: 200

property real latitude: 0.0
property real longitude: 0.0
property alias inputText: inputName.text

signal popupOk(string text)

Rectangle {
id: background
anchors.fill: parent
color: "white"
border.width: 2
border.color: "black"
}

Text {
Expand Down
14 changes: 12 additions & 2 deletions landmarkmanager.cpp
Expand Up @@ -2,6 +2,7 @@

#include <qlandmarkmanager.h>
#include <qlandmark.h>
#include <qgeocoordinate.h>
#include <QObject>
#include <QString>
#include <QStringList>
Expand Down Expand Up @@ -29,11 +30,20 @@ void LandmarkManager::init()
}
}

void LandmarkManager::saveLandmark(QLandmark *landmark)
void LandmarkManager::saveLandmark(double latitude, double longitude, QString name)
{
if (!m_manager)
return;
Q_UNUSED(landmark);

QGeoCoordinate coordinate;
coordinate.setLatitude(latitude);
coordinate.setLongitude(longitude);
QLandmark *landmark = new QLandmark;
landmark->setName(name);
landmark->setCoordinate(coordinate);

bool result = m_manager->saveLandmark(landmark);
qDebug() << __func__ << "#### result of save landmark: " << result;
}

void LandmarkManager::landmarks()
Expand Down
2 changes: 1 addition & 1 deletion landmarkmanager.h
Expand Up @@ -16,7 +16,7 @@ class LandmarkManager : public QObject

public slots:
void init();
void saveLandmark(QLandmark *landmark);
void saveLandmark(double latitude, double longitude, QString name);
void landmarks();
bool cleanLandmarks();

Expand Down
8 changes: 8 additions & 0 deletions main.qml
Expand Up @@ -22,12 +22,20 @@ Item {
onAddLandmark: {
popupDialog.x = mouseObject.x
popupDialog.y = mouseObject.y
popupDialog.latitude = mouseObject.coordinate.latitude
popupDialog.longitude = mouseObject.coordinate.longitude
popupDialog.visible = !popupDialog.visible
}
}

PopupDialog {
id: popupDialog
visible: false

onPopupOk: {
controller.saveLandmark(popupDialog.latitude, popupDialog.longitude, text)
popupDialog.visible = !popupDialog.visible
popupDialog.inputText = ""
}
}
}

0 comments on commit 2a50748

Please sign in to comment.