void SGSelectionTool::createContextMenu(const QList<QSGItem *> &items, QPoint pos)
{
    QMenu contextMenu;
    connect(&contextMenu, SIGNAL(hovered(QAction*)),
            this, SLOT(contextMenuElementHovered(QAction*)));

    const QList<QSGItem*> selectedItems = inspector()->selectedItems();
    int shortcutKey = Qt::Key_1;

    foreach (QSGItem *item, items) {
        const QString title = inspector()->titleForItem(item);
        QAction *elementAction = contextMenu.addAction(title);
        elementAction->setData(QVariant::fromValue(item));

        connect(elementAction, SIGNAL(triggered()), this, SLOT(contextMenuElementSelected()));

        if (selectedItems.contains(item)) {
            QFont font = elementAction->font();
            font.setBold(true);
            elementAction->setFont(font);
        }

        if (shortcutKey <= Qt::Key_9) {
            elementAction->setShortcut(QKeySequence(shortcutKey));
            shortcutKey++;
        }
    }

    contextMenu.exec(pos);
}
void SGSelectionTool::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton) {
        if (QSGItem *item = inspector()->topVisibleItemAt(event->pos()))
            inspector()->setSelectedItems(QList<QSGItem*>() << item);
    } else if (event->button() == Qt::RightButton) {
        QList<QSGItem*> items = inspector()->itemsAt(event->pos());
        createContextMenu(items, event->globalPos());
    }
}
示例#3
0
void InspectTool::selectItem()
{
    if (!inspector()->topVisibleItemAt(m_mousePosition))
        return;
    if (m_lastClickedItem == inspector()->topVisibleItemAt(m_mousePosition)) {
        m_nameDisplayTimer.start();
        return;
    }
    m_lastClickedItem = inspector()->topVisibleItemAt(m_mousePosition);
    m_lastItem = m_lastClickedItem;
    inspector()->setSelectedItems(QList<QQuickItem*>() << m_lastClickedItem);
    showSelectedItemName();
}
示例#4
0
void * queue_lookup (queue_t * queue, queue_inspector_t inspector, ...)
{
  bool result;
  va_list list, list_copy;
  queue_link_t * item = NULL;

  va_start (list, inspector);

  if (queue -> status != 0)
  {
    for (item = queue -> head; item != NULL; item = item -> next)
    {
      result = false;

      va_copy (list_copy, list);
      result = inspector (item, list_copy);
      va_end (list_copy);

      if (result) break;
    }
  }

  va_end (list);
  return item;
}
示例#5
0
void LiveSelectionTool::createContextMenu(const QList<QGraphicsItem*> &itemList, QPoint globalPos)
{
    QMenu contextMenu;
    connect(&contextMenu, SIGNAL(hovered(QAction*)),
            this, SLOT(contextMenuElementHovered(QAction*)));

    m_contextMenuItemList = itemList;

    contextMenu.addAction(tr("Items"));
    contextMenu.addSeparator();
    int shortcutKey = Qt::Key_1;
    int i = 0;

    foreach (QGraphicsItem * const item, itemList) {
        QString itemTitle = titleForItem(item);
        QAction *elementAction = contextMenu.addAction(itemTitle, this,
                                                       SLOT(contextMenuElementSelected()));

        if (inspector()->selectedItems().contains(item)) {
            QFont boldFont = elementAction->font();
            boldFont.setBold(true);
            elementAction->setFont(boldFont);
        }

        elementAction->setData(i);

        if (shortcutKey <= Qt::Key_9) {
            elementAction->setShortcut(QKeySequence(shortcutKey));
            shortcutKey++;
        }

        ++i;
    }
示例#6
0
void InspectTool::selectNextItem()
{
    if (m_lastClickedItem != inspector()->topVisibleItemAt(m_mousePosition))
        return;
    QList<QQuickItem*> items = inspector()->itemsAt(m_mousePosition);
    for (int i = 0; i < items.count(); i++) {
        if (m_lastItem == items[i]) {
            if (i + 1 < items.count())
                m_lastItem = items[i+1];
            else
                m_lastItem = items[0];
            inspector()->setSelectedItems(QList<QQuickItem*>() << m_lastItem);
            showSelectedItemName();
            break;
        }
    }
}
void SGSelectionTool::hoverMoveEvent(QMouseEvent *event)
{
    QSGItem *item = inspector()->topVisibleItemAt(event->pos());
    if (!item) {
        m_hoverHighlight->setVisible(false);
    } else {
        m_hoverHighlight->setItem(item);
        m_hoverHighlight->setVisible(true);
    }
}
示例#8
0
bool AbstractLiveEditTool::topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList)
{
    QList<QGraphicsItem*> selectedItems = inspector()->selectedItems();

    foreach (QGraphicsItem *item, itemList) {
        QDeclarativeItem *declarativeItem = toQDeclarativeItem(item);
        if (declarativeItem
                && selectedItems.contains(declarativeItem)
                /*&& (declarativeItem->qmlItemNode().hasShowContent() || selectNonContentItems)*/)
            return true;
    }
示例#9
0
void InspectTool::hoverMoveEvent(QMouseEvent *event)
{
    m_mousePosition = event->localPos();
    m_pressAndHoldTimer.stop();
    QQuickItem *item = inspector()->topVisibleItemAt(event->pos());
    if (!item || item == m_lastClickedItem) {
        m_hoverHighlight->setVisible(false);
    } else {
        m_hoverHighlight->setItem(item);
        m_hoverHighlight->setVisible(true);
    }
}
示例#10
0
bool LiveSelectionTool::alreadySelected(const QList<QGraphicsItem*> &itemList) const
{
    QDeclarativeViewInspectorPrivate *inspectorPrivate
            = QDeclarativeViewInspectorPrivate::get(inspector());
    const QList<QGraphicsItem*> selectedItems = inspectorPrivate->selectedItems();

    if (selectedItems.isEmpty())
        return false;

    foreach (QGraphicsItem *item, itemList)
        if (selectedItems.contains(item))
            return true;

    return false;
}
示例#11
0
WebString WebDevToolsAgent::disconnectEventAsText()
{
    class ChannelImpl : public InspectorFrontendChannel {
    public:
        virtual bool sendMessageToFrontend(const String& message)
        {
            m_message = message;
            return true;
        }
        String m_message;
    } channel;
#if ENABLE(WORKERS)
    InspectorFrontend::Worker inspector(&channel);
    inspector.disconnectedFromWorker();
#endif
    return channel.m_message;
}
示例#12
0
void InspectTool::enable(bool enable)
{
    if (!enable) {
        inspector()->setSelectedItems(QList<QQuickItem*>());
        // restoring the original states.
        if (m_contentItem) {
            m_contentItem->setScale(m_originalScale);
            m_contentItem->setPosition(m_originalPosition);
            m_contentItem->setSmooth(m_originalSmooth);
        }
    } else {
        if (m_contentItem) {
            m_originalSmooth = m_contentItem->smooth();
            m_originalScale = m_contentItem->scale();
            m_originalPosition = m_contentItem->position();
            m_contentItem->setSmooth(true);
        }
    }
}
示例#13
0
void LiveSelectionTool::mousePressEvent(QMouseEvent *event)
{
    QDeclarativeViewInspectorPrivate *inspectorPrivate
            = QDeclarativeViewInspectorPrivate::get(inspector());
    QList<QGraphicsItem*> itemList = inspectorPrivate->selectableItems(event->pos());
    LiveSingleSelectionManipulator::SelectionType selectionType = getSelectionType(event->modifiers());

    if (event->buttons() & Qt::LeftButton) {
        m_mousePressTimer.start();

        if (m_rubberbandSelectionMode) {
            m_rubberbandSelectionManipulator.begin(event->pos());
        } else {
            m_singleSelectionManipulator.begin(event->pos());
            m_singleSelectionManipulator.select(selectionType, m_selectOnlyContentItems);
        }
    } else if (event->buttons() & Qt::RightButton) {
        createContextMenu(itemList, event->globalPos());
    }
}
示例#14
0
    /**
     * Run analysis with the provided parameters. See IndexStatsCmd for in-depth expanation of
     * output.
     *
     * @return true on success, false otherwise
     */
    bool runInternal(const NamespaceDetails* nsd, IndexStatsParams params, string& errmsg,
                     BSONObjBuilder& result) {

        const IndexDetails* details = NULL;

        // casting away const, we are not going to modify NamespaceDetails
        // but ii() is not marked const, see SERVER-7619
        for (NamespaceDetails::IndexIterator it = const_cast<NamespaceDetails*>(nsd)->ii();
             it.more();) {
            IndexDetails& cur = it.next();
            if (cur.indexName() == params.indexName) details = &cur;
        }

        if (details == NULL) {
            errmsg = "the requested index does not exist";
            return false;
        }

        result << "index" << details->indexName()
               << "version" << details->version()
               << "isIdIndex" << details->isIdIndex()
               << "keyPattern" << details->keyPattern()
               << "storageNs" << details->indexNamespace();

        scoped_ptr<BtreeInspector> inspector(NULL);
        switch (details->version()) {
          case 1: inspector.reset(new BtreeInspectorV1(params.expandNodes)); break;
          case 0: inspector.reset(new BtreeInspectorV0(params.expandNodes)); break;
          default:
            errmsg = str::stream() << "index version " << details->version() << " is "
                                   << "not supported";
            return false;
        }

        inspector->inspect(details->head);

        inspector->stats().appendTo(result);

        return true;
    }
示例#15
0
int main(int argc, char** argv)
{
	QApplication app(argc,argv);

	QStringList args = app.arguments();
	if (args.count() < 2)
	{
		qWarning() << "Usage: qtinspector <pid>|<program> (<args>...)";
		return -1;
	}

	QProcess process;
	int targetPid = args.at(1).toInt();

	// inject the helper library
	QScopedPointer<Injector> injector;
	if (targetPid != 0)
	{
#ifdef Q_OS_UNIX
		injector.reset(new GdbLibraryInjector);
#endif
		if (!injector->inject(targetPid, injectorLibPath(), "qtInspectorInit"))
		{
			return false;
		}
	}
	else
	{
#ifdef Q_OS_UNIX
		injector.reset(new PreloadInjector);
#endif
		QStringList programArgs;
		for (int i=2; i < args.count(); i++)
		{
			programArgs << args.at(i);
		}
		if (!injector->startAndInject(args.at(1),programArgs,injectorLibPath(),"qtInspectorInit",&targetPid))
		{
			return false;
		}
	}

	TargetApplicationProxy proxy;
	if (!proxy.connectToTarget(targetPid))
	{
		qWarning() << "Failed to inject helper library into process <pid>";
	}

	WidgetPicker* picker = new ExternalWidgetPicker(&proxy,0);

	WidgetInspector inspector(&proxy);
	inspector.setWidgetPicker(picker);
	inspector.show();

	int result = app.exec();

	if (process.state() == QProcess::Running && !process.waitForFinished())
	{
		qWarning() << "Failed to wait for process" << process.pid() << "to exit";
	}

	return result;
}
void SGSelectionTool::contextMenuElementSelected()
{
    if (QSGItem *item = static_cast<QAction*>(sender())->data().value<QSGItem*>())
        inspector()->setSelectedItems(QList<QSGItem*>() << item);
}
示例#17
0
QList<QGraphicsItem*> AbstractLiveEditTool::items() const
{
    return inspector()->selectedItems();
}
示例#18
0
QDeclarativeView *AbstractLiveEditTool::view() const
{
    return inspector()->declarativeView();
}
示例#19
0
void StyleBuilderFunctions::applyValueCSSPropertySize(StyleResolverState& state, CSSValue* value)
{
    state.style()->resetPageSizeType();
    Length width;
    Length height;
    PageSizeType pageSizeType = PAGE_SIZE_AUTO;
    CSSValueListInspector inspector(value);
    switch (inspector.length()) {
    case 2: {
        // <length>{2} | <page-size> <orientation>
        if (!inspector.first()->isPrimitiveValue() || !inspector.second()->isPrimitiveValue())
            return;
        CSSPrimitiveValue* first = toCSSPrimitiveValue(inspector.first());
        CSSPrimitiveValue* second = toCSSPrimitiveValue(inspector.second());
        if (first->isLength()) {
            // <length>{2}
            if (!second->isLength())
                return;
            width = first->computeLength<Length>(state.cssToLengthConversionData());
            height = second->computeLength<Length>(state.cssToLengthConversionData());
        } else {
            // <page-size> <orientation>
            // The value order is guaranteed. See BisonCSSParser::parseSizeParameter.
            if (!getPageSizeFromName(first, second, width, height))
                return;
        }
        pageSizeType = PAGE_SIZE_RESOLVED;
        break;
    }
    case 1: {
        // <length> | auto | <page-size> | [ portrait | landscape]
        if (!inspector.first()->isPrimitiveValue())
            return;
        CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(inspector.first());
        if (primitiveValue->isLength()) {
            // <length>
            pageSizeType = PAGE_SIZE_RESOLVED;
            width = height = primitiveValue->computeLength<Length>(state.cssToLengthConversionData());
        } else {
            switch (primitiveValue->getValueID()) {
            case 0:
                return;
            case CSSValueAuto:
                pageSizeType = PAGE_SIZE_AUTO;
                break;
            case CSSValuePortrait:
                pageSizeType = PAGE_SIZE_AUTO_PORTRAIT;
                break;
            case CSSValueLandscape:
                pageSizeType = PAGE_SIZE_AUTO_LANDSCAPE;
                break;
            default:
                // <page-size>
                pageSizeType = PAGE_SIZE_RESOLVED;
                if (!getPageSizeFromName(primitiveValue, 0, width, height))
                    return;
            }
        }
        break;
    }
    default:
        return;
    }
    state.style()->setPageSizeType(pageSizeType);
    state.style()->setPageSize(LengthSize(width, height));
}
示例#20
0
/*----------------------------------------------------------------------
|       main
+---------------------------------------------------------------------*/
int
main(int argc, char** argv)
{
    if (argc < 2) {
        PrintUsageAndExit();
    }

    // init the variables
    AP4_UI32 track_id = 0;
    AP4_ByteStream* input = NULL;
    AP4_ByteStream* track_data = NULL;

    // parse the command line
    argv++;
    char* arg;
    while ((arg = *argv++)) {
        if (!strcmp(arg, "-track")) {
            if (argv[0] && argv[1] && argv[2]) {
                track_id = atoi(argv[0]);
                if (track_id == 0) PrintUsageAndExit();
                track_data =
                    new AP4_FileByteStream(argv[1],
                                           AP4_FileByteStream::STREAM_MODE_WRITE);
                argv += 2;
            } else {
                PrintUsageAndExit();
            }
        } else {
            try {
                input =
                    new AP4_FileByteStream(arg,
                                           AP4_FileByteStream::STREAM_MODE_READ);
            } catch(AP4_Exception e) {
                AP4_Debug("ERROR: cannot open input (%d)\n", e.m_Error);
                return 1;
            }
        }
    }

    // open the output
    AP4_ByteStream* output =
        new AP4_FileByteStream("-stdout",
                               AP4_FileByteStream::STREAM_MODE_WRITE);

    // create an inspector
    AP4_PrintInspector inspector(*output);

    // inspect the atoms one by one
    AP4_Atom* atom;
    //for (int i=0; i<1000; i++) {
    AP4_AtomFactory& atom_factory = AP4_AtomFactory::DefaultFactory;
    //MyTypeHandler my_type_handler;
    //atom_factory.AddTypeHandler(&my_type_handler);
    while (atom_factory.CreateAtomFromStream(*input, atom) ==
            AP4_SUCCESS) {
        atom->Inspect(inspector);
        delete atom;
    }
    //input->Seek(0);
    //}

    // inspect the track data if needed
    if ((track_id != 0) && (track_data != NULL)) {
        //DumpTrackData(file, track_id, track_data);
    }

    if (input) input->Release();
    if (output) output->Release();
    if (track_data) track_data->Release();

    return 0;
}
示例#21
0
void InspectTool::showSelectedItemName()
{
    inspector()->showSelectedItemName(m_lastItem, m_mousePosition);
}