summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/browser/downloadmanager.cpp2
-rwxr-xr-xdemos/declarative/samegame/SamegameCore/samegame.js3
-rw-r--r--demos/declarative/samegame/samegame.qml1
-rw-r--r--demos/declarative/twitter/TwitterCore/AuthView.qml146
-rw-r--r--demos/declarative/twitter/TwitterCore/Button.qml2
-rw-r--r--demos/declarative/twitter/TwitterCore/FatDelegate.qml36
-rw-r--r--demos/declarative/twitter/TwitterCore/HomeTitleBar.qml161
-rw-r--r--demos/declarative/twitter/TwitterCore/Input.qml (renamed from tools/designer/src/components/propertyeditor/defs.h)43
-rw-r--r--demos/declarative/twitter/TwitterCore/MultiTitleBar.qml7
-rw-r--r--demos/declarative/twitter/TwitterCore/RssModel.qml59
-rw-r--r--demos/declarative/twitter/TwitterCore/SearchView.qml124
-rw-r--r--demos/declarative/twitter/TwitterCore/TitleBar.qml80
-rw-r--r--demos/declarative/twitter/TwitterCore/ToolBar.qml5
-rw-r--r--demos/declarative/twitter/TwitterCore/UserModel.qml26
-rw-r--r--demos/declarative/twitter/TwitterCore/qmldir4
-rw-r--r--demos/declarative/twitter/twitter.qml74
-rw-r--r--demos/qtdemo/menumanager.cpp4
-rw-r--r--dist/changes-4.7.024
-rw-r--r--doc/src/declarative/qml-intro.qdoc7
-rw-r--r--doc/src/examples/qml-twitter.qdoc4
-rw-r--r--doc/src/getting-started/gettingstartedqml.qdoc36
-rw-r--r--doc/src/snippets/declarative/qml-intro/basic-syntax.qml48
-rw-r--r--doc/src/snippets/declarative/qml-intro/sequential-animation3.qml2
-rw-r--r--[-rwxr-xr-x]doc/src/tutorials/modelview.qdoc575
-rw-r--r--examples/sql/masterdetail/mainwindow.cpp6
-rw-r--r--examples/tools/treemodelcompleter/mainwindow.cpp2
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/1_readonly/1_readonly.pro13
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/1_readonly/main.cpp9
-rw-r--r--examples/tutorials/modelview/1_readonly/modelview.cpp54
-rw-r--r--examples/tutorials/modelview/1_readonly/modelview.h61
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/1_readonly/mymodel.cpp0
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/1_readonly/mymodel.h0
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/2_formatting/2_formatting.pro12
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/2_formatting/main.cpp12
-rw-r--r--examples/tutorials/modelview/2_formatting/modelview.cpp52
-rw-r--r--examples/tutorials/modelview/2_formatting/modelview.h57
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/2_formatting/mymodel.cpp6
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/2_formatting/mymodel.h0
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro12
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/3_changingmodel/main.cpp9
-rw-r--r--examples/tutorials/modelview/3_changingmodel/modelview.cpp52
-rw-r--r--examples/tutorials/modelview/3_changingmodel/modelview.h57
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/3_changingmodel/mymodel.cpp0
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/3_changingmodel/mymodel.h2
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/4_headers/4_headers.pro14
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/4_headers/main.cpp11
-rw-r--r--examples/tutorials/modelview/4_headers/modelview.cpp54
-rw-r--r--examples/tutorials/modelview/4_headers/modelview.h58
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/4_headers/mymodel.cpp0
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/4_headers/mymodel.h0
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/5_edit/5_edit.pro12
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/5_edit/main.cpp4
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/5_edit/mainwindow.cpp (renamed from examples/tutorials/modelview/5_edit/modelview.cpp)6
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/5_edit/mainwindow.h (renamed from examples/tutorials/modelview/5_edit/modelview.h)12
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/5_edit/mymodel.cpp40
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/5_edit/mymodel.h9
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/6_treeview/6_treeview.pro12
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/6_treeview/main.cpp4
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/6_treeview/mainwindow.cpp (renamed from examples/tutorials/modelview/6_treeview/modelview.cpp)24
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/6_treeview/mainwindow.h (renamed from examples/tutorials/modelview/6_treeview/modelview.h)19
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/7_selections/7_selections.pro12
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/7_selections/main.cpp4
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/7_selections/mainwindow.cpp (renamed from examples/tutorials/modelview/7_selections/modelview.cpp)8
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/7_selections/mainwindow.h (renamed from examples/tutorials/modelview/7_selections/modelview.h)13
-rwxr-xr-x[-rw-r--r--]examples/tutorials/modelview/modelview.pro10
-rw-r--r--examples/xmlpatterns/filetree/mainwindow.cpp2
-rw-r--r--mkspecs/common/symbian/symbian.conf3
-rw-r--r--mkspecs/features/symbian/symbian_building.prf13
-rw-r--r--mkspecs/features/unix/separate_debug_info.prf3
-rw-r--r--mkspecs/features/vxworks.prf11
-rw-r--r--mkspecs/features/win32/embed_manifest_dll.prf5
-rw-r--r--mkspecs/features/win32/embed_manifest_exe.prf5
-rw-r--r--src/3rdparty/phonon/gstreamer/mediaobject.cpp6
-rw-r--r--src/3rdparty/webkit/WebCore/WebCore.pro34
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp8
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp1
-rw-r--r--src/declarative/qml/parser/qdeclarativejslexer.cpp8
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp2
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_p.h11
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_s60.cpp41
-rw-r--r--src/gui/kernel/qapplication_s60.cpp29
-rw-r--r--src/gui/kernel/qt_s60_p.h4
-rw-r--r--src/gui/styles/qcleanlooksstyle.cpp10
-rw-r--r--src/gui/styles/qs60style.cpp6
-rw-r--r--src/gui/text/qtextengine.cpp7
-rw-r--r--src/gui/widgets/qlinecontrol.cpp2
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp2
-rw-r--r--src/network/bearer/qnetworkconfigmanager.cpp23
-rw-r--r--src/network/kernel/qauthenticator.cpp56
-rw-r--r--src/plugins/bearer/symbian/qnetworksession_impl.cpp82
-rw-r--r--src/plugins/bearer/symbian/qnetworksession_impl.h11
-rw-r--r--src/plugins/bearer/symbian/symbianengine.cpp86
-rw-r--r--src/plugins/bearer/symbian/symbianengine.h17
-rw-r--r--src/script/api/qscriptengine.cpp3
-rw-r--r--src/script/api/qscriptprogram.cpp4
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parseqml/main.qml97
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parseqml/project.pro3
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parseqml/project.ts.result195
-rw-r--r--tests/auto/qinputcontext/qinputcontext.pro4
-rw-r--r--tests/auto/qinputcontext/tst_qinputcontext.cpp657
-rw-r--r--tests/auto/qkeysequence/tst_qkeysequence.cpp28
-rw-r--r--tests/auto/qtimer/tst_qtimer.cpp5
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp25
-rw-r--r--tools/activeqt/testcon/changeproperties.cpp8
-rw-r--r--tools/assistant/tools/assistant/bookmarkitem.cpp5
-rw-r--r--tools/assistant/tools/assistant/cmdlineparser.cpp6
-rw-r--r--tools/assistant/tools/assistant/cmdlineparser.h1
-rw-r--r--tools/assistant/tools/assistant/mainwindow.cpp2
-rw-r--r--tools/assistant/tools/qcollectiongenerator/main.cpp75
-rw-r--r--tools/assistant/tools/qhelpconverter/filterpage.cpp2
-rw-r--r--tools/assistant/tools/qhelpconverter/finishpage.cpp3
-rw-r--r--tools/assistant/tools/qhelpconverter/helpwindow.cpp2
-rw-r--r--tools/assistant/tools/qhelpconverter/main.cpp15
-rw-r--r--tools/assistant/tools/qhelpgenerator/main.cpp42
-rw-r--r--tools/assistant/tools/shared/helpgenerator.cpp4
-rw-r--r--tools/configure/configureapp.cpp8
-rw-r--r--tools/designer/src/components/propertyeditor/defs.cpp107
-rw-r--r--tools/designer/src/components/propertyeditor/propertyeditor.pri4
-rw-r--r--tools/designer/src/components/taskmenu/itemlisteditor.cpp22
-rw-r--r--tools/designer/src/lib/shared/plugindialog.cpp4
-rw-r--r--tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp4
-rw-r--r--tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp4
-rw-r--r--tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp4
-rw-r--r--tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp4
-rw-r--r--tools/designer/src/plugins/qwebview/qwebview_plugin.cpp4
-rw-r--r--tools/linguist/lconvert/main.cpp21
-rw-r--r--tools/linguist/linguist/phrase.cpp7
-rw-r--r--tools/linguist/lrelease/main.cpp52
-rw-r--r--tools/linguist/lupdate/cpp.cpp83
-rw-r--r--tools/linguist/lupdate/java.cpp29
-rw-r--r--tools/linguist/lupdate/main.cpp32
-rw-r--r--tools/linguist/lupdate/merge.cpp18
-rw-r--r--tools/linguist/lupdate/qdeclarative.cpp166
-rw-r--r--tools/linguist/lupdate/qscript.cpp52
-rw-r--r--tools/linguist/lupdate/qscript.g51
-rw-r--r--tools/linguist/lupdate/ui.cpp19
-rw-r--r--tools/qdoc3/main.cpp2
-rw-r--r--tools/shared/qtpropertybrowser/qtpropertymanager.cpp24
-rw-r--r--translations/translations.pri4
139 files changed, 2621 insertions, 1993 deletions
diff --git a/demos/browser/downloadmanager.cpp b/demos/browser/downloadmanager.cpp
index 876ec1d..ab68209 100644
--- a/demos/browser/downloadmanager.cpp
+++ b/demos/browser/downloadmanager.cpp
@@ -282,7 +282,7 @@ void DownloadItem::updateInfoLabel()
remaining = tr("- %4 %5 remaining")
.arg(timeRemaining)
.arg(timeRemainingString);
- info = QString(tr("%1 of %2 (%3/sec) %4"))
+ info = tr("%1 of %2 (%3/sec) %4")
.arg(dataString(m_bytesReceived))
.arg(bytesTotal == 0 ? tr("?") : dataString(bytesTotal))
.arg(dataString((int)speed))
diff --git a/demos/declarative/samegame/SamegameCore/samegame.js b/demos/declarative/samegame/SamegameCore/samegame.js
index aa1b359..9266767 100755
--- a/demos/declarative/samegame/SamegameCore/samegame.js
+++ b/demos/declarative/samegame/SamegameCore/samegame.js
@@ -151,7 +151,8 @@ function victoryCheck()
gameDuration = new Date() - gameDuration;
nameInputDialog.show("You won! Please enter your name: ");
nameInputDialog.initialWidth = nameInputDialog.text.width + 20;
- nameInputDialog.width = nameInputDialog.initialWidth;
+ if(nameInputDialog.name == "")
+ nameInputDialog.width = nameInputDialog.initialWidth;
nameInputDialog.text.opacity = 0;//Just a spacer
}
}
diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml
index 9504fb6..3e9c505 100644
--- a/demos/declarative/samegame/samegame.qml
+++ b/demos/declarative/samegame/samegame.qml
@@ -82,6 +82,7 @@ Rectangle {
id: nameInputDialog
property int initialWidth: 0
+ property alias name: nameInputText.text
anchors.centerIn: parent
z: 22;
diff --git a/demos/declarative/twitter/TwitterCore/AuthView.qml b/demos/declarative/twitter/TwitterCore/AuthView.qml
deleted file mode 100644
index 0d05deb..0000000
--- a/demos/declarative/twitter/TwitterCore/AuthView.qml
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** 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 QtDeclarative module 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$
-**
-****************************************************************************/
-
-import Qt 4.7
-
-Item {
- id: wrapper
- Column {
- anchors.centerIn: parent
- spacing: 20
- Column{
- spacing: 4
- Text {
- text: "Screen name:"
- font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
- horizontalAlignment: Qt.AlignRight
- }
- Item {
- width: 220
- height: 28
- BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
- TextInput{
- id: nameIn
- width: parent.width - 8
- anchors.centerIn: parent
- maximumLength:21
- font.pixelSize: 16;
- font.bold: true
- color: "#151515"; selectionColor: "green"
- KeyNavigation.tab: passIn
- KeyNavigation.backtab: guest
- focus: true
- }
- }
- }
- Column{
- spacing: 4
- Text {
- text: "Password:"
- font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
- horizontalAlignment: Qt.AlignRight
- }
- Item {
- width: 220
- height: 28
- BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
- TextInput{
- id: passIn
- width: parent.width - 8
- anchors.centerIn: parent
- maximumLength:21
- echoMode: TextInput.Password
- font.pixelSize: 16;
- font.bold: true
- color: "#151515"; selectionColor: "green"
- KeyNavigation.tab: login
- KeyNavigation.backtab: nameIn
- onAccepted: login.doLogin();
- }
- }
- }
- Row{
- spacing: 10
- Button {
- width: 100
- height: 32
- id: login
- keyUsing: true;
- function doLogin(){
- rssModel.authName=nameIn.text;
- rssModel.authPass=passIn.text;
- rssModel.tags='my timeline';
- screen.focus = true;
- }
- text: "Log in"
- KeyNavigation.right: guest
- KeyNavigation.tab: guest
- KeyNavigation.backtab: passIn
- Keys.onReturnPressed: login.doLogin();
- Keys.onEnterPressed: login.doLogin();
- Keys.onSelectPressed: login.doLogin();
- Keys.onSpacePressed: login.doLogin();
- onClicked: login.doLogin();
- }
- Button {
- width: 100
- height: 32
- id: guest
- keyUsing: true;
- function doGuest()
- {
- rssModel.authName='-';
- screen.focus = true;
- screen.setMode(true);
- }
- text: "Guest"
- KeyNavigation.left: login
- KeyNavigation.tab: nameIn
- KeyNavigation.backtab: login
- Keys.onReturnPressed: guest.doGuest();
- Keys.onEnterPressed: guest.doGuest();
- Keys.onSelectPressed: guest.doGuest();
- Keys.onSpacePressed: guest.doGuest();
- onClicked: guest.doGuest();
- }
- }
- }
-}
diff --git a/demos/declarative/twitter/TwitterCore/Button.qml b/demos/declarative/twitter/TwitterCore/Button.qml
index d326c64..437b013 100644
--- a/demos/declarative/twitter/TwitterCore/Button.qml
+++ b/demos/declarative/twitter/TwitterCore/Button.qml
@@ -67,7 +67,7 @@ Item {
}
Text {
id: btnText
- color: if(container.keyUsing){"#DDDDDD";} else {"#FFFFFF";}
+ color: if(container.keyUsing){"#D0D0D0";} else {"#FFFFFF";}
anchors.centerIn: buttonImage; font.bold: true
text: container.text; style: Text.Raised; styleColor: "black"
font.pixelSize: 12
diff --git a/demos/declarative/twitter/TwitterCore/FatDelegate.qml b/demos/declarative/twitter/TwitterCore/FatDelegate.qml
index ff03b0b..27dd300 100644
--- a/demos/declarative/twitter/TwitterCore/FatDelegate.qml
+++ b/demos/declarative/twitter/TwitterCore/FatDelegate.qml
@@ -44,11 +44,10 @@ import Qt 4.7
Component {
id: listDelegate
Item {
- id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 58){txt.height+8}else{58}//50+4+4
+ id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 60){txt.height+10}else{60} //50+5+5
function handleLink(link){
if(link.slice(0,3) == 'app'){
screen.setUser(link.slice(7));
- screen.setMode(true);
}else if(link.slice(0,4) == 'http'){
Qt.openUrlExternally(link);
}
@@ -58,26 +57,47 @@ Component {
var ret2 = ret.replace(/http:\/\/[^ \n\t]+/g, '<a href="$&">$&</a>');//surrounds http links with html link tags
return ret2;
}
+
+ // Strip away paranthesis
+ function userName(str) {
+ var user = str.replace(/\([\S|\s]*\)/gi, "");
+ return user.trim();
+ }
+
Item {
id: moveMe; height: parent.height
Rectangle {
id: blackRect
color: "black"; opacity: wrapper.ListView.index % 2 ? 0.2 : 0.3; height: wrapper.height-2; width: wrapper.width; y: 1
}
- Rectangle {
- id: whiteRect; x: 6; width: 50; height: 50; color: "white"; smooth: true
+ Item {
+ id: image; x: 6; width: 48; height: 48; smooth: true
anchors.verticalCenter: parent.verticalCenter
Loading { x: 1; y: 1; width: 48; height: 48; visible: realImage.status != Image.Ready }
- Image { id: realImage; source: userImage; x: 1; y: 1; width:48; height:48 }
+ Image {
+ id: realImage;
+ source: userImage; x: 1; y: 1;
+ width:48; height:48; opacity:0 ;
+ onStatusChanged: {
+ if(status==Image.Ready)
+ image.state="loaded"
+ }
+ }
+ states: State {
+ name: "loaded";
+ PropertyChanges { target: realImage ; opacity:1 }
+ }
+ transitions: Transition { NumberAnimation { target: realImage; property: "opacity"; duration: 200 } }
+
}
Text { id:txt; y:4; x: 56
text: '<html><style type="text/css">a:link {color:"#aaccaa"}; a:visited {color:"#336633"}</style>'
- + '<a href="app://@'+userScreenName+'"><b>'+userScreenName + "</b></a> from " +source
- + "<br /><b>" + wrapper.addTags(statusText) + "</b></html>";
+ + '<a href="app://@'+userName(name)+'"><b>'+userName(name) + "</b></a> from " +source
+ + "<br /><b>" + statusText + "</b></html>";
textFormat: Qt.RichText
color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap
- anchors.left: whiteRect.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6
+ anchors.left: image.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6
onLinkActivated: wrapper.handleLink(link)
}
}
diff --git a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml
deleted file mode 100644
index 56f31b1..0000000
--- a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** 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 QtDeclarative module 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$
-**
-****************************************************************************/
-
-import Qt 4.7
-
-Item {
- id: titleBar
-
- signal update()
- onYChanged: state="" //When switching titlebars
-
- BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
- Item {
- id: container
- width: (parent.width * 2) - 55 ; height: parent.height
-
- function accept() {
- if(rssModel.authName == '' || rssModel.authPass == '')
- return false;//Can't login like that
-
- var postData = "status=" + editor.text;
- var postman = new XMLHttpRequest();
- postman.open("POST", "http://twitter.com/statuses/update.xml", true, rssModel.authName, rssModel.authPass);
- postman.onreadystatechange = function() {
- if (postman.readyState == postman.DONE) {
- titleBar.update();
- }
- }
- postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- postman.send(postData);
-
- editor.text = ""
- titleBar.state = ""
- }
-
- Rectangle {
- x: 6; width: 50; height: 50; color: "white"; smooth: true
- anchors.verticalCenter: parent.verticalCenter
-
- UserModel { user: rssModel.authName; id: userModel }
- Component { id: imgDelegate;
- Item {
- Loading { width:48; height:48; visible: realImage.status != Image.Ready }
- Image { source: image; width:48; height:48; id: realImage }
- }
- }
- ListView { model: userModel.model; x:1; y:1; delegate: imgDelegate }
- }
-
- Text {
- id: categoryText
- anchors.left: parent.left; anchors.right: tagButton.left
- anchors.leftMargin: 58; anchors.rightMargin: 10
- anchors.verticalCenter: parent.verticalCenter
- elide: Text.ElideLeft
- text: "Timeline for " + rssModel.authName
- font.pixelSize: 12; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
- }
-
- Button {
- id: tagButton; x: titleBar.width - 90; width: 85; height: 32; text: "New Post..."
- anchors.verticalCenter: parent.verticalCenter;
- onClicked: if (titleBar.state == "Posting") container.accept(); else titleBar.state = "Posting"
- }
-
- Text {
- id: charsLeftText; anchors.horizontalCenter: tagButton.horizontalCenter;
- anchors.top: tagButton.bottom; anchors.topMargin: 2
- text: {140 - editor.text.length;} visible: titleBar.state == "Posting"
- font.pointSize: 10; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
- }
- Item {
- id: txtEdit;
- anchors.left: tagButton.right; anchors.leftMargin: 5; y: 4
- anchors.right: parent.right; anchors.rightMargin: 40; height: parent.height - 9
- BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
-
- Binding {//TODO: Can this be a function, which also resets the cursor? And flashes?
- when: editor.text.length > 140
- target: editor
- property: "text"
- value: editor.text.slice(0,140)
- }
- TextEdit {
- id: editor
- anchors.left: parent.left;
- anchors.leftMargin: 8;
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 4;
- cursorVisible: true; font.bold: true
- width: parent.width - 12
- height: parent.height - 8
- font.pixelSize: 12
- wrapMode: TextEdit.Wrap
- color: "#151515"; selectionColor: "green"
- }
- Keys.forwardTo: [(returnKey), (editor)]
- Item {
- id: returnKey
- Keys.onReturnPressed: container.accept()
- Keys.onEnterPressed: container.accept()
- Keys.onEscapePressed: titleBar.state = ""
- }
- }
- }
- states: [
- State {
- name: "Posting"
- PropertyChanges { target: container; x: -tagButton.x + 5 }
- PropertyChanges { target: titleBar; height: 80 }
- PropertyChanges { target: tagButton; text: "OK" }
- PropertyChanges { target: tagButton; width: 28 }
- PropertyChanges { target: tagButton; height: 24 }
- PropertyChanges { target: editor; focus: true }
- }
- ]
- transitions: [
- Transition {
- from: "*"; to: "*"
- NumberAnimation { properties: "x,y,width,height"; easing.type: Easing.InOutQuad }
- }
- ]
-}
diff --git a/tools/designer/src/components/propertyeditor/defs.h b/demos/declarative/twitter/TwitterCore/Input.qml
index 28e39fc..a33a995 100644
--- a/tools/designer/src/components/propertyeditor/defs.h
+++ b/demos/declarative/twitter/TwitterCore/Input.qml
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Designer of the Qt Toolkit.
+** This file is part of the QtDeclarative module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,22 +39,27 @@
**
****************************************************************************/
-#ifndef DEFS_H
-#define DEFS_H
+import Qt 4.7
-#include <QtGui/QSizePolicy>
-#include <QtCore/QString>
-
-QT_BEGIN_NAMESPACE
-
-namespace qdesigner_internal {
-
-int size_type_to_int(QSizePolicy::Policy t);
-QString size_type_to_string(QSizePolicy::Policy t);
-QSizePolicy::Policy int_to_size_type(int i);
-
-} // namespace qdesigner_internal
-
-QT_END_NAMESPACE
-
-#endif // DEFS_H
+FocusScope {
+ id:container
+ width: 220
+ height: 28
+ BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
+ signal accepted
+ property alias text: input.text
+ property alias item:input
+ TextInput{
+ id: input
+ width: parent.width - 12
+ anchors.centerIn: parent
+ maximumLength:21
+ font.pixelSize: 16;
+ font.bold: true
+ color: "#151515"; selectionColor: "mediumseagreen"
+ focus: true
+ onAccepted:{container.accepted()}
+ text: ""
+ selectByMouse: true
+ }
+}
diff --git a/demos/declarative/twitter/TwitterCore/MultiTitleBar.qml b/demos/declarative/twitter/TwitterCore/MultiTitleBar.qml
index 38d6c9c..29b7713 100644
--- a/demos/declarative/twitter/TwitterCore/MultiTitleBar.qml
+++ b/demos/declarative/twitter/TwitterCore/MultiTitleBar.qml
@@ -42,10 +42,6 @@
import Qt 4.7
Item {
- height: homeBar.height
- HomeTitleBar { id: homeBar; width: parent.width; height: 60;
- onUpdate: rssModel.reload()
- }
TitleBar { id: titleBar; width: parent.width; height: 60;
y: -80
untaggedString: "Latest tweets from everyone"
@@ -53,9 +49,8 @@ Item {
}
states: [
State {
- name: "search"; when: screen.userView
+ name: "search"; when: screen.state!="search"
PropertyChanges { target: titleBar; y: 0 }
- PropertyChanges { target: homeBar; y: -80 }
}
]
transitions: [
diff --git a/demos/declarative/twitter/TwitterCore/RssModel.qml b/demos/declarative/twitter/TwitterCore/RssModel.qml
index bd73200..d03cdb3 100644
--- a/demos/declarative/twitter/TwitterCore/RssModel.qml
+++ b/demos/declarative/twitter/TwitterCore/RssModel.qml
@@ -43,43 +43,34 @@ import Qt 4.7
Item { id: wrapper
property variant model: xmlModel
- property string tags : ""
- property string authName : ""
- property string authPass : ""
+ property string from : ""
+ property string to : ""
+ property string phrase : ""
+
property string mode : "everyone"
property int status: xmlModel.status
function reload() { xmlModel.reload(); }
-XmlListModel {
- id: xmlModel
+ XmlListModel {
+ id: xmlModel
- source:{
- if (wrapper.authName == ""){
- ""; //Avoid worthless calls to twitter servers
- }else if(wrapper.mode == 'user'){
- "https://"+ ((wrapper.authName!="" && wrapper.authPass!="")? (wrapper.authName+":"+wrapper.authPass+"@") : "" )+"twitter.com/statuses/user_timeline.xml?screen_name="+wrapper.tags;
- }else if(wrapper.mode == 'self'){
- "https://"+ ((wrapper.authName!="" && wrapper.authPass!="")? (wrapper.authName+":"+wrapper.authPass+"@") : "" )+"twitter.com/statuses/friends_timeline.xml";
- }else{//everyone/public
- "http://twitter.com/statuses/public_timeline.xml";
- }
- }
- query: "/statuses/status"
+ source: (from=="" && to=="" && phrase=="") ? "" :
+ 'http://search.twitter.com/search.atom?from='+from+"&to="+to+"&phrase="+phrase
- XmlRole { name: "statusText"; query: "text/string()" }
- XmlRole { name: "timestamp"; query: "created_at/string()" }
- XmlRole { name: "source"; query: "source/string()" }
- XmlRole { name: "userName"; query: "user/name/string()" }
- XmlRole { name: "userScreenName"; query: "user/screen_name/string()" }
- XmlRole { name: "userImage"; query: "user/profile_image_url/string()" }
- XmlRole { name: "userLocation"; query: "user/location/string()" }
- XmlRole { name: "userDescription"; query: "user/description/string()" }
- XmlRole { name: "userFollowers"; query: "user/followers_count/string()" }
- XmlRole { name: "userStatuses"; query: "user/statuses_count/string()" }
- //TODO: Could also get the user's color scheme, timezone and a few other things
-}
-Binding {
- property: "mode"
- target: wrapper
- value: {if(wrapper.tags==''){"everyone";}else if(wrapper.tags=='my timeline'){"self";}else{"user";}}
-}
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " +
+ "declare namespace twitter=\"http://api.twitter.com/\";";
+
+ query: "/feed/entry"
+
+ XmlRole { name: "statusText"; query: "content/string()" }
+ XmlRole { name: "timestamp"; query: "published/string()" }
+ XmlRole { name: "source"; query: "twitter:source/string()" }
+ XmlRole { name: "name"; query: "author/name/string()" }
+ XmlRole { name: "userImage"; query: "link[@rel = 'image']/@href/string()" }
+
+ }
+ Binding {
+ property: "mode"
+ target: wrapper
+ value: {if(wrapper.tags==''){"everyone";}else if(wrapper.tags=='my timeline'){"self";}else{"user";}}
+ }
}
diff --git a/demos/declarative/twitter/TwitterCore/SearchView.qml b/demos/declarative/twitter/TwitterCore/SearchView.qml
new file mode 100644
index 0000000..22df374
--- /dev/null
+++ b/demos/declarative/twitter/TwitterCore/SearchView.qml
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** 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 QtDeclarative module 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$
+**
+****************************************************************************/
+
+import Qt 4.7
+
+FocusScope {
+ id: wrapper
+ Column {
+ anchors.centerIn: parent
+ spacing: 20
+ Column{
+ spacing: 4
+ Text {
+ text: "Posted by:"
+ font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
+ horizontalAlignment: Qt.AlignRight
+ }
+ Input{
+ id: fromIn
+ KeyNavigation.backtab: searchbutton
+ KeyNavigation.tab:toIn
+ onAccepted:searchbutton.doSearch();
+ focus: true
+ }
+ Text {
+ text: "In reply to:"
+ font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
+ horizontalAlignment: Qt.AlignRight
+ }
+ Input{
+ id: toIn
+ KeyNavigation.backtab: fromIn
+ KeyNavigation.tab:phraseIn
+ onAccepted:searchbutton.doSearch();
+ }
+ Text {
+ text: "Search phrase:"
+ font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
+ horizontalAlignment: Qt.AlignRight
+ }
+ Input{
+ id: phraseIn
+ KeyNavigation.backtab: toIn
+ KeyNavigation.tab:searchbutton
+ onAccepted:searchbutton.doSearch();
+ text: "Qt Quick"
+ }
+ }
+ Button {
+ width: 100
+ height: 32
+ id: searchbutton
+ keyUsing: true;
+ opacity: 1
+ text: "Search"
+ KeyNavigation.tab: fromIn
+ Keys.onReturnPressed: searchbutton.doSearch();
+ Keys.onEnterPressed: searchbutton.doSearch();
+ Keys.onSelectPressed: searchbutton.doSearch();
+ Keys.onSpacePressed: searchbutton.doSearch();
+ onClicked: searchbutton.doSearch();
+
+ function doSearch() {
+ // Search ! allowed
+ if (wrapper.state=="invalidinput")
+ return;
+
+ rssModel.from=fromIn.text;
+ rssModel.to= toIn.text;
+ rssModel.phrase = phraseIn.text;
+ screen.focus = true;
+ screen.state = ""
+ }
+ }
+ }
+ states:
+ State {
+ name: "invalidinput"
+ when: fromIn.text=="" && toIn.text=="" && phraseIn.text==""
+ PropertyChanges { target: searchbutton ; opacity: 0.6 ; }
+ }
+ transitions:
+ Transition {
+ NumberAnimation { target: searchbutton; property: "opacity"; duration: 200 }
+ }
+}
diff --git a/demos/declarative/twitter/TwitterCore/TitleBar.qml b/demos/declarative/twitter/TwitterCore/TitleBar.qml
index 479aa20..145c189 100644
--- a/demos/declarative/twitter/TwitterCore/TitleBar.qml
+++ b/demos/declarative/twitter/TwitterCore/TitleBar.qml
@@ -58,66 +58,58 @@ Item {
rssModel.tags = editor.text
}
- Image {
- id: quitButton
- x: 5
+ Item {
+ id:imageBox
+ x: 6; width: 0; height: 50; smooth: true
anchors.verticalCenter: parent.verticalCenter
- source: "images/quit.png"
- MouseArea {
- anchors.fill: parent
- onClicked: Qt.quit()
+
+ UserModel { user: rssModel.from; id: userModel }
+ Component {
+ id: imgDelegate;
+ Item {
+ id:imageitem
+ visible:true
+ Loading { width:48; height:48; visible: realImage.status != Image.Ready }
+ Image { id: realImage; source: image; width:48; height:48; opacity:0; }
+ states:
+ State {
+ name: "loaded"
+ when: (realImage.status == Image.Ready)
+ PropertyChanges { target: realImage; opacity:1 }
+ }
+ transitions: Transition {
+ NumberAnimation { target: realImage; property: "opacity"; duration: 200 }
+ }
+ }
+ }
+ ListView { id:view; model: userModel.model; x:1; y:1; delegate: imgDelegate }
+ states:
+ State {
+ when: !userModel.user==""
+ PropertyChanges { target: imageBox; width: 50; }
+ }
+ transitions:
+ Transition {
+ NumberAnimation { target: imageBox; property: "width"; duration: 200 }
}
- }
+ }
+
Text {
id: categoryText
anchors {
- left: quitButton.right; right: tagButton.left; leftMargin: 5; rightMargin: 10
+ left: imageBox.right; right: parent.right; leftMargin: 10; rightMargin: 10
verticalCenter: parent.verticalCenter
}
elide: Text.ElideLeft
- text: (rssModel.tags=="" ? untaggedString : taggedString + rssModel.tags)
+ text: (rssModel.from=="" ? untaggedString : taggedString + rssModel.from)
font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black"
font.pixelSize: 12
}
-
- Button {
- id: tagButton; x: titleBar.width - 50; width: 45; height: 32; text: "..."
- onClicked: if (titleBar.state == "Tags") container.accept(); else titleBar.state = "Tags"
- anchors.verticalCenter: parent.verticalCenter
- }
-
- Item {
- id: lineEdit
- y: 4; height: parent.height - 9
- anchors { left: tagButton.right; leftMargin: 5; right: parent.right; rightMargin: 5 }
-
- BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
-
- TextInput {
- id: editor
- anchors {
- left: parent.left; right: parent.right; leftMargin: 10; rightMargin: 10
- verticalCenter: parent.verticalCenter
- }
- cursorVisible: true; font.bold: true
- color: "#151515"; selectionColor: "Green"
- }
-
- Keys.forwardTo: [ (returnKey), (editor)]
-
- Item {
- id: returnKey
- Keys.onReturnPressed: container.accept()
- Keys.onEnterPressed: container.accept()
- Keys.onEscapePressed: titleBar.state = ""
- }
- }
}
states: State {
name: "Tags"
PropertyChanges { target: container; x: -tagButton.x + 5 }
- PropertyChanges { target: tagButton; text: "OK" }
PropertyChanges { target: editor; focus: true }
}
diff --git a/demos/declarative/twitter/TwitterCore/ToolBar.qml b/demos/declarative/twitter/TwitterCore/ToolBar.qml
index b9cb915..e18f5c6 100644
--- a/demos/declarative/twitter/TwitterCore/ToolBar.qml
+++ b/demos/declarative/twitter/TwitterCore/ToolBar.qml
@@ -48,15 +48,14 @@ Item {
property alias button2Label: button2.text
signal button1Clicked
signal button2Clicked
-
+ focus:true
BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
-
Button {
id: button1
anchors.left: parent.left; anchors.leftMargin: 5; y: 3; width: 140; height: 32
onClicked: toolbar.button1Clicked()
+ focus:true
}
-
Button {
id: button2
anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 32
diff --git a/demos/declarative/twitter/TwitterCore/UserModel.qml b/demos/declarative/twitter/TwitterCore/UserModel.qml
index e653836..d8ca804 100644
--- a/demos/declarative/twitter/TwitterCore/UserModel.qml
+++ b/demos/declarative/twitter/TwitterCore/UserModel.qml
@@ -42,26 +42,24 @@
import Qt 4.7
//This "model" gets the user information about the searched user. Mainly for the icon.
-//Copied from RssModel
Item { id: wrapper
property variant model: xmlModel
property string user : ""
property int status: xmlModel.status
function reload() { xmlModel.reload(); }
-XmlListModel {
- id: xmlModel
+ XmlListModel {
+ id: xmlModel
- source: {if(user!="") {"http://twitter.com/users/show.xml?screen_name="+user;}else{"";}}
- query: "/user"
+ source: user!= "" ? "http://twitter.com/users/show.xml?screen_name="+user : ""
+ query: "/user"
- XmlRole { name: "name"; query: "name/string()" }
- XmlRole { name: "screenName"; query: "screen_name/string()" }
- XmlRole { name: "image"; query: "profile_image_url/string()" }
- XmlRole { name: "location"; query: "location/string()" }
- XmlRole { name: "description"; query: "description/string()" }
- XmlRole { name: "followers"; query: "followers_count/string()" }
- //XmlRole { name: "protected"; query: "protected/bool()" }
- //TODO: Could also get the user's color scheme, timezone and a few other things
-}
+ XmlRole { name: "name"; query: "name/string()" }
+ XmlRole { name: "screenName"; query: "screen_name/string()" }
+ XmlRole { name: "image"; query: "profile_image_url/string()" }
+ XmlRole { name: "location"; query: "location/string()" }
+ XmlRole { name: "description"; query: "description/string()" }
+ XmlRole { name: "followers"; query: "followers_count/string()" }
+ //TODO: Could also get the user's color scheme, timezone and a few other things
+ }
}
diff --git a/demos/declarative/twitter/TwitterCore/qmldir b/demos/declarative/twitter/TwitterCore/qmldir
index 8b56c56..84d85c2 100644
--- a/demos/declarative/twitter/TwitterCore/qmldir
+++ b/demos/declarative/twitter/TwitterCore/qmldir
@@ -1,7 +1,7 @@
-AuthView 1.0 AuthView.qml
+SearchView 1.0 SearchView.qml
Button 1.0 Button.qml
+Input 1.0 Input.qml
FatDelegate 1.0 FatDelegate.qml
-HomeTitleBar 1.0 HomeTitleBar.qml
Loading 1.0 Loading.qml
MultiTitleBar 1.0 MultiTitleBar.qml
TitleBar 1.0 TitleBar.qml
diff --git a/demos/declarative/twitter/twitter.qml b/demos/declarative/twitter/twitter.qml
index 08cecb0..6d224a2 100644
--- a/demos/declarative/twitter/twitter.qml
+++ b/demos/declarative/twitter/twitter.qml
@@ -46,28 +46,18 @@ Item {
id: screen; width: 320; height: 480
property bool userView : false
property variant tmpStr
- function setMode(m){
- screen.userView = m;
- if(m == false){
- rssModel.tags='my timeline';
- rssModel.reload();
- toolBar.button2Label = "View others";
- } else {
- toolBar.button2Label = "Return home";
- }
- }
function setUser(str){hack.running = true; tmpStr = str}
- function reallySetUser(){rssModel.tags = tmpStr;}
-
+ function reallySetUser(){rssModel.from = tmpStr;rssModel.to = ""; rssModel.phrase = ""}
+ state:"searchquery"
//Workaround for bug 260266
Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack }
-
- //TODO: better way to return to the auth screen
- Keys.onEscapePressed: rssModel.authName=''
+ Keys.onEscapePressed: screen.state="searchquery"
+ Keys.onBacktabPressed: screen.state="searchquery"
Rectangle {
id: background
anchors.fill: parent; color: "#343434";
+ state:"searchquery"
Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 }
MouseArea {
@@ -90,8 +80,16 @@ Item {
y:60 //Below the title bars
height: 380
- Twitter.AuthView{
- id: authView
+ Text {
+ id:title
+ text: "Search Twitter"
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 20; font.bold: true; color: "#bbb"; style: Text.Raised; styleColor: "black"
+ opacity:0
+ }
+
+ Twitter.SearchView{
+ id: searchView
anchors.verticalCenter: parent.verticalCenter
width: parent.width; height: parent.height-60;
x: -(screen.width * 1.5)
@@ -110,31 +108,27 @@ Item {
//TODO: Use anchor changes instead of hard coding
y: screen.height - 40
width: parent.width; opacity: 0.9
- button1Label: "Update"
- button2Label: "View others"
- onButton1Clicked: rssModel.reload();
- onButton2Clicked:
+ button1Label: "New Search"
+ button2Label: "Update"
+ onButton1Clicked:
{
- if(screen.userView == true){
- screen.setMode(false);
- }else{
- rssModel.tags='';
- screen.setMode(true);
- }
+ screen.state="searchquery"
}
+ onButton2Clicked: rssModel.reload();
}
-
- states: [
- State {
- name: "unauthed"; when: rssModel.authName==""
- PropertyChanges { target: authView; x: 0 }
- PropertyChanges { target: mainView; x: -(parent.width * 1.5) }
- PropertyChanges { target: titleBar; y: -80 }
- PropertyChanges { target: toolBar; y: screen.height }
- }
- ]
- transitions: [
- Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } }
- ]
}
+ states: [
+ State {
+ name: "searchquery";
+ PropertyChanges { target: searchView; x: 0; focus:true}
+ PropertyChanges { target: mainView; x: -(parent.width * 1.5) }
+ PropertyChanges { target: titleBar; y: -80 }
+ PropertyChanges { target: toolBar; y: screen.height }
+ PropertyChanges { target: toolBar }
+ PropertyChanges { target: title; opacity:1}
+ }
+ ]
+ transitions: [
+ Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutQuad } }
+ ]
}
diff --git a/demos/qtdemo/menumanager.cpp b/demos/qtdemo/menumanager.cpp
index 4ae9ca1..fe3c5aa 100644
--- a/demos/qtdemo/menumanager.cpp
+++ b/demos/qtdemo/menumanager.cpp
@@ -384,9 +384,7 @@ void MenuManager::launchQmlExample(const QString &name)
qmlRoot->setProperty("show", QVariant(true));
qmlRoot->setProperty("qmlFile", QUrl::fromLocalFile(file.fileName()));
#else
- QMessageBox::critical(0, tr("Failed to launch the example"),
- tr("This application was built without the QtDeclarative module, and therefore declarative examples have been disabled."),
- QMessageBox::Cancel);
+ exampleError(QProcess::UnknownError);
#endif
}
diff --git a/dist/changes-4.7.0 b/dist/changes-4.7.0
index 01ebf63..a5939e3 100644
--- a/dist/changes-4.7.0
+++ b/dist/changes-4.7.0
@@ -88,7 +88,10 @@ QtGui
- QComboBox
* [QTBUG-8796] Made ForegroundRole work for all styles.
-
+
+ - QCommandLinkButton
+ * [QTBUG-5995] Fixed text and icon alignment issues.
+
- QPrinter
* Obsoleted the slightly confusing setNumCopies() and numCopies()
functions, and replaced them with setCopyCount(), copyCount() and
@@ -133,6 +136,9 @@ QtGui
* [QTBUG-7982] Added QImage::bitPlaneCount().
* [QTBUG-9072] Fixed alpha check for 1-bit-per-pixel images.
+ - QLineEdit
+ * [QTBUG-9823] Placeholder text is now correctly aligned with text.
+
- QPicture
* [QTBUG-4974] Printing QPictures containing text to a high resolution
QPrinter would in many cases cause incorrect character spacing.
@@ -286,8 +292,9 @@ Qt for Linux/X11
----------------
- QGtkStyle
* Fixed rtl issues with sliders (QTBUG-8986)
- * Fixed missing pressed appearance on scroll bar handles. (QTBUG-10396)
-
+ * Fixed missing pressed appearance on scroll bar handles. (QTBUG-10396)
+ * Fixed crash when creating QGtkStyle before QApplication. (QTBUG-10758)
+
- QFontDatabase
* [QTBUG-4428] Fixed regression when using bitmap fonts on some
Linux systems.
@@ -303,7 +310,12 @@ Qt for Linux/X11
Qt for Windows
--------------
- Popup windows now implicitly activate when shown. (QTBUG-7386)
-
+ - QComboBox [QTBUG-7552] Fix an issue where only "..." would be shown for
+ QComboBox with certain DPI settings.
+ - Fixed a problem where menus exec'ed on system tray icons did not
+ disappear. (QTBUG-7386)
+ - Improved look and feel for QWizard on Windows 7 and Vista. (QTBUG-9873),
+ (QTBUG-11974) and (QTBUG-6120)
- QLocalSocket
* Pipe handle leak fixed, when closing a QLocalSocket that still has
unwritten data. (QTBUG-7815)
@@ -315,7 +327,9 @@ Qt for Mac OS X
---------------
- QMacStyle
* Removed frame around statusbar items. (QTBUG-3574)
- * More native appearance of item view headers and frames. (QTBUG-10047)
+ * More native appearance of item view headers and frames. (QTBUG-10047)
+ * Increased spacing between tree view items. (QTBUG-10190)
+ * Removed frame around status bar items. (QTBUG-3574)
- QFontEngine
* Enable fractional metrics for the font engine on Mac in all
diff --git a/doc/src/declarative/qml-intro.qdoc b/doc/src/declarative/qml-intro.qdoc
index 63d6825..9130be0 100644
--- a/doc/src/declarative/qml-intro.qdoc
+++ b/doc/src/declarative/qml-intro.qdoc
@@ -58,7 +58,12 @@ would be a property.
The basic syntax of an \l{QML Elements}{element} is
-\snippet doc/src/snippets/declarative/qml-intro/basic-syntax.qml basic syntax
+\code
+SomeElement {
+ id: myObject
+ ... some other things here ...
+}
+\endcode
Here we are defining a new object. We specify its 'type' first as SomeElement.
Then within matching braces { ... } we specify the various parts of our
diff --git a/doc/src/examples/qml-twitter.qdoc b/doc/src/examples/qml-twitter.qdoc
index 8a0de00..c3182a0 100644
--- a/doc/src/examples/qml-twitter.qdoc
+++ b/doc/src/examples/qml-twitter.qdoc
@@ -29,8 +29,8 @@
\title Twitter Mobile
\example demos/declarative/twitter
- This demo shows how to write a mobile Twitter client in QML. Use it to
- tweet us(@qtbynokia) how much you like our demos!
+ This demo shows how to write a mobile Twitter search client in QML. Use it to
+ see what people think about Qt Quick!
\image qml-twitter-demo.png
*/
diff --git a/doc/src/getting-started/gettingstartedqml.qdoc b/doc/src/getting-started/gettingstartedqml.qdoc
index a19d281..405e791 100644
--- a/doc/src/getting-started/gettingstartedqml.qdoc
+++ b/doc/src/getting-started/gettingstartedqml.qdoc
@@ -404,13 +404,9 @@
\image qml-texteditor2_menubar.png
- */
+ \section1 Building a Text Editor
- /*!
- \page qml-textEditor3.html
- \title Building a Text Editor
-
- \section1 Declaring a TextArea
+ \section2 Declaring a TextArea
Our text editor is not a text editor if it didn't contain an editable text area.
QML's \l {TextEdit}{TextEdit} element allows the declaration of a multi-line
@@ -451,7 +447,7 @@
}
\endcode
- \section1 Combining Components for the Text Editor
+ \section2 Combining Components for the Text Editor
We are now ready to create the layout of our text editor using QML. The text
editor has two components, the menu bar we created and the text area. QML allows
@@ -494,12 +490,8 @@
\image qml-texteditor3_texteditor.png
- */
-
- /*!
- \page qml-textEditor4
- \title Decorating the Text Editor
- \section1 Implementing a Drawer Interface
+ \section1 Decorating the Text Editor
+ \section2 Implementing a Drawer Interface
Our text editor looks simple and we need to decorate it. Using QML, we can declare
transitions and animate our text editor. Our menu bar is occupying one-third of the
@@ -652,7 +644,7 @@
The first color starts at \c 0.0 and the last color is at \c 1.0.
- \section2 Where to Go from Here
+ \section3 Where to Go from Here
We are finished building the user interface of a very simple text editor.
Going forward, the user interface is complete, and we can implement the
@@ -661,7 +653,7 @@
\image qml-texteditor4_texteditor.png
- \section1 Extending QML using Qt C++
+ \section2 Extending QML using Qt C++
Now that we have our text editor layout, we may now implement the text editor
functionalities in C++. Using QML with C++ enables us to create our application
@@ -672,7 +664,7 @@
we shall implement the load and save functions in C++ and export it as a plugin.
This way, we only need to load the QML file directly instead of running an executable.
- \section2 Exposing C++ Classes to QML
+ \section3 Exposing C++ Classes to QML
We will be implementing file loading and saving using Qt and C++. C++ classes
and functions can be used in QML by registering them. The class also needs to be
@@ -687,7 +679,7 @@
\o A \c qmldir file telling the qmlviewer tool where to find the plugin
\endlist
- \section2 Building a Qt Plugin
+ \section3 Building a Qt Plugin
To build a plugin, we need to set the following in a Qt project file. First,
the necessary sources, headers, and Qt modules need to be added into our
@@ -721,7 +713,7 @@
parent's \c plugins directory.
- \section2 Registering a Class into QML
+ \section3 Registering a Class into QML
\code
In dialogPlugin.h:
@@ -771,7 +763,7 @@
file to generate the necessary meta-object code.
- \section2 Creating QML Properties in a C++ class
+ \section3 Creating QML Properties in a C++ class
We can create QML elements and properties using C++ and
\l {The Meta-Object System}{Qt's Meta-Object System}. We can implement
@@ -925,7 +917,7 @@
\c make to build and transfer the plugin to the \c plugins directory.
- \section2 Importing a Plugin in QML
+ \section3 Importing a Plugin in QML
The qmlviewer tool imports files that are in the same directory as the
application. We can also create a \c qmldir file containing the locations of
@@ -948,7 +940,7 @@
\c TARGET field in the project file. The compiled plugin is in the \c plugins directory.
- \section2 Integrating a File Dialog into the File Menu
+ \section3 Integrating a File Dialog into the File Menu
Our \c FileMenu needs to display the \c FileDialog element, containing a list of
the text files in a directory thus allowing the user to select the file by
@@ -1038,7 +1030,7 @@
\image qml-texteditor5_filemenu.png
- \section1 Text Editor Completion
+ \section2 Text Editor Completion
\image qml-texteditor5_newfile.png
diff --git a/doc/src/snippets/declarative/qml-intro/basic-syntax.qml b/doc/src/snippets/declarative/qml-intro/basic-syntax.qml
deleted file mode 100644
index 686a927..0000000
--- a/doc/src/snippets/declarative/qml-intro/basic-syntax.qml
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
-**
-** 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 QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// Note: this file is not intended to be run.
-
-//! [basic syntax]
-SomeElement {
- id: myObject
- ... some other things here ...
-}
-//! [basic syntax]
diff --git a/doc/src/snippets/declarative/qml-intro/sequential-animation3.qml b/doc/src/snippets/declarative/qml-intro/sequential-animation3.qml
index f83a966..6926f8a 100644
--- a/doc/src/snippets/declarative/qml-intro/sequential-animation3.qml
+++ b/doc/src/snippets/declarative/qml-intro/sequential-animation3.qml
@@ -39,6 +39,8 @@
****************************************************************************/
//! [document]
+import Qt 4.7
+
Rectangle {
id: mainRec
width: 600
diff --git a/doc/src/tutorials/modelview.qdoc b/doc/src/tutorials/modelview.qdoc
index b39a01c..65f6674 100755..100644
--- a/doc/src/tutorials/modelview.qdoc
+++ b/doc/src/tutorials/modelview.qdoc
@@ -29,22 +29,28 @@
\page modelview.html
\startpage {index.html}{Qt Reference Documentation}
- \nextpage {modelview-part1.html}{Introduction}
\title Model/View Contents
\brief An introduction to ModelView programming
- This tutorial gives an introduction to ModelView programming using the Qt
- cross-platform framework.
+ Every UI developer should know about ModelView programming and the goal of
+ this tutorial is to provide you with an easily understandable introduction
+ to this topic.
+
+ Table, list and tree widgets are components frequently used in GUIs. There
+ are 2 different ways how these widgets can access their data. The
+ traditional way involves widgets which include internal containers for
+ storing data. This approach is very intuitive, however, in many non-trivial
+ applications, it leads to data synchronization issues.
+ The second approach is model/view programming, in
+ which widgets do not maintain internal data containers. They access external
+ data through a standardized interface and therefore avoid data duplication.
+ This may seem complicated at first, but once you take a closer look, it is
+ not only easy to grasp, but the many benefits of model/view programming also
+ become clearer.
\image treeview.png
- \omit
- It doesn't cover everything; the emphasis is on teaching the programming
- philosophy of Model/View programming, and Qt's features are introduced as
- needed. Some commonly used features are never used in this tutorial.
- \endomit
-
In the process, we will learn about some basic technologies provided by Qt,
such as:
@@ -52,38 +58,29 @@
\o The difference between standard and model/view widgets
\o Adapters betweeen forms and models
\o Developing a simple model/view application
+ \o Predefined models
\o Intermediate topics such as:
\list
\o Tree views
\o Selection
- \o Predefined models
\o Delegates
\o Debugging with model test
\endlist
\endlist
- If you are completely new to Qt, please read \l{How to Learn Qt} if you
- have not already done so.
-
- The tutorial's source code is located in Qt's \c examples/tutorials/modelview
- directory.
+ You will also learn whether your new application can be written easier with
+ model/view programming or if classic widgets will work just as well.
- \list 1
- \o \l{modelview-part1.html}{Introduction}
- \o \l{modelview-part2.html}{Developing a Simple Model/View Application}
- \o \l{modelview-part3.html}{Intermediate Topics}
- \o \l{modelview-part4.html}{Good Sources of Additional Information}
- \endlist
+ This tutorial includes example code for you to edit and integrate into your
+ project. The tutorial's source code is located in Qt's
+ \c examples/tutorials/modelview directory.
+ For more detailed information you may also want to look at the
+ \l{model-view-programming.html}{reference documentation}
-*/
+ If you are completely new to Qt, please read \l{How to Learn Qt} if you
+ have not already done so.
-/*!
- \page modelview-part1.html
- \contentspage {modelview.html}{Model/View Contents}
- \previouspage {modelview.html}{Model/View Contents}
- \nextpage {modelview-part2.html}{Developing a Simple Model/View Application}
- \title An Introduction to Model/View Programming
\section1 1. Introduction
@@ -104,16 +101,16 @@
\section2 1.1 Standard Widgets
Let's have a closer look at a standard table widget. A table widget is a 2D
- array of the data elements that the user can change. The table widget can
- be integrated into a program flow by reading and writing the data elements
- that the table widget provides. This method is very intuitive and useful in
- many applications.
+ array of the data elements that the user can change. The table widget can be
+ integrated into a program flow by reading and writing the data elements that
+ the table widget provides. This method is very intuitive and useful in many
+ applications.
Displaying and editing a database table with a standard table widget can be
problematic. Two copies of the data have to be coordinated: one outside the
- widget; one inside the widget. The developer needs to know where up-to-date
- data is so the both copies contain the most recent data. The tight coupling
- of presentation and data makes it harder to write unit tests.
+ widget; one inside the widget. The developer is responsible for
+ synchronizing both versions. The tight coupling of presentation and data
+ makes it harder to write unit tests.
\section2 1.2 Model/View to the Rescue
@@ -121,14 +118,14 @@
architecture. Model/view eliminates the data consistency problems that may
occur with standard widgets. Model/view also makes it easier to use more
than one view of the same data because one model can be passed on to many
- views. The most important difference is that model/view widgets do not
- store data behind the table cells. In fact, they operate directly from your
- data. Since view classes do not know your data's structure, you need to
- provide a wrapper to make your data conform to the QAbstractItemModel
- interface. A view uses this interface to read from and write to your data
- and any class that implements QAbstractItemModel is a model. Once the view
- receives a pointer to a model, it will read and display its content and be
- its editor.
+ views. The most important difference is that model/view widgets do not store
+ data behind the table cells. In fact, they operate directly from your data.
+ Since view classes do not know your data's structure, you need to provide a
+ wrapper to make your data conform to the QAbstractItemModel interface. A
+ view uses this interface to read from and write to your data. Any instance
+ of a class that implements QAbstractItemModel is said to be a model. Once
+ the view receives a pointer to a model, it will read and display its content
+ and be its editor.
\section2 1.3 Overview of the Model/View Widgets
@@ -138,9 +135,10 @@
\table
\header
\o Widget
- \o Standard Widget (a convenience class with data in
- the widget)
- \o Model/View View Class (for use with external data)
+ \o Standard Widget\br
+ (an item based convenience class)
+ \o Model/View View Class\br
+ (for use with external data)
\row
\o \inlineimage listview.png
\o \l QListWidget
@@ -167,47 +165,26 @@
Having adapters between forms and models can come in handy.
- We often prefer editing data stored in tables (e.g. in database tables) in
- forms rather than in tables. There is no direct model/view counterpart for
- separating data and views for widgets that operate on one value instead of
- a dataset, so we need an adapter in order to connect the form to the source
- of data.
+ We can edit data stored in tables directly from within the table itself, but
+ it's much more comfortable to edit data in text fields. There is no direct
+ model/view counterpart that separates data and views for widgets that
+ operate on one value (QLineEdit, QCheckBox ...) instead of a dataset, so we
+ need an adapter in order to connect the form to the source of data.
\l QDataWidgetMapper is a great solution because it maps form widgets to a
- table row and it makes it very easy to build forms for database tables.
+ table row and makes it very easy to build forms for database tables.
\image widgetmapper.png
- Another example of an adapter is QCompleter. Qt has QCompleter for
- providing auto-completions in Qt widgets such as QComboBox and, as shown
- below, QLineEdit. QCompleter uses a model as its data source, so QCompleter,
- in itself, is a very handy adapter.
+ Another example of an adapter is \l QCompleter. Qt has \l QCompleter for
+ providing auto-completions in Qt widgets such as \l QComboBox and, as shown
+ below, \l QLineEdit. \l QCompleter uses a model as its data source.
\image qcompleter.png
-*/
-
-/*!
- \page modelview-part2-main-cpp.html
- \title main.cpp
- \quotefile tutorials/modelview/1_readonly/main.cpp
-*/
-/*!
- \page modelview-part2.html
- \contentspage {modelview-index.html}{Model/View Contents}
- \previouspage {modelview-part1.html}{Introduction}
- \nextpage {modelview-part3.html}{Intermediate Topics}
- \title Model/View Chapter 2 - A Simple Model/View Application
\section1 2. A Simple Model/View Application
-
- If you want to develop a model/view application, where should you start? We
- recommend starting with a simple example and extending it step-by-step.
- This makes understanding the architecture a lot easier. Trying to
- understand the model/view architecture in detail before invoking the IDE
- has proven to be less convenient for many developers. It is substantially
- easier to start with a simple model/view application that has demo data.
- Give it a try! Simply replace the data in the examples below with your own.
+ If you want to develop a model/view application, where should you start? We recommend starting with a simple example and extending it step-by-step. This makes understanding the architecture a lot easier. Trying to understand the model/view architecture in detail before invoking the IDE has proven to be less convenient for many developers. It is substantially easier to start with a simple model/view application that has demo data. Give it a try! Simply replace the data in the examples below with your own.
Below are 7 very simple and independent applications that show different
sides of model/view programming. The source code can be found inside the
@@ -216,58 +193,55 @@
\section2 2.1 A Read Only Table
We start with an application that uses a QTableView to show data. We will
- add editing capabilities later.
+ add editing capabilities later.
+ (file source: examples/tutorials/modelview/1_readonly/main.cpp)
\snippet examples/tutorials/modelview/1_readonly/main.cpp Quoting ModelView Tutorial
We have the usual \l {modelview-part2-main-cpp.html}{main()} function:
- \snippet examples/tutorials/modelview/1_readonly/modelview.h Quoting ModelView Tutorial
-
- The application is a \l QMainWindow that holds a \l QTableView.
-
- \snippet examples/tutorials/modelview/1_readonly/modelview.cpp Quoting ModelView Tutorial
-
- Here is the interesting part: We use
- \l{QTableView::setModel()}{tableView->setModel(new MyModel(this));} to
- instantiate the Model and pass its pointer to \l {QTableView}{tableView()}.
- \l{QTableView}{tableView} will invoke the methods of the pointer it has
- received to find out two things:
+ Here is the interesting part: We create an instance of MyModel and use
+ \l{QTableView::setModel()}{tableView.setModel(&myModel);} to pass a
+ pointer of it to to \l{QTableView}{tableView}. \l{QTableView}{tableView}
+ will invoke the methods of the pointer it has received to find out two
+ things:
\list
- \o How many rows and columns should be displayed
- \o What content should be printed into each cell.
+ \o How many rows and columns should be displayed.
+ \o What content should be printed into each cell.
\endlist
- The model needs some code to respond to this.
+ The model needs some code to respond to this.
We have a table data set, so let's start with QAbstractTableModel since it
- is easier to use.
+ is easier to use than the more general QAbstractItemModel.
+ (file source: examples/tutorials/modelview/1_readonly/mymodel.h)
\snippet examples/tutorials/modelview/1_readonly/mymodel.h Quoting ModelView Tutorial
QAbstractTableModel requires the implementation of three abstract methods.
+ (file source: examples/tutorials/modelview/1_readonly/mymodel.cpp)
\snippet examples/tutorials/modelview/1_readonly/mymodel.cpp Quoting ModelView Tutorial
- The number of rows and columns is set by
+ The number of rows and columns is provided by
\l{QAbstractItemModel::rowCount()}{MyModel::rowCount()} and
- \l{QAbstractItemModel::columnCount()}{MyModel::columnCount()}.
- When the view has to know what the cell's text is, it calls the method.
- Row and column information is specified with parameter \c index and the
- role is set to \l{Qt::ItemDataRole}{Qt::DisplayRole}. Other roles are
- covered in the next section. In our example, the data that should be
- displayed is generated. In a real application, \c MyModel would have a
- member called \c MyData, which serves as the target for all reading and
- writing operations.
+ \l{QAbstractItemModel::columnCount()}{MyModel::columnCount()}. When the view
+ has to know what the cell's text is, it calls the method
+ \l{QAbstractItemModel::data()}{MyModel::data()}. Row and column information
+ is specified with parameter \c index and the role is set to
+ \l{Qt::ItemDataRole}{Qt::DisplayRole}. Other roles are covered in the next
+ section. In our example, the data that should be displayed is generated. In
+ a real application, \c MyModel would have a member called \c MyData, which
+ serves as the target for all reading and writing operations.
This small example demonstrates the passive nature of a model. The model
does not know when it will be used or which data is needed. It simply
- provides data each time the view requests it.
+ provides data each time the view requests it.
- What happens when the model 's data needs to be changed? How does the view
- know when data changes and needs to be read again? The model has to emit a
- signal that indicates what range of cells has changed. This will be
+ What happens when the model's data needs to be changed? How does the view
+ realize that data has changed and needs to be read again? The model has to
+ emit a signal that indicates what range of cells has changed. This will be
demonstrated in section 2.3.
\section2 2.2 Extending the Read Only Example with Roles
@@ -276,12 +250,14 @@
controls the text's appearance. When we slightly change the model, we get
the following result: \image readonlytable_role.png
- In fact, nothing except for the \l{QAbstractItemModel::}{data()}
- method needs to be changed to set fonts, background colour, alignment and a
+ In fact, nothing except for the \l{QAbstractItemModel::}{data()} method
+ needs to be changed to set fonts, background colour, alignment and a
checkbox.
- Here is the \l{QAbstractItemModel::data()}{data()} method that produces the
- result shown above:
+ Below is the \l{QAbstractItemModel::data()}{data()} method that produces the
+ result shown above. The difference is that this time we use parameter int
+ role to return different pieces of information depending on its value.
+ (file source: examples/tutorials/modelview/2_formatting/mymodel.cpp)
\snippet examples/tutorials/modelview/2_formatting/mymodel.cpp Quoting ModelView Tutorial
Each formatting property will be requested from the model with a separate
@@ -290,42 +266,45 @@
\table
\header
- \o Role (enum Qt::ItemDataRole )
+ \o \l{Qt::ItemDataRole}{enum Qt::ItemDataRole}
\o Meaning
- \o Type
+ \o Type
\row
- \o \l{Qt::ItemDataRole}{Qt::DisplayRole}
+ \o \l{Qt::ItemDataRole}{}Qt::DisplayRole
\o text
\o QString
\row
- \o Qt::FontRole
+ \o \l{Qt::ItemDataRole}{Qt::FontRole}
\o font
\o QFont
\row
- \o Qt::BackgroundRole
+ \o \l{Qt::ItemDataRole}{BackgroundRole}
\o brush for the background of the cell
\o QBrush
\row
- \o Qt::TextAlignmentRole
+ \o \l{Qt::ItemDataRole}{Qt::TextAlignmentRole}
\o text alignment
- \o enum Qt::AlignmentFlag
+ \o \l{Qt::AlignmentFlag}{enum Qt::AlignmentFlag}
\row
- \o {1, 3} Qt::CheckStateRole
+ \o {1, 3} \l{Qt::ItemDataRole}{Qt::CheckStateRole}
\o {1, 3} suppresses checkboxes with \l{QVariant}{QVariant()},
- sets checkboxes with Qt::Checked or Qt::Unchecked
- \o {1, 3} \l{Qt::ItemDataRole}{enum Qt::ItemDataRole}
+
+ sets checkboxes with \l{Qt::CheckState}{Qt::Checked}
+
+ or \l{Qt::CheckState}{Qt::Unchecked}
+ \o {1, 3} \l{Qt::ItemDataRole}{enum Qt::ItemDataRole}
\endtable
Refer to the Qt namespace documentation to learn more about the
- Qt::ItemDataRole enum's capabilities.
+ \l{Qt::ItemDataRole}{Qt::ItemDataRole} enum's capabilities.
- Now we need to determine how using a seperated model impacts the
+ Now we need to determine how using a separated model impacts the
application's performance, so let's trace how often the view calls the
- \l{QAbstractItemModel::}{data()} method. In order to track how often
- the view calls the model, we have put a debug statement in the
- \l{QAbstractItemModel::}{data()} method, which logs onto stdio. In
- our small example, \l{QAbstractItemModel::}{data()} will be called 42
- times.
+ \l{QAbstractItemModel::}{data()} method. In order to track how often the
+ view calls the model, we have put a debug statement in the
+ \l{QAbstractItemModel::}{data()} method, which logs onto the error output
+ stream. In our small example, \l{QAbstractItemModel::}{data()} will be
+ called 42 times.
Each time you hover the cursor over the field,
\l{QAbstractItemModel::}{data()} will be called again \mdash 7 times for
each cell. That's why it is important to make sure that your data is
@@ -339,6 +318,7 @@
We still have a read only table, but this time the content changes every
second because we are showing the current time.
+ (file source: examples/tutorials/modelview/3_changingmodel/mymodel.cpp)
\snippet examples/tutorials/modelview/3_changingmodel/mymodel.cpp quoting mymodel_QVariant
Something is missing to make the clock tick. We need to tell the view every
@@ -346,17 +326,18 @@
this with a timer. In the constructor, we set its interval to 1 second and
connect its timeout signal.
+ (file source: examples/tutorials/modelview/3_changingmodel/mymodel.cpp)
\snippet examples/tutorials/modelview/3_changingmodel/mymodel.cpp quoting mymodel_a
Here is the corresponding slot:
+ (file source: examples/tutorials/modelview/3_changingmodel/mymodel.cpp)
\snippet examples/tutorials/modelview/3_changingmodel/mymodel.cpp quoting mymodel_b
We ask the view to read the data in the top left cell again by emitting the
\l{QAbstractItemModel::}{dataChanged()} signal. Note that we did not
- explicitly connect the \l{QAbstractItemModel::}{dataChanged()} signal to
- the view. This happened automatically when we called
- \l{QTableView::}{setModel()}.
+ explicitly connect the \l{QAbstractItemModel::}{dataChanged()} signal to the
+ view. This happened automatically when we called \l{QTableView::}{setModel()}.
\section2 2.4 Setting up Headers for Columns and Rows
@@ -366,60 +347,58 @@
The header content, however, is set via the model, so we reimplement the
\l{QAbstractItemModel::headerData()}{headerData()} method:
+ (file source: examples/tutorials/modelview/4_headers/mymodel.cpp)
\snippet examples/tutorials/modelview/4_headers/mymodel.cpp quoting mymodel_c
+ Note that method \l{QAbstractItemModel::headerData()}{headerData()} also has
+ a parameter role which has the same meaning as in
+ \l{QAbstractItemModel::data()}{MyModel::data()}.
\section2 2.5 The Minimal Editing Example
In this example, we are going to build an application that automatically
- populates a window title with content by repeating values entered into
- table cells.
+ populates a window title with content by repeating values entered into table
+ cells. To be able to access the window title easily we put the QTableView in
+ a QMainWindow.
- The model decides whether editing capabilities are available . We only have
+ The model decides whether editing capabilities are available. We only have
to modify the model in order for the available editing capabilities to be
enabled. This is done by reimplementing the following virtual methods:
\l{QAbstractItemModel::}{setData()} and \l{QAbstractItemModel::}{flags()}.
+ (file source: examples/tutorials/modelview/5_edit/mymodel.h)
\snippet examples/tutorials/modelview/5_edit/mymodel.h Quoting ModelView Tutorial
- We use \c QStringList m_gridData to store our data. This makes
- \c m_gridData the core of MyModel. The rest of \c MyModel acts like a
- wrapper and adapts \c m_gridData to the QAbstractItemModel interface. We
- have also introduced the \c editCompleted() signal,
- which makes it possible to transfer the modified text to the window title.
-
- \snippet examples/tutorials/modelview/5_edit/mymodel.cpp quoting mymodel_d
-
- In the constructor, we fill \c QStringList gridData with 6 items (one item
- for every field in the table):
+ We use \c the two-dimensional array QString \c m_gridData to store our data.
+ This makes \c m_gridData the core of \c MyModel. The rest of \c MyModel acts
+ like a wrapper and adapts \c m_gridData to the QAbstractItemModel
+ interface. We have also introduced the \c editCompleted() signal, which
+ makes it possible to transfer the modified text to the window title.
+ (file source: examples/tutorials/modelview/5_edit/mymodel.cpp)
\snippet examples/tutorials/modelview/5_edit/mymodel.cpp quoting mymodel_e
\l{QAbstractItemModel::setData()}{setData()} will be called each time the
user edits a cell. The \c index parameter tells us which field has been
edited and \c value provides the result of the editing process. The role
- will always be set to \c Qt::EditRole because our cells only contain text.
+ will always be set to \l Qt::EditRole because our cells only contain text.
If a checkbox were present and user permissions are set to allow the
checkbox to be selected, calls would also be made with the role set to
- \c Qt::CheckStateRole.
+ \l Qt::CheckStateRole.
+ (file source: examples/tutorials/modelview/5_edit/mymodel.cpp)
\snippet examples/tutorials/modelview/5_edit/mymodel.cpp quoting mymodel_f
Various properties of a cell can be adjusted with
- \l{QAbstractItemModel::flags()}{flags()}. Returning
- \c Qt::ItemIsEditable | \c Qt::ItemIsEnabled is enough to show an editor
- that a cell has been selected. If editing one cell modifies more data than
- the data in that particular cell, the model must emit a
- \l{QAbstractItemModel::}{dataChanged()} signal in order for the data that
- has been changed to be read.
-*/
+ \l{QAbstractItemModel::flags()}{flags()}.
+
+ Returning \l{Qt::ItemFlag}{Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled}
+ is enough to show an editor that a cell can be selected.
+
+ If editing one cell modifies more data than the data in that particular
+ cell, the model must emit a \l{QAbstractItemModel::}{dataChanged()} signal
+ in order for the data that has been changed to be read.
-/*!
- \page modelview-part3.html
- \contentspage {modelview-index.html}{Model/View Contents}
- \previouspage {modelview-part2.html}{Developing a Simple Model/View Application}
- \nextpage {modelview-part4.html}{Good Sources of Additional Information}
- \title Model/View Chapter 3 - Intermediate Topics
\section1 3. Intermediate Topics
@@ -429,28 +408,30 @@
Simply replace QTableView with QTreeView, which results in a read/write
tree. No changes have to be made to the model. The tree won't have any
hierarchies because there aren't any hierarchies in the model itself.
- \image dummy_tree.png
+ \image dummy_tree.png
QListView, QTableView and QTreeView all use a model abstraction, which is a
merged list, table and tree. This makes it possible to use several different
types of view classes from the same model.
- \image list_table_tree.png
+ \image list_table_tree.png
This is how our example model looks so far:
- \image example_model.png
+ \image example_model.png
We want to present a real tree. We have wrapped our data in the examples
above in order to make a model. This time we use QStandardItemModel, which
is a container for hierarchical data that also implements
QAbstractItemModel. To show a tree, QStandardItemModel must be populated
- with \l{QStandardItem}{QStandardItems}, which are able to hold all the
- standard properties of items like text, fonts, checkboxes or brushes.
+ with \l{QStandardItem}s, which are able to hold all the standard properties
+ of items like text, fonts, checkboxes or brushes.
+
\image tree_2_with_algorithm.png
- \snippet examples/tutorials/modelview/6_treeview/modelview.cpp Quoting ModelView Tutorial
+ (file source: examples/tutorials/modelview/6_treeview/mainwindow.cpp)
+ \snippet examples/tutorials/modelview/6_treeview/mainwindow.cpp Quoting ModelView Tutorial
We simply instantiate a QStandardItemModel and add a couple of
\l{QStandardItem}{QStandardItems} to the constructor. We can then make a
@@ -462,42 +443,45 @@
We want to access a selected item's content in order to output it into the
window title together with the hierarchy level.
+
\image selection2.png
So let's create a couple of items:
- \snippet examples/tutorials/modelview/7_selections/modelview.cpp quoting modelview_a
+ (file source: examples/tutorials/modelview/7_selections/mainwindow.cpp)
+ \snippet examples/tutorials/modelview/7_selections/mainwindow.cpp quoting modelview_a
Views manage selections within a separate selection model, which can be
- retrieved with the \l{QAbstractItemView::}{selectionModel()}
- method. We retrieve the selection Model in order to connect a slot to its
+ retrieved with the \l{QAbstractItemView::}{selectionModel()} method. We
+ retrieve the selection Model in order to connect a slot to its
\l{QAbstractItemView::}{selectionChanged()} signal.
- \snippet examples/tutorials/modelview/7_selections/modelview.cpp quoting modelview_b
+ (file source: examples/tutorials/modelview/7_selections/mainwindow.cpp)
+ \snippet examples/tutorials/modelview/7_selections/mainwindow.cpp quoting modelview_b
- We get the model index that corresponds to the selection by calling
+ We get the model index that corresponds to the selection by calling
\l{QItemSelectionModel::currentIndex()}{treeView->selectionModel()->currentIndex()}
and we get the the field's string by using the model index. Then we just
- calculate the item's \c hierarchyLevel. Top level items do not have
- parents and the \l{QAbstractItemModel::}{parent()} method will return a
- default constructed \l{QModelIndex}{QModelIndex()}. This is why we use the
+ calculate the item's \c hierarchyLevel. Top level items do not have parents
+ and the \l{QAbstractItemModel::}{parent()} method will return a default
+ constructed \l{QModelIndex}{QModelIndex()}. This is why we use the
\l{QAbstractItemModel::}{parent()} method to iterate to the top level while
counting the steps performed during iteration.
The selection model (as shown above) can be retrieved, but it can also be
set with \l{QAbstractItemView}{QAbstractItemView::setSelectionModel}. This
is how it's possible to have 3 view classes with synchronised selections
- because only one instance of a selection model is used. The instance of a
- selection model is retrieved from the first view class with
- \l{QAbstractItemView::}{selectionModel()} and the result is assigned to the
- second and third view class with \l{QAbstractItemView::}{setSelectionModel()}.
+ because only one instance of a selection model is used. To share a selection
+ model between 3 views use \l{QAbstractItemView::}{selectionModel()} and
+ assign the result to the second and third view class with
+ \l{QAbstractItemView::}{setSelectionModel()}.
\section2 3.3 Predefined Models
- The typical way to use model/view is to wrap specific data to make it
- usable with view classes. Qt, however, also provides predefined models for
- common underlying data structures. If one of the available data structures
- is suitable for your application, a predefined model can be a good choice.
+ The typical way to use model/view is to wrap specific data to make it usable
+ with view classes. Qt, however, also provides predefined models for common
+ underlying data structures. If one of the available data structures is
+ suitable for your application, a predefined model can be a good choice.
\table
\row
@@ -531,26 +515,26 @@
and is edited as text or a checkbox. The component that provides these
presentation and editing services is called a \e delegate. We are only just
beginning to work with the delegate because the view uses a default
- delegate. But imagine that we want to have a different editor.(e.g. a
+ delegate. But imagine that we want to have a different editor (e.g., a
slider or a drop down list) Or imagine that we want to present data as
- graphics. Let's take a look at an example called
- \l{Star Delegate Example}{Star Delegate}, in which stars are used to show
- a rating:
+ graphics.
+ Let's take a look at an example called \l{Star Delegate Example}{Star
+ Delegate}, in which stars are used to show a rating:
+
\image stardelegate.png
- The view has a method that replaces the default delegate and installs a
- custom delegate. This method is called
- \l{QAbstractItemView::}{setItemDelegate()}. A new delegate can be written
- by creating a class that inherits from QStyledItemDelegate. In order to
- write a delegate that displays stars and has no input capabilities, we only
- need to overwrite 2 methods.
+ The view has a \l{QAbstractItemView::}{setItemDelegate()} method that
+ replaces the default delegate and installs a custom delegate.
+ A new delegate can be written by creating a class that inherits from
+ QStyledItemDelegate. In order to write a delegate that displays stars and
+ has no input capabilities, we only need to override 2 methods.
\code
class StarDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
- StarDelegate(QWidget *parent = 0);
+ StarDelegate(QWidget *parent = 0);
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option,
@@ -558,16 +542,28 @@
};
\endcode
- \l{QStyledItemDelegate::}{paint()} draws stars depending on the content
- of the underlying data. The data can be looked up with parameter
- \l{QModelIndex::data()}{index.data()}.
- \l{QAbstractItemDelegate::}{sizeHint()} specifies each star's dimensions
- so the the cell will provide enough height and width to accommodate the
- stars.
+ \l{QStyledItemDelegate::}{paint()} draws stars depending on the content of
+ the underlying data. The data can be looked up by calling
+ \l{QModelIndex::data()}{index.data()}. The delegate's
+ \l{QAbstractItemDelegate::}{sizeHint()} method is used to obtain each
+ star's dimensions, so the the cell will provide enough height and width to
+ accommodate the stars.
Writing custom delegates is the right choice if you want to show your data
- with a custom graphical representation inside the grid of the view class.
- If you want to leave the grid, you can write a custom view class.
+ with a custom graphical representation inside the grid of the view class. If
+ you want to leave the grid, you would not use a custom delegate but a custom
+ view class.
+
+ Other references to delegates in Qt Documentation:
+
+ \list
+ \o \l{Spin Box Delegate Example}
+ \o \l{QAbstractItemDelegate}{QAbstractItemDelegate Class Reference}
+ \o \l{QSqlRelationalDelegate}{QSqlRelationalDelegate Class Reference}
+ \o \l{QStyledItemDelegate}{QStyledItemDelegate Class Reference}
+ \o \l{QItemDelegate}{QItemDelegate Class Reference}
+ \endlist
+
\section2 3.5 Debugging with ModelTest
@@ -575,9 +571,9 @@
Inconsistencies in the model can cause the application to crash. Since the
model is hit by numerous calls from the view, it is hard to find out which
call has crashed the application and which operation has introduced the
- problem.
+ problem.
- Qt provides software called
+ Qt Labs provides software called
\l{http://labs.qt.nokia.com/page/Projects/Itemview/Modeltest}{ModelTest},
which checks models while your programming is running. Every time the model
is changed, ModelTest scans the model and reports errors with an assert.
@@ -586,57 +582,9 @@
Unlike view classes, ModelTest uses out of range indexes to test the model.
This means your application may crash with ModelTest even if it runs
- perfectly without it. So you also need to handle all of the indexes that
- are out of range when using ModelTest.
-
-
- \section2 3.6 Model/View NG
-
- \raw HTML
- <table style="background-color:white;border:none;font: normal 13px/1.2 Verdana;">
- <tr><td align="left" valign="top" style="background-color:white;border:none;padding:5px;">
- \endraw
-
- \raw HTML
- <!-- wrap content table p has 0 padding and the padding for p outside of the table is 5px-->
- \endraw
-
- Model/View was introduced in Qt 4.0 and is a frequently used technology.
- Feedback from developers and new development trends have shown that there
- is a need to further develop the model/view technology. Therefore a
- research project originated at Nokia is looking into ways to go beyond the
- current implementation.
-
- One limitation of model/view is that view classes are basically all fixed
- grids. It is possible, but really hard to make a list view with icons
- placed on a curve; or cells expanding on mouse over events to show
- additional information.
- In order to achieve graphically rich view experiences, Model/View NG will
- use QGraphicsView to render elements. Nodel/View NG also aims to make
- model/view programming more intuitive. One way to achieve this is to have
- separate models for lists, tables and trees. The current model abstraction
- is complex because it is capable of representing a list, a table or a tree.
-
- Model/View NG is a research project. You are welcome to checkout the source
- code, monitor progress and take part in discussions at the following
- address: \l{http://labs.qt.nokia.com/page/Projects/Itemview/ItemviewsNG}
-
- \raw HTML
- </td><td align="right" valign="top">
- \endraw
-
- \inlineimage path.png
-
- \raw HTML
- </td></tr></table>
- \endraw
-*/
+ perfectly without it. So you also need to handle all of the indexes that are
+ out of range when using ModelTest.
-/*!
- \page modelview-part4.html
- \contentspage {modelview-index.html}{Model/View Contents}
- \previouspage {modelview-part3.html}{Intermediate Topics}
- \title Model/View Chapter 4 - Good Sources of Additional Information
\section1 4. Good Sources of Additional Information
@@ -666,10 +614,10 @@
\table
\header
- \o example name
- \o view class used
- \o model used
- \o aspects touched
+ \o Example name
+ \o View class used
+ \o Model used
+ \o Aspects covered
\o
\row
\o Team Leaders
@@ -695,26 +643,26 @@
\o QTableView
\o custom model based on
QAbstractTableModel
- \o read only
+ \o Read only
\o Book 1, Chapter 10, Figure 10.10
\row
\o Cities
\o QTableView
- \o custom model based on
+ \o Custom model based on
QAbstractTableModel
- \o read / write
+ \o Read / write
\o Book 1, Chapter 10, Figure 10.12
\row
\o Boolean Parser
\o QTreeView
- \o custom model based on
+ \o Custom model based on
QAbstractItemModel
- \o read only
+ \o Read only
\o Book 1, Chapter 10, Figure 10.14
\row
\o Track Editor
\o {2, 1} QTableWidget
- \o custom delegate providing a custom editor
+ \o Custom delegate providing a custom editor
\o Book 1, Chapter 10, Figure 10.15
\row
@@ -723,47 +671,47 @@
QTableView
QTreeView
\o QDirModel
- \o demonstrates the use of multiple views
+ \o Demonstrates the use of multiple views
\o Book2, Chapter 8.2
\row
\o Address Book
\o QListView
QTableView
QTreeView
- \o custom model based on
+ \o Custom model based on
QAbstractTableModel
- \o read / write
+ \o Read / write
\o Book2, Chapter 8.4
\row
\o Address Book with sorting
\o
\o QProxyModel
- \o introducing sort and filter capabilities
+ \o Introducing sort and filter capabilities
\o Book2, Chapter 8.5
\row
\o Address Book
with checkboxes
\o
\o
- \o introducing checkboxes in model/view
+ \o Introducing checkboxes in model/view
\o Book2, Chapter 8.6
\row
\o Address Book with transposed grid
\o
- \o custom proxy Model based on QAbstractProxyModel
- \o introducing a custom model
+ \o Custom proxy Model based on QAbstractProxyModel
+ \o Introducing a custom model
\o Book2, Chapter 8.7
\row
\o Address Book with drag and drop
\o
\o
- \o introducing drag and drop support
+ \o Introducing drag and drop support
\o Book2, Chapter 8.8
\row
\o Address Book with custom editor
\o
\o
- \o introducing custom delegates
+ \o Introducing custom delegates
\o Book2, Chapter 8.9
\row
\o Views
@@ -771,51 +719,51 @@
QTableView
QTreeView
\o QStandardItemModel
- \o read only
+ \o Read only
\o Book 3, Chapter 5, figure 5-3
\row
\o Bardelegate
\o QTableView
\o
- \o custom delegate for presentation based on QAbstractItemDelegate
+ \o Custom delegate for presentation based on QAbstractItemDelegate
\o Book 3, Chapter 5, figure 5-5
\row
\o Editdelegate
\o QTableView
\o
- \o custom delegate for editing based on QAbstractItemDelegate
+ \o Custom delegate for editing based on QAbstractItemDelegate
\o Book 3, Chapter 5, figure 5-6
\row
\o Singleitemview
- \o custom view based on QAbstractItemView
+ \o Custom view based on QAbstractItemView
\o
- \o custom view
+ \o Custom view
\o Book 3,
Chapter 5,
figure 5-7
\row
\o listmodel
\o QTableView
- \o custom Model based on QAbstractTableModel
- \o read only
+ \o Custom Model based on QAbstractTableModel
+ \o Read only
\o Book 3, Chapter 5, Figure 5-8
\row
\o treemodel
\o QTreeView
- \o custom Model based on QAbstractItemModel
- \o read only
+ \o Custom Model based on QAbstractItemModel
+ \o Read only
\o Book 3, Chapter 5, Figure 5-10
\row
\o edit integers
\o QListView
- \o custom Model based on QAbstractListModel
- \o read / write
+ \o Custom Model based on QAbstractListModel
+ \o Read / write
\o Book 3, Chapter 5, Listing 5-37, Figure 5-11
\row
\o sorting
\o QTableView
\o QSortFilterProxyModel applied to QStringListModel
- \o demonstrates sorting
+ \o Demonstrates sorting
\o Book 3, Chapter 5, Figure 5-12
\endtable
@@ -823,19 +771,20 @@
\section2 4.2 Qt Documentation
Qt 4.7 comes with 17 examples and 2 Demonstrations for model/view.
- The examples can be found here: \l{Item Views Examples}
+ The examples can be found on the \l{Item Views Examples} page.
+
\table
\header
\o Example name
\o View class used
\o Model used
- \o Aspects touched
+ \o Aspects covered
\row
\o Address Book
\o QTableView
\o QAbstractTableModel
QSortFilterProxyModel
- \o usage of QSortFilterProxyModel to generate different
+ \o Usage of QSortFilterProxyModel to generate different
subsets from one data pool
\row
\o Basic Sort/Filter Model
@@ -845,41 +794,41 @@
\o
\row
\o Chart
- \o custom view
+ \o Custom view
\o QStandardItemModel
- \o designing custom views that cooperate with selection models
+ \o Designing custom views that cooperate with selection models
\row
\o Color Editor Factory
\o {2, 1} QTableWidget
- \o enhancing the standard delegate with a new custom editor to choose colours
+ \o Enhancing the standard delegate with a new custom editor to choose colours
\row
\o Combo Widget Mapper
\o QDataWidgetMapper to map QLineEdit, QTextEdit and QComboBox
\o QStandardItemModel
- \o shows how a QComboBox can serve as a view class
+ \o Shows how a QComboBox can serve as a view class
\row
\o Custom Sort/Filter Model
\o QTreeView
\o QStandardItemModel
QSortFilterProxyModel
- \o subclass QSortFilterProxyModel for advanced sorting and filtering
+ \o Subclass QSortFilterProxyModel for advanced sorting and filtering
\row
\o Dir View
\o QTreeView
\o QDirModel
- \o very small example to demonstrate how to assign a model to a view
+ \o Very small example to demonstrate how to assign a model to a view
\row
\o Editable Tree Model
\o QTreeView
- \o custom tree model
- \o comprehensive example for working with trees, demonstrates
+ \o Custom tree model
+ \o Comprehensive example for working with trees, demonstrates
editing cells and tree structure with an underlying custom
model
\row
\o Fetch More
\o QListView
- \o custom list model
- \o dynamically changing model
+ \o Custom list model
+ \o Dynamically changing model
\row
\o Frozen Column
\o QTableView
@@ -888,47 +837,47 @@
\row
\o Pixelator
\o QTableView
- \o custom table model
- \o implementation of a custom delegate
+ \o Custom table model
+ \o Implementation of a custom delegate
\row
\o Puzzle
\o QListView
- \o custom list model
- \o model/view with drag and drop
+ \o Custom list model
+ \o Model/view with drag and drop
\row
\o Simple DOM Model
\o QTreeView
- \o custom tree model
- \o read only example for a custom tree model
+ \o Custom tree model
+ \o Read only example for a custom tree model
\row
\o Simple Tree Model
\o QTreeView
- \o custom tree model
- \o read only example for a custom tree model
+ \o Custom tree model
+ \o Read only example for a custom tree model
\row
\o Simple Widget Mapper
\o QDataWidgetMapper to map QLineEdit, QTextEdit and QSpinBox
\o QStandardItemModel
- \o basic QDataWidgetMapper usage
+ \o Basic QDataWidgetMapper usage
\row
\o Spin Box Delegate
\o QTableView
\o QStandardItemModel
- \o custom delegate that uses a spin box as a cell editor
+ \o Custom delegate that uses a spin box as a cell editor
\row
\o Star Delegate
\o {2, 1} QTableWidget
- \o comprehensive custom delegate example.
+ \o Comprehensive custom delegate example.
\endtable
- \l{Qt Demonstrations}{Demonstrations} are similar to examples except
- that no walkthrough is provided for the code. Demonstrations are also
- sometimes more feature rich.
+ \l{Qt Demonstrations}{Demonstrations} are similar to examples except that no
+ walkthrough is provided for the code. Demonstrations are typically more
+ feature rich than examples.
\list
\o The \bold Interview demonstration shows the same model and
selection being shared between three different views.
- \o Demonstration \bold Spreadsheet demonstrates the use of a
+ \o The \bold Spreadsheet demonstration illustrates the use of a
table view as a spreadsheet, using custom delegates to render
each item according to the type of data it contains.
\endlist
@@ -936,3 +885,9 @@
A \l{Model/View Programming}{reference document} for model/view technology
is also available.
*/
+
+/*!
+ \page modelview-part2-main-cpp.html
+ \title main.cpp
+ \quotefile tutorials/modelview/1_readonly/main.cpp
+*/
diff --git a/examples/sql/masterdetail/mainwindow.cpp b/examples/sql/masterdetail/mainwindow.cpp
index b8c9df6..2ef8ad0 100644
--- a/examples/sql/masterdetail/mainwindow.cpp
+++ b/examples/sql/masterdetail/mainwindow.cpp
@@ -189,9 +189,9 @@ void MainWindow::deleteAlbum()
QMessageBox::StandardButton button;
button = QMessageBox::question(this, tr("Delete Album"),
- QString(tr("Are you sure you want to " \
- "delete '%1' by '%2'?"))
- .arg(title).arg(artist),
+ tr("Are you sure you want to "
+ "delete '%1' by '%2'?")
+ .arg(title, artist),
QMessageBox::Yes | QMessageBox::No);
if (button == QMessageBox::Yes) {
diff --git a/examples/tools/treemodelcompleter/mainwindow.cpp b/examples/tools/treemodelcompleter/mainwindow.cpp
index 0448e9d..cfe003a 100644
--- a/examples/tools/treemodelcompleter/mainwindow.cpp
+++ b/examples/tools/treemodelcompleter/mainwindow.cpp
@@ -241,6 +241,6 @@ void MainWindow::changeCase(int cs)
void MainWindow::updateContentsLabel(const QString& sep)
{
- contentsLabel->setText(QString(tr("Type path from model above with items at each level separated by a '%1'")).arg(sep));
+ contentsLabel->setText(tr("Type path from model above with items at each level separated by a '%1'").arg(sep));
}
diff --git a/examples/tutorials/modelview/1_readonly/1_readonly.pro b/examples/tutorials/modelview/1_readonly/1_readonly.pro
index 1162d5a..3ecebc2 100644..100755
--- a/examples/tutorials/modelview/1_readonly/1_readonly.pro
+++ b/examples/tutorials/modelview/1_readonly/1_readonly.pro
@@ -3,8 +3,15 @@ TARGET = mv_readonly
TEMPLATE = app
SOURCES += main.cpp \
- modelview.cpp \
mymodel.cpp
-HEADERS += modelview.h \
- mymodel.h
+HEADERS += mymodel.h
+
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/1_readonly
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 1_readonly.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/1_readonly
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/tutorials/modelview/1_readonly/main.cpp b/examples/tutorials/modelview/1_readonly/main.cpp
index fb4726a..2143854 100644..100755
--- a/examples/tutorials/modelview/1_readonly/main.cpp
+++ b/examples/tutorials/modelview/1_readonly/main.cpp
@@ -41,13 +41,16 @@
//! [Quoting ModelView Tutorial]
// main.cpp
#include <QtGui/QApplication>
-#include "modelview.h"
+#include <QtGui/QTableView>
+#include "mymodel.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- ModelView w;
- w.show();
+ QTableView tableView;
+ MyModel myModel(0);
+ tableView.setModel( &myModel );
+ tableView.show();
return a.exec();
}
//! [Quoting ModelView Tutorial]
diff --git a/examples/tutorials/modelview/1_readonly/modelview.cpp b/examples/tutorials/modelview/1_readonly/modelview.cpp
deleted file mode 100644
index 91a97bf..0000000
--- a/examples/tutorials/modelview/1_readonly/modelview.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** 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 examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//! [Quoting ModelView Tutorial]
-// modelview.cpp
-#include <QTableView>
-#include "modelview.h"
-#include "mymodel.h"
-
-ModelView::ModelView(QWidget *parent)
- : QMainWindow(parent)
-{
- tableView = new QTableView(this);
- setCentralWidget(tableView);
- tableView->setModel(new MyModel(this));
-}
-//! [Quoting ModelView Tutorial]
diff --git a/examples/tutorials/modelview/1_readonly/modelview.h b/examples/tutorials/modelview/1_readonly/modelview.h
deleted file mode 100644
index cc14d90..0000000
--- a/examples/tutorials/modelview/1_readonly/modelview.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** 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 examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MODELVIEW_H
-#define MODELVIEW_H
-
-//! [Quoting ModelView Tutorial]
-// modelview.h
-#include <QtGui/QMainWindow>
-
-QT_FORWARD_DECLARE_CLASS(QTableView)
-
-class ModelView : public QMainWindow
-{
- Q_OBJECT
-private:
- QTableView *tableView;
-public:
- ModelView(QWidget *parent = 0);
-
-};
-//! [Quoting ModelView Tutorial]
-
-#endif // MODELVIEW_H
diff --git a/examples/tutorials/modelview/1_readonly/mymodel.cpp b/examples/tutorials/modelview/1_readonly/mymodel.cpp
index 394605a..394605a 100644..100755
--- a/examples/tutorials/modelview/1_readonly/mymodel.cpp
+++ b/examples/tutorials/modelview/1_readonly/mymodel.cpp
diff --git a/examples/tutorials/modelview/1_readonly/mymodel.h b/examples/tutorials/modelview/1_readonly/mymodel.h
index 6065f6e..6065f6e 100644..100755
--- a/examples/tutorials/modelview/1_readonly/mymodel.h
+++ b/examples/tutorials/modelview/1_readonly/mymodel.h
diff --git a/examples/tutorials/modelview/2_formatting/2_formatting.pro b/examples/tutorials/modelview/2_formatting/2_formatting.pro
index 7e70d81..c6ad27c 100644..100755
--- a/examples/tutorials/modelview/2_formatting/2_formatting.pro
+++ b/examples/tutorials/modelview/2_formatting/2_formatting.pro
@@ -3,8 +3,14 @@ TARGET = mv_formatting
TEMPLATE = app
SOURCES += main.cpp \
- modelview.cpp \
mymodel.cpp
-HEADERS += modelview.h \
- mymodel.h
+HEADERS += mymodel.h
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/2_formatting
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 2_formatting.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/2_formatting
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/tutorials/modelview/2_formatting/main.cpp b/examples/tutorials/modelview/2_formatting/main.cpp
index 7be212e..2143854 100644..100755
--- a/examples/tutorials/modelview/2_formatting/main.cpp
+++ b/examples/tutorials/modelview/2_formatting/main.cpp
@@ -38,13 +38,19 @@
**
****************************************************************************/
+//! [Quoting ModelView Tutorial]
+// main.cpp
#include <QtGui/QApplication>
-#include "modelview.h"
+#include <QtGui/QTableView>
+#include "mymodel.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- ModelView w;
- w.show();
+ QTableView tableView;
+ MyModel myModel(0);
+ tableView.setModel( &myModel );
+ tableView.show();
return a.exec();
}
+//! [Quoting ModelView Tutorial]
diff --git a/examples/tutorials/modelview/2_formatting/modelview.cpp b/examples/tutorials/modelview/2_formatting/modelview.cpp
deleted file mode 100644
index 9a5ce64..0000000
--- a/examples/tutorials/modelview/2_formatting/modelview.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** 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 examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QTableView>
-#include "modelview.h"
-#include "mymodel.h"
-
-ModelView::ModelView(QWidget *parent)
- : QMainWindow(parent)
-{
- tableView = new QTableView(this);
- setCentralWidget(tableView);
- tableView->setModel(new MyModel(this));
-}
-
diff --git a/examples/tutorials/modelview/2_formatting/modelview.h b/examples/tutorials/modelview/2_formatting/modelview.h
deleted file mode 100644
index b2943ac..0000000
--- a/examples/tutorials/modelview/2_formatting/modelview.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** 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 examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MODELVIEW_H
-#define MODELVIEW_H
-
-#include <QtGui/QMainWindow>
-
-QT_FORWARD_DECLARE_CLASS(QTableView)
-
-class ModelView : public QMainWindow
-{
- Q_OBJECT
-private:
- QTableView *tableView;
-public:
- ModelView(QWidget *parent = 0);
-};
-
-#endif // MODELVIEW_H
diff --git a/examples/tutorials/modelview/2_formatting/mymodel.cpp b/examples/tutorials/modelview/2_formatting/mymodel.cpp
index f7ff504..3e13ff4 100644..100755
--- a/examples/tutorials/modelview/2_formatting/mymodel.cpp
+++ b/examples/tutorials/modelview/2_formatting/mymodel.cpp
@@ -43,8 +43,6 @@
#include "mymodel.h"
#include <QDebug>
-//! [Quoting ModelView Tutorial]
-// mymodel.cpp
MyModel::MyModel(QObject *parent)
:QAbstractTableModel(parent)
{
@@ -60,6 +58,8 @@ int MyModel::columnCount(const QModelIndex & /*parent */) const
return 3;
}
+//! [Quoting ModelView Tutorial]
+// mymodel.cpp
QVariant MyModel::data(const QModelIndex &index, int role) const
{
int row = index.row();
@@ -89,7 +89,7 @@ QVariant MyModel::data(const QModelIndex &index, int role) const
if (row == 1 && col == 2) //change background only for cell(1,2)
{
- QBrush redBackground = QBrush(Qt::red);
+ QBrush redBackground(QColor(Qt::red));
return redBackground;
}
break;
diff --git a/examples/tutorials/modelview/2_formatting/mymodel.h b/examples/tutorials/modelview/2_formatting/mymodel.h
index 4dc405a..4dc405a 100644..100755
--- a/examples/tutorials/modelview/2_formatting/mymodel.h
+++ b/examples/tutorials/modelview/2_formatting/mymodel.h
diff --git a/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro b/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro
index d61ee4c..e977731 100644..100755
--- a/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro
+++ b/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro
@@ -3,8 +3,14 @@ TARGET = mv_changingmodel
TEMPLATE = app
SOURCES += main.cpp \
- modelview.cpp \
mymodel.cpp
-HEADERS += modelview.h \
- mymodel.h
+HEADERS += mymodel.h
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/3_changingmodel
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 3_changingmodel.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/3_changingmodel
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/tutorials/modelview/3_changingmodel/main.cpp b/examples/tutorials/modelview/3_changingmodel/main.cpp
index 7be212e..3b6061a 100644..100755
--- a/examples/tutorials/modelview/3_changingmodel/main.cpp
+++ b/examples/tutorials/modelview/3_changingmodel/main.cpp
@@ -39,12 +39,15 @@
****************************************************************************/
#include <QtGui/QApplication>
-#include "modelview.h"
+#include <QtGui/QTableView>
+#include "mymodel.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- ModelView w;
- w.show();
+ QTableView tableView;
+ MyModel myModel(0);
+ tableView.setModel( &myModel );
+ tableView.show();
return a.exec();
}
diff --git a/examples/tutorials/modelview/3_changingmodel/modelview.cpp b/examples/tutorials/modelview/3_changingmodel/modelview.cpp
deleted file mode 100644
index 9a5ce64..0000000
--- a/examples/tutorials/modelview/3_changingmodel/modelview.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** 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 examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QTableView>
-#include "modelview.h"
-#include "mymodel.h"
-
-ModelView::ModelView(QWidget *parent)
- : QMainWindow(parent)
-{
- tableView = new QTableView(this);
- setCentralWidget(tableView);
- tableView->setModel(new MyModel(this));
-}
-
diff --git a/examples/tutorials/modelview/3_changingmodel/modelview.h b/examples/tutorials/modelview/3_changingmodel/modelview.h
deleted file mode 100644
index b2943ac..0000000
--- a/examples/tutorials/modelview/3_changingmodel/modelview.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** 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 examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MODELVIEW_H
-#define MODELVIEW_H
-
-#include <QtGui/QMainWindow>
-
-QT_FORWARD_DECLARE_CLASS(QTableView)
-
-class ModelView : public QMainWindow
-{
- Q_OBJECT
-private:
- QTableView *tableView;
-public:
- ModelView(QWidget *parent = 0);
-};
-
-#endif // MODELVIEW_H
diff --git a/examples/tutorials/modelview/3_changingmodel/mymodel.cpp b/examples/tutorials/modelview/3_changingmodel/mymodel.cpp
index 42915b0..42915b0 100644..100755
--- a/examples/tutorials/modelview/3_changingmodel/mymodel.cpp
+++ b/examples/tutorials/modelview/3_changingmodel/mymodel.cpp
diff --git a/examples/tutorials/modelview/3_changingmodel/mymodel.h b/examples/tutorials/modelview/3_changingmodel/mymodel.h
index 01ad88d..47b026e 100644..100755
--- a/examples/tutorials/modelview/3_changingmodel/mymodel.h
+++ b/examples/tutorials/modelview/3_changingmodel/mymodel.h
@@ -43,7 +43,7 @@
#include <QAbstractTableModel>
-QT_FORWARD_DECLARE_CLASS(QTimer)
+class QTimer; // forward declaration
class MyModel : public QAbstractTableModel
{
diff --git a/examples/tutorials/modelview/4_headers/4_headers.pro b/examples/tutorials/modelview/4_headers/4_headers.pro
index d6f8d23..f6c60b2 100644..100755
--- a/examples/tutorials/modelview/4_headers/4_headers.pro
+++ b/examples/tutorials/modelview/4_headers/4_headers.pro
@@ -2,9 +2,15 @@ TARGET = mv_headers
TEMPLATE = app
-SOURCES += main.cpp \
- modelview.cpp \
+SOURCES += main.cpp \
mymodel.cpp
-HEADERS += modelview.h \
- mymodel.h
+HEADERS += mymodel.h
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/4_headers
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 4_headers.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/4_headers
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/tutorials/modelview/4_headers/main.cpp b/examples/tutorials/modelview/4_headers/main.cpp
index 7be212e..5f5d05f 100644..100755
--- a/examples/tutorials/modelview/4_headers/main.cpp
+++ b/examples/tutorials/modelview/4_headers/main.cpp
@@ -39,12 +39,15 @@
****************************************************************************/
#include <QtGui/QApplication>
-#include "modelview.h"
+#include <QtGui/QTableView>
+#include "mymodel.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- ModelView w;
- w.show();
+ QTableView tableView;
+ MyModel myModel(0);
+ tableView.setModel( &myModel );
+ tableView.show();
return a.exec();
-}
+} \ No newline at end of file
diff --git a/examples/tutorials/modelview/4_headers/modelview.cpp b/examples/tutorials/modelview/4_headers/modelview.cpp
deleted file mode 100644
index 449dbbc..0000000
--- a/examples/tutorials/modelview/4_headers/modelview.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** 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 examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QTableView>
-#include <QHeaderView>
-#include "modelview.h"
-#include "mymodel.h"
-
-ModelView::ModelView(QWidget *parent)
- : QMainWindow(parent)
-{
- tableView = new QTableView(this);
- setCentralWidget(tableView);
- tableView->setModel(new MyModel(this));
- tableView->verticalHeader()->hide();
-}
-
diff --git a/examples/tutorials/modelview/4_headers/modelview.h b/examples/tutorials/modelview/4_headers/modelview.h
deleted file mode 100644
index 03f99c0..0000000
--- a/examples/tutorials/modelview/4_headers/modelview.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** 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 examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MODELVIEW_H
-#define MODELVIEW_H
-
-#include <QtGui/QMainWindow>
-
-QT_FORWARD_DECLARE_CLASS(QTableView)
-
-class ModelView : public QMainWindow
-{
- Q_OBJECT
-private:
- QTableView *tableView;
-public:
- ModelView(QWidget *parent = 0);
-
-};
-
-#endif // MODELVIEW_H
diff --git a/examples/tutorials/modelview/4_headers/mymodel.cpp b/examples/tutorials/modelview/4_headers/mymodel.cpp
index e6f977d..e6f977d 100644..100755
--- a/examples/tutorials/modelview/4_headers/mymodel.cpp
+++ b/examples/tutorials/modelview/4_headers/mymodel.cpp
diff --git a/examples/tutorials/modelview/4_headers/mymodel.h b/examples/tutorials/modelview/4_headers/mymodel.h
index ada3169..ada3169 100644..100755
--- a/examples/tutorials/modelview/4_headers/mymodel.h
+++ b/examples/tutorials/modelview/4_headers/mymodel.h
diff --git a/examples/tutorials/modelview/5_edit/5_edit.pro b/examples/tutorials/modelview/5_edit/5_edit.pro
index e18c596..2ef343f 100644..100755
--- a/examples/tutorials/modelview/5_edit/5_edit.pro
+++ b/examples/tutorials/modelview/5_edit/5_edit.pro
@@ -3,8 +3,16 @@ TARGET = mv_edit
TEMPLATE = app
SOURCES += main.cpp \
- modelview.cpp \
+ mainwindow.cpp \
mymodel.cpp
-HEADERS += modelview.h \
+HEADERS += mainwindow.h \
mymodel.h
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/5_edit
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 5_edit.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/5_edit
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/tutorials/modelview/5_edit/main.cpp b/examples/tutorials/modelview/5_edit/main.cpp
index 7be212e..59e82ef 100644..100755
--- a/examples/tutorials/modelview/5_edit/main.cpp
+++ b/examples/tutorials/modelview/5_edit/main.cpp
@@ -39,12 +39,12 @@
****************************************************************************/
#include <QtGui/QApplication>
-#include "modelview.h"
+#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- ModelView w;
+ MainWindow w;
w.show();
return a.exec();
}
diff --git a/examples/tutorials/modelview/5_edit/modelview.cpp b/examples/tutorials/modelview/5_edit/mainwindow.cpp
index a6c6ef5..542f3d6 100644..100755
--- a/examples/tutorials/modelview/5_edit/modelview.cpp
+++ b/examples/tutorials/modelview/5_edit/mainwindow.cpp
@@ -39,10 +39,10 @@
****************************************************************************/
#include <QTableView>
-#include "modelview.h"
+#include "mainwindow.h"
#include "mymodel.h"
-ModelView::ModelView(QWidget *parent)
+MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
tableView = new QTableView(this);
@@ -54,7 +54,7 @@ ModelView::ModelView(QWidget *parent)
connect(myModel, SIGNAL(editCompleted(const QString &)), this, SLOT(setWindowTitle(const QString &)));
}
-void ModelView::showWindowTitle(const QString & title)
+void MainWindow::showWindowTitle(const QString & title)
{
setWindowTitle(title);
}
diff --git a/examples/tutorials/modelview/5_edit/modelview.h b/examples/tutorials/modelview/5_edit/mainwindow.h
index 069107b..1d49f47 100644..100755
--- a/examples/tutorials/modelview/5_edit/modelview.h
+++ b/examples/tutorials/modelview/5_edit/mainwindow.h
@@ -38,22 +38,22 @@
**
****************************************************************************/
-#ifndef MODELVIEW_H
-#define MODELVIEW_H
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
#include <QtGui/QMainWindow>
-QT_FORWARD_DECLARE_CLASS(QTableView)
+class QTableView; //forward declaration
-class ModelView : public QMainWindow
+class MainWindow : public QMainWindow
{
Q_OBJECT
private:
QTableView *tableView;
public:
- ModelView(QWidget *parent = 0);
+ MainWindow(QWidget *parent = 0);
public slots:
void showWindowTitle(const QString & title);
};
-#endif // MODELVIEW_H
+#endif // MAINWINDOW_H
diff --git a/examples/tutorials/modelview/5_edit/mymodel.cpp b/examples/tutorials/modelview/5_edit/mymodel.cpp
index 67181ca..e2fd391 100644..100755
--- a/examples/tutorials/modelview/5_edit/mymodel.cpp
+++ b/examples/tutorials/modelview/5_edit/mymodel.cpp
@@ -38,62 +38,64 @@
**
****************************************************************************/
-//! [quoting mymodel_d]
+
#include "mymodel.h"
-const int COLS= 3;
-const int ROWS= 2;
MyModel::MyModel(QObject *parent)
:QAbstractTableModel(parent)
{
- //gridData needs to have 6 element, one for each table cell
- m_gridData << "1/1" << "1/2" << "1/3" << "2/1" << "2/2" << "2/3" ;
}
-//! [quoting mymodel_d]
-//! [quoting mymodel_e]
+//-----------------------------------------------------------------
int MyModel::rowCount(const QModelIndex & /*parent*/) const
{
return ROWS;
}
+//-----------------------------------------------------------------
int MyModel::columnCount(const QModelIndex & /*parent*/) const
{
return COLS;
}
+//-----------------------------------------------------------------
QVariant MyModel::data(const QModelIndex &index, int role) const
{
if (role == Qt::DisplayRole)
{
- return m_gridData[modelIndexToOffset(index)];
+ return m_gridData[index.row()][index.column()];
}
return QVariant();
}
-//! [quoting mymodel_e]
//-----------------------------------------------------------------
-
-//! [quoting mymodel_f]
+//! [quoting mymodel_e]
bool MyModel::setData(const QModelIndex & index, const QVariant & value, int role)
{
if (role == Qt::EditRole)
{
- m_gridData[modelIndexToOffset(index)] = value.toString();
- emit editCompleted(m_gridData.join(" | "));
+ //save value from editor to member m_gridData
+ m_gridData[index.row()][index.column()] = value.toString();
+ //for presentation purposes only: build and emit a joined string
+ QString result;
+ for(int row= 0; row < ROWS; row++)
+ {
+ for(int col= 0; col < COLS; col++)
+ {
+ result += m_gridData[row][col] + " ";
+ }
+ }
+ emit editCompleted( result );
}
return true;
}
+//! [quoting mymodel_e]
+//-----------------------------------------------------------------
+//! [quoting mymodel_f]
Qt::ItemFlags MyModel::flags(const QModelIndex & /*index*/) const
{
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled ;
}
-
-//convert row and column information to array offset
-int MyModel::modelIndexToOffset(const QModelIndex & index) const
-{
- return index.row()*COLS + index.column();
-}
//! [quoting mymodel_f]
diff --git a/examples/tutorials/modelview/5_edit/mymodel.h b/examples/tutorials/modelview/5_edit/mymodel.h
index 0d2a1b8..574808e 100644..100755
--- a/examples/tutorials/modelview/5_edit/mymodel.h
+++ b/examples/tutorials/modelview/5_edit/mymodel.h
@@ -44,7 +44,11 @@
//! [Quoting ModelView Tutorial]
// mymodel.h
#include <QAbstractTableModel>
-#include <QStringList>
+#include <QString>
+
+const int COLS= 3;
+const int ROWS= 2;
+
class MyModel : public QAbstractTableModel
{
@@ -57,8 +61,7 @@ public:
bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
Qt::ItemFlags flags(const QModelIndex & index) const ;
private:
- QStringList m_gridData; //holds text entered into QTableView
- int modelIndexToOffset(const QModelIndex & index) const;
+ QString m_gridData[ROWS][COLS]; //holds text entered into QTableView
signals:
void editCompleted(const QString &);
};
diff --git a/examples/tutorials/modelview/6_treeview/6_treeview.pro b/examples/tutorials/modelview/6_treeview/6_treeview.pro
index 6d078be..e79ef20 100644..100755
--- a/examples/tutorials/modelview/6_treeview/6_treeview.pro
+++ b/examples/tutorials/modelview/6_treeview/6_treeview.pro
@@ -1,5 +1,13 @@
TARGET = mv_tree
TEMPLATE = app
SOURCES += main.cpp \
- modelview.cpp
-HEADERS += modelview.h
+ mainwindow.cpp
+HEADERS += mainwindow.h
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/6_treeview
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 6_treeview.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/6_treeview
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/tutorials/modelview/6_treeview/main.cpp b/examples/tutorials/modelview/6_treeview/main.cpp
index 7be212e..59e82ef 100644..100755
--- a/examples/tutorials/modelview/6_treeview/main.cpp
+++ b/examples/tutorials/modelview/6_treeview/main.cpp
@@ -39,12 +39,12 @@
****************************************************************************/
#include <QtGui/QApplication>
-#include "modelview.h"
+#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- ModelView w;
+ MainWindow w;
w.show();
return a.exec();
}
diff --git a/examples/tutorials/modelview/6_treeview/modelview.cpp b/examples/tutorials/modelview/6_treeview/mainwindow.cpp
index 772dbdd..a105232 100644..100755
--- a/examples/tutorials/modelview/6_treeview/modelview.cpp
+++ b/examples/tutorials/modelview/6_treeview/mainwindow.cpp
@@ -43,40 +43,40 @@
#include <QTreeView>
#include <QStandardItemModel>
#include <QStandardItem>
-#include "modelview.h"
+#include "mainwindow.h"
const int ROWS = 2;
const int COLUMNS = 3;
-ModelView::ModelView(QWidget *parent)
+MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
treeView = new QTreeView(this);
setCentralWidget(treeView);
standardModel = new QStandardItemModel ;
- QList<QStandardItem *> preparedColumn =prepareColumn("first", "second", "third");
+ QList<QStandardItem *> preparedRow =prepareRow("first", "second", "third");
QStandardItem *item = standardModel->invisibleRootItem();
// adding a row to the invisible root item produces a root element
- item->appendRow(preparedColumn);
+ item->appendRow(preparedRow);
- QList<QStandardItem *> secondRow =prepareColumn("111", "222", "333");
+ QList<QStandardItem *> secondRow =prepareRow("111", "222", "333");
// adding a row to an item starts a subtree
- preparedColumn.first()->appendRow(secondRow);
+ preparedRow.first()->appendRow(secondRow);
treeView->setModel(standardModel);
treeView->expandAll();
}
-QList<QStandardItem *> ModelView::prepareColumn(const QString &first,
+QList<QStandardItem *> MainWindow::prepareRow(const QString &first,
const QString &second,
const QString &third)
{
- QList<QStandardItem *> colItems;
- colItems << new QStandardItem(first);
- colItems << new QStandardItem(second);
- colItems << new QStandardItem(third);
- return colItems;
+ QList<QStandardItem *> rowItems;
+ rowItems << new QStandardItem(first);
+ rowItems << new QStandardItem(second);
+ rowItems << new QStandardItem(third);
+ return rowItems;
}
//! [Quoting ModelView Tutorial]
diff --git a/examples/tutorials/modelview/6_treeview/modelview.h b/examples/tutorials/modelview/6_treeview/mainwindow.h
index 55f3470..fb8de79 100644..100755
--- a/examples/tutorials/modelview/6_treeview/modelview.h
+++ b/examples/tutorials/modelview/6_treeview/mainwindow.h
@@ -38,28 +38,27 @@
**
****************************************************************************/
-#ifndef MODELVIEW_H
-#define MODELVIEW_H
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
#include <QtGui/QMainWindow>
-QT_BEGIN_NAMESPACE
class QTreeView; //forward declaration
class QStandardItemModel;
class QStandardItem;
-QT_END_NAMESPACE
-class ModelView : public QMainWindow
+
+class MainWindow : public QMainWindow
{
Q_OBJECT
private:
QTreeView *treeView;
QStandardItemModel *standardModel;
- QList<QStandardItem *> prepareColumn(const QString &first,
- const QString &second,
- const QString &third);
+ QList<QStandardItem *> prepareRow( const QString &first,
+ const QString &second,
+ const QString &third );
public:
- ModelView(QWidget *parent = 0);
+ MainWindow(QWidget *parent = 0);
};
-#endif // MODELVIEW_H
+#endif // MAINWINDOW_H
diff --git a/examples/tutorials/modelview/7_selections/7_selections.pro b/examples/tutorials/modelview/7_selections/7_selections.pro
index 952641c6..6945bf7 100644..100755
--- a/examples/tutorials/modelview/7_selections/7_selections.pro
+++ b/examples/tutorials/modelview/7_selections/7_selections.pro
@@ -1,5 +1,13 @@
TARGET = mv_selections
TEMPLATE = app
SOURCES += main.cpp \
- modelview.cpp
-HEADERS += modelview.h
+ mainwindow.cpp
+HEADERS += mainwindow.h
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/7_selections
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 7_selections.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/7_selections
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/tutorials/modelview/7_selections/main.cpp b/examples/tutorials/modelview/7_selections/main.cpp
index 7be212e..59e82ef 100644..100755
--- a/examples/tutorials/modelview/7_selections/main.cpp
+++ b/examples/tutorials/modelview/7_selections/main.cpp
@@ -39,12 +39,12 @@
****************************************************************************/
#include <QtGui/QApplication>
-#include "modelview.h"
+#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- ModelView w;
+ MainWindow w;
w.show();
return a.exec();
}
diff --git a/examples/tutorials/modelview/7_selections/modelview.cpp b/examples/tutorials/modelview/7_selections/mainwindow.cpp
index 3b373c6..cb09633 100644..100755
--- a/examples/tutorials/modelview/7_selections/modelview.cpp
+++ b/examples/tutorials/modelview/7_selections/mainwindow.cpp
@@ -42,9 +42,9 @@
#include <QTreeView>
#include <QStandardItemModel>
#include <QItemSelectionModel>
-#include "modelview.h"
+#include "mainwindow.h"
-ModelView::ModelView(QWidget *parent)
+MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
treeView = new QTreeView(this);
@@ -87,10 +87,12 @@ ModelView::ModelView(QWidget *parent)
//------------------------------------------------------------------------------------
//! [quoting modelview_b]
-void ModelView::selectionChangedSlot(const QItemSelection & /*newSelection*/, const QItemSelection & /*oldSelection*/)
+void MainWindow::selectionChangedSlot(const QItemSelection & /*newSelection*/, const QItemSelection & /*oldSelection*/)
{
+ //get the text of the selected item
const QModelIndex index = treeView->selectionModel()->currentIndex();
QString selectedText = index.data(Qt::DisplayRole).toString();
+ //find out the hierarchy level of the selected item
int hierarchyLevel=1;
QModelIndex seekRoot = index;
while(seekRoot.parent() != QModelIndex())
diff --git a/examples/tutorials/modelview/7_selections/modelview.h b/examples/tutorials/modelview/7_selections/mainwindow.h
index d20797e..f2defb5 100644..100755
--- a/examples/tutorials/modelview/7_selections/modelview.h
+++ b/examples/tutorials/modelview/7_selections/mainwindow.h
@@ -38,18 +38,17 @@
**
****************************************************************************/
-#ifndef MODELVIEW_H
-#define MODELVIEW_H
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
#include <QtGui/QMainWindow>
-QT_BEGIN_NAMESPACE
class QTreeView; //forward declaration
class QStandardItemModel;
class QItemSelection;
-QT_END_NAMESPACE
-class ModelView : public QMainWindow
+
+class MainWindow : public QMainWindow
{
Q_OBJECT
private:
@@ -58,7 +57,7 @@ private:
private slots:
void selectionChangedSlot(const QItemSelection & newSelection, const QItemSelection & oldSelection);
public:
- ModelView(QWidget *parent = 0);
+ MainWindow(QWidget *parent = 0);
};
-#endif // MODELVIEW_H
+#endif // MAINWINDOW_H
diff --git a/examples/tutorials/modelview/modelview.pro b/examples/tutorials/modelview/modelview.pro
index 7f684ba..50f5c3a 100644..100755
--- a/examples/tutorials/modelview/modelview.pro
+++ b/examples/tutorials/modelview/modelview.pro
@@ -1,5 +1,4 @@
-TEMPLATE = subdirs
-
+TEMPLATE = subdirs
SUBDIRS = 1_readonly \
2_formatting \
3_changingmodel \
@@ -8,3 +7,10 @@ SUBDIRS = 1_readonly \
6_treeview \
7_selections
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS modelview.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/xmlpatterns/filetree/mainwindow.cpp b/examples/xmlpatterns/filetree/mainwindow.cpp
index 5b9b0c3..85348f3 100644
--- a/examples/xmlpatterns/filetree/mainwindow.cpp
+++ b/examples/xmlpatterns/filetree/mainwindow.cpp
@@ -140,7 +140,7 @@ void MainWindow::loadDirectory(const QString &directory)
QXmlFormatter formatter(query, &buffer);
query.evaluateTo(&formatter);
- treeInfo->setText((QString(tr("Model of %1 output as XML.")).arg(directory)));
+ treeInfo->setText(tr("Model of %1 output as XML.").arg(directory));
fileTree->setText(QString::fromLatin1(output.constData()));
evaluateResult();
//! [6]
diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf
index 04b81b0..61cc7d9 100644
--- a/mkspecs/common/symbian/symbian.conf
+++ b/mkspecs/common/symbian/symbian.conf
@@ -117,11 +117,12 @@ QMAKE_GZIP = gzip -9f
QT_ARCH = symbian
+load(qt_config)
+
# These directories must match what configure uses for QT_INSTALL_PLUGINS and QT_INSTALL_IMPORTS
QT_PLUGINS_BASE_DIR = /resource/qt$${QT_LIBINFIX}/plugins
QT_IMPORTS_BASE_DIR = /resource/qt/imports
-load(qt_config)
load(symbian/platform_paths)
# The Symbian^3 PDK does not necessarily contain the required sis files.
diff --git a/mkspecs/features/symbian/symbian_building.prf b/mkspecs/features/symbian/symbian_building.prf
index 374fe21..414b081 100644
--- a/mkspecs/features/symbian/symbian_building.prf
+++ b/mkspecs/features/symbian/symbian_building.prf
@@ -114,14 +114,9 @@ isEmpty(capability): capability = "None"
capability = "--capability=$$capability"
contains(TEMPLATE, lib):!contains(CONFIG, static):!contains(CONFIG, staticlib) {
- !isEmpty(QMAKE_POST_LINK) {
- # No way to honor the '@' :-(
- QMAKE_POST_LINK = $$replace(QMAKE_POST_LINK, "^@", "")
- QMAKE_POST_LINK = && $$QMAKE_POST_LINK
- }
-
contains(CONFIG, plugin):QMAKE_ELF2E32_FLAGS += --definput=plugin_commonu.def
+ !isEmpty(QMAKE_POST_LINK):QMAKE_POST_LINK = $$escape_expand(\\n\\t)$$QMAKE_POST_LINK
QMAKE_POST_LINK = $$QMAKE_MOVE $$symbianDestdir/$${baseTarget}.dll $$symbianDestdir/$${baseTarget}.sym \
&& $$QMAKE_ELF2E32_WRAPPER --version=$$decVersion \
--sid=$$TARGET.SID \
@@ -166,11 +161,7 @@ contains(TEMPLATE, lib):!contains(CONFIG, static):!contains(CONFIG, staticlib) {
}
contains(TEMPLATE, app):!contains(QMAKE_LINK, "^@:.*") {
- !isEmpty(QMAKE_POST_LINK) {
- # No way to honor the '@' :-(
- QMAKE_POST_LINK = $$replace(QMAKE_POST_LINK, "^@", "")
- QMAKE_POST_LINK = && $$QMAKE_POST_LINK
- }
+ !isEmpty(QMAKE_POST_LINK):QMAKE_POST_LINK = $$escape_expand(\\n\\t)$$QMAKE_POST_LINK
QMAKE_POST_LINK = $$QMAKE_MOVE $$symbianDestdir/$${baseTarget} $$symbianDestdir/$${baseTarget}.sym \
&& $$QMAKE_ELF2E32_WRAPPER --version $$decVersion \
--sid=$$TARGET.SID \
diff --git a/mkspecs/features/unix/separate_debug_info.prf b/mkspecs/features/unix/separate_debug_info.prf
index 40d52cb..8843c6d 100644
--- a/mkspecs/features/unix/separate_debug_info.prf
+++ b/mkspecs/features/unix/separate_debug_info.prf
@@ -1,8 +1,9 @@
!separate_debug_info_nocopy:!staticlib:!static:!contains(TEMPLATE, subdirs):!isEmpty(QMAKE_OBJCOPY) {
- QMAKE_SEPARATE_DEBUG_INFO = (test -z \"$(DESTDIR)\" || cd \"$(DESTDIR)\" ; targ=`basename $(TARGET)`; $$QMAKE_OBJCOPY --only-keep-debug \"\$\$targ\" \"\$\$targ.debug\" && $$QMAKE_OBJCOPY --strip-debug \"\$\$targ\" && $$QMAKE_OBJCOPY --add-gnu-debuglink=\"\$\$targ.debug\" \"\$\$targ\" && chmod -x \"\$\$targ.debug\" ) ;
+ QMAKE_SEPARATE_DEBUG_INFO = test -z \"$(DESTDIR)\" || cd \"$(DESTDIR)\" ; targ=`basename $(TARGET)`; $$QMAKE_OBJCOPY --only-keep-debug \"\$\$targ\" \"\$\$targ.debug\" && $$QMAKE_OBJCOPY --strip-debug \"\$\$targ\" && $$QMAKE_OBJCOPY --add-gnu-debuglink=\"\$\$targ.debug\" \"\$\$targ\" && chmod -x \"\$\$targ.debug\"
QMAKE_INSTALL_SEPARATE_DEBUG_INFO = test -z \"$(DESTDIR)\" || cd \"$(DESTDIR)\" ; $(INSTALL_FILE) `basename $(TARGET)`.debug $(INSTALL_ROOT)/\$\$target_path/
+ !isEmpty(QMAKE_POST_LINK):QMAKE_POST_LINK = $$escape_expand(\\n\\t)$$QMAKE_POST_LINK
QMAKE_POST_LINK = $$QMAKE_SEPARATE_DEBUG_INFO $$QMAKE_POST_LINK
silent:QMAKE_POST_LINK = @echo creating $@.debug && $$QMAKE_POST_LINK
diff --git a/mkspecs/features/vxworks.prf b/mkspecs/features/vxworks.prf
index a910c69..e257cd7 100644
--- a/mkspecs/features/vxworks.prf
+++ b/mkspecs/features/vxworks.prf
@@ -22,20 +22,20 @@ isEmpty(VXWORKS_MUNCH_TOOL):VXWORKS_MUNCH_TOOL = $(WIND_BASE)/host/resource/huti
shared|!staticlib:!lib {
*-dcc {
- VXWORKS_MUNCH_CMD = (targ=`basename $(TARGET)`; \
+ VXWORKS_MUNCH_CMD = targ=`basename $(TARGET)`; \
ddump -Ng \"$(TARGET)\" | tclsh $$VXWORKS_MUNCH_TOOL -c $$VXWORKS_ARCH_MUNCH >\"$(OBJECTS_DIR)/\$\${targ}_ctdt.c\" && \
$$QMAKE_CC -c $$QMAKE_CFLAGS \"$(OBJECTS_DIR)/\$\${targ}_ctdt.c\" -o \"$(OBJECTS_DIR)/\$\${targ}_ctdt.o\" && \
$$QMAKE_LINK $$QMAKE_LFLAGS -X -r5 -r4 \"$(OBJECTS_DIR)/\$\${targ}_ctdt.o\" \"$(TARGET)\" -o \"$(TARGET).munched\" && \
mv \"$(TARGET).munched\" \"$(TARGET)\" && \
- chmod +x \"$(TARGET)\")
+ chmod +x \"$(TARGET)\"
}
*-g++ {
- VXWORKS_MUNCH_CMD = (targ=`basename $(TARGET)`; \
+ VXWORKS_MUNCH_CMD = targ=`basename $(TARGET)`; \
nm \"$(DESTDIR)$(TARGET)\" | tclsh $$VXWORKS_MUNCH_TOOL -c $$VXWORKS_ARCH_MUNCH >\"$(OBJECTS_DIR)/\$\${targ}_ctdt.c\" && \
$$QMAKE_CC -c $$QMAKE_CFLAGS -fdollars-in-identifiers \"$(OBJECTS_DIR)/\$\${targ}_ctdt.c\" -o \"$(OBJECTS_DIR)/\$\${targ}_ctdt.o\" && \
$$QMAKE_LINK $$QMAKE_LFLAGS -nostdlib -Wl,-X -T $(WIND_BASE)/target/h/tool/gnu/ldscripts/link.OUT \"$(OBJECTS_DIR)/\$\${targ}_ctdt.o\" \"$(DESTDIR)$(TARGET)\" -o \"$(DESTDIR)$(TARGET).munched\" && \
mv \"$(DESTDIR)$(TARGET).munched\" \"$(DESTDIR)$(TARGET)\" && \
- chmod +x \"$(DESTDIR)$(TARGET)\")
+ chmod +x \"$(DESTDIR)$(TARGET)\"
}
# We need to create a dummy lib.a in case someone links against this lib.
@@ -48,7 +48,8 @@ shared|!staticlib:!lib {
VXWORKS_MUNCH_CMD += (atarg=`basename $(TARGET) .so.$${VERSION}`.a ; touch \"$(DESTDIR)\$\${atarg}\")
}
- QMAKE_POST_LINK = $$VXWORKS_MUNCH_CMD $$QMAKE_POST_LINK
+ !isEmpty(QMAKE_POST_LINK):QMAKE_POST_LINK = $$escape_expand(\\n\\t)$$QMAKE_POST_LINK
+ QMAKE_POST_LINK = $$VXWORKS_MUNCH_CMD$$QMAKE_POST_LINK
silent:QMAKE_POST_LINK = @echo creating $@.$$VXWORKS_MUNCH_EXT && $$QMAKE_POST_LINK
isEmpty(DESTDIR) {
diff --git a/mkspecs/features/win32/embed_manifest_dll.prf b/mkspecs/features/win32/embed_manifest_dll.prf
index 7305c04..e8711da 100644
--- a/mkspecs/features/win32/embed_manifest_dll.prf
+++ b/mkspecs/features/win32/embed_manifest_dll.prf
@@ -6,8 +6,7 @@ isEmpty(MANIFEST_DIR):MANIFEST_DIR = .
NOPATH_TARGET ~= s,\\\\,/,g # Change to single type separators
NOPATH_TARGET ~= s,^(.*/)+,, # Remove all paths
QMAKE_LFLAGS += /MANIFEST $$quote(/MANIFESTFILE:\"$${MANIFEST_DIR}\\$${NOPATH_TARGET}.intermediate.manifest\")
- QMAKE_PREV_POST_LINK = $$QMAKE_POST_LINK
- QMAKE_POST_LINK = $$quote(mt.exe -nologo -manifest \"$$replace(MANIFEST_DIR,/,\\)\\$${NOPATH_TARGET}.intermediate.manifest\" -outputresource:$(DESTDIR_TARGET);2$$escape_expand(\\n\\t))
- QMAKE_POST_LINK += $$QMAKE_PREV_POST_LINK
+ !isEmpty(QMAKE_POST_LINK):QMAKE_POST_LINK = $$escape_expand(\\n\\t)$$QMAKE_POST_LINK
+ QMAKE_POST_LINK = $$quote(mt.exe -nologo -manifest \"$$replace(MANIFEST_DIR,/,\\)\\$${NOPATH_TARGET}.intermediate.manifest\" -outputresource:$(DESTDIR_TARGET);2$$escape_expand(\\n\\t))$$QMAKE_POST_LINK
QMAKE_CLEAN += \"$$replace(MANIFEST_DIR,/,\\)\\$${NOPATH_TARGET}.intermediate.manifest\"
}
diff --git a/mkspecs/features/win32/embed_manifest_exe.prf b/mkspecs/features/win32/embed_manifest_exe.prf
index 5b37a6d..2d1c09b 100644
--- a/mkspecs/features/win32/embed_manifest_exe.prf
+++ b/mkspecs/features/win32/embed_manifest_exe.prf
@@ -6,8 +6,7 @@ if(win32-msvc2005*|win32-msvc2008*|win32-msvc2010*):!equals(TEMPLATE_PREFIX, "vc
NOPATH_TARGET ~= s,\\\\,/,g # Change to single type separators
NOPATH_TARGET ~= s,^(.*/)+,, # Remove all paths
QMAKE_LFLAGS += /MANIFEST $$quote(/MANIFESTFILE:\"$${MANIFEST_DIR}\\$${NOPATH_TARGET}.intermediate.manifest\")
- QMAKE_PREV_POST_LINK = $$QMAKE_POST_LINK
- QMAKE_POST_LINK = $$quote(mt.exe -nologo -manifest \"$$replace(MANIFEST_DIR,/,\\)\\$${NOPATH_TARGET}.intermediate.manifest\" -outputresource:$(DESTDIR_TARGET);1$$escape_expand(\\n\\t))
- QMAKE_POST_LINK += $$QMAKE_PREV_POST_LINK
+ !isEmpty(QMAKE_POST_LINK):QMAKE_POST_LINK = $$escape_expand(\\n\\t)$$QMAKE_POST_LINK
+ QMAKE_POST_LINK = $$quote(mt.exe -nologo -manifest \"$$replace(MANIFEST_DIR,/,\\)\\$${NOPATH_TARGET}.intermediate.manifest\" -outputresource:$(DESTDIR_TARGET);1$$escape_expand(\\n\\t))$$QMAKE_POST_LINK
QMAKE_CLEAN += \"$$replace(MANIFEST_DIR,/,\\)\\$${NOPATH_TARGET}.intermediate.manifest\"
}
diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.cpp b/src/3rdparty/phonon/gstreamer/mediaobject.cpp
index 3e0addc..23a60c0 100644
--- a/src/3rdparty/phonon/gstreamer/mediaobject.cpp
+++ b/src/3rdparty/phonon/gstreamer/mediaobject.cpp
@@ -219,9 +219,9 @@ void MediaObject::noMorePadsAvailable ()
if ( status != GST_INSTALL_PLUGINS_STARTED_OK )
{
if( status == GST_INSTALL_PLUGINS_HELPER_MISSING )
- setError(QString(tr("Missing codec helper script assistant.")), Phonon::FatalError );
+ setError(tr("Missing codec helper script assistant."), Phonon::FatalError );
else
- setError(QString(tr("Plugin codec installation failed for codec: %0"))
+ setError(tr("Plugin codec installation failed for codec: %0")
.arg(m_missingCodecs[0].split("|")[3]), error);
}
m_missingCodecs.clear();
@@ -232,7 +232,7 @@ void MediaObject::noMorePadsAvailable ()
m_hasVideo = false;
emit hasVideoChanged(false);
}
- setError(QString(tr("A required codec is missing. You need to install the following codec(s) to play this content: %0")).arg(codecs), error);
+ setError(tr("A required codec is missing. You need to install the following codec(s) to play this content: %0").arg(codecs), error);
m_missingCodecs.clear();
#endif
}
diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro
index ac0c47c..537cdd3 100644
--- a/src/3rdparty/webkit/WebCore/WebCore.pro
+++ b/src/3rdparty/webkit/WebCore/WebCore.pro
@@ -2857,6 +2857,25 @@ contains(DEFINES, ENABLE_SYMBIAN_DIALOG_PROVIDERS) {
}
}
+!symbian {
+ modfile.files = $$moduleFile
+ modfile.path = $$[QMAKE_MKSPECS]/modules
+
+ INSTALLS += modfile
+} else {
+ # INSTALLS is not implemented in qmake's s60 generators, copy headers manually
+
+ inst_modfile.commands = $$QMAKE_COPY ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
+ inst_modfile.input = moduleFile
+ inst_modfile.output = $$[QMAKE_MKSPECS]/modules
+ inst_modfile.CONFIG = no_clean
+
+ QMAKE_EXTRA_COMPILERS += inst_modfile
+
+ install.depends += compiler_inst_modfile_make_all
+ QMAKE_EXTRA_TARGETS += install
+}
+
include($$PWD/../WebKit/qt/Api/headers.pri)
HEADERS += $$WEBKIT_API_HEADERS
@@ -2873,10 +2892,7 @@ HEADERS += $$WEBKIT_API_HEADERS
!isEmpty(INSTALL_LIBS): target.path = $$INSTALL_LIBS
else: target.path = $$[QT_INSTALL_LIBS]
- modfile.files = $$moduleFile
- modfile.path = $$[QMAKE_MKSPECS]/modules
-
- INSTALLS += target headers modfile
+ INSTALLS += target headers
} else {
# INSTALLS is not implemented in qmake's s60 generators, copy headers manually
inst_headers.commands = $$QMAKE_COPY ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
@@ -2888,15 +2904,7 @@ HEADERS += $$WEBKIT_API_HEADERS
QMAKE_EXTRA_COMPILERS += inst_headers
- inst_modfile.commands = $$inst_headers.commands
- inst_modfile.input = moduleFile
- inst_modfile.output = $$[QMAKE_MKSPECS]/modules
- inst_modfile.CONFIG = no_clean
-
- QMAKE_EXTRA_COMPILERS += inst_modfile
-
- install.depends += compiler_inst_headers_make_all compiler_inst_modfile_make_all
- QMAKE_EXTRA_TARGETS += install
+ install.depends += compiler_inst_headers_make_all
}
win32-*|wince* {
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index 1bad8ed..5cc6ae3 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp
@@ -232,8 +232,12 @@ void QTimerActiveObject::DoCancel()
void QTimerActiveObject::RunL()
{
- int error;
- QT_TRYCATCH_ERROR(error, Run());
+ int error = KErrNone;
+ if (iStatus == KErrNone) {
+ QT_TRYCATCH_ERROR(error, Run());
+ } else {
+ error = iStatus.Int();
+ }
// All Symbian error codes are negative.
if (error < 0) {
CActiveScheduler::Current()->Error(error); // stop and report here, as this timer will be deleted on scope exit
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 63a2a77..b302393 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -1258,6 +1258,7 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) {
d->clearDelayedPress();
d->stealMouse = false;
+ d->pressed = false;
}
return false;
}
diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp
index cd08658..1eb42e4 100644
--- a/src/declarative/qml/parser/qdeclarativejslexer.cpp
+++ b/src/declarative/qml/parser/qdeclarativejslexer.cpp
@@ -677,9 +677,9 @@ int Lexer::lex()
setDone(Other);
} else
state = Start;
- if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
+ if (driver) driver->addComment(startpos+2, tokenLength()-2, startlineno, startcolumn+2);
} else if (current == 0) {
- if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
+ if (driver) driver->addComment(startpos+2, tokenLength()-2, startlineno, startcolumn+2);
setDone(Eof);
}
@@ -689,14 +689,14 @@ int Lexer::lex()
setDone(Bad);
err = UnclosedComment;
errmsg = QCoreApplication::translate("QDeclarativeParser", "Unclosed comment at end of file");
- if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
+ if (driver) driver->addComment(startpos+2, tokenLength()-2, startlineno, startcolumn+2);
} else if (isLineTerminator()) {
shiftWindowsLineBreak();
yylineno++;
} else if (current == '*' && next1 == '/') {
state = Start;
shift(1);
- if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
+ if (driver) driver->addComment(startpos+2, tokenLength()-3, startlineno, startcolumn+2);
}
break;
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 267642d..3c09747 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -332,7 +332,7 @@ void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool f)
stopped - either by setting the \c running property to false, or by calling
the \c stop() method.
- In the following example, the rectangle will spin indefinately.
+ In the following example, the rectangle will spin indefinitely.
\code
Rectangle {
diff --git a/src/gui/inputmethod/qcoefepinputcontext_p.h b/src/gui/inputmethod/qcoefepinputcontext_p.h
index d5243c3..2fd6d16 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_p.h
+++ b/src/gui/inputmethod/qcoefepinputcontext_p.h
@@ -66,10 +66,10 @@
QT_BEGIN_NAMESPACE
-class QCoeFepInputContext : public QInputContext,
- public MCoeFepAwareTextEditor,
- public MCoeFepAwareTextEditor_Extension1,
- public MObjectProvider
+class Q_AUTOTEST_EXPORT QCoeFepInputContext : public QInputContext,
+ public MCoeFepAwareTextEditor,
+ public MCoeFepAwareTextEditor_Extension1,
+ public MObjectProvider
{
Q_OBJECT
@@ -151,9 +151,10 @@ private:
int m_inlinePosition;
MFepInlineTextFormatRetriever *m_formatRetriever;
MFepPointerEventHandlerDuringInlineEdit *m_pointerHandler;
- int m_cursorPos;
QBasicTimer m_tempPreeditStringTimeout;
bool m_hasTempPreeditString;
+
+ friend class tst_QInputContext;
};
QT_END_NAMESPACE
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
index c4d60a5..add3d17 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
@@ -79,7 +79,6 @@ QCoeFepInputContext::QCoeFepInputContext(QObject *parent)
m_inlinePosition(0),
m_formatRetriever(0),
m_pointerHandler(0),
- m_cursorPos(0),
m_hasTempPreeditString(false)
{
m_fepState->SetObjectProvider(this);
@@ -237,11 +236,17 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event)
break;
}
+ QString widgetText = focusWidget()->inputMethodQuery(Qt::ImSurroundingText).toString();
+ int maxLength = focusWidget()->inputMethodQuery(Qt::ImMaximumTextLength).toInt();
+ if (!keyEvent->text().isEmpty() && widgetText.size() + m_preeditString.size() >= maxLength) {
+ // Don't send key events with string content if the widget is "full".
+ return true;
+ }
+
if (keyEvent->type() == QEvent::KeyPress
&& focusWidget()->inputMethodHints() & Qt::ImhHiddenText
&& !keyEvent->text().isEmpty()) {
// Send some temporary preedit text in order to make text visible for a moment.
- m_cursorPos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt();
m_preeditString = keyEvent->text();
QList<QInputMethodEvent::Attribute> attributes;
QInputMethodEvent imEvent(m_preeditString, attributes);
@@ -297,10 +302,6 @@ void QCoeFepInputContext::commitTemporaryPreeditString()
return;
commitCurrentString(false);
-
- //update cursor position, now this pre-edit text has been committed.
- //this prevents next keypress overwriting it (QTBUG-11673)
- m_cursorPos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt();
}
void QCoeFepInputContext::mouseHandler( int x, QMouseEvent *event)
@@ -596,8 +597,6 @@ void QCoeFepInputContext::StartFepInlineEditL(const TDesC& aInitialInlineText,
commitTemporaryPreeditString();
- m_cursorPos = w->inputMethodQuery(Qt::ImCursorPosition).toInt();
-
QList<QInputMethodEvent::Attribute> attributes;
m_cursorVisibility = aCursorVisibility ? 1 : 0;
@@ -612,9 +611,10 @@ void QCoeFepInputContext::StartFepInlineEditL(const TDesC& aInitialInlineText,
// Let's remove the selected text if aInitialInlineText is empty and there is selected text
if (m_preeditString.isEmpty()) {
int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt();
- int replacementLength = qAbs(m_cursorPos-anchor);
+ int cursorPos = w->inputMethodQuery(Qt::ImCursorPosition).toInt();
+ int replacementLength = qAbs(cursorPos-anchor);
if (replacementLength > 0) {
- int replacementStart = m_cursorPos < anchor ? 0 : -replacementLength;
+ int replacementStart = cursorPos < anchor ? 0 : -replacementLength;
QList<QInputMethodEvent::Attribute> clearSelectionAttributes;
QInputMethodEvent clearSelectionEvent(QLatin1String(""), clearSelectionAttributes);
clearSelectionEvent.setCommitString(QLatin1String(""), replacementStart, replacementLength);
@@ -647,8 +647,13 @@ void QCoeFepInputContext::UpdateFepInlineTextL(const TDesC& aNewInlineText,
m_inlinePosition,
m_cursorVisibility,
QVariant()));
- m_preeditString = qt_TDesC2QString(aNewInlineText);
- QInputMethodEvent event(m_preeditString, attributes);
+ QString newPreeditString = qt_TDesC2QString(aNewInlineText);
+ QInputMethodEvent event(newPreeditString, attributes);
+ if (newPreeditString.isEmpty() && m_preeditString.isEmpty()) {
+ // In Symbian world this means "erase last character".
+ event.setCommitString("", -1, 1);
+ }
+ m_preeditString = newPreeditString;
sendEvent(event);
}
@@ -820,23 +825,13 @@ void QCoeFepInputContext::commitCurrentString(bool cancelFepTransaction)
{
int longPress = 0;
- if (m_preeditString.size() == 0) {
- QWidget *w = focusWidget();
- if (!cancelFepTransaction && w) {
- // We must replace the last character only if the input box has already accepted one
- if (w->inputMethodQuery(Qt::ImCursorPosition).toInt() != m_cursorPos)
- longPress = 1;
- }
- }
-
QList<QInputMethodEvent::Attribute> attributes;
QInputMethodEvent event(QLatin1String(""), attributes);
- event.setCommitString(m_preeditString, 0-longPress, longPress);
+ event.setCommitString(m_preeditString, 0, 0);
m_preeditString.clear();
sendEvent(event);
m_hasTempPreeditString = false;
- longPress = 0;
if (cancelFepTransaction) {
CCoeFep* fep = CCoeEnv::Static()->Fep();
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index e197dc5..4ed4ba3 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -1242,17 +1242,28 @@ void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */)
S60->setStatusPaneAndButtonGroupVisibility(statusPaneVisibility, buttonGroupVisibility);
#endif
} else if (QApplication::activeWindow() == qwidget->window()) {
- if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog() || S60->menuBeingConstructed) {
- QWidget *fw = QApplication::focusWidget();
- if (fw) {
- QFocusEvent event(QEvent::FocusOut, Qt::PopupFocusReason);
- QCoreApplication::sendEvent(fw, &event);
- }
- m_symbianPopupIsOpen = true;
- return;
+ bool focusedControlFound = false;
+ WId winId = 0;
+ for (QWidget *w = qwidget->parentWidget(); w && (winId = w->internalWinId()); w = w->parentWidget()) {
+ if (winId->IsFocused() && winId->IsVisible()) {
+ focusedControlFound = true;
+ break;
+ } else if (w->isWindow())
+ break;
}
+ if (!focusedControlFound) {
+ if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog() || S60->menuBeingConstructed) {
+ QWidget *fw = QApplication::focusWidget();
+ if (fw) {
+ QFocusEvent event(QEvent::FocusOut, Qt::PopupFocusReason);
+ QCoreApplication::sendEvent(fw, &event);
+ }
+ m_symbianPopupIsOpen = true;
+ return;
+ }
- QApplication::setActiveWindow(0);
+ QApplication::setActiveWindow(0);
+ }
}
// else { We don't touch the active window unless we were explicitly activated or deactivated }
}
diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h
index eb1aa18..7fd2baa 100644
--- a/src/gui/kernel/qt_s60_p.h
+++ b/src/gui/kernel/qt_s60_p.h
@@ -87,7 +87,7 @@ const TInt KInternalStatusPaneChange = 0x50000000;
//this macro exists because EColor16MAP enum value doesn't exist in Symbian OS 9.2
#define Q_SYMBIAN_ECOLOR16MAP TDisplayMode(13)
-class QS60ThreadLocalData
+class Q_AUTOTEST_EXPORT QS60ThreadLocalData
{
public:
QS60ThreadLocalData();
@@ -171,7 +171,7 @@ public:
#endif
};
-QS60Data* qGlobalS60Data();
+Q_AUTOTEST_EXPORT QS60Data* qGlobalS60Data();
#define S60 qGlobalS60Data()
class QAbstractLongTapObserver
diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp
index ada5293..306219d 100644
--- a/src/gui/styles/qcleanlooksstyle.cpp
+++ b/src/gui/styles/qcleanlooksstyle.cpp
@@ -2157,7 +2157,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o
}
if (button->features & QStyleOptionButton::HasMenu)
- ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0);
+ ir = ir.adjusted(0, 0, -proxy()->pixelMetric(PM_MenuButtonIndicator, button, widget), 0);
proxy()->drawItemText(painter, ir, tf, button->palette, (button->state & State_Enabled),
button->text, QPalette::ButtonText);
}
@@ -4014,8 +4014,8 @@ QRect QCleanlooksStyle::subControlRect(ComplexControl control, const QStyleOptio
switch (subControl) {
case SC_SliderHandle: {
if (slider->orientation == Qt::Horizontal) {
- rect.setHeight(pixelMetric(PM_SliderThickness));
- rect.setWidth(pixelMetric(PM_SliderLength));
+ rect.setHeight(proxy()->pixelMetric(PM_SliderThickness));
+ rect.setWidth(proxy()->pixelMetric(PM_SliderLength));
int centerY = slider->rect.center().y() - rect.height() / 2;
if (slider->tickPosition & QSlider::TicksAbove)
centerY += tickSize;
@@ -4023,8 +4023,8 @@ QRect QCleanlooksStyle::subControlRect(ComplexControl control, const QStyleOptio
centerY -= tickSize;
rect.moveTop(centerY);
} else {
- rect.setWidth(pixelMetric(PM_SliderThickness));
- rect.setHeight(pixelMetric(PM_SliderLength));
+ rect.setWidth(proxy()->pixelMetric(PM_SliderThickness));
+ rect.setHeight(proxy()->pixelMetric(PM_SliderLength));
int centerX = slider->rect.center().x() - rect.width() / 2;
if (slider->tickPosition & QSlider::TicksAbove)
centerX += tickSize;
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index e28403b..0ba1bc6 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -2340,16 +2340,20 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
tableView = true;
QS60StylePrivate::SkinElements element;
+ bool themeGraphicDefined = false;
QRect elementRect = option->rect;
//draw item is drawn as pressed, if it already has focus.
if (isPressed && (hasFocus || isSelected)) {
+ themeGraphicDefined = true;
element = tableView ? QS60StylePrivate::SE_TableItemPressed : QS60StylePrivate::SE_ListItemPressed;
} else if (hasFocus || (isSelected && selectionBehavior != QAbstractItemView::SelectItems)) {
element = QS60StylePrivate::SE_ListHighlight;
elementRect = highlightRect;
+ themeGraphicDefined = true;
}
- QS60StylePrivate::drawSkinElement(element, painter, elementRect, flags);
+ if (themeGraphicDefined)
+ QS60StylePrivate::drawSkinElement(element, painter, elementRect, flags);
} else {
QCommonStyle::drawPrimitive(element, option, painter, widget);
}
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index c30091e..119217a 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -2139,8 +2139,11 @@ bool QTextEngine::LayoutData::reallocate(int totalGlyphs)
void **newMem = memory;
newMem = (void **)::realloc(memory_on_stack ? 0 : memory, newAllocated*sizeof(void *));
- Q_CHECK_PTR(newMem);
- if (memory_on_stack && newMem)
+ if (!newMem) {
+ layoutState = LayoutFailed;
+ return false;
+ }
+ if (memory_on_stack)
memcpy(newMem, memory, allocated*sizeof(void *));
memory = newMem;
memory_on_stack = false;
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index 7f0c6c8..69e6791 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -419,7 +419,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event)
int c = m_cursor; // cursor position after insertion of commit string
- if (event->replacementStart() == 0)
+ if (event->replacementStart() <= 0)
c += event->commitString().length() + qMin(-event->replacementStart(), event->replacementLength());
m_cursor += event->replacementStart();
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 837cf66..b35c318 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -201,7 +201,7 @@ static void ensureInitialized()
deleteResource())
\value CustomOperation custom operation (created with
- sendCustomRequest())
+ sendCustomRequest()) \since 4.7
\omitvalue UnknownOperation
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp
index 65014a6..23d7800 100644
--- a/src/network/bearer/qnetworkconfigmanager.cpp
+++ b/src/network/bearer/qnetworkconfigmanager.cpp
@@ -45,12 +45,33 @@
#include "qbearerengine_p.h"
#include <QtCore/qstringlist.h>
+#include <QtCore/qcoreapplication.h>
#ifndef QT_NO_BEARERMANAGEMENT
QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC(QNetworkConfigurationManagerPrivate, connManager);
+#define Q_GLOBAL_STATIC_QAPP_DESTRUCTION(TYPE, NAME) \
+ Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
+ static void NAME##_cleanup() \
+ { \
+ delete this_##NAME.pointer; \
+ this_##NAME.pointer = 0; \
+ this_##NAME.destroyed = true; \
+ } \
+ static TYPE *NAME() \
+ { \
+ if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
+ TYPE *x = new TYPE; \
+ if (!this_##NAME.pointer.testAndSetOrdered(0, x)) \
+ delete x; \
+ else \
+ qAddPostRoutine(NAME##_cleanup); \
+ } \
+ return this_##NAME.pointer; \
+ }
+
+Q_GLOBAL_STATIC_QAPP_DESTRUCTION(QNetworkConfigurationManagerPrivate, connManager);
QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
{
diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp
index d61c686..18cc14e 100644
--- a/src/network/kernel/qauthenticator.cpp
+++ b/src/network/kernel/qauthenticator.cpp
@@ -52,10 +52,13 @@
#include <qstring.h>
#include <qdatetime.h>
+//#define NTLMV1_CLIENT
QT_BEGIN_NAMESPACE
+#ifdef NTLMV1_CLIENT
#include "../../3rdparty/des/des.cpp"
+#endif
static QByteArray qNtlmPhase1();
static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phase2data);
@@ -203,17 +206,29 @@ QString QAuthenticator::user() const
void QAuthenticator::setUser(const QString &user)
{
detach();
-
int separatorPosn = 0;
- separatorPosn = user.indexOf(QLatin1String("\\"));
- if (separatorPosn == -1) {
- //No domain name present
+ switch(d->method) {
+ case QAuthenticatorPrivate::DigestMd5:
+ case QAuthenticatorPrivate::Ntlm:
+ if((separatorPosn = user.indexOf(QLatin1String("\\"))) != -1)
+ {
+ //domain name is present
+ d->realm = user.left(separatorPosn);
+ d->user = user.mid(separatorPosn + 1);
+ } else if((separatorPosn = user.indexOf(QLatin1String("@"))) != -1) {
+ //domain name is present
+ d->realm = user.mid(separatorPosn + 1);
+ d->user = user.left(separatorPosn);
+ } else {
+ d->user = user;
+ d->realm.clear();
+ }
+ break;
+ // For other auth mechanisms, domain name will be part of username
+ default:
d->user = user;
- } else {
- //domain name is present
- d->realm = user.left(separatorPosn);
- d->user = user.mid(separatorPosn+1);
+ break;
}
}
@@ -1178,11 +1193,9 @@ static QByteArray clientChallenge(const QAuthenticatorPrivate *ctx)
}
// caller has to ensure a valid targetInfoBuff
-static bool qExtractServerTime(const QByteArray& targetInfoBuff,
- quint64 *serverTime)
+static QByteArray qExtractServerTime(const QByteArray& targetInfoBuff)
{
- Q_ASSERT(serverTime != 0);
- bool retValue = false;
+ QByteArray timeArray;
QDataStream ds(targetInfoBuff);
ds.setByteOrder(QDataStream::LittleEndian);
@@ -1193,19 +1206,16 @@ static bool qExtractServerTime(const QByteArray& targetInfoBuff,
ds >> avLen;
while(avId != 0) {
if(avId == AVTIMESTAMP) {
- QByteArray timeArray(avLen, 0);
+ timeArray.resize(avLen);
//avLen size of QByteArray is allocated
ds.readRawData(timeArray.data(), avLen);
- bool ok;
- *serverTime = timeArray.toHex().toLongLong(&ok, 16);
- retValue = true;
break;
}
ds.skipRawData(avLen);
ds >> avId;
ds >> avLen;
}
- return retValue;
+ return timeArray;
}
static QByteArray qEncodeNtlmv2Response(const QAuthenticatorPrivate *ctx,
@@ -1228,9 +1238,17 @@ static QByteArray qEncodeNtlmv2Response(const QAuthenticatorPrivate *ctx,
ds.writeRawData(reserved1.constData(), reserved1.size());
quint64 time = 0;
+ QByteArray timeArray;
+
+ if(ch.targetInfo.len)
+ {
+ timeArray = qExtractServerTime(ch.targetInfoBuff);
+ }
//if server sends time, use it instead of current time
- if(!(ch.targetInfo.len && qExtractServerTime(ch.targetInfoBuff, &time))) {
+ if(timeArray.size()) {
+ ds.writeRawData(timeArray.constData(), timeArray.size());
+ } else {
QDateTime currentTime(QDate::currentDate(),
QTime::currentTime(), Qt::UTC);
@@ -1242,8 +1260,8 @@ static QByteArray qEncodeNtlmv2Response(const QAuthenticatorPrivate *ctx,
// represented as 100 nano seconds
time = Q_UINT64_C(time * 10000000);
+ ds << time;
}
- ds << time;
//8 byte client challenge
QByteArray clientCh = clientChallenge(ctx);
diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp
index 32eb61a..19f13c2 100644
--- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp
@@ -48,6 +48,14 @@
#include <stdapis/sys/socket.h>
#include <stdapis/net/if.h>
+#ifdef SNAP_FUNCTIONALITY_AVAILABLE
+#include <cmmanager.h>
+#endif
+
+#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE)
+#include <extendedconnpref.h>
+#endif
+
#ifndef QT_NO_BEARERMANAGEMENT
QT_BEGIN_NAMESPACE
@@ -113,7 +121,7 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl()
#endif
}
-void QNetworkSessionPrivateImpl::configurationStateChanged(TUint32 accessPointId, TUint32 connMonId, QNetworkSession::State newState)
+void QNetworkSessionPrivateImpl::configurationStateChanged(quint32 accessPointId, quint32 connMonId, QNetworkSession::State newState)
{
if (iHandleStateNotificationsFromManager) {
#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG
@@ -170,8 +178,10 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface()
return;
if (iFirstSync) {
- QObject::connect(engine, SIGNAL(configurationStateChanged(TUint32, TUint32, QNetworkSession::State)),
- this, SLOT(configurationStateChanged(TUint32, TUint32, QNetworkSession::State)));
+ QObject::connect(engine,
+ SIGNAL(configurationStateChanged(quint32,quint32,QNetworkSession::State)),
+ this,
+ SLOT(configurationStateChanged(quint32,quint32,QNetworkSession::State)));
// Listen to configuration removals, so that in case the configuration
// this session is based on is removed, session knows to enter Invalid -state.
QObject::connect(engine, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)),
@@ -902,13 +912,13 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia
if (iapId == 0) {
_LIT(KSetting, "IAP\\Id");
iConnection.GetIntSetting(KSetting, iapId);
-#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE)
+#ifdef SNAP_FUNCTIONALITY_AVAILABLE
// Check if this is an Easy WLAN configuration. On Symbian^3 RConnection may report
// the used configuration as 'EasyWLAN' IAP ID if someone has just opened the configuration
// from WLAN Scan dialog, _and_ that connection is still up. We need to find the
// real matching configuration. Function alters the Easy WLAN ID to real IAP ID (only if
// easy WLAN):
- engine->easyWlanTrueIapId(iapId);
+ easyWlanTrueIapId(iapId);
#endif
}
@@ -948,7 +958,7 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia
}
}
} else {
-#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE)
+#ifdef SNAP_FUNCTIONALITY_AVAILABLE
// On Symbian^3 (only, not earlier or Symbian^4) if the SNAP was not reachable, it triggers
// user choice type of activity (EasyWLAN). As a result, a new IAP may be created, and
// hence if was not found yet. Therefore update configurations and see if there is something new.
@@ -1319,7 +1329,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint
}
}
}
-#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE)
+#ifdef SNAP_FUNCTIONALITY_AVAILABLE
// If the retVal is not true here, it means that the status update may apply to an IAP outside of
// SNAP (session is based on SNAP but follows IAP outside of it), which may occur on Symbian^3 EasyWlan.
if (retVal == false && activeConfig.isValid() &&
@@ -1472,6 +1482,64 @@ void QNetworkSessionPrivateImpl::restoreDefaultIf()
setdefaultif(&ifr);
}
+#if defined(SNAP_FUNCTIONALITY_AVAILABLE)
+bool QNetworkSessionPrivateImpl::easyWlanTrueIapId(TUint32 &trueIapId) const
+{
+ RCmManager iCmManager;
+ TRAPD(err, iCmManager.OpenL());
+ if (err != KErrNone)
+ return false;
+
+ // Check if this is easy wlan id in the first place
+ if (trueIapId != iCmManager.EasyWlanIdL()) {
+ iCmManager.Close();
+ return false;
+ }
+
+ iCmManager.Close();
+
+ // Loop through all connections that connection monitor is aware
+ // and check for IAPs based on easy WLAN
+ TRequestStatus status;
+ TUint connectionCount;
+ iConnectionMonitor.GetConnectionCount(connectionCount, status);
+ User::WaitForRequest(status);
+ TUint connectionId;
+ TUint subConnectionCount;
+ TUint apId;
+ if (status.Int() == KErrNone) {
+ for (TUint i = 1; i <= connectionCount; i++) {
+ iConnectionMonitor.GetConnectionInfo(i, connectionId, subConnectionCount);
+ iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount,
+ KIAPId, apId, status);
+ User::WaitForRequest(status);
+ if (apId == trueIapId) {
+ TBuf<50>easyWlanNetworkName;
+ iConnectionMonitor.GetStringAttribute(connectionId, 0, KNetworkName,
+ easyWlanNetworkName, status);
+ User::WaitForRequest(status);
+ if (status.Int() != KErrNone)
+ continue;
+
+ const QString ssid = QString::fromUtf16(easyWlanNetworkName.Ptr(),
+ easyWlanNetworkName.Length());
+
+ QNetworkConfigurationPrivatePointer ptr = engine->configurationFromSsid(ssid);
+ if (ptr) {
+#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG
+ qDebug() << "QNCM easyWlanTrueIapId(), found true IAP ID: "
+ << toSymbianConfig(ptr)->numericIdentifier();
+#endif
+ trueIapId = toSymbianConfig(ptr)->numericIdentifier();
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+#endif
+
ConnectionProgressNotifier::ConnectionProgressNotifier(QNetworkSessionPrivateImpl& owner, RConnection& connection)
: CActive(CActive::EPriorityUserInput), iOwner(owner), iConnection(connection)
{
diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h
index 1b0e968..51f2e70 100644
--- a/src/plugins/bearer/symbian/qnetworksession_impl.h
+++ b/src/plugins/bearer/symbian/qnetworksession_impl.h
@@ -64,9 +64,6 @@
#ifdef SNAP_FUNCTIONALITY_AVAILABLE
#include <comms-infras/cs_mobility_apiext.h>
#endif
-#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE)
- #include <extendedconnpref.h>
-#endif
QT_BEGIN_NAMESPACE
@@ -132,7 +129,8 @@ protected: // From CActive
void DoCancel();
private Q_SLOTS:
- void configurationStateChanged(TUint32 accessPointId, TUint32 connMonId, QNetworkSession::State newState);
+ void configurationStateChanged(quint32 accessPointId, quint32 connMonId,
+ QNetworkSession::State newState);
void configurationRemoved(QNetworkConfigurationPrivatePointer config);
void configurationAdded(QNetworkConfigurationPrivatePointer config);
@@ -148,6 +146,11 @@ private:
QNetworkInterface interface(TUint iapId) const;
#endif
+#if defined(SNAP_FUNCTIONALITY_AVAILABLE)
+ bool easyWlanTrueIapId(TUint32 &trueIapId) const;
+#endif
+
+
private: // data
SymbianEngine *engine;
diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp
index 9593461..2e2b671 100644
--- a/src/plugins/bearer/symbian/symbianengine.cpp
+++ b/src/plugins/bearer/symbian/symbianengine.cpp
@@ -692,7 +692,7 @@ void SymbianEngine::updateActiveAccessPoints()
User::WaitForRequest(status);
QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId));
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident);
-#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE)
+#ifdef SNAP_FUNCTIONALITY_AVAILABLE
if (!ptr) {
// If IAP was not found, check if the update was about EasyWLAN
ptr = configurationFromEasyWlan(apId, connectionId);
@@ -1054,7 +1054,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent)
QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId));
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident);
-#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE)
+#ifdef SNAP_FUNCTIONALITY_AVAILABLE
if (!ptr) {
// Check if status was regarding EasyWLAN
ptr = configurationFromEasyWlan(apId, connectionId);
@@ -1079,7 +1079,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent)
User::WaitForRequest(status);
QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId));
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident);
-#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE)
+#ifdef SNAP_FUNCTIONALITY_AVAILABLE
if (!ptr) {
// Check for EasyWLAN
ptr = configurationFromEasyWlan(apId, connectionId);
@@ -1189,7 +1189,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent)
User::WaitForRequest(status);
QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId));
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident);
-#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE)
+#ifdef SNAP_FUNCTIONALITY_AVAILABLE
if (!ptr) {
// If IAP was not found, check if the update was about EasyWLAN
ptr = configurationFromEasyWlan(apId, connectionId);
@@ -1210,11 +1210,39 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent)
}
}
-#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE)
+/*
+ Returns the network configuration that matches the given SSID.
+*/
+QNetworkConfigurationPrivatePointer SymbianEngine::configurationFromSsid(const QString &ssid)
+{
+ QMutexLocker locker(&mutex);
+
+ // Browser through all items and check their name for match
+ QHash<QString, QNetworkConfigurationPrivatePointer>::ConstIterator i =
+ accessPointConfigurations.constBegin();
+ while (i != accessPointConfigurations.constEnd()) {
+ QNetworkConfigurationPrivatePointer ptr = i.value();
+
+ QMutexLocker configLocker(&ptr->mutex);
+
+ if (ptr->name == ssid) {
+#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG
+ qDebug() << "QNCM EasyWlan uses real SSID: " << ssid;
+#endif
+ return ptr;
+ }
+ ++i;
+ }
+
+ return QNetworkConfigurationPrivatePointer();
+}
+
+#ifdef SNAP_FUNCTIONALITY_AVAILABLE
// Tries to derive configuration from EasyWLAN.
// First checks if the interface brought up was EasyWLAN, then derives the real SSID,
// and looks up configuration based on that one.
-QNetworkConfigurationPrivatePointer SymbianEngine::configurationFromEasyWlan(TUint32 apId, TUint connectionId)
+QNetworkConfigurationPrivatePointer SymbianEngine::configurationFromEasyWlan(TUint32 apId,
+ TUint connectionId)
{
if (apId == iCmManager.EasyWlanIdL()) {
TRequestStatus status;
@@ -1223,11 +1251,12 @@ QNetworkConfigurationPrivatePointer SymbianEngine::configurationFromEasyWlan(TUi
easyWlanNetworkName, status );
User::WaitForRequest(status);
if (status.Int() == KErrNone) {
- QString realSSID = QString::fromUtf16(easyWlanNetworkName.Ptr(), easyWlanNetworkName.Length());
+ const QString realSSID = QString::fromUtf16(easyWlanNetworkName.Ptr(),
+ easyWlanNetworkName.Length());
// Browser through all items and check their name for match
- QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> >::const_iterator i =
- accessPointConfigurations.constBegin();
+ QHash<QString, QNetworkConfigurationPrivatePointer>::ConstIterator i =
+ accessPointConfigurations.constBegin();
while (i != accessPointConfigurations.constEnd()) {
QNetworkConfigurationPrivatePointer ptr = i.value();
@@ -1245,45 +1274,6 @@ QNetworkConfigurationPrivatePointer SymbianEngine::configurationFromEasyWlan(TUi
}
return QNetworkConfigurationPrivatePointer();
}
-
-bool SymbianEngine::easyWlanTrueIapId(TUint32& trueIapId)
-{
- // Check if this is easy wlan id in the first place
- if (trueIapId != iCmManager.EasyWlanIdL())
- return false;
-
- // Loop through all connections that connection monitor is aware
- // and check for IAPs based on easy WLAN
- TRequestStatus status;
- TUint connectionCount;
- iConnectionMonitor.GetConnectionCount(connectionCount, status);
- User::WaitForRequest(status);
- TUint connectionId;
- TUint subConnectionCount;
- TUint apId;
- if (status.Int() == KErrNone) {
- for (TUint i = 1; i <= connectionCount; i++) {
- iConnectionMonitor.GetConnectionInfo(i, connectionId, subConnectionCount);
- iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount,
- KIAPId, apId, status);
- User::WaitForRequest(status);
- if (apId == trueIapId) {
- QNetworkConfigurationPrivatePointer ptr =
- configurationFromEasyWlan(apId, connectionId);
- if (ptr) {
-#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG
- qDebug() << "QNCM easyWlanTrueIapId(), found true IAP ID: "
- << toSymbianConfig(ptr)->numericIdentifier();
-#endif
- trueIapId = toSymbianConfig(ptr)->numericIdentifier();
- return true;
- }
- }
- }
- }
- return false;
-}
-
#endif
// Sessions may use this function to report configuration state changes,
diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h
index 1fe6395..7c1076e 100644
--- a/src/plugins/bearer/symbian/symbianengine.h
+++ b/src/plugins/bearer/symbian/symbianengine.h
@@ -138,10 +138,15 @@ public:
QStringList accessPointConfigurationIdentifiers();
+ QNetworkConfigurationPrivatePointer configurationFromSsid(const QString &ssid);
+
+ // For QNetworkSessionPrivateImpl to indicate about state changes
+ void configurationStateChangeReport(TUint32 accessPointId, QNetworkSession::State newState);
+
Q_SIGNALS:
void onlineStateChanged(bool isOnline);
- void configurationStateChanged(TUint32 accessPointId, TUint32 connMonId,
+ void configurationStateChanged(quint32 accessPointId, quint32 connMonId,
QNetworkSession::State newState);
public Q_SLOTS:
@@ -187,12 +192,9 @@ protected:
private:
// MConnectionMonitorObserver
void EventL(const CConnMonEventBase& aEvent);
- // For QNetworkSessionPrivate to indicate about state changes
- void configurationStateChangeReport(TUint32 accessPointId,
- QNetworkSession::State newState);
-#ifdef OCC_FUNCTIONALITY_AVAILABLE
- QNetworkConfigurationPrivatePointer configurationFromEasyWlan(TUint32 apId, TUint connectionId);
- bool easyWlanTrueIapId(TUint32& trueIapId);
+#ifdef SNAP_FUNCTIONALITY_AVAILABLE
+ QNetworkConfigurationPrivatePointer configurationFromEasyWlan(TUint32 apId,
+ TUint connectionId);
#endif
private: // Data
@@ -212,7 +214,6 @@ private: // Data
friend class QNetworkSessionPrivate;
friend class AccessPointsAvailabilityScanner;
- friend class QNetworkSessionPrivateImpl;
#ifdef SNAP_FUNCTIONALITY_AVAILABLE
RCmManager iCmManager;
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 8347626..07aced4 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -2626,8 +2626,7 @@ QScriptValue QScriptEngine::evaluate(const QString &program, const QString &file
}
/*!
- \internal
- \since 4.6
+ \since 4.7
Evaluates the given \a program and returns the result of the
evaluation.
diff --git a/src/script/api/qscriptprogram.cpp b/src/script/api/qscriptprogram.cpp
index 02beba4..3857b75 100644
--- a/src/script/api/qscriptprogram.cpp
+++ b/src/script/api/qscriptprogram.cpp
@@ -32,9 +32,7 @@
QT_BEGIN_NAMESPACE
/*!
- \internal
-
- \since 4.6
+ \since 4.7
\class QScriptProgram
\brief The QScriptProgram class encapsulates a Qt Script program.
diff --git a/tests/auto/linguist/lupdate/testdata/good/parseqml/main.qml b/tests/auto/linguist/lupdate/testdata/good/parseqml/main.qml
new file mode 100644
index 0000000..172bd65
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parseqml/main.qml
@@ -0,0 +1,97 @@
+import Qt 4.7
+
+QtObject {
+ function translate() {
+ qsTr("One");
+ qsTranslate("FooContext", "Two");
+
+ var greeting_strings = [
+ QT_TR_NOOP("Hello"),
+ QT_TRANSLATE_NOOP("FooContext", "Goodbye")
+ ];
+
+ qsTr("One", "not the same one");
+
+ //: My first comment.
+ qsTr("See comment");
+
+ //: My second comment.
+ qsTranslate("BarContext", "See other comment");
+
+ //: My third comment
+ //: spans two lines.
+ qsTr("The comment explains it all");
+
+ //: My fourth comment
+ //: spans a whopping
+ //: three lines.
+ qsTranslate("BazContext", "It should be clear by now");
+
+ /*: C-style comment. */
+ qsTr("I love C++");
+
+ /*: Another C-style comment. */
+ qsTranslate("FooContext", "I really love C++");
+
+ /*: C-style comment, followed by */
+ /*: another one. */
+ qsTr("Qt is the best");
+
+ /*: Another C-style comment, followed by */
+ /*: yet another one. */
+ qsTranslate("BarContext", "Qt is the very best");
+
+ // This comment doesn't have any effect.
+ qsTr("The comment had no effect");
+
+ // This comment doesn't have any effect either.
+ qsTranslate("BazContext", "The comment had no effect, really");
+
+ /* This C-style comment doesn't have any effect. */
+ qsTr("No comment to your comment");
+
+ /* This C-style comment doesn't have any effect either. */
+ qsTranslate("FooContext", "I refuse to comment on that");
+
+ //= id_foo
+ qsTr("This string has an identifier");
+
+ //= id_bar
+ qsTranslate("BarContext", "This string also has an identifier");
+
+ //~ loc-blank False
+ qsTr("This string has meta-data");
+
+ //~ loc-layout_id foo_dialog
+ qsTranslate("BazContext", "This string also has meta-data");
+
+ // This comment is to be ignored.
+ //: This is a comment for the translator.
+ //= id_baz
+ //~ foo 123
+ //~ magic-stuff This means something special.
+ qsTr("This string has a lot of information");
+
+ // This comment is also to be ignored.
+ //: This is another comment for the translator.
+ //= id_babar
+ //~ foo-bar Important stuff
+ //~ needle-in-haystack Found
+ //~ overflow True
+ qsTranslate("FooContext", "This string has even more information");
+
+ qsTr("This string has disambiguation", "Disambiguation");
+
+ qsTranslate("BarContext", "This string also has disambiguation", "Another disambiguation");
+
+ qsTr("This string contains plurals", "", 10);
+
+ qsTrId("qtn_foo_bar");
+
+ var more_greeting_strings = [ QT_TRID_NOOP("qtn_needle"), QT_TRID_NOOP("qtn_haystack") ];
+
+ //: qsTrId() with comment, meta-data and plurals.
+ //~ well-tested True
+ qsTrId("qtn_bar_baz", 10);
+ }
+}
diff --git a/tests/auto/linguist/lupdate/testdata/good/parseqml/project.pro b/tests/auto/linguist/lupdate/testdata/good/parseqml/project.pro
new file mode 100644
index 0000000..1040e22
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parseqml/project.pro
@@ -0,0 +1,3 @@
+SOURCES += main.qml
+
+TRANSLATIONS = project.ts
diff --git a/tests/auto/linguist/lupdate/testdata/good/parseqml/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parseqml/project.ts.result
new file mode 100644
index 0000000..7dac8cb
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parseqml/project.ts.result
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+ <name></name>
+ <message id="qtn_foo_bar">
+ <location filename="main.qml" line="89"/>
+ <source></source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="qtn_needle">
+ <location filename="main.qml" line="91"/>
+ <source></source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="qtn_haystack">
+ <location filename="main.qml" line="91"/>
+ <source></source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="qtn_bar_baz" numerus="yes">
+ <location filename="main.qml" line="95"/>
+ <source></source>
+ <extracomment>qsTrId() with comment, meta-data and plurals.</extracomment>
+ <translation type="unfinished">
+ <numerusform></numerusform>
+ </translation>
+ <extra-well-tested>True</extra-well-tested>
+ </message>
+</context>
+<context>
+ <name>BarContext</name>
+ <message>
+ <location filename="main.qml" line="19"/>
+ <source>See other comment</source>
+ <extracomment>My second comment.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="42"/>
+ <source>Qt is the very best</source>
+ <extracomment>Another C-style comment, followed by yet another one.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="id_bar">
+ <location filename="main.qml" line="60"/>
+ <source>This string also has an identifier</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="85"/>
+ <source>This string also has disambiguation</source>
+ <comment>Another disambiguation</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>BazContext</name>
+ <message>
+ <location filename="main.qml" line="28"/>
+ <source>It should be clear by now</source>
+ <extracomment>My fourth comment spans a whopping three lines.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="48"/>
+ <source>The comment had no effect, really</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="66"/>
+ <source>This string also has meta-data</source>
+ <translation type="unfinished"></translation>
+ <extra-loc-layout_id>foo_dialog</extra-loc-layout_id>
+ </message>
+</context>
+<context>
+ <name>FooContext</name>
+ <message>
+ <location filename="main.qml" line="6"/>
+ <source>Two</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="10"/>
+ <source>Goodbye</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="34"/>
+ <source>I really love C++</source>
+ <extracomment>Another C-style comment.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="54"/>
+ <source>I refuse to comment on that</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="id_babar">
+ <location filename="main.qml" line="81"/>
+ <source>This string has even more information</source>
+ <extracomment>This is another comment for the translator.</extracomment>
+ <translation type="unfinished"></translation>
+ <extra-needle-in-haystack>Found</extra-needle-in-haystack>
+ <extra-overflow>True</extra-overflow>
+ <extra-foo-bar>Important stuff</extra-foo-bar>
+ </message>
+</context>
+<context>
+ <name>main</name>
+ <message>
+ <location filename="main.qml" line="5"/>
+ <source>One</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="9"/>
+ <source>Hello</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="13"/>
+ <source>One</source>
+ <comment>not the same one</comment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="16"/>
+ <source>See comment</source>
+ <extracomment>My first comment.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="23"/>
+ <source>The comment explains it all</source>
+ <extracomment>My third comment spans two lines.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="31"/>
+ <source>I love C++</source>
+ <extracomment>C-style comment.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="38"/>
+ <source>Qt is the best</source>
+ <extracomment>C-style comment, followed by another one.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="45"/>
+ <source>The comment had no effect</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="51"/>
+ <source>No comment to your comment</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="id_foo">
+ <location filename="main.qml" line="57"/>
+ <source>This string has an identifier</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="63"/>
+ <source>This string has meta-data</source>
+ <translation type="unfinished"></translation>
+ <extra-loc-blank>False</extra-loc-blank>
+ </message>
+ <message id="id_baz">
+ <location filename="main.qml" line="73"/>
+ <source>This string has a lot of information</source>
+ <extracomment>This is a comment for the translator.</extracomment>
+ <translation type="unfinished"></translation>
+ <extra-foo>123</extra-foo>
+ <extra-magic-stuff>This means something special.</extra-magic-stuff>
+ </message>
+ <message>
+ <location filename="main.qml" line="83"/>
+ <source>This string has disambiguation</source>
+ <comment>Disambiguation</comment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message numerus="yes">
+ <location filename="main.qml" line="87"/>
+ <source>This string contains plurals</source>
+ <translation type="unfinished">
+ <numerusform></numerusform>
+ </translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/qinputcontext/qinputcontext.pro b/tests/auto/qinputcontext/qinputcontext.pro
index b3ea8c2..ec6831e 100644
--- a/tests/auto/qinputcontext/qinputcontext.pro
+++ b/tests/auto/qinputcontext/qinputcontext.pro
@@ -1,2 +1,6 @@
load(qttest_p4)
SOURCES += tst_qinputcontext.cpp
+
+symbian {
+ LIBS += -lws32 -lcone
+}
diff --git a/tests/auto/qinputcontext/tst_qinputcontext.cpp b/tests/auto/qinputcontext/tst_qinputcontext.cpp
index 644b463..93813f9 100644
--- a/tests/auto/qinputcontext/tst_qinputcontext.cpp
+++ b/tests/auto/qinputcontext/tst_qinputcontext.cpp
@@ -48,17 +48,26 @@
#include <qlayout.h>
#include <qradiobutton.h>
#include <qwindowsstyle.h>
+#include <qdesktopwidget.h>
+
+#ifdef Q_OS_SYMBIAN
+#include <private/qt_s60_p.h>
+#include <private/qcoefepinputcontext_p.h>
+
+#include <w32std.h>
+#include <coecntrl.h>
+#endif
class tst_QInputContext : public QObject
{
Q_OBJECT
public:
- tst_QInputContext() {}
+ tst_QInputContext() : m_phoneIsQwerty(false) {}
virtual ~tst_QInputContext() {}
public slots:
- void initTestCase() {}
+ void initTestCase();
void cleanupTestCase() {}
void init() {}
void cleanup() {}
@@ -69,8 +78,176 @@ private slots:
void closeSoftwareInputPanel();
void selections();
void focusProxy();
+ void symbianTestCoeFepInputContext_data();
+ void symbianTestCoeFepInputContext();
+
+private:
+ bool m_phoneIsQwerty;
};
+#ifdef Q_OS_SYMBIAN
+class KeyEvent : public TWsEvent
+{
+public:
+ KeyEvent(QWidget *w, TInt type, TInt scanCode, TUint code, TUint modifiers, TInt repeats) {
+ iHandle = w->effectiveWinId()->DrawableWindow()->WindowGroupId();
+ iType = type;
+ SetTimeNow();
+ TKeyEvent *keyEvent = reinterpret_cast<TKeyEvent *>(iEventData);
+ keyEvent->iScanCode = scanCode;
+ keyEvent->iCode = code;
+ keyEvent->iModifiers = modifiers;
+ keyEvent->iRepeats = repeats;
+ }
+};
+
+class FepReplayEvent
+{
+public:
+ enum Type {
+ Pause,
+ Key,
+ CompleteKey
+ };
+
+ FepReplayEvent(int msecsToPause)
+ : m_type(Pause)
+ , m_msecsToPause(msecsToPause)
+ {
+ }
+
+ FepReplayEvent(TInt keyType, TInt scanCode, TUint code, TUint modifiers, TInt repeats)
+ : m_type(Key)
+ , m_keyType(keyType)
+ , m_scanCode(scanCode)
+ , m_code(code)
+ , m_modifiers(modifiers)
+ , m_repeats(repeats)
+ {
+ }
+
+ FepReplayEvent(TInt scanCode, TUint code, TUint modifiers, TInt repeats)
+ : m_type(CompleteKey)
+ , m_scanCode(scanCode)
+ , m_code(code)
+ , m_modifiers(modifiers)
+ , m_repeats(repeats)
+ {
+ }
+
+ void sendEvent(QWidget *w, TInt type, TInt scanCode, TUint code, TUint modifiers, TInt repeats)
+ {
+ KeyEvent event(w, type, scanCode, code, modifiers, repeats);
+ S60->wsSession().SendEventToWindowGroup(w->effectiveWinId()->DrawableWindow()->WindowGroupId(), event);
+ }
+
+ void pause(int msecs)
+ {
+ // Don't use qWait here. The polling nature of that function screws up the test.
+ QTimer timer;
+ QEventLoop loop;
+ QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ timer.setSingleShot(true);
+ timer.start(msecs);
+ loop.exec();
+ }
+
+ // For some reason, the test fails if using processEvents instead of an event loop
+ // with a zero timer to quit it, so use the timer.
+#define KEY_WAIT 0
+
+ void replay(QWidget *w)
+ {
+ if (m_type == Pause) {
+ pause(m_msecsToPause);
+ } else if (m_type == Key) {
+ sendEvent(w, m_keyType, m_scanCode, m_code, m_modifiers, m_repeats);
+ if (m_keyType != EEventKeyDown)
+ // EEventKeyDown events should have no pause before the EEventKey event.
+ pause(KEY_WAIT);
+ } else if (m_type == CompleteKey) {
+ sendEvent(w, EEventKeyDown, m_scanCode, 0, m_modifiers, m_repeats);
+ // EEventKeyDown events should have no pause before the EEventKey event.
+ sendEvent(w, EEventKey, m_scanCode, m_code, m_modifiers, m_repeats);
+ pause(KEY_WAIT);
+ sendEvent(w, EEventKeyUp, m_scanCode, 0, m_modifiers, m_repeats);
+ pause(KEY_WAIT);
+ }
+ }
+
+private:
+ Type m_type;
+ int m_msecsToPause;
+ TInt m_keyType;
+ TInt m_scanCode;
+ TUint m_code;
+ TUint m_modifiers;
+ TInt m_repeats;
+};
+
+Q_DECLARE_METATYPE(QList<FepReplayEvent>)
+Q_DECLARE_METATYPE(Qt::InputMethodHints)
+Q_DECLARE_METATYPE(QLineEdit::EchoMode);
+
+#endif // Q_OS_SYMBIAN
+
+void tst_QInputContext::initTestCase()
+{
+#ifdef Q_OS_SYMBIAN
+ // Sanity test. Checks FEP for:
+ // - T9 mode is default (it will attempt to fix this)
+ // - Language is English (it cannot fix this; bail out if not correct)
+ QWidget w;
+ QLayout *layout = new QVBoxLayout;
+ w.setLayout(layout);
+ QLineEdit *lineedit = new QLineEdit;
+ layout->addWidget(lineedit);
+ lineedit->setFocus();
+#ifdef QT_KEYPAD_NAVIGATION
+ lineedit->setEditFocus(true);
+#endif
+ w.show();
+
+ QDesktopWidget desktop;
+ QRect screenSize = desktop.screenGeometry(&w);
+ if (screenSize.width() > screenSize.height()) {
+ // Crude way of finding out we are running on a qwerty phone.
+ m_phoneIsQwerty = true;
+ return;
+ }
+
+ for (int iterations = 0; iterations < 16; iterations++) {
+ QTest::qWait(500);
+
+ QList<FepReplayEvent> keyEvents;
+
+ keyEvents << FepReplayEvent('9', '9', 0, 0);
+ keyEvents << FepReplayEvent('6', '6', 0, 0);
+ keyEvents << FepReplayEvent('8', '8', 0, 0);
+ keyEvents << FepReplayEvent(EStdKeyRightArrow, EKeyRightArrow, 0, 0);
+
+ foreach(FepReplayEvent event, keyEvents) {
+ event.replay(lineedit);
+ }
+
+ QApplication::processEvents();
+
+ if (lineedit->text().endsWith("you", Qt::CaseInsensitive)) {
+ // Success!
+ return;
+ }
+
+ // Try changing modes.
+ // After 8 iterations, try to press the mode switch twice before typing.
+ for (int c = 0; c <= iterations / 8; c++) {
+ FepReplayEvent(EStdKeyHash, '#', 0, 0).replay(lineedit);
+ }
+ }
+
+ QFAIL("FEP sanity test failed. Either the phone is not set to English, or the test was unable to enable T9");
+#endif
+}
+
void tst_QInputContext::maximumTextLength()
{
QLineEdit le;
@@ -271,7 +448,6 @@ void tst_QInputContext::focusProxy()
QInputContext *gic = qApp->inputContext();
QVERIFY(gic);
- qDebug() << gic->focusWidget() << &proxy;
QCOMPARE(gic->focusWidget(), &proxy);
// then change the focus proxy and check that input context is valid
@@ -285,5 +461,480 @@ void tst_QInputContext::focusProxy()
QCOMPARE(gic->focusWidget(), &proxy);
}
+void tst_QInputContext::symbianTestCoeFepInputContext_data()
+{
+#ifdef Q_OS_SYMBIAN
+ QTest::addColumn<bool> ("inputMethodEnabled");
+ QTest::addColumn<Qt::InputMethodHints> ("inputMethodHints");
+ QTest::addColumn<int> ("maxLength"); // Zero for no limit
+ QTest::addColumn<QLineEdit::EchoMode> ("echoMode");
+ QTest::addColumn<QList<FepReplayEvent> > ("keyEvents");
+ QTest::addColumn<QString> ("finalString");
+ QTest::addColumn<QString> ("preeditString");
+ QList<FepReplayEvent> events;
+
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ events << FepReplayEvent('5', '5', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('6', '6', 0, 0);
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ events << FepReplayEvent('1', '1', 0, 0);
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ events << FepReplayEvent('2', '2', 0, 0);
+ events << FepReplayEvent('1', '1', 0, 0);
+ QTest::newRow("Numbers (no FEP)")
+ << false
+ << Qt::InputMethodHints(Qt::ImhNone)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("521")
+ << QString("");
+ QTest::newRow("Numbers and password mode (no FEP)")
+ << false
+ << Qt::InputMethodHints(Qt::ImhNone)
+ << 0
+ << QLineEdit::Password
+ << events
+ << QString("521")
+ << QString("");
+ QTest::newRow("Numbers")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("521")
+ << QString("");
+ QTest::newRow("Numbers max length (no FEP)")
+ << false
+ << Qt::InputMethodHints(Qt::ImhNone)
+ << 2
+ << QLineEdit::Normal
+ << events
+ << QString("21")
+ << QString("");
+ QTest::newRow("Numbers max length")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 2
+ << QLineEdit::Normal
+ << events
+ << QString("21")
+ << QString("");
+ events.clear();
+
+ events << FepReplayEvent(EEventKeyDown, '5', 0, 0, 0);
+ events << FepReplayEvent(EEventKey, '5', '5', 0, 0);
+ events << FepReplayEvent(EEventKey, '5', '5', 0, 1);
+ events << FepReplayEvent(EEventKey, '5', '5', 0, 1);
+ events << FepReplayEvent(EEventKeyUp, '5', 0, 0, 0);
+ QTest::newRow("Numbers and autorepeat (no FEP)")
+ << false
+ << Qt::InputMethodHints(Qt::ImhNone)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("555")
+ << QString("");
+ events.clear();
+
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ events << FepReplayEvent('2', '2', 0, 0);
+ events << FepReplayEvent('3', '3', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('5', '5', 0, 0);
+ events << FepReplayEvent('5', '5', 0, 0);
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ QTest::newRow("Multitap")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("Adh")
+ << QString("");
+ QTest::newRow("Multitap with no auto uppercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("adh")
+ << QString("");
+ QTest::newRow("Multitap with uppercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferUppercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("ADH")
+ << QString("");
+ QTest::newRow("Multitap with lowercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("adh")
+ << QString("");
+ QTest::newRow("Multitap with forced uppercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhUppercaseOnly)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("ADH")
+ << QString("");
+ QTest::newRow("Multitap with forced lowercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhLowercaseOnly)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("adh")
+ << QString("");
+ events.clear();
+
+ events << FepReplayEvent(EStdKeyHash, '#', 0, 0);
+ events << FepReplayEvent('2', '2', 0, 0);
+ events << FepReplayEvent('2', '2', 0, 0);
+ events << FepReplayEvent('3', '3', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('5', '5', 0, 0);
+ events << FepReplayEvent('5', '5', 0, 0);
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ QTest::newRow("Multitap with mode switch")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("bdh")
+ << QString("");
+ events.clear();
+
+ events << FepReplayEvent('7', '7', 0, 0);
+ events << FepReplayEvent('7', '7', 0, 0);
+ events << FepReplayEvent('8', '8', 0, 0);
+ events << FepReplayEvent('9', '9', 0, 0);
+ events << FepReplayEvent('9', '9', 0, 0);
+ QTest::newRow("Multitap with unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("Qt")
+ << QString("x");
+ events << FepReplayEvent(2000);
+ QTest::newRow("Multitap with committed text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("Qtx")
+ << QString("");
+ events.clear();
+
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ // Simulate holding down hash key.
+ events << FepReplayEvent(EEventKeyDown, EStdKeyHash, 0, 0, 0);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 0);
+ events << FepReplayEvent(500);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 1);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 1);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 1);
+ events << FepReplayEvent(EEventKeyUp, EStdKeyHash, 0, 0, 0);
+ events << FepReplayEvent('7', '7', 0, 0);
+ events << FepReplayEvent('7', '7', 0, 0);
+ events << FepReplayEvent('8', '8', 0, 0);
+ // QTBUG-9867: Switch back as well to make sure we don't get extra symbols
+ events << FepReplayEvent(EEventKeyDown, EStdKeyHash, 0, 0, 0);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 0);
+ events << FepReplayEvent(500);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 1);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 1);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 1);
+ events << FepReplayEvent(EEventKeyUp, EStdKeyHash, 0, 0, 0);
+ events << FepReplayEvent('9', '9', 0, 0);
+ events << FepReplayEvent('6', '6', 0, 0);
+ events << FepReplayEvent('8', '8', 0, 0);
+ events << FepReplayEvent(2000);
+ events << FepReplayEvent(EStdKeyDevice3, EKeyDevice3, 0, 0); // Select key
+ QTest::newRow("Multitap and numbers")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("H778wmt")
+ << QString("");
+ QTest::newRow("T9 and numbers")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("hi778you")
+ << QString("");
+ events.clear();
+
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent(EStdKeyDevice3, EKeyDevice3, 0, 0); // Select key
+ QTest::newRow("T9")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("hi")
+ << QString("");
+ QTest::newRow("T9 with uppercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferUppercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("HI")
+ << QString("");
+ QTest::newRow("T9 with forced lowercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhLowercaseOnly)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("hi")
+ << QString("");
+ QTest::newRow("T9 with forced uppercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhUppercaseOnly)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("HI")
+ << QString("");
+ QTest::newRow("T9 with maxlength")
+ << true
+ << Qt::InputMethodHints(Qt::ImhLowercaseOnly)
+ << 1
+ << QLineEdit::Normal
+ << events
+ << QString("i")
+ << QString("");
+ events.clear();
+
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent(EStdKeyLeftArrow, EKeyLeftArrow, 0, 0);
+ events << FepReplayEvent(EStdKeyLeftArrow, EKeyLeftArrow, 0, 0);
+ events << FepReplayEvent('9', '9', 0, 0);
+ events << FepReplayEvent('6', '6', 0, 0);
+ events << FepReplayEvent('8', '8', 0, 0);
+ events << FepReplayEvent('0', '0', 0, 0);
+ events << FepReplayEvent(EStdKeyRightArrow, EKeyRightArrow, 0, 0);
+ events << FepReplayEvent(EStdKeyRightArrow, EKeyRightArrow, 0, 0);
+ events << FepReplayEvent('8', '8', 0, 0);
+ events << FepReplayEvent('8', '8', 0, 0);
+ QTest::newRow("T9 with movement and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("you hi")
+ << QString("tv");
+ QTest::newRow("T9 with movement, password and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Password
+ << events
+ << QString("wmt h")
+ << QString("u");
+ QTest::newRow("T9 with movement, maxlength, password and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 2
+ << QLineEdit::Password
+ << events
+ << QString("wh")
+ << QString("");
+ QTest::newRow("T9 with movement, maxlength and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 2
+ << QLineEdit::Normal
+ << events
+ << QString("hi")
+ << QString("");
+ QTest::newRow("Multitap with movement and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("wmt h")
+ << QString("u");
+ QTest::newRow("Multitap with movement, maxlength and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase)
+ << 2
+ << QLineEdit::Normal
+ << events
+ << QString("wh")
+ << QString("");
+ QTest::newRow("Numbers with movement")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("96804488")
+ << QString("");
+ QTest::newRow("Numbers with movement and maxlength")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 2
+ << QLineEdit::Normal
+ << events
+ << QString("44")
+ << QString("");
+ QTest::newRow("Numbers with movement, password and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 0
+ << QLineEdit::Password
+ << events
+ << QString("9680448")
+ << QString("8");
+ QTest::newRow("Numbers with movement, maxlength, password and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 2
+ << QLineEdit::Password
+ << events
+ << QString("44")
+ << QString("");
+ events << FepReplayEvent(EStdKeyRightArrow, EKeyRightArrow, 0, 0);
+ QTest::newRow("T9 with movement")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("you htvi")
+ << QString("");
+ QTest::newRow("T9 with movement and password")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Password
+ << events
+ << QString("wmt hu")
+ << QString("");
+ QTest::newRow("T9 with movement, maxlength and password")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 2
+ << QLineEdit::Password
+ << events
+ << QString("wh")
+ << QString("");
+ QTest::newRow("Multitap with movement")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("wmt hu")
+ << QString("");
+ QTest::newRow("Multitap with movement and maxlength")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase)
+ << 2
+ << QLineEdit::Normal
+ << events
+ << QString("wh")
+ << QString("");
+ QTest::newRow("Numbers with movement and password")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 0
+ << QLineEdit::Password
+ << events
+ << QString("96804488")
+ << QString("");
+ QTest::newRow("Numbers with movement, maxlength and password")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 2
+ << QLineEdit::Password
+ << events
+ << QString("44")
+ << QString("");
+ events.clear();
+#endif
+}
+
+void tst_QInputContext::symbianTestCoeFepInputContext()
+{
+#ifndef Q_OS_SYMBIAN
+ QSKIP("This is a Symbian-only test", SkipAll);
+#else
+ QCoeFepInputContext *ic = qobject_cast<QCoeFepInputContext *>(qApp->inputContext());
+ if (!ic) {
+ QSKIP("coefep is not the active input context; skipping test", SkipAll);
+ }
+
+ QFETCH(bool, inputMethodEnabled);
+ QFETCH(Qt::InputMethodHints, inputMethodHints);
+ QFETCH(int, maxLength);
+ QFETCH(QLineEdit::EchoMode, echoMode);
+ QFETCH(QList<FepReplayEvent>, keyEvents);
+ QFETCH(QString, finalString);
+ QFETCH(QString, preeditString);
+
+ if (inputMethodEnabled && m_phoneIsQwerty) {
+ QSKIP("Skipping advanced input method tests on QWERTY phones", SkipSingle);
+ }
+
+ QWidget w;
+ QLayout *layout = new QVBoxLayout;
+ w.setLayout(layout);
+ QLineEdit *lineedit = new QLineEdit;
+ layout->addWidget(lineedit);
+ lineedit->setFocus();
+#ifdef QT_KEYPAD_NAVIGATION
+ lineedit->setEditFocus(true);
+#endif
+ w.show();
+
+ lineedit->setAttribute(Qt::WA_InputMethodEnabled, inputMethodEnabled);
+ lineedit->setInputMethodHints(inputMethodHints);
+ if (maxLength > 0)
+ lineedit->setMaxLength(maxLength);
+ lineedit->setEchoMode(echoMode);
+
+ QTest::qWait(200);
+
+ foreach(FepReplayEvent event, keyEvents) {
+ event.replay(lineedit);
+ }
+
+ QApplication::processEvents();
+
+ QCOMPARE(lineedit->text(), finalString);
+ QCOMPARE(ic->m_preeditString, preeditString);
+#endif
+}
+
QTEST_MAIN(tst_QInputContext)
#include "tst_qinputcontext.moc"
diff --git a/tests/auto/qkeysequence/tst_qkeysequence.cpp b/tests/auto/qkeysequence/tst_qkeysequence.cpp
index 1faae6a..60f022f 100644
--- a/tests/auto/qkeysequence/tst_qkeysequence.cpp
+++ b/tests/auto/qkeysequence/tst_qkeysequence.cpp
@@ -532,20 +532,20 @@ void tst_QKeySequence::translated_data()
QTest::addColumn<QString>("transKey");
QTest::addColumn<QString>("compKey");
- QTest::newRow("Shift++") << QString(tr("Shift++")) << QString("Umschalt++");
- QTest::newRow("Ctrl++") << QString(tr("Ctrl++")) << QString("Strg++");
- QTest::newRow("Alt++") << QString(tr("Alt++")) << QString("Alt++");
- QTest::newRow("Meta++") << QString(tr("Meta++")) << QString("Meta++");
-
- QTest::newRow("Shift+,, Shift++") << QString(tr("Shift+,, Shift++")) << QString("Umschalt+,, Umschalt++");
- QTest::newRow("Shift+,, Ctrl++") << QString(tr("Shift+,, Ctrl++")) << QString("Umschalt+,, Strg++");
- QTest::newRow("Shift+,, Alt++") << QString(tr("Shift+,, Alt++")) << QString("Umschalt+,, Alt++");
- QTest::newRow("Shift+,, Meta++") << QString(tr("Shift+,, Meta++")) << QString("Umschalt+,, Meta++");
-
- QTest::newRow("Ctrl+,, Shift++") << QString(tr("Ctrl+,, Shift++")) << QString("Strg+,, Umschalt++");
- QTest::newRow("Ctrl+,, Ctrl++") << QString(tr("Ctrl+,, Ctrl++")) << QString("Strg+,, Strg++");
- QTest::newRow("Ctrl+,, Alt++") << QString(tr("Ctrl+,, Alt++")) << QString("Strg+,, Alt++");
- QTest::newRow("Ctrl+,, Meta++") << QString(tr("Ctrl+,, Meta++")) << QString("Strg+,, Meta++");
+ QTest::newRow("Shift++") << tr("Shift++") << QString("Umschalt++");
+ QTest::newRow("Ctrl++") << tr("Ctrl++") << QString("Strg++");
+ QTest::newRow("Alt++") << tr("Alt++") << QString("Alt++");
+ QTest::newRow("Meta++") << tr("Meta++") << QString("Meta++");
+
+ QTest::newRow("Shift+,, Shift++") << tr("Shift+,, Shift++") << QString("Umschalt+,, Umschalt++");
+ QTest::newRow("Shift+,, Ctrl++") << tr("Shift+,, Ctrl++") << QString("Umschalt+,, Strg++");
+ QTest::newRow("Shift+,, Alt++") << tr("Shift+,, Alt++") << QString("Umschalt+,, Alt++");
+ QTest::newRow("Shift+,, Meta++") << tr("Shift+,, Meta++") << QString("Umschalt+,, Meta++");
+
+ QTest::newRow("Ctrl+,, Shift++") << tr("Ctrl+,, Shift++") << QString("Strg+,, Umschalt++");
+ QTest::newRow("Ctrl+,, Ctrl++") << tr("Ctrl+,, Ctrl++") << QString("Strg+,, Strg++");
+ QTest::newRow("Ctrl+,, Alt++") << tr("Ctrl+,, Alt++") << QString("Strg+,, Alt++");
+ QTest::newRow("Ctrl+,, Meta++") << tr("Ctrl+,, Meta++") << QString("Strg+,, Meta++");
qApp->removeTranslator(ourTranslator);
qApp->removeTranslator(qtTranslator);
diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp
index 8d213ed..b651187 100644
--- a/tests/auto/qtimer/tst_qtimer.cpp
+++ b/tests/auto/qtimer/tst_qtimer.cpp
@@ -161,8 +161,9 @@ void tst_QTimer::singleShotTimeout()
QCOMPARE(helper.count, 1);
}
-#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86)
-// Increase wait as emulator startup can cause unexpected delays
+#if defined(Q_OS_SYMBIAN)
+// Increase wait as emulator startup can cause unexpected delays, and
+// on hardware there are sometimes spikes right after process startup.
#define TIMEOUT_TIMEOUT 2000
#else
#define TIMEOUT_TIMEOUT 200
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index ef05b91..098ce3c 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -402,6 +402,8 @@ private slots:
#endif // QT_MAC_USE_COCOA
#endif
+ void nativeChildFocus();
+
private:
bool ensureScreenSize(int width, int height);
QWidget *testWidget;
@@ -10531,5 +10533,28 @@ void tst_QWidget::taskQTBUG_11373()
#endif // QT_MAC_USE_COCOA
#endif
+void tst_QWidget::nativeChildFocus()
+{
+ QWidget w;
+ QLayout *layout = new QVBoxLayout;
+ w.setLayout(layout);
+ QLineEdit *p1 = new QLineEdit;
+ QLineEdit *p2 = new QLineEdit;
+ layout->addWidget(p1);
+ layout->addWidget(p2);
+ p1->setObjectName("p1");
+ p2->setObjectName("p2");
+ w.show();
+ w.activateWindow();
+ p1->setFocus();
+ p1->setAttribute(Qt::WA_NativeWindow);
+ p2->setAttribute(Qt::WA_NativeWindow);
+ QApplication::processEvents();
+ QTest::qWaitForWindowShown(&w);
+
+ QCOMPARE(QApplication::activeWindow(), &w);
+ QCOMPARE(QApplication::focusWidget(), p1);
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"
diff --git a/tools/activeqt/testcon/changeproperties.cpp b/tools/activeqt/testcon/changeproperties.cpp
index e2ad601..00a2cab 100644
--- a/tools/activeqt/testcon/changeproperties.cpp
+++ b/tools/activeqt/testcon/changeproperties.cpp
@@ -111,10 +111,10 @@ void ChangeProperties::on_buttonSet_clicked()
value = qVariantFromValue(col);
} else {
QMessageBox::warning(this, tr("Can't parse input"),
- QString(tr("Failed to create a color from %1\n"
+ tr("Failed to create a color from %1\n"
"The string has to be a valid color name (e.g. 'red')\n"
"or a RGB triple of format '#rrggbb'."
- ).arg(editValue->text())));
+ ).arg(editValue->text()));
}
}
break;
@@ -125,10 +125,10 @@ void ChangeProperties::on_buttonSet_clicked()
value = qVariantFromValue(fnt);
} else {
QMessageBox::warning(this, tr("Can't parse input"),
- (tr("Failed to create a font from %1\n"
+ tr("Failed to create a font from %1\n"
"The string has to have a format family,<point size> or\n"
"family,pointsize,stylehint,weight,italic,underline,strikeout,fixedpitch,rawmode."
- ).arg(editValue->text())));
+ ).arg(editValue->text()));
}
}
break;
diff --git a/tools/assistant/tools/assistant/bookmarkitem.cpp b/tools/assistant/tools/assistant/bookmarkitem.cpp
index 2e81e38..2c92113 100644
--- a/tools/assistant/tools/assistant/bookmarkitem.cpp
+++ b/tools/assistant/tools/assistant/bookmarkitem.cpp
@@ -41,6 +41,7 @@
#include "bookmarkitem.h"
+#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
QT_BEGIN_NAMESPACE
@@ -147,7 +148,9 @@ BookmarkItem::insertChildren(bool isFolder, int position, int count)
for (int row = 0; row < count; ++row) {
m_children.insert(position, new BookmarkItem(DataVector()
- << QObject::tr(isFolder ? "New Folder" : "Untitled")
+ << (isFolder
+ ? QCoreApplication::translate("BookmarkItem", "New Folder")
+ : QCoreApplication::translate("BookmarkItem", "Untitled"))
<< (isFolder ? "Folder" : "about:blank") << false, this));
}
diff --git a/tools/assistant/tools/assistant/cmdlineparser.cpp b/tools/assistant/tools/assistant/cmdlineparser.cpp
index b6c0beb..1cf2915 100644
--- a/tools/assistant/tools/assistant/cmdlineparser.cpp
+++ b/tools/assistant/tools/assistant/cmdlineparser.cpp
@@ -48,7 +48,7 @@
QT_BEGIN_NAMESPACE
-const QString CmdLineParser::m_helpMessage = QLatin1String(
+static const char helpMessage[] = QT_TRANSLATE_NOOP("CmdLineParser",
"Usage: assistant [Options]\n\n"
"-collectionFile file Uses the specified collection\n"
" file instead of the default one\n"
@@ -138,10 +138,10 @@ CmdLineParser::Result CmdLineParser::parse()
}
if (!m_error.isEmpty()) {
- showMessage(m_error + QLatin1String("\n\n\n") + m_helpMessage, true);
+ showMessage(m_error + QLatin1String("\n\n\n") + tr(helpMessage), true);
return Error;
} else if (showHelp) {
- showMessage(m_helpMessage, false);
+ showMessage(tr(helpMessage), false);
return Help;
}
return Ok;
diff --git a/tools/assistant/tools/assistant/cmdlineparser.h b/tools/assistant/tools/assistant/cmdlineparser.h
index 5573081..db66494 100644
--- a/tools/assistant/tools/assistant/cmdlineparser.h
+++ b/tools/assistant/tools/assistant/cmdlineparser.h
@@ -93,7 +93,6 @@ private:
QStringList m_arguments;
int m_pos;
- static const QString m_helpMessage;
QString m_collectionFile;
QString m_cloneFile;
QString m_helpFile;
diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp
index 913e342..65a58c0 100644
--- a/tools/assistant/tools/assistant/mainwindow.cpp
+++ b/tools/assistant/tools/assistant/mainwindow.cpp
@@ -831,7 +831,7 @@ void MainWindow::showAboutDialog()
aboutDia.setWindowTitle(aboutDia.documentTitle());
} else {
QByteArray resources;
- aboutDia.setText(QString::fromLatin1("<center>"
+ aboutDia.setText(tr("<center>"
"<h3>%1</h3>"
"<p>Version %2</p></center>"
"<p>Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).</p>")
diff --git a/tools/assistant/tools/qcollectiongenerator/main.cpp b/tools/assistant/tools/qcollectiongenerator/main.cpp
index b3f6bd9..46e301c 100644
--- a/tools/assistant/tools/qcollectiongenerator/main.cpp
+++ b/tools/assistant/tools/qcollectiongenerator/main.cpp
@@ -49,15 +49,21 @@
#include <QtCore/QDir>
#include <QtCore/QMap>
#include <QtCore/QFileInfo>
-#include <QtCore/QCoreApplication>
#include <QtCore/QDateTime>
#include <QtCore/QBuffer>
+#include <QtCore/QTranslator>
+#include <QtCore/QLocale>
+#include <QtCore/QLibraryInfo>
#include <QtHelp/QHelpEngineCore>
#include <QtXml/QXmlStreamReader>
QT_USE_NAMESPACE
+class QCG {
+ Q_DECLARE_TR_FUNCTIONS(QCollectionGenerator)
+};
+
class CollectionConfigReader : public QXmlStreamReader
{
public:
@@ -123,9 +129,7 @@ private:
void CollectionConfigReader::raiseErrorWithLine()
{
- raiseError(QCoreApplication::translate("QCollectionGenerator",
- "Unknown token at line %1.")
- .arg(lineNumber()));
+ raiseError(QCG::tr("Unknown token at line %1.").arg(lineNumber()));
}
void CollectionConfigReader::readData(const QByteArray &contents)
@@ -144,9 +148,8 @@ void CollectionConfigReader::readData(const QByteArray &contents)
&& attributes().value(QLatin1String("version")) == QLatin1String("1.0"))
readConfig();
else
- raiseError(QCoreApplication::translate("QCollectionGenerator",
- "Unknown token at line %1. "
- "Expected \"QtHelpCollectionProject\"!")
+ raiseError(QCG::tr("Unknown token at line %1. "
+ "Expected \"QtHelpCollectionProject\".")
.arg(lineNumber()));
}
}
@@ -169,7 +172,7 @@ void CollectionConfigReader::readConfig()
}
}
if (!ok && !hasError())
- raiseError(QLatin1String("Missing end tags."));
+ raiseError(QCG::tr("Missing end tags."));
}
void CollectionConfigReader::readAssistantSettings()
@@ -311,7 +314,7 @@ void CollectionConfigReader::readFiles()
}
}
if (input.isEmpty() || output.isEmpty()) {
- raiseError(QLatin1String("Missing input or output file for help file generation!"));
+ raiseError(QCG::tr("Missing input or output file for help file generation."));
return;
}
m_filesToGenerate.insert(input, output);
@@ -350,6 +353,20 @@ int main(int argc, char *argv[])
bool showHelp = false;
bool showVersion = false;
+ QCoreApplication app(argc, argv);
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QTranslator qt_helpTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("assistant_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)
+ && qt_helpTranslator.load(QLatin1String("qt_help_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ app.installTranslator(&qt_helpTranslator);
+ }
+
for (int i=1; i<argc; ++i) {
arg = QString::fromLocal8Bit(argv[i]);
if (arg == QLatin1String("-o")) {
@@ -357,8 +374,7 @@ int main(int argc, char *argv[])
QFileInfo fi(QString::fromLocal8Bit(argv[i]));
collectionFile = fi.absoluteFilePath();
} else {
- error = QCoreApplication::translate("QCollectionGenerator",
- "Missing output file name!");
+ error = QCG::tr("Missing output file name.");
}
} else if (arg == QLatin1String("-h")) {
showHelp = true;
@@ -372,16 +388,15 @@ int main(int argc, char *argv[])
}
if (showVersion) {
- fprintf(stdout, "Qt Collection Generator version 1.0 (Qt %s)\n",
- QT_VERSION_STR);
+ fputs(qPrintable(QCG::tr("Qt Collection Generator version 1.0 (Qt %1)\n")
+ .arg(QT_VERSION_STR)), stdout);
return 0;
}
if (configFile.isEmpty() && !showHelp)
- error = QCoreApplication::translate("QCollectionGenerator",
- "Missing collection config file!");
+ error = QCG::tr("Missing collection config file.");
- QString help = QCoreApplication::translate("QCollectionGenerator", "\nUsage:\n\n"
+ QString help = QCG::tr("\nUsage:\n\n"
"qcollectiongenerator <collection-config-file> [options]\n\n"
" -o <collection-file> Generates a collection file\n"
" called <collection-file>. If\n"
@@ -391,7 +406,7 @@ int main(int argc, char *argv[])
" qcollectiongenerator.\n\n");
if (showHelp) {
- fprintf(stdout, "%s", qPrintable(help));
+ fputs(qPrintable(help), stdout);
return 0;
}else if (!error.isEmpty()) {
fprintf(stderr, "%s\n\n%s", qPrintable(error), qPrintable(help));
@@ -400,7 +415,7 @@ int main(int argc, char *argv[])
QFile file(configFile);
if (!file.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Could not open %s!\n", qPrintable(configFile));
+ fputs(qPrintable(QCG::tr("Could not open %1.\n").arg(configFile)), stderr);
return -1;
}
@@ -410,19 +425,18 @@ int main(int argc, char *argv[])
+ fi.baseName() + QLatin1String(".qhc");
}
- QCoreApplication app(argc, argv);
-
- fprintf(stdout, "Reading collection config file...\n");
+ fputs(qPrintable(QCG::tr("Reading collection config file...\n")), stdout);
CollectionConfigReader config;
config.readData(file.readAll());
if (config.hasError()) {
- fprintf(stderr, "Collection config file error: %s\n", qPrintable(config.errorString()));
+ fputs(qPrintable(QCG::tr("Collection config file error: %1\n")
+ .arg(config.errorString())), stderr);
return -1;
}
QMap<QString, QString>::const_iterator it = config.filesToGenerate().constBegin();
while (it != config.filesToGenerate().constEnd()) {
- fprintf(stdout, "Generating help for %s...\n", qPrintable(it.key()));
+ fputs(qPrintable(QCG::tr("Generating help for %1...\n").arg(it.key())), stdout);
QHelpProjectData helpData;
if (!helpData.readData(absoluteFileName(basePath, it.key()))) {
fprintf(stderr, "%s\n", qPrintable(helpData.errorMessage()));
@@ -437,12 +451,13 @@ int main(int argc, char *argv[])
++it;
}
- fprintf(stdout, "Creating collection file...\n");
+ fputs(qPrintable(QCG::tr("Creating collection file...\n")), stdout);
QFileInfo colFi(collectionFile);
if (colFi.exists()) {
if (!colFi.dir().remove(colFi.fileName())) {
- fprintf(stderr, "The file %s cannot be overwritten!\n", qPrintable(collectionFile));
+ fputs(qPrintable(QCG::tr("The file %1 cannot be overwritten.\n")
+ .arg(collectionFile)), stderr);
return -1;
}
}
@@ -500,7 +515,7 @@ int main(int argc, char *argv[])
if (!config.applicationIcon().isEmpty()) {
QFile icon(absoluteFileName(basePath, config.applicationIcon()));
if (!icon.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Cannot open %s!\n", qPrintable(icon.fileName()));
+ fputs(qPrintable(QCG::tr("Cannot open %1.\n").arg(icon.fileName())), stderr);
return -1;
}
CollectionConfiguration::setApplicationIcon(helpEngine, icon.readAll());
@@ -521,7 +536,7 @@ int main(int argc, char *argv[])
if (!config.aboutIcon().isEmpty()) {
QFile icon(absoluteFileName(basePath, config.aboutIcon()));
if (!icon.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Cannot open %s!\n", qPrintable(icon.fileName()));
+ fputs(qPrintable(QCG::tr("Cannot open %1.\n").arg(icon.fileName())), stderr);
return -1;
}
CollectionConfiguration::setAboutIcon(helpEngine, icon.readAll());
@@ -543,7 +558,7 @@ int main(int argc, char *argv[])
QFileInfo fi(absoluteFileName(basePath, it.value()));
QFile f(fi.absoluteFilePath());
if (!f.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Cannot open %s!\n", qPrintable(f.fileName()));
+ fputs(qPrintable(QCG::tr("Cannot open %1.\n").arg(f.fileName())), stderr);
return -1;
}
QByteArray data = f.readAll();
@@ -565,8 +580,8 @@ int main(int argc, char *argv[])
if (!imgData.contains(src))
imgData.insert(src, img.readAll());
} else {
- fprintf(stderr, "Cannot open referenced image file %s!\n",
- qPrintable(img.fileName()));
+ fputs(qPrintable(QCG::tr("Cannot open referenced image file %1.\n")
+ .arg(img.fileName())), stderr);
}
}
}
diff --git a/tools/assistant/tools/qhelpconverter/filterpage.cpp b/tools/assistant/tools/qhelpconverter/filterpage.cpp
index 7f86980..c782943 100644
--- a/tools/assistant/tools/qhelpconverter/filterpage.cpp
+++ b/tools/assistant/tools/qhelpconverter/filterpage.cpp
@@ -127,7 +127,7 @@ void FilterPage::addFilter()
{
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.customFilterWidget);
item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsSelectable);
- item->setText(0, QLatin1String("unfiltered"));
+ item->setText(0, tr("unfiltered", "list of available documentation"));
item->setText(1, QLatin1String(""));
m_ui.customFilterWidget->editItem(item, 0);
m_ui.removeButton->setDisabled(false);
diff --git a/tools/assistant/tools/qhelpconverter/finishpage.cpp b/tools/assistant/tools/qhelpconverter/finishpage.cpp
index 0be3a1b..f0228e3 100644
--- a/tools/assistant/tools/qhelpconverter/finishpage.cpp
+++ b/tools/assistant/tools/qhelpconverter/finishpage.cpp
@@ -52,8 +52,7 @@ FinishPage::FinishPage(QWidget *parent)
: QWizardPage(parent)
{
setTitle(tr("Converting File"));
- setSubTitle(QLatin1String("Creating the new Qt help files from the "
- "old .adp file."));
+ setSubTitle(tr("Creating the new Qt help files from the old ADP file."));
setFinalPage(true);
QVBoxLayout *layout = new QVBoxLayout(this);
diff --git a/tools/assistant/tools/qhelpconverter/helpwindow.cpp b/tools/assistant/tools/qhelpconverter/helpwindow.cpp
index 9cc1a85..2c7e030 100644
--- a/tools/assistant/tools/qhelpconverter/helpwindow.cpp
+++ b/tools/assistant/tools/qhelpconverter/helpwindow.cpp
@@ -64,7 +64,7 @@ HelpWindow::HelpWindow(QWidget *parent)
layout = new QVBoxLayout(frame);
layout->setMargin(2);
- QLabel *l = new QLabel(QLatin1String("<center><b>Wizard Assistant</b></center>"));
+ QLabel *l = new QLabel(tr("<center><b>Wizard Assistant</b></center>"));
layout->addWidget(l);
m_textEdit = new QTextEdit();
m_textEdit->setFrameStyle(QFrame::NoFrame);
diff --git a/tools/assistant/tools/qhelpconverter/main.cpp b/tools/assistant/tools/qhelpconverter/main.cpp
index 4b1d815..5ee624d 100644
--- a/tools/assistant/tools/qhelpconverter/main.cpp
+++ b/tools/assistant/tools/qhelpconverter/main.cpp
@@ -40,6 +40,9 @@
****************************************************************************/
#include <QtCore/QFileInfo>
+#include <QtCore/QTranslator>
+#include <QtCore/QLocale>
+#include <QtCore/QLibraryInfo>
#include <QtGui/QApplication>
#include "conversionwizard.h"
@@ -49,6 +52,18 @@ QT_USE_NAMESPACE
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QTranslator qt_helpTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("assistant_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)
+ && qt_helpTranslator.load(QLatin1String("qt_help_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ app.installTranslator(&qt_helpTranslator);
+ }
ConversionWizard w;
if (argc == 2) {
diff --git a/tools/assistant/tools/qhelpgenerator/main.cpp b/tools/assistant/tools/qhelpgenerator/main.cpp
index a309f42..637786c 100644
--- a/tools/assistant/tools/qhelpgenerator/main.cpp
+++ b/tools/assistant/tools/qhelpgenerator/main.cpp
@@ -44,11 +44,18 @@
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QCoreApplication>
+#include <QtCore/QTranslator>
+#include <QtCore/QLocale>
+#include <QtCore/QLibraryInfo>
#include <private/qhelpprojectdata_p.h>
QT_USE_NAMESPACE
+class QHG {
+ Q_DECLARE_TR_FUNCTIONS(QHelpGenerator)
+};
+
int main(int argc, char *argv[])
{
QString error;
@@ -60,6 +67,20 @@ int main(int argc, char *argv[])
bool showVersion = false;
bool checkLinks = false;
+ QCoreApplication app(argc, argv);
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QTranslator qt_helpTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("assistant_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)
+ && qt_helpTranslator.load(QLatin1String("qt_help_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ app.installTranslator(&qt_helpTranslator);
+ }
+
for (int i = 1; i < argc; ++i) {
arg = QString::fromLocal8Bit(argv[i]);
if (arg == QLatin1String("-o")) {
@@ -67,8 +88,7 @@ int main(int argc, char *argv[])
QFileInfo fi(QString::fromLocal8Bit(argv[i]));
compressedFile = fi.absoluteFilePath();
} else {
- error = QCoreApplication::translate("QHelpGenerator",
- "Missing output file name!");
+ error = QHG::tr("Missing output file name.");
}
} else if (arg == QLatin1String("-v")) {
showVersion = true;
@@ -84,16 +104,15 @@ int main(int argc, char *argv[])
}
if (showVersion) {
- fprintf(stdout, "Qt Help Generator version 1.0 (Qt %s)\n",
- QT_VERSION_STR);
+ fputs(qPrintable(QHG::tr("Qt Help Generator version 1.0 (Qt %1)\n")
+ .arg(QT_VERSION_STR)), stdout);
return 0;
}
if (projectFile.isEmpty() && !showHelp)
- error = QCoreApplication::translate("QHelpGenerator",
- "Missing Qt help project file!");
+ error = QHG::tr("Missing Qt help project file.");
- QString help = QCoreApplication::translate("QHelpGenerator", "\nUsage:\n\n"
+ QString help = QHG::tr("\nUsage:\n\n"
"qhelpgenerator <help-project-file> [options]\n\n"
" -o <compressed-file> Generates a Qt compressed help\n"
" file called <compressed-file>.\n"
@@ -105,7 +124,7 @@ int main(int argc, char *argv[])
" qhelpgenerator.\n\n");
if (showHelp) {
- fprintf(stdout, "%s", qPrintable(help));
+ fputs(qPrintable(help), stdout);
return 0;
}else if (!error.isEmpty()) {
fprintf(stderr, "%s\n\n%s", qPrintable(error), qPrintable(help));
@@ -114,7 +133,7 @@ int main(int argc, char *argv[])
QFile file(projectFile);
if (!file.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Could not open %s!\n", qPrintable(projectFile));
+ fputs(qPrintable(QHG::tr("Could not open %1.\n").arg(projectFile)), stderr);
return -1;
}
@@ -130,8 +149,8 @@ int main(int argc, char *argv[])
QDir parentDir = fi.dir();
if (!parentDir.exists()) {
if (!parentDir.mkpath(QLatin1String("."))) {
- fprintf(stderr, "Could not create output directory: %s\n",
- qPrintable(parentDir.path()));
+ fputs(qPrintable(QHG::tr("Could not create output directory: %1\n")
+ .arg(parentDir.path())), stderr);
}
}
}
@@ -142,7 +161,6 @@ int main(int argc, char *argv[])
return -1;
}
- QCoreApplication app(argc, argv);
HelpGenerator generator;
bool success = true;
if (checkLinks)
diff --git a/tools/assistant/tools/shared/helpgenerator.cpp b/tools/assistant/tools/shared/helpgenerator.cpp
index 12008e6..4812bc5 100644
--- a/tools/assistant/tools/shared/helpgenerator.cpp
+++ b/tools/assistant/tools/shared/helpgenerator.cpp
@@ -73,12 +73,12 @@ QString HelpGenerator::error() const
void HelpGenerator::printStatus(const QString &msg)
{
- fprintf(stdout, "%s\n", qPrintable(msg));
+ puts(qPrintable(msg));
}
void HelpGenerator::printWarning(const QString &msg)
{
- fprintf(stdout, "Warning: %s\n", qPrintable(msg));
+ puts(qPrintable(tr("Warning: %1").arg(msg)));
}
QT_END_NAMESPACE
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index e1d7275..09da581 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -3612,7 +3612,10 @@ void Configure::buildHostTools()
// generate Makefile
QStringList args;
args << QDir::toNativeSeparators(buildPath + "/bin/qmake");
- args << "-spec" << dictionary["QMAKESPEC"] << "-r";
+ // override .qmake.cache because we are not cross-building these.
+ // we need a full path so that a build with -prefix will still find it.
+ args << "-spec" << QDir::toNativeSeparators(buildPath + "/mkspecs/" + dictionary["QMAKESPEC"]);
+ args << "-r";
args << "-o" << QDir::toNativeSeparators(toolBuildPath + "/Makefile");
QDir().mkpath(toolBuildPath);
@@ -3750,8 +3753,7 @@ void Configure::generateMakefiles()
printf("Generating Makefiles...\n");
generate = false; // Now Makefiles will be done
}
- args << "-spec";
- args << spec;
+ // don't pass -spec - .qmake.cache has it already
args << "-r";
args << (sourcePath + "/projects.pro");
args << "-o";
diff --git a/tools/designer/src/components/propertyeditor/defs.cpp b/tools/designer/src/components/propertyeditor/defs.cpp
deleted file mode 100644
index 54dec74..0000000
--- a/tools/designer/src/components/propertyeditor/defs.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** 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 Qt Designer 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$
-**
-****************************************************************************/
-
-#include "defs.h"
-
-QT_BEGIN_NAMESPACE
-
-namespace qdesigner_internal {
-
-int size_type_to_int( QSizePolicy::Policy t )
-{
- if ( t == QSizePolicy::Fixed )
- return 0;
- if ( t == QSizePolicy::Minimum )
- return 1;
- if ( t == QSizePolicy::Maximum )
- return 2;
- if ( t == QSizePolicy::Preferred )
- return 3;
- if ( t == QSizePolicy::MinimumExpanding )
- return 4;
- if ( t == QSizePolicy::Expanding )
- return 5;
- if ( t == QSizePolicy::Ignored )
- return 6;
- return 0;
-}
-
-QString size_type_to_string( QSizePolicy::Policy t )
-{
- if ( t == QSizePolicy::Fixed )
- return QString::fromUtf8("Fixed");
- if ( t == QSizePolicy::Minimum )
- return QString::fromUtf8("Minimum");
- if ( t == QSizePolicy::Maximum )
- return QString::fromUtf8("Maximum");
- if ( t == QSizePolicy::Preferred )
- return QString::fromUtf8("Preferred");
- if ( t == QSizePolicy::MinimumExpanding )
- return QString::fromUtf8("MinimumExpanding");
- if ( t == QSizePolicy::Expanding )
- return QString::fromUtf8("Expanding");
- if ( t == QSizePolicy::Ignored )
- return QString::fromUtf8("Ignored");
- return QString();
-}
-
-QSizePolicy::Policy int_to_size_type( int i )
-{
- if ( i == 0 )
- return QSizePolicy::Fixed;
- if ( i == 1 )
- return QSizePolicy::Minimum;
- if ( i == 2 )
- return QSizePolicy::Maximum;
- if ( i == 3 )
- return QSizePolicy::Preferred;
- if ( i == 4 )
- return QSizePolicy::MinimumExpanding;
- if ( i == 5 )
- return QSizePolicy::Expanding;
- if ( i == 6 )
- return QSizePolicy::Ignored;
- return QSizePolicy::Preferred;
-}
-
-} // namespace qdesigner_internal
-
-QT_END_NAMESPACE
diff --git a/tools/designer/src/components/propertyeditor/propertyeditor.pri b/tools/designer/src/components/propertyeditor/propertyeditor.pri
index 7d2e7cb..bb1afdb 100644
--- a/tools/designer/src/components/propertyeditor/propertyeditor.pri
+++ b/tools/designer/src/components/propertyeditor/propertyeditor.pri
@@ -45,10 +45,8 @@ SOURCES += $$PWD/propertyeditor.cpp \
HEADERS += \
$$PWD/propertyeditor_global.h \
- $$PWD/defs.h \
$$PWD/qlonglongvalidator.h
-SOURCES += $$PWD/defs.cpp \
- $$PWD/qlonglongvalidator.cpp
+SOURCES += $$PWD/qlonglongvalidator.cpp
RESOURCES += $$PWD/propertyeditor.qrc
diff --git a/tools/designer/src/components/taskmenu/itemlisteditor.cpp b/tools/designer/src/components/taskmenu/itemlisteditor.cpp
index 94959fd..9f8e9c8 100644
--- a/tools/designer/src/components/taskmenu/itemlisteditor.cpp
+++ b/tools/designer/src/components/taskmenu/itemlisteditor.cpp
@@ -114,20 +114,20 @@ void AbstractItemEditor::keyPressEvent(QKeyEvent *e)
}
static const char * const itemFlagNames[] = {
- "Selectable",
- "Editable",
- "DragEnabled",
- "DropEnabled",
- "UserCheckable",
- "Enabled",
- "Tristate",
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Selectable"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Editable"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "DragEnabled"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "DropEnabled"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "UserCheckable"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Enabled"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Tristate"),
0
};
static const char * const checkStateNames[] = {
- "Unchecked",
- "PartiallyChecked",
- "Checked",
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Unchecked"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "PartiallyChecked"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Checked"),
0
};
@@ -135,7 +135,7 @@ static QStringList c2qStringList(const char * const in[])
{
QStringList out;
for (int i = 0; in[i]; i++)
- out << QLatin1String(in[i]);
+ out << AbstractItemEditor::tr(in[i]);
return out;
}
diff --git a/tools/designer/src/lib/shared/plugindialog.cpp b/tools/designer/src/lib/shared/plugindialog.cpp
index 3e88043..63ba81c 100644
--- a/tools/designer/src/lib/shared/plugindialog.cpp
+++ b/tools/designer/src/lib/shared/plugindialog.cpp
@@ -102,7 +102,7 @@ void PluginDialog::populateTreeWidget()
const QStringList fileNames = pluginManager->registeredPlugins();
if (!fileNames.isEmpty()) {
- QTreeWidgetItem *topLevelItem = setTopLevelItem(QLatin1String("Loaded Plugins"));
+ QTreeWidgetItem *topLevelItem = setTopLevelItem(tr("Loaded Plugins"));
QFont boldFont = topLevelItem->font(0);
foreach (const QString &fileName, fileNames) {
@@ -125,7 +125,7 @@ void PluginDialog::populateTreeWidget()
const QStringList notLoadedPlugins = pluginManager->failedPlugins();
if (!notLoadedPlugins.isEmpty()) {
- QTreeWidgetItem *topLevelItem = setTopLevelItem(QLatin1String("Failed Plugins"));
+ QTreeWidgetItem *topLevelItem = setTopLevelItem(tr("Failed Plugins"));
const QFont boldFont = topLevelItem->font(0);
foreach (const QString &plugin, notLoadedPlugins) {
const QString failureReason = pluginManager->failureReason(plugin);
diff --git a/tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp b/tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp
index c508fa2..7f597ff 100644
--- a/tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp
+++ b/tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp
@@ -66,12 +66,12 @@ QString SeekSliderPlugin::group() const
QString SeekSliderPlugin::toolTip() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString SeekSliderPlugin::whatsThis() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString SeekSliderPlugin::includeFile() const
diff --git a/tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp b/tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp
index d4af121..489a08c 100644
--- a/tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp
+++ b/tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp
@@ -72,12 +72,12 @@ QString VideoPlayerPlugin::group() const
QString VideoPlayerPlugin::toolTip() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString VideoPlayerPlugin::whatsThis() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString VideoPlayerPlugin::includeFile() const
diff --git a/tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp b/tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp
index becd5d9..24eb829 100644
--- a/tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp
+++ b/tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp
@@ -66,12 +66,12 @@ QString VolumeSliderPlugin::group() const
QString VolumeSliderPlugin::toolTip() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString VolumeSliderPlugin::whatsThis() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString VolumeSliderPlugin::includeFile() const
diff --git a/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp b/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp
index b352a9b..7148ad0 100644
--- a/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp
+++ b/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp
@@ -69,12 +69,12 @@ QString QDeclarativeViewPlugin::group() const
QString QDeclarativeViewPlugin::toolTip() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString QDeclarativeViewPlugin::whatsThis() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString QDeclarativeViewPlugin::includeFile() const
diff --git a/tools/designer/src/plugins/qwebview/qwebview_plugin.cpp b/tools/designer/src/plugins/qwebview/qwebview_plugin.cpp
index 61f7e66..c90e191 100644
--- a/tools/designer/src/plugins/qwebview/qwebview_plugin.cpp
+++ b/tools/designer/src/plugins/qwebview/qwebview_plugin.cpp
@@ -69,12 +69,12 @@ QString QWebViewPlugin::group() const
QString QWebViewPlugin::toolTip() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString QWebViewPlugin::whatsThis() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString QWebViewPlugin::includeFile() const
diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp
index 094406c..d691548 100644
--- a/tools/linguist/lconvert/main.cpp
+++ b/tools/linguist/lconvert/main.cpp
@@ -45,11 +45,17 @@
#include <QtCore/QDebug>
#include <QtCore/QString>
#include <QtCore/QStringList>
+#include <QtCore/QTranslator>
+#include <QtCore/QLibraryInfo>
#include <iostream>
QT_USE_NAMESPACE
+class LC {
+ Q_DECLARE_TR_FUNCTIONS(LConvert)
+};
+
static int usage(const QStringList &args)
{
Q_UNUSED(args);
@@ -59,7 +65,7 @@ static int usage(const QStringList &args)
foreach (Translator::FileFormat format, Translator::registeredFileFormats())
loaders += line.arg(format.extension, -5).arg(format.description);
- std::cerr << qPrintable(QString(QLatin1String("\nUsage:\n"
+ std::cerr << qPrintable(LC::tr("\nUsage:\n"
" lconvert [options] <infile> [<infile>...]\n\n"
"lconvert is part of Qt's Linguist tool chain. It can be used as a\n"
"stand-alone tool to convert and filter translation data files.\n"
@@ -121,7 +127,7 @@ static int usage(const QStringList &args)
" 0 on success\n"
" 1 on command line parse failures\n"
" 2 on read failures\n"
- " 3 on write failures\n")).arg(loaders));
+ " 3 on write failures\n").arg(loaders));
return 1;
}
@@ -134,8 +140,17 @@ struct File
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
- QStringList args = app.arguments();
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("linguist_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ }
+ QStringList args = app.arguments();
QList<File> inFiles;
QString inFormat(QLatin1String("auto"));
QString outFileName;
diff --git a/tools/linguist/linguist/phrase.cpp b/tools/linguist/linguist/phrase.cpp
index 254daf4..709ec35 100644
--- a/tools/linguist/linguist/phrase.cpp
+++ b/tools/linguist/linguist/phrase.cpp
@@ -188,10 +188,9 @@ bool QphHandler::characters(const QString &ch)
bool QphHandler::fatalError(const QXmlParseException &exception)
{
if (ferrorCount++ == 0) {
- QString msg;
- msg.sprintf("Parse error at line %d, column %d (%s).",
- exception.lineNumber(), exception.columnNumber(),
- exception.message().toLatin1().constData());
+ QString msg = PhraseBook::tr("Parse error at line %1, column %2 (%3).")
+ .arg(exception.lineNumber()).arg(exception.columnNumber())
+ .arg(exception.message());
QMessageBox::information(0,
QObject::tr("Qt Linguist"), msg);
}
diff --git a/tools/linguist/lrelease/main.cpp b/tools/linguist/lrelease/main.cpp
index b5cff90..19377ef 100644
--- a/tools/linguist/lrelease/main.cpp
+++ b/tools/linguist/lrelease/main.cpp
@@ -65,6 +65,17 @@ static void initBinaryDir(
const char *argv0
#endif
);
+
+struct LR {
+ static inline QString tr(const char *sourceText, const char *comment = 0)
+ {
+ return QCoreApplication::translate("LRelease", sourceText, comment);
+ }
+};
+#else
+class LR {
+ Q_DECLARE_TR_FUNCTIONS(LRelease)
+};
#endif
static void printOut(const QString & out)
@@ -75,7 +86,7 @@ static void printOut(const QString & out)
static void printUsage()
{
- printOut(QCoreApplication::tr(
+ printOut(LR::tr(
"Usage:\n"
" lrelease [options] project-file\n"
" lrelease [options] ts-files [-qm qm-file]\n\n"
@@ -108,7 +119,7 @@ static bool loadTsFile(Translator &tor, const QString &tsFileName, bool /* verbo
ConversionData cd;
bool ok = tor.load(tsFileName, cd, QLatin1String("auto"));
if (!ok) {
- std::cerr << "lrelease error: " << qPrintable(cd.error());
+ std::cerr << qPrintable(LR::tr("lrelease error: %1").arg(cd.error()));
} else {
if (!cd.errors().isEmpty())
printOut(cd.error());
@@ -123,17 +134,17 @@ static bool releaseTranslator(Translator &tor, const QString &qmFileName,
tor.reportDuplicates(tor.resolveDuplicates(), qmFileName, cd.isVerbose());
if (cd.isVerbose())
- printOut(QCoreApplication::tr( "Updating '%1'...\n").arg(qmFileName));
+ printOut(LR::tr("Updating '%1'...\n").arg(qmFileName));
if (removeIdentical) {
if (cd.isVerbose())
- printOut(QCoreApplication::tr( "Removing translations equal to source text in '%1'...\n").arg(qmFileName));
+ printOut(LR::tr("Removing translations equal to source text in '%1'...\n").arg(qmFileName));
tor.stripIdenticalSourceTranslations();
}
QFile file(qmFileName);
if (!file.open(QIODevice::WriteOnly)) {
- std::cerr << "lrelease error: cannot create '" << qPrintable(qmFileName)
- << "': " << qPrintable(file.errorString()) << std::endl;
+ std::cerr << qPrintable(LR::tr("lrelease error: cannot create '%1': %2\n")
+ .arg(qmFileName, file.errorString()));
return false;
}
@@ -142,8 +153,8 @@ static bool releaseTranslator(Translator &tor, const QString &qmFileName,
file.close();
if (!ok) {
- std::cerr << "lrelease error: cannot save '" << qPrintable(qmFileName)
- << "': " << qPrintable(cd.error());
+ std::cerr << qPrintable(LR::tr("lrelease error: cannot save '%1': %2")
+ .arg(qmFileName, cd.error()));
} else if (!cd.errors().isEmpty()) {
printOut(cd.error());
}
@@ -181,8 +192,14 @@ int main(int argc, char **argv)
#else
QCoreApplication app(argc, argv);
QTranslator translator;
- if (translator.load(QLatin1String("lrelease_") + QLocale::system().name()))
+ QTranslator qtTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("linguist_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) {
app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ }
#endif
ConversionData cd;
@@ -221,7 +238,7 @@ int main(int argc, char **argv)
cd.m_verbose = true;
continue;
} else if (!strcmp(argv[i], "-version")) {
- printOut(QCoreApplication::tr( "lrelease version %1\n").arg(QLatin1String(QT_VERSION_STR)) );
+ printOut(LR::tr("lrelease version %1\n").arg(QLatin1String(QT_VERSION_STR)));
return 0;
} else if (!strcmp(argv[i], "-qm")) {
if (i == argc - 1) {
@@ -255,20 +272,23 @@ int main(int argc, char **argv)
visitor.setVerbose(cd.isVerbose());
if (!visitor.queryProFile(&pro)) {
- std::cerr << "lrelease error: cannot read project file '"
- << qPrintable(inputFile) << "'.\n";
+ std::cerr << qPrintable(LR::tr(
+ "lrelease error: cannot read project file '%1'.\n")
+ .arg(inputFile));
continue;
}
if (!visitor.accept(&pro)) {
- std::cerr << "lrelease error: cannot process project file '"
- << qPrintable(inputFile) << "'.\n";
+ std::cerr << qPrintable(LR::tr(
+ "lrelease error: cannot process project file '%1'.\n")
+ .arg(inputFile));
continue;
}
QStringList translations = visitor.values(QLatin1String("TRANSLATIONS"));
if (translations.isEmpty()) {
- std::cerr << "lrelease warning: Met no 'TRANSLATIONS' entry in project file '"
- << qPrintable(inputFile) << "'\n";
+ std::cerr << qPrintable(LR::tr(
+ "lrelease warning: Met no 'TRANSLATIONS' entry in project file '%1'\n")
+ .arg(inputFile));
} else {
QDir proDir(fi.absolutePath());
foreach (const QString &trans, translations)
diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp
index bc9bb26..970d44b 100644
--- a/tools/linguist/lupdate/cpp.cpp
+++ b/tools/linguist/lupdate/cpp.cpp
@@ -50,6 +50,7 @@
#include <QtCore/QString>
#include <QtCore/QTextCodec>
#include <QtCore/QTextStream>
+#include <QtCore/QCoreApplication>
#include <iostream>
@@ -57,6 +58,10 @@
QT_BEGIN_NAMESPACE
+class LU {
+ Q_DECLARE_TR_FUNCTIONS(LUpdate)
+};
+
/* qmake ignore Q_OBJECT */
static QString MagicComment(QLatin1String("TRANSLATOR"));
@@ -624,8 +629,8 @@ uint CppParser::getToken()
|| yyBraceDepth != is.braceDepth1st
|| yyParenDepth != is.parenDepth1st)
yyMsg(is.elseLine)
- << "Parenthesis/bracket/brace mismatch between "
- "#if and #else branches; using #if branch\n";
+ << qPrintable(LU::tr("Parenthesis/bracket/brace mismatch between "
+ "#if and #else branches; using #if branch\n"));
} else {
is.bracketDepth1st = yyBracketDepth;
is.braceDepth1st = yyBraceDepth;
@@ -647,8 +652,8 @@ uint CppParser::getToken()
|| yyBraceDepth != is.braceDepth1st
|| yyParenDepth != is.parenDepth1st)
yyMsg(is.elseLine)
- << "Parenthesis/brace mismatch between "
- "#if and #else branches; using #if branch\n";
+ << qPrintable(LU::tr("Parenthesis/brace mismatch between "
+ "#if and #else branches; using #if branch\n"));
yyBracketDepth = is.bracketDepth1st;
yyBraceDepth = is.braceDepth1st;
yyParenDepth = is.parenDepth1st;
@@ -674,7 +679,7 @@ uint CppParser::getToken()
forever {
yyCh = getChar();
if (yyCh == EOF) {
- yyMsg() << "Unterminated C++ comment\n";
+ yyMsg() << qPrintable(LU::tr("Unterminated C++ comment\n"));
break;
}
@@ -804,7 +809,7 @@ uint CppParser::getToken()
forever {
yyCh = getChar();
if (yyCh == EOF) {
- yyMsg() << "Unterminated C++ comment\n";
+ yyMsg() << qPrintable(LU::tr("Unterminated C++ comment\n"));
break;
}
*ptr++ = yyCh;
@@ -837,7 +842,7 @@ uint CppParser::getToken()
yyWord.resize(ptr - (ushort *)yyWord.unicode());
if (yyCh != '"')
- yyMsg() << "Unterminated C++ string\n";
+ yyMsg() << qPrintable(LU::tr("Unterminated C++ string\n"));
else
yyCh = getChar();
return Tok_String;
@@ -894,8 +899,8 @@ uint CppParser::getToken()
if (yyBraceDepth == yyMinBraceDepth) {
if (!inDefine)
yyMsg(yyCurLineNo)
- << "Excess closing brace in C++ code"
- " (or abuse of the C++ preprocessor)\n";
+ << qPrintable(LU::tr("Excess closing brace in C++ code"
+ " (or abuse of the C++ preprocessor)\n"));
// Avoid things getting messed up even more
yyCh = getChar();
return Tok_Semicolon;
@@ -912,8 +917,8 @@ uint CppParser::getToken()
case ')':
if (yyParenDepth == 0)
yyMsg(yyCurLineNo)
- << "Excess closing parenthesis in C++ code"
- " (or abuse of the C++ preprocessor)\n";
+ << qPrintable(LU::tr("Excess closing parenthesis in C++ code"
+ " (or abuse of the C++ preprocessor)\n"));
else
yyParenDepth--;
yyCh = getChar();
@@ -927,8 +932,8 @@ uint CppParser::getToken()
case ']':
if (yyBracketDepth == 0)
yyMsg(yyCurLineNo)
- << "Excess closing bracket in C++ code"
- " (or abuse of the C++ preprocessor)\n";
+ << qPrintable(LU::tr("Excess closing bracket in C++ code"
+ " (or abuse of the C++ preprocessor)\n"));
else
yyBracketDepth--;
yyCh = getChar();
@@ -1296,7 +1301,7 @@ void CppParser::processInclude(const QString &file, ConversionData &cd,
QString cleanFile = QDir::cleanPath(file);
if (inclusions.contains(cleanFile)) {
- yyMsg() << "circular inclusion of " << qPrintable(cleanFile) << std::endl;
+ yyMsg() << qPrintable(LU::tr("circular inclusion of %1\n").arg(cleanFile));
return;
}
@@ -1320,9 +1325,7 @@ void CppParser::processInclude(const QString &file, ConversionData &cd,
QFile f(cleanFile);
if (!f.open(QIODevice::ReadOnly)) {
- yyMsg()
- << "Cannot open " << qPrintable(cleanFile) << ": "
- << qPrintable(f.errorString()) << std::endl;
+ yyMsg() << qPrintable(LU::tr("Cannot open %1: %2\n").arg(cleanFile, f.errorString()));
return;
}
@@ -1766,7 +1769,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
if (!tor)
goto case_default;
if (!sourcetext.isEmpty())
- yyMsg() << "//% cannot be used with tr() / QT_TR_NOOP(). Ignoring\n";
+ yyMsg() << qPrintable(LU::tr("//% cannot be used with tr() / QT_TR_NOOP(). Ignoring\n"));
utf8 = (yyTok == Tok_trUtf8);
line = yyLineNo;
yyTok = getToken();
@@ -1787,9 +1790,8 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
QStringList unresolved;
if (!fullyQualify(namespaces, pendingContext, true, &functionContext, &unresolved)) {
functionContextUnresolved = unresolved.join(strColons);
- yyMsg() << "Qualifying with unknown namespace/class "
- << qPrintable(stringifyNamespace(functionContext)) << "::"
- << qPrintable(unresolved.first()) << std::endl;
+ yyMsg() << qPrintable(LU::tr("Qualifying with unknown namespace/class %1::%2\n")
+ .arg(stringifyNamespace(functionContext)).arg(unresolved.first()));
}
pendingContext.clear();
}
@@ -1797,7 +1799,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
if (functionContextUnresolved.isEmpty()) {
int idx = functionContext.length();
if (idx < 2) {
- yyMsg() << "tr() cannot be called without context\n";
+ yyMsg() << qPrintable(LU::tr("tr() cannot be called without context\n"));
break;
}
Namespace *fctx;
@@ -1806,8 +1808,8 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
context = stringifyNamespace(functionContext);
fctx = findNamespace(functionContext)->classDef;
if (!fctx->complained) {
- yyMsg() << "Class '" << qPrintable(context)
- << "' lacks Q_OBJECT macro\n";
+ yyMsg() << qPrintable(LU::tr("Class '%1' lacks Q_OBJECT macro\n")
+ .arg(context));
fctx->complained = true;
}
goto gotctx;
@@ -1835,8 +1837,8 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
int last = prefix.lastIndexOf(strColons);
QString className = prefix.mid(last == -1 ? 0 : last + 2);
if (!className.isEmpty() && className == functionName) {
- yyMsg() << "It is not recommended to call tr() from within a constructor '"
- << qPrintable(className) << "::" << qPrintable(functionName) << "'\n";
+ yyMsg() << qPrintable(LU::tr("It is not recommended to call tr() from within a constructor '%1::%2'\n")
+ .arg(className).arg(functionName));
}
#endif
prefix.chop(2);
@@ -1851,7 +1853,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
context = fctx->trQualification;
}
if (!fctx->hasTrFunctions && !fctx->complained) {
- yyMsg() << "Class '" << qPrintable(context) << "' lacks Q_OBJECT macro\n";
+ yyMsg() << qPrintable(LU::tr("Class '%1' lacks Q_OBJECT macro\n").arg(context));
fctx->complained = true;
}
} else {
@@ -1873,7 +1875,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
if (!tor)
goto case_default;
if (!sourcetext.isEmpty())
- yyMsg() << "//% cannot be used with translate() / QT_TRANSLATE_NOOP(). Ignoring\n";
+ yyMsg() << qPrintable(LU::tr("//% cannot be used with translate() / QT_TRANSLATE_NOOP(). Ignoring\n"));
utf8 = (yyTok == Tok_translateUtf8);
line = yyLineNo;
yyTok = getToken();
@@ -1928,7 +1930,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
if (!tor)
goto case_default;
if (!msgid.isEmpty())
- yyMsg() << "//= cannot be used with qtTrId() / QT_TRID_NOOP(). Ignoring\n";
+ yyMsg() << qPrintable(LU::tr("//= cannot be used with qtTrId() / QT_TRID_NOOP(). Ignoring\n"));
//utf8 = false; // Maybe use //%% or something like that
line = yyLineNo;
yyTok = getToken();
@@ -1995,13 +1997,13 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
if (isspace(c))
continue;
if (c != '"') {
- yyMsg() << "Unexpected character in meta string\n";
+ yyMsg() << qPrintable(LU::tr("Unexpected character in meta string\n"));
break;
}
forever {
if (p >= yyWord.length()) {
whoops:
- yyMsg() << "Unterminated meta string\n";
+ yyMsg() << qPrintable(LU::tr("Unterminated meta string\n"));
break;
}
c = yyWord.unicode()[p++].unicode();
@@ -2054,7 +2056,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
case Tok_Arrow:
yyTok = getToken();
if (yyTok == Tok_tr || yyTok == Tok_trUtf8)
- yyMsg() << "Cannot invoke tr() like this\n";
+ yyMsg() << qPrintable(LU::tr("Cannot invoke tr() like this\n"));
break;
case Tok_ColonColon:
if (yyBraceDepth == namespaceDepths.count() && yyParenDepth == 0 && !yyTokColonSeen)
@@ -2087,7 +2089,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
prospectiveContext.clear();
prefix.clear();
if (!sourcetext.isEmpty() || !extracomment.isEmpty() || !msgid.isEmpty() || !extra.isEmpty()) {
- yyMsg() << "Discarding unconsumed meta data\n";
+ yyMsg() << qPrintable(LU::tr("Discarding unconsumed meta data\n"));
sourcetext.clear();
extracomment.clear();
msgid.clear();
@@ -2127,16 +2129,16 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
if (yyBraceDepth != 0)
yyMsg(yyBraceLineNo)
- << "Unbalanced opening brace in C++ code"
- " (or abuse of the C++ preprocessor)\n";
+ << qPrintable(LU::tr("Unbalanced opening brace in C++ code"
+ " (or abuse of the C++ preprocessor)\n"));
else if (yyParenDepth != 0)
yyMsg(yyParenLineNo)
- << "Unbalanced opening parenthesis in C++ code"
- " (or abuse of the C++ preprocessor)\n";
+ << qPrintable(LU::tr("Unbalanced opening parenthesis in C++ code"
+ " (or abuse of the C++ preprocessor)\n"));
else if (yyBracketDepth != 0)
yyMsg(yyBracketLineNo)
- << "Unbalanced opening bracket in C++ code"
- " (or abuse of the C++ preprocessor)\n";
+ << qPrintable(LU::tr("Unbalanced opening bracket in C++ code"
+ " (or abuse of the C++ preprocessor)\n"));
}
const ParseResults *CppParser::recordResults(bool isHeader)
@@ -2197,8 +2199,7 @@ void loadCPP(Translator &translator, const QStringList &filenames, ConversionDat
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
- cd.appendError(QString::fromLatin1("Cannot open %1: %2")
- .arg(filename, file.errorString()));
+ cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString()));
continue;
}
diff --git a/tools/linguist/lupdate/java.cpp b/tools/linguist/lupdate/java.cpp
index dc66e2b..165b6a3 100644
--- a/tools/linguist/lupdate/java.cpp
+++ b/tools/linguist/lupdate/java.cpp
@@ -50,6 +50,7 @@
#include <QtCore/QStack>
#include <QtCore/QString>
#include <QtCore/QTextCodec>
+#include <QtCore/QCoreApplication>
#include <iostream>
@@ -57,6 +58,10 @@
QT_BEGIN_NAMESPACE
+class LU {
+ Q_DECLARE_TR_FUNCTIONS(LUpdate)
+};
+
enum { Tok_Eof, Tok_class, Tok_return, Tok_tr,
Tok_translate, Tok_Ident, Tok_Package,
Tok_Comment, Tok_String, Tok_Colon, Tok_Dot,
@@ -196,7 +201,7 @@ static int getToken()
while ( !metAsterSlash ) {
yyCh = getChar();
if ( yyCh == EOF ) {
- yyMsg() << "Unterminated Java comment.\n";
+ yyMsg() << qPrintable(LU::tr("Unterminated Java comment.\n"));
return Tok_Comment;
}
@@ -232,7 +237,7 @@ static int getToken()
else {
int sub(yyCh.toLower().toAscii() - 87);
if( sub > 15 || sub < 10) {
- yyMsg() << "Invalid Unicode value.\n";
+ yyMsg() << qPrintable(LU::tr("Invalid Unicode value.\n"));
break;
}
unicode += sub;
@@ -255,7 +260,7 @@ static int getToken()
}
if ( yyCh != QLatin1Char('"') )
- yyMsg() << "Unterminated string.\n";
+ yyMsg() << qPrintable(LU::tr("Unterminated string.\n"));
yyCh = getChar();
@@ -368,8 +373,9 @@ static bool matchString( QString &s )
if (yyTok == Tok_String)
s += yyString;
else {
- yyMsg() << "String used in translation can contain only literals"
- " concatenated with other literals, not expressions or numbers.\n";
+ yyMsg() << qPrintable(LU::tr(
+ "String used in translation can contain only literals"
+ " concatenated with other literals, not expressions or numbers.\n"));
return false;
}
yyTok = getToken();
@@ -477,7 +483,7 @@ static void parse( Translator *tor )
yyScope.push(new Scope(yyIdent, Scope::Clazz, yyLineNo));
}
else {
- yyMsg() << "'class' must be followed by a class name.\n";
+ yyMsg() << qPrintable(LU::tr("'class' must be followed by a class name.\n"));
break;
}
while (!match(Tok_LeftBrace)) {
@@ -549,7 +555,7 @@ static void parse( Translator *tor )
case Tok_RightBrace:
if ( yyScope.isEmpty() ) {
- yyMsg() << "Excess closing brace.\n";
+ yyMsg() << qPrintable(LU::tr("Excess closing brace.\n"));
}
else
delete (yyScope.pop());
@@ -578,7 +584,7 @@ static void parse( Translator *tor )
yyPackage.append(QLatin1String("."));
break;
default:
- yyMsg() << "'package' must be followed by package name.\n";
+ yyMsg() << qPrintable(LU::tr("'package' must be followed by package name.\n"));
break;
}
yyTok = getToken();
@@ -591,9 +597,9 @@ static void parse( Translator *tor )
}
if ( !yyScope.isEmpty() )
- yyMsg(yyScope.top()->line) << "Unbalanced opening brace.\n";
+ yyMsg(yyScope.top()->line) << qPrintable(LU::tr("Unbalanced opening brace.\n"));
else if ( yyParenDepth != 0 )
- yyMsg(yyParenLineNo) << "Unbalanced opening parenthesis.\n";
+ yyMsg(yyParenLineNo) << qPrintable(LU::tr("Unbalanced opening parenthesis.\n"));
}
@@ -601,8 +607,7 @@ bool loadJava(Translator &translator, const QString &filename, ConversionData &c
{
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
- cd.appendError(QString::fromLatin1("Cannot open %1: %2")
- .arg(filename, file.errorString()));
+ cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString()));
return false;
}
diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp
index a575192..d96e205 100644
--- a/tools/linguist/lupdate/main.cpp
+++ b/tools/linguist/lupdate/main.cpp
@@ -52,6 +52,8 @@
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QTextCodec>
+#include <QtCore/QTranslator>
+#include <QtCore/QLibraryInfo>
#include <iostream>
@@ -79,7 +81,7 @@ static void recursiveFileInfoList(const QDir &dir,
static void printUsage()
{
- printOut(QObject::tr(
+ printOut(LU::tr(
"Usage:\n"
" lupdate [options] [project-file]...\n"
" lupdate [options] [source-file|path|@lst-file]... -ts ts-files|@lst-file\n\n"
@@ -186,7 +188,7 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil
else if (options & AbsoluteLocations)
tor.setLocationsType(Translator::AbsoluteLocations);
if (options & Verbose)
- printOut(QObject::tr("Updating '%1'...\n").arg(fn));
+ printOut(LU::tr("Updating '%1'...\n").arg(fn));
UpdateOptions theseOptions = options;
if (tor.locationsType() == Translator::NoLocations) // Could be set from file
@@ -201,7 +203,7 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil
}
if (options & PluralOnly) {
if (options & Verbose)
- printOut(QObject::tr("Stripping non plural forms in '%1'...\n").arg(fn));
+ printOut(LU::tr("Stripping non plural forms in '%1'...\n").arg(fn));
out.stripNonPluralForms();
}
if (options & NoObsolete)
@@ -359,12 +361,12 @@ static void processProjects(
if (visitor.contains(QLatin1String("TRANSLATIONS"))) {
if (parentTor) {
if (topLevel) {
- std::cerr << "lupdate warning: TS files from command line "
- "will override TRANSLATIONS in " << qPrintable(proFile) << ".\n";
+ std::cerr << qPrintable(LU::tr("lupdate warning: TS files from command line "
+ "will override TRANSLATIONS in %1.\n").arg(proFile));
goto noTrans;
} else if (nestComplain) {
- std::cerr << "lupdate warning: TS files from command line "
- "prevent recursing into " << qPrintable(proFile) << ".\n";
+ std::cerr << qPrintable(LU::tr("lupdate warning: TS files from command line "
+ "prevent recursing into %1.\n").arg(proFile));
continue;
}
}
@@ -395,8 +397,8 @@ static void processProjects(
noTrans:
if (!parentTor) {
if (topLevel)
- std::cerr << "lupdate warning: no TS files specified. Only diagnostics "
- "will be produced for '" << qPrintable(proFile) << "'.\n";
+ std::cerr << qPrintable(LU::tr("lupdate warning: no TS files specified. Only diagnostics "
+ "will be produced for '%1'.\n").arg(proFile));
Translator tor;
processProject(nestComplain, pfi, visitor, options, codecForSource,
targetLanguage, sourceLanguage, &tor, fail);
@@ -410,6 +412,16 @@ static void processProjects(
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("linguist_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ }
+
m_defaultExtensions = QLatin1String("java,jui,ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx,js,qs,qml");
QStringList args = app.arguments();
@@ -613,7 +625,7 @@ int main(int argc, char **argv)
proFiles << file;
} else if (fi.isDir()) {
if (options & Verbose)
- printOut(QObject::tr("Scanning directory '%1'...\n").arg(file));
+ printOut(LU::tr("Scanning directory '%1'...\n").arg(file));
QDir dir = QDir(fi.filePath());
projectRoots.insert(dir.absolutePath() + QLatin1Char('/'));
if (extensionsNameFilters.isEmpty()) {
diff --git a/tools/linguist/lupdate/merge.cpp b/tools/linguist/lupdate/merge.cpp
index fffdf9b..87c150c 100644
--- a/tools/linguist/lupdate/merge.cpp
+++ b/tools/linguist/lupdate/merge.cpp
@@ -44,15 +44,19 @@
#include "simtexth.h"
#include "translator.h"
+#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QtCore/QMap>
#include <QtCore/QStringList>
#include <QtCore/QTextCodec>
#include <QtCore/QVector>
-
QT_BEGIN_NAMESPACE
+class LU {
+ Q_DECLARE_TR_FUNCTIONS(LUpdate)
+};
+
static bool isDigitFriendly(QChar c)
{
return c.isPunct() || c.isSpace();
@@ -485,24 +489,24 @@ Translator merge(const Translator &tor, const Translator &virginTor,
if (options & Verbose) {
int totalFound = neww + known;
- err += QObject::tr(" Found %n source text(s) (%1 new and %2 already existing)\n", 0, totalFound).arg(neww).arg(known);
+ err += LU::tr(" Found %n source text(s) (%1 new and %2 already existing)\n", 0, totalFound).arg(neww).arg(known);
if (obsoleted) {
if (options & NoObsolete) {
- err += QObject::tr(" Removed %n obsolete entries\n", 0, obsoleted);
+ err += LU::tr(" Removed %n obsolete entries\n", 0, obsoleted);
} else {
- err += QObject::tr(" Kept %n obsolete entries\n", 0, obsoleted);
+ err += LU::tr(" Kept %n obsolete entries\n", 0, obsoleted);
}
}
if (sameNumberHeuristicCount)
- err += QObject::tr(" Number heuristic provided %n translation(s)\n",
+ err += LU::tr(" Number heuristic provided %n translation(s)\n",
0, sameNumberHeuristicCount);
if (sameTextHeuristicCount)
- err += QObject::tr(" Same-text heuristic provided %n translation(s)\n",
+ err += LU::tr(" Same-text heuristic provided %n translation(s)\n",
0, sameTextHeuristicCount);
if (similarTextHeuristicCount)
- err += QObject::tr(" Similar-text heuristic provided %n translation(s)\n",
+ err += LU::tr(" Similar-text heuristic provided %n translation(s)\n",
0, similarTextHeuristicCount);
}
return outTor;
diff --git a/tools/linguist/lupdate/qdeclarative.cpp b/tools/linguist/lupdate/qdeclarative.cpp
index 2377416..01b9a1d 100644
--- a/tools/linguist/lupdate/qdeclarative.cpp
+++ b/tools/linguist/lupdate/qdeclarative.cpp
@@ -65,8 +65,26 @@
QT_BEGIN_NAMESPACE
+class LU {
+ Q_DECLARE_TR_FUNCTIONS(LUpdate)
+};
+
using namespace QDeclarativeJS;
+class Comment
+{
+public:
+ Comment() : lastLine(-1) {}
+ QString extracomment;
+ QString msgid;
+ TranslatorMessage::ExtraData extra;
+ QString sourcetext;
+ int lastLine;
+
+ bool isValid() const
+ { return !extracomment.isEmpty() || !msgid.isEmpty() || !sourcetext.isEmpty() || !extra.isEmpty(); }
+};
+
class FindTrCalls: protected AST::Visitor
{
public:
@@ -78,6 +96,8 @@ public:
accept(node);
}
+ QList<Comment> comments;
+
protected:
using AST::Visitor::visit;
using AST::Visitor::endVisit;
@@ -114,10 +134,23 @@ protected:
plural = true;
}
+ QString id;
+ QString extracomment;
+ TranslatorMessage::ExtraData extra;
+ Comment scomment = findComment(node->firstSourceLocation().startLine);
+ if (scomment.isValid()) {
+ extracomment = scomment.extracomment;
+ extra = scomment.extra;
+ id = scomment.msgid;
+ }
+
TranslatorMessage msg(m_component, source,
comment, QString(), m_fileName,
node->firstSourceLocation().startLine, QStringList(),
TranslatorMessage::Unfinished, plural);
+ msg.setExtraComment(extracomment.simplified());
+ msg.setId(id);
+ msg.setExtras(extra);
m_translator->extend(msg);
}
} else if (idExpr->name->asString() == QLatin1String("qsTranslate") ||
@@ -140,6 +173,17 @@ protected:
}
if (!literal && m_bSource.isEmpty())
return;
+
+ QString id;
+ QString extracomment;
+ TranslatorMessage::ExtraData extra;
+ Comment scomment = findComment(node->firstSourceLocation().startLine);
+ if (scomment.isValid()) {
+ extracomment = scomment.extracomment;
+ extra = scomment.extra;
+ id = scomment.msgid;
+ }
+
source = literal ? literal->value->asString() : m_bSource;
AST::ArgumentList *commentNode = sourceNode->next;
if (commentNode && AST::cast<AST::StringLiteral *>(commentNode->expression)) {
@@ -155,15 +199,48 @@ protected:
comment, QString(), m_fileName,
node->firstSourceLocation().startLine, QStringList(),
TranslatorMessage::Unfinished, plural);
+ msg.setExtraComment(extracomment.simplified());
+ msg.setId(id);
+ msg.setExtras(extra);
m_translator->extend(msg);
}
+ } else if (idExpr->name->asString() == QLatin1String("qsTrId") ||
+ idExpr->name->asString() == QLatin1String("QT_TRID_NOOP")) {
+ if (!node->arguments)
+ return;
+ AST::StringLiteral *literal = AST::cast<AST::StringLiteral *>(node->arguments->expression);
+ if (literal) {
+
+ QString extracomment;
+ QString sourcetext;
+ TranslatorMessage::ExtraData extra;
+ Comment comment = findComment(node->firstSourceLocation().startLine);
+ if (comment.isValid()) {
+ extracomment = comment.extracomment;
+ sourcetext = comment.sourcetext;
+ extra = comment.extra;
+ }
+
+ const QString id = literal->value->asString();
+ bool plural = node->arguments->next;
+
+ TranslatorMessage msg(QString(), QString(),
+ QString(), QString(), m_fileName,
+ node->firstSourceLocation().startLine, QStringList(),
+ TranslatorMessage::Unfinished, plural);
+ msg.setExtraComment(extracomment.simplified());
+ msg.setId(id);
+ msg.setExtras(extra);
+ m_translator->extend(msg);
+ }
}
}
}
private:
- bool createString(AST::BinaryExpression *b) {
+ bool createString(AST::BinaryExpression *b)
+ {
if (!b || b->op != 0)
return false;
AST::BinaryExpression *l = AST::cast<AST::BinaryExpression *>(b->left);
@@ -187,6 +264,23 @@ private:
return true;
}
+ Comment findComment(int loc)
+ {
+ if (comments.isEmpty())
+ return Comment();
+
+ int i = 0;
+ int commentLoc = comments.at(i).lastLine;
+ while (commentLoc <= loc) {
+ if (commentLoc == loc)
+ return comments.at(i);
+ if (i == comments.count()-1)
+ break;
+ commentLoc = comments.at(++i).lastLine;
+ }
+ return Comment();
+ }
+
Translator *m_translator;
QString m_fileName;
QString m_component;
@@ -236,13 +330,60 @@ QString createErrorString(const QString &filename, const QString &code, Parser &
return errorString;
}
+bool processComment(const QChar *chars, int length, Comment &comment)
+{
+ // Try to match the logic of the QtScript parser.
+ if (!length)
+ return comment.isValid();
+ if (*chars == QLatin1Char(':') && chars[1].isSpace()) {
+ comment.extracomment += QString(chars+1, length-1);
+ } else if (*chars == QLatin1Char('=') && chars[1].isSpace()) {
+ comment.msgid = QString(chars+2, length-2).simplified();
+ } else if (*chars == QLatin1Char('~') && chars[1].isSpace()) {
+ QString text = QString(chars+2, length-2).trimmed();
+ int k = text.indexOf(QLatin1Char(' '));
+ if (k > -1)
+ comment.extra.insert(text.left(k), text.mid(k + 1).trimmed());
+ } else if (*chars == QLatin1Char('%') && chars[1].isSpace()) {
+ comment.sourcetext.reserve(comment.sourcetext.length() + length-2);
+ ushort *ptr = (ushort *)comment.sourcetext.data() + comment.sourcetext.length();
+ int p = 2, c;
+ forever {
+ if (p >= length)
+ break;
+ c = chars[p++].unicode();
+ if (isspace(c))
+ continue;
+ if (c != '"')
+ break;
+ forever {
+ if (p >= length)
+ break;
+ c = chars[p++].unicode();
+ if (c == '"')
+ break;
+ if (c == '\\') {
+ if (p >= length)
+ break;
+ c = chars[p++].unicode();
+ if (c == '\n')
+ break;
+ *ptr++ = '\\';
+ }
+ *ptr++ = c;
+ }
+ }
+ comment.sourcetext.resize(ptr - (ushort *)comment.sourcetext.data());
+ }
+ return comment.isValid();
+}
+
bool loadQml(Translator &translator, const QString &filename, ConversionData &cd)
{
cd.m_sourceFileName = filename;
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
- cd.appendError(QString::fromLatin1("Cannot open %1: %2")
- .arg(filename, file.errorString()));
+ cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString()));
return false;
}
@@ -260,6 +401,25 @@ bool loadQml(Translator &translator, const QString &filename, ConversionData &cd
if (parser.parse()) {
FindTrCalls trCalls;
+
+ // build up a list of comments that contain translation information.
+ for (int i = 0; i < driver.comments().size(); ++i) {
+ AST::SourceLocation loc = driver.comments().at(i);
+ QString commentStr = code.mid(loc.offset, loc.length);
+
+ if (trCalls.comments.isEmpty() || trCalls.comments.last().lastLine != int(loc.startLine)) {
+ Comment comment;
+ comment.lastLine = loc.startLine+1;
+ if (processComment(commentStr.constData(), commentStr.length(), comment))
+ trCalls.comments.append(comment);
+ } else {
+ Comment &lastComment = trCalls.comments.last();
+ lastComment.lastLine += 1;
+ processComment(commentStr.constData(), commentStr.length(), lastComment);
+ }
+ }
+
+ //find all tr calls in the code
trCalls(&translator, filename, parser.ast());
} else {
QString error = createErrorString(filename, code, parser);
diff --git a/tools/linguist/lupdate/qscript.cpp b/tools/linguist/lupdate/qscript.cpp
index 7ca0987..5323022 100644
--- a/tools/linguist/lupdate/qscript.cpp
+++ b/tools/linguist/lupdate/qscript.cpp
@@ -47,6 +47,7 @@
#include <translator.h>
+#include <QtCore/QCoreApplication>
#include <QtCore/qdebug.h>
#include <QtCore/qnumeric.h>
#include <QtCore/qstring.h>
@@ -62,6 +63,10 @@
QT_BEGIN_NAMESPACE
+class LU {
+ Q_DECLARE_TR_FUNCTIONS(LUpdate)
+};
+
class QScriptGrammar
{
public:
@@ -1486,7 +1491,7 @@ int QScript::Lexer::lex()
else {
setDone(Bad);
err = IllegalCharacter;
- errmsg = QLatin1String("Illegal character");
+ errmsg = LU::tr("Illegal character");
}
}
break;
@@ -1497,7 +1502,7 @@ int QScript::Lexer::lex()
} else if (current == 0 || isLineTerminator()) {
setDone(Bad);
err = UnclosedStringLiteral;
- errmsg = QLatin1String("Unclosed string at end of line");
+ errmsg = LU::tr("Unclosed string at end of line");
} else if (current == '\\') {
state = InEscapeSequence;
} else {
@@ -1523,7 +1528,7 @@ int QScript::Lexer::lex()
} else {
setDone(Bad);
err = IllegalEscapeSequence;
- errmsg = QLatin1String("Illegal escape squence");
+ errmsg = LU::tr("Illegal escape squence");
}
} else if (current == 'x')
state = InHexEscape;
@@ -1562,7 +1567,7 @@ int QScript::Lexer::lex()
} else {
setDone(Bad);
err = IllegalUnicodeEscapeSequence;
- errmsg = QLatin1String("Illegal unicode escape sequence");
+ errmsg = LU::tr("Illegal unicode escape sequence");
}
break;
case InSingleLineComment:
@@ -1590,7 +1595,7 @@ int QScript::Lexer::lex()
if (current == 0) {
setDone(Bad);
err = UnclosedComment;
- errmsg = QLatin1String("Unclosed comment at end of file");
+ errmsg = LU::tr("Unclosed comment at end of file");
} else if (isLineTerminator()) {
shiftWindowsLineBreak();
yylineno++;
@@ -1678,7 +1683,7 @@ int QScript::Lexer::lex()
} else {
setDone(Bad);
err = IllegalExponentIndicator;
- errmsg = QLatin1String("Illegal syntax for exponential number");
+ errmsg = LU::tr("Illegal syntax for exponential number");
}
break;
case InExponent:
@@ -1704,7 +1709,7 @@ int QScript::Lexer::lex()
&& isIdentLetter(current)) {
state = Bad;
err = IllegalIdentifier;
- errmsg = QLatin1String("Identifier cannot start with numeric literal");
+ errmsg = LU::tr("Identifier cannot start with numeric literal");
}
// terminate string
@@ -2023,7 +2028,7 @@ bool QScript::Lexer::scanRegExp(RegExpBodyPrefix prefix)
while (1) {
if (isLineTerminator() || current == 0) {
- errmsg = QLatin1String("Unterminated regular expression literal");
+ errmsg = LU::tr("Unterminated regular expression literal");
return false;
}
else if (current != '/' || lastWasEscape == true)
@@ -2267,14 +2272,14 @@ case 66: {
QString name = sym(1).toString();
if ((name == QLatin1String("qsTranslate")) || (name == QLatin1String("QT_TRANSLATE_NOOP"))) {
if (!sourcetext.isEmpty())
- yyMsg(identLineNo) << "//% cannot be used with " << qPrintable(name) << "(). Ignoring\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("//% cannot be used with %1(). Ignoring\n").arg(name));
QVariantList args = sym(2).toList();
if (args.size() < 2) {
- yyMsg(identLineNo) << qPrintable(name) << "() requires at least two arguments.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least two arguments.\n").arg(name));
} else {
if ((args.at(0).type() != QVariant::String)
|| (args.at(1).type() != QVariant::String)) {
- yyMsg(identLineNo) << qPrintable(name) << "(): both arguments must be literal strings.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1(): both arguments must be literal strings.\n").arg(name));
} else {
QString context = args.at(0).toString();
QString text = args.at(1).toString();
@@ -2290,13 +2295,13 @@ case 66: {
extra.clear();
} else if ((name == QLatin1String("qsTr")) || (name == QLatin1String("QT_TR_NOOP"))) {
if (!sourcetext.isEmpty())
- yyMsg(identLineNo) << "//% cannot be used with " << qPrintable(name) << "(). Ignoring\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("//% cannot be used with %1(). Ignoring\n").arg(name));
QVariantList args = sym(2).toList();
if (args.size() < 1) {
- yyMsg(identLineNo) << qPrintable(name) << "() requires at least one argument.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least one argument.\n").arg(name));
} else {
if (args.at(0).type() != QVariant::String) {
- yyMsg(identLineNo) << qPrintable(name) << "(): text to translate must be a literal string.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1(): text to translate must be a literal string.\n").arg(name));
} else {
QString context = QFileInfo(fileName()).baseName();
QString text = args.at(0).toString();
@@ -2312,13 +2317,13 @@ case 66: {
extra.clear();
} else if ((name == QLatin1String("qsTrId")) || (name == QLatin1String("QT_TRID_NOOP"))) {
if (!msgid.isEmpty())
- yyMsg(identLineNo) << "//= cannot be used with " << qPrintable(name) << "(). Ignoring\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("//= cannot be used with %1(). Ignoring\n").arg(name));
QVariantList args = sym(2).toList();
if (args.size() < 1) {
- yyMsg(identLineNo) << qPrintable(name) << "() requires at least one argument.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least one argument.\n").arg(name));
} else {
if (args.at(0).type() != QVariant::String) {
- yyMsg(identLineNo) << qPrintable(name) << "(): identifier must be a literal string.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1(): identifier must be a literal string.\n").arg(name));
} else {
msgid = args.at(0).toString();
bool plural = (args.size() > 1);
@@ -2386,7 +2391,7 @@ case 94: {
case 185:
if (!sourcetext.isEmpty() || !extracomment.isEmpty() || !msgid.isEmpty() || !extra.isEmpty()) {
- yyMsg() << "Discarding unconsumed meta data\n";
+ yyMsg() << qPrintable(LU::tr("Discarding unconsumed meta data\n"));
sourcetext.clear();
extracomment.clear();
msgid.clear();
@@ -2448,7 +2453,9 @@ case 94: {
for (int s = 0; s < shifts; ++s)
{
if (first)
- error_message += QLatin1String ("Expected ");
+ //: Beginning of the string that contains
+ //: comma-separated list of expected tokens
+ error_message += LU::tr("Expected ");
else
error_message += QLatin1String (", ");
@@ -2502,13 +2509,13 @@ void QScriptParser::processComment(const QChar *chars, int length)
if (isspace(c))
continue;
if (c != '"') {
- yyMsg() << "Unexpected character in meta string\n";
+ yyMsg() << qPrintable(LU::tr("Unexpected character in meta string\n"));
break;
}
forever {
if (p >= length) {
whoops:
- yyMsg() << "Unterminated meta string\n";
+ yyMsg() << qPrintable(LU::tr("Unterminated meta string\n"));
break;
}
c = chars[p++].unicode();
@@ -2534,8 +2541,7 @@ bool loadQScript(Translator &translator, const QString &filename, ConversionData
{
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
- cd.appendError(QString::fromLatin1("Cannot open %1: %2")
- .arg(filename, file.errorString()));
+ cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString()));
return false;
}
QTextStream ts(&file);
diff --git a/tools/linguist/lupdate/qscript.g b/tools/linguist/lupdate/qscript.g
index e4c2d22..3655f2e 100644
--- a/tools/linguist/lupdate/qscript.g
+++ b/tools/linguist/lupdate/qscript.g
@@ -84,6 +84,7 @@
/.
#include <translator.h>
+#include <QtCore/QCoreApplication>
#include <QtCore/qdebug.h>
#include <QtCore/qnumeric.h>
#include <QtCore/qstring.h>
@@ -99,6 +100,10 @@
QT_BEGIN_NAMESPACE
+class LU {
+ Q_DECLARE_TR_FUNCTIONS(LUpdate)
+};
+
static void recordMessage(
Translator *tor, const QString &context, const QString &text, const QString &comment,
const QString &extracomment, const QString &msgid, const TranslatorMessage::ExtraData &extra,
@@ -817,7 +822,7 @@ int QScript::Lexer::lex()
else {
setDone(Bad);
err = IllegalCharacter;
- errmsg = QLatin1String("Illegal character");
+ errmsg = LU::tr("Illegal character");
}
}
break;
@@ -828,7 +833,7 @@ int QScript::Lexer::lex()
} else if (current == 0 || isLineTerminator()) {
setDone(Bad);
err = UnclosedStringLiteral;
- errmsg = QLatin1String("Unclosed string at end of line");
+ errmsg = LU::tr("Unclosed string at end of line");
} else if (current == '\\') {
state = InEscapeSequence;
} else {
@@ -854,7 +859,7 @@ int QScript::Lexer::lex()
} else {
setDone(Bad);
err = IllegalEscapeSequence;
- errmsg = QLatin1String("Illegal escape squence");
+ errmsg = LU::tr("Illegal escape squence");
}
} else if (current == 'x')
state = InHexEscape;
@@ -893,7 +898,7 @@ int QScript::Lexer::lex()
} else {
setDone(Bad);
err = IllegalUnicodeEscapeSequence;
- errmsg = QLatin1String("Illegal unicode escape sequence");
+ errmsg = LU::tr("Illegal unicode escape sequence");
}
break;
case InSingleLineComment:
@@ -921,7 +926,7 @@ int QScript::Lexer::lex()
if (current == 0) {
setDone(Bad);
err = UnclosedComment;
- errmsg = QLatin1String("Unclosed comment at end of file");
+ errmsg = LU::tr("Unclosed comment at end of file");
} else if (isLineTerminator()) {
shiftWindowsLineBreak();
yylineno++;
@@ -1009,7 +1014,7 @@ int QScript::Lexer::lex()
} else {
setDone(Bad);
err = IllegalExponentIndicator;
- errmsg = QLatin1String("Illegal syntax for exponential number");
+ errmsg = LU::tr("Illegal syntax for exponential number");
}
break;
case InExponent:
@@ -1035,7 +1040,7 @@ int QScript::Lexer::lex()
&& isIdentLetter(current)) {
state = Bad;
err = IllegalIdentifier;
- errmsg = QLatin1String("Identifier cannot start with numeric literal");
+ errmsg = LU::tr("Identifier cannot start with numeric literal");
}
// terminate string
@@ -1354,7 +1359,7 @@ bool QScript::Lexer::scanRegExp(RegExpBodyPrefix prefix)
while (1) {
if (isLineTerminator() || current == 0) {
- errmsg = QLatin1String("Unterminated regular expression literal");
+ errmsg = LU::tr("Unterminated regular expression literal");
return false;
}
else if (current != '/' || lastWasEscape == true)
@@ -1683,14 +1688,14 @@ case $rule_number: {
QString name = sym(1).toString();
if ((name == QLatin1String("qsTranslate")) || (name == QLatin1String("QT_TRANSLATE_NOOP"))) {
if (!sourcetext.isEmpty())
- yyMsg(identLineNo) << "//% cannot be used with " << qPrintable(name) << "(). Ignoring\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("//% cannot be used with %1(). Ignoring\n").arg(name));
QVariantList args = sym(2).toList();
if (args.size() < 2) {
- yyMsg(identLineNo) << qPrintable(name) << "() requires at least two arguments.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least two arguments.\n").arg(name));
} else {
if ((args.at(0).type() != QVariant::String)
|| (args.at(1).type() != QVariant::String)) {
- yyMsg(identLineNo) << qPrintable(name) << "(): both arguments must be literal strings.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1(): both arguments must be literal strings.\n").arg(name));
} else {
QString context = args.at(0).toString();
QString text = args.at(1).toString();
@@ -1706,13 +1711,13 @@ case $rule_number: {
extra.clear();
} else if ((name == QLatin1String("qsTr")) || (name == QLatin1String("QT_TR_NOOP"))) {
if (!sourcetext.isEmpty())
- yyMsg(identLineNo) << "//% cannot be used with " << qPrintable(name) << "(). Ignoring\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("//% cannot be used with %1(). Ignoring\n").arg(name));
QVariantList args = sym(2).toList();
if (args.size() < 1) {
- yyMsg(identLineNo) << qPrintable(name) << "() requires at least one argument.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least one argument.\n").arg(name));
} else {
if (args.at(0).type() != QVariant::String) {
- yyMsg(identLineNo) << qPrintable(name) << "(): text to translate must be a literal string.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1(): text to translate must be a literal string.\n").arg(name));
} else {
QString context = QFileInfo(fileName()).baseName();
QString text = args.at(0).toString();
@@ -1728,13 +1733,13 @@ case $rule_number: {
extra.clear();
} else if ((name == QLatin1String("qsTrId")) || (name == QLatin1String("QT_TRID_NOOP"))) {
if (!msgid.isEmpty())
- yyMsg(identLineNo) << "//= cannot be used with " << qPrintable(name) << "(). Ignoring\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("//= cannot be used with %1(). Ignoring\n").arg(name));
QVariantList args = sym(2).toList();
if (args.size() < 1) {
- yyMsg(identLineNo) << qPrintable(name) << "() requires at least one argument.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least one argument.\n").arg(name));
} else {
if (args.at(0).type() != QVariant::String) {
- yyMsg(identLineNo) << qPrintable(name) << "(): identifier must be a literal string.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1(): identifier must be a literal string.\n").arg(name));
} else {
msgid = args.at(0).toString();
bool plural = (args.size() > 1);
@@ -1950,7 +1955,7 @@ Statement: DebuggerStatement ;
/.
case $rule_number:
if (!sourcetext.isEmpty() || !extracomment.isEmpty() || !msgid.isEmpty() || !extra.isEmpty()) {
- yyMsg() << "Discarding unconsumed meta data\n";
+ yyMsg() << qPrintable(LU::tr("Discarding unconsumed meta data\n"));
sourcetext.clear();
extracomment.clear();
msgid.clear();
@@ -2096,6 +2101,9 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
{
if (first)
error_message += QLatin1String ("Expected ");
+ //: Beginning of the string that contains
+ //: comma-separated list of expected tokens
+ error_message += LU::tr("Expected ");
else
error_message += QLatin1String (", ");
@@ -2149,13 +2157,13 @@ void QScriptParser::processComment(const QChar *chars, int length)
if (isspace(c))
continue;
if (c != '"') {
- yyMsg() << "Unexpected character in meta string\n";
+ yyMsg() << qPrintable(LU::tr("Unexpected character in meta string\n"));
break;
}
forever {
if (p >= length) {
whoops:
- yyMsg() << "Unterminated meta string\n";
+ yyMsg() << qPrintable(LU::tr("Unterminated meta string\n"));
break;
}
c = chars[p++].unicode();
@@ -2181,8 +2189,7 @@ bool loadQScript(Translator &translator, const QString &filename, ConversionData
{
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
- cd.appendError(QString::fromLatin1("Cannot open %1: %2")
- .arg(filename, file.errorString()));
+ cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString()));
return false;
}
QTextStream ts(&file);
diff --git a/tools/linguist/lupdate/ui.cpp b/tools/linguist/lupdate/ui.cpp
index 9e22922..797ab1f 100644
--- a/tools/linguist/lupdate/ui.cpp
+++ b/tools/linguist/lupdate/ui.cpp
@@ -43,6 +43,7 @@
#include <translator.h>
+#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QtCore/QFile>
#include <QtCore/QString>
@@ -55,6 +56,10 @@
QT_BEGIN_NAMESPACE
+class LU {
+ Q_DECLARE_TR_FUNCTIONS(LUpdate)
+};
+
class UiReader : public QXmlDefaultHandler
{
public:
@@ -152,11 +157,10 @@ bool UiReader::characters(const QString &ch)
bool UiReader::fatalError(const QXmlParseException &exception)
{
- QString msg;
- msg.sprintf("XML error: Parse error at line %d, column %d (%s).",
- exception.lineNumber(), exception.columnNumber(),
- exception.message().toLatin1().data());
- m_cd.appendError(msg);
+ QString msg = LU::tr("XML error: Parse error at line %1, column %2 (%3).")
+ .arg(exception.lineNumber()).arg(exception.columnNumber())
+ .arg(exception.message());
+ m_cd.appendError(msg);
return false;
}
@@ -181,8 +185,7 @@ bool loadUI(Translator &translator, const QString &filename, ConversionData &cd)
cd.m_sourceFileName = filename;
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
- cd.appendError(QString::fromLatin1("Cannot open %1: %2")
- .arg(filename, file.errorString()));
+ cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString()));
return false;
}
QXmlInputSource in(&file);
@@ -196,7 +199,7 @@ bool loadUI(Translator &translator, const QString &filename, ConversionData &cd)
reader.setErrorHandler(&handler);
bool result = reader.parse(in);
if (!result)
- cd.appendError(QLatin1String("Parse error in UI file"));
+ cd.appendError(LU::tr("Parse error in UI file"));
reader.setContentHandler(0);
reader.setErrorHandler(0);
return result;
diff --git a/tools/qdoc3/main.cpp b/tools/qdoc3/main.cpp
index fa7efee..2bfe38e 100644
--- a/tools/qdoc3/main.cpp
+++ b/tools/qdoc3/main.cpp
@@ -148,7 +148,7 @@ static void printHelp()
*/
static void printVersion()
{
- QString s = QString(tr("qdoc version ")) + QString(QT_VERSION_STR);
+ QString s = tr("qdoc version %1").arg(QT_VERSION_STR);
Location::information(s);
}
diff --git a/tools/shared/qtpropertybrowser/qtpropertymanager.cpp b/tools/shared/qtpropertybrowser/qtpropertymanager.cpp
index a0bef0a..8c7835c 100644
--- a/tools/shared/qtpropertybrowser/qtpropertymanager.cpp
+++ b/tools/shared/qtpropertybrowser/qtpropertymanager.cpp
@@ -2643,8 +2643,8 @@ QString QtPointPropertyManager::valueText(const QtProperty *property) const
if (it == d_ptr->m_values.constEnd())
return QString();
const QPoint v = it.value();
- return QString(tr("(%1, %2)").arg(QString::number(v.x()))
- .arg(QString::number(v.y())));
+ return tr("(%1, %2)").arg(QString::number(v.x()))
+ .arg(QString::number(v.y()));
}
/*!
@@ -2884,8 +2884,8 @@ QString QtPointFPropertyManager::valueText(const QtProperty *property) const
return QString();
const QPointF v = it.value().val;
const int dec = it.value().decimals;
- return QString(tr("(%1, %2)").arg(QString::number(v.x(), 'f', dec))
- .arg(QString::number(v.y(), 'f', dec)));
+ return tr("(%1, %2)").arg(QString::number(v.x(), 'f', dec))
+ .arg(QString::number(v.y(), 'f', dec));
}
/*!
@@ -3204,8 +3204,8 @@ QString QtSizePropertyManager::valueText(const QtProperty *property) const
if (it == d_ptr->m_values.constEnd())
return QString();
const QSize v = it.value().val;
- return QString(tr("%1 x %2").arg(QString::number(v.width()))
- .arg(QString::number(v.height())));
+ return tr("%1 x %2").arg(QString::number(v.width()))
+ .arg(QString::number(v.height()));
}
/*!
@@ -3569,8 +3569,8 @@ QString QtSizeFPropertyManager::valueText(const QtProperty *property) const
return QString();
const QSizeF v = it.value().val;
const int dec = it.value().decimals;
- return QString(tr("%1 x %2").arg(QString::number(v.width(), 'f', dec))
- .arg(QString::number(v.height(), 'f', dec)));
+ return tr("%1 x %2").arg(QString::number(v.width(), 'f', dec))
+ .arg(QString::number(v.height(), 'f', dec));
}
/*!
@@ -3962,10 +3962,10 @@ QString QtRectPropertyManager::valueText(const QtProperty *property) const
if (it == d_ptr->m_values.constEnd())
return QString();
const QRect v = it.value().val;
- return QString(tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x()))
- .arg(QString::number(v.y()))
- .arg(QString::number(v.width()))
- .arg(QString::number(v.height())));
+ return tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x()))
+ .arg(QString::number(v.y()))
+ .arg(QString::number(v.width()))
+ .arg(QString::number(v.height()));
}
/*!
diff --git a/translations/translations.pri b/translations/translations.pri
index fbc1596..1576bd5 100644
--- a/translations/translations.pri
+++ b/translations/translations.pri
@@ -47,8 +47,8 @@ addTsTargets(qt, -I../include -I../include/Qt \
xmlpatterns \
)
addTsTargets(designer, ../tools/designer/designer.pro)
-addTsTargets(linguist, ../tools/linguist/linguist/linguist.pro)
-addTsTargets(assistant, ../tools/assistant/tools/assistant/assistant.pro)
+addTsTargets(linguist, ../tools/linguist/linguist.pro)
+addTsTargets(assistant, ../tools/assistant/tools/tools.pro)
addTsTargets(qt_help, ../tools/assistant/lib/lib.pro)
addTsTargets(qtconfig, ../tools/qtconfig/qtconfig.pro)
addTsTargets(qvfb, ../tools/qvfb/qvfb.pro)