~bzoltan/kubuntu-packaging/decouple_cmake_plugin

« back to all changes in this revision

Viewing changes to src/plugins/qmlprofiler/qml/CategoryLabel.qml

  • Committer: Timo Jyrinki
  • Date: 2013-12-02 09:16:15 UTC
  • mfrom: (1.1.29)
  • Revision ID: timo.jyrinki@canonical.com-20131202091615-xbj1os1f604ber1m
New upstream release candidate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
 
4
** Contact: http://www.qt-project.org/legal
 
5
**
 
6
** This file is part of Qt Creator.
 
7
**
 
8
** Commercial License Usage
 
9
** Licensees holding valid commercial Qt licenses may use this file in
 
10
** accordance with the commercial license agreement provided with the
 
11
** Software or, alternatively, in accordance with the terms contained in
 
12
** a written agreement between you and Digia.  For licensing terms and
 
13
** conditions see http://qt.digia.com/licensing.  For further information
 
14
** use the contact form at http://qt.digia.com/contact-us.
 
15
**
 
16
** GNU Lesser General Public License Usage
 
17
** Alternatively, this file may be used under the terms of the GNU Lesser
 
18
** General Public License version 2.1 as published by the Free Software
 
19
** Foundation and appearing in the file LICENSE.LGPL included in the
 
20
** packaging of this file.  Please review the following information to
 
21
** ensure the GNU Lesser General Public License version 2.1 requirements
 
22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 
23
**
 
24
** In addition, as a special exception, Digia gives you certain additional
 
25
** rights.  These rights are described in the Digia Qt LGPL Exception
 
26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
27
**
 
28
****************************************************************************/
 
29
 
 
30
import QtQuick 2.1
 
31
 
 
32
Item {
 
33
    id: labelContainer
 
34
    property string text: qmlProfilerModelProxy.categoryLabel(modelIndex, categoryIndex)
 
35
    property bool expanded: false
 
36
    property int categoryIndex: qmlProfilerModelProxy.correctedCategoryIndexForModel(modelIndex, index)
 
37
    property int modelIndex: qmlProfilerModelProxy.modelIndexForCategory(index);
 
38
 
 
39
    property var descriptions: []
 
40
    property var extdescriptions: []
 
41
    property var eventIds: []
 
42
 
 
43
    visible: qmlProfilerModelProxy.categoryDepth(modelIndex, categoryIndex) > 0;
 
44
 
 
45
    height: root.singleRowHeight
 
46
    width: 150
 
47
 
 
48
    onExpandedChanged: {
 
49
        qmlProfilerModelProxy.setExpanded(modelIndex, categoryIndex, expanded);
 
50
        backgroundMarks.requestRedraw();
 
51
        getDescriptions();
 
52
        updateHeight();
 
53
    }
 
54
 
 
55
    Component.onCompleted: {
 
56
        updateHeight();
 
57
    }
 
58
 
 
59
    function updateHeight() {
 
60
        if (expanded != qmlProfilerModelProxy.expanded(modelIndex, categoryIndex))
 
61
            expanded = qmlProfilerModelProxy.expanded(modelIndex, categoryIndex);
 
62
        height = root.singleRowHeight * qmlProfilerModelProxy.categoryDepth(modelIndex, categoryIndex);
 
63
    }
 
64
 
 
65
    function getDescriptions() {
 
66
        visible = qmlProfilerModelProxy.categoryDepth(modelIndex, categoryIndex) > 0;
 
67
        if (!visible)
 
68
            return;
 
69
 
 
70
        var desc=[];
 
71
        var ids=[];
 
72
        var extdesc=[];
 
73
        var labelList = qmlProfilerModelProxy.getLabelsForCategory(modelIndex, categoryIndex);
 
74
        for (var i = 0; i < labelList.length; i++ ) {
 
75
            desc[i] = labelList[i].description;
 
76
            ids[i] = labelList[i].id;
 
77
            extdesc[i] = labelList[i].displayName + ":" + labelList[i].description;
 
78
        }
 
79
        descriptions = desc;
 
80
        eventIds = ids;
 
81
        extdescriptions = extdesc;
 
82
        updateHeight();
 
83
    }
 
84
 
 
85
    Connections {
 
86
        target: qmlProfilerModelProxy
 
87
        onExpandedChanged: {
 
88
            updateHeight();
 
89
        }
 
90
 
 
91
        onStateChanged: {
 
92
            getDescriptions();
 
93
        }
 
94
    }
 
95
 
 
96
    Text {
 
97
        id: txt
 
98
        x: 5
 
99
        font.pixelSize: 12
 
100
        text: labelContainer.text
 
101
        color: "#232323"
 
102
        height: root.singleRowHeight
 
103
        width: 140
 
104
        verticalAlignment: Text.AlignVCenter
 
105
    }
 
106
 
 
107
    Rectangle {
 
108
        height: 1
 
109
        width: parent.width
 
110
        color: "#999999"
 
111
        anchors.bottom: parent.bottom
 
112
        z: 2
 
113
    }
 
114
 
 
115
    Column {
 
116
        y: root.singleRowHeight
 
117
        visible: expanded
 
118
        Repeater {
 
119
            model: descriptions.length
 
120
            Rectangle {
 
121
                width: labelContainer.width
 
122
                height: root.singleRowHeight
 
123
                color: "#eaeaea"
 
124
                border.width: 1
 
125
                border.color:"#c8c8c8"
 
126
                Text {
 
127
                    height: root.singleRowHeight
 
128
                    x: 5
 
129
                    width: 140
 
130
                    text: descriptions[index]
 
131
                    textFormat: Text.PlainText
 
132
                    elide: Text.ElideRight
 
133
                    verticalAlignment: Text.AlignVCenter
 
134
                }
 
135
                MouseArea {
 
136
                    anchors.fill: parent
 
137
                    hoverEnabled: true
 
138
                    onEntered: changeToolTip(extdescriptions[index]);
 
139
                    onExited: changeToolTip("");
 
140
                    onClicked: {
 
141
                        if (mouse.modifiers & Qt.ShiftModifier)
 
142
                            view.selectPrevFromId(modelIndex,eventIds[index]);
 
143
                        else
 
144
                            view.selectNextFromId(modelIndex,eventIds[index]);
 
145
                    }
 
146
                }
 
147
            }
 
148
        }
 
149
    }
 
150
 
 
151
    Image {
 
152
        source: expanded ? "arrow_down.png" : "arrow_right.png"
 
153
        x: parent.width - 12
 
154
        y: root.singleRowHeight / 2 - height / 2
 
155
        MouseArea {
 
156
            anchors.fill: parent
 
157
            anchors.rightMargin: -10
 
158
            anchors.leftMargin: -10
 
159
            anchors.topMargin: -10
 
160
            anchors.bottomMargin: -10
 
161
            onClicked: {
 
162
                expanded = !expanded;
 
163
            }
 
164
        }
 
165
    }
 
166
}