summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/declarative/examples.qdoc6
-rw-r--r--doc/src/declarative/qmlruntime.qdoc26
-rw-r--r--doc/src/examples/qml-folderlistmodel.qdoc144
-rw-r--r--doc/src/images/declarative-folderlistmodel.pngbin0 -> 17764 bytes
-rw-r--r--doc/src/snippets/declarative/folderlistmodel.qml17
-rw-r--r--doc/src/snippets/declarative/gridview/gridview.qml2
-rw-r--r--doc/src/snippets/declarative/listview/highlight.qml63
-rw-r--r--src/declarative/QmlChanges.txt4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp8
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp48
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p.h5
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp36
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p.h5
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p_p.h4
-rw-r--r--src/declarative/qml/qdeclarativecompiledbindings.cpp389
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp2
-rw-r--r--src/imports/folderlistmodel/plugin.cpp4
-rw-r--r--src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp12
-rw-r--r--src/imports/folderlistmodel/qdeclarativefolderlistmodel.h41
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp45
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp2
-rw-r--r--tools/qdoc3/test/macros.qdocconf2
-rw-r--r--tools/qml/content/Browser.qml6
-rw-r--r--tools/qml/main.cpp18
-rw-r--r--tools/qml/qml.pro4
-rw-r--r--tools/qml/qmlruntime.cpp12
27 files changed, 698 insertions, 211 deletions
diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc
index bc02646..5b8c937 100644
--- a/doc/src/declarative/examples.qdoc
+++ b/doc/src/declarative/examples.qdoc
@@ -167,5 +167,11 @@ For example, from your build directory, run:
\o \l{demos/declarative/snake}{Snake}
\endlist
+\section1 Labs
+
+\list
+\o \l{src/imports/folderlistmodel}{Folder List Model} - a C++ model plugin
+\endlist
+
*/
diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc
index b105df4..cef5e63 100644
--- a/doc/src/declarative/qmlruntime.qdoc
+++ b/doc/src/declarative/qmlruntime.qdoc
@@ -42,17 +42,17 @@
/*!
\page qmlruntime.html
\title Qt Declarative UI Runtime
- \keyword qml runtime
+ \keyword QML Viewer
\ingroup qttools
This page documents the \e{Declarative UI Runtime} for the Qt GUI
- toolkit, and the \QQL which can be used to run apps
- written for the runtime. The \QQL reads a declarative
+ toolkit, and the \QQV which can be used to run apps
+ written for the runtime. The \QQV reads a declarative
user interface definition (\c .qml) file and displays the user interface it describes.
QML is a runtime, as you can run plain QML files which pull in their required modules.
To run apps with the QML runtime, you can either start the runtime
- from your own application (using a QDeclarativeView) or with the simple \QQL.
+ from your own application (using a QDeclarativeView) or with the simple \QQV.
The launcher can be installed in a production environment, assuming that it is not already
present in the system. It is generally packaged alongside Qt.
@@ -61,16 +61,16 @@
\list
\o Write your own Qt application including a QDeclarative view and deploy it the same as
any other Qt application (not discussed further on this page), or
- \o Write a main QML file for your application, and run your application using the included \QQL.
+ \o Write a main QML file for your application, and run your application using the included \QQV.
\endlist
- To run an application with the \QQL, pass the filename as an argument:
+ To run an application with the \QQV, pass the filename as an argument:
\code
- qml myQmlFile.qml
+ qmlviewer myQmlFile.qml
\endcode
- Deploying a QML application via the \QQL allows for QML only deployments, but can also
+ Deploying a QML application via the \QQV allows for QML only deployments, but can also
include custom C++ modules just as easily. Below is an example of how you might structure
a complex application deployed via the QML runtime, it is a listing of the files that would
be included in the deployment package.
@@ -92,8 +92,8 @@
as the appropriate module file is chosen based on platform naming conventions. The C++
modules must contain a QDeclarativeExtentionPlugin subclass.
- The application would be executed either with your own application, the command 'qml MyApp.qml' or by
- opening the file if your system has the \QQL registered as the handler for QML files. The MyApp.qml file would have access
+ The application would be executed either with your own application, the command 'qmlviewer MyApp.qml' or by
+ opening the file if your system has the \QQV registered as the handler for QML files. The MyApp.qml file would have access
to all of the deployed types using the import statements such as the following:
\code
@@ -101,15 +101,15 @@
import "OtherModule" 1.0 as Other
\endcode
- \section1 Qt QML Launcher functionality
- The \QQL implements some additional functionality to help it supporting
+ \section1 Qt QML Viewer functionality
+ The \QQV implements some additional functionality to help it supporting
myriad applications. If you implement your own application, you may also wish to reimplement
some or all of this functionality. However, much of this functionality is intended to aid the prototyping of
QML applications and may not be necessary for a deployed application.
\section2 Options
- When run with the \c -help option, \c qml shows available options.
+ When run with the \c -help option, \c qmlviewer shows available options.
\section2 Translations
diff --git a/doc/src/examples/qml-folderlistmodel.qdoc b/doc/src/examples/qml-folderlistmodel.qdoc
new file mode 100644
index 0000000..b820528
--- /dev/null
+++ b/doc/src/examples/qml-folderlistmodel.qdoc
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title FolderListModel - a C++ model plugin
+\example src/imports/folderlistmodel
+
+This plugin shows how to make a C++ model available to QML. It presents
+a simple file list for a single folder (directory) and allows the presented
+folder to be changed.
+
+\image declarative-folderlistmodel.png The FolderListModel used to choose a QML file
+
+We do not explain the model implementation in detail, but rather focus on the mechanics of
+making the model available to QML.
+
+\section1 Usage from QML
+
+The type we are creating can be used from QML like this:
+
+\snippet doc/src/snippets/declarative/folderlistmodel.qml 0
+
+\section1 Defining the Model
+
+We are subclassing QAbstractListModel which will allow us to give data to QML and
+send notifications when the data changes:
+
+\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h class begin
+
+As you see, we also inherit the QDeclarativeParserStatus interface, so that we
+can delay initial processing until we have all properties set (via componentComplete() below).
+
+The first thing to do when devising a new type for QML is to define the properties
+you want the type to have:
+
+\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h class props
+
+The purposes of each of these should be pretty obvious - in QML we will set the folder
+to display (a file: URL), and the kinds of files we want to show in the view of the model.
+
+Next are the constructor, destructor, and standard QAbstractListModel subclassing requirements:
+
+\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h abslistmodel
+
+The data() function is where we provide model values. The rowCount() function
+is also a standard part of the QAbstractListModel interface, but we also want to provide
+a simpler count property:
+
+\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h count
+
+Then we have the functions for the remaining properties which we defined above:
+
+\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h prop funcs
+
+Imperative actions upon the model are made available to QML via a Q_INVOKABLE tag on
+a normal member function. The isFolder(index) function says whether the value at \e index
+is a folder:
+
+\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h isfolder
+
+Then we have the QDeclarativeParserStatus interface:
+
+\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h parserstatus
+
+Then the NOTIFY function for the folders property. The implementation will emit this
+when the folder property is changed.
+
+\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h notifier
+
+The class ends with some implementation details:
+
+\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h class end
+
+Lastly, the boilerplare to declare the type for QML use:
+
+\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h qml decl
+
+\section1 Connecting the Model to QML
+
+To make this class available to QML, we only need to make a simple subclass of QDeclarativeExtensionPlugin:
+
+\snippet src/imports/folderlistmodel/plugin.cpp class decl
+
+and then use the standard Qt plugin export macro:
+
+\snippet src/imports/folderlistmodel/plugin.cpp plugin export decl
+
+Finally, in order for QML to connect the "import" statement to our plugin, we list it in the qmldir file:
+
+\l{src/imports/folderlistmodel/qmldir}
+
+This qmldir file and the compiled plugin will be installed in \c $QTDIR/imports/Qt/labs/folderlistmodel/ where
+the QML engine will find it (since \c $QTDIR/imports is the value of QLibraryInf::libraryPath()).
+
+\section1 Implementing the Model
+
+We'll not discuss the model implementation in detail, as it is not specific to QML - any Qt C++ model
+can be interfaced to QML.
+This implementation is basically just takes the krufty old QDirModel,
+which is a tree with lots of detailed roles and re-presents it as a simpler list model where
+each item is just a fileName and a filePath (as a file: URL rather than a plain file, since QML
+works with URLs for all content).
+
+\l{src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp}
+*/
diff --git a/doc/src/images/declarative-folderlistmodel.png b/doc/src/images/declarative-folderlistmodel.png
new file mode 100644
index 0000000..a469f96
--- /dev/null
+++ b/doc/src/images/declarative-folderlistmodel.png
Binary files differ
diff --git a/doc/src/snippets/declarative/folderlistmodel.qml b/doc/src/snippets/declarative/folderlistmodel.qml
new file mode 100644
index 0000000..e90f9fd
--- /dev/null
+++ b/doc/src/snippets/declarative/folderlistmodel.qml
@@ -0,0 +1,17 @@
+//![0]
+import Qt 4.7
+import Qt.labs.folderlistmodel 1.0
+
+ListView {
+ FolderListModel {
+ id: foldermodel
+ nameFilters: ["*.qml"]
+ }
+ Component {
+ id: filedelegate
+ Text { text: fileName }
+ }
+ model: foldermodel
+ delegate: filedelegate
+}
+//![0]
diff --git a/doc/src/snippets/declarative/gridview/gridview.qml b/doc/src/snippets/declarative/gridview/gridview.qml
index cf345aa..1d3df97 100644
--- a/doc/src/snippets/declarative/gridview/gridview.qml
+++ b/doc/src/snippets/declarative/gridview/gridview.qml
@@ -4,7 +4,7 @@ import Qt 4.7
Rectangle {
width: 240; height: 180; color: "white"
// ContactModel model is defined in dummydata/ContactModel.qml
- // The launcher automatically loads files in dummydata/* to assist
+ // The viewer automatically loads files in dummydata/* to assist
// development without a real data source.
// Define a delegate component. A component will be
diff --git a/doc/src/snippets/declarative/listview/highlight.qml b/doc/src/snippets/declarative/listview/highlight.qml
new file mode 100644
index 0000000..794b3f2
--- /dev/null
+++ b/doc/src/snippets/declarative/listview/highlight.qml
@@ -0,0 +1,63 @@
+import Qt 4.7
+
+Rectangle {
+ width: 180; height: 200; color: "white"
+
+ // ContactModel model is defined in dummydata/ContactModel.qml
+ // The viewer automatically loads files in dummydata/* to assist
+ // development without a real data source.
+
+ // Define a delegate component. A component will be
+ // instantiated for each visible item in the list.
+//! [0]
+ Component {
+ id: delegate
+ Item {
+ id: wrapper
+ width: 180; height: 40
+ Column {
+ x: 5; y: 5
+ Text { text: '<b>Name:</b> ' + name }
+ Text { text: '<b>Number:</b> ' + number }
+ }
+ // Use the ListView.isCurrentItem attached property to
+ // indent the item if it is the current item.
+ states: [
+ State {
+ name: "Current"
+ when: wrapper.ListView.isCurrentItem
+ PropertyChanges { target: wrapper; x: 10 }
+ }
+ ]
+ transitions: [
+ Transition { NumberAnimation { properties: "x"; duration: 200 } }
+ ]
+ }
+ }
+//! [0]
+ // Specify a highlight with custom movement. Note that autoHighlight
+ // is set to false in the ListView so that we can control how the
+ // highlight moves to the current item.
+//! [1]
+ Component {
+ id: highlight
+ Rectangle {
+ width: 180; height: 40
+ color: "lightsteelblue"; radius: 5
+ SpringFollow on y {
+ to: list.currentItem.y
+ spring: 3
+ damping: 0.2
+ }
+ }
+ }
+ ListView {
+ id: list
+ width: parent.height; height: parent.height
+ model: ContactModel; delegate: delegate
+ highlight: highlight
+ highlightFollowsCurrentItem: false
+ focus: true
+ }
+//! [1]
+}
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index b1f4f1b..c121a2d 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -23,9 +23,9 @@ The QDeclarativeExpression constructor has changed from
to
QDeclarativeExpression(context, scope, expression, parent = 0)
-QML Launcher
+QML Viewer
------------
-The standalone executable has been renamed to qml launcher. Runtime warnings
+The standalone qml executable has been renamed back to Qml Viewer. Runtime warnings
can be now accessed via the menu (Debugging->Show Warnings).
=============================================================================
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index 94983c4..4995baf 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -81,8 +81,12 @@ void QDeclarativeLoaderPrivate::clear()
// We can't delete immediately because our item may have triggered
// the Loader to load a different item.
- item->setVisible(false);
- item->setParentItem(0);
+ if (item->scene()) {
+ item->scene()->removeItem(item);
+ } else {
+ item->setParentItem(0);
+ item->setVisible(false);
+ }
item->deleteLater();
item = 0;
}
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 45b79a7..40d37a2 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -773,6 +773,33 @@ void QDeclarativeTextEdit::componentComplete()
}
/*!
+ \qmlproperty string TextEdit::selectByMouse
+
+ Defaults to false.
+
+ If true, the user can use the mouse to select text in some
+ platform-specific way. Note that for some platforms this may
+ not be an appropriate interaction (eg. may conflict with how
+ the text needs to behave inside a Flickable.
+*/
+bool QDeclarativeTextEdit::selectByMouse() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->selectByMouse;
+}
+
+void QDeclarativeTextEdit::setSelectByMouse(bool on)
+{
+ Q_D(QDeclarativeTextEdit);
+ if (d->selectByMouse != on) {
+ d->selectByMouse = on;
+ emit selectByMouseChanged(on);
+ }
+}
+
+
+
+/*!
\qmlproperty bool TextEdit::readOnly
Whether the user an interact with the TextEdit item. If this
@@ -914,7 +941,8 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
if (!hadFocus && hasFocus())
d->clickCausedFocus = true;
- d->control->processEvent(event, QPointF(0, 0));
+ if (event->type() != QEvent::GraphicsSceneMouseDoubleClick || d->selectByMouse)
+ d->control->processEvent(event, QPointF(0, 0));
if (!event->isAccepted())
QDeclarativePaintedItem::mousePressEvent(event);
}
@@ -943,9 +971,13 @@ Handles the given mouse \a event.
void QDeclarativeTextEdit::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextEdit);
- d->control->processEvent(event, QPointF(0, 0));
- if (!event->isAccepted())
+ if (d->selectByMouse) {
+ d->control->processEvent(event, QPointF(0, 0));
+ if (!event->isAccepted())
+ QDeclarativePaintedItem::mouseDoubleClickEvent(event);
+ } else {
QDeclarativePaintedItem::mouseDoubleClickEvent(event);
+ }
}
/*!
@@ -955,10 +987,14 @@ Handles the given mouse \a event.
void QDeclarativeTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextEdit);
- d->control->processEvent(event, QPointF(0, 0));
- if (!event->isAccepted())
+ if (d->selectByMouse) {
+ d->control->processEvent(event, QPointF(0, 0));
+ if (!event->isAccepted())
+ QDeclarativePaintedItem::mouseMoveEvent(event);
+ event->setAccepted(true);
+ } else {
QDeclarativePaintedItem::mouseMoveEvent(event);
- event->setAccepted(true);
+ }
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
index 474de09..8848d47 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
@@ -86,6 +86,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem
Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged)
Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged)
Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
+ Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged)
public:
QDeclarativeTextEdit(QDeclarativeItem *parent=0);
@@ -167,6 +168,9 @@ public:
qreal textMargin() const;
void setTextMargin(qreal margin);
+ bool selectByMouse() const;
+ void setSelectByMouse(bool);
+
virtual void componentComplete();
/* FROM EDIT */
@@ -200,6 +204,7 @@ Q_SIGNALS:
void focusOnPressChanged(bool focusIsPressed);
void persistentSelectionChanged(bool isPersistentSelection);
void textMarginChanged(qreal textMargin);
+ void selectByMouseChanged(bool selectByMouse);
public Q_SLOTS:
void selectAll();
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
index 5e19c3d..885620d 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
@@ -72,7 +72,8 @@ public:
imgDirty(true), dirty(false), richText(false), cursorVisible(false), focusOnPress(true),
persistentSelection(true), clickCausedFocus(false), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
cursorComponent(0), cursor(0), format(QDeclarativeTextEdit::AutoText), document(0),
- wrapMode(QDeclarativeTextEdit::NoWrap)
+ wrapMode(QDeclarativeTextEdit::NoWrap),
+ selectByMouse(false)
{
}
@@ -110,6 +111,7 @@ public:
QTextDocument *document;
QTextControl *control;
QDeclarativeTextEdit::WrapMode wrapMode;
+ bool selectByMouse;
};
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 8aa7e99..2e7715f 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -907,8 +907,12 @@ void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
void QDeclarativeTextInput::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextInput);
- d->control->moveCursor(d->xToPos(event->pos().x()), true);
- event->setAccepted(true);
+ if (d->selectByMouse) {
+ d->control->moveCursor(d->xToPos(event->pos().x()), true);
+ event->setAccepted(true);
+ } else {
+ QDeclarativePaintedItem::mouseMoveEvent(event);
+ }
}
/*!
@@ -939,6 +943,8 @@ bool QDeclarativeTextInput::event(QEvent* ev)
case QEvent::GraphicsSceneMouseRelease:
break;
default:
+ if (ev->type() == QEvent::GraphicsSceneMouseDoubleClick && !d->selectByMouse)
+ break;
handled = d->control->processEvent(ev);
if (ev->type() == QEvent::InputMethod)
updateSize();
@@ -1114,6 +1120,32 @@ QString QDeclarativeTextInput::displayText() const
}
/*!
+ \qmlproperty string TextInput::selectByMouse
+
+ Defaults to false.
+
+ If true, the user can use the mouse to select text in some
+ platform-specific way. Note that for some platforms this may
+ not be an appropriate interaction (eg. may conflict with how
+ the text needs to behave inside a Flickable.
+*/
+bool QDeclarativeTextInput::selectByMouse() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->selectByMouse;
+}
+
+void QDeclarativeTextInput::setSelectByMouse(bool on)
+{
+ Q_D(QDeclarativeTextInput);
+ if (d->selectByMouse != on) {
+ d->selectByMouse = on;
+ emit selectByMouseChanged(on);
+ }
+}
+
+
+/*!
\qmlmethod void TextInput::moveCursorSelection(int position)
Moves the cursor to \a position and updates the selection accordingly.
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
index c0c1e50..b2fd057 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
@@ -89,6 +89,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTextInput : public QDeclarativePaintedIte
Q_PROPERTY(QString passwordCharacter READ passwordCharacter WRITE setPasswordCharacter NOTIFY passwordCharacterChanged)
Q_PROPERTY(QString displayText READ displayText NOTIFY displayTextChanged)
Q_PROPERTY(bool autoScroll READ autoScroll WRITE setAutoScroll NOTIFY autoScrollChanged)
+ Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged)
public:
QDeclarativeTextInput(QDeclarativeItem* parent=0);
@@ -174,6 +175,9 @@ public:
bool autoScroll() const;
void setAutoScroll(bool);
+ bool selectByMouse() const;
+ void setSelectByMouse(bool);
+
bool hasAcceptableInput() const;
void drawContents(QPainter *p,const QRect &r);
@@ -203,6 +207,7 @@ Q_SIGNALS:
void displayTextChanged(const QString &text);
void focusOnPressChanged(bool focusOnPress);
void autoScrollChanged(bool autoScroll);
+ void selectByMouseChanged(bool selectByMouse);
protected:
virtual void geometryChanged(const QRectF &newGeometry,
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
index 99866b8..1d8e0f7 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
@@ -72,7 +72,8 @@ 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), clickCausedFocus(false)
+ cursorVisible(false), autoScroll(true), clickCausedFocus(false),
+ selectByMouse(false)
{
}
@@ -117,6 +118,7 @@ public:
bool cursorVisible;
bool autoScroll;
bool clickCausedFocus;
+ bool selectByMouse;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp
index 7ddc735..ad05e80 100644
--- a/src/declarative/qml/qdeclarativecompiledbindings.cpp
+++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp
@@ -64,6 +64,73 @@ DEFINE_BOOL_CONFIG_OPTION(bindingsDump, QML_BINDINGS_DUMP);
Q_GLOBAL_STATIC(QDeclarativeFastProperties, fastProperties);
+#ifdef __GNUC__
+# define QML_THREADED_INTERPRETER
+#endif
+
+#define FOR_EACH_QML_INSTR(F) \
+ F(Noop) /* Nop */ \
+ F(BindingId) /* id */ \
+ F(Subscribe) /* subscribe */ \
+ F(SubscribeId) /* subscribe */ \
+ F(FetchAndSubscribe) /* fetchAndSubscribe */ \
+ F(LoadId) /* load */ \
+ F(LoadScope) /* load */ \
+ F(LoadRoot) /* load */ \
+ F(LoadAttached) /* attached */ \
+ F(ConvertIntToReal) /* unaryop */ \
+ F(ConvertRealToInt) /* unaryop */ \
+ F(Real) /* real_value */ \
+ F(Int) /* int_value */ \
+ F(Bool) /* bool_value */ \
+ F(String) /* string_value */ \
+ F(AddReal) /* binaryop */ \
+ F(AddInt) /* binaryop */ \
+ F(AddString) /* binaryop */ \
+ F(MinusReal) /* binaryop */ \
+ F(MinusInt) /* binaryop */ \
+ F(CompareReal) /* binaryop */ \
+ F(CompareString) /* binaryop */ \
+ F(NotCompareReal) /* binaryop */ \
+ F(NotCompareString) /* binaryop */ \
+ F(GreaterThanReal) /* binaryop */ \
+ F(MaxReal) /* binaryop */ \
+ F(MinReal) /* binaryop */ \
+ F(NewString) /* construct */ \
+ F(NewUrl) /* construct */ \
+ F(CleanupUrl) /* cleanup */ \
+ F(CleanupString) /* cleanup */ \
+ F(Copy) /* copy */ \
+ F(Fetch) /* fetch */ \
+ F(Store) /* store */ \
+ F(Skip) /* skip */ \
+ F(Done) /* done */ \
+ /* Speculative property resolution */ \
+ F(InitString) /* initstring */ \
+ F(FindGeneric) /* find */ \
+ F(FindGenericTerminal) /* find */ \
+ F(FindProperty) /* find */ \
+ F(FindPropertyTerminal) /* find */ \
+ F(CleanupGeneric) /* cleanup */ \
+ F(ConvertGenericToReal) /* unaryop */ \
+ F(ConvertGenericToBool) /* unaryop */ \
+ F(ConvertGenericToString) /* unaryop */ \
+ F(ConvertGenericToUrl) /* unaryop */
+
+#define QML_INSTR_ENUM(I) I,
+#define QML_INSTR_ADDR(I) &&op_##I,
+
+#ifdef QML_THREADED_INTERPRETER
+# define QML_BEGIN_INSTR(I) op_##I:
+# define QML_END_INSTR(I) ++instr; goto *instr->common.code;
+# define QML_INSTR_HEADER void *code;
+#else
+# define QML_BEGIN_INSTR(I) case Instr::I:
+# define QML_END_INSTR(I) break;
+# define QML_INSTR_HEADER
+#endif
+
+
using namespace QDeclarativeJS;
namespace {
@@ -328,101 +395,45 @@ namespace {
// This structure is exactly 8-bytes in size
struct Instr {
enum {
- Noop,
- BindingId, // id
-
- Subscribe, // subscribe
- SubscribeId, // subscribe
-
- FetchAndSubscribe, // fetchAndSubscribe
-
- LoadId, // load
- LoadScope, // load
- LoadRoot, // load
- LoadAttached, // attached
-
- ConvertIntToReal, // unaryop
- ConvertRealToInt, // unaryop
-
- Real, // real_value
- Int, // int_value
- Bool, // bool_value
- String, // string_value
-
- AddReal, // binaryop
- AddInt, // binaryop
- AddString, // binaryop
-
- MinusReal, // binaryop
- MinusInt, // binaryop
-
- CompareReal, // binaryop
- CompareString, // binaryop
-
- NotCompareReal, // binaryop
- NotCompareString, // binaryop
-
- GreaterThanReal, // binaryop
- MaxReal, // binaryop
- MinReal, // binaryop
-
- NewString, // construct
- NewUrl, // construct
-
- CleanupUrl, // cleanup
- CleanupString, // cleanup
-
- Copy, // copy
- Fetch, // fetch
- Store, // store
-
- Skip, // skip
-
- Done,
-
- // Speculative property resolution
- InitString, // initstring
- FindGeneric, // find
- FindGenericTerminal, // find
- FindProperty, // find
- FindPropertyTerminal, // find
- CleanupGeneric, // cleanup
- ConvertGenericToReal, // unaryop
- ConvertGenericToBool, // unaryop
- ConvertGenericToString, // unaryop
- ConvertGenericToUrl, // unaryop
+ FOR_EACH_QML_INSTR(QML_INSTR_ENUM)
};
union {
struct {
+ QML_INSTR_HEADER
quint8 type;
quint8 packing[7];
} common;
struct {
+ QML_INSTR_HEADER
quint8 type;
quint8 packing;
quint16 column;
quint32 line;
} id;
struct {
+ QML_INSTR_HEADER
quint8 type;
quint8 packing[3];
quint16 subscriptions;
quint16 identifiers;
} init;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint16 offset;
quint32 index;
} subscribe;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint8 packing[2];
quint32 index;
} load;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 output;
qint8 reg;
@@ -430,6 +441,7 @@ struct Instr {
quint32 index;
} attached;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 output;
qint8 reg;
@@ -437,6 +449,7 @@ struct Instr {
quint32 index;
} store;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 output;
qint8 objectReg;
@@ -445,6 +458,7 @@ struct Instr {
quint16 function;
} fetchAndSubscribe;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 output;
qint8 objectReg;
@@ -452,41 +466,48 @@ struct Instr {
quint32 index;
} fetch;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
qint8 src;
quint8 packing[5];
} copy;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint8 packing[6];
} construct;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint8 packing[2];
float value;
} real_value;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint8 packing[2];
int value;
} int_value;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
bool value;
quint8 packing[5];
} bool_value;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint16 length;
quint32 offset;
} string_value;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 output;
qint8 src1;
@@ -494,18 +515,21 @@ struct Instr {
quint8 packing[4];
} binaryop;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 output;
qint8 src;
quint8 packing[5];
} unaryop;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint8 packing[2];
quint32 count;
} skip;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
qint8 src;
@@ -514,11 +538,13 @@ struct Instr {
quint16 subscribeIndex;
} find;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint8 packing[6];
} cleanup;
struct {
+ QML_INSTR_HEADER
quint8 type;
quint8 packing[1];
quint16 offset;
@@ -535,7 +561,7 @@ struct Program {
quint16 subscriptions;
quint16 identifiers;
quint16 instructionCount;
- quint16 dummy;
+ quint16 compiled;
const char *data() const { return ((const char *)this) + sizeof(Program); }
const Instr *instructions() const { return (const Instr *)(data() + dataLength); }
@@ -1097,35 +1123,57 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
instr += instrIndex;
const char *data = program->data();
+#ifdef QML_THREADED_INTERPRETER
+ static void *decode_instr[] = {
+ FOR_EACH_QML_INSTR(QML_INSTR_ADDR)
+ };
+
+ if (!program->compiled) {
+ program->compiled = true;
+ const Instr *inop = program->instructions();
+ for (int i = 0; i < program->instructionCount; ++i) {
+ Instr *op = (Instr *) inop++;
+ op->common.code = decode_instr[op->common.type];
+ }
+ }
+
+ goto *instr->common.code;
+#else
// return;
+
#ifdef COMPILEDBINDINGS_DEBUG
qWarning().nospace() << "Begin binding run";
#endif
while (instr) {
+ switch (instr->common.type) {
+
#ifdef COMPILEDBINDINGS_DEBUG
dumpInstruction(instr);
#endif
- switch (instr->common.type) {
- case Instr::Noop:
- case Instr::BindingId:
- break;
+#endif
- case Instr::SubscribeId:
+ QML_BEGIN_INSTR(Noop)
+ QML_END_INSTR(Noop)
+
+ QML_BEGIN_INSTR(BindingId)
+ QML_END_INSTR(BindingId)
+
+ QML_BEGIN_INSTR(SubscribeId)
subscribeId(context, instr->subscribe.index, instr->subscribe.offset);
- break;
+ QML_END_INSTR(SubscribeId)
- case Instr::Subscribe:
+ QML_BEGIN_INSTR(Subscribe)
{
QObject *o = 0;
const Register &object = registers[instr->subscribe.reg];
if (!object.isUndefined()) o = object.getQObject();
subscribe(o, instr->subscribe.index, instr->subscribe.offset);
}
- break;
+ QML_END_INSTR(Subscribe)
- case Instr::FetchAndSubscribe:
+ QML_BEGIN_INSTR(FetchAndSubscribe)
{
const Register &input = registers[instr->fetchAndSubscribe.objectReg];
Register &output = registers[instr->fetchAndSubscribe.output];
@@ -1149,21 +1197,21 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
fastProperties()->accessor(instr->fetchAndSubscribe.function)(object, output.typeDataPtr(), sub);
}
}
- break;
+ QML_END_INSTR(FetchAndSubscribe)
- case Instr::LoadId:
+ QML_BEGIN_INSTR(LoadId)
registers[instr->load.reg].setQObject(context->idValues[instr->load.index].data());
- break;
+ QML_END_INSTR(LoadId)
- case Instr::LoadScope:
+ QML_BEGIN_INSTR(LoadScope)
registers[instr->load.reg].setQObject(scope);
- break;
+ QML_END_INSTR(LoadScope)
- case Instr::LoadRoot:
+ QML_BEGIN_INSTR(LoadRoot)
registers[instr->load.reg].setQObject(context->contextObject);
- break;
+ QML_END_INSTR(LoadRoot)
- case Instr::LoadAttached:
+ QML_BEGIN_INSTR(LoadAttached)
{
const Register &input = registers[instr->attached.reg];
Register &output = registers[instr->attached.output];
@@ -1184,48 +1232,48 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
output.setQObject(attached);
}
}
- break;
+ QML_END_INSTR(LoadAttached)
- case Instr::ConvertIntToReal:
+ QML_BEGIN_INSTR(ConvertIntToReal)
{
const Register &input = registers[instr->unaryop.src];
Register &output = registers[instr->unaryop.output];
if (input.isUndefined()) output.setUndefined();
else output.setqreal(qreal(input.getint()));
}
- break;
+ QML_END_INSTR(ConvertIntToReal)
- case Instr::ConvertRealToInt:
+ QML_BEGIN_INSTR(ConvertRealToInt)
{
const Register &input = registers[instr->unaryop.src];
Register &output = registers[instr->unaryop.output];
if (input.isUndefined()) output.setUndefined();
else output.setint(qRound(input.getqreal()));
}
- break;
+ QML_END_INSTR(ConvertRealToInt)
- case Instr::Real:
+ QML_BEGIN_INSTR(Real)
registers[instr->real_value.reg].setqreal(instr->real_value.value);
- break;
+ QML_END_INSTR(Real)
- case Instr::Int:
+ QML_BEGIN_INSTR(Int)
registers[instr->int_value.reg].setint(instr->int_value.value);
- break;
+ QML_END_INSTR(Int)
- case Instr::Bool:
+ QML_BEGIN_INSTR(Bool)
registers[instr->bool_value.reg].setbool(instr->bool_value.value);
- break;
+ QML_END_INSTR(Bool)
- case Instr::String:
+ QML_BEGIN_INSTR(String)
{
Register &output = registers[instr->string_value.reg];
new (output.getstringptr())
QString((QChar *)(data + instr->string_value.offset), instr->string_value.length);
output.settype(QMetaType::QString);
}
- break;
+ QML_END_INSTR(String)
- case Instr::AddReal:
+ QML_BEGIN_INSTR(AddReal)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1233,9 +1281,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
else output.setqreal(lhs.getqreal() + rhs.getqreal());
}
- break;
+ QML_END_INSTR(AddReal)
- case Instr::AddInt:
+ QML_BEGIN_INSTR(AddInt)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1243,9 +1291,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
else output.setint(lhs.getint() + rhs.getint());
}
- break;
+ QML_END_INSTR(AddInt)
- case Instr::AddString:
+ QML_BEGIN_INSTR(AddString)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1265,9 +1313,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
output.settype(QMetaType::QString);
}
}
- break;
+ QML_END_INSTR(AddString)
- case Instr::MinusReal:
+ QML_BEGIN_INSTR(MinusReal)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1275,9 +1323,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
else output.setqreal(lhs.getqreal() - rhs.getqreal());
}
- break;
+ QML_END_INSTR(MinusReal)
- case Instr::MinusInt:
+ QML_BEGIN_INSTR(MinusInt)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1285,9 +1333,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
else output.setint(lhs.getint() - rhs.getint());
}
- break;
+ QML_END_INSTR(MinusInt)
- case Instr::CompareReal:
+ QML_BEGIN_INSTR(CompareReal)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1295,9 +1343,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() == rhs.isUndefined());
else output.setbool(lhs.getqreal() == rhs.getqreal());
}
- break;
+ QML_END_INSTR(CompareReal)
- case Instr::CompareString:
+ QML_BEGIN_INSTR(CompareString)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1305,9 +1353,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() == rhs.isUndefined());
else output.setbool(*lhs.getstringptr() == *rhs.getstringptr());
}
- break;
+ QML_END_INSTR(CompareString)
- case Instr::NotCompareReal:
+ QML_BEGIN_INSTR(NotCompareReal)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1315,9 +1363,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() != rhs.isUndefined());
else output.setbool(lhs.getqreal() != rhs.getqreal());
}
- break;
+ QML_END_INSTR(NotCompareReal)
- case Instr::NotCompareString:
+ QML_BEGIN_INSTR(NotCompareString)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1325,9 +1373,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() != rhs.isUndefined());
else output.setbool(*lhs.getstringptr() != *rhs.getstringptr());
}
- break;
+ QML_END_INSTR(NotCompareString)
- case Instr::GreaterThanReal:
+ QML_BEGIN_INSTR(GreaterThanReal)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1335,9 +1383,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(false);
else output.setbool(lhs.getqreal() > rhs.getqreal());
}
- break;
+ QML_END_INSTR(GreaterThanReal)
- case Instr::MaxReal:
+ QML_BEGIN_INSTR(MaxReal)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1345,9 +1393,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
else output.setqreal(qMax(lhs.getqreal(), rhs.getqreal()));
}
- break;
+ QML_END_INSTR(MaxReal)
- case Instr::MinReal:
+ QML_BEGIN_INSTR(MinReal)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1355,33 +1403,33 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
else output.setqreal(qMin(lhs.getqreal(), rhs.getqreal()));
}
- break;
+ QML_END_INSTR(MinReal)
- case Instr::NewString:
+ QML_BEGIN_INSTR(NewString)
{
Register &output = registers[instr->construct.reg];
new (output.getstringptr()) QString;
output.settype(QMetaType::QString);
}
- break;
+ QML_END_INSTR(NewString)
- case Instr::NewUrl:
+ QML_BEGIN_INSTR(NewUrl)
{
Register &output = registers[instr->construct.reg];
new (output.geturlptr()) QUrl;
output.settype(QMetaType::QUrl);
}
- break;
+ QML_END_INSTR(NewUrl)
- case Instr::CleanupString:
+ QML_BEGIN_INSTR(CleanupString)
registers[instr->cleanup.reg].getstringptr()->~QString();
- break;
+ QML_END_INSTR(CleanupString)
- case Instr::CleanupUrl:
+ QML_BEGIN_INSTR(CleanupUrl)
registers[instr->cleanup.reg].geturlptr()->~QUrl();
- break;
+ QML_END_INSTR(CleanupUrl)
- case Instr::Fetch:
+ QML_BEGIN_INSTR(Fetch)
{
const Register &input = registers[instr->fetch.objectReg];
Register &output = registers[instr->fetch.output];
@@ -1399,9 +1447,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
QMetaObject::metacall(object, QMetaObject::ReadProperty, instr->fetch.index, argv);
}
}
- break;
+ QML_END_INSTR(Fetch)
- case Instr::Store:
+ QML_BEGIN_INSTR(Store)
{
Register &data = registers[instr->store.reg];
if (data.isUndefined()) {
@@ -1415,21 +1463,22 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
QMetaObject::metacall(output, QMetaObject::WriteProperty,
instr->store.index, argv);
}
- break;
+ QML_END_INSTR(Store)
- case Instr::Copy:
+ QML_BEGIN_INSTR(Copy)
registers[instr->copy.reg] = registers[instr->copy.src];
- break;
+ QML_END_INSTR(Copy)
- case Instr::Skip:
+ QML_BEGIN_INSTR(Skip)
if (instr->skip.reg == -1 || !registers[instr->skip.reg].getbool())
instr += instr->skip.count;
- break;
+ QML_END_INSTR(Skip)
- case Instr::Done:
+ QML_BEGIN_INSTR(Done)
return;
+ QML_END_INSTR(Done)
- case Instr::InitString:
+ QML_BEGIN_INSTR(InitString)
if (!identifiers[instr->initstring.offset].identifier) {
quint32 len = *(quint32 *)(data + instr->initstring.dataIdx);
QChar *strdata = (QChar *)(data + instr->initstring.dataIdx + sizeof(quint32));
@@ -1438,10 +1487,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
identifiers[instr->initstring.offset] = engine->objectClass->createPersistentIdentifier(str);
}
- break;
+ QML_END_INSTR(InitString)
- case Instr::FindGenericTerminal:
- case Instr::FindGeneric:
+ QML_BEGIN_INSTR(FindGenericTerminal)
// We start the search in the parent context, as we know that the
// name is not present in the current context or it would have been
// found during the static compile
@@ -1449,10 +1497,19 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
context->parent,
identifiers[instr->find.name].identifier,
instr->common.type == Instr::FindGenericTerminal);
- break;
+ QML_END_INSTR(FindGenericTerminal)
- case Instr::FindPropertyTerminal:
- case Instr::FindProperty:
+ QML_BEGIN_INSTR(FindGeneric)
+ // We start the search in the parent context, as we know that the
+ // name is not present in the current context or it would have been
+ // found during the static compile
+ findgeneric(registers + instr->find.reg, instr->find.subscribeIndex,
+ context->parent,
+ identifiers[instr->find.name].identifier,
+ instr->common.type == Instr::FindGenericTerminal);
+ QML_END_INSTR(FindGeneric)
+
+ QML_BEGIN_INSTR(FindPropertyTerminal)
{
const Register &object = registers[instr->find.src];
if (object.isUndefined()) {
@@ -1465,9 +1522,24 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
instr->find.subscribeIndex, identifiers[instr->find.name].identifier,
instr->common.type == Instr::FindPropertyTerminal);
}
- break;
+ QML_END_INSTR(FindPropertyTerminal)
- case Instr::CleanupGeneric:
+ QML_BEGIN_INSTR(FindProperty)
+ {
+ const Register &object = registers[instr->find.src];
+ if (object.isUndefined()) {
+ throwException(instr->find.exceptionId, error, program, context);
+ return;
+ }
+
+ findproperty(object.getQObject(), registers + instr->find.reg,
+ QDeclarativeEnginePrivate::get(context->engine),
+ instr->find.subscribeIndex, identifiers[instr->find.name].identifier,
+ instr->common.type == Instr::FindPropertyTerminal);
+ }
+ QML_END_INSTR(FindProperty)
+
+ QML_BEGIN_INSTR(CleanupGeneric)
{
int type = registers[instr->cleanup.reg].gettype();
if (type == qMetaTypeId<QVariant>()) {
@@ -1478,9 +1550,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
registers[instr->cleanup.reg].geturlptr()->~QUrl();
}
}
- break;
+ QML_END_INSTR(CleanupGeneric)
- case Instr::ConvertGenericToReal:
+ QML_BEGIN_INSTR(ConvertGenericToReal)
{
Register &output = registers[instr->unaryop.output];
Register &input = registers[instr->unaryop.src];
@@ -1488,9 +1560,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
output.setqreal(toReal(&input, input.gettype(), &ok));
if (!ok) output.setUndefined();
}
- break;
+ QML_END_INSTR(ConvertGenericToReal)
- case Instr::ConvertGenericToBool:
+ QML_BEGIN_INSTR(ConvertGenericToBool)
{
Register &output = registers[instr->unaryop.output];
Register &input = registers[instr->unaryop.src];
@@ -1498,9 +1570,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
output.setbool(toBool(&input, input.gettype(), &ok));
if (!ok) output.setUndefined();
}
- break;
+ QML_END_INSTR(ConvertGenericToBool)
- case Instr::ConvertGenericToString:
+ QML_BEGIN_INSTR(ConvertGenericToString)
{
Register &output = registers[instr->unaryop.output];
Register &input = registers[instr->unaryop.src];
@@ -1509,9 +1581,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (ok) { new (output.getstringptr()) QString(str); output.settype(QMetaType::QString); }
else { output.setUndefined(); }
}
- break;
+ QML_END_INSTR(ConvertGenericToString)
- case Instr::ConvertGenericToUrl:
+ QML_BEGIN_INSTR(ConvertGenericToUrl)
{
Register &output = registers[instr->unaryop.output];
Register &input = registers[instr->unaryop.src];
@@ -1520,15 +1592,19 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (ok) { new (output.geturlptr()) QUrl(url); output.settype(QMetaType::QUrl); }
else { output.setUndefined(); }
}
- break;
+ QML_END_INSTR(ConvertGenericToUrl)
+#ifdef QML_THREADED_INTERPRETER
+ // nothing to do
+#else
default:
qFatal("EEK");
break;
- }
+ } // switch
- instr++;
- }
+ ++instr;
+ } // while
+#endif
}
void QDeclarativeBindingCompiler::dump(const QByteArray &programData)
@@ -2781,6 +2857,7 @@ QByteArray QDeclarativeBindingCompiler::program() const
prog.subscriptions = d->committed.subscriptionIds.count();
prog.identifiers = d->committed.registeredStrings.count();
prog.instructionCount = bytecode.count();
+ prog.compiled = false;
int size = sizeof(Program) + bytecode.count() * sizeof(Instr);
size += prog.dataLength;
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index b11c0c2..80ae5f5 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -69,7 +69,7 @@ public:
rewindParent(0), rewindStackBefore(0) {}
QDeclarativeItem *target;
- QDeclarativeItem *parent;
+ QDeclarativeGuard<QDeclarativeItem> parent;
QDeclarativeGuard<QDeclarativeItem> origParent;
QDeclarativeGuard<QDeclarativeItem> origStackBefore;
QDeclarativeItem *rewindParent;
diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp
index b94efb0..d4569f7 100644
--- a/src/imports/folderlistmodel/plugin.cpp
+++ b/src/imports/folderlistmodel/plugin.cpp
@@ -46,6 +46,7 @@
QT_BEGIN_NAMESPACE
+//![class decl]
class QmlFolderListModelPlugin : public QDeclarativeExtensionPlugin
{
Q_OBJECT
@@ -56,10 +57,13 @@ public:
qmlRegisterType<QDeclarativeFolderListModel>(uri,1,0,"FolderListModel");
}
};
+//![class decl]
QT_END_NAMESPACE
#include "plugin.moc"
+//![plugin export decl]
Q_EXPORT_PLUGIN2(qmlfolderlistmodelplugin, QT_PREPEND_NAMESPACE(QmlFolderListModelPlugin));
+//![plugin export decl]
diff --git a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp
index a16f0c6..6a7383a 100644
--- a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp
+++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp
@@ -39,11 +39,14 @@
**
****************************************************************************/
+//![code]
#include "qdeclarativefolderlistmodel.h"
#include <QDirModel>
#include <QDebug>
#include <qdeclarativecontext.h>
+QT_BEGIN_NAMESPACE
+
class QDeclarativeFolderListModelPrivate
{
public:
@@ -99,6 +102,12 @@ public:
separator, Qt will translate your paths to conform to the underlying
operating system.
+ This type is made available by importing the \c Qt.labs.folderlistmodel module.
+ \e {Elements in the Qt.labs module are not guaranteed to remain compatible
+ in future versions.}
+
+ \bold{import Qt.labs.folderlistmodel 1.0}
+
The roles available are:
\list
\o fileName
@@ -387,3 +396,6 @@ void QDeclarativeFolderListModel::setShowOnlyReadable(bool on)
else
d->model.setFilter(d->model.filter() & ~QDir::Readable);
}
+
+//![code]
+QT_END_NAMESPACE
diff --git a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h
index e610a14..ea7d701 100644
--- a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h
+++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h
@@ -47,15 +47,25 @@
#include <QUrl>
#include <QAbstractListModel>
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
class QDeclarativeContext;
class QModelIndex;
class QDeclarativeFolderListModelPrivate;
+
+//![class begin]
class QDeclarativeFolderListModel : public QAbstractListModel, public QDeclarativeParserStatus
{
Q_OBJECT
Q_INTERFACES(QDeclarativeParserStatus)
+//![class begin]
+//![class props]
Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged)
Q_PROPERTY(QUrl parentFolder READ parentFolder NOTIFY folderChanged)
Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters)
@@ -65,7 +75,9 @@ class QDeclarativeFolderListModel : public QAbstractListModel, public QDeclarati
Q_PROPERTY(bool showDotAndDotDot READ showDotAndDotDot WRITE setShowDotAndDotDot)
Q_PROPERTY(bool showOnlyReadable READ showOnlyReadable WRITE setShowOnlyReadable)
Q_PROPERTY(int count READ count)
+//![class props]
+//![abslistmodel]
public:
QDeclarativeFolderListModel(QObject *parent = 0);
~QDeclarativeFolderListModel();
@@ -74,9 +86,13 @@ public:
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
+//![abslistmodel]
+//![count]
int count() const { return rowCount(QModelIndex()); }
+//![count]
+//![prop funcs]
QUrl folder() const;
void setFolder(const QUrl &folder);
@@ -85,11 +101,6 @@ public:
QStringList nameFilters() const;
void setNameFilters(const QStringList &filters);
- virtual void classBegin();
- virtual void componentComplete();
-
- Q_INVOKABLE bool isFolder(int index) const;
-
enum SortField { Unsorted, Name, Time, Size, Type };
SortField sortField() const;
void setSortField(SortField field);
@@ -104,10 +115,23 @@ public:
void setShowDotAndDotDot(bool);
bool showOnlyReadable() const;
void setShowOnlyReadable(bool);
+//![prop funcs]
+
+//![isfolder]
+ Q_INVOKABLE bool isFolder(int index) const;
+//![isfolder]
+
+//![parserstatus]
+ virtual void classBegin();
+ virtual void componentComplete();
+//![parserstatus]
+//![notifier]
Q_SIGNALS:
void folderChanged();
+//![notifier]
+//![class end]
private Q_SLOTS:
void refresh();
void inserted(const QModelIndex &index, int start, int end);
@@ -118,7 +142,14 @@ private:
Q_DISABLE_COPY(QDeclarativeFolderListModel)
QDeclarativeFolderListModelPrivate *d;
};
+//![class end]
+QT_END_NAMESPACE
+
+//![qml decl]
QML_DECLARE_TYPE(QDeclarativeFolderListModel)
+//![qml decl]
+
+QT_END_HEADER
#endif // QDECLARATIVEFOLDERLISTMODEL_H
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index c65c883..4befc4c 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -76,6 +76,8 @@ private slots:
void persistentSelection();
void focusOnPress();
void selection();
+ void mouseSelection_data();
+ void mouseSelection();
void inputMethodHints();
void cursorDelegate();
@@ -602,6 +604,49 @@ void tst_qdeclarativetextedit::selection()
QVERIFY(textEditObject->selectedText().size() == 10);
}
+void tst_qdeclarativetextedit::mouseSelection_data()
+{
+ QTest::addColumn<QString>("qmlfile");
+ QTest::addColumn<bool>("expectSelection");
+
+ // import installed
+ QTest::newRow("on") << SRCDIR "/data/mouseselection_true.qml" << true;
+ QTest::newRow("off") << SRCDIR "/data/mouseselection_false.qml" << false;
+ QTest::newRow("default") << SRCDIR "/data/mouseselection_default.qml" << false;
+}
+
+void tst_qdeclarativetextedit::mouseSelection()
+{
+ QFETCH(QString, qmlfile);
+ QFETCH(bool, expectSelection);
+
+ QDeclarativeView *canvas = createView(qmlfile);
+
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit *>(canvas->rootObject());
+ QVERIFY(textEditObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = textEditObject->height()/2;
+ QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
+ //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv);
+ QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
+ QString str = textEditObject->selectedText();
+ if (expectSelection)
+ QVERIFY(str.length() > 3); // don't reallly care *what* was selected (and it's too sensitive to platform)
+ else
+ QVERIFY(str.isEmpty());
+}
+
void tst_qdeclarativetextedit::inputMethodHints()
{
QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethodhints.qml");
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
index 831e318..4173a44 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
@@ -238,7 +238,7 @@ void tst_qdeclarativexmllistmodel::roleErrors()
QCOMPARE(data.value(Qt::UserRole+1), QVariant());
QCOMPARE(data.value(Qt::UserRole+2), QVariant());
- QEXPECT_FAIL("", "QT-2456", Continue);
+ QEXPECT_FAIL("", "QTBUG-10797", Continue);
QCOMPARE(data.value(Qt::UserRole+3), QVariant());
delete model;
diff --git a/tools/qdoc3/test/macros.qdocconf b/tools/qdoc3/test/macros.qdocconf
index e7a1dbc..510a8b3 100644
--- a/tools/qdoc3/test/macros.qdocconf
+++ b/tools/qdoc3/test/macros.qdocconf
@@ -18,7 +18,7 @@ macro.ouml.HTML = "&ouml;"
macro.QA = "\\e{Qt Assistant}"
macro.QD = "\\e{Qt Designer}"
macro.QL = "\\e{Qt Linguist}"
-macro.QQL = "\\e{Qt QML Launcher}"
+macro.QQV = "\\e{Qt QML Viewer}"
macro.param = "\\e"
macro.raisedaster.HTML = "<sup>*</sup>"
macro.rarrow.HTML = "&rarr;"
diff --git a/tools/qml/content/Browser.qml b/tools/qml/content/Browser.qml
index fe7ad9c..7238203 100644
--- a/tools/qml/content/Browser.qml
+++ b/tools/qml/content/Browser.qml
@@ -13,12 +13,12 @@ Rectangle {
FolderListModel {
id: folders1
nameFilters: [ "*.qml" ]
- folder: qmlLauncherFolder
+ folder: qmlViewerFolder
}
FolderListModel {
id: folders2
nameFilters: [ "*.qml" ]
- folder: qmlLauncherFolder
+ folder: qmlViewerFolder
}
SystemPalette { id: palette }
@@ -63,7 +63,7 @@ Rectangle {
if (folders.isFolder(index)) {
down(filePath);
} else {
- qmlLauncher.launch(filePath);
+ qmlViewer.launch(filePath);
}
}
width: root.width
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 18e2531..0cce1cc 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -85,7 +85,7 @@ QString warnings;
void showWarnings()
{
if (!warnings.isEmpty()) {
- QMessageBox::warning(0, QApplication::tr("Qt QML Launcher"), warnings);
+ QMessageBox::warning(0, QApplication::tr("Qt QML Viewer"), warnings);
}
}
@@ -110,14 +110,14 @@ void myMessageOutput(QtMsgType type, const char *msg)
void usage()
{
- qWarning("Usage: qml [options] <filename>");
+ qWarning("Usage: qmlviewer [options] <filename>");
qWarning(" ");
qWarning(" options:");
qWarning(" -v, -version ............................. display version");
qWarning(" -frameless ............................... run with no window frame");
qWarning(" -maximized................................ run maximized");
qWarning(" -fullscreen............................... run fullscreen");
- qWarning(" -stayontop................................ keep launcher window on top");
+ qWarning(" -stayontop................................ keep viewer window on top");
qWarning(" -sizeviewtorootobject .................... the view resizes to the changes in the content");
qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view");
qWarning(" -qmlbrowser .............................. use a QML-based file browser");
@@ -148,7 +148,7 @@ void usage()
void scriptOptsUsage()
{
- qWarning("Usage: qml -scriptopts <option>[,<option>...] ...");
+ qWarning("Usage: qmlviewer -scriptopts <option>[,<option>...] ...");
qWarning(" options:");
qWarning(" record ................................... record a new script");
qWarning(" play ..................................... playback an existing script");
@@ -156,9 +156,9 @@ void scriptOptsUsage()
qWarning(" testerror ................................ test 'error' property of root item on playback");
qWarning(" snapshot ................................. file being recorded is static,");
qWarning(" only one frame will be recorded or tested");
- qWarning(" exitoncomplete ........................... cleanly exit the launcher on script completion");
- qWarning(" exitonfailure ............................ immediately exit the launcher on script failure");
- qWarning(" saveonexit ............................... save recording on launcher exit");
+ qWarning(" exitoncomplete ........................... cleanly exit the viewer on script completion");
+ qWarning(" exitonfailure ............................ immediately exit the viewer on script failure");
+ qWarning(" saveonexit ............................... save recording on viewer exit");
qWarning(" ");
qWarning(" One of record, play or both must be specified.");
exit(1);
@@ -196,7 +196,7 @@ int main(int argc, char ** argv)
#endif
QApplication app(argc, argv);
- app.setApplicationName("QtQmlLauncher");
+ app.setApplicationName("QtQmlViewer");
app.setOrganizationName("Nokia");
app.setOrganizationDomain("nokia.com");
@@ -277,7 +277,7 @@ int main(int argc, char ** argv)
if (lastArg) usage();
app.setStartDragDistance(QString(argv[++i]).toInt());
} else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) {
- qWarning("Qt QML Launcher version %s", QT_VERSION_STR);
+ qWarning("Qt QML Viewer version %s", QT_VERSION_STR);
exit(0);
} else if (arg == "-translation") {
if (lastArg) usage();
diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro
index 6129639..9cdec77 100644
--- a/tools/qml/qml.pro
+++ b/tools/qml/qml.pro
@@ -37,6 +37,8 @@ symbian {
}
mac {
QMAKE_INFO_PLIST=Info_mac.plist
- TARGET="QML Launcher"
+ TARGET=QMLViewer
ICON=qml.icns
+} else {
+ TARGET=qmlviewer
}
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index 490fa34..8df250f 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -350,7 +350,7 @@ QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent)
setupProxy(manager);
if (cacheSize > 0) {
QNetworkDiskCache *cache = new QNetworkDiskCache;
- cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-launcher-network-cache"));
+ cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-viewer-network-cache"));
cache->setMaximumCacheSize(cacheSize);
manager->setCache(cache);
} else {
@@ -388,7 +388,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
, translator(0)
{
QDeclarativeViewer::registerTypes();
- setWindowTitle(tr("Qt QML Launcher"));
+ setWindowTitle(tr("Qt QML Viewer"));
devicemode = false;
canvas = 0;
@@ -887,7 +887,7 @@ bool QDeclarativeViewer::open(const QString& file_or_url)
url = QUrl::fromLocalFile(fi.absoluteFilePath());
else
url = QUrl(file_or_url);
- setWindowTitle(tr("%1 - Qt QML Launcher").arg(file_or_url));
+ setWindowTitle(tr("%1 - Qt QML Viewer").arg(file_or_url));
if (!m_script.isEmpty())
tester = new QDeclarativeTester(m_script, m_scriptOptions, canvas);
@@ -895,11 +895,11 @@ bool QDeclarativeViewer::open(const QString& file_or_url)
delete canvas->rootObject();
canvas->engine()->clearComponentCache();
QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("qmlLauncher", this);
+ ctxt->setContextProperty("qmlViewer", this);
#ifdef Q_OS_SYMBIAN
- ctxt->setContextProperty("qmlLauncherFolder", "E:\\"); // Documents on your S60 phone
+ ctxt->setContextProperty("qmlViewerFolder", "E:\\"); // Documents on your S60 phone
#else
- ctxt->setContextProperty("qmlLauncherFolder", QDir::currentPath());
+ ctxt->setContextProperty("qmlViewerFolder", QDir::currentPath());
#endif
ctxt->setContextProperty("runtime", Runtime::instance());