Пример #1
0
void WidgetInspectorWidget::analyzePainting()
{
  m_inspector->analyzePainting();

  PaintBufferViewer *viewer = new PaintBufferViewer(QStringLiteral("com.kdab.GammaRay.WidgetPaintAnalyzer"), this);
  viewer->show();
}
Пример #2
0
void GammaRay::QuickInspectorWidget::itemContextMenu(const QPoint& pos)
{
  const QModelIndex index = ui->itemTreeView->indexAt(pos);
  if (!index.isValid()) {
    return;
  }

  QMenu contextMenu;

  const auto sourceFile = index.data(QuickItemModelRole::SourceFileRole).toString();
  if (!sourceFile.isEmpty() && UiIntegration::instance()) {
    QAction *action = contextMenu.addAction(tr("Show Code: %1:%2:%3").
      arg(sourceFile,
          index.data(QuickItemModelRole::SourceLineRole).toString(),
          index.data(QuickItemModelRole::SourceColumnRole).toString()));
    action->setData(QuickItemAction::NavigateToCode);
  }

  if (index.sibling(index.row(), 0).data(QuickItemModelRole::ItemActions).value<QuickItemActions>() & QuickItemAction::AnalyzePainting) {
    auto action = contextMenu.addAction(tr("Analyze Painting..."));
    action->setData(QuickItemAction::AnalyzePainting);
  }

  const auto objectId = index.data(ObjectModel::ObjectIdRole).value<ObjectId>();
  ContextMenuExtension ext(objectId);
  ext.populateMenu(&contextMenu);

  if (QAction *action = contextMenu.exec(ui->itemTreeView->viewport()->mapToGlobal(pos))) {
    UiIntegration *integ = 0;
    switch (action->data().toInt()) {
      case QuickItemAction::NavigateToCode:
        integ = UiIntegration::instance();
        emit integ->navigateToCode(sourceFile,
                                   index.data(QuickItemModelRole::SourceLineRole).toInt(),
                                   index.data(QuickItemModelRole::SourceColumnRole).toInt());
        break;
      case QuickItemAction::AnalyzePainting:
        m_interface->analyzePainting();
        PaintBufferViewer *viewer = new PaintBufferViewer(QStringLiteral("com.kdab.GammaRay.QuickPaintAnalyzer"), this);
        viewer->show();
        break;
    }
  }
}