~qqworini/ubuntu-rssreader-app/gridview-dynamic-load

« back to all changes in this revision

Viewing changes to ListColumnDelegate.qml

  • Committer: Tarmac
  • Author(s): Joey Chan
  • Date: 2013-09-03 16:05:14 UTC
  • mfrom: (55.1.1 ubuntu-rssreader-app)
  • Revision ID: tarmac-20130903160514-2bdefz78lg9jfrfq
what's new:
1. new grid view with new layout algorithm;
2. article items updated;

to do:
1. memory management of the new grid view;
2. read and unread indicate (need to modify the database first);
3. order articles;. Fixes: https://bugs.launchpad.net/bugs/1215343, https://bugs.launchpad.net/bugs/1218201, https://bugs.launchpad.net/bugs/1218204.

Approved by Ubuntu Phone Apps Jenkins Bot, Roman Shchekin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import QtQuick 2.0
2
 
 
3
 
import Ubuntu.Components 0.1
4
 
import Ubuntu.Components.ListItems 0.1 as ListItem
5
 
import Ubuntu.Components.Popups 0.1
6
 
 
7
 
import "./addDelegate.js" as AddD
8
 
import "./imgSeparator.js" as ImgS
9
 
//import "./article_items"
10
 
 
11
 
Column {
12
 
    id: rss_item_delegate
13
 
//    width: units.gu(50)
14
 
//    height: units.gu(75)
15
 
 
16
 
//    height: parent.height
17
 
    spacing: units.gu(2)
18
 
 
19
 
    property bool isFull: false
20
 
    property real childrenSumHeight: 0
21
 
    property real childrenMaxWidth: 0
22
 
    property int modelIndex
23
 
 
24
 
    function addItem(rss_item, rss_description, model, index)
25
 
    {
26
 
        var newD = AddD.addDelegate(rss_item, ImgS.separate(rss_description), model, index, rss_item_delegate);
27
 
        getChildrenRect() ;
28
 
        rss_item_delegate.width = childrenMaxWidth ;
29
 
//        console.log("childrenSumHeight, column.height: ", childrenSumHeight, rss_item_delegate.childrenRect.height)
30
 
        //console.log("children list: ", rss_item_delegate.children.length)
31
 
        if (childrenSumHeight > rss_item_delegate.height + units.gu(2))
32
 
        {
33
 
            isFull = true ;
34
 
            newD.destroy() ;
35
 
            getChildrenRect() ;
36
 
            rss_item_delegate.width = childrenMaxWidth ;
37
 
//            rss_item_delegate.children[rss_item_delegate.children.length-1].destroy() ;
38
 
//            rss_item_delegate.spacing = (childrenSumHeight - rss_item_delegate.height) / (rss_item_delegate.children.length + 2)
39
 
            return false ;
40
 
        }
41
 
        else
42
 
        {
43
 
            isFull = false ;
44
 
            return true ;
45
 
        }
46
 
    }
47
 
 
48
 
    function getChildrenRect()
49
 
    {
50
 
        childrenSumHeight = 0 ;
51
 
        childrenMaxWidth = 0 ;
52
 
        var length = rss_item_delegate.children.length ;
53
 
        for (var i=0; i<length; i++)
54
 
        {
55
 
            childrenSumHeight += (rss_item_delegate.children[i].height + units.gu(2) * length) ;
56
 
            if (rss_item_delegate.children[i].width > childrenMaxWidth)
57
 
            {
58
 
                childrenMaxWidth = rss_item_delegate.children[i].width
59
 
            }
60
 
        }
61
 
    }
62
 
}