~dragly/ubuntu-rssreader-app/single-entry-styling

« back to all changes in this revision

Viewing changes to EntryListPage.qml

  • Committer: Tarmac
  • Author(s): Svenn-Arne Dragly
  • Date: 2013-04-16 07:16:39 UTC
  • mfrom: (5.1.4 ubuntu-rssreader-app)
  • Revision ID: tarmac-20130416071639-v6ug4t6ahb8mfdos
Implemented design proposal with horizontal swipes between feeds on main screen.

Approved by Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
import "databasemodule.js" as DB
9
9
 
10
 
import QtWebKit 3.0
11
 
 
12
10
Page {
13
11
 
14
12
    signal backRequst
 
13
    property string feedLink: ""
15
14
 
16
15
    /* 1. Loading data from database by url.
17
16
     * 2. Appending data to ListModel for displaying.
18
17
     */
19
18
    function loadEntriesByUrl(strUrl) {
20
19
        newsListModel.clear()
21
 
        var isAll = (strUrl === "")
22
 
        DB.loadEntries(strUrl, isAll)
23
 
        var entries = DB.dbResult.rows
 
20
        var isAll = (feedLink === "")
 
21
        var entries = DB.loadEntries(feedLink, isAll)
 
22
//        var entries = DB.dbResult.rows
24
23
        for (var i = 0; i < entries.length; i++) {
25
24
            newsListModel.append({"title":entries.item(i).title,
26
25
                                     "pubDate":entries.item(i).pubDate,
28
27
                                     "description":entries.item(i).description,
29
28
                                     "hash":entries.item(i).hash})
30
29
        }
 
30
        console.log("Loaded entries by URL " + strUrl)
 
31
    }
 
32
 
 
33
    onFeedLinkChanged: {
 
34
        loadEntriesByUrl(feedLink)
31
35
    }
32
36
 
33
37
    tools: ToolbarActions {
43
47
    ListView {
44
48
        id: newsList
45
49
 
46
 
        width: parent.width
47
 
        height: units.gu(40)
48
50
        clip: true
49
 
        anchors {
50
 
            top: parent.top
51
 
        }
 
51
        anchors.fill: parent
52
52
 
53
53
        model: ListModel {
54
54
            id: newsListModel
64
64
            }
65
65
 
66
66
            onClicked: {
67
 
                contentLabel.loadHtml((model.content !== "")? model.content : model.description) // FIRST WAY
 
67
                mainPageStack.push(singleEntryPage)
 
68
                singleEntryPage.content.loadHtml((model.content !== "")? model.content : model.description) // FIRST WAY
68
69
                // contentLabel.text = (model.content != "")? model.content : model.description // SECOND WAY
69
70
            }
70
71
        } // delegate
71
72
    } // ListView
72
73
 
73
 
    /* FIRST WAY OF DISPLAYING FEED */
74
 
    WebView {
75
 
        id: contentLabel
76
 
        width: parent.width
77
 
 
78
 
 
79
 
        onNavigationRequested: {
80
 
            if (request.navigationType == 0)
81
 
                request.action = 1
82
 
        }
83
 
 
84
 
        anchors {
85
 
            top: newsList.bottom
86
 
            bottom: parent.bottom
87
 
        }
88
 
    }
89
 
 
90
74
    /* SECOND WAY OF DISPLAYING FEED. DOES NOT WORK ON MY QT5 LIBS, BUG */
91
75
    //    Flickable {
92
76
    //        id: tmpLabelFlick