diff --git a/src/GUI/gui.cpp b/src/GUI/gui.cpp index b01ec198..51cd8ef4 100644 --- a/src/GUI/gui.cpp +++ b/src/GUI/gui.cpp @@ -1527,7 +1527,7 @@ void GUI::mapLoaded() } } -void GUI::mapLoadedNoTrigger() +void GUI::mapLoadedDir() { MapAction *action = static_cast(QObject::sender()); Map *map = action->data().value(); @@ -1535,6 +1535,9 @@ void GUI::mapLoadedNoTrigger() if (map->isValid()) { _showMapAction->setEnabled(true); _clearMapCacheAction->setEnabled(true); + QList actions; + actions.append(action); + _mapView->loadMaps(actions); } else { QString error = tr("Error loading map:") + "\n\n" + map->path() + "\n\n" + map->errorString(); @@ -1568,17 +1571,19 @@ void GUI::loadMapDir() } else { a = createMapAction(map); menu->addAction(a); - actions.append(a); if (map->isReady()) { _showMapAction->setEnabled(true); _clearMapCacheAction->setEnabled(true); + actions.append(a); } else - connect(a, SIGNAL(loaded()), this, - SLOT(mapLoadedNoTrigger())); + connect(a, SIGNAL(loaded()), this, SLOT(mapLoadedDir())); } - } else - actions.append(a); + } else { + map = a->data().value(); + if (map->isReady()) + actions.append(a); + } } _mapView->loadMaps(actions); diff --git a/src/GUI/gui.h b/src/GUI/gui.h index fc42509b..a9e5209a 100644 --- a/src/GUI/gui.h +++ b/src/GUI/gui.h @@ -96,7 +96,7 @@ private slots: void logicalDotsPerInchChanged(qreal dpi); void mapLoaded(); - void mapLoadedNoTrigger(); + void mapLoadedDir(); void mapInitialized(); private: diff --git a/src/GUI/mapview.cpp b/src/GUI/mapview.cpp index 39e7e715..dc72951a 100644 --- a/src/GUI/mapview.cpp +++ b/src/GUI/mapview.cpp @@ -279,11 +279,9 @@ void MapView::loadMaps(const QList &maps) for (int i = 0; i < maps.size(); i++) { MapAction *a = maps.at(i); Map *map = a->data().value(); - if (map->isReady()) { - MapItem *mi = addMap(map); - connect(mi, SIGNAL(triggered()), a, SLOT(trigger())); - } else - connect(a, SIGNAL(loaded()), this, SLOT(mapLoaded())); + Q_ASSERT(map->isReady()); + MapItem *mi = addMap(map); + connect(mi, SIGNAL(triggered()), a, SLOT(trigger())); } if (fitMapZoom() != zoom) @@ -296,29 +294,6 @@ void MapView::loadMaps(const QList &maps) centerOn(contentCenter()); } -void MapView::mapLoaded() -{ - MapAction *action = static_cast(QObject::sender()); - Map *map = action->data().value(); - - if (!map->isValid()) - return; - - int zoom = _map->zoom(); - - MapItem *mi = addMap(map); - connect(mi, SIGNAL(triggered()), action, SLOT(trigger())); - - if (fitMapZoom() != zoom) - rescale(); - else - updatePOIVisibility(); - - updateZValues(_areas); - - centerOn(contentCenter()); -} - int MapView::fitMapZoom() const { RectC br = _tr | _rr | _wr | _ar; diff --git a/src/GUI/mapview.h b/src/GUI/mapview.h index d800b621..045c89c0 100644 --- a/src/GUI/mapview.h +++ b/src/GUI/mapview.h @@ -105,7 +105,6 @@ public slots: private slots: void updatePOI(); void reloadMap(); - void mapLoaded(); private: typedef QHash, WaypointItem*> POIHash; diff --git a/src/map/invalidmap.h b/src/map/invalidmap.h index d676580e..c07a11ec 100644 --- a/src/map/invalidmap.h +++ b/src/map/invalidmap.h @@ -21,6 +21,7 @@ public: void draw(QPainter *, const QRectF &, Flags) {} bool isValid() const {return false;} + bool isReady() const {return false;} QString errorString() const {return _errorString;} private: