Avoid Qt Sanity Bot noise when these files are moved.
Change-Id: I714e949837909883fe7e387ae336d2ffc4a1912b
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
r->context->buffer()->strokeRect(x, y, w, h);
}
-
+
return args.This();
}
else
r->context->state.clipPath = clipPath;
r->context->buffer()->clip(r->context->state.clipPath);
-
+
return args.This();
}
if (args.Length() >= 1) {
int filterFlag = args[0]->IntegerValue();
- switch(filterFlag) {
+ switch (filterFlag) {
case QSGCanvasItem::Mono :
{
r->image = r->image.convertToFormat(QImage::Format_Mono).convertToFormat(QImage::Format_ARGB32_Premultiplied);
static qreal position(QSGItem *item, QSGAnchorLine::AnchorLine anchorLine)
{
qreal ret = 0.0;
- switch(anchorLine) {
+ switch (anchorLine) {
case QSGAnchorLine::Left:
ret = item->x();
break;
static qreal adjustedPosition(QSGItem *item, QSGAnchorLine::AnchorLine anchorLine)
{
qreal ret = 0.0;
- switch(anchorLine) {
+ switch (anchorLine) {
case QSGAnchorLine::Left:
ret = 0.0;
break;
{
if (!item)
return;
-
+
QSGItemPrivate *p = QSGItemPrivate::get(item);
p->addItemChangeListener(this, QSGItemPrivate::Geometry);
}
if (d->leftMargin == offset)
return;
d->leftMargin = offset;
- if(d->fill)
+ if (d->fill)
d->fillChanged();
else
d->updateHorizontalAnchors();
if (d->rightMargin == offset)
return;
d->rightMargin = offset;
- if(d->fill)
+ if (d->fill)
d->fillChanged();
else
d->updateHorizontalAnchors();
if (d->margins == offset)
return;
//###Is it significantly faster to set them directly so we can call fillChanged only once?
- if(!d->rightMargin || d->rightMargin == d->margins)
+ if (!d->rightMargin || d->rightMargin == d->margins)
setRightMargin(offset);
- if(!d->leftMargin || d->leftMargin == d->margins)
+ if (!d->leftMargin || d->leftMargin == d->margins)
setLeftMargin(offset);
- if(!d->topMargin || d->topMargin == d->margins)
+ if (!d->topMargin || d->topMargin == d->margins)
setTopMargin(offset);
- if(!d->bottomMargin || d->bottomMargin == d->margins)
+ if (!d->bottomMargin || d->bottomMargin == d->margins)
setBottomMargin(offset);
d->margins = offset;
emit marginsChanged();
if (d->hCenterOffset == offset)
return;
d->hCenterOffset = offset;
- if(d->centerIn)
+ if (d->centerIn)
d->centerInChanged();
else
d->updateHorizontalAnchors();
if (d->topMargin == offset)
return;
d->topMargin = offset;
- if(d->fill)
+ if (d->fill)
d->fillChanged();
else
d->updateVerticalAnchors();
if (d->bottomMargin == offset)
return;
d->bottomMargin = offset;
- if(d->fill)
+ if (d->fill)
d->fillChanged();
else
d->updateVerticalAnchors();
if (d->vCenterOffset == offset)
return;
d->vCenterOffset = offset;
- if(d->centerIn)
+ if (d->centerIn)
d->centerInChanged();
else
d->updateVerticalAnchors();
bool QSGAnimatedImage::isPaused() const
{
Q_D(const QSGAnimatedImage);
- if(!d->_movie)
+ if (!d->_movie)
return false;
return d->_movie->state()==QMovie::Paused;
}
void QSGAnimatedImage::setPaused(bool pause)
{
Q_D(QSGAnimatedImage);
- if(pause == d->paused)
+ if (pause == d->paused)
return;
d->paused = pause;
- if(!d->_movie)
+ if (!d->_movie)
return;
d->_movie->setPaused(pause);
}
void QSGAnimatedImage::setPlaying(bool play)
{
Q_D(QSGAnimatedImage);
- if(play == d->playing)
+ if (play == d->playing)
return;
d->playing = play;
if (!d->_movie)
connect(d->_movie, SIGNAL(frameChanged(int)),
this, SLOT(movieUpdate()));
d->_movie->setCacheMode(QMovie::CacheAll);
- if(d->playing)
+ if (d->playing)
d->_movie->start();
else
d->_movie->jumpToFrame(0);
- if(d->paused)
+ if (d->paused)
d->_movie->setPaused(true);
d->setPixmap(d->_movie->currentPixmap());
d->status = Ready;
connect(d->_movie, SIGNAL(frameChanged(int)),
this, SLOT(movieUpdate()));
d->_movie->setCacheMode(QMovie::CacheAll);
- if(d->playing)
+ if (d->playing)
d->_movie->start();
if (d->paused || !d->playing) {
d->_movie->jumpToFrame(d->preset_currentframe);
d->preset_currentframe = 0;
}
- if(d->paused)
+ if (d->paused)
d->_movie->setPaused(true);
d->setPixmap(d->_movie->currentPixmap());
d->status = Ready;
void QSGAnimatedImage::playingStatusChanged()
{
Q_D(QSGAnimatedImage);
- if((d->_movie->state() != QMovie::NotRunning) != d->playing){
+ if ((d->_movie->state() != QMovie::NotRunning) != d->playing) {
d->playing = (d->_movie->state() != QMovie::NotRunning);
emit playingChanged();
}
- if((d->_movie->state() == QMovie::Paused) != d->paused){
+ if ((d->_movie->state() == QMovie::Paused) != d->paused) {
d->playing = (d->_movie->state() == QMovie::Paused);
emit pausedChanged();
}
//### mirrors same-named function in QSGItem
QPointF QSGParentAnimationPrivate::computeTransformOrigin(QSGItem::TransformOrigin origin, qreal width, qreal height) const
{
- switch(origin) {
+ switch (origin) {
default:
case QSGItem::TopLeft:
return QPointF(0, 0);
lastMousePosition = event->windowPos();
- if (!mouseGrabberItem &&
+ if (!mouseGrabberItem &&
event->type() == QEvent::MouseButtonPress &&
(event->button() & event->buttons()) == event->buttons()) {
-
return deliverInitialMousePressEvent(rootItem, event);
}
case QEvent::MouseButtonRelease:
case QEvent::MouseButtonDblClick:
case QEvent::MouseMove:
- // XXX todo - should sendEvent be doing this? how does it relate to forwarded events?
+ // XXX todo - should sendEvent be doing this? how does it relate to forwarded events?
{
QMouseEvent *se = static_cast<QMouseEvent *>(e);
if (!d->sendFilteredMouseEvent(item->parentItem(), item, se)) {
}
/*!
- Returns an incubation controller that splices incubation between frames
+ Returns an incubation controller that splices incubation between frames
for this canvas. QSGView automatically installs this controller for you.
The controller is owned by the canvas and will be destroyed when the canvas
// if we drag then pause before release we should not cause a flick.
qint64 elapsed = QSGItemPrivate::elapsed(lastPosTime);
-
+
vData.updateVelocity();
hData.updateVelocity();
mouseEvent.setAccepted(false);
- switch(mouseEvent.type()) {
+ switch (mouseEvent.type()) {
case QEvent::MouseMove:
d->handleMouseMoveEvent(&mouseEvent);
break;
if (widthScale <= heightScale) {
d->paintedWidth = w;
d->paintedHeight = widthScale * qreal(d->pix.height());
- } else if(heightScale < widthScale) {
+ } else if (heightScale < widthScale) {
d->paintedWidth = heightScale * qreal(d->pix.width());
d->paintedHeight = h;
}
qreal heightScale = height() / qreal(d->pix.height());
if (widthScale < heightScale) {
widthScale = heightScale;
- } else if(heightScale < widthScale) {
+ } else if (heightScale < widthScale) {
heightScale = widthScale;
}
}
QSGImageNode *node = static_cast<QSGImageNode *>(oldNode);
- if (!node) {
+ if (!node) {
d->pixmapChanged = true;
node = d->sceneGraphContext()->createImageNode();
node->setTexture(texture);
d->downSet = true;
QSGKeyNavigationAttached* other =
qobject_cast<QSGKeyNavigationAttached*>(qmlAttachedPropertiesObject<QSGKeyNavigationAttached>(i));
- if(other && !other->d_func()->upSet){
+ if (other && !other->d_func()->upSet) {
other->d_func()->up = qobject_cast<QSGItem*>(parent());
emit other->upChanged();
}
d->tabSet = true;
QSGKeyNavigationAttached* other =
qobject_cast<QSGKeyNavigationAttached*>(qmlAttachedPropertiesObject<QSGKeyNavigationAttached>(i));
- if(other && !other->d_func()->backtabSet){
+ if (other && !other->d_func()->backtabSet) {
other->d_func()->backtab = qobject_cast<QSGItem*>(parent());
emit other->backtabChanged();
}
d->backtabSet = true;
QSGKeyNavigationAttached* other =
qobject_cast<QSGKeyNavigationAttached*>(qmlAttachedPropertiesObject<QSGKeyNavigationAttached>(i));
- if(other && !other->d_func()->tabSet){
+ if (other && !other->d_func()->tabSet) {
other->d_func()->tab = qobject_cast<QSGItem*>(parent());
emit other->tabChanged();
}
}
bool mirror = false;
- switch(event->key()) {
+ switch (event->key()) {
case Qt::Key_Left: {
if (QSGItem *parentItem = qobject_cast<QSGItem*>(parent()))
mirror = QSGItemPrivate::get(parentItem)->effectiveLayoutMirror;
}
bool mirror = false;
- switch(event->key()) {
+ switch (event->key()) {
case Qt::Key_Left:
if (QSGItem *parentItem = qobject_cast<QSGItem*>(parent()))
mirror = QSGItemPrivate::get(parentItem)->effectiveLayoutMirror;
void QSGItemPrivate::siblingOrderChanged()
{
Q_Q(QSGItem);
- for(int ii = 0; ii < changeListeners.count(); ++ii) {
+ for (int ii = 0; ii < changeListeners.count(); ++ii) {
const QSGItemPrivate::ChangeListener &change = changeListeners.at(ii);
if (change.types & QSGItemPrivate::SiblingOrder) {
change.listener->itemSiblingOrderChanged(q);
if (d->_anchors)
QSGAnchorsPrivate::get(d->_anchors)->updateMe();
- for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
+ for (int ii = 0; ii < d->changeListeners.count(); ++ii) {
const QSGItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
if (change.types & QSGItemPrivate::Geometry)
change.listener->itemGeometryChanged(this, newGeometry, oldGeometry);
d->baselineOffset = offset;
- for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
+ for (int ii = 0; ii < d->changeListeners.count(); ++ii) {
const QSGItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
if (change.types & QSGItemPrivate::Geometry) {
QSGAnchorsPrivate *anchor = change.listener->anchorPrivate();
QPointF QSGItemPrivate::computeTransformOrigin() const
{
- switch(origin) {
+ switch (origin) {
default:
case QSGItem::TopLeft:
return QPointF(0, 0);
Q_ASSERT(e->isAccepted());
- switch(e->type()) {
+ switch (e->type()) {
default:
Q_ASSERT(!"Unknown event type");
case QEvent::MouseMove:
void QSGItemPrivate::deliverHoverEvent(QHoverEvent *e)
{
Q_Q(QSGItem);
- switch(e->type()) {
+ switch (e->type()) {
default:
Q_ASSERT(!"Unknown event type");
case QEvent::HoverEnter:
for (int ii = 0; ii < childItems.count(); ++ii)
QSGItemPrivate::get(childItems.at(ii))->setEffectiveVisibleRecur(newEffectiveVisible);
- for(int ii = 0; ii < changeListeners.count(); ++ii) {
+ for (int ii = 0; ii < changeListeners.count(); ++ii) {
const QSGItemPrivate::ChangeListener &change = changeListeners.at(ii);
if (change.types & QSGItemPrivate::Visibility)
change.listener->itemVisibilityChanged(q);
void QSGItemPrivate::itemChange(QSGItem::ItemChange change, const QSGItem::ItemChangeData &data)
{
Q_Q(QSGItem);
- switch(change) {
+ switch (change) {
case QSGItem::ItemChildAddedChange:
q->itemChange(change, data);
if (_contents && componentComplete)
_contents->childAdded(data.item);
- for(int ii = 0; ii < changeListeners.count(); ++ii) {
+ for (int ii = 0; ii < changeListeners.count(); ++ii) {
const QSGItemPrivate::ChangeListener &change = changeListeners.at(ii);
if (change.types & QSGItemPrivate::Children) {
change.listener->itemChildAdded(q, data.item);
q->itemChange(change, data);
if (_contents && componentComplete)
_contents->childRemoved(data.item);
- for(int ii = 0; ii < changeListeners.count(); ++ii) {
+ for (int ii = 0; ii < changeListeners.count(); ++ii) {
const QSGItemPrivate::ChangeListener &change = changeListeners.at(ii);
if (change.types & QSGItemPrivate::Children) {
change.listener->itemChildRemoved(q, data.item);
break;
case QSGItem::ItemVisibleHasChanged:
q->itemChange(change, data);
- for(int ii = 0; ii < changeListeners.count(); ++ii) {
+ for (int ii = 0; ii < changeListeners.count(); ++ii) {
const QSGItemPrivate::ChangeListener &change = changeListeners.at(ii);
if (change.types & QSGItemPrivate::Visibility) {
change.listener->itemVisibilityChanged(q);
break;
case QSGItem::ItemParentHasChanged:
q->itemChange(change, data);
- for(int ii = 0; ii < changeListeners.count(); ++ii) {
+ for (int ii = 0; ii < changeListeners.count(); ++ii) {
const QSGItemPrivate::ChangeListener &change = changeListeners.at(ii);
if (change.types & QSGItemPrivate::Parent) {
change.listener->itemParentChanged(q, data.item);
break;
case QSGItem::ItemOpacityHasChanged:
q->itemChange(change, data);
- for(int ii = 0; ii < changeListeners.count(); ++ii) {
+ for (int ii = 0; ii < changeListeners.count(); ++ii) {
const QSGItemPrivate::ChangeListener &change = changeListeners.at(ii);
if (change.types & QSGItemPrivate::Opacity) {
change.listener->itemOpacityChanged(q);
break;
case QSGItem::ItemRotationHasChanged:
q->itemChange(change, data);
- for(int ii = 0; ii < changeListeners.count(); ++ii) {
+ for (int ii = 0; ii < changeListeners.count(); ++ii) {
const QSGItemPrivate::ChangeListener &change = changeListeners.at(ii);
if (change.types & QSGItemPrivate::Rotation) {
change.listener->itemRotationChanged(q);
d->hoverEnabled = enabled;
}
-void QSGItem::grabMouse()
+void QSGItem::grabMouse()
{
Q_D(QSGItem);
if (!d->canvas)
};
QSGTransformNode *QSGItemPrivate::itemNode()
-{
+{
if (!itemNodeInstance) {
itemNodeInstance = createTransformNode();
itemNodeInstance->setFlag(QSGNode::OwnedByParent, false);
itemNodeInstance->description = QString::fromLatin1("QSGItem(%1)").arg(QString::fromLatin1(q->metaObject()->className()));
#endif
}
- return itemNodeInstance;
+ return itemNodeInstance;
}
QSGNode *QSGItemPrivate::childContainerNode()
QSGMouseArea* ma = qobject_cast<QSGMouseArea*>(item);
if (ma && ma != q && itemPrivate->acceptedMouseButtons & ev->button()) {
- switch(sig){
+ switch (sig) {
case Click:
if (!ma->d_func()->isClickConnected())
return false;
ev->setX(p.x());
ev->setY(p.y());
ev->setAccepted(true);//It is connected, they have to explicitly ignore to let it slide
- switch(sig){
+ switch (sig) {
case Click: emit ma->clicked(ev); break;
case DoubleClick: emit ma->doubleClicked(ev); break;
case PressAndHold: emit ma->pressAndHold(ev); break;
inline qreal qmlMod(qreal x, qreal y)
{
#ifdef QT_USE_MATH_H_FLOATS
- if(sizeof(qreal) == sizeof(float))
+ if (sizeof(qreal) == sizeof(float))
return fmodf(float(x), float(y));
else
#endif
if (!attType) {
// pre-create one metatype to share with all attached objects
attType = new QDeclarativeOpenMetaObjectType(&QSGPathViewAttached::staticMetaObject, qmlEngine(q));
- foreach(const QString &attr, path->attributes())
+ foreach (const QString &attr, path->attributes())
attType->createProperty(attr.toUtf8());
}
qPathViewAttachedType = attType;
if (qFuzzyCompare(att->m_percent, percent))
return;
att->m_percent = percent;
- foreach(const QString &attr, path->attributes())
+ foreach (const QString &attr, path->attributes())
att->setValue(attr.toUtf8(), path->attributeAt(attr, percent));
}
QPointF pf = path->pointAt(percent);
event->button(), event->buttons(), event->modifiers());
mouseEvent.setAccepted(false);
- switch(mouseEvent.type()) {
+ switch (mouseEvent.type()) {
case QEvent::MouseMove:
d->handleMouseMoveEvent(&mouseEvent);
break;
if (!d->attType) {
// pre-create one metatype to share with all attached objects
d->attType = new QDeclarativeOpenMetaObjectType(&QSGPathViewAttached::staticMetaObject, qmlEngine(this));
- foreach(const QString &attr, d->path->attributes())
+ foreach (const QString &attr, d->path->attributes())
d->attType->createProperty(attr.toUtf8());
}
qPathViewAttachedType = d->attType;
event->button(), event->buttons(), event->modifiers());
mouseEvent.setAccepted(false);
- switch(mouseEvent.type()) {
+ switch (mouseEvent.type()) {
case QEvent::MouseMove:
mouseMoveEvent(&mouseEvent);
break;
void QSGBasePositioner::positionX(int x, const PositionedItem &target)
{
Q_D(QSGBasePositioner);
- if(d->type == Horizontal || d->type == Both){
+ if (d->type == Horizontal || d->type == Both) {
if (target.isNew) {
if (!d->addTransition || !d->addTransition->enabled())
target.item->setX(x);
void QSGBasePositioner::positionY(int y, const PositionedItem &target)
{
Q_D(QSGBasePositioner);
- if(d->type == Vertical || d->type == Both){
+ if (d->type == Vertical || d->type == Both) {
if (target.isNew) {
if (!d->addTransition || !d->addTransition->enabled())
target.item->setY(y);
if (!child.item || !child.isVisible)
continue;
- if(child.item->y() != voffset)
+ if (child.item->y() != voffset)
positionY(voffset, child);
contentSize->setWidth(qMax(contentSize->width(), child.item->width()));
//Is allocating the extra QPODVector too much overhead?
QPODVector<PositionedItem, 8> visibleItems;//we aren't concerned with invisible items
visibleItems.reserve(positionedItems.count());
- for(int i=0; i<positionedItems.count(); i++)
- if(positionedItems[i].item && positionedItems[i].isVisible)
+ for (int i=0; i<positionedItems.count(); i++)
+ if (positionedItems[i].item && positionedItems[i].isVisible)
visibleItems.append(positionedItems[i]);
int numVisible = visibleItems.count();
c = (numVisible+(m_rows-1))/m_rows;
}
- if(r==0 || c==0)
+ if (r==0 || c==0)
return; //Nothing to do
QList<int> maxColWidth;
QString imgFile;
QByteArray raw;
- while(raw = data->readLine(), !raw.isEmpty()) {
+ while (raw = data->readLine(), !raw.isEmpty()) {
QString line = QString::fromUtf8(raw.trimmed());
if (line.isEmpty() || line.startsWith(QLatin1Char('#')))
continue;
QVector<QPair<QByteArray, QSGTextureProvider *> > textures;
const QVector<QPair<QByteArray, QSGTextureProvider *> > &oldTextures = material->textureProviders();
- for (QSet<QByteArray>::const_iterator it = m_source.uniformNames.begin();
+ for (QSet<QByteArray>::const_iterator it = m_source.uniformNames.begin();
it != m_source.uniformNames.end(); ++it) {
values.append(qMakePair(*it, property(*it)));
}
QByteArray fragmentShader() const { return m_source.fragmentCode; }
void setFragmentShader(const QByteArray &code);
-
+
QByteArray vertexShader() const { return m_source.vertexCode; }
void setVertexShader(const QByteArray &code);
The complex element can be rendered once into the texture, which can
then be animated freely without the need to render the complex element
again every frame.
- \o an opacity layer.
+ \o an opacity layer.
ShaderEffectSource allows you to apply an opacity to elements as a group
rather than each element individually.
\endlist
void QSGSpriteImage::createEngine()
{
//TODO: delay until component complete
- if(m_spriteEngine)
+ if (m_spriteEngine)
delete m_spriteEngine;
- if(m_sprites.count())
+ if (m_sprites.count())
m_spriteEngine = new QSGSpriteEngine(m_sprites, this);
else
m_spriteEngine = 0;
m_material = new QSGSpriteMaterial();
QImage image = m_spriteEngine->assembledImage();
- if(image.isNull())
+ if (image.isNull())
return 0;
m_material->texture = sceneGraphEngine()->createTextureFromImage(image);
m_material->texture->setFiltering(QSGTexture::Linear);
QSGNode *QSGSpriteImage::updatePaintNode(QSGNode *, UpdatePaintNodeData *)
{
- if(m_pleaseReset){
+ if (m_pleaseReset) {
delete m_node;
delete m_material;
prepareNextFrame();
- if(m_running){
+ if (m_running) {
update();
if (m_node)
m_node->markDirty(QSGNode::DirtyMaterial);
{
Q_Q(QSGText);
- if(richTextAsImage || cacheAllTextAsImage || (qmlDisableDistanceField() && style != QSGText::Normal)){//If actually using the image cache
+ if (richTextAsImage || cacheAllTextAsImage || (qmlDisableDistanceField() && style != QSGText::Normal)) { // If actually using the image cache
if (imageCacheDirty)
return;
\list
\o Font.MixedCase - This is the normal text rendering option where no capitalization change is applied.
\o Font.AllUppercase - This alters the text to be rendered in all uppercase type.
- \o Font.AllLowercase - This alters the text to be rendered in all lowercase type.
- \o Font.SmallCaps - This alters the text to be rendered in small-caps type.
+ \o Font.AllLowercase - This alters the text to be rendered in all lowercase type.
+ \o Font.SmallCaps - This alters the text to be rendered in small-caps type.
\o Font.Capitalize - This alters the text to be rendered with the first character of each word as an uppercase character.
\endlist
\list
\o Font.MixedCase - This is the normal text rendering option where no capitalization change is applied.
\o Font.AllUppercase - This alters the text to be rendered in all uppercase type.
- \o Font.AllLowercase - This alters the text to be rendered in all lowercase type.
- \o Font.SmallCaps - This alters the text to be rendered in small-caps type.
+ \o Font.AllLowercase - This alters the text to be rendered in all lowercase type.
+ \o Font.SmallCaps - This alters the text to be rendered in small-caps type.
\o Font.Capitalize - This alters the text to be rendered with the first character of each word as an uppercase character.
\endlist
if (oldFont != d->font) {
d->document->setDefaultFont(d->font);
- if(d->cursor){
+ if (d->cursor) {
d->cursor->setHeight(QFontMetrics(d->font).height());
moveCursorDelegate();
}
void QSGTextEdit::setCursorDelegate(QDeclarativeComponent* c)
{
Q_D(QSGTextEdit);
- if(d->cursorComponent){
- if(d->cursor){
+ if (d->cursorComponent) {
+ if (d->cursor) {
d->control->setCursorWidth(-1);
updateCursor();
delete d->cursor;
}
}
d->cursorComponent = c;
- if(c && c->isReady()){
+ if (c && c->isReady()) {
loadCursorDelegate();
- }else{
- if(c)
+ } else {
+ if (c)
connect(c, SIGNAL(statusChanged()),
this, SLOT(loadCursorDelegate()));
}
void QSGTextEdit::loadCursorDelegate()
{
Q_D(QSGTextEdit);
- if(d->cursorComponent->isLoading())
+ if (d->cursorComponent->isLoading())
return;
QDeclarativeContext *creationContext = d->cursorComponent->creationContext();
QObject *object = d->cursorComponent->create(creationContext ? creationContext : qmlContext(this));
d->cursor = qobject_cast<QSGItem*>(object);
- if(d->cursor){
+ if (d->cursor) {
d->control->setCursorWidth(0);
updateCursor();
QDeclarative_setParent_noEvent(d->cursor, this);
d->determineHorizontalAlignment();
updateMicroFocus();
emit cursorRectangleChanged();
- if(!d->cursor)
+ if (!d->cursor)
return;
QRectF cursorRect = cursorRectangle();
d->cursor->setX(cursorRect.x());
cursor.setPosition(lastSelectionEnd, QTextCursor::KeepAnchor);
cursor.endEditBlock();
control->setTextCursor(cursor);
- if(startChange)
+ if (startChange)
q->selectionStartChanged();
- if(endChange)
+ if (endChange)
q->selectionEndChanged();
}
void QSGTextEdit::updateSelectionMarkers()
{
Q_D(QSGTextEdit);
- if(d->lastSelectionStart != d->control->textCursor().selectionStart()){
+ if (d->lastSelectionStart != d->control->textCursor().selectionStart()) {
d->lastSelectionStart = d->control->textCursor().selectionStart();
emit selectionStartChanged();
}
- if(d->lastSelectionEnd != d->control->textCursor().selectionEnd()){
+ if (d->lastSelectionEnd != d->control->textCursor().selectionEnd()) {
d->lastSelectionEnd = d->control->textCursor().selectionEnd();
emit selectionEndChanged();
}
Q_D(const QSGTextEdit);
QRectF r = QSGImplicitSizeItem::boundingRect();
int cursorWidth = 1;
- if(d->cursor)
+ if (d->cursor)
cursorWidth = d->cursor->width();
- if(!d->document->isEmpty())
+ if (!d->document->isEmpty())
cursorWidth += 3;// ### Need a better way of accounting for space between char and cursor
// Could include font max left/right bearings to either side of rectangle.
\endcode
*/
void QSGTextEdit::closeSoftwareInputPanel()
-{
+{
if (qGuiApp)
qGuiApp->inputPanel()->hide();
}
Q_D(QSGTextEdit);
bool old = d->canPaste;
d->canPaste = d->control->canPaste();
- if(old!=d->canPaste)
+ if (old!=d->canPaste)
emit canPasteChanged();
}
void updateImageCache(const QRectF &rect = QRectF());
protected:
- virtual void geometryChanged(const QRectF &newGeometry,
+ virtual void geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry);
bool event(QEvent *);
void QSGTextInput::setText(const QString &s)
{
Q_D(QSGTextInput);
- if(s == text())
+ if (s == text())
return;
d->control->setText(s);
}
\list
\o Font.MixedCase - This is the normal text rendering option where no capitalization change is applied.
\o Font.AllUppercase - This alters the text to be rendered in all uppercase type.
- \o Font.AllLowercase - This alters the text to be rendered in all lowercase type.
- \o Font.SmallCaps - This alters the text to be rendered in small-caps type.
+ \o Font.AllLowercase - This alters the text to be rendered in all lowercase type.
+ \o Font.SmallCaps - This alters the text to be rendered in small-caps type.
\o Font.Capitalize - This alters the text to be rendered with the first character of each word as an uppercase character.
\endlist
d->control->setFont(d->font);
updateSize();
updateCursorRectangle();
- if(d->cursorItem){
+ if (d->cursorItem) {
d->cursorItem->setHeight(QFontMetrics(d->font).height());
}
}
return;
d->control->setValidator(v);
- if(!d->control->hasAcceptableInput()){
+ if (!d->control->hasAcceptableInput()) {
d->oldValidity = false;
emit acceptableInputChanged();
}
return;
d->cursorComponent = c;
- if(!c){
+ if (!c) {
//note that the components are owned by something else
delete d->cursorItem;
- }else{
+ } else {
d->startCreatingCursor();
}
void QSGTextInputPrivate::startCreatingCursor()
{
Q_Q(QSGTextInput);
- if(cursorComponent->isReady()){
+ if (cursorComponent->isReady()) {
q->createCursor();
- }else if(cursorComponent->isLoading()){
+ } else if (cursorComponent->isLoading()) {
q->connect(cursorComponent, SIGNAL(statusChanged(int)),
q, SLOT(createCursor()));
- }else {//isError
+ } else { // isError
qmlInfo(q, cursorComponent->errors()) << QSGTextInput::tr("Could not load cursor delegate");
}
}
void QSGTextInput::createCursor()
{
Q_D(QSGTextInput);
- if(d->cursorComponent->isError()){
+ if (d->cursorComponent->isError()) {
qmlInfo(this, d->cursorComponent->errors()) << tr("Could not load cursor delegate");
return;
}
- if(!d->cursorComponent->isReady())
+ if (!d->cursorComponent->isReady())
return;
- if(d->cursorItem)
+ if (d->cursorItem)
delete d->cursorItem;
QDeclarativeContext *creationContext = d->cursorComponent->creationContext();
QObject *object = d->cursorComponent->create(creationContext ? creationContext : qmlContext(this));
d->cursorItem = qobject_cast<QSGItem*>(object);
- if(!d->cursorItem){
+ if (!d->cursorItem) {
delete object;
qmlInfo(this, d->cursorComponent->errors()) << tr("Could not instantiate cursor delegate");
return;
Q_D(QSGTextInput);
if (d->sendMouseEventToInputContext(event))
return;
- if(d->focusOnPress){
+ if (d->focusOnPress) {
bool hadActiveFocus = hasActiveFocus();
forceActiveFocus();
// re-open input panel on press if already focused
Q_D(QSGTextInput);
//Anything we don't deal with ourselves, pass to the control
bool handled = false;
- switch(ev->type()){
+ switch (ev->type()) {
case QEvent::KeyPress:
case QEvent::KeyRelease://###Should the control be doing anything with release?
case QEvent::InputMethod:
default:
handled = d->control->processEvent(ev);
}
- if(!handled)
+ if (!handled)
handled = QSGImplicitSizeItem::event(ev);
return handled;
}
QVariant QSGTextInput::inputMethodQuery(Qt::InputMethodQuery property) const
{
Q_D(const QSGTextInput);
- switch(property) {
+ switch (property) {
case Qt::ImEnabled:
return QVariant((bool)(flags() & ItemAcceptsInputMethod));
case Qt::ImHints:
void QSGTextInput::setPasswordCharacter(const QString &str)
{
Q_D(QSGTextInput);
- if(str.length() < 1)
+ if (str.length() < 1)
return;
d->control->setPasswordCharacter(str.constData()[0]);
EchoMode echoMode_ = echoMode();
bool hasFocus = value.boolValue;
d->focused = hasFocus;
setCursorVisible(hasFocus); // ### refactor: && d->canvas && d->canvas->hasFocus()
- if(echoMode() == QSGTextInput::PasswordEchoOnEdit && !hasFocus)
+ if (echoMode() == QSGTextInput::PasswordEchoOnEdit && !hasFocus)
d->control->updatePasswordEchoEditing(false);//QLineControl sets it on key events, but doesn't deal with focus events
if (!hasFocus)
d->control->deselect();
d->control->resetCursorBlinkTimer();
#endif
- if(!d->control->hasSelectedText()){
- if(d->lastSelectionStart != d->control->cursor()){
+ if (!d->control->hasSelectedText()) {
+ if (d->lastSelectionStart != d->control->cursor()) {
d->lastSelectionStart = d->control->cursor();
emit selectionStartChanged();
}
- if(d->lastSelectionEnd != d->control->cursor()){
+ if (d->lastSelectionEnd != d->control->cursor()) {
d->lastSelectionEnd = d->control->cursor();
emit selectionEndChanged();
}
updateRect();//TODO: Only update rect in selection
emit selectedTextChanged();
- if(d->lastSelectionStart != d->control->selectionStart()){
+ if (d->lastSelectionStart != d->control->selectionStart()) {
d->lastSelectionStart = d->control->selectionStart();
- if(d->lastSelectionStart == -1)
+ if (d->lastSelectionStart == -1)
d->lastSelectionStart = d->control->cursor();
emit selectionStartChanged();
}
- if(d->lastSelectionEnd != d->control->selectionEnd()){
+ if (d->lastSelectionEnd != d->control->selectionEnd()) {
d->lastSelectionEnd = d->control->selectionEnd();
- if(d->lastSelectionEnd == -1)
+ if (d->lastSelectionEnd == -1)
d->lastSelectionEnd = d->control->cursor();
emit selectionEndChanged();
}
d->determineHorizontalAlignment();
d->updateHorizontalScroll();
updateMicroFocus();
- if(hasAcceptableInput() != d->oldValidity){
+ if (hasAcceptableInput() != d->oldValidity) {
d->oldValidity = hasAcceptableInput();
emit acceptableInputChanged();
}
int h = height();
setImplicitHeight(d->control->height()-1); // -1 to counter QLineControl's +1 which is not consistent with Text.
setImplicitWidth(d->calculateTextWidth());
- if(w==width() && h==height() && needsRedraw)
+ if (w==width() && h==height() && needsRedraw)
update();
}
#ifndef QT_NO_CLIPBOARD
d->canPaste = !d->control->isReadOnly() && QGuiApplication::clipboard()->text().length() != 0;
#endif
- if(d->canPaste != old)
+ if (d->canPaste != old)
emit canPasteChanged();
}
QObject *obj = d->component->create();
- if(d->component->isError()) {
+ if (d->component->isError()) {
QList<QDeclarativeError> errorList = d->component->errors();
foreach (const QDeclarativeError &error, errorList) {
qWarning() << error;
QList<QSGImage *> images = obj->findChildren<QSGImage *>();
QCOMPARE(images.count(), 4);
QTest::qWait(100);
- foreach(QSGImage *img, images) {
+ foreach (QSGImage *img, images) {
QCOMPARE(img->status(), QSGImage::Loading);
}
provider->ok = true;
provider->cond.wakeAll();
QTest::qWait(250);
- foreach(QSGImage *img, images) {
+ foreach (QSGImage *img, images) {
QTRY_VERIFY(img->status() == QSGImage::Ready);
}
}
//qDebug() << parent->childItems().count() << "children";
for (int i = 0; i < parent->childItems().count(); ++i) {
QSGItem *item = qobject_cast<QSGItem*>(parent->childItems().at(i));
- if(!item)
+ if (!item)
continue;
//qDebug() << "try" << item;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
QCOMPARE(gridviewA->layoutDirection(), gridviewA->effectiveLayoutDirection());
// LTR != RTL
- foreach(const QString objectName, objectNames)
+ foreach (const QString objectName, objectNames)
QVERIFY(findItem<QSGItem>(gridviewA, objectName)->x() != findItem<QSGItem>(gridviewB, objectName)->x());
gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
gridviewB->setProperty("layoutDirection", Qt::LeftToRight);
// LTR == LTR
- foreach(const QString objectName, objectNames)
+ foreach (const QString objectName, objectNames)
QCOMPARE(findItem<QSGItem>(gridviewA, objectName)->x(), findItem<QSGItem>(gridviewB, objectName)->x());
QVERIFY(gridviewB->layoutDirection() == gridviewB->effectiveLayoutDirection());
QVERIFY(gridviewB->layoutDirection() != gridviewB->effectiveLayoutDirection());
// LTR != LTR+mirror
- foreach(const QString objectName, objectNames)
+ foreach (const QString objectName, objectNames)
QVERIFY(findItem<QSGItem>(gridviewA, objectName)->x() != findItem<QSGItem>(gridviewB, objectName)->x());
gridviewA->setProperty("layoutDirection", Qt::RightToLeft);
// RTL == LTR+mirror
- foreach(const QString objectName, objectNames)
+ foreach (const QString objectName, objectNames)
QCOMPARE(findItem<QSGItem>(gridviewA, objectName)->x(), findItem<QSGItem>(gridviewB, objectName)->x());
gridviewB->setProperty("layoutDirection", Qt::RightToLeft);
// RTL != RTL+mirror
- foreach(const QString objectName, objectNames)
+ foreach (const QString objectName, objectNames)
QVERIFY(findItem<QSGItem>(gridviewA, objectName)->x() != findItem<QSGItem>(gridviewB, objectName)->x());
gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
// LTR == RTL+mirror
- foreach(const QString objectName, objectNames)
+ foreach (const QString objectName, objectNames)
QCOMPARE(findItem<QSGItem>(gridviewA, objectName)->x(), findItem<QSGItem>(gridviewB, objectName)->x());
delete canvasA;
//qDebug() << parent->childItems().count() << "children";
for (int i = 0; i < parent->childItems().count(); ++i) {
QSGItem *item = qobject_cast<QSGItem*>(parent->childItems().at(i));
- if(!item)
+ if (!item)
continue;
//qDebug() << "try" << item;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
//qDebug() << parent->childItems().count() << "children";
for (int i = 0; i < parent->childItems().count(); ++i) {
QSGItem *item = qobject_cast<QSGItem*>(parent->childItems().at(i));
- if(!item)
+ if (!item)
continue;
//qDebug() << "try" << item;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
static QString padding(" ");
for (int i = 0; i < parent->childItems().count(); ++i) {
QSGItem *item = qobject_cast<QSGItem*>(parent->childItems().at(i));
- if(!item)
+ if (!item)
continue;
QDeclarativeContext *context = QDeclarativeEngine::contextForObject(item);
qDebug() << padding.left(depth*2) << item << (context ? context->contextProperty("index").toInt() : -1);
//qDebug() << parent->childItems().count() << "children";
for (int i = 0; i < parent->childItems().count(); ++i) {
QSGItem *item = qobject_cast<QSGItem*>(parent->childItems().at(i));
- if(!item)
+ if (!item)
continue;
//qDebug() << "try" << item;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
}
public slots:
- void doPolish() {
+ void doPolish() {
polish();
}
};
} else { \
QCOMPARE(canvas.activeFocusItem(), canvas.rootItem()); \
} \
- for(QHash<QSGItem *, FocusData>::Iterator iter = focusState.begin(); \
+ for (QHash<QSGItem *, FocusData>::Iterator iter = focusState.begin(); \
iter != focusState.end(); \
iter++) { \
QCOMPARE(iter.key()->hasFocus(), iter.value().focus); \
QCOMPARE(iter.key()->hasActiveFocus(), iter.value().activeFocus); \
} \
- } while(false)
+ } while (false)
// Tests a simple set of top-level scoped items
void tst_qsgitem::simpleFocus()
focusState[item].set(false, false);
FVERIFY();
}
-
+
}
void tst_qsgitem::constructor()
//qDebug() << parent->QSGItem::children().count() << "children";
for (int i = 0; i < parent->childItems().count(); ++i) {
QSGItem *item = qobject_cast<QSGItem*>(parent->childItems().at(i));
- if(!item)
+ if (!item)
continue;
//qDebug() << "try" << item;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true);
QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true);
QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true);
-
+
//
// dynamic parenting
//
childItem2->setParentItem(parentItem2);
QCOMPARE(QSGItemPrivate::get(childItem2)->effectiveLayoutMirror, false);
QCOMPARE(QSGItemPrivate::get(childItem2)->inheritMirrorFromParent, false);
-
+
delete parentItem1;
delete parentItem2;
}
void tst_QSGItem::childrenProperty()
{
QDeclarativeComponent component(&engine, TESTDATA("childrenProperty.qml"));
-
+
QObject *o = component.create();
QVERIFY(o != 0);
void tst_QSGItem::resourcesProperty()
{
QDeclarativeComponent component(&engine, TESTDATA("resourcesProperty.qml"));
-
+
QObject *o = component.create();
QVERIFY(o != 0);
QList<int> roles() const { return QList<int>() << Name << Number; }
QString toString(int role) const {
- switch(role) {
+ switch (role) {
case Name:
return "name";
case Number:
for (int i = 0; i < roles.size(); ++i) {
int role = roles.at(i);
QVariant info;
- switch(role) {
+ switch (role) {
case Name:
info = list.at(index).first;
break;
QCOMPARE(listviewA->layoutDirection(), listviewA->effectiveLayoutDirection());
// LTR != RTL
- foreach(const QString objectName, objectNames)
+ foreach (const QString objectName, objectNames)
QVERIFY(findItem<QSGItem>(listviewA, objectName)->x() != findItem<QSGItem>(listviewB, objectName)->x());
listviewA->setProperty("layoutDirection", Qt::LeftToRight);
listviewB->setProperty("layoutDirection", Qt::LeftToRight);
// LTR == LTR
- foreach(const QString objectName, objectNames)
+ foreach (const QString objectName, objectNames)
QCOMPARE(findItem<QSGItem>(listviewA, objectName)->x(), findItem<QSGItem>(listviewB, objectName)->x());
QVERIFY(listviewB->layoutDirection() == listviewB->effectiveLayoutDirection());
QVERIFY(listviewB->layoutDirection() != listviewB->effectiveLayoutDirection());
// LTR != LTR+mirror
- foreach(const QString objectName, objectNames)
+ foreach (const QString objectName, objectNames)
QVERIFY(findItem<QSGItem>(listviewA, objectName)->x() != findItem<QSGItem>(listviewB, objectName)->x());
listviewA->setProperty("layoutDirection", Qt::RightToLeft);
// RTL == LTR+mirror
- foreach(const QString objectName, objectNames)
+ foreach (const QString objectName, objectNames)
QCOMPARE(findItem<QSGItem>(listviewA, objectName)->x(), findItem<QSGItem>(listviewB, objectName)->x());
listviewB->setProperty("layoutDirection", Qt::RightToLeft);
// RTL != RTL+mirror
- foreach(const QString objectName, objectNames)
+ foreach (const QString objectName, objectNames)
QVERIFY(findItem<QSGItem>(listviewA, objectName)->x() != findItem<QSGItem>(listviewB, objectName)->x());
listviewA->setProperty("layoutDirection", Qt::LeftToRight);
// LTR == RTL+mirror
- foreach(const QString objectName, objectNames)
+ foreach (const QString objectName, objectNames)
QCOMPARE(findItem<QSGItem>(listviewA, objectName)->x(), findItem<QSGItem>(listviewB, objectName)->x());
delete canvasA;
QCOMPARE(listview->contentY(), -30.);
QCOMPARE(listview->yOrigin(), 0.);
-
+
// check end bound
listview->positionViewAtEnd();
qreal pos = listview->contentY();
listview->setTopMargin(20);
QCOMPARE(listview->yOrigin(), 20.);
QTRY_COMPARE(listview->contentY(), 0.);
-
+
// check end bound
listview->positionViewAtEnd();
pos = listview->contentY();
//qDebug() << parent->childItems().count() << "children";
for (int i = 0; i < parent->childItems().count(); ++i) {
QSGItem *item = qobject_cast<QSGItem*>(parent->childItems().at(i));
- if(!item)
+ if (!item)
continue;
//qDebug() << "try" << item;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
//qDebug() << parent->childItems().count() << "children";
for (int i = 0; i < parent->childItems().count(); ++i) {
QSGItem *item = qobject_cast<QSGItem*>(parent->childItems().at(i));
- if(!item || !item->isVisible())
+ if (!item || !item->isVisible())
continue;
//qDebug() << "try" << item;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
static QString padding(" ");
for (int i = 0; i < parent->childItems().count(); ++i) {
QSGItem *item = qobject_cast<QSGItem*>(parent->childItems().at(i));
- if(!item)
+ if (!item)
continue;
qDebug() << padding.left(depth*2) << item;
dumpTree(item, depth+1);
QSGItem *item = qobject_cast<QSGItem*>(component.create());
QVERIFY(item);
- QSGLoader *loader = qobject_cast<QSGLoader*>(item->QSGItem::childItems().at(0));
+ QSGLoader *loader = qobject_cast<QSGLoader*>(item->QSGItem::childItems().at(0));
QVERIFY(loader);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
QSGItem *item = qobject_cast<QSGItem*>(component.create());
QVERIFY(item);
- QSGLoader *loader = qobject_cast<QSGLoader*>(item->QSGItem::childItems().at(0));
+ QSGLoader *loader = qobject_cast<QSGLoader*>(item->QSGItem::childItems().at(0));
QVERIFY(loader);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
QSGItem *item = qobject_cast<QSGItem*>(component.create());
QVERIFY(item);
- QSGLoader *loader = qobject_cast<QSGLoader*>(item->QSGItem::children().at(1));
+ QSGLoader *loader = qobject_cast<QSGLoader*>(item->QSGItem::children().at(1));
QVERIFY(loader);
QTRY_VERIFY(loader->status() == QSGLoader::Ready);
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-CONFIG += parallel_test
+CONFIG += parallel_test
QT += core-private gui-private v8-private declarative-private widgets testlib
QCOMPARE(firstItem->pos() + offset, start);
pathview->setOffset(1.0);
- for(int i=0; i<model.count(); i++){
+ for (int i=0; i<model.count(); i++) {
QSGRectangle *curItem = findItem<QSGRectangle>(pathview, "wrapper", i);
QPointF itemPos(path->pointAt(0.25 + i*0.25));
QCOMPARE(curItem->pos() + offset, QPointF(qRound(itemPos.x()), qRound(itemPos.y())));
//qDebug() << parent->childItems().count() << "children";
for (int i = 0; i < parent->childItems().count(); ++i) {
QSGItem *item = qobject_cast<QSGItem*>(parent->childItems().at(i));
- if(!item)
+ if (!item)
continue;
//qDebug() << "try" << item;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
//qDebug() << parent->QSGItem::children().count() << "children";
for (int i = 0; i < parent->childItems().count(); ++i) {
QSGItem *item = qobject_cast<QSGItem*>(parent->childItems().at(i));
- if(!item)
+ if (!item)
continue;
//qDebug() << "try" << item;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
QList<QString> objectNames;
objectNames << "one" << "two" << "three" << "four" << "five";
- foreach(const QString qmlFile, qmlFiles) {
+ foreach (const QString qmlFile, qmlFiles) {
QSGView *canvasA = createView(TESTDATA(qmlFile));
QSGItem *rootA = qobject_cast<QSGItem*>(canvasA->rootObject());
rootA->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
// LTR != RTL
- foreach(const QString objectName, objectNames) {
+ foreach (const QString objectName, objectNames) {
// horizontal.qml only has three items
if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
break;
rootPrivateB->resolveLayoutMirror();
// RTL == mirror
- foreach(const QString objectName, objectNames) {
+ foreach (const QString objectName, objectNames) {
// horizontal.qml only has three items
if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
break;
rootB->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
// LTR == RTL + mirror
- foreach(const QString objectName, objectNames) {
+ foreach (const QString objectName, objectNames) {
// horizontal.qml only has three items
if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
break;
{
QSGView *canvas = createView();
QObjectList data;
- for(int i=0; i<100; i++)
+ for (int i=0; i<100; i++)
data << new MyObject(i);
QDeclarativeContext *ctxt = canvas->rootContext();
//qDebug() << parent->children().count() << "children";
for (int i = 0; i < parent->children().count(); ++i) {
QSGItem *item = qobject_cast<QSGItem*>(parent->children().at(i));
- if(!item)
+ if (!item)
continue;
//qDebug() << "try" << item;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
void lineCount();
void lineHeight();
- // ### these tests may be trivial
+ // ### these tests may be trivial
void horizontalAlignment();
void horizontalAlignment_RightToLeft();
void verticalAlignment();
delete textObject;
}
- {
+ {
QString componentStr = "import QtQuick 2.0\nText { font.bold: true; text: \"Hello World\" }";
QDeclarativeComponent textComponent(&engine);
textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
delete textObject;
}
- {
+ {
QString componentStr = "import QtQuick 2.0\nText { font.italic: true; text: \"Hello World\" }";
QDeclarativeComponent textComponent(&engine);
textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
delete textObject;
}
- {
+ {
QString componentStr = "import QtQuick 2.0\nText { font.family: \"Helvetica\"; text: \"Hello World\" }";
QDeclarativeComponent textComponent(&engine);
textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
delete textObject;
}
- {
+ {
QString componentStr = "import QtQuick 2.0\nText { font.family: \"\"; text: \"Hello World\" }";
QDeclarativeComponent textComponent(&engine);
textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
{
//test style
for (int i = 0; i < styles.size(); i++)
- {
+ {
QString componentStr = "import QtQuick 2.0\nText { style: \"" + styleStrings.at(i) + "\"; styleColor: \"white\"; text: \"Hello World\" }";
QDeclarativeComponent textComponent(&engine);
textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
{
//test style
for (int i = 0; i < colorStrings.size(); i++)
- {
+ {
QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
QDeclarativeComponent textComponent(&engine);
textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
}
for (int i = 0; i < colorStrings.size(); i++)
- {
+ {
QString componentStr = "import QtQuick 2.0\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
QDeclarativeComponent textComponent(&engine);
textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
delete textObject;
}
-
+
for (int i = 0; i < colorStrings.size(); i++)
- {
+ {
for (int j = 0; j < colorStrings.size(); j++)
{
QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStrings.at(i) + "\"; styleColor: \"" + colorStrings.at(j) + "\"; text: \"Hello World\" }";
if (!error.isEmpty())
QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
-
+
QDeclarativeComponent textComponent(&engine, qmlfile);
QSGText *textObject = qobject_cast<QSGText*>(textComponent.create());
void alignments();
void alignments_data();
- // ### these tests may be trivial
+ // ### these tests may be trivial
void hAlign();
void hAlign_RightToLeft();
void vAlign();
// need a different test to do alpha channel test
// << "#AA0011DD"
// << "#00F16B11";
- //
+ //
}
void tst_qsgtextedit::text()
void tst_qsgtextedit::font()
{
//test size, then bold, then italic, then family
- {
+ {
QString componentStr = "import QtQuick 2.0\nTextEdit { font.pointSize: 40; text: \"Hello World\" }";
QDeclarativeComponent texteditComponent(&engine);
texteditComponent.setData(componentStr.toLatin1(), QUrl());
QCOMPARE(textEditObject->font().italic(), false);
}
- {
+ {
QString componentStr = "import QtQuick 2.0\nTextEdit { font.bold: true; text: \"Hello World\" }";
QDeclarativeComponent texteditComponent(&engine);
texteditComponent.setData(componentStr.toLatin1(), QUrl());
QCOMPARE(textEditObject->font().italic(), false);
}
- {
+ {
QString componentStr = "import QtQuick 2.0\nTextEdit { font.italic: true; text: \"Hello World\" }";
QDeclarativeComponent texteditComponent(&engine);
texteditComponent.setData(componentStr.toLatin1(), QUrl());
QCOMPARE(textEditObject->font().bold(), false);
}
- {
+ {
QString componentStr = "import QtQuick 2.0\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
QDeclarativeComponent texteditComponent(&engine);
texteditComponent.setData(componentStr.toLatin1(), QUrl());
QCOMPARE(textEditObject->font().italic(), false);
}
- {
+ {
QString componentStr = "import QtQuick 2.0\nTextEdit { font.family: \"\"; text: \"Hello World\" }";
QDeclarativeComponent texteditComponent(&engine);
texteditComponent.setData(componentStr.toLatin1(), QUrl());
}
//test normal
for (int i = 0; i < colorStrings.size(); i++)
- {
+ {
QString componentStr = "import QtQuick 2.0\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
QDeclarativeComponent texteditComponent(&engine);
texteditComponent.setData(componentStr.toLatin1(), QUrl());
void tst_qsgtextedit::textMargin()
{
- for(qreal i=0; i<=10; i+=0.3){
+ for (qreal i=0; i<=10; i+=0.3) {
QString componentStr = "import QtQuick 2.0\nTextEdit { textMargin: " + QString::number(i) + "; text: \"Hello World\" }";
QDeclarativeComponent texteditComponent(&engine);
texteditComponent.setData(componentStr.toLatin1(), QUrl());
//Test selection follows cursor
- for(int i=0; i<= testStr.size(); i++) {
+ for (int i=0; i<= testStr.size(); i++) {
textEditObject->setCursorPosition(i);
QCOMPARE(textEditObject->cursorPosition(), i);
QCOMPARE(textEditObject->selectionStart(), i);
QVERIFY(textEditObject->selectedText().isNull());
//Test selection
- for(int i=0; i<= testStr.size(); i++) {
+ for (int i=0; i<= testStr.size(); i++) {
textEditObject->select(0,i);
QCOMPARE(testStr.mid(0,i), textEditObject->selectedText());
}
- for(int i=0; i<= testStr.size(); i++) {
+ for (int i=0; i<= testStr.size(); i++) {
textEditObject->select(i,testStr.size());
QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText());
}
QVERIFY(delegateObject);
QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello"));
//Test Delegate gets moved
- for(int i=0; i<= textEditObject->text().length(); i++){
+ for (int i=0; i<= textEditObject->text().length(); i++) {
textEditObject->setCursorPosition(i);
QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
QTRY_VERIFY(edit->hasActiveFocus() == true);
QVERIFY(edit->isReadOnly() == true);
QString initial = edit->text();
- for(int k=Qt::Key_0; k<=Qt::Key_Z; k++)
+ for (int k=Qt::Key_0; k<=Qt::Key_Z; k++)
simulateKey(&canvas, k);
simulateKey(&canvas, Qt::Key_Return);
simulateKey(&canvas, Qt::Key_Space);
void tst_qsgtextinput::font()
{
//test size, then bold, then italic, then family
- {
+ {
QString componentStr = "import QtQuick 2.0\nTextInput { font.pointSize: 40; text: \"Hello World\" }";
QDeclarativeComponent textinputComponent(&engine);
textinputComponent.setData(componentStr.toLatin1(), QUrl());
delete textinputObject;
}
- {
+ {
QString componentStr = "import QtQuick 2.0\nTextInput { font.bold: true; text: \"Hello World\" }";
QDeclarativeComponent textinputComponent(&engine);
textinputComponent.setData(componentStr.toLatin1(), QUrl());
delete textinputObject;
}
- {
+ {
QString componentStr = "import QtQuick 2.0\nTextInput { font.italic: true; text: \"Hello World\" }";
QDeclarativeComponent textinputComponent(&engine);
textinputComponent.setData(componentStr.toLatin1(), QUrl());
delete textinputObject;
}
-
- {
+
+ {
QString componentStr = "import QtQuick 2.0\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }";
QDeclarativeComponent textinputComponent(&engine);
textinputComponent.setData(componentStr.toLatin1(), QUrl());
delete textinputObject;
}
- {
+ {
QString componentStr = "import QtQuick 2.0\nTextInput { font.family: \"\"; text: \"Hello World\" }";
QDeclarativeComponent textinputComponent(&engine);
textinputComponent.setData(componentStr.toLatin1(), QUrl());
{
//test color
for (int i = 0; i < colorStrings.size(); i++)
- {
+ {
QString componentStr = "import QtQuick 2.0\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
QDeclarativeComponent textinputComponent(&engine);
textinputComponent.setData(componentStr.toLatin1(), QUrl());
//test selected text color
for (int i = 0; i < colorStrings.size(); i++)
- {
+ {
QString componentStr = "import QtQuick 2.0\nTextInput { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
QDeclarativeComponent textinputComponent(&engine);
textinputComponent.setData(componentStr.toLatin1(), QUrl());
//Test selection follows cursor
- for(int i=0; i<= testStr.size(); i++) {
+ for (int i=0; i<= testStr.size(); i++) {
textinputObject->setCursorPosition(i);
QCOMPARE(textinputObject->cursorPosition(), i);
QCOMPARE(textinputObject->selectionStart(), i);
QVERIFY(textinputObject->selectedText().isNull());
//Test selection
- for(int i=0; i<= testStr.size(); i++) {
+ for (int i=0; i<= testStr.size(); i++) {
textinputObject->select(0,i);
QCOMPARE(testStr.mid(0,i), textinputObject->selectedText());
}
- for(int i=0; i<= testStr.size(); i++) {
+ for (int i=0; i<= testStr.size(); i++) {
textinputObject->select(i,testStr.size());
QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText());
}
QVERIFY(textinputObject != 0);
QVERIFY(textinputObject->text().isEmpty());
QVERIFY(textinputObject->maxLength() == 10);
- foreach(const QString &str, standard){
+ foreach (const QString &str, standard) {
QVERIFY(textinputObject->text().length() <= 10);
textinputObject->setText(str);
QVERIFY(textinputObject->text().length() <= 10);
textinputObject->setText("");
QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
- for(int i=0; i<20; i++){
+ for (int i=0; i<20; i++) {
QTRY_COMPARE(textinputObject->text().length(), qMin(i,10));
//simulateKey(&canvas, Qt::Key_A);
QTest::keyPress(&canvas, Qt::Key_A);
QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
QVERIFY(textinputObject->text().length() == 0);
QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; "));
- for(int i=0; i<10; i++){
+ for (int i=0; i<10; i++) {
QTRY_COMPARE(qMin(i,8), textinputObject->text().length());
QCOMPARE(i>=4, textinputObject->hasAcceptableInput());
//simulateKey(&canvas, Qt::Key_A);
QVERIFY(delegateObject);
QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello"));
//Test Delegate gets moved
- for(int i=0; i<= textInputObject->text().length(); i++){
+ for (int i=0; i<= textInputObject->text().length(); i++) {
textInputObject->setCursorPosition(i);
QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));
QTRY_VERIFY(input->hasActiveFocus() == true);
QVERIFY(input->isReadOnly() == true);
QString initial = input->text();
- for(int k=Qt::Key_0; k<=Qt::Key_Z; k++)
+ for (int k=Qt::Key_0; k<=Qt::Key_Z; k++)
simulateKey(&canvas, k);
simulateKey(&canvas, Qt::Key_Return);
simulateKey(&canvas, Qt::Key_Space);
//qDebug() << parent->childItems().count() << "children";
for (int i = 0; i < parent->childItems().count(); ++i) {
QSGItem *item = qobject_cast<QSGItem*>(parent->childItems().at(i));
- if(!item)
+ if (!item)
continue;
//qDebug() << "try" << item;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {