locs << loc->label();
}
}
-
this->ui->locations->addItems(locs);
+
+ if (!locations->getGpsLocation()->isUpdating())
+ this->ui->gps_button->setEnabled(false);
+ else if (!locations->getGpsLocation()->isValid())
+ {
+ this->ui->gps_button->setEnabled(false);
+ this->m_text = this->ui->gps_button->text();
+ this->ui->gps_button->setText(this->m_text + " (Searching...)");
+ this->connect(locations->getGpsLocation(), SIGNAL(gpsLocationChanged(GpsLocation*)), SLOT(gps_location_retrieved()));
+ }
+
+ //this->connect(locations->getGpsLocation(), SIGNAL(gpsLocationUpdatingChanged(bool)), SLOT(gps_updating_changed(bool)));
+
}
FavoriteSelectionDialog::~FavoriteSelectionDialog()
delete ui;
}
+void FavoriteSelectionDialog::gps_updating_changed(bool isActive)
+{
+ //this->ui->gps_button->setEnabled(isActive);
+}
+
+void FavoriteSelectionDialog::gps_location_retrieved()
+{
+ this->ui->gps_button->setEnabled(true);
+ this->ui->gps_button->setText(this->m_text);
+ this->disconnect(this, SLOT(gps_location_retrieved()));
+}
+
void FavoriteSelectionDialog::on_locations_itemClicked(QListWidgetItem* item)
{
Locations *locations = Locations::GetInstance();
emit(this->customizeRequested());
this->deleteLater();
}
+
+void FavoriteSelectionDialog::on_gps_button_clicked()
+{
+ Locations *locations = Locations::GetInstance();
+ emit(this->selectedLocation(locations->getGpsLocation()));
+ this->deleteLater();
+}
private:
Ui::FavoriteSelectionDialog *ui;
+ QString m_text;
private slots:
+ void on_gps_button_clicked();
void on_modify_button_clicked();
void on_locations_itemClicked(QListWidgetItem* item);
+ void gps_updating_changed(bool isActive);
+ void gps_location_retrieved();
};
#endif // FAVORITESELECTIONDIALOG_H
</widget>
</item>
<item>
- <widget class="QListWidget" name="locations"/>
+ <widget class="QPushButton" name="gps_button">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Current location</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListWidget" name="locations">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>600</height>
+ </size>
+ </property>
+ </widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
- <x>248</x>
- <y>254</y>
+ <x>252</x>
+ <y>295</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
- <x>316</x>
- <y>260</y>
+ <x>320</x>
+ <y>295</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
//this->ui->from_favorites->setIcon(QIcon::fromTheme("edit-copy"));
//this->ui->dest_favorites->setText("Fav");
+ QMenuBar *menu = this->ui->menubar;
+ QAction *use_gps = new QAction("Use GPS", this);
+ use_gps->setCheckable(true);
+ use_gps->setChecked(false);
+ this->connect(use_gps, SIGNAL(toggled(bool)), SLOT(gps_status_change_requested(bool)));
+ this->connect(use_gps, SIGNAL(toggled(bool)), locations->getGpsLocation(), SLOT(enableGps(bool)));
+ menu->addAction(use_gps);
+
this->from_selected = NULL;
this->dest_selected = NULL;
this->edit_window = NULL;
qDebug() << "Finish constructor";
}
+void SearchDisplay::gps_status_change_requested(bool status)
+{
+
+
+}
+
SearchDisplay::~SearchDisplay()
{
delete ui;
void route_finder_finished();
+ void gps_status_change_requested(bool status);
+
private:
void setEditText(QLineEdit*, QString&);
void updateLocationLists();
GpsLocation::GpsLocation(QObject *parent) :
QObject(parent), Location("0", "0", "GPS", "GPS"),
m_gps(QGeoPositionInfoSource::createDefaultSource(this)), m_active(false),
- m_calculated(false),
latitude(0), longitude(0)
{
m_valid = false;
else
this->m_gps->stopUpdates();
+ this->m_active = enable;
emit(this->gpsLocationUpdatingChanged(enable));
}
this->latitude = positionInfo.coordinate().latitude();
this->longitude = positionInfo.coordinate().longitude();
- this->m_calculated = false;
+ this->calculateXY();
+
this->m_valid = true;
emit(this->gpsLocationChanged(this));
this->m_x.setNum(outX);
this->m_y.setNum(outY);
-
- this->m_calculated = true;
}
-QString GpsLocation::x()
+bool GpsLocation::isUpdating() const
{
- if (!this->m_calculated)
- {
- this->calculateXY();
- }
- return this->m_x;
-}
-
-QString GpsLocation::y()
-{
- if (!this->m_calculated)
- {
- this->calculateXY();
- }
- return this->m_y;
+ return this->m_active;
}
const double KkjZoneInfo[6][2] = {
explicit GpsLocation(QObject *parent = 0);
~GpsLocation();
- QString x();
- QString y();
+ bool isUpdating() const;
signals:
void gpsLocationChanged(GpsLocation *newLocation);
void calculateXY();
QGeoPositionInfoSource *m_gps;
- bool m_active, m_calculated;
+ bool m_active;
qreal latitude, longitude;
};