summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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--doc/src/examples/qml-twitter.qdoc4
-rw-r--r--[-rwxr-xr-x]doc/src/tutorials/modelview.qdoc575
-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--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/webkit/WebCore/WebCore.pro34
-rw-r--r--src/gui/text/qtextengine.cpp7
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp2
-rw-r--r--src/network/kernel/qauthenticator.cpp56
-rw-r--r--src/script/api/qscriptengine.cpp3
-rw-r--r--src/script/api/qscriptprogram.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
68 files changed, 824 insertions, 1518 deletions
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/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/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/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/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/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/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/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/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/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/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