/*!
    \internal
*/
void QDeclarativeGeoMapItemBase::afterChildrenChanged()
{
    QList<QQuickItem *> kids = childItems();
    if (kids.size() > 0) {
        bool printedWarning = false;
        foreach (QQuickItem *i, kids) {
            if (i->flags() & QQuickItem::ItemHasContents
                    && !qobject_cast<QDeclarativeGeoMapMouseArea *>(i)) {
                if (!printedWarning) {
                    qmlInfo(this) << "Geographic map items do not support child items";
                    printedWarning = true;
                }

                qmlInfo(i) << "deleting this child";
                i->deleteLater();
            }
        }
    }
Example #2
0
bool QSGAnchorsPrivate::checkVAnchorValid(QSGAnchorLine anchor) const
{
    if (!anchor.item) {
        qmlInfo(item) << QSGAnchors::tr("Cannot anchor to a null item.");
        return false;
    } else if (anchor.anchorLine & QSGAnchorLine::Horizontal_Mask) {
        qmlInfo(item) << QSGAnchors::tr("Cannot anchor a vertical edge to a horizontal edge.");
        return false;
    } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){
        qmlInfo(item) << QSGAnchors::tr("Cannot anchor to an item that isn't a parent or sibling.");
        return false;
    } else if (anchor.item == item){
        qmlInfo(item) << QSGAnchors::tr("Cannot anchor item to self.");
        return false;
    }

    return true;
}
QDeclarativeGeoRoute *QDeclarativeGeoRouteModel::get(int index)
{
    if (index < 0 || index >= routes_.count()) {
        qmlInfo(this) << QStringLiteral("Error, invalid index for get():")
                      << index;
        return 0;
    }
    return routes_.at(index);
}
Example #4
0
/*!
    \qmlmethod ListModel::insert(int index, jsobject dict)

    Adds a new item to the list model at position \a index, with the
    values in \a dict.

    \code
        fruitModel.insert(2, {"cost": 5.95, "name":"Pizza"})
    \endcode

    The \a index must be to an existing item in the list, or one past
    the end of the list (equivalent to append).

    \sa set() append()
*/
void QDeclarativeListModel::insert(int index, const QScriptValue& valuemap)
{
    if (!valuemap.isObject() || valuemap.isArray()) {
        qmlInfo(this) << tr("insert: value is not an object");
        return;
    }

    if (index < 0 || index > count()) {
        qmlInfo(this) << tr("insert: index %1 out of range").arg(index);
        return;
    }

    bool ok = m_flat ?  m_flat->insert(index, valuemap) : m_nested->insert(index, valuemap);
    if (ok && !inWorkerThread()) {
        emit itemsInserted(index, 1);
        emit countChanged();
    }
}
Example #5
0
/*!
    \qmlmethod ListModel::append(jsobject dict)

    Adds a new item to the end of the list model, with the
    values in \a dict.

    \code
        fruitModel.append({"cost": 5.95, "name":"Pizza"})
    \endcode

    \sa set() remove()
*/
void QDeclarativeListModel::append(const QScriptValue& valuemap)
{
    if (!valuemap.isObject() || valuemap.isArray()) {
        qmlInfo(this) << tr("append: value is not an object");
        return;
    }

    insert(count(), valuemap);
}
void QDeclarativeGraphicsGeoMap::pan(int dx, int dy)
{
    if (mapData_) {
        mapData_->pan(dx, dy);
        update();
    } else {
        qmlInfo(this) << tr("Map plugin is not set, cannot pan.");
    }
}
void DefaultWidgetContainer::setLayout(QLayout *layout)
{
  if (m_widget->layout()) {
    qmlInfo(m_widget) << "Cannot add a second layout";
    return;
  }

  m_widget->setLayout(layout);
}
/*!    
    Takes a screen shot of \link target\endlink, and returns true if the screen shot is successfully saved 
    to \link fileName\endlink.
*/
bool QchScreenShot::grab() {
    Q_D(QchScreenShot);
    d->pixmap = QPixmap();
    
    QObject *obj = target();
    
    if (obj) {
        if (obj->isWidgetType()) {
            QWidget *widget = qobject_cast<QWidget*>(obj);
            
            if (widget) {
                d->pixmap = QPixmap::grabWidget(widget, targetX(), targetY(), targetWidth(), targetHeight());
            }
        }
        else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(obj)) {
            QRect rect = go->boundingRect().toRect();
            rect.moveLeft(qMax(0, targetX()));
            rect.moveTop(qMax(0, targetY()));
            rect.setWidth(qBound(1, targetWidth(), rect.width()));
            rect.setHeight(qBound(1, targetHeight(), rect.height()));
            
            QStyleOptionGraphicsItem styleOption;
            styleOption.rect = rect;
            
            d->pixmap = QPixmap(rect.size());
            d->pixmap.fill(Qt::transparent);
            
            QPainter painter(&d->pixmap);
            go->paint(&painter, &styleOption);
        }
        else {
            qmlInfo(this) << tr("Target must be a visual item.");
            return false;
        }
    }
    else {
        d->pixmap = QPixmap::grabWindow(QApplication::desktop()->winId(), targetX(), targetY(), targetWidth(),
                                        targetHeight());
    }

    if (!d->pixmap.isNull()) {
        QString name = d->getFileName();

        if (!name.isEmpty()) {
            setFileName(name);

            if ((width() > 0) && (height() > 0)) {
                d->pixmap = d->pixmap.scaled(width(), height(), Qt::IgnoreAspectRatio,
                                             smooth() ? Qt::SmoothTransformation : Qt::FastTransformation);
            }

            return d->pixmap.save(name);
        }
    }

    return false;
}
void QDeclarativeStateGroupPrivate::setCurrentStateInternal(const QString &state, 
                                                   bool ignoreTrans)
{
    Q_Q(QDeclarativeStateGroup);
    if (!componentComplete) {
        currentState = state;
        return;
    }

    if (applyingState) {
        qmlInfo(q) << "Can't apply a state change as part of a state definition.";
        return;
    }

    applyingState = true;

    QDeclarativeTransition *transition = (ignoreTrans || ignoreTrans) ? 0 : findTransition(currentState, state);
    if (stateChangeDebug()) {
        qWarning() << this << "Changing state.  From" << currentState << ". To" << state;
        if (transition)
            qWarning() << "   using transition" << transition->fromState() 
                       << transition->toState();
    }

    QDeclarativeState *oldState = 0;
    if (!currentState.isEmpty()) {
        for (int ii = 0; ii < states.count(); ++ii) {
            if (states.at(ii)->name() == currentState) {
                oldState = states.at(ii);
                break;
            }
        }
    }

    currentState = state;
    emit q->stateChanged(currentState);

    QDeclarativeState *newState = 0;
    for (int ii = 0; ii < states.count(); ++ii) {
        if (states.at(ii)->name() == currentState) {
            newState = states.at(ii);
            break;
        }
    }

    if (oldState == 0 || newState == 0) {
        if (!nullState) { nullState = new QDeclarativeState; QDeclarative_setParent_noEvent(nullState, q); }
        if (!oldState) oldState = nullState;
        if (!newState) newState = nullState;
    }

    newState->apply(q, transition, oldState);
    applyingState = false;
    if (!transition)
        static_cast<QDeclarativeStatePrivate*>(QObjectPrivate::get(newState))->complete();
}
void QDeclarativePolylineMapItem::removeCoordinate(const QGeoCoordinate &coordinate)
{
    int index = path_.lastIndexOf(coordinate);

    if (index == -1) {
        qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, COORD_NOT_BELONG_TO).arg("PolylineMapItem");
        return;
    }

    if (path_.count() < index + 1) {
        qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, COORD_NOT_BELONG_TO).arg("PolylineMapItem");
        return;
    }
    path_.removeAt(index);

    geometry_.markSourceDirty();
    updateMapItem();
    emit pathChanged();
}
/*!
    \internal
*/
void QDeclarativePlaceIcon::pluginReady()
{
    QGeoServiceProvider *serviceProvider = m_plugin->sharedGeoServiceProvider();
    QPlaceManager *placeManager = serviceProvider->placeManager();
    if (!placeManager || serviceProvider->error() != QGeoServiceProvider::NoError) {
        qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, PLUGIN_ERROR)
                         .arg(m_plugin->name()).arg(serviceProvider->errorString());
        return;
    }
}
void DeclarativeDBusAdaptor::componentComplete()
{
    QDBusConnection conn = DeclarativeDBus::connection(m_bus);

    // Register service name only if it has been set.
    if (!m_service.isEmpty()) {
        if (!conn.registerService(m_service)) {
            qmlInfo(this) << "Failed to register service" << m_service;
            qmlInfo(this) << conn.lastError().message();
        }
    }

    // It is still valid to publish an object on the bus without first registering a service name,
    // a remote process would have to connect directly to the DBus address.
    if (!conn.registerVirtualObject(m_path, this)) {
        qmlInfo(this) << "Failed to register object" << m_path;
        qmlInfo(this) << conn.lastError().message();
    }
}
void QDeclarativeGraphicsGeoMap::removeMapObject(QDeclarativeGeoMapObject *object)
{
    if (!mapData_)
        qmlInfo(this) << tr("Map plugin is not set, map object cannot be removed.");
    if (!mapData_ || !object || !objectMap_.contains(object->mapObject()))
        return;
    objectMap_.remove(object->mapObject());
    mapObjects_.removeOne(object);
    mapData_->removeMapObject(object->mapObject());
}
Example #14
0
void QQuickStateChangeScript::execute(Reason)
{
    Q_D(QQuickStateChangeScript);
    if (!d->script.isEmpty()) {
        QQmlExpression expr(d->script);
        expr.evaluate();
        if (expr.hasError())
            qmlInfo(this, expr.error());
    }
}
void ScrollAreaWidgetContainer::addWidget(QWidget *widget)
{
  QScrollArea *scrollArea = extendedScrollArea();

  if (scrollArea->widget()) {
    qmlInfo(scrollArea) << "Can not add multiple Widgets to ScrollArea";
  } else {
    scrollArea->setWidget(widget);
  }
}
void MenuWidgetContainer::addWidget(QWidget *widget)
{
  QMenu *menu = qobject_cast<QMenu*>(widget);
  if (!menu) {
    qmlInfo(m_widget) << "The Menu can only contain Menu, Action, ActionItem or Separator";
    return;
  }

  extendedMenu()->addMenu(menu);
}
Example #17
0
/*!
    \internal
    Overloadable method allows properties to be set during creation
*/
QScriptValue QDeclarativeComponent::createObject(QObject* parent, const QScriptValue& valuemap)
{
    Q_D(QDeclarativeComponent);

    if (!valuemap.isObject() || valuemap.isArray()) {
        qmlInfo(this) << tr("createObject: value is not an object");
        return QScriptValue(QScriptValue::NullValue);
    }
    return d->createObject(parent, valuemap);
}
void QDeclarativePolylineMapItem::removeCoordinate(const QGeoCoordinate &coordinate)
{
    int index = path_.lastIndexOf(coordinate);

    if (index == -1) {
        qmlInfo(this) << COORD_NOT_BELONG_TO << QStringLiteral("PolylineMapItem");
        return;
    }

    if (path_.count() < index + 1) {
        qmlInfo(this) << COORD_NOT_BELONG_TO << QStringLiteral("PolylineMapItem");
        return;
    }
    path_.removeAt(index);

    geometry_.markSourceDirty();
    updateMapItem();
    emit pathChanged();
}
Example #19
0
bool QDeclarativeAnchorsPrivate::checkHValid() const
{
    if (usedAnchors & QDeclarativeAnchors::LeftAnchor &&
        usedAnchors & QDeclarativeAnchors::RightAnchor &&
        usedAnchors & QDeclarativeAnchors::HCenterAnchor) {
        qmlInfo(item) << QDeclarativeAnchors::tr("Cannot specify left, right, and hcenter anchors.");
        return false;
    }

    return true;
}
Example #20
0
void QDeclarativeListModel::set(int index, const QScriptValue& valuemap, QList<int> *roles)
{
    if (!valuemap.isObject() || valuemap.isArray()) {
        qmlInfo(this) << tr("set: value is not an object");
        return;
    }
    if (index > count() || index < 0) {
        qmlInfo(this) << tr("set: index %1 out of range").arg(index);
        return;
    }

    if (index == count()) {
        append(valuemap);
    } else {
        if (m_flat)
            m_flat->set(index, valuemap, roles);
        else
            m_nested->set(index, valuemap, roles);
    }
}
void QDeclarativeGraphicsGeoMap::addMapObject(QDeclarativeGeoMapObject *object)
{
    if (!mapData_)
        qmlInfo(this) << tr("Map plugin is not set, map object cannot be added.");
    if (!mapData_ || !object || objectMap_.contains(object->mapObject()))
        return;
    mapObjects_.append(object);
    objectMap_.insert(object->mapObject(), object);
    mapData_->addMapObject(object->mapObject());
    object->setMap(this);
}
Example #22
0
void StateMachine::componentComplete()
{
    if (QStateMachine::initialState() == NULL && childMode() == QState::ExclusiveStates)
         qmlInfo(this) << "No initial state set for StateMachine";

    // Everything is proper setup, now start the state-machine if we got
    // asked to do so.
    m_completed = true;
    if (m_running)
        setRunning(true);
}
/*!
    \internal
*/
void QDeclarativeGeoMapQuickItem::afterChildrenChanged()
{
    QList<QQuickItem *> kids = childItems();
    if (kids.size() > 0) {
        bool printedWarning = false;
        foreach (QQuickItem *i, kids) {
            if (i->flags() & QQuickItem::ItemHasContents
                    && !qobject_cast<QQuickMouseArea *>(i)
                    && sourceItem_.data() != i
                    && opacityContainer_ != i) {
                if (!printedWarning) {
                    qmlInfo(this) << "Use the sourceItem property for the contained item, direct children are not supported";
                    printedWarning = true;
                }

                qmlInfo(i) << "deleting this child";
                i->deleteLater();
            }
        }
    }
Example #24
0
void Geocode::initialized(bool success) {
  if (!success) {
    qmlInfo(this) << "Error initializing geocoding";
    setActive(false);
    return;
  }

  if (m_pending.isValid()) {
    search(m_pending.longitude(), m_pending.latitude());
    m_pending = QGeoCoordinate();
  }
}
Example #25
0
void QDeclarativeListModel::setProperty(int index, const QString& property, const QVariant& value, QList<int> *roles)
{
    if (count() == 0 || index >= count() || index < 0) {
        qmlInfo(this) << tr("set: index %1 out of range").arg(index);
        return;
    }

    if (m_flat)
        m_flat->setProperty(index, property, value, roles);
    else
        m_nested->setProperty(index, property, value, roles);
}
Example #26
0
void QQuickCanvasItem::setRenderStrategy(QQuickCanvasItem::RenderStrategy strategy)
{
    Q_D(QQuickCanvasItem);
    if (d->renderStrategy != strategy) {
        if (d->context) {
            qmlInfo(this) << "Canvas:renderStrategy not changeable once context is active.";
            return;
        }
        d->renderStrategy = strategy;
        emit renderStrategyChanged();
    }
}
Example #27
0
void QDeclarativeFlipable::setFront(QGraphicsObject *front)
{
    Q_D(QDeclarativeFlipable);
    if (d->front) {
        qmlInfo(this) << tr("front is a write-once property");
        return;
    }
    d->front = front;
    d->front->setParentItem(this);
    if (Back == d->current)
        d->front->setOpacity(0.);
}
void ScreenSaver::componentComplete() {
    Q_D(ScreenSaver);
    d->complete = true;
    
    if (QWidget *window = QApplication::activeWindow()) {
        d->windowId = window->winId();
        this->setScreenSaverInhibited(d->inhibited);
    }
    else {
        qmlInfo(this) << tr("Could not find window id");
    }
}
void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledImage& sci)
{
    Q_D(QDeclarativeBorderImage);
    if (!sci.isValid()) {
        d->status = Error;
        emit statusChanged(d->status);
    } else {
        QDeclarativeScaleGrid *sg = border();
        sg->setTop(sci.gridTop());
        sg->setBottom(sci.gridBottom());
        sg->setLeft(sci.gridLeft());
        sg->setRight(sci.gridRight());
        d->horizontalTileMode = sci.horizontalTileRule();
        d->verticalTileMode = sci.verticalTileRule();

        d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl()));

        d->pix.load(qmlEngine(this), d->sciurl, d->async);

        if (d->pix.isLoading()) {
            static int thisRequestProgress = -1;
            static int thisRequestFinished = -1;
            if (thisRequestProgress == -1) {
                thisRequestProgress =
                    QDeclarativeBorderImage::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)");
                thisRequestFinished =
                    QDeclarativeBorderImage::staticMetaObject.indexOfSlot("requestFinished()");
            }

            d->pix.connectFinished(this, thisRequestFinished);
            d->pix.connectDownloadProgress(this, thisRequestProgress);

        } else {

            QSize impsize = d->pix.implicitSize();
            setImplicitWidth(impsize.width());
            setImplicitHeight(impsize.height());

            if (d->pix.isReady()) {
                d->status = Ready;
            } else {
                d->status = Error;
                qmlInfo(this) << d->pix.error();
            }

            d->progress = 1.0;
            emit statusChanged(d->status);
            emit progressChanged(1.0);
            update();

        }
    }
}
Example #30
0
void Geocode::search(double longitude, double latitude) {
  if (!isActive()) {
    qmlInfo(this) << "geocoding is not active";
    return;
  }

  if (!m_service->isInitialized()) {
    m_pending = QGeoCoordinate(latitude, longitude);
    return;
  }

  m_id = 0;
  QGeoCoordinate coords(latitude, longitude);
  GeoLocationService::GeoLocationError err = m_service->addressQuery(coords, 1, &m_id);
  if (err == GeoLocationService::QueryFailedError) {
    setActive(false);
  }

  if (err != GeoLocationService::NoError) {
    qmlInfo(this) << "error" << err << "from GeoLocationService";
  }
}