void FGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent) { QGraphicsItem * item = this->itemAt(helpEvent->scenePos()); if (item == NULL) return; QString text; QPoint point; ItemBase * itemBase = dynamic_cast<ItemBase *>(item); if (itemBase == NULL) { ConnectorItem * connectorItem = dynamic_cast<ConnectorItem *>(item); if (connectorItem) { connectorItem->updateTooltip(); } } else { itemBase->updateTooltip(); } if (!item->toolTip().isEmpty()) { text = item->toolTip(); point = helpEvent->screenPos(); } // Show or hide the tooltip QToolTip::showText(point, text); }
void AxisInteractor::showContextMenu(const QPoint &pos) { QPoint globalPos = this->mapToGlobal(pos); QList<QGraphicsItem *> list = this->scene->items(); for (int i = 0; i < list.count(); ++i) { QGraphicsItem *item = list.at(i); if (item->type() == IndicatorItemType) { if (item->isUnderMouse()) { item->setSelected(false); this->createContextMenu(); QAction *selectedItem = this->indicatorContextMenu->exec(globalPos); if (selectedItem) { if (QString("Delete") == selectedItem->text()) { this->scene->removeItem(item); emit this->deleteIndicator(item->toolTip()); } if (QString("Hide") == selectedItem->text()) { bool isVisible = !selectedItem->isChecked(); emit this->showOrHideIndicator(isVisible, item->toolTip()); static_cast<Indicator *>(item)->changeIndicatorColor(isVisible); } } } } } }
void AxisInteractor::getIndicator() { QList<QGraphicsItem *> list = this->scene->selectedItems(); if (1 == list.size()) { QGraphicsItem *item = list.at(0); if (item->type() == IndicatorItemType) { emit this->indicatorSelected(item->toolTip()); } } }
void AxisInteractor::selectIndicator(const QString &name) { this->clearSelections(); QList<QGraphicsItem *> list = this->scene->items(); for (int i = 0; i < list.count(); ++i) { QGraphicsItem *item = list.at(i); if (item->type() == IndicatorItemType) { if (item->toolTip() == name) { item->setSelected(true); } } } }
void GalaGV::onSelectionChanged() { QList<QGraphicsItem*> l = scene()->selectedItems(); if(!l.isEmpty()){ QGraphicsItem *i = l.first(); QString t; if(mData->gate != NULL){ int d = clacDis(i->data(Cords).toString(),mData->gate->data(Cords).toString()); d=d/5; int h =0; if(d>59) h = d/60; t = QString::number(h)+"h:"+QString::number(d%60)+"min "; } mLabelInfo->setText(t+i->toolTip()); } }