X-Git-Url: http://git.maemo.org/git/?p=googlelatitude;a=blobdiff_plain;f=src%2Flatitude.cpp;h=37a6176f0980a5ed8bbaebfaa87db1517f1ac0d5;hp=c782c2f40fd8de2cd89a2b44ed14b7b6e941ed63;hb=7ee5f4d99ce070730090ad079c59ec2d5ab00906;hpb=016de1e3a5f9819bf2662e9a9e89868472149a56;ds=sidebyside diff --git a/src/latitude.cpp b/src/latitude.cpp index c782c2f..37a6176 100644 --- a/src/latitude.cpp +++ b/src/latitude.cpp @@ -2,29 +2,53 @@ LatitudeGUI::LatitudeGUI(QMainWindow *parent) : QMainWindow(parent) { glatitude = new GoogleLatitude(this); + gps = new GpsMaemo5(this); setting = new QSettings(); urllogin = QUrl::fromEncoded("https://www.google.com/accounts/ServiceLogin?service=friendview&continue=http://www.google.com/maps/m?mode=latitude"); + // buzz http://www.google.com/maps/m?l-view=map&l-lci=m,com.google.latitudepublicupdates&ac=f,s,l show_lat(); connect(glatitude, SIGNAL(getOK()), this, SLOT(get_loc())); + connect(gps, SIGNAL(getOK()), this, SLOT(get_maemo5())); + connect(gps, SIGNAL(getOK_acwp()), this, SLOT(get_acwp())); + 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())); + } 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())); - statusBar()->showMessage(tr("Using google.com/loc"),2000); + 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 ")); + emit newpos(); } -void LatitudeGUI::get_cell() { - statusBar()->showMessage(tr("Using cell... TODO"),2000); +void LatitudeGUI::get_acwp() { + 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 acwp, cell-based ")); + emit newpos(); } -void LatitudeGUI::get_gps() { - statusBar()->showMessage(tr("Using gps... TODO"),2000); +void LatitudeGUI::get_agnss() { + 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 agnss, gps-based ")); + emit newpos(); } void LatitudeGUI::set() { @@ -33,15 +57,14 @@ void LatitudeGUI::set() { glatitude->set(location_lat->text().toDouble(), location_lon->text().toDouble(), location_acc->text().toDouble()); - statusBar()->showMessage(tr("Setting location..."),2000); } void LatitudeGUI::set_OK() { - statusBar()->showMessage(tr("Location Updated !"),5000); + status->setText(tr("Updated Location !")); } void LatitudeGUI::set_ERROR() { - statusBar()->showMessage(tr("Error in Authentification !"),5000); + status->setText(tr("Error in Authentification !")); } void LatitudeGUI::save() { @@ -50,6 +73,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())); @@ -62,7 +94,6 @@ void LatitudeGUI::show_map() { // menu menuBar()->clear(); menuBar()->addAction(tr("&Latitude") ,this, SLOT(show_lat())); - setStatusBar(0); } void LatitudeGUI::show_lat() { @@ -70,7 +101,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); @@ -94,9 +125,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); @@ -104,8 +135,8 @@ void LatitudeGUI::show_lat() { layout_source->addWidget(source_gps); // source connect connect(source_loc, SIGNAL(clicked()), glatitude, SLOT(get())); - connect(source_cell, SIGNAL(clicked()), this, SLOT(get_cell())); - connect(source_gps, SIGNAL(clicked()), this, SLOT(get_gps())); + connect(source_cell, SIGNAL(clicked()), gps, SLOT(get_acwp())); + connect(source_gps, SIGNAL(clicked()), gps, SLOT(get_agnss())); // main layout location = new QWidget(); @@ -113,7 +144,11 @@ void LatitudeGUI::show_lat() { layout_form->addLayout(layout_login); layout_form->addLayout(layout_location); QVBoxLayout *layout = new QVBoxLayout(); + status = new QLineEdit("Ready"); + status->setReadOnly(true); + status->setDisabled(true); layout->addLayout(layout_form); + layout->addWidget(status); layout->addLayout(layout_source); location->setLayout(layout); @@ -124,7 +159,6 @@ void LatitudeGUI::show_lat() { // menu menuBar()->clear(); menuBar()->addAction(tr("&Maps") ,this, SLOT(show_map())); - statusBar()->showMessage(tr("Ready")); } void LatitudeGUI::maps_login() {