BlockView changes: fixed right-click while selecting, new signal "selectionChanged()"

This commit is contained in:
2020-09-09 19:07:02 +03:00
parent bfa1e4af38
commit 8812ad1c37
2 changed files with 12 additions and 3 deletions

View File

@@ -213,7 +213,12 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
match_bus = bus_from = 0; match_bus = bus_from = 0;
hpin = 0; hpin = 0;
copy_dp = QPointF(); copy_dp = QPointF();
//qDebug() << mm_cancel << mm_copy << mm_drag << new_branch << new_bus; //qDebug() << mm_cancel << moved << sel_rect.isVisible();
if (sel_rect.isVisible()) {
QList<QGraphicsItem*> gi = scene_->items();
foreach (QGraphicsItem * i, gi)
i->setSelected(i->data(1000).toBool());
}
if (mm_copy && mm_cancel) { if (mm_copy && mm_cancel) {
deleteCopyTemp(); deleteCopyTemp();
mm_copy = moved = false; mm_copy = moved = false;
@@ -242,7 +247,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
mm_drag = moved = false; mm_drag = moved = false;
screen_point = me->screenPos(); screen_point = me->screenPos();
scene_point = me->scenePos(); scene_point = me->scenePos();
if ((me->button() == Qt::MidButton)) { if ((me->button() == Qt::MidButton) || (me->button() == Qt::RightButton)) {
thumbShow(); thumbShow();
restartTimer(timer_thumb, thumb_hide_delay); restartTimer(timer_thumb, thumb_hide_delay);
return true; return true;
@@ -655,7 +660,7 @@ void BlockView::mousePressEvent(QMouseEvent * event) {
press_point = event->pos(); press_point = event->pos();
if (event->buttons().testFlag(Qt::MidButton) || event->buttons().testFlag(Qt::RightButton)) { if (event->buttons().testFlag(Qt::MidButton) || event->buttons().testFlag(Qt::RightButton)) {
setCursor(Qt::ClosedHandCursor); setCursor(Qt::ClosedHandCursor);
sel_rect.hide(); //sel_rect.hide();
if (sel_rect.scene()) if (sel_rect.scene())
scene_->removeItem(&sel_rect); scene_->removeItem(&sel_rect);
} }
@@ -1208,6 +1213,7 @@ void BlockView::applySelRect(QGraphicsSceneMouseEvent * me) {
QList<QGraphicsItem*> ci = sel_rect.collidingItems(Qt::IntersectsItemBoundingRect); QList<QGraphicsItem*> ci = sel_rect.collidingItems(Qt::IntersectsItemBoundingRect);
QList<QGraphicsItem*> gi = scene_->items(); QList<QGraphicsItem*> gi = scene_->items();
bool add = me->modifiers().testFlag(Qt::ControlModifier); bool add = me->modifiers().testFlag(Qt::ControlModifier);
QList<QGraphicsItem*> sil = scene_->selectedItems();
if (!add) clearSelection(); if (!add) clearSelection();
else { else {
foreach (QGraphicsItem * i, gi) foreach (QGraphicsItem * i, gi)
@@ -1216,6 +1222,8 @@ void BlockView::applySelRect(QGraphicsSceneMouseEvent * me) {
foreach (QGraphicsItem * i, ci) { foreach (QGraphicsItem * i, ci) {
i->setSelected(!i->isSelected()); i->setSelected(!i->isSelected());
} }
if (sil != scene_->selectedItems())
emit selectionChanged();
} }

View File

@@ -266,6 +266,7 @@ signals:
void connectionsChanged(); void connectionsChanged();
void copyEnabledChanged(bool); void copyEnabledChanged(bool);
void pasteEnabledChanged(bool); void pasteEnabledChanged(bool);
void selectionChanged();
}; };