summaryrefslogtreecommitdiff
path: root/qml/SideThreadList.qml
blob: 872d6b0ef371768fdec74791b7f83a3ccb620dc2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import QtQuick 2.2
import QtQuick.Window 2.1;
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1

import secushare 1.0

Rectangle {
    id: root
    color: Settings.rightSideColor

    property int noTab: -1
    property int threadTab: 4

    property int mainIndex: -1
    property int currentIndex: -1

    property var selectedThread: null
    property var selectedPlace: null

    onMainIndexChanged: {
        console.log ("thread list: main index changed:", mainIndex)
        if (threadTab != mainIndex)
        {
            threadList.currentIndex = -1
        }
    }

    ColumnLayout {
        width: parent.width
        height: parent.height

        Rectangle { height: 5 }

        Rectangle {
            id: newThreadButton
            anchors.right: parent.right
            width: parent.width - 8
            height: 30
            color: "black"

            Image {
                height: parent.height - 4
                anchors.centerIn: parent
                fillMode: Image.PreserveAspectFit
                source: "images/add.png"
            }

            MouseArea {
                anchors.fill: parent
                onClicked: {
                    selectedThread = null
                    currentIndex = threadTab
                }
            }
        }

        ListModel {
            id: threadListModel

            // FIXME: These threads are just mock-ups,
            //	      they should actually be coming from
            //	      the user's subscribed places!	-lynX
            //

            ListElement {
                name: "Things you knew this morning"
                image: "images/demo/Conffeti-background.jpg"
            }
            ListElement {
                name: "Did you see the NSA graffiti"
                image: "images/demo/ubuntu-wallpaper.jpg"
            }
            ListElement {
                name: "Popcorn"
                image: "images/demo/popcorn-background.jpg"
            }
        }

        ListView {
            id: threadList
            //currentIndex: -1

            width: 186
            //Layout.fillWidth: true
            Layout.fillHeight: true
            anchors.right: parent.right

            spacing: 15
            clip: true

            //model: threadListModel
            model: selectedPlace.threadListModel
            delegate: threadListDelegate
            focus: true

            onCurrentIndexChanged: {
                selectedThread = model.thread(currentIndex)
                if (selectedThread)
                {
                    root.currentIndex = threadTab
                }
            }

            Component {
                id: threadListDelegate

                Item {
                    id: threadItem
                    width: threadTab == root.currentIndex && threadItem.ListView.isCurrentItem ? 186 : 170
                    height: 170

                    Rectangle {
                        id: threadItemInside
                        anchors.fill: parent
                        anchors.topMargin: 20
                        opacity: 1.0

                        color: threadTab == root.currentIndex && threadItem.ListView.isCurrentItem ? "white" : "black"

                        Image {
                            id: threadMiniImage
                            source: "images/demo/ubuntu-wallpaper.jpg" // FIXME
                            fillMode: Image.PreserveAspectCrop
                            height: 60
                            width: 160
                            anchors.left: parent.left
                            anchors.leftMargin: 5
                            anchors.top: parent.top
                            anchors.topMargin: 5
                        }

                        Text {
                            anchors.top: threadMiniImage.bottom
                            id: contactInfo
                            text: name
                            width: 160
                            height: 80
                            anchors.left: parent.left
                            anchors.leftMargin: 5

                            wrapMode : Text.Wrap
                            elide : Text.ElideRight
                            color: threadTab == root.currentIndex && threadItem.ListView.isCurrentItem ? "black" : "white"

                            font.family: ubuntuBIFont.name
                            font.pointSize: 18
                            font.letterSpacing : -2
                        }

                        MouseArea {
                            id:ma
                            anchors.fill: parent
                            onClicked: threadList.currentIndex = index
                        }
                    }

                    Rectangle {
                        id: indicator
                        radius: 35
                        color: "#EFC208"
                        anchors.left: threadItemInside.left
                        anchors.leftMargin: 125
                        anchors.top: parent.top
                        anchors.topMargin: 10
                        border.color: "black"
                        border.width: 3
                        height: 35
                        width: 35
                        visible: threadTab == root.currentIndex && threadItem.ListView.isCurrentItem ? false : true

                        Text {
                            anchors.centerIn: parent
                            text: "12"
                            font.family: ubuntuFont.name
                            font.pointSize: 14
                        }
                    }
                }
            }
        }
    }
}