mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-22 14:24:13 +02:00
Report jump: show the target's whole folio, shade its texts too
Feedback on a real plan: zooming in on the end jumped to was too much. A jump now shows the target's folio whole, as a page (the view's fit), selects the target and shades it and its texts blue for three seconds, so that the eye finds the label too. One function, Element::jumpTo(), serves the double click on the arrow and on the text. The mouse pointer is not moved onto the target: Wayland does not let a program move the pointer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -785,6 +785,9 @@ void DynamicElementTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
|
||||
void DynamicElementTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
if (m_jump_highlight)
|
||||
painter->fillRect(boundingRect(), QColor(69, 137, 255, 90));
|
||||
|
||||
DiagramTextItem::paint(painter, option, widget);
|
||||
|
||||
if (m_frame)
|
||||
@@ -1635,10 +1638,18 @@ void DynamicElementTextItem::zoomToLinkedElement()
|
||||
setSelected(false);
|
||||
ungrabMouse();
|
||||
|
||||
QetGraphicsItem::showItem(zoomed_element);
|
||||
Element::jumpTo(zoomed_element);
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicElementTextItem::setJumpHighlight(bool on)
|
||||
{
|
||||
if (on == m_jump_highlight)
|
||||
return;
|
||||
m_jump_highlight = on;
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DynamicElementTextItem::parentElementRotationChanged
|
||||
* Called when the parent element is rotated
|
||||
|
||||
@@ -106,6 +106,9 @@ class DynamicElementTextItem : public DiagramTextItem
|
||||
void setInfoName(const QString &info_name);
|
||||
QString infoName() const;
|
||||
Element *linkedElementShown() const;
|
||||
/// Shaded blue for a moment: its symbol is where a jump landed
|
||||
void setJumpHighlight(bool on);
|
||||
bool isJumpHighlighted() const {return m_jump_highlight;}
|
||||
void setCompositeText(const QString &text);
|
||||
QString compositeText() const;
|
||||
void setFrame(const bool frame);
|
||||
@@ -197,6 +200,7 @@ class DynamicElementTextItem : public DiagramTextItem
|
||||
CrossRefItem *m_Xref_item = nullptr;
|
||||
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
||||
qreal m_text_width = -1;
|
||||
bool m_jump_highlight = false;
|
||||
/// The text was emptied with its alignment kept (setPlainText())
|
||||
bool m_emptied_aligned = false;
|
||||
QPointF m_initial_position;
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
#include <QCollator>
|
||||
#include <QScreen>
|
||||
#include <QTimer>
|
||||
#include <QPointer>
|
||||
#include "../diagramview.h"
|
||||
|
||||
static const QString plcTerminalKeys[] = {
|
||||
QETInformation::ELMT_PLC_T1,
|
||||
@@ -263,15 +265,58 @@ void Element::setHighlighted(bool hl)
|
||||
*/
|
||||
void Element::showAsJumpTarget()
|
||||
{
|
||||
//The symbol and its texts, so that the label jumped to is seen too
|
||||
QList<DynamicElementTextItem *> texts = dynamicTextItems();
|
||||
for (ElementTextItemGroup *group : textGroups())
|
||||
texts.append(group->texts());
|
||||
for (DynamicElementTextItem *text : std::as_const(texts))
|
||||
text->setJumpHighlight(true);
|
||||
|
||||
++m_jump_highlight;
|
||||
update();
|
||||
QTimer::singleShot(2000, this, [this]() {
|
||||
if (m_jump_highlight > 0)
|
||||
--m_jump_highlight;
|
||||
update();
|
||||
QPointer<Element> self(this);
|
||||
QTimer::singleShot(3000, this, [self]() {
|
||||
if (!self) return;
|
||||
if (self->m_jump_highlight > 0)
|
||||
--self->m_jump_highlight;
|
||||
if (self->m_jump_highlight == 0) {
|
||||
QList<DynamicElementTextItem *> texts = self->dynamicTextItems();
|
||||
for (ElementTextItemGroup *group : self->textGroups())
|
||||
texts.append(group->texts());
|
||||
for (DynamicElementTextItem *text : std::as_const(texts))
|
||||
text->setJumpHighlight(false);
|
||||
}
|
||||
self->update();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Element::jumpTo
|
||||
Go to @a target, the other end of a folio report or the master of a
|
||||
cross reference: its folio is shown whole, as a page, without zooming
|
||||
in on it, and the target and its texts are shaded blue for a moment,
|
||||
so that the eye finds it on the page.
|
||||
(The mouse pointer cannot be put on it: Wayland does not let a program
|
||||
move the pointer.)
|
||||
*/
|
||||
void Element::jumpTo(Element *target)
|
||||
{
|
||||
if (!target || !target->diagram())
|
||||
return;
|
||||
Diagram *diagram = target->diagram();
|
||||
diagram->showMe();
|
||||
diagram->clearSelection();
|
||||
target->setSelected(true);
|
||||
for (QGraphicsView *view : diagram->views())
|
||||
{
|
||||
if (auto *diagram_view = qobject_cast<DiagramView *>(view))
|
||||
diagram_view->zoomFit();
|
||||
else
|
||||
view->fitInView(diagram->sceneRect(), Qt::KeepAspectRatio);
|
||||
}
|
||||
target->showAsJumpTarget();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Element::jumpTarget
|
||||
@return the element a double click on this one jumps to: the other end
|
||||
@@ -2402,7 +2447,7 @@ void Element::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||
//move when the target is in the same scene as this.
|
||||
setSelected(false);
|
||||
ungrabMouse();
|
||||
QetGraphicsItem::showItem(target);
|
||||
jumpTo(target);
|
||||
return;
|
||||
}
|
||||
QetGraphicsItem::mouseDoubleClickEvent(event);
|
||||
|
||||
@@ -179,6 +179,7 @@ class Element : public QetGraphicsItem
|
||||
void showAsJumpTarget();
|
||||
bool isShownAsJumpTarget() const { return m_jump_highlight > 0; }
|
||||
Element *jumpTarget() const;
|
||||
static void jumpTo(Element *target);
|
||||
void displayHelpLine(bool b = true);
|
||||
QSize size() const;
|
||||
QPixmap pixmap();
|
||||
|
||||
Reference in New Issue
Block a user