-
Notifications
You must be signed in to change notification settings - Fork 1
/
twobuntu-app.qml
60 lines (47 loc) · 1.52 KB
/
twobuntu-app.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import QtQuick 2.2
import Ubuntu.Components 1.1
import "articledb.js" as ArticleDB
MainView {
objectName: "twobuntu"
applicationName: "com.ubuntu.developer.nathanosman.twobuntu-app"
useDeprecatedToolbar: false
width: units.gu(50)
height: units.gu(75)
backgroundColor: "#f5f5f5"
// Model used for accessing all of the recent articles
// that are retrieved when the application loads
ListModel {
id: articleList
// True if data has been loaded into the list for the first time
property bool loading: true
// Refresh the articles in the list
function refresh() {
ArticleDB.loadArticles(articleList);
}
// Load more articles
function loadMore() {
var lastTimestamp = articleList.get(articleList.count - 1).date;
ArticleDB.loadArticles(articleList, lastTimestamp - 1);
}
// Refresh at startup
Component.onCompleted: refresh()
}
// List of pages
PageStack {
id: pageStack
Component.onCompleted: push(articleListPage)
ArticleListPage {
id: articleListPage
articleModel: articleList
// When an article is selected, open the article view page
onArticleSelected: {
articleViewPage.articleIndex = index;
pageStack.push(articleViewPage);
}
}
ArticleViewPage {
id: articleViewPage
articleModel: articleList
}
}
}