コード例 #1
0
ファイル: marblemap.cpp プロジェクト: GiancarloF/POM
/**
 * @brief Mouse right click on map
 * @param p_x
 * @param p_y
 * @note  If a marker is clicked, the markerClicked() signal 
 *        containing the marker id is emitted, otherwise the context menu
 *        to save the new place is shown
 */
void MarbleMap::mouseRightClick(int p_x, int p_y)
{
#ifdef DBG_MARBLE_MAP
  qDebug() << "MarbleMap::mouseRightClick() pt = " << p_x << ", " << p_y;
#endif
  int l_id = -1;
  
  QVector<const GeoDataPlacemark *> l_v = whichFeatureAt(QPoint(p_x, p_y));
  
  if(0 < l_v.size())        // since we can have more placemarks (e.g. zoom too low)
  {
    l_id = l_v.at(0)->id(); // then, get the first one
    emit markerClicked(l_id);
  }
  else
  {
    QMenu l_menu;
    l_menu.addAction("Save this location?");
    
    QPoint l_pos = mapToGlobal(QPoint(p_x, p_y)); // the menu position is relative to screen and not to widget
    QAction* l_action = l_menu.exec(l_pos);
    if (l_action)
    {
      qreal l_lng;
      qreal l_lat;
      geoCoordinates(p_x, p_y, l_lng, l_lat);
#ifdef DBG_MARBLE_MAP
      qDebug() << "MarbleMap::mouseRightClick() going to create marker at " << l_lat << ", " << l_lng;
#endif
      createMarker(l_lat, l_lng);
    }
  }
}
コード例 #2
0
void MarbleWidget::notifyMouseClick( int x, int y)
{
    qreal  lon   = 0;
    qreal  lat   = 0;

    bool const valid = geoCoordinates( x, y, lon, lat, GeoDataCoordinates::Radian );

    if ( valid ) {
        emit mouseClickGeoPosition( lon, lat, GeoDataCoordinates::Radian );
    }
}