Skip to content

Commit

Permalink
repeater project updated
Browse files Browse the repository at this point in the history
  • Loading branch information
johodgson committed Sep 21, 2012
1 parent ce53a69 commit 32c6fab
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 164 deletions.
6 changes: 2 additions & 4 deletions repeater/assets/CustomPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ Container {

// The background image
ImageView {
layoutProperties: DockLayoutProperties {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
}
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill

imageSource: "asset:///images/background.png"
}
Expand Down
138 changes: 65 additions & 73 deletions repeater/assets/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,28 @@ import Components 1.0

TabbedPane {
Tab {
title: "Simple"
title: qsTr ("Simple")
Page {
content: CustomPage {
CustomPage {
//! [0]
Container {
layoutProperties: DockLayoutProperties {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
}
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill

layout: StackLayout {
leftPadding: 30
topPadding: 30
rightPadding: 30
}
leftPadding: 30
topPadding: 30
rightPadding: 30

Repeater {
// Use a simple number (N) as model -> the delegate will be repeated N times
model: 5

Label {
text: "Hello World"
textStyle.color: Color.White
text: qsTr ("Hello World")
textStyle {
base: SystemDefaults.TextStyles.BodyText
color: Color.White
}
}
}
}
Expand All @@ -50,30 +49,29 @@ TabbedPane {
}

Tab {
title: "Index"
title: qsTr ("Index")
Page {
content: CustomPage {
CustomPage {
//! [1]
Container {
layoutProperties: DockLayoutProperties {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
}
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill

layout: StackLayout {
leftPadding: 30
topPadding: 30
rightPadding: 30
}
leftPadding: 30
topPadding: 30
rightPadding: 30

Repeater {
// Use a simple number (N) as model -> the delegate will be repeated N times
model: 5

Label {
// The current index can be accessed via the 'index' context property
text: "Hello World (" + index + ")"
textStyle.color: Color.White
text: qsTr ("Hello World (%1)").arg(index)
textStyle {
base: SystemDefaults.TextStyles.BodyText
color: Color.White
}
}
}
}
Expand All @@ -83,22 +81,18 @@ TabbedPane {
}

Tab {
title: "Dynamic"
title: qsTr ("Dynamic")
Page {

content: CustomPage {
CustomPage {
//! [2]
Container {
layoutProperties: DockLayoutProperties {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
}
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill

layout: StackLayout {
leftPadding: 30
topPadding: 30
rightPadding: 30
}
leftPadding: 30
topPadding: 30
rightPadding: 30

Slider {
id: slider
Expand All @@ -109,11 +103,14 @@ TabbedPane {

Repeater {
// The number, that is used as model, can be a property binding as well
model: slider.value
model: slider.immediateValue

Label {
text: "Hello World (" + index + ")"
textStyle.color: Color.White
text: qsTr ("Hello World (%1)").arg(index)
textStyle {
base: SystemDefaults.TextStyles.BodyText
color: Color.White
}
}
}
}
Expand All @@ -123,31 +120,30 @@ TabbedPane {
}

Tab {
title: "Array"
title: qsTr ("Array")
Page {
content: CustomPage {
CustomPage {
//! [3]
Container {
layoutProperties: DockLayoutProperties {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
}
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill

layout: StackLayout {
leftPadding: 30
topPadding: 30
rightPadding: 30
}
leftPadding: 30
topPadding: 30
rightPadding: 30

Repeater {
// Use an array of arbitrary values as model
model: [Color.Red, Color.Yellow, Color.Green, Color.Blue, Color.White]

Label {
text: "Hello World (" + index + ")"
text: qsTr ("Hello World (%1)").arg(index)

// The current value of the model can be accessed via the 'modelData' context property
textStyle.color: modelData
textStyle {
base: SystemDefaults.TextStyles.BodyText
color: modelData
}
}
}
}
Expand All @@ -157,48 +153,44 @@ TabbedPane {
}

Tab {
title: "SQL Model"
title: qsTr ("SQL Model")
Page {
content: CustomPage {
CustomPage {
//! [4]
Container {
layoutProperties: DockLayoutProperties {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
}

layout: StackLayout {
leftPadding: 30
topPadding: 30
rightPadding: 30
}
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill

preferredWidth: 768
leftPadding: 30
topPadding: 30
rightPadding: 30

ScrollView {
scrollViewProperties {
scrollMode: ScrollMode.Both
scrollMode: ScrollMode.Vertical
}

Container {
Repeater {
// Use a DataModel object as model
model: _sqlModel
Container {
layout: StackLayout {
topPadding: 30
}
topPadding: 30

// The values of the current model entry can be accessed by their key names (here: title, firstname, surname)
Label {
text: title
textStyle.base: SystemDefaults.TextStyles.TitleText
textStyle.color: Color.White
}

Label {
text: "[" + firstname + " " + surname + "]"
text: qsTr ("[%1 %2]").arg(firstname).arg(surname)
textStyle.base: SystemDefaults.TextStyles.BodyText
textStyle.color: Color.White
}
Divider { }

Divider {}
}
}
}
Expand All @@ -208,4 +200,4 @@ TabbedPane {
}
}
}
}
}
2 changes: 1 addition & 1 deletion repeater/bar-descriptor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<!-- A universally unique application identifier. Must be unique across all BlackBerry Tablet OS applications.
Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. -->
<id>net.rim.bb10samples.declarative.repeater</id>
<id>com.example.bb10samples.declarative.repeater</id>

<!-- The name that is displayed in the BlackBerry Tablet OS application installer.
May have multiple values for each language. See samples or xsd schema file. Optional. -->
Expand Down
2 changes: 1 addition & 1 deletion repeater/repeater.pro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TEMPLATE = app
TARGET = repeater

CONFIG += qt warn_on debug cascades
CONFIG += qt warn_on debug_and_release cascades
LIBS += -lbbdata

INCLUDEPATH += ../src
Expand Down
47 changes: 0 additions & 47 deletions repeater/src/RepeaterApp.cpp

This file was deleted.

33 changes: 0 additions & 33 deletions repeater/src/RepeaterApp.hpp

This file was deleted.

4 changes: 3 additions & 1 deletion repeater/src/SqlModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ SqlModel* SqlModel::fromSQLAsset(const QString &fileName)

// Use the result as data source for a model.
SqlModel *model = new SqlModel();
model->append(sqlRoot);
foreach (const QVariant &entry, sqlRoot)
model->append(entry.toMap());

return model;
}
Loading

0 comments on commit 32c6fab

Please sign in to comment.