~paolorotolo/ubuntu-rssreader-app/fix-for-1202733

« back to all changes in this revision

Viewing changes to ListColumnDelegate.qml

  • Committer: Tarmac
  • Author(s): Joey Chan
  • Date: 2013-07-15 18:08:52 UTC
  • mfrom: (17.1.1 ubuntu-rssreader-app)
  • Revision ID: tarmac-20130715180852-xhfwcpmtjrjsj18c
pre-alpha-release, just for Ubuntu core app hack day in case we cannot release the "real" alpha release on time.

Approved by Ubuntu Phone Apps Jenkins Bot.

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
 
 
10
Column {
 
11
    id: rss_item_delegate
 
12
//    width: units.gu(50)
 
13
//    height: units.gu(75)
 
14
 
 
15
//    height: parent.height
 
16
    spacing: units.gu(3)
 
17
 
 
18
    property bool isFull: false
 
19
    property real childrenSumHeight: 0
 
20
    property real childrenMaxWidth: 0
 
21
    property int modelIndex
 
22
 
 
23
    function addItem(rss_title, rss_description, model, index)
 
24
    {
 
25
//        console.log("delegate height: ", rss_item_delegate.height) ;
 
26
        var newD = AddD.addDelegate(rss_title, ImgS.separate(rss_description), model, index);
 
27
        getChildrenRect() ;
 
28
        rss_item_delegate.width = childrenMaxWidth ;
 
29
        console.log("childrenSumHeight, column.height: ", childrenSumHeight, rss_item_delegate.height)
 
30
        console.log("children list: ", rss_item_delegate.children.length)
 
31
        if (childrenSumHeight > rss_item_delegate.height)
 
32
        {
 
33
            isFull = true ;
 
34
            newD.destroy() ;
 
35
//            rss_item_delegate.children[rss_item_delegate.children.length-1].destroy() ;
 
36
            return false ;
 
37
        }
 
38
        else
 
39
        {
 
40
            isFull = false ;
 
41
            return true ;
 
42
        }
 
43
    }
 
44
 
 
45
    function getChildrenRect()
 
46
    {
 
47
        childrenSumHeight = 0 ;
 
48
        childrenMaxWidth = 0 ;
 
49
        for (var i=0; i<rss_item_delegate.children.length; i++)
 
50
        {
 
51
            childrenSumHeight += rss_item_delegate.children[i].height ;
 
52
            if (rss_item_delegate.children[i].width > childrenMaxWidth)
 
53
            {
 
54
                childrenMaxWidth = rss_item_delegate.children[i].width
 
55
            }
 
56
        }
 
57
    }
 
58
}