提交 79e52686 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

Add a mouse hover event in geomarker, ITEM_MOUSE_ENTER,ITEM_MOUSE_LEAVE

Mouse hover event is SLOW! As a result, prop "want_hover" is default setted to "0", means disabled.

We will add additional plugin function to reset this prop in future.
上级 85337dfd
...@@ -65,8 +65,11 @@ namespace QTVP_GEOMARKER{ ...@@ -65,8 +65,11 @@ namespace QTVP_GEOMARKER{
void geoGraphicsEllipseItem::mousePressEvent(QGraphicsSceneMouseEvent * event) void geoGraphicsEllipseItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
{ {
QGraphicsEllipseItem::mousePressEvent(event); QGraphicsEllipseItem::mousePressEvent(event);
bool bshow = this->props_visible(); //if (wantMouseHoverEvent()==false)e)
this->show_props(!bshow); {
bool bshow = this->props_visible();
this->show_props(!bshow);
}
//post enent //post enent
QMap<QString, QVariant > map_evt; QMap<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene()); geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
...@@ -96,6 +99,59 @@ namespace QTVP_GEOMARKER{ ...@@ -96,6 +99,59 @@ namespace QTVP_GEOMARKER{
} }
} }
void geoGraphicsEllipseItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event)
{
QGraphicsEllipseItem::hoverEnterEvent(event);
//this->show_props(true);
//post enent
QMap<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
if (pscene)
{
QObject * pPlg = pscene->parent();
if (pPlg)
{
qtvplugin_geomarker * pMarker = dynamic_cast<qtvplugin_geomarker *>(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<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
if (pscene)
{
QObject * pPlg = pscene->parent();
if (pPlg)
{
qtvplugin_geomarker * pMarker = dynamic_cast<qtvplugin_geomarker *>(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) void geoGraphicsEllipseItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event)
{ {
QGraphicsEllipseItem::mouseDoubleClickEvent(event); QGraphicsEllipseItem::mouseDoubleClickEvent(event);
......
...@@ -14,6 +14,8 @@ namespace QTVP_GEOMARKER{ ...@@ -14,6 +14,8 @@ namespace QTVP_GEOMARKER{
protected: protected:
void mousePressEvent(QGraphicsSceneMouseEvent * event); void mousePressEvent(QGraphicsSceneMouseEvent * event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event);
void hoverEnterEvent(QGraphicsSceneHoverEvent * event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent * event);
public: public:
explicit geoGraphicsEllipseItem(QString name,QTVOSM::viewer_interface * pVi, explicit geoGraphicsEllipseItem(QString name,QTVOSM::viewer_interface * pVi,
qreal cent_lat = 90, qreal cent_lat = 90,
......
...@@ -64,8 +64,11 @@ namespace QTVP_GEOMARKER{ ...@@ -64,8 +64,11 @@ namespace QTVP_GEOMARKER{
void geoGraphicsLineItem::mousePressEvent(QGraphicsSceneMouseEvent * event) void geoGraphicsLineItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
{ {
QGraphicsLineItem::mousePressEvent(event); QGraphicsLineItem::mousePressEvent(event);
bool bshow = this->props_visible(); //if (wantMouseHoverEvent()==false)
this->show_props(!bshow); {
bool bshow = this->props_visible();
this->show_props(!bshow);
}
//post enent //post enent
QMap<QString, QVariant > map_evt; QMap<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene()); geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
...@@ -94,7 +97,57 @@ namespace QTVP_GEOMARKER{ ...@@ -94,7 +97,57 @@ namespace QTVP_GEOMARKER{
} }
} }
void geoGraphicsLineItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event)
{
QGraphicsLineItem::hoverEnterEvent(event);
//this->show_props(true);
//post enent
QMap<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
if (pscene)
{
QObject * pPlg = pscene->parent();
if (pPlg)
{
qtvplugin_geomarker * pMarker = dynamic_cast<qtvplugin_geomarker *>(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<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
if (pscene)
{
QObject * pPlg = pscene->parent();
if (pPlg)
{
qtvplugin_geomarker * pMarker = dynamic_cast<qtvplugin_geomarker *>(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) void geoGraphicsLineItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event)
{ {
QGraphicsLineItem::mouseDoubleClickEvent(event); QGraphicsLineItem::mouseDoubleClickEvent(event);
......
...@@ -15,7 +15,8 @@ namespace QTVP_GEOMARKER{ ...@@ -15,7 +15,8 @@ namespace QTVP_GEOMARKER{
protected: protected:
void mousePressEvent(QGraphicsSceneMouseEvent * event); void mousePressEvent(QGraphicsSceneMouseEvent * event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event);
void hoverEnterEvent(QGraphicsSceneHoverEvent * event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent * event);
public: public:
explicit geoGraphicsLineItem(QString name,QTVOSM::viewer_interface * pVi, explicit geoGraphicsLineItem(QString name,QTVOSM::viewer_interface * pVi,
qreal lat1 = 90, qreal lat1 = 90,
......
...@@ -72,8 +72,11 @@ namespace QTVP_GEOMARKER{ ...@@ -72,8 +72,11 @@ namespace QTVP_GEOMARKER{
void geoGraphicsMultilineItem::mousePressEvent(QGraphicsSceneMouseEvent * event) void geoGraphicsMultilineItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
{ {
QGraphicsPathItem::mousePressEvent(event); QGraphicsPathItem::mousePressEvent(event);
bool bshow = this->props_visible(); //if (wantMouseHoverEvent()==false)
this->show_props(!bshow); {
bool bshow = this->props_visible();
this->show_props(!bshow);
}
//post enent //post enent
QMap<QString, QVariant > map_evt; QMap<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene()); geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
...@@ -102,6 +105,58 @@ namespace QTVP_GEOMARKER{ ...@@ -102,6 +105,58 @@ namespace QTVP_GEOMARKER{
} }
} }
void geoGraphicsMultilineItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event)
{
QGraphicsPathItem::hoverEnterEvent(event);
//this->show_props(true);
//post enent
QMap<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
if (pscene)
{
QObject * pPlg = pscene->parent();
if (pPlg)
{
qtvplugin_geomarker * pMarker = dynamic_cast<qtvplugin_geomarker *>(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<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
if (pscene)
{
QObject * pPlg = pscene->parent();
if (pPlg)
{
qtvplugin_geomarker * pMarker = dynamic_cast<qtvplugin_geomarker *>(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) void geoGraphicsMultilineItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event)
{ {
QGraphicsPathItem::mouseDoubleClickEvent(event); QGraphicsPathItem::mouseDoubleClickEvent(event);
......
...@@ -13,7 +13,8 @@ namespace QTVP_GEOMARKER{ ...@@ -13,7 +13,8 @@ namespace QTVP_GEOMARKER{
protected: protected:
void mousePressEvent(QGraphicsSceneMouseEvent * event); void mousePressEvent(QGraphicsSceneMouseEvent * event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event);
void hoverEnterEvent(QGraphicsSceneHoverEvent * event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent * event);
public: public:
explicit geoGraphicsMultilineItem(QString name,QTVOSM::viewer_interface * pVi, explicit geoGraphicsMultilineItem(QString name,QTVOSM::viewer_interface * pVi,
const QPolygonF & lla_polygon const QPolygonF & lla_polygon
......
...@@ -54,7 +54,57 @@ namespace QTVP_GEOMARKER{ ...@@ -54,7 +54,57 @@ namespace QTVP_GEOMARKER{
setOffset(px - m_pIcon->centerx, py - m_pIcon->centery); setOffset(px - m_pIcon->centerx, py - m_pIcon->centery);
QGraphicsPixmapItem::setTransformOriginPoint(px, py); QGraphicsPixmapItem::setTransformOriginPoint(px, py);
} }
void geoGraphicsPixmapItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event)
{
QGraphicsPixmapItem::hoverEnterEvent(event);
//this->show_props(true);
//post enent
QMap<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
if (pscene)
{
QObject * pPlg = pscene->parent();
if (pPlg)
{
qtvplugin_geomarker * pMarker = dynamic_cast<qtvplugin_geomarker *>(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<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
if (pscene)
{
QObject * pPlg = pscene->parent();
if (pPlg)
{
qtvplugin_geomarker * pMarker = dynamic_cast<qtvplugin_geomarker *>(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) void geoGraphicsPixmapItem::setGeo(qreal cent_lat,qreal cent_lon)
{ {
m_lat = cent_lat; m_lat = cent_lat;
...@@ -68,8 +118,11 @@ namespace QTVP_GEOMARKER{ ...@@ -68,8 +118,11 @@ namespace QTVP_GEOMARKER{
void geoGraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent * event) void geoGraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
{ {
QGraphicsPixmapItem ::mousePressEvent(event); QGraphicsPixmapItem ::mousePressEvent(event);
bool bshow = this->props_visible(); //if (wantMouseHoverEvent()==false)
this->show_props(!bshow); {
bool bshow = this->props_visible();
this->show_props(!bshow);
}
//post enent //post enent
QMap<QString, QVariant > map_evt; QMap<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene()); geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
......
...@@ -21,7 +21,8 @@ namespace QTVP_GEOMARKER{ ...@@ -21,7 +21,8 @@ namespace QTVP_GEOMARKER{
protected: protected:
void mousePressEvent(QGraphicsSceneMouseEvent * event); void mousePressEvent(QGraphicsSceneMouseEvent * event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event);
void hoverEnterEvent(QGraphicsSceneHoverEvent * event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent * event);
public: public:
explicit geoGraphicsPixmapItem(QString name,QTVOSM::viewer_interface * pVi explicit geoGraphicsPixmapItem(QString name,QTVOSM::viewer_interface * pVi
,const tag_icon * pIcon, ,const tag_icon * pIcon,
......
...@@ -72,8 +72,11 @@ namespace QTVP_GEOMARKER{ ...@@ -72,8 +72,11 @@ namespace QTVP_GEOMARKER{
void geoGraphicsPolygonItem::mousePressEvent(QGraphicsSceneMouseEvent * event) void geoGraphicsPolygonItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
{ {
QGraphicsPolygonItem::mousePressEvent(event); QGraphicsPolygonItem::mousePressEvent(event);
bool bshow = this->props_visible(); //if (wantMouseHoverEvent()==false)
this->show_props(!bshow); {
bool bshow = this->props_visible();
this->show_props(!bshow);
}
//post enent //post enent
QMap<QString, QVariant > map_evt; QMap<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene()); geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
...@@ -102,6 +105,59 @@ namespace QTVP_GEOMARKER{ ...@@ -102,6 +105,59 @@ namespace QTVP_GEOMARKER{
} }
} }
void geoGraphicsPolygonItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event)
{
QGraphicsPolygonItem::hoverEnterEvent(event);
//this->show_props(true);
//post enent
QMap<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
if (pscene)
{
QObject * pPlg = pscene->parent();
if (pPlg)
{
qtvplugin_geomarker * pMarker = dynamic_cast<qtvplugin_geomarker *>(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<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
if (pscene)
{
QObject * pPlg = pscene->parent();
if (pPlg)
{
qtvplugin_geomarker * pMarker = dynamic_cast<qtvplugin_geomarker *>(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) void geoGraphicsPolygonItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event)
{ {
QGraphicsPolygonItem::mouseDoubleClickEvent(event); QGraphicsPolygonItem::mouseDoubleClickEvent(event);
......
...@@ -13,7 +13,8 @@ namespace QTVP_GEOMARKER{ ...@@ -13,7 +13,8 @@ namespace QTVP_GEOMARKER{
protected: protected:
void mousePressEvent(QGraphicsSceneMouseEvent * event); void mousePressEvent(QGraphicsSceneMouseEvent * event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event);
void hoverEnterEvent(QGraphicsSceneHoverEvent * event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent * event);
public: public:
explicit geoGraphicsPolygonItem(QString name,QTVOSM::viewer_interface * pVi, explicit geoGraphicsPolygonItem(QString name,QTVOSM::viewer_interface * pVi,
const QPolygonF & lla_polygon const QPolygonF & lla_polygon
......
...@@ -66,8 +66,11 @@ namespace QTVP_GEOMARKER{ ...@@ -66,8 +66,11 @@ namespace QTVP_GEOMARKER{
void geoGraphicsRectItem::mousePressEvent(QGraphicsSceneMouseEvent * event) void geoGraphicsRectItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
{ {
QGraphicsRectItem::mousePressEvent(event); QGraphicsRectItem::mousePressEvent(event);
bool bshow = this->props_visible(); //if (wantMouseHoverEvent()==false)
this->show_props(!bshow); {
bool bshow = this->props_visible();
this->show_props(!bshow);
}
//post enent //post enent
QMap<QString, QVariant > map_evt; QMap<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene()); geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
...@@ -96,6 +99,57 @@ namespace QTVP_GEOMARKER{ ...@@ -96,6 +99,57 @@ namespace QTVP_GEOMARKER{
} }
} }
void geoGraphicsRectItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event)
{
QGraphicsRectItem::hoverEnterEvent(event);
//this->show_props(true);
//post enent
QMap<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
if (pscene)
{
QObject * pPlg = pscene->parent();
if (pPlg)
{
qtvplugin_geomarker * pMarker = dynamic_cast<qtvplugin_geomarker *>(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<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
if (pscene)
{
QObject * pPlg = pscene->parent();
if (pPlg)
{
qtvplugin_geomarker * pMarker = dynamic_cast<qtvplugin_geomarker *>(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) void geoGraphicsRectItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event)
{ {
......
...@@ -14,7 +14,8 @@ namespace QTVP_GEOMARKER{ ...@@ -14,7 +14,8 @@ namespace QTVP_GEOMARKER{
protected: protected:
void mousePressEvent(QGraphicsSceneMouseEvent * event); void mousePressEvent(QGraphicsSceneMouseEvent * event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event);
void hoverEnterEvent(QGraphicsSceneHoverEvent * event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent * event);
public: public:
explicit geoGraphicsRectItem(QString name,QTVOSM::viewer_interface * pVi, explicit geoGraphicsRectItem(QString name,QTVOSM::viewer_interface * pVi,
qreal cent_lat = 90, qreal cent_lat = 90,
......
...@@ -256,4 +256,25 @@ namespace QTVP_GEOMARKER{ ...@@ -256,4 +256,25 @@ namespace QTVP_GEOMARKER{
m_pSelectionBound->setRect(pc->boundingRect()); m_pSelectionBound->setRect(pc->boundingRect());
} }
} }
bool geoItemBase::wantMouseHoverEvent()
{
QGraphicsItem * pc = dynamic_cast<QGraphicsItem *> (this);
if (pc)
{
return pc->acceptHoverEvents();
}
return false;
}
void geoItemBase::setWantMouseHoverEvent(bool w)
{
QGraphicsItem * pc = dynamic_cast<QGraphicsItem *> (this);
if (pc)
{
pc->setAcceptHoverEvents(w);
}
}
} }
...@@ -80,6 +80,8 @@ namespace QTVP_GEOMARKER{ ...@@ -80,6 +80,8 @@ namespace QTVP_GEOMARKER{
void setLabelColor (QColor col) {m_LabelTextColor = col;if (m_pLabelItem) m_pLabelItem->setDefaultTextColor(m_LabelTextColor);} void setLabelColor (QColor col) {m_LabelTextColor = col;if (m_pLabelItem) m_pLabelItem->setDefaultTextColor(m_LabelTextColor);}
QColor labelColor () {return m_LabelTextColor;} QColor labelColor () {return m_LabelTextColor;}
void adjustLabelPos (); void adjustLabelPos ();
bool wantMouseHoverEvent();
void setWantMouseHoverEvent(bool );
QStringList prop_names(); QStringList prop_names();
QVariantList prop_values(); QVariantList prop_values();
......
...@@ -610,7 +610,28 @@ bool qtvplugin_geomarker::cb_mouseMoveEvent ( QMouseEvent * e ) ...@@ -610,7 +610,28 @@ bool qtvplugin_geomarker::cb_mouseMoveEvent ( QMouseEvent * e )
//Warp //Warp
while (wx < 0) wx += winsz; while (wx < 0) wx += winsz;
while (wx > winsz-1) 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<QWidget *> (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 //tools
switch (m_currentTools) switch (m_currentTools)
{ {
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>538</width> <width>547</width>
<height>424</height> <height>465</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -150,8 +150,8 @@ ...@@ -150,8 +150,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>165</width> <width>160</width>
<height>225</height> <height>194</height>
</rect> </rect>
</property> </property>
<attribute name="icon"> <attribute name="icon">
...@@ -194,8 +194,8 @@ ...@@ -194,8 +194,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>166</width> <width>174</width>
<height>220</height> <height>186</height>
</rect> </rect>
</property> </property>
<attribute name="icon"> <attribute name="icon">
...@@ -304,6 +304,13 @@ ...@@ -304,6 +304,13 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="checkBox_QTV_acceptHoverEvent">
<property name="text">
<string>Accept &quot;Hover&quot; Event(Slow!)</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
...@@ -344,7 +351,7 @@ ...@@ -344,7 +351,7 @@
<string>Delete</string> <string>Delete</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="resources.qrc"> <iconset resource="../qtvplugin_grid/resources.qrc">
<normaloff>:/icons/delete-21.png</normaloff>:/icons/delete-21.png</iconset> <normaloff>:/icons/delete-21.png</normaloff>:/icons/delete-21.png</iconset>
</property> </property>
</widget> </widget>
...@@ -703,7 +710,7 @@ ...@@ -703,7 +710,7 @@
<string>add</string> <string>add</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="resources.qrc"> <iconset resource="../qtvplugin_grid/resources.qrc">
<normaloff>:/icons/Add to favourites.png</normaloff>:/icons/Add to favourites.png</iconset> <normaloff>:/icons/Add to favourites.png</normaloff>:/icons/Add to favourites.png</iconset>
</property> </property>
</widget> </widget>
...@@ -1050,7 +1057,7 @@ ...@@ -1050,7 +1057,7 @@
<string>Delete Prop</string> <string>Delete Prop</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="resources.qrc"> <iconset resource="../qtvplugin_grid/resources.qrc">
<normaloff>:/icons/delete-21.png</normaloff>:/icons/delete-21.png</iconset> <normaloff>:/icons/delete-21.png</normaloff>:/icons/delete-21.png</iconset>
</property> </property>
</widget> </widget>
...@@ -1079,6 +1086,7 @@ ...@@ -1079,6 +1086,7 @@
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="../qtvplugin_grid/resources.qrc"/>
<include location="resources.qrc"/> <include location="resources.qrc"/>
</resources> </resources>
<connections/> <connections/>
......
...@@ -261,6 +261,15 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_point (const QMap<QStr ...@@ -261,6 +261,15 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_point (const QMap<QStr
} }
else else
newitem->setLabelColor(m_default_style.text_color); newitem->setLabelColor(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(); //scheduleRefreshMarks();
scheduleUpdateMap(); scheduleUpdateMap();
} }
...@@ -366,6 +375,13 @@ QMap<QString, QVariant> qtvplugin_geomarker:: func_update_icon (const QMap<QSt ...@@ -366,6 +375,13 @@ QMap<QString, QVariant> qtvplugin_geomarker:: func_update_icon (const QMap<QSt
} }
else else
newitem->setLabelColor( m_default_style.text_color); newitem->setLabelColor( 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(); //scheduleRefreshMarks();
scheduleUpdateMap(); scheduleUpdateMap();
} }
...@@ -482,6 +498,13 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_line (const QMap<QStr ...@@ -482,6 +498,13 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_line (const QMap<QStr
} }
else else
newitem->setLabelColor(m_default_style.text_color); newitem->setLabelColor(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(); //scheduleRefreshMarks();
scheduleUpdateMap(); scheduleUpdateMap();
} }
...@@ -669,6 +692,13 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS ...@@ -669,6 +692,13 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS
} }
else else
newitem->setLabelColor(m_default_style.text_color); newitem->setLabelColor(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(); //scheduleRefreshMarks();
scheduleUpdateMap(); scheduleUpdateMap();
} }
...@@ -1044,6 +1074,10 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_mark (const QMap<QString, ...@@ -1044,6 +1074,10 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_mark (const QMap<QString,
int weight = item->labelFont().weight(); int weight = item->labelFont().weight();
res["weight_label"] = QString("%1").arg(weight); res["weight_label"] = QString("%1").arg(weight);
bool want_hover = item->wantMouseHoverEvent();
res["want_hover"] = QString("%1").arg(want_hover?1:0);
} }
else else
res["error"] = tr("the mark name.") + name + tr(" does not exist in current scene."); res["error"] = tr("the mark name.") + name + tr(" does not exist in current scene.");
......
...@@ -178,6 +178,7 @@ void qtvplugin_geomarker::ini_save() ...@@ -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_rotate",ui->lineEdit_QTV_icon_rotate->text());
settings.setValue("ui/lineEdit_QTV_icon_scale",ui->lineEdit_QTV_icon_scale->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_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() void qtvplugin_geomarker::ini_load()
...@@ -273,6 +274,8 @@ 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(); int checkBox_QTV_multiline = settings.value("ui/checkBox_QTV_multiline",0).toInt();
ui->checkBox_QTV_multiline->setChecked(checkBox_QTV_multiline?true:false); 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() ...@@ -526,8 +529,7 @@ void qtvplugin_geomarker::on_pushButton_QTV_update_clicked()
f.setWeight(fontWeight); f.setWeight(fontWeight);
newitem->setLabelFont(f); newitem->setLabelFont(f);
newitem->setLabelColor(textColor); newitem->setLabelColor(textColor);
newitem->setWantMouseHoverEvent(ui->checkBox_QTV_acceptHoverEvent->isChecked());
} }
scheduleRefreshMarks(); scheduleRefreshMarks();
m_pVi->UpdateWindow(); m_pVi->UpdateWindow();
...@@ -764,6 +766,9 @@ void qtvplugin_geomarker::refreshItemUI(QString markname) ...@@ -764,6 +766,9 @@ void qtvplugin_geomarker::refreshItemUI(QString markname)
int weight = item->labelFont().weight(); int weight = item->labelFont().weight();
ui->spinBox_QTV_textWeight->setValue(weight); ui->spinBox_QTV_textWeight->setValue(weight);
bool bwant_hover = item->wantMouseHoverEvent();
ui->checkBox_QTV_acceptHoverEvent->setChecked(bwant_hover);
refreshProps(item); refreshProps(item);
}//end if item }//end if item
......
...@@ -57,8 +57,7 @@ bool qtvplugin_geomarker::xml_save(QString xml) ...@@ -57,8 +57,7 @@ bool qtvplugin_geomarker::xml_save(QString xml)
stream.writeTextElement("style_pen",QString("%1").arg(int(pU->pen().style()))); stream.writeTextElement("style_pen",QString("%1").arg(int(pU->pen().style())));
stream.writeTextElement("width_pen",QString("%1").arg(int(pU->pen().width()))); stream.writeTextElement("width_pen",QString("%1").arg(int(pU->pen().width())));
stream.writeTextElement("color_brush",color2string(pU->brush().color())); 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; break;
...@@ -186,7 +185,7 @@ bool qtvplugin_geomarker::xml_save(QString xml) ...@@ -186,7 +185,7 @@ bool qtvplugin_geomarker::xml_save(QString xml)
int weight = item->labelFont().weight(); int weight = item->labelFont().weight();
stream.writeTextElement("weight_label",QString("%1").arg(weight)); stream.writeTextElement("weight_label",QString("%1").arg(weight));
stream.writeTextElement("want_hover",QString("%1").arg(item->wantMouseHoverEvent()==true?1:0));
stream.writeEndElement(); // style stream.writeEndElement(); // style
//1.2 properties //1.2 properties
...@@ -490,6 +489,8 @@ bool qtvplugin_geomarker::xml_update_mark(tag_xml_mark & mark) ...@@ -490,6 +489,8 @@ bool qtvplugin_geomarker::xml_update_mark(tag_xml_mark & mark)
{ {
newitem->set_prop_data(p.key(),p.value()); newitem->set_prop_data(p.key(),p.value());
} }
bool bWantHover = mark.styles["want_hover"].toInt()!=0?true:false;
newitem->setWantMouseHoverEvent(bWantHover);
} }
......
...@@ -301,7 +301,7 @@ void testcontainer::on_pushButton_QTV_test_mark_clicked() ...@@ -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_pen=2;color_pen=0,0,255,128;width_pen=3;"
"style_brush=1;color_brush=0,255,0,128;" "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;"
"width=16;height=20;") "width=16;height=20;want_hover=1;")
.arg(rand()%1700/10.0-85) .arg(rand()%1700/10.0-85)
.arg(rand()%3600/10.0-180) .arg(rand()%3600/10.0-180)
).toString(); ).toString();
...@@ -371,7 +371,7 @@ void testcontainer::on_pushButton_QTV_test_line_clicked() ...@@ -371,7 +371,7 @@ void testcontainer::on_pushButton_QTV_test_line_clicked()
"lat0=%1;lon0=%2;" "lat0=%1;lon0=%2;"
"lat1=%3;lon1=%4;" "lat1=%3;lon1=%4;"
"style_pen=4;color_pen=255,0,0,96;" "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()%1700/10.0-85)
.arg(rand()%3600/10.0-180) .arg(rand()%3600/10.0-180)
.arg(rand()%1700/10.0-85) .arg(rand()%1700/10.0-85)
......
...@@ -266,7 +266,7 @@ void testcontainer::on_pushButton_QTV_test_mark_clicked() ...@@ -266,7 +266,7 @@ void testcontainer::on_pushButton_QTV_test_mark_clicked()
"lat=%1;lon=%2;" "lat=%1;lon=%2;"
"style_pen=2;color_pen=0,0,255,128;width_pen=3;" "style_pen=2;color_pen=0,0,255,128;width_pen=3;"
"style_brush=1;color_brush=0,255,0,128;" "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;") "width=16;height=20;")
.arg(rand()%1700/10.0-85) .arg(rand()%1700/10.0-85)
.arg(rand()%3600/10.0-180) .arg(rand()%3600/10.0-180)
...@@ -337,7 +337,7 @@ void testcontainer::on_pushButton_QTV_test_line_clicked() ...@@ -337,7 +337,7 @@ void testcontainer::on_pushButton_QTV_test_line_clicked()
"lat0=%1;lon0=%2;" "lat0=%1;lon0=%2;"
"lat1=%3;lon1=%4;" "lat1=%3;lon1=%4;"
"style_pen=4;color_pen=255,0,0,96;" "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()%1700/10.0-85)
.arg(rand()%3600/10.0-180) .arg(rand()%3600/10.0-180)
.arg(rand()%1700/10.0-85) .arg(rand()%1700/10.0-85)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册