~dholbach/ubuntu-rssreader-app/fix-paths

« back to all changes in this revision

Viewing changes to feeds/ChooseTopicPage.qml

  • Committer: Roman Shchekin
  • Date: 2013-09-07 16:38:50 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: mrqtros@gmail.com-20130907163850-jeujfvlwvgbc1lv0
Set of minor changes, like:
* ChooseTopicPage - now accept on text field makes two things - appends new topic and selects it.
* Articles*.qml - mark article as read code moved to RssFeedPage.qml (so swipe right and left now makes articles read too)
* Other changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        }
49
49
    }
50
50
 
 
51
    function appendFeedsToTopic(topicId) {
 
52
        var tagId = topicId
 
53
 
 
54
        var updateList = []
 
55
 
 
56
        for(var i = 0; i < feedsToAdd.length; i++) {
 
57
 
 
58
            var f = feedsToAdd[i]
 
59
 
 
60
            // TODO should I remove html tags or not? :)
 
61
            var feedTitle = f.title
 
62
            feedTitle = feedTitle.replace(/<[^>]*>/g, '')
 
63
 
 
64
            var dbResult = DB.addFeed(feedTitle, f.url)
 
65
 
 
66
            if (dbResult.error) {
 
67
                // TODO Exist
 
68
                continue
 
69
            }
 
70
 
 
71
            DB.updateFeedByXml(dbResult.feedId, f.link, f.description, feedTitle)
 
72
            DB.addFeedTag(dbResult.feedId, tagId)
 
73
 
 
74
            updateList.push({"source" : f.url, "link" : f.link, "id" : dbResult.feedId})
 
75
        }
 
76
 
 
77
        pageStack.pop()
 
78
        pageStack.pop()
 
79
 
 
80
        topicChoosen(tagId, updateList)
 
81
    }
 
82
 
51
83
    ListView {
52
84
        id: suggestionTopics
53
85
 
81
113
                }
82
114
 
83
115
                onAccepted: {
84
 
                    if (text != "") {
 
116
                    if (text.replace(/^\s+|\s+$/g, '') != "") { // Check that text contains only spaces.
85
117
                        var tagName = text
86
118
 
87
119
                        var dbResult = DB.addTag(text)
97
129
                                                         "tagId" : dbResult.tagId})
98
130
 
99
131
                        text = ""
 
132
 
 
133
                        appendFeedsToTopic(dbResult.tagId)
 
134
                    } else {
 
135
                        PopupUtils.open(errorDialogComponent, chooseTopicPage,
 
136
                                        {"text" : i18n.tr("Topic name can't contain only whitespaces"),
 
137
                                            "title" : i18n.tr("Warning")})
100
138
                    }
101
139
                }
102
140
            }
109
147
            onClicked: {
110
148
                console.log("Topic selected", model.tagId, model.tagName)
111
149
 
112
 
                var tagId = model.tagId
113
 
 
114
 
                var updateList = []
115
 
 
116
 
                for(var i = 0; i < feedsToAdd.length; i++) {
117
 
 
118
 
                    var f = feedsToAdd[i]
119
 
 
120
 
                    // TODO should I remove html tags or not? :)
121
 
                    var feedTitle = f.title
122
 
                    feedTitle = feedTitle.replace(/<[^>]*>/g, '')
123
 
 
124
 
                    var dbResult = DB.addFeed(feedTitle, f.url)
125
 
 
126
 
                    if (dbResult.error) {
127
 
                        // TODO Exist
128
 
                        continue
129
 
                    }
130
 
 
131
 
                    DB.updateFeedByXml(dbResult.feedId, f.link, f.description, feedTitle)
132
 
 
133
 
                    DB.addFeedTag(dbResult.feedId, tagId)
134
 
                    // feedAdded(dbResult.feedId, tagId)
135
 
 
136
 
                    updateList.push({"source" : f.url, "link" : f.link, "id" : dbResult.feedId})
137
 
                }
138
 
 
139
 
                pageStack.pop()
140
 
                pageStack.pop()
141
 
 
142
 
                topicChoosen(tagId, updateList)
 
150
                appendFeedsToTopic(model.tagId)
143
151
            }
144
152
        }
145
153
    }