diff options
Diffstat (limited to 'src/declarative/graphicsitems')
4 files changed, 34 insertions, 41 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp index c81c2d2..32a6321 100644 --- a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp @@ -45,7 +45,7 @@ #ifndef QT_NO_MOVIE #include <qdeclarativeinfo.h> -#include <qdeclarativeengine.h> +#include <private/qdeclarativeengine_p.h> #include <QMovie> #include <QNetworkRequest> @@ -180,14 +180,6 @@ int QDeclarativeAnimatedImage::frameCount() const return d->_movie->frameCount(); } -static QString toLocalFileOrQrc(const QUrl& url) -{ - QString r = url.toLocalFile(); - if (r.isEmpty() && url.scheme() == QLatin1String("qrc")) - r = QLatin1Char(':') + url.path(); - return r; -} - void QDeclarativeAnimatedImage::setSource(const QUrl &url) { Q_D(QDeclarativeAnimatedImage); @@ -209,7 +201,7 @@ void QDeclarativeAnimatedImage::setSource(const QUrl &url) d->status = Null; } else { #ifndef QT_NO_LOCALFILE_OPTIMIZED_QML - QString lf = toLocalFileOrQrc(url); + QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url); if (!lf.isEmpty()) { //### should be unified with movieRequestFinished d->_movie = new QMovie(lf); diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index 229e15b..1f1e453 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -42,8 +42,8 @@ #include "private/qdeclarativeborderimage_p.h" #include "private/qdeclarativeborderimage_p_p.h" -#include <qdeclarativeengine.h> #include <qdeclarativeinfo.h> +#include <private/qdeclarativeengine_p.h> #include <QNetworkRequest> #include <QNetworkReply> @@ -152,16 +152,6 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage() The URL may be absolute, or relative to the URL of the component. */ - -static QString toLocalFileOrQrc(const QUrl& url) -{ - QString r = url.toLocalFile(); - if (r.isEmpty() && url.scheme() == QLatin1String("qrc")) - r = QLatin1Char(':') + url.path(); - return r; -} - - void QDeclarativeBorderImage::setSource(const QUrl &url) { Q_D(QDeclarativeBorderImage); @@ -210,7 +200,7 @@ void QDeclarativeBorderImage::load() d->status = Loading; if (d->url.path().endsWith(QLatin1String("sci"))) { #ifndef QT_NO_LOCALFILE_OPTIMIZED_QML - QString lf = toLocalFileOrQrc(d->url); + QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url); if (!lf.isEmpty()) { QFile file(lf); file.open(QIODevice::ReadOnly); diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 40d37a2..7b00d2f 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -523,7 +523,7 @@ void QDeclarativeTextEdit::setCursorVisible(bool on) QFocusEvent focusEvent(on ? QEvent::FocusIn : QEvent::FocusOut); if (!on && !d->persistentSelection) d->control->setCursorIsFocusIndicator(true); - d->control->processEvent(&focusEvent, QPointF(0, 0)); + d->control->processEvent(&focusEvent, QPointF(0, -d->yoff)); emit cursorVisibleChanged(d->cursorVisible); } @@ -860,7 +860,7 @@ Qt::TextInteractionFlags QDeclarativeTextEdit::textInteractionFlags() const QRect QDeclarativeTextEdit::cursorRect() const { Q_D(const QDeclarativeTextEdit); - return d->control->cursorRect().toRect(); + return d->control->cursorRect().toRect().translated(0,-d->yoff); } @@ -872,7 +872,7 @@ bool QDeclarativeTextEdit::event(QEvent *event) { Q_D(QDeclarativeTextEdit); if (event->type() == QEvent::ShortcutOverride) { - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); return event->isAccepted(); } return QDeclarativePaintedItem::event(event); @@ -887,7 +887,7 @@ void QDeclarativeTextEdit::keyPressEvent(QKeyEvent *event) Q_D(QDeclarativeTextEdit); keyPressPreHandler(event); if (!event->isAccepted()) - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) QDeclarativePaintedItem::keyPressEvent(event); } @@ -901,7 +901,7 @@ void QDeclarativeTextEdit::keyReleaseEvent(QKeyEvent *event) Q_D(QDeclarativeTextEdit); keyReleasePreHandler(event); if (!event->isAccepted()) - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) QDeclarativePaintedItem::keyReleaseEvent(event); } @@ -942,7 +942,7 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) if (!hadFocus && hasFocus()) d->clickCausedFocus = true; if (event->type() != QEvent::GraphicsSceneMouseDoubleClick || d->selectByMouse) - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) QDeclarativePaintedItem::mousePressEvent(event); } @@ -959,7 +959,7 @@ void QDeclarativeTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->clickCausedFocus); d->clickCausedFocus = false; - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) QDeclarativePaintedItem::mouseReleaseEvent(event); } @@ -972,7 +972,7 @@ void QDeclarativeTextEdit::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event { Q_D(QDeclarativeTextEdit); if (d->selectByMouse) { - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) QDeclarativePaintedItem::mouseDoubleClickEvent(event); } else { @@ -988,7 +988,7 @@ void QDeclarativeTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeTextEdit); if (d->selectByMouse) { - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) QDeclarativePaintedItem::mouseMoveEvent(event); event->setAccepted(true); @@ -1004,7 +1004,7 @@ Handles the given input method \a event. void QDeclarativeTextEdit::inputMethodEvent(QInputMethodEvent *event) { Q_D(QDeclarativeTextEdit); - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); } /*! @@ -1026,13 +1026,20 @@ void QDeclarativeTextEdit::drawContents(QPainter *painter, const QRect &bounds) Q_D(QDeclarativeTextEdit); painter->setRenderHint(QPainter::TextAntialiasing, true); + painter->translate(0,d->yoff); - d->control->drawContents(painter, bounds); + d->control->drawContents(painter, bounds.translated(0,-d->yoff)); + + painter->translate(0,-d->yoff); } -void QDeclarativeTextEdit::updateImgCache(const QRectF &r) +void QDeclarativeTextEdit::updateImgCache(const QRectF &rf) { - dirtyCache(r.toRect()); + Q_D(const QDeclarativeTextEdit); + QRect r = rf.toRect(); + if (r != QRect(0,0,INT_MAX,INT_MAX)) // Don't translate "everything" + r = r.translated(0,d->yoff); + dirtyCache(r); emit update(); } @@ -1141,18 +1148,20 @@ void QDeclarativeTextEdit::updateSize() d->document->setTextWidth(width()); dy -= (int)d->document->size().height(); - int yoff = 0; if (heightValid()) { if (d->vAlign == AlignBottom) - yoff = dy; + d->yoff = dy; else if (d->vAlign == AlignVCenter) - yoff = dy/2; + d->yoff = dy/2; + } else { + d->yoff = 0; } - setBaselineOffset(fm.ascent() + yoff + d->textMargin); + setBaselineOffset(fm.ascent() + d->yoff + d->textMargin); //### need to comfirm cost of always setting these int newWidth = qCeil(d->document->idealWidth()); - d->document->setTextWidth(newWidth); // ### QTextDoc> Alignment will not work unless textWidth is set. Does Text need this line as well? + if (!widthValid()) + d->document->setTextWidth(newWidth); // ### Text does not align if width is not set (QTextDoc bug) int cursorWidth = 1; if(d->cursor) cursorWidth = d->cursor->width(); diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h index 885620d..d96796c 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h @@ -73,7 +73,8 @@ public: persistentSelection(true), clickCausedFocus(false), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), cursorComponent(0), cursor(0), format(QDeclarativeTextEdit::AutoText), document(0), wrapMode(QDeclarativeTextEdit::NoWrap), - selectByMouse(false) + selectByMouse(false), + yoff(0) { } @@ -112,6 +113,7 @@ public: QTextControl *control; QDeclarativeTextEdit::WrapMode wrapMode; bool selectByMouse; + int yoff; }; QT_END_NAMESPACE |