diff --git a/qtvplugin_geomarker/geographicsellipseitem.cpp b/qtvplugin_geomarker/geographicsellipseitem.cpp index 8dcc286e860fe51132d51d00364e33d79c419bef..ce2fd1c7bd873afc93d59492c2dc77920eea9baf 100644 --- a/qtvplugin_geomarker/geographicsellipseitem.cpp +++ b/qtvplugin_geomarker/geographicsellipseitem.cpp @@ -65,8 +65,11 @@ namespace QTVP_GEOMARKER{ void geoGraphicsEllipseItem::mousePressEvent(QGraphicsSceneMouseEvent * event) { QGraphicsEllipseItem::mousePressEvent(event); - bool bshow = this->props_visible(); - this->show_props(!bshow); + //if (wantMouseHoverEvent()==false)e) + { + bool bshow = this->props_visible(); + this->show_props(!bshow); + } //post enent QMap map_evt; geoGraphicsScene * pscene = dynamic_cast(this->scene()); @@ -96,6 +99,59 @@ namespace QTVP_GEOMARKER{ } } + void geoGraphicsEllipseItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event) + { + QGraphicsEllipseItem::hoverEnterEvent(event); + //this->show_props(true); + //post enent + QMap map_evt; + geoGraphicsScene * pscene = dynamic_cast(this->scene()); + if (pscene) + { + QObject * pPlg = pscene->parent(); + if (pPlg) + { + qtvplugin_geomarker * pMarker = dynamic_cast(pPlg) ; + if (pMarker) + { + map_evt["source"] = pMarker->get_name(); + map_evt["destin"] = "ALL"; + map_evt["name"] = "ITEM_MOUSE_ENTER"; + map_evt["id"] = this->item_name(); + vi()->post_event(map_evt); + } + } + + } + + } + + void geoGraphicsEllipseItem::hoverLeaveEvent(QGraphicsSceneHoverEvent * event) + { + QGraphicsEllipseItem::hoverLeaveEvent(event); + //this->show_props(false); + //post enent + QMap map_evt; + geoGraphicsScene * pscene = dynamic_cast(this->scene()); + if (pscene) + { + QObject * pPlg = pscene->parent(); + if (pPlg) + { + qtvplugin_geomarker * pMarker = dynamic_cast(pPlg) ; + if (pMarker) + { + map_evt["source"] = pMarker->get_name(); + map_evt["destin"] = "ALL"; + map_evt["name"] = "ITEM_MOUSE_LEAVE"; + map_evt["id"] = this->item_name(); + vi()->post_event(map_evt); + } + } + + } + } + void geoGraphicsEllipseItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event) { QGraphicsEllipseItem::mouseDoubleClickEvent(event); diff --git a/qtvplugin_geomarker/geographicsellipseitem.h b/qtvplugin_geomarker/geographicsellipseitem.h index 81c8fffcbaa24c774ee6c2b8da436b21b4f11da8..696518042fae79e92912621d0930ce0b1f46aaa2 100644 --- a/qtvplugin_geomarker/geographicsellipseitem.h +++ b/qtvplugin_geomarker/geographicsellipseitem.h @@ -14,6 +14,8 @@ namespace QTVP_GEOMARKER{ protected: void mousePressEvent(QGraphicsSceneMouseEvent * event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event); + void hoverEnterEvent(QGraphicsSceneHoverEvent * event); + void hoverLeaveEvent(QGraphicsSceneHoverEvent * event); public: explicit geoGraphicsEllipseItem(QString name,QTVOSM::viewer_interface * pVi, qreal cent_lat = 90, diff --git a/qtvplugin_geomarker/geographicslineitem.cpp b/qtvplugin_geomarker/geographicslineitem.cpp index ed335d71486d689bd2449b099ec9259f42b4648d..e9682f6ab86e672dde13360fb07bfb5e3faad826 100644 --- a/qtvplugin_geomarker/geographicslineitem.cpp +++ b/qtvplugin_geomarker/geographicslineitem.cpp @@ -64,8 +64,11 @@ namespace QTVP_GEOMARKER{ void geoGraphicsLineItem::mousePressEvent(QGraphicsSceneMouseEvent * event) { QGraphicsLineItem::mousePressEvent(event); - bool bshow = this->props_visible(); - this->show_props(!bshow); + //if (wantMouseHoverEvent()==false) + { + bool bshow = this->props_visible(); + this->show_props(!bshow); + } //post enent QMap map_evt; geoGraphicsScene * pscene = dynamic_cast(this->scene()); @@ -94,7 +97,57 @@ namespace QTVP_GEOMARKER{ } } + void geoGraphicsLineItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event) + { + QGraphicsLineItem::hoverEnterEvent(event); + //this->show_props(true); + //post enent + QMap map_evt; + geoGraphicsScene * pscene = dynamic_cast(this->scene()); + if (pscene) + { + QObject * pPlg = pscene->parent(); + if (pPlg) + { + qtvplugin_geomarker * pMarker = dynamic_cast(pPlg) ; + if (pMarker) + { + map_evt["source"] = pMarker->get_name(); + map_evt["destin"] = "ALL"; + map_evt["name"] = "ITEM_MOUSE_ENTER"; + map_evt["id"] = this->item_name(); + vi()->post_event(map_evt); + } + } + + } + } + + void geoGraphicsLineItem::hoverLeaveEvent(QGraphicsSceneHoverEvent * event) + { + QGraphicsLineItem::hoverLeaveEvent(event); + //this->show_props(false); + //post enent + QMap map_evt; + geoGraphicsScene * pscene = dynamic_cast(this->scene()); + if (pscene) + { + QObject * pPlg = pscene->parent(); + if (pPlg) + { + qtvplugin_geomarker * pMarker = dynamic_cast(pPlg) ; + if (pMarker) + { + map_evt["source"] = pMarker->get_name(); + map_evt["destin"] = "ALL"; + map_evt["name"] = "ITEM_MOUSE_LEAVE"; + map_evt["id"] = this->item_name(); + vi()->post_event(map_evt); + } + } + } + } void geoGraphicsLineItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event) { QGraphicsLineItem::mouseDoubleClickEvent(event); diff --git a/qtvplugin_geomarker/geographicslineitem.h b/qtvplugin_geomarker/geographicslineitem.h index 81998f8efce4007f9a93972df66108cd217183b8..2118993b1471c2afc7ede3844752d0e35211ecb4 100644 --- a/qtvplugin_geomarker/geographicslineitem.h +++ b/qtvplugin_geomarker/geographicslineitem.h @@ -15,7 +15,8 @@ namespace QTVP_GEOMARKER{ protected: void mousePressEvent(QGraphicsSceneMouseEvent * event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event); - + void hoverEnterEvent(QGraphicsSceneHoverEvent * event); + void hoverLeaveEvent(QGraphicsSceneHoverEvent * event); public: explicit geoGraphicsLineItem(QString name,QTVOSM::viewer_interface * pVi, qreal lat1 = 90, diff --git a/qtvplugin_geomarker/geographicsmultilineitem.cpp b/qtvplugin_geomarker/geographicsmultilineitem.cpp index e8f4173fdbd95f0d558307d37290c89058d4d43e..3a0193714f4d2038b95eed854710b9534c414b86 100644 --- a/qtvplugin_geomarker/geographicsmultilineitem.cpp +++ b/qtvplugin_geomarker/geographicsmultilineitem.cpp @@ -72,8 +72,11 @@ namespace QTVP_GEOMARKER{ void geoGraphicsMultilineItem::mousePressEvent(QGraphicsSceneMouseEvent * event) { QGraphicsPathItem::mousePressEvent(event); - bool bshow = this->props_visible(); - this->show_props(!bshow); + //if (wantMouseHoverEvent()==false) + { + bool bshow = this->props_visible(); + this->show_props(!bshow); + } //post enent QMap map_evt; geoGraphicsScene * pscene = dynamic_cast(this->scene()); @@ -102,6 +105,58 @@ namespace QTVP_GEOMARKER{ } } + void geoGraphicsMultilineItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event) + { + QGraphicsPathItem::hoverEnterEvent(event); + //this->show_props(true); + //post enent + QMap map_evt; + geoGraphicsScene * pscene = dynamic_cast(this->scene()); + if (pscene) + { + QObject * pPlg = pscene->parent(); + if (pPlg) + { + qtvplugin_geomarker * pMarker = dynamic_cast(pPlg) ; + if (pMarker) + { + map_evt["source"] = pMarker->get_name(); + map_evt["destin"] = "ALL"; + map_evt["name"] = "ITEM_MOUSE_ENTER"; + map_evt["id"] = this->item_name(); + vi()->post_event(map_evt); + } + } + + } + } + + void geoGraphicsMultilineItem::hoverLeaveEvent(QGraphicsSceneHoverEvent * event) + { + QGraphicsPathItem::hoverLeaveEvent(event); + //this->show_props(false); + //post enent + QMap map_evt; + geoGraphicsScene * pscene = dynamic_cast(this->scene()); + if (pscene) + { + QObject * pPlg = pscene->parent(); + if (pPlg) + { + qtvplugin_geomarker * pMarker = dynamic_cast(pPlg) ; + if (pMarker) + { + map_evt["source"] = pMarker->get_name(); + map_evt["destin"] = "ALL"; + map_evt["name"] = "ITEM_MOUSE_LEAVE"; + map_evt["id"] = this->item_name(); + vi()->post_event(map_evt); + } + } + + } + } + void geoGraphicsMultilineItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event) { QGraphicsPathItem::mouseDoubleClickEvent(event); diff --git a/qtvplugin_geomarker/geographicsmultilineitem.h b/qtvplugin_geomarker/geographicsmultilineitem.h index 22b52055cf6c5146291d395f19006f3a732cbe1b..6cf847ad879328e920a457e19eb7c4bf423d23b8 100644 --- a/qtvplugin_geomarker/geographicsmultilineitem.h +++ b/qtvplugin_geomarker/geographicsmultilineitem.h @@ -13,7 +13,8 @@ namespace QTVP_GEOMARKER{ protected: void mousePressEvent(QGraphicsSceneMouseEvent * event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event); - + void hoverEnterEvent(QGraphicsSceneHoverEvent * event); + void hoverLeaveEvent(QGraphicsSceneHoverEvent * event); public: explicit geoGraphicsMultilineItem(QString name,QTVOSM::viewer_interface * pVi, const QPolygonF & lla_polygon diff --git a/qtvplugin_geomarker/geographicspixmapitem.cpp b/qtvplugin_geomarker/geographicspixmapitem.cpp index d414e60b253bc33fa1bb9fac811e9727cb962832..2d6fd30c0c00ed39018b146597fe9662e4cb39c0 100644 --- a/qtvplugin_geomarker/geographicspixmapitem.cpp +++ b/qtvplugin_geomarker/geographicspixmapitem.cpp @@ -54,7 +54,57 @@ namespace QTVP_GEOMARKER{ setOffset(px - m_pIcon->centerx, py - m_pIcon->centery); QGraphicsPixmapItem::setTransformOriginPoint(px, py); } + void geoGraphicsPixmapItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event) + { + QGraphicsPixmapItem::hoverEnterEvent(event); + //this->show_props(true); + //post enent + QMap map_evt; + geoGraphicsScene * pscene = dynamic_cast(this->scene()); + if (pscene) + { + QObject * pPlg = pscene->parent(); + if (pPlg) + { + qtvplugin_geomarker * pMarker = dynamic_cast(pPlg) ; + if (pMarker) + { + map_evt["source"] = pMarker->get_name(); + map_evt["destin"] = "ALL"; + map_evt["name"] = "ITEM_MOUSE_ENTER"; + map_evt["id"] = this->item_name(); + vi()->post_event(map_evt); + } + } + + } + } + + void geoGraphicsPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent * event) + { + QGraphicsPixmapItem::hoverLeaveEvent(event); + //this->show_props(false); + //post enent + QMap map_evt; + geoGraphicsScene * pscene = dynamic_cast(this->scene()); + if (pscene) + { + QObject * pPlg = pscene->parent(); + if (pPlg) + { + qtvplugin_geomarker * pMarker = dynamic_cast(pPlg) ; + if (pMarker) + { + map_evt["source"] = pMarker->get_name(); + map_evt["destin"] = "ALL"; + map_evt["name"] = "ITEM_MOUSE_LEAVE"; + map_evt["id"] = this->item_name(); + vi()->post_event(map_evt); + } + } + } + } void geoGraphicsPixmapItem::setGeo(qreal cent_lat,qreal cent_lon) { m_lat = cent_lat; @@ -68,8 +118,11 @@ namespace QTVP_GEOMARKER{ void geoGraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent * event) { QGraphicsPixmapItem ::mousePressEvent(event); - bool bshow = this->props_visible(); - this->show_props(!bshow); + //if (wantMouseHoverEvent()==false) + { + bool bshow = this->props_visible(); + this->show_props(!bshow); + } //post enent QMap map_evt; geoGraphicsScene * pscene = dynamic_cast(this->scene()); diff --git a/qtvplugin_geomarker/geographicspixmapitem.h b/qtvplugin_geomarker/geographicspixmapitem.h index d4df80f7383d3e42eacfcb7042dfc7d5c452c219..178e387f0c37be97307ffbef22b1ecc3269a2aec 100644 --- a/qtvplugin_geomarker/geographicspixmapitem.h +++ b/qtvplugin_geomarker/geographicspixmapitem.h @@ -21,7 +21,8 @@ namespace QTVP_GEOMARKER{ protected: void mousePressEvent(QGraphicsSceneMouseEvent * event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event); - + void hoverEnterEvent(QGraphicsSceneHoverEvent * event); + void hoverLeaveEvent(QGraphicsSceneHoverEvent * event); public: explicit geoGraphicsPixmapItem(QString name,QTVOSM::viewer_interface * pVi ,const tag_icon * pIcon, diff --git a/qtvplugin_geomarker/geographicspolygonitem.cpp b/qtvplugin_geomarker/geographicspolygonitem.cpp index 50b198be0ae7f1e70e398e993ff30321e6f5b7c6..a19ec7a3f9c97a6f5c16e91b4eb129f0a56c34e5 100644 --- a/qtvplugin_geomarker/geographicspolygonitem.cpp +++ b/qtvplugin_geomarker/geographicspolygonitem.cpp @@ -72,8 +72,11 @@ namespace QTVP_GEOMARKER{ void geoGraphicsPolygonItem::mousePressEvent(QGraphicsSceneMouseEvent * event) { QGraphicsPolygonItem::mousePressEvent(event); - bool bshow = this->props_visible(); - this->show_props(!bshow); + //if (wantMouseHoverEvent()==false) + { + bool bshow = this->props_visible(); + this->show_props(!bshow); + } //post enent QMap map_evt; geoGraphicsScene * pscene = dynamic_cast(this->scene()); @@ -102,6 +105,59 @@ namespace QTVP_GEOMARKER{ } } + + void geoGraphicsPolygonItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event) + { + QGraphicsPolygonItem::hoverEnterEvent(event); + //this->show_props(true); + //post enent + QMap map_evt; + geoGraphicsScene * pscene = dynamic_cast(this->scene()); + if (pscene) + { + QObject * pPlg = pscene->parent(); + if (pPlg) + { + qtvplugin_geomarker * pMarker = dynamic_cast(pPlg) ; + if (pMarker) + { + map_evt["source"] = pMarker->get_name(); + map_evt["destin"] = "ALL"; + map_evt["name"] = "ITEM_MOUSE_ENTER"; + map_evt["id"] = this->item_name(); + vi()->post_event(map_evt); + } + } + + } + } + + void geoGraphicsPolygonItem::hoverLeaveEvent(QGraphicsSceneHoverEvent * event) + { + QGraphicsPolygonItem::hoverLeaveEvent(event); + //this->show_props(false); + //post enent + QMap map_evt; + geoGraphicsScene * pscene = dynamic_cast(this->scene()); + if (pscene) + { + QObject * pPlg = pscene->parent(); + if (pPlg) + { + qtvplugin_geomarker * pMarker = dynamic_cast(pPlg) ; + if (pMarker) + { + map_evt["source"] = pMarker->get_name(); + map_evt["destin"] = "ALL"; + map_evt["name"] = "ITEM_MOUSE_LEAVE"; + map_evt["id"] = this->item_name(); + vi()->post_event(map_evt); + } + } + + } + } + void geoGraphicsPolygonItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event) { QGraphicsPolygonItem::mouseDoubleClickEvent(event); diff --git a/qtvplugin_geomarker/geographicspolygonitem.h b/qtvplugin_geomarker/geographicspolygonitem.h index 91d0326b999ebb734361b94037cdcb2ca6dbf5b6..d50ee2a6624b5f8ebd025761c0409ab835cf7d16 100644 --- a/qtvplugin_geomarker/geographicspolygonitem.h +++ b/qtvplugin_geomarker/geographicspolygonitem.h @@ -13,7 +13,8 @@ namespace QTVP_GEOMARKER{ protected: void mousePressEvent(QGraphicsSceneMouseEvent * event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event); - + void hoverEnterEvent(QGraphicsSceneHoverEvent * event); + void hoverLeaveEvent(QGraphicsSceneHoverEvent * event); public: explicit geoGraphicsPolygonItem(QString name,QTVOSM::viewer_interface * pVi, const QPolygonF & lla_polygon diff --git a/qtvplugin_geomarker/geographicsrectitem.cpp b/qtvplugin_geomarker/geographicsrectitem.cpp index 552b9957d12701dd5c3b4c964fb81d69eb811678..87e82d8a83f1fa61edef9d92876f12bece1a8700 100644 --- a/qtvplugin_geomarker/geographicsrectitem.cpp +++ b/qtvplugin_geomarker/geographicsrectitem.cpp @@ -66,8 +66,11 @@ namespace QTVP_GEOMARKER{ void geoGraphicsRectItem::mousePressEvent(QGraphicsSceneMouseEvent * event) { QGraphicsRectItem::mousePressEvent(event); - bool bshow = this->props_visible(); - this->show_props(!bshow); + //if (wantMouseHoverEvent()==false) + { + bool bshow = this->props_visible(); + this->show_props(!bshow); + } //post enent QMap map_evt; geoGraphicsScene * pscene = dynamic_cast(this->scene()); @@ -96,6 +99,57 @@ namespace QTVP_GEOMARKER{ } } + void geoGraphicsRectItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event) + { + QGraphicsRectItem::hoverEnterEvent(event); + //this->show_props(true); + //post enent + QMap map_evt; + geoGraphicsScene * pscene = dynamic_cast(this->scene()); + if (pscene) + { + QObject * pPlg = pscene->parent(); + if (pPlg) + { + qtvplugin_geomarker * pMarker = dynamic_cast(pPlg) ; + if (pMarker) + { + map_evt["source"] = pMarker->get_name(); + map_evt["destin"] = "ALL"; + map_evt["name"] = "ITEM_MOUSE_ENTER"; + map_evt["id"] = this->item_name(); + vi()->post_event(map_evt); + } + } + + } + } + + void geoGraphicsRectItem::hoverLeaveEvent(QGraphicsSceneHoverEvent * event) + { + QGraphicsRectItem::hoverLeaveEvent(event); + //this->show_props(false); + //post enent + QMap map_evt; + geoGraphicsScene * pscene = dynamic_cast(this->scene()); + if (pscene) + { + QObject * pPlg = pscene->parent(); + if (pPlg) + { + qtvplugin_geomarker * pMarker = dynamic_cast(pPlg) ; + if (pMarker) + { + map_evt["source"] = pMarker->get_name(); + map_evt["destin"] = "ALL"; + map_evt["name"] = "ITEM_MOUSE_LEAVE"; + map_evt["id"] = this->item_name(); + vi()->post_event(map_evt); + } + } + + } + } void geoGraphicsRectItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event) { diff --git a/qtvplugin_geomarker/geographicsrectitem.h b/qtvplugin_geomarker/geographicsrectitem.h index e17b2e591ed7b44c865614377a58ef8c8253a6fe..9b932fce506713fac76afd523bbe8ff1e5e7520d 100644 --- a/qtvplugin_geomarker/geographicsrectitem.h +++ b/qtvplugin_geomarker/geographicsrectitem.h @@ -14,7 +14,8 @@ namespace QTVP_GEOMARKER{ protected: void mousePressEvent(QGraphicsSceneMouseEvent * event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event); - + void hoverEnterEvent(QGraphicsSceneHoverEvent * event); + void hoverLeaveEvent(QGraphicsSceneHoverEvent * event); public: explicit geoGraphicsRectItem(QString name,QTVOSM::viewer_interface * pVi, qreal cent_lat = 90, diff --git a/qtvplugin_geomarker/geoitembase.cpp b/qtvplugin_geomarker/geoitembase.cpp index 3e4000312870f376d3ceae32cf15e57166af629c..59cab5d5b03ac8f9a5429a52444da37f8a892d81 100644 --- a/qtvplugin_geomarker/geoitembase.cpp +++ b/qtvplugin_geomarker/geoitembase.cpp @@ -256,4 +256,25 @@ namespace QTVP_GEOMARKER{ m_pSelectionBound->setRect(pc->boundingRect()); } } + + bool geoItemBase::wantMouseHoverEvent() + { + QGraphicsItem * pc = dynamic_cast (this); + if (pc) + { + return pc->acceptHoverEvents(); + } + return false; + } + + void geoItemBase::setWantMouseHoverEvent(bool w) + { + QGraphicsItem * pc = dynamic_cast (this); + if (pc) + { + pc->setAcceptHoverEvents(w); + } + + } + } diff --git a/qtvplugin_geomarker/geoitembase.h b/qtvplugin_geomarker/geoitembase.h index 1de226ce6be03a90a871d62e52e3a1309c36084a..42692432cc1ddd187ad3f9b9cb0705e495e90a48 100644 --- a/qtvplugin_geomarker/geoitembase.h +++ b/qtvplugin_geomarker/geoitembase.h @@ -80,6 +80,8 @@ namespace QTVP_GEOMARKER{ void setLabelColor (QColor col) {m_LabelTextColor = col;if (m_pLabelItem) m_pLabelItem->setDefaultTextColor(m_LabelTextColor);} QColor labelColor () {return m_LabelTextColor;} void adjustLabelPos (); + bool wantMouseHoverEvent(); + void setWantMouseHoverEvent(bool ); QStringList prop_names(); QVariantList prop_values(); diff --git a/qtvplugin_geomarker/qtvplugin_geomarker.cpp b/qtvplugin_geomarker/qtvplugin_geomarker.cpp index 1bcb127980b49890a0db7f76fb808df3e745e278..73a21b9667efef17d89d445a618f8aa845b1548b 100644 --- a/qtvplugin_geomarker/qtvplugin_geomarker.cpp +++ b/qtvplugin_geomarker/qtvplugin_geomarker.cpp @@ -610,7 +610,28 @@ bool qtvplugin_geomarker::cb_mouseMoveEvent ( QMouseEvent * e ) //Warp while (wx < 0) wx += winsz; while (wx > winsz-1) wx -= winsz; - + QPointF mouse_scene_pt(wx,wy); + QPoint mouse_screen_pt = e->globalPos(); + Qt::MouseButton mouse_button = e->button(); + QWidget * pwig = dynamic_cast (m_pVi); + if (m_bVisible && pwig && too_many_items()==false) + { + // Convert and deliver the mouse event to the scene. + QGraphicsSceneMouseEvent * pmouseEvent = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseMove); + QGraphicsSceneMouseEvent & mouseEvent = * pmouseEvent; + mouseEvent.setWidget(pwig); + mouseEvent.setButtonDownScenePos(mouse_button, mouse_scene_pt); + mouseEvent.setButtonDownScreenPos(mouse_button, mouse_screen_pt); + mouseEvent.setScenePos(mouse_scene_pt); + mouseEvent.setScreenPos(mouse_screen_pt); + mouseEvent.setLastScenePos(mouse_scene_pt); + mouseEvent.setLastScreenPos(mouse_screen_pt); + mouseEvent.setButtons(e->buttons()); + mouseEvent.setButton(e->button()); + mouseEvent.setModifiers(e->modifiers()); + mouseEvent.setAccepted(false); + QApplication::postEvent(m_pScene, &mouseEvent); + } //tools switch (m_currentTools) { diff --git a/qtvplugin_geomarker/qtvplugin_geomarker.ui b/qtvplugin_geomarker/qtvplugin_geomarker.ui index 3bc7dd1a9cf34b3878a6464879b8f7dc9e9b3636..999bcd00093c77fe6c0f85916028ea1ded4cb91e 100644 --- a/qtvplugin_geomarker/qtvplugin_geomarker.ui +++ b/qtvplugin_geomarker/qtvplugin_geomarker.ui @@ -6,8 +6,8 @@ 0 0 - 538 - 424 + 547 + 465 @@ -150,8 +150,8 @@ 0 0 - 165 - 225 + 160 + 194 @@ -194,8 +194,8 @@ 0 0 - 166 - 220 + 174 + 186 @@ -304,6 +304,13 @@ + + + + Accept "Hover" Event(Slow!) + + + @@ -344,7 +351,7 @@ Delete - + :/icons/delete-21.png:/icons/delete-21.png @@ -703,7 +710,7 @@ add - + :/icons/Add to favourites.png:/icons/Add to favourites.png @@ -1050,7 +1057,7 @@ Delete Prop - + :/icons/delete-21.png:/icons/delete-21.png @@ -1079,6 +1086,7 @@ + diff --git a/qtvplugin_geomarker/qtvplugin_geomarker_func.cpp b/qtvplugin_geomarker/qtvplugin_geomarker_func.cpp index 008893945d4b64c852481b31a38a513bc967af74..33257457e4bf699b02a0a3d4e8559a12242b0470 100644 --- a/qtvplugin_geomarker/qtvplugin_geomarker_func.cpp +++ b/qtvplugin_geomarker/qtvplugin_geomarker_func.cpp @@ -261,6 +261,15 @@ QMap qtvplugin_geomarker::func_update_point (const QMapsetLabelColor(m_default_style.text_color); + + //! want_hover is the boolean para that tells the plugin this mark want mouse hover event. + //! this is SLOW! + if ( paras.contains("want_hover")) + { + bool want_hover = paras["want_hover"].toInt()==0?false:true; + newitem->setWantMouseHoverEvent(want_hover); + } + //scheduleRefreshMarks(); scheduleUpdateMap(); } @@ -366,6 +375,13 @@ QMap qtvplugin_geomarker:: func_update_icon (const QMapsetLabelColor( m_default_style.text_color); + //! want_hover is the boolean para that tells the plugin this mark want mouse hover event. + //! this is SLOW! + if ( paras.contains("want_hover")) + { + bool want_hover = paras["want_hover"].toInt()==0?false:true; + newitem->setWantMouseHoverEvent(want_hover); + } //scheduleRefreshMarks(); scheduleUpdateMap(); } @@ -482,6 +498,13 @@ QMap qtvplugin_geomarker::func_update_line (const QMapsetLabelColor(m_default_style.text_color); + //! want_hover is the boolean para that tells the plugin this mark want mouse hover event. + //! this is SLOW! + if ( paras.contains("want_hover")) + { + bool want_hover = paras["want_hover"].toInt()==0?false:true; + newitem->setWantMouseHoverEvent(want_hover); + } //scheduleRefreshMarks(); scheduleUpdateMap(); } @@ -669,6 +692,13 @@ QMap qtvplugin_geomarker::func_update_polygon (const QMapsetLabelColor(m_default_style.text_color); + //! want_hover is the boolean para that tells the plugin this mark want mouse hover event. + //! this is SLOW! + if ( paras.contains("want_hover")) + { + bool want_hover = paras["want_hover"].toInt()==0?false:true; + newitem->setWantMouseHoverEvent(want_hover); + } //scheduleRefreshMarks(); scheduleUpdateMap(); } @@ -1044,6 +1074,10 @@ QMap qtvplugin_geomarker::func_mark (const QMaplabelFont().weight(); res["weight_label"] = QString("%1").arg(weight); + bool want_hover = item->wantMouseHoverEvent(); + res["want_hover"] = QString("%1").arg(want_hover?1:0); + + } else res["error"] = tr("the mark name.") + name + tr(" does not exist in current scene."); diff --git a/qtvplugin_geomarker/qtvplugin_geomarker_uimethods.cpp b/qtvplugin_geomarker/qtvplugin_geomarker_uimethods.cpp index 01d6a0c81a942e824f1da2811ed0c8b696abe50b..0612fb6d595f480b14048ba66680ebdead0c0275 100644 --- a/qtvplugin_geomarker/qtvplugin_geomarker_uimethods.cpp +++ b/qtvplugin_geomarker/qtvplugin_geomarker_uimethods.cpp @@ -178,6 +178,7 @@ void qtvplugin_geomarker::ini_save() settings.setValue("ui/lineEdit_QTV_icon_rotate",ui->lineEdit_QTV_icon_rotate->text()); settings.setValue("ui/lineEdit_QTV_icon_scale",ui->lineEdit_QTV_icon_scale->text()); settings.setValue("ui/checkBox_QTV_multiline",ui->checkBox_QTV_multiline->isChecked()?-1:0); + settings.setValue("ui/checkBox_QTV_acceptHoverEvent",ui->checkBox_QTV_acceptHoverEvent->isChecked()?-1:0); } void qtvplugin_geomarker::ini_load() @@ -273,6 +274,8 @@ void qtvplugin_geomarker::ini_load() int checkBox_QTV_multiline = settings.value("ui/checkBox_QTV_multiline",0).toInt(); ui->checkBox_QTV_multiline->setChecked(checkBox_QTV_multiline?true:false); + int checkBox_QTV_acceptHoverEvent = settings.value("ui/checkBox_QTV_acceptHoverEvent",0).toInt(); + ui->checkBox_QTV_acceptHoverEvent->setChecked(checkBox_QTV_acceptHoverEvent?true:false); } @@ -526,8 +529,7 @@ void qtvplugin_geomarker::on_pushButton_QTV_update_clicked() f.setWeight(fontWeight); newitem->setLabelFont(f); newitem->setLabelColor(textColor); - - + newitem->setWantMouseHoverEvent(ui->checkBox_QTV_acceptHoverEvent->isChecked()); } scheduleRefreshMarks(); m_pVi->UpdateWindow(); @@ -764,6 +766,9 @@ void qtvplugin_geomarker::refreshItemUI(QString markname) int weight = item->labelFont().weight(); ui->spinBox_QTV_textWeight->setValue(weight); + bool bwant_hover = item->wantMouseHoverEvent(); + ui->checkBox_QTV_acceptHoverEvent->setChecked(bwant_hover); + refreshProps(item); }//end if item diff --git a/qtvplugin_geomarker/qtvplugin_geomarker_xml.cpp b/qtvplugin_geomarker/qtvplugin_geomarker_xml.cpp index 4130ac3ced3541d98a7db88e564ac640376a8366..c09a61ac63ada66b4737fd113b19a80e4f918181 100644 --- a/qtvplugin_geomarker/qtvplugin_geomarker_xml.cpp +++ b/qtvplugin_geomarker/qtvplugin_geomarker_xml.cpp @@ -57,8 +57,7 @@ bool qtvplugin_geomarker::xml_save(QString xml) stream.writeTextElement("style_pen",QString("%1").arg(int(pU->pen().style()))); stream.writeTextElement("width_pen",QString("%1").arg(int(pU->pen().width()))); stream.writeTextElement("color_brush",color2string(pU->brush().color())); - stream.writeTextElement("style_brush",QString("%1").arg(int(pU->brush().style()))); - + stream.writeTextElement("style_brush",QString("%1").arg(int(pU->brush().style()))); } } break; @@ -186,7 +185,7 @@ bool qtvplugin_geomarker::xml_save(QString xml) int weight = item->labelFont().weight(); stream.writeTextElement("weight_label",QString("%1").arg(weight)); - + stream.writeTextElement("want_hover",QString("%1").arg(item->wantMouseHoverEvent()==true?1:0)); stream.writeEndElement(); // style //1.2 properties @@ -490,6 +489,8 @@ bool qtvplugin_geomarker::xml_update_mark(tag_xml_mark & mark) { newitem->set_prop_data(p.key(),p.value()); } + bool bWantHover = mark.styles["want_hover"].toInt()!=0?true:false; + newitem->setWantMouseHoverEvent(bWantHover); } diff --git a/test_container/testcontainer.cpp b/test_container/testcontainer.cpp index 08d8e6a51b283492d938d3d53b1cea98504c373c..a9afa77749ddce07c4ac8c20158fc5e4e7d89dc5 100644 --- a/test_container/testcontainer.cpp +++ b/test_container/testcontainer.cpp @@ -301,7 +301,7 @@ void testcontainer::on_pushButton_QTV_test_mark_clicked() "style_pen=2;color_pen=0,0,255,128;width_pen=3;" "style_brush=1;color_brush=0,255,0,128;" "color_label=0,0,255,96;weight_label=99;size_label=12;" - "width=16;height=20;") + "width=16;height=20;want_hover=1;") .arg(rand()%1700/10.0-85) .arg(rand()%3600/10.0-180) ).toString(); @@ -371,7 +371,7 @@ void testcontainer::on_pushButton_QTV_test_line_clicked() "lat0=%1;lon0=%2;" "lat1=%3;lon1=%4;" "style_pen=4;color_pen=255,0,0,96;" - "width_pen=2;") + "width_pen=2;want_hover=1;") .arg(rand()%1700/10.0-85) .arg(rand()%3600/10.0-180) .arg(rand()%1700/10.0-85) diff --git a/test_container/testcontainer_linux.cpp b/test_container/testcontainer_linux.cpp index 200f5cd5b314ec21317b17585f4ae7cb2e606c11..c47fcd669a1dd8164813bc5893b23a4fb0e465cd 100644 --- a/test_container/testcontainer_linux.cpp +++ b/test_container/testcontainer_linux.cpp @@ -266,7 +266,7 @@ void testcontainer::on_pushButton_QTV_test_mark_clicked() "lat=%1;lon=%2;" "style_pen=2;color_pen=0,0,255,128;width_pen=3;" "style_brush=1;color_brush=0,255,0,128;" - "color_label=0,0,255,96;weight_label=99;size_label=12;" + "color_label=0,0,255,96;weight_label=99;size_label=12;want_hover=1;" "width=16;height=20;") .arg(rand()%1700/10.0-85) .arg(rand()%3600/10.0-180) @@ -337,7 +337,7 @@ void testcontainer::on_pushButton_QTV_test_line_clicked() "lat0=%1;lon0=%2;" "lat1=%3;lon1=%4;" "style_pen=4;color_pen=255,0,0,96;" - "width_pen=2;") + "width_pen=2;want_hover=1;") .arg(rand()%1700/10.0-85) .arg(rand()%3600/10.0-180) .arg(rand()%1700/10.0-85)