summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsborderimage.cpp2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem.cpp2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspainteditem.cpp24
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspainteditem_p.h7
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextedit.cpp76
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextedit_p.h7
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextinput.cpp18
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview.cpp39
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview_p.h4
9 files changed, 39 insertions, 140 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
index 6f953bc..d7d725b 100644
--- a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
@@ -394,7 +394,7 @@ void QmlGraphicsBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem *
p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
const QmlGraphicsScaleGrid *border = d->getScaleGrid();
- QMargins margins(border->top(), border->left(), border->bottom(), border->right());
+ QMargins margins(border->left(), border->top(), border->right(), border->bottom());
QTileRules rules((Qt::TileRule)d->horizontalTileMode, (Qt::TileRule)d->verticalTileMode);
qDrawBorderPixmap(p, QRect(0, 0, (int)d->width, (int)d->height), margins, d->pix, d->pix.rect(), margins, rules);
if (d->smooth) {
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
index fb6afb1..263aea5 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
@@ -2307,7 +2307,7 @@ void QmlGraphicsItem::setBaselineOffset(qreal offset)
Opacity is an \e inherited attribute. That is, the opacity is
also applied individually to child items. In almost all cases this
is what you want. If you can spot the issue in the following
- example, you might need to use an opacity filter (not yet available) instead.
+ example, you might need to use an \l Opacity effect instead.
\table
\row
diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp b/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp
index b1b1210..2f467e7 100644
--- a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp
@@ -223,10 +223,14 @@ void QmlGraphicsPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *
}
QRegion topaint = p->clipRegion();
- if (topaint.isEmpty())
- topaint = effectiveClip;
- else
+ if (topaint.isEmpty()) {
+ if (effectiveClip.isEmpty())
+ topaint = QRect(0,0,p->device()->width(),p->device()->height());
+ else
+ topaint = effectiveClip;
+ } else {
topaint &= effectiveClip;
+ }
topaint &= content;
QRegion uncached(content);
@@ -323,27 +327,26 @@ void QmlGraphicsPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *
}
/*!
- \qmlproperty int PaintedItem::cacheSize
+ \qmlproperty int PaintedItem::pixelCacheSize
This property holds the maximum number of pixels of image cache to
allow. The default is 0.1 megapixels. The cache will not be larger
- than the (unscaled) size of the item.
+ than the (unscaled) size of the WebView.
*/
-
/*!
- \property QmlGraphicsPaintedItem::cacheSize
+ \property QmlGraphicsPaintedItem::pixelCacheSize
The maximum number of pixels of image cache to allow. The default
is 0.1 megapixels. The cache will not be larger than the (unscaled)
size of the QmlGraphicsPaintedItem.
*/
-int QmlGraphicsPaintedItem::cacheSize() const
+int QmlGraphicsPaintedItem::pixelCacheSize() const
{
Q_D(const QmlGraphicsPaintedItem);
return d->max_imagecache_size;
}
-void QmlGraphicsPaintedItem::setCacheSize(int pixels)
+void QmlGraphicsPaintedItem::setPixelCacheSize(int pixels)
{
Q_D(QmlGraphicsPaintedItem);
if (pixels < d->max_imagecache_size) {
@@ -369,6 +372,8 @@ void QmlGraphicsPaintedItem::setCacheSize(int pixels)
d->max_imagecache_size = pixels;
}
+
+
/*!
\property QmlGraphicsPaintedItem::fillColor
@@ -419,5 +424,4 @@ void QmlGraphicsPaintedItem::setSmoothCache(bool on)
}
-
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h b/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h
index 0805330..f6bb078 100644
--- a/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h
@@ -58,9 +58,10 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsPaintedItem : public QmlGraphicsItem
Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize)
Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged)
- Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize)
+ Q_PROPERTY(int pixelCacheSize READ pixelCacheSize WRITE setPixelCacheSize)
Q_PROPERTY(bool smoothCache READ smoothCache WRITE setSmoothCache)
+
public:
QmlGraphicsPaintedItem(QmlGraphicsItem *parent=0);
~QmlGraphicsPaintedItem();
@@ -68,8 +69,8 @@ public:
QSize contentsSize() const;
void setContentsSize(const QSize &);
- int cacheSize() const;
- void setCacheSize(int pixels);
+ int pixelCacheSize() const;
+ void setPixelCacheSize(int pixels);
bool smoothCache() const;
void setSmoothCache(bool on);
diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
index b691304..2588f7d 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
@@ -686,29 +686,6 @@ Qt::TextInteractionFlags QmlGraphicsTextEdit::textInteractionFlags() const
}
/*!
- Returns the cursor for the point at the given \a pos on the
- text edit.
-*/
-QTextCursor QmlGraphicsTextEdit::cursorForPosition(const QPoint &pos) const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->control->cursorForPosition(pos);
-}
-
-/*!
- Returns the rectangle where the given text \a cursor is rendered
- within the text edit.
-*/
-QRect QmlGraphicsTextEdit::cursorRect(const QTextCursor &cursor) const
-{
- Q_D(const QmlGraphicsTextEdit);
- if (cursor.isNull())
- return QRect();
-
- return d->control->cursorRect(cursor).toRect();
-}
-
-/*!
Returns the rectangle where the text cursor is rendered
within the text edit.
*/
@@ -720,35 +697,6 @@ QRect QmlGraphicsTextEdit::cursorRect() const
/*!
- Sets the text cursor for the text edit to the given \a cursor.
-*/
-void QmlGraphicsTextEdit::setTextCursor(const QTextCursor &cursor)
-{
- Q_D(QmlGraphicsTextEdit);
- d->control->setTextCursor(cursor);
-}
-
-/*!
- Returns the text cursor for the text edit.
-*/
-QTextCursor QmlGraphicsTextEdit::textCursor() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->control->textCursor();
-}
-
-/*!
-Moves the cursor by performing the given \a operation.
-
-If \a mode is QTextCursor::KeepAnchor, the cursor selects the text it moves over. This is the same effect that the user achieves when they hold down the Shift key and move the cursor with the cursor keys.
-*/
-void QmlGraphicsTextEdit::moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode)
-{
- Q_D(QmlGraphicsTextEdit);
- d->control->moveCursor(operation, mode);
-}
-
-/*!
\overload
Handles the given \a event.
*/
@@ -769,28 +717,7 @@ Handles the given key \a event.
void QmlGraphicsTextEdit::keyPressEvent(QKeyEvent *event)
{
Q_D(QmlGraphicsTextEdit);
- //### this causes non-standard cursor behavior in some cases.
- // is it still needed?
- /*QTextCursor c = textCursor();
- QTextCursor::MoveOperation op = QTextCursor::NoMove;
- if (event == QKeySequence::MoveToNextChar) {
- op = QTextCursor::Right;
- } else if (event == QKeySequence::MoveToPreviousChar) {
- op = QTextCursor::Left;
- } else if (event == QKeySequence::MoveToNextWord) {
- op = QTextCursor::WordRight;
- } else if (event == QKeySequence::MoveToPreviousWord) {
- op = QTextCursor::WordLeft;
- } else if (event == QKeySequence::MoveToNextLine) {
- op = QTextCursor::Down;
- } else if (event == QKeySequence::MoveToPreviousLine) {
- op = QTextCursor::Up;
- }
-
- if (op != QTextCursor::NoMove && !c.movePosition(op))
- event->ignore();
- else*/
- d->control->processEvent(event, QPointF(0, 0));
+ d->control->processEvent(event, QPointF(0, 0));
if (!event->isAccepted())
QmlGraphicsPaintedItem::keyPressEvent(event);
@@ -942,6 +869,7 @@ void QmlGraphicsTextEditPrivate::init()
q->setFlag(QGraphicsItem::ItemAcceptsInputMethod);
control = new QTextControl(q);
+ control->setIgnoreUnusedNavigationEvents(true);
QObject::connect(control, SIGNAL(updateRequest(QRectF)), q, SLOT(updateImgCache(QRectF)));
diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit_p.h b/src/declarative/graphicsitems/qmlgraphicstextedit_p.h
index fa95373..1ddfa6b 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextedit_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicstextedit_p.h
@@ -169,15 +169,8 @@ public:
void setTextInteractionFlags(Qt::TextInteractionFlags flags);
Qt::TextInteractionFlags textInteractionFlags() const;
- QTextCursor cursorForPosition(const QPoint &pos) const;
- QRect cursorRect(const QTextCursor &cursor) const;
QRect cursorRect() const;
- void setTextCursor(const QTextCursor &cursor);
- QTextCursor textCursor() const;
-
- void moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
-
QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
Q_SIGNALS:
diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
index 56f59d8..b7d4e8c 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
@@ -212,8 +212,9 @@ QmlGraphicsTextInput::HAlignment QmlGraphicsTextInput::hAlign() const
void QmlGraphicsTextInput::setHAlign(HAlignment align)
{
Q_D(QmlGraphicsTextInput);
+ if(align == d->hAlign)
+ return;
d->hAlign = align;
- //TODO: implement
}
bool QmlGraphicsTextInput::isReadOnly() const
@@ -650,6 +651,21 @@ void QmlGraphicsTextInput::drawContents(QPainter *p, const QRect &r)
}
QPoint offset = QPoint(0,0);
+ if(d->hAlign != AlignLeft){
+ QFontMetrics fm = QFontMetrics(d->font);
+ //###Is this using bearing appropriately?
+ int minLB = qMax(0, -fm.minLeftBearing());
+ int minRB = qMax(0, -fm.minRightBearing());
+ int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB;
+ int hOffset = 0;
+ if(d->hAlign == AlignRight){
+ hOffset = width() - widthUsed;
+ }else if(d->hAlign == AlignHCenter){
+ hOffset = (width() - widthUsed) / 2;
+ }
+ hOffset -= minLB;
+ offset = QPoint(hOffset, 0);
+ }
QRect clipRect = r;
d->control->draw(p, offset, clipRect, flags);
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
index e165e59..aedf787 100644
--- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
@@ -434,45 +434,6 @@ void QmlGraphicsWebView::paintPage(const QRect& r)
}
/*!
- \qmlproperty int WebView::pixelCacheSize
-
- This property holds the maximum number of pixels of image cache to
- allow. The default is 0.1 megapixels. The cache will not be larger
- than the (unscaled) size of the WebView.
-*/
-int QmlGraphicsWebView::pixelCacheSize() const
-{
- Q_D(const QmlGraphicsWebView);
- return d->max_imagecache_size;
-}
-
-void QmlGraphicsWebView::setPixelCacheSize(int pixels)
-{
- Q_D(QmlGraphicsWebView);
- if (pixels < d->max_imagecache_size) {
- int cachesize=0;
- for (int i=0; i<d->imagecache.count(); ++i) {
- QRect area = d->imagecache[i]->area;
- cachesize += area.width()*area.height();
- }
- while (d->imagecache.count() && cachesize > pixels) {
- int oldest=-1;
- int age=-1;
- for (int i=0; i<d->imagecache.count(); ++i) {
- int a = d->imagecache[i]->age;
- if (a > age) {
- oldest = i;
- age = a;
- }
- }
- cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height();
- d->imagecache.removeAt(oldest);
- }
- }
- d->max_imagecache_size = pixels;
-}
-
-/*!
\qmlproperty list<object> WebView::javaScriptWindowObjects
This property is a list of object that are available from within
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h
index fa7d19d..17546c1 100644
--- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h
@@ -100,7 +100,6 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsWebView : public QmlGraphicsPaintedItem
Q_PROPERTY(int preferredWidth READ preferredWidth WRITE setPreferredWidth NOTIFY preferredWidthChanged)
Q_PROPERTY(int preferredHeight READ preferredHeight WRITE setPreferredHeight NOTIFY preferredHeightChanged)
- Q_PROPERTY(int pixelCacheSize READ pixelCacheSize WRITE setPixelCacheSize)
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
@@ -166,9 +165,6 @@ public:
QWebSettings *settings() const;
QmlGraphicsWebSettings *settingsObject() const;
- int pixelCacheSize() const;
- void setPixelCacheSize(int pixels);
-
bool renderingEnabled() const;
void setRenderingEnabled(bool);