void Highlight::setItem(QQuickItem *item) { if (m_item) m_item->disconnect(this); if (item) { connect(item, SIGNAL(xChanged()), SLOT(adjust())); connect(item, SIGNAL(yChanged()), SLOT(adjust())); connect(item, SIGNAL(widthChanged()), SLOT(adjust())); connect(item, SIGNAL(heightChanged()), SLOT(adjust())); connect(item, SIGNAL(rotationChanged()), SLOT(adjust())); connect(item, SIGNAL(transformOriginChanged(TransformOrigin)), SLOT(adjust())); } QQuickWindow *view = item->window(); QQuickItem * contentItem = view->contentItem(); if (contentItem) { connect(contentItem, SIGNAL(xChanged()), SLOT(adjust())); connect(contentItem, SIGNAL(yChanged()), SLOT(adjust())); connect(contentItem, SIGNAL(widthChanged()), SLOT(adjust())); connect(contentItem, SIGNAL(heightChanged()), SLOT(adjust())); connect(contentItem, SIGNAL(rotationChanged()), SLOT(adjust())); connect(contentItem, SIGNAL(transformOriginChanged(TransformOrigin)), SLOT(adjust())); } m_item = item; setContentsSize(view->size()); adjust(); }
void Highlight::setItem(QQuickItem *item) { if (m_item) m_item->disconnect(this); if (item) { connect(item, &QQuickItem::xChanged, this, &Highlight::adjust); connect(item, &QQuickItem::yChanged, this, &Highlight::adjust); connect(item, &QQuickItem::widthChanged, this, &Highlight::adjust); connect(item, &QQuickItem::heightChanged, this, &Highlight::adjust); connect(item, &QQuickItem::rotationChanged, this, &Highlight::adjust); connect(item, &QQuickItem::transformOriginChanged, this, &Highlight::adjust); } QQuickWindow *view = item->window(); QQuickItem * contentItem = view->contentItem(); if (contentItem) { connect(contentItem, &QQuickItem::xChanged, this, &Highlight::adjust); connect(contentItem, &QQuickItem::yChanged, this, &Highlight::adjust); connect(contentItem, &QQuickItem::widthChanged, this, &Highlight::adjust); connect(contentItem, &QQuickItem::heightChanged, this, &Highlight::adjust); connect(contentItem, &QQuickItem::rotationChanged, this, &Highlight::adjust); connect(contentItem, &QQuickItem::transformOriginChanged, this, &Highlight::adjust); } m_item = item; setContentsSize(view->size()); adjust(); }
int QDeclarativePaintedItem::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDeclarativeItem::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 5) qt_static_metacall(this, _c, _id, _a); _id -= 5; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QSize*>(_v) = contentsSize(); break; case 1: *reinterpret_cast< QColor*>(_v) = fillColor(); break; case 2: *reinterpret_cast< int*>(_v) = pixelCacheSize(); break; case 3: *reinterpret_cast< bool*>(_v) = smoothCache(); break; case 4: *reinterpret_cast< qreal*>(_v) = contentsScale(); break; } _id -= 5; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setContentsSize(*reinterpret_cast< QSize*>(_v)); break; case 1: setFillColor(*reinterpret_cast< QColor*>(_v)); break; case 2: setPixelCacheSize(*reinterpret_cast< int*>(_v)); break; case 3: setSmoothCache(*reinterpret_cast< bool*>(_v)); break; case 4: setContentsScale(*reinterpret_cast< qreal*>(_v)); break; } _id -= 5; } else if (_c == QMetaObject::ResetProperty) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 5; } #endif // QT_NO_PROPERTIES return _id; }
//### we should perhaps be a bit smarter here -- depending on what has changed, we shouldn't // need to do all the calculations each time void QDeclarativeTextEdit::updateSize() { Q_D(QDeclarativeTextEdit); if (isComponentComplete()) { QFontMetrics fm = QFontMetrics(d->font); int dy = height(); // ### assumes that if the width is set, the text will fill to edges // ### (unless wrap is false, then clipping will occur) if (widthValid()) d->document->setTextWidth(width()); dy -= (int)d->document->size().height(); int yoff = 0; if (heightValid()) { if (d->vAlign == AlignBottom) yoff = dy; else if (d->vAlign == AlignVCenter) yoff = dy/2; } setBaselineOffset(fm.ascent() + yoff + d->textMargin); //### need to comfirm cost of always setting these int newWidth = (int)d->document->idealWidth(); d->document->setTextWidth(newWidth); // ### QTextDoc> Alignment will not work unless textWidth is set. Does Text need this line as well? int cursorWidth = 1; if(d->cursor) cursorWidth = d->cursor->width(); newWidth += cursorWidth; if(!d->document->isEmpty()) newWidth += 3;// ### Need a better way of accounting for space between char and cursor // ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed. setImplicitWidth(newWidth); setImplicitHeight(d->text.isEmpty() ? fm.height() : (int)d->document->size().height()); setContentsSize(QSize(width(), height())); } else { d->dirty = true; } emit update(); }
/*! This convenience function is equivalent to calling setContentsSize(QSize()). */ void QQuickPaintedItem::resetContentsSize() { setContentsSize(QSize()); }