~daker/ubuntu-rssreader-app/fix.1217297

« back to all changes in this revision

Viewing changes to ubuntu-rssreader-app.qml

  • Committer: Roman Shchekin
  • Date: 2013-09-01 14:35:33 UTC
  • mto: This revision was merged to the branch mainline in revision 52.
  • Revision ID: mrqtros@gmail.com-20130901143533-aqeohpuf6qlbt335
Fix for https://bugs.launchpad.net/ubuntu-rssreader-app/+bug/1217300.
A lot of little but extremelly important changes in refresh process.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    {
27
27
        //////////////////////////////////////////////////////////////  below DB operation is for avoid empty db
28
28
        //         DB.dropTable()
 
29
        // DB.deleteTag(22)
 
30
        // DB.deleteFeed(63)
29
31
        var feeds = DB.loadFeeds();
30
32
 
31
33
        if (feeds.rows.length < 1)
44
46
        } else repeater.reloadTabs() ;     // load tabs from db
45
47
    }
46
48
 
47
 
    function refresh()             //  download all articles
48
 
    {
 
49
    /* Refresh current topic or all feeds if we are in the Shorts.
 
50
     */
 
51
    function refresh() {
49
52
        var topicId = 0
50
53
        if (pageStack.currentPage == tabstabs) {
51
54
            var curTab = tabstabs.selectedTab
59
62
            feeds = DB.loadFeedsFromTag(topicId)
60
63
        else feeds = DB.loadFeeds()
61
64
 
62
 
        var feedarray = [] ;
 
65
        var feedarray = []
63
66
        for (var i=0; i< feeds.rows.length; i++)
64
67
        {
65
 
            feedarray.push(feeds.rows.item(i));
 
68
            feedarray.push(feeds.rows.item(i))
66
69
        }
67
 
        xmlnetwork.updateFeeds(feedarray);
 
70
        xmlnetwork.updateFeeds(feedarray, topicId)
68
71
    }
69
72
 
70
73
    function toRssPage(model, index)     //   go to single article page     // bugs remain
88
91
 
89
92
        Component.onCompleted: {
90
93
            push(tabstabs)
 
94
            //push(feedListPage)
91
95
        }
92
96
 
93
97
        onCurrentPageChanged: {
156
160
            id: tabstabs
157
161
            visible: false
158
162
 
 
163
            function selectTopic(topicId) {
 
164
                if (topicId == 0) {
 
165
                    tabstabs.selectedTabIndex = 0
 
166
                } else {
 
167
                    for(var i = 0; i < repeater.count; i++) {
 
168
                        if (repeater.itemAt(i).topicId == topicId) {
 
169
                            tabstabs.selectedTabIndex = i + 1
 
170
                            return tabstabs.selectedTab
 
171
                        }
 
172
                    }
 
173
                }
 
174
            }
 
175
 
159
176
            TopicTab {
160
177
                id: shortsTab
161
178
 
275
292
            Connections {
276
293
                target: xmlnetwork
277
294
 
278
 
                onDownloadFinish: {
 
295
                onDownloadFinished: {
279
296
                    PopupUtils.close(refreshWaitDialog)
280
297
                }
281
298
            }
341
358
        }
342
359
    } // Component
343
360
 
344
 
    function reloadViews() {
 
361
    function reloadViews(tagId) {
345
362
        shortsTab.reload()
346
363
        repeater.reloadTabs()
 
364
        tabstabs.selectTopic(tagId)
 
365
        // TODO use later.
 
366
        // Weak and slow place, we need dynamic tabs management to speed up.
 
367
        //        if (tagId == 0) {
 
368
        //            shortsTab.reload()
 
369
        //            repeater.reloadTabs()
 
370
        //        } else {
 
371
        //            var tab = tabstabs.selectTopic(tagId)
 
372
        //            tab.reload()
 
373
        //        }
347
374
    }
348
375
 
349
376
    XmlNetwork {
350
377
        id: xmlnetwork
351
378
 
352
 
        onDownloadFinish: {
353
 
            reloadViews()
 
379
        onDownloadFinished: {
 
380
            reloadViews(tagId)
354
381
        }
355
382
 
356
383
        onDownloadStarted: {
375
402
        id: connAddFeed
376
403
        target: chooseTopicPage
377
404
 
378
 
        onFeedAdded: {
379
 
            // reloadViews() need to discuss it.
 
405
        onTopicChoosen: {
 
406
            xmlnetwork.updateFeeds(addedFeeds, topicId)
380
407
        }
381
408
    }
382
409