From 395c65142a81fb6cb06196e7e2bb9b150cb9f8ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Wed, 14 Jun 2017 20:21:56 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/libs@235 a8b55f48-bf90-11e4-a774-851b48703e85 --- qad/graphic/graphic.cpp | 11 +++++++++++ qad/graphic/graphic.h | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/qad/graphic/graphic.cpp b/qad/graphic/graphic.cpp index 29318f0..1a31011 100644 --- a/qad/graphic/graphic.cpp +++ b/qad/graphic/graphic.cpp @@ -1356,6 +1356,7 @@ void Graphic::updateLegend() { for (int i = 0; i < graphics.size(); i++) { while (!graphics[i].pb->actions().isEmpty()) graphics[i].pb->removeAction(graphics[i].pb->actions()[0]); delete graphics[i].pb; + //qDebug() << "new legend item" << graphics[i].name; QPixmap pix(60, 22); pix.fill(back_color); QPainter p(&pix); @@ -1394,6 +1395,16 @@ void Graphic::updateLegend() { } +void Graphic::updateLegendChecks() { + for (int i = 0; i < graphics.size(); i++) { + if (!graphics[i].pb) continue; + bool pbs = graphics[i].pb->blockSignals(true); + graphics[i].pb->setChecked(graphics[i].visible); + graphics[i].pb->blockSignals(pbs); + } +} + + void Graphic::graphicVisibleChange(bool checked) { if (visible_update) return; QCheckBox * cb = qobject_cast(sender()); diff --git a/qad/graphic/graphic.h b/qad/graphic/graphic.h index 8a1688f..606b4c9 100644 --- a/qad/graphic/graphic.h +++ b/qad/graphic/graphic.h @@ -247,7 +247,7 @@ public slots: void setGraphicStyle(const Qt::PenStyle & style) {graphics[curGraphic].pen.setStyle(style); updateLegend(); if (aupdate) update();} void setGridStyle(const Qt::PenStyle & style) {grid_pen.setStyle(style); if (aupdate) update();} void setSelectionStyle(const Qt::PenStyle & style) {selpen.setStyle(style);} - void setGraphicVisible(bool visible, int index) {graphics[index].visible = visible; updateLegend(); if (aupdate) update();} + void setGraphicVisible(bool visible, int index) {graphics[index].visible = visible; updateLegendChecks(); if (aupdate) update();} void setGraphicVisible(bool visible) {setGraphicVisible(visible, curGraphic);} void setGraphicLineWidth(double w, int index) {if (qRound(w) == w) graphics[index].pen.setWidth(qRound(w)); else graphics[index].pen.setWidthF(w); updateLegend(); if (aupdate) update();} void setGraphicLineWidth(double w) {setGraphicLineWidth(w, curGraphic);} @@ -349,6 +349,7 @@ protected: void drawPause(); void drawAction(); void updateLegend(); + void updateLegendChecks(); void setCanvasCursor(QCursor cursor); void swapToBuffer(); void swapToNormal() {bufferActive = false;}