My app consists of a PathView of pages, and each page consists of simple rows of text represented with a Flickable+Column+Repeater. Could you take a look at my QML to see, if there is some way I could optimize the performance of drawing the text rows?
import QtQuick 1.1
import com.nokia.symbian 1.1
Window {
id: page
Rectangle {
id: pageControl
anchors.fill: parent
PathView {
id: pathView
anchors.fill: parent
model: pageModel
flickDeceleration: 500
preferredHighlightBegin: 0.5
preferredHighlightEnd: 0.5
focus: true
interactive: pathView.model.count > 1
delegate: pageDelegate
path: Path {
startX: - pathView.width * pathView.model.count / 2 + pathView.width / 2
startY: pathView.height / 2
PathLine {
x: pathView.width * pathView.model.count / 2 + pathView.width / 2
y: pathView.height / 2
}
}
}
Component {
id: pageDelegate
Rectangle {
width: pathView.width
height: pathView.height
color: "white"
Flickable {
id: flickable
clip: true
anchors {
left: parent.left; right: parent.right; top: parent.top; bottom: parent.bottom;
leftMargin: 6; rightMargin: 6; topMargin: 6; bottomMargin: 6
}
contentHeight: contentColumn.height
contentWidth: contentColumn.width
flickableDirection: Flickable.VerticalFlick
Column {
id: contentColumn
Repeater {
model: contentModel
delegate: Text {
width: flickable.width
wrapMode: Text.Wrap
font.pixelSize: 16
textFormat: Text.RichText
text: time + (author != "" ? " <b><" + author + "></b> " : " ") + content
}
}
}
}
}
}
}
ListModel {
id: pageModel
ListElement {
name: "page 1"
}
ListElement {
name: "page 2"
}
ListElement {
name: "page 3"
}
ListElement {
name: "page 3"
}
}
ListModel {
id: contentModel
ListElement {
time: "11:11"
author: "1"
content: "feiwjf wie iew jigwguregiuareuiriuea uireahi fsferghraegaregrg"
}
ListElement {
time: "11:12"
author: "2"
content: "feiwjf wie iew jigwguregiuareuiriuea uireahi fsferghraegaregrg"
}
ListElement {
time: "11:13"
author: "3"
content: "feiwjf wie iew jigwguregiuareuiriuea uireahi fsferghraegaregrg"
}
ListElement {
time: "11:14"
author: "4"
content: "feiwjf wie iew jigwguregiuareuiriuea uireahi fsferghraegaregrg"
}
ListElement {
time: "11:15"
author: "5"
content: "feiwjf wie iew jigwguregiuareuiriuea uireahi fsferghraegaregrg"
}
}
}
The performance issue comes up when switching orientation between portrait and landscape on a Symbian device. The orientation switch takes more than 10 seconds with the amount of content I would like to support (at least 5 pages with around 150 rows of text each). I know this might be a Symbian specific problem, but I would like to rule out performance issues with my QML first.
I’ve tried:
- Removing the width property binding from the Repeater’s delegate: This improves the performance a bit, but I want to wrap long rows onto the next line, so I guess I have to define the width like this.
- Having a ListView instead of Flickable+Column+Repeater for each page: This caused the application to randomly crash when scrolling the ListView fast.
- Having the page content inside one huge scrollable text element: The scrolling performance was really bad for this.
I’ve considered:
- Having a ListView instead of PathView for the page control: I doubt this would help much, because I would want to have at least one page on either side of the visible page to be in the cache and ready for being swiped visible, and the performance with 3 pages of around 150 rows of text is already unacceptable.
↧