summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-05-13 03:24:43 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-05-13 03:24:43 (GMT)
commitffdb6fcca3bf8f4cc97f8bfe09a43811c29a7dbe (patch)
treeb0865c2107f0794feda8bdfc96d2e6447d6b045e /src/declarative
parent6c19bdb8552f3cc6ced2a20868f1f1952f94a69c (diff)
parent50711dd7aa22052eff58431d9f4e95e1a688047e (diff)
downloadQt-ffdb6fcca3bf8f4cc97f8bfe09a43811c29a7dbe.zip
Qt-ffdb6fcca3bf8f4cc97f8bfe09a43811c29a7dbe.tar.gz
Qt-ffdb6fcca3bf8f4cc97f8bfe09a43811c29a7dbe.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp11
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p_p.h3
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp16
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p_p.h3
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp11
5 files changed, 30 insertions, 14 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 6d86e58..db20da8 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -899,6 +899,7 @@ Handles the given mouse \a event.
void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextEdit);
+ bool hadFocus = hasFocus();
if (d->focusOnPress){
QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope?
while(p) {
@@ -910,6 +911,8 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
setFocus(true);
}
+ if (!hadFocus && hasFocus())
+ d->clickCausedFocus = true;
d->control->processEvent(event, QPointF(0, 0));
if (!event->isAccepted())
QDeclarativePaintedItem::mousePressEvent(event);
@@ -924,11 +927,12 @@ void QDeclarativeTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Q_D(QDeclarativeTextEdit);
QWidget *widget = event->widget();
if (widget && (d->control->textInteractionFlags() & Qt::TextEditable) && boundingRect().contains(event->pos()))
- qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->focusOnPress);
+ qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->clickCausedFocus);
+ d->clickCausedFocus = false;
d->control->processEvent(event, QPointF(0, 0));
if (!event->isAccepted())
- QDeclarativePaintedItem::mousePressEvent(event);
+ QDeclarativePaintedItem::mouseReleaseEvent(event);
}
/*!
@@ -952,7 +956,8 @@ void QDeclarativeTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Q_D(QDeclarativeTextEdit);
d->control->processEvent(event, QPointF(0, 0));
if (!event->isAccepted())
- QDeclarativePaintedItem::mousePressEvent(event);
+ QDeclarativePaintedItem::mouseMoveEvent(event);
+ event->setAccepted(true);
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
index 8d4b611..5e19c3d 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
@@ -70,7 +70,7 @@ public:
QDeclarativeTextEditPrivate()
: color("black"), hAlign(QDeclarativeTextEdit::AlignLeft), vAlign(QDeclarativeTextEdit::AlignTop),
imgDirty(true), dirty(false), richText(false), cursorVisible(false), focusOnPress(true),
- persistentSelection(true), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
+ persistentSelection(true), clickCausedFocus(false), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
cursorComponent(0), cursor(0), format(QDeclarativeTextEdit::AutoText), document(0),
wrapMode(QDeclarativeTextEdit::NoWrap)
{
@@ -100,6 +100,7 @@ public:
bool cursorVisible : 1;
bool focusOnPress : 1;
bool persistentSelection : 1;
+ bool clickCausedFocus : 1;
qreal textMargin;
int lastSelectionStart;
int lastSelectionEnd;
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 8f86aa0..afbaaac 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -882,6 +882,7 @@ void QDeclarativeTextInput::keyPressEvent(QKeyEvent* ev)
void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextInput);
+ bool hadFocus = hasFocus();
if(d->focusOnPress){
QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope?
while(p) {
@@ -893,15 +894,20 @@ void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
setFocus(true);
}
+ if (!hadFocus && hasFocus())
+ d->clickCausedFocus = true;
+
bool mark = event->modifiers() & Qt::ShiftModifier;
int cursor = d->xToPos(event->pos().x());
d->control->moveCursor(cursor, mark);
+ event->setAccepted(true);
}
void QDeclarativeTextInput::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextInput);
d->control->moveCursor(d->xToPos(event->pos().x()), true);
+ event->setAccepted(true);
}
/*!
@@ -913,8 +919,10 @@ void QDeclarativeTextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Q_D(QDeclarativeTextInput);
QWidget *widget = event->widget();
if (widget && !d->control->isReadOnly() && boundingRect().contains(event->pos()))
- qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->focusOnPress);
- d->control->processEvent(event);
+ qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->clickCausedFocus);
+ d->clickCausedFocus = false;
+ if (!event->isAccepted())
+ QDeclarativePaintedItem::mouseReleaseEvent(event);
}
bool QDeclarativeTextInput::event(QEvent* ev)
@@ -935,8 +943,8 @@ bool QDeclarativeTextInput::event(QEvent* ev)
updateSize();
}
if(!handled)
- return QDeclarativePaintedItem::event(ev);
- return true;
+ handled = QDeclarativePaintedItem::event(ev);
+ return handled;
}
void QDeclarativeTextInput::geometryChanged(const QRectF &newGeometry,
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
index 26cf78c..99866b8 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
@@ -72,7 +72,7 @@ public:
color((QRgb)0), style(QDeclarativeText::Normal),
styleColor((QRgb)0), hAlign(QDeclarativeTextInput::AlignLeft),
hscroll(0), oldScroll(0), focused(false), focusOnPress(true),
- cursorVisible(false), autoScroll(true)
+ cursorVisible(false), autoScroll(true), clickCausedFocus(false)
{
}
@@ -116,6 +116,7 @@ public:
bool focusOnPress;
bool cursorVisible;
bool autoScroll;
+ bool clickCausedFocus;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 9f5cafe..94e6771 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -327,11 +327,12 @@ Q_GLOBAL_STATIC(QDeclarativeEngineDebugServer, qmlEngineDebugServer);
void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *o)
{
QObjectPrivate *p = QObjectPrivate::get(o);
- Q_ASSERT(p->declarativeData);
- QDeclarativeData *d = static_cast<QDeclarativeData*>(p->declarativeData);
- if (d->ownContext && d->context) {
- d->context->destroy();
- d->context = 0;
+ if (p->declarativeData) {
+ QDeclarativeData *d = static_cast<QDeclarativeData*>(p->declarativeData);
+ if (d->ownContext && d->context) {
+ d->context->destroy();
+ d->context = 0;
+ }
}
}