From 01b1c10adb3ec8ef2e3e00c1bca777b0b5305f3b Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Mon, 28 Apr 2014 22:01:03 +0200 Subject: [PATCH 1/2] MainWindow: set minimum size to 640x400 Signed-off-by: Koen Kooi --- src/ui/MainWindow.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/MainWindow.ui b/src/ui/MainWindow.ui index 523cbfd..cee01d4 100644 --- a/src/ui/MainWindow.ui +++ b/src/ui/MainWindow.ui @@ -12,8 +12,8 @@ - 1024 - 600 + 640 + 400 From 5e95b6d266b32321b815cfb035283038ded6c35d Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 17 May 2014 13:22:26 +0200 Subject: [PATCH 2/2] Protect against empty lists, fix map interaction --- src/ui/WaypointEditableView.cc | 3 +-- src/ui/WaypointList.cc | 43 +++++++++++++++++++++++++----------------- src/ui/WaypointViewOnlyView.cc | 6 +++++- src/ui/map/QGCMapWidget.cc | 26 +++++++++++++------------ 4 files changed, 46 insertions(+), 32 deletions(-) diff --git a/src/ui/WaypointEditableView.cc b/src/ui/WaypointEditableView.cc index 8bb0c6c..11b2f78 100644 --- a/src/ui/WaypointEditableView.cc +++ b/src/ui/WaypointEditableView.cc @@ -39,11 +39,10 @@ WaypointEditableView::WaypointEditableView(Waypoint* wp, QWidget* parent) : QWidget(parent), viewMode(QGC_WAYPOINTEDITABLEVIEW_MODE_DEFAULT), + wp(wp), m_ui(new Ui::WaypointEditableView) { m_ui->setupUi(this); - - this->wp = wp; connect(wp, SIGNAL(destroyed(QObject*)), this, SLOT(deleted(QObject*))); // CUSTOM COMMAND WIDGET diff --git a/src/ui/WaypointList.cc b/src/ui/WaypointList.cc index b664e73..e745691 100644 --- a/src/ui/WaypointList.cc +++ b/src/ui/WaypointList.cc @@ -382,13 +382,13 @@ void WaypointList::changeCurrentWaypoint(quint16 seq) void WaypointList::currentWaypointEditableChanged(quint16 seq) { WPM->setCurrentEditable(seq); - const QList &waypoints = WPM->getWaypointEditableList(); + const QList waypoints = WPM->getWaypointEditableList(); if (seq < waypoints.count()) { for(int i = 0; i < waypoints.count(); i++) { - WaypointEditableView* widget = wpEditableViews.find(waypoints[i]).value(); + WaypointEditableView* widget = wpEditableViews.value(waypoints[i], NULL); if (widget) { if (waypoints[i]->getId() == seq) @@ -410,13 +410,13 @@ void WaypointList::currentWaypointViewOnlyChanged(quint16 seq) // First update the edit list currentWaypointEditableChanged(seq); - const QList &waypoints = WPM->getWaypointViewOnlyList(); + const QList waypoints = WPM->getWaypointViewOnlyList(); if (seq < waypoints.count()) { for(int i = 0; i < waypoints.count(); i++) { - WaypointViewOnlyView* widget = wpViewOnlyViews.find(waypoints[i]).value(); + WaypointViewOnlyView* widget = wpViewOnlyViews.value(waypoints[i], NULL); if (waypoints[i]->getId() == seq) { @@ -465,10 +465,12 @@ void WaypointList::waypointViewOnlyListChanged() } } if (i == waypoints.count()) { - WaypointViewOnlyView* widget = wpViewOnlyViews.find(cur).value(); - widget->hide(); - viewOnlyListLayout->removeWidget(widget); - wpViewOnlyViews.remove(cur); + WaypointViewOnlyView* widget = wpViewOnlyViews.value(cur, NULL); + if (widget) { + widget->hide(); + viewOnlyListLayout->removeWidget(widget); + wpViewOnlyViews.remove(cur); + } } } } @@ -519,10 +521,13 @@ void WaypointList::waypointEditableListChanged() } } if (i == waypoints.count()) { - WaypointEditableView* widget = wpEditableViews.find(cur).value(); - widget->hide(); - editableListLayout->removeWidget(widget); - wpEditableViews.remove(cur); + WaypointEditableView* widget = wpEditableViews.value(cur, NULL); + + if (widget) { + widget->hide(); + editableListLayout->removeWidget(widget); + wpEditableViews.remove(cur); + } } } } @@ -613,8 +618,10 @@ void WaypointList::on_clearWPListButton_clicked() emit clearPathclicked(); const QList &waypoints = WPM->getWaypointEditableList(); while(!waypoints.isEmpty()) { - WaypointEditableView* widget = wpEditableViews.find(waypoints[0]).value(); - widget->remove(); + WaypointEditableView* widget = wpEditableViews.value(waypoints[0], NULL); + if (widget) { + widget->remove(); + } } } } @@ -622,14 +629,16 @@ void WaypointList::on_clearWPListButton_clicked() void WaypointList::clearWPWidget() { // Get list - const QList &waypoints = WPM->getWaypointEditableList(); + const QList waypoints = WPM->getWaypointEditableList(); // XXX delete wps as well // Clear UI elements while(!waypoints.isEmpty()) { - WaypointEditableView* widget = wpEditableViews.find(waypoints[0]).value(); - widget->remove(); + WaypointEditableView* widget = wpEditableViews.value(waypoints[0], NULL); + if (widget) { + widget->remove(); + } } } diff --git a/src/ui/WaypointViewOnlyView.cc b/src/ui/WaypointViewOnlyView.cc index 8688b3f..32f3b07 100644 --- a/src/ui/WaypointViewOnlyView.cc +++ b/src/ui/WaypointViewOnlyView.cc @@ -6,10 +6,10 @@ WaypointViewOnlyView::WaypointViewOnlyView(Waypoint* wp, QWidget *parent) : QWidget(parent), + wp(wp), m_ui(new Ui::WaypointViewOnlyView) { m_ui->setupUi(this); - this->wp = wp; updateValues(); connect(m_ui->current, SIGNAL(stateChanged(int)), this, SLOT(changedCurrent(int))); @@ -60,6 +60,10 @@ void WaypointViewOnlyView::changedCurrent(int state) void WaypointViewOnlyView::setCurrent(bool state) //This is a slot receiving signals from UASWaypointManager. The state given here is the true representation of what the "current" waypoint on UAV is. { + if (!wp) { + return; + } + m_ui->current->blockSignals(true); if (state == true) { diff --git a/src/ui/map/QGCMapWidget.cc b/src/ui/map/QGCMapWidget.cc index 4cb9098..5f5ba36 100644 --- a/src/ui/map/QGCMapWidget.cc +++ b/src/ui/map/QGCMapWidget.cc @@ -169,6 +169,12 @@ void QGCMapWidget::mouseReleaseEvent(QMouseEvent *event) { mousePressPos = event->pos(); mapcontrol::OPMapWidget::mouseReleaseEvent(event); + + // If the mouse is released, we can't be dragging + if (firingWaypointChange) { + firingWaypointChange = NULL; + } + qDebug() << "MOUSE RELEASED"; } QGCMapWidget::~QGCMapWidget() @@ -620,10 +626,11 @@ void QGCMapWidget::handleMapWaypointEdit(mapcontrol::WayPointItem* waypoint) WPDelete(waypoint); // Protect from vicious double update cycle - if (firingWaypointChange == wp) return; + if (firingWaypointChange == wp) { + return; + } // Not in cycle, block now from entering it firingWaypointChange = wp; - // // qDebug() << "UPDATING WP FROM MAP"; // Update WP values internals::PointLatLng pos = waypoint->Coord(); @@ -632,19 +639,14 @@ void QGCMapWidget::handleMapWaypointEdit(mapcontrol::WayPointItem* waypoint) wp->blockSignals(true); wp->setLatitude(pos.Lat()); wp->setLongitude(pos.Lng()); - // XXX Magic values -// wp->setAltitude(homeAltitude + 50.0f); -// wp->setAcceptanceRadius(10.0f); wp->blockSignals(false); - internals::PointLatLng coord = waypoint->Coord(); - QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6); - // // qDebug() << "MAP WP COORD (MAP):" << coord_str << __FILE__ << __LINE__; - QString wp_str = QString::number(wp->getLatitude(), 'f', 6) + " " + QString::number(wp->getLongitude(), 'f', 6); - // // qDebug() << "MAP WP COORD (WP):" << wp_str << __FILE__ << __LINE__; - - firingWaypointChange = NULL; +// internals::PointLatLng coord = waypoint->Coord(); +// QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6); +// qDebug() << "MAP WP COORD (MAP):" << coord_str << __FILE__ << __LINE__; +// QString wp_str = QString::number(wp->getLatitude(), 'f', 6) + " " + QString::number(wp->getLongitude(), 'f', 6); +// qDebug() << "MAP WP COORD (WP):" << wp_str << __FILE__ << __LINE__; emit waypointChanged(wp); }