cell/gps only on maemo5
[googlelatitude] / src / latitude.cpp
index 2661345..47e08e1 100644 (file)
@@ -14,6 +14,7 @@ LatitudeGUI::LatitudeGUI(QMainWindow *parent) : QMainWindow(parent) {
     connect(gps, SIGNAL(getOK_agnss()), this, SLOT(get_agnss()));
     connect(glatitude, SIGNAL(setOK()), this, SLOT(set_OK()));
     connect(glatitude, SIGNAL(setERROR()), this, SLOT(set_ERROR()));
+    connect(this, SIGNAL(newpos()), this, SLOT(set()));
 
 }
 
@@ -21,14 +22,16 @@ void LatitudeGUI::get_loc() {
     location_lat->setText(QString::number(glatitude->get_lat()));
     location_lon->setText(QString::number(glatitude->get_lon()));
     location_acc->setText(QString::number(glatitude->get_acc()));
-    status->setText(tr("Using google.com/loc, ip-based"));
+    status->setText(tr("Using google.com/loc, ip-based" ));
+    emit newpos();
 }
 
 void LatitudeGUI::get_maemo5() {
     location_lat->setText(QString::number(gps->get_lat()));
     location_lon->setText(QString::number(gps->get_lon()));
     location_acc->setText(QString::number(gps->get_acc()));
-    status->setText(tr("Using liblocation"));
+    status->setText(tr("Using liblocation "));
+    emit newpos();
 }
 
 void LatitudeGUI::get_acwp() {
@@ -36,6 +39,7 @@ void LatitudeGUI::get_acwp() {
     location_lon->setText(QString::number(gps->get_lon()));
     location_acc->setText(QString::number(gps->get_acc()));
     status->setText(tr("Using acwp, cell-based "));
+    emit newpos();
 }
 
 void LatitudeGUI::get_agnss() {
@@ -43,6 +47,7 @@ void LatitudeGUI::get_agnss() {
     location_lon->setText(QString::number(gps->get_lon()));
     location_acc->setText(QString::number(gps->get_acc()));
     status->setText(tr("Using agnss, gps-based "));
+    emit newpos();
 }
 
 void LatitudeGUI::set() {
@@ -51,7 +56,6 @@ void LatitudeGUI::set() {
     glatitude->set(location_lat->text().toDouble(),
                    location_lon->text().toDouble(),
                    location_acc->text().toDouble());
-    status->setText(tr("Setting location..."));
 }
 
 void LatitudeGUI::set_OK() {
@@ -68,6 +72,15 @@ void LatitudeGUI::save() {
 }
 
 void LatitudeGUI::show_map() {
+    // no scrash and stop gps
+    location_lat = new QLineEdit(QString::number(0));
+    location_lon = new QLineEdit(QString::number(0));
+    location_acc = new QLineEdit(QString::number(0));
+    status = new QLineEdit("Ready");
+    login_user = new QLineEdit(setting->value("user","my_username").toString());
+    login_pass = new QLineEdit(setting->value("pass","my_password").toString());
+    gps->stop();
+
     // webkit magic
     maps = new QWebView();
     connect(maps, SIGNAL(loadFinished(bool)), this, SLOT(maps_login()));
@@ -87,7 +100,7 @@ void LatitudeGUI::show_lat() {
     login_user = new QLineEdit(setting->value("user","my_username").toString());
     login_pass = new QLineEdit(setting->value("pass","my_password").toString());
     login_pass->setEchoMode(QLineEdit::Password);
-    QPushButton *button_update = new QPushButton(tr("&Update Location"));
+    QPushButton *button_update = new QPushButton(tr("Manual &Update"));
     // login layout
     QFormLayout *layout_login = new QFormLayout();
     layout_login->addRow(tr("&Username"), login_user);
@@ -111,9 +124,9 @@ void LatitudeGUI::show_lat() {
     layout_location->addRow(tr("acc :"), location_acc);
 
     // source button
-    QPushButton *source_loc = new QPushButton(tr("&loc"));
-    QPushButton *source_cell = new QPushButton(tr("&cell"));
-    QPushButton *source_gps = new QPushButton(tr("&gps"));
+    QPushButton *source_loc = new QPushButton(tr("Update with &IP"));
+    QPushButton *source_cell = new QPushButton(tr("Update with &Cell"));
+    QPushButton *source_gps = new QPushButton(tr("Update with &Gps"));
     // source layout
     QHBoxLayout *layout_source = new QHBoxLayout();
     layout_source->addWidget(source_loc);
@@ -138,6 +151,12 @@ void LatitudeGUI::show_lat() {
     layout->addLayout(layout_source);
     location->setLayout(layout);
 
+    // gps enable only on maemo5
+#ifndef Q_WS_MAEMO_5
+    source_cell->setDisabled(1);
+    source_gps->setDisabled(1);
+#endif
+
     // set widget
     setCentralWidget(location);
     setWindowTitle(tr("Google Latitude Updater"));