From 6182305f754fa1cdd73de03279dbf1adbcfdd628 Mon Sep 17 00:00:00 2001 From: goldenhawking Date: Fri, 19 Jan 2018 21:07:29 +0800 Subject: [PATCH] add a item hover auto show labels function. --- qtvplugin_geomarker/qtvplugin_geomarker.cpp | 33 ++++++++++++++++++- qtvplugin_geomarker/qtvplugin_geomarker.ui | 24 +++++++++----- .../qtvplugin_geomarker_uimethods.cpp | 4 ++- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/qtvplugin_geomarker/qtvplugin_geomarker.cpp b/qtvplugin_geomarker/qtvplugin_geomarker.cpp index c46ccc6..408eafb 100644 --- a/qtvplugin_geomarker/qtvplugin_geomarker.cpp +++ b/qtvplugin_geomarker/qtvplugin_geomarker.cpp @@ -473,7 +473,38 @@ void qtvplugin_geomarker::addSelection(QRectF rectWorld) bool qtvplugin_geomarker::cb_event(const QMap para) { - return false; + if (para["source"]==this->get_name() && para["name"]=="ITEM_MOUSE_ENTER") + { + if (ui->checkBox_QTV_hoverEvt_AutoLabel->isChecked()) + { + const QString key = para["id"].toString(); + if (key.length()) + { + QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(key); + if (base) + { + base->show_props(true); + scheduleUpdateMap(); + } + } + } + } + if (para["source"]==this->get_name() && para["name"]=="ITEM_MOUSE_LEAVE") + { + if (ui->checkBox_QTV_hoverEvt_AutoLabel->isChecked()) + { + const QString key = para["id"].toString(); + if (key.length()) + { + QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(key); + if (base) + { + base->show_props(false); + scheduleUpdateMap(); + } + } + } + } return false; } /*! qtvplugin_geomarker::cb_mouseXXXEvent tranfer mouse events from main view to diff --git a/qtvplugin_geomarker/qtvplugin_geomarker.ui b/qtvplugin_geomarker/qtvplugin_geomarker.ui index 999bcd0..ff1c8c2 100644 --- a/qtvplugin_geomarker/qtvplugin_geomarker.ui +++ b/qtvplugin_geomarker/qtvplugin_geomarker.ui @@ -6,8 +6,8 @@ 0 0 - 547 - 465 + 559 + 449 @@ -128,6 +128,13 @@ + + + + Auto Collapse Labels + + + @@ -150,7 +157,7 @@ 0 0 - 160 + 173 194 @@ -194,8 +201,8 @@ 0 0 - 174 - 186 + 187 + 177 @@ -351,7 +358,7 @@ Delete - + :/icons/delete-21.png:/icons/delete-21.png @@ -710,7 +717,7 @@ add - + :/icons/Add to favourites.png:/icons/Add to favourites.png @@ -1057,7 +1064,7 @@ Delete Prop - + :/icons/delete-21.png:/icons/delete-21.png @@ -1086,7 +1093,6 @@ - diff --git a/qtvplugin_geomarker/qtvplugin_geomarker_uimethods.cpp b/qtvplugin_geomarker/qtvplugin_geomarker_uimethods.cpp index a11826e..abf5570 100644 --- a/qtvplugin_geomarker/qtvplugin_geomarker_uimethods.cpp +++ b/qtvplugin_geomarker/qtvplugin_geomarker_uimethods.cpp @@ -179,6 +179,7 @@ void qtvplugin_geomarker::ini_save() 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); + settings.setValue("ui/checkBox_QTV_hoverEvt_AutoLabel",ui->checkBox_QTV_hoverEvt_AutoLabel->isChecked()?-1:0); } void qtvplugin_geomarker::ini_load() @@ -276,7 +277,8 @@ void qtvplugin_geomarker::ini_load() int checkBox_QTV_acceptHoverEvent = settings.value("ui/checkBox_QTV_acceptHoverEvent",0).toInt(); ui->checkBox_QTV_acceptHoverEvent->setChecked(checkBox_QTV_acceptHoverEvent?true:false); -} + int checkBox_QTV_hoverEvt_AutoLabel = settings.value("ui/checkBox_QTV_hoverEvt_AutoLabel",1).toInt(); + ui->checkBox_QTV_hoverEvt_AutoLabel->setChecked(checkBox_QTV_hoverEvt_AutoLabel?true:false);} void qtvplugin_geomarker::style_save() -- GitLab