提交 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{
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<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
......@@ -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)
{
QGraphicsEllipseItem::mouseDoubleClickEvent(event);
......
......@@ -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,
......
......@@ -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<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
......@@ -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)
{
QGraphicsLineItem::mouseDoubleClickEvent(event);
......
......@@ -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,
......
......@@ -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<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
......@@ -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)
{
QGraphicsPathItem::mouseDoubleClickEvent(event);
......
......@@ -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
......
......@@ -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<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)
{
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<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
......
......@@ -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,
......
......@@ -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<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
......@@ -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)
{
QGraphicsPolygonItem::mouseDoubleClickEvent(event);
......
......@@ -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
......
......@@ -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<QString, QVariant > map_evt;
geoGraphicsScene * pscene = dynamic_cast<geoGraphicsScene *>(this->scene());
......@@ -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)
{
......
......@@ -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,
......
......@@ -256,4 +256,25 @@ namespace QTVP_GEOMARKER{
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{
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();
......
......@@ -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<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
switch (m_currentTools)
{
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>538</width>
<height>424</height>
<width>547</width>
<height>465</height>
</rect>
</property>
<property name="windowTitle">
......@@ -150,8 +150,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>165</width>
<height>225</height>
<width>160</width>
<height>194</height>
</rect>
</property>
<attribute name="icon">
......@@ -194,8 +194,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>166</width>
<height>220</height>
<width>174</width>
<height>186</height>
</rect>
</property>
<attribute name="icon">
......@@ -304,6 +304,13 @@
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_QTV_acceptHoverEvent">
<property name="text">
<string>Accept &quot;Hover&quot; Event(Slow!)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......@@ -344,7 +351,7 @@
<string>Delete</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../qtvplugin_grid/resources.qrc">
<normaloff>:/icons/delete-21.png</normaloff>:/icons/delete-21.png</iconset>
</property>
</widget>
......@@ -703,7 +710,7 @@
<string>add</string>
</property>
<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>
</property>
</widget>
......@@ -1050,7 +1057,7 @@
<string>Delete Prop</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../qtvplugin_grid/resources.qrc">
<normaloff>:/icons/delete-21.png</normaloff>:/icons/delete-21.png</iconset>
</property>
</widget>
......@@ -1079,6 +1086,7 @@
</layout>
</widget>
<resources>
<include location="../qtvplugin_grid/resources.qrc"/>
<include location="resources.qrc"/>
</resources>
<connections/>
......
......@@ -261,6 +261,15 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_point (const QMap<QStr
}
else
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();
scheduleUpdateMap();
}
......@@ -366,6 +375,13 @@ QMap<QString, QVariant> qtvplugin_geomarker:: func_update_icon (const QMap<QSt
}
else
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();
scheduleUpdateMap();
}
......@@ -482,6 +498,13 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_line (const QMap<QStr
}
else
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();
scheduleUpdateMap();
}
......@@ -669,6 +692,13 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS
}
else
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();
scheduleUpdateMap();
}
......@@ -1044,6 +1074,10 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_mark (const QMap<QString,
int weight = item->labelFont().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.");
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册