void SceneInspector::objectSelected(QObject *object, const QPoint &pos) { QWidget *widget = qobject_cast<QWidget*>(object); QGraphicsView *qgv = Util::findParentOfType<QGraphicsView>(object); if (qgv) { // TODO: select qgv->scene() first, right now this only works for a single scene QGraphicsItem *item = qgv->itemAt(widget ? widget->mapTo(qgv, pos) : pos); if (item) { sceneItemSelected(item); } } }
void CurrentTrack::mousePressEvent( QGraphicsSceneMouseEvent *event ) { if( !m_isStopped && event->modifiers() == Qt::NoModifier && event->button() == Qt::LeftButton ) { QGraphicsView *view = scene()->views().first(); QGraphicsItem *item = view->itemAt( view->mapFromScene(event->scenePos()) ); if( item == m_albumCover->graphicsItem() ) { Meta::AlbumPtr album = The::engineController()->currentTrack()->album(); if( album ) ( new CoverViewDialog( album, The::mainWindow() ) )->show(); return; } } Context::Applet::mousePressEvent( event ); }
void PickFormatter::handle(QObject * object, const QPoint & pos) { QString path = QString("WIDGET: `%1` (pos: %2, %3)") .arg(ObjectPath::objectPath(object)) .arg(pos.x()) .arg(pos.y()); m_stream << path << endl; if (m_showProperties) { print_object_props(object, m_stream); } QGraphicsView * view = dynamic_cast<QGraphicsView *>(object->parent()); if (view) { QGraphicsItem * item = view->itemAt(pos); QObject * qitem = dynamic_cast<QObject *>(item); if (item) { m_stream << "GITEM: `" << ObjectPath::graphicsItemId(item) << "` (QObject: " << (qitem != 0) << ")" << endl; if (qitem) { print_object_props(qitem, m_stream); } } } }