コード例 #1
0
QtFlickProvider::QtFlickProvider(QQuickWebView* viewItem, QQuickWebPage* pageItem)
    : QObject(viewItem)
{
    ASSERT(viewItem);
    ASSERT(pageItem);

    QDeclarativeEngine* engine = qmlEngine(viewItem);
    QDeclarativeContext* context = qmlContext(viewItem);

    ASSERT(engine);
    ASSERT(context);

    QDeclarativeComponent component(engine, viewItem);

    // Create the internal Flickable instance dynamically.
    // We only use public QML API so that we do not depend
    // on private API of the QtDeclarative module.
    component.setData(QByteArrayLiteral("import QtQuick 2.0\nFlickable {}"), QUrl());

    m_flickable = qobject_cast<QQuickItem*>(component.create(context));

    QMetaProperty content = resolveMetaProperty(m_flickable, "contentItem");
    m_contentItem = content.read(m_flickable).value<QQuickItem*>();
    ASSERT(m_contentItem);

    // Resolve meta methods and properties of the Flickable instance.
    m_returnToBoundsMethod = resolveMetaMethod(m_flickable, "returnToBounds()");
    m_cancelFlickMethod = resolveMetaMethod(m_flickable, "cancelFlick()");

    m_contentWidth = resolveMetaProperty(m_flickable, "contentWidth");
    m_contentHeight = resolveMetaProperty(m_flickable, "contentHeight");
    m_contentX = resolveMetaProperty(m_flickable, "contentX");
    m_contentY = resolveMetaProperty(m_flickable, "contentY");
    m_moving = resolveMetaProperty(m_flickable, "moving");
    m_dragging = resolveMetaProperty(m_flickable, "dragging");
    m_flicking = resolveMetaProperty(m_flickable, "flicking");

    m_flickableData = resolveMetaProperty(m_flickable, "flickableData");

    // Set the viewItem as the parent of the flickable instance
    // and reparent the page so it is placed on the flickable contentItem.
    m_flickable->setParentItem(viewItem);
    pageItem->setParentItem(m_contentItem);

    // Propagate flickable signals.
    connect(m_flickable, SIGNAL(movementStarted()), SIGNAL(movementStarted()), Qt::DirectConnection);
    connect(m_flickable, SIGNAL(movementEnded()), SIGNAL(movementEnded()), Qt::DirectConnection);
    connect(m_flickable, SIGNAL(flickingChanged()), SIGNAL(flickingChanged()), Qt::DirectConnection);
    connect(m_flickable, SIGNAL(draggingChanged()), SIGNAL(draggingChanged()), Qt::DirectConnection);
    connect(m_flickable, SIGNAL(contentWidthChanged()), SIGNAL(contentWidthChanged()), Qt::DirectConnection);
    connect(m_flickable, SIGNAL(contentHeightChanged()), SIGNAL(contentHeightChanged()), Qt::DirectConnection);
    connect(m_flickable, SIGNAL(contentXChanged()), SIGNAL(contentXChanged()), Qt::DirectConnection);
    connect(m_flickable, SIGNAL(contentYChanged()), SIGNAL(contentYChanged()), Qt::DirectConnection);
}
コード例 #2
0
ファイル: hexview.cpp プロジェクト: hempnall/QHexTools
void HexView::setContentWidth(int contentWidth)
{
    if (contentWidth != contentWidth_ ) {
        contentWidth_ = contentWidth;
        emit contentWidthChanged();
    }
}
コード例 #3
0
ファイル: viewport.cpp プロジェクト: diegohcg/Quasi-Engine
void Viewport::setContentWidth(const float &contentWidth)
{
    if (m_contentWidth != contentWidth) {
        m_contentWidth = contentWidth;

        emit contentWidthChanged();
    }
}
コード例 #4
0
ファイル: qquickpane.cpp プロジェクト: 2gis/2gisqt5android
void QQuickPane::setContentWidth(qreal width)
{
    Q_D(QQuickPane);
    if (d->contentWidth != width) {
        d->contentWidth = width;
        emit contentWidthChanged();
    }
}
コード例 #5
0
void BooksListWatcher::setListView(QQuickItem* aView)
{
    if (iListView != aView) {
        const QSize oldSize(iSize);
        if (iListView) iListView->disconnect(this);
        iListView = aView;
        if (iListView) {
            connect(iListView,
                SIGNAL(widthChanged()),
                SLOT(onWidthChanged()));
            connect(iListView,
                SIGNAL(heightChanged()),
                SLOT(onHeightChanged()));
            connect(iListView,
                SIGNAL(contentXChanged()),
                SLOT(onContentXChanged()));
            connect(iListView,
                SIGNAL(contentYChanged()),
                SLOT(onContentYChanged()));
            connect(iListView,
                SIGNAL(contentWidthChanged()),
                SLOT(onContentSizeChanged()));
            connect(iListView,
                SIGNAL(contentHeightChanged()),
                SLOT(onContentSizeChanged()));
            iContentX = contentX();
            iContentY = contentY();
            updateCurrentIndex();
        } else {
            iContentX = iContentY = 0;
            iSize = QSize(0,0);
        }
        Q_EMIT listViewChanged();
        if (oldSize != iSize) {
            Q_EMIT sizeChanged();
        }
        if (oldSize.width() != iSize.width()) {
            Q_EMIT widthChanged();
        }
        if (oldSize.height() != iSize.height()) {
            Q_EMIT heightChanged();
        }
    }
}