RangeDetails.qml 6.48 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
Kai Koehne's avatar
Kai Koehne committed
2
**
hjk's avatar
hjk committed
3
4
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
Kai Koehne's avatar
Kai Koehne committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
Kai Koehne's avatar
Kai Koehne committed
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
Kai Koehne's avatar
Kai Koehne committed
15
16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
23
24
25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
Kai Koehne's avatar
Kai Koehne committed
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
Kai Koehne's avatar
Kai Koehne committed
29

30
import QtQuick 1.0
Christiaan Janssen's avatar
Christiaan Janssen committed
31
32
import Monitor 1.0

33
Item {
Christiaan Janssen's avatar
Christiaan Janssen committed
34
35
    id: rangeDetails

36
    property string duration
Christiaan Janssen's avatar
Christiaan Janssen committed
37
38
39
40
    property string label
    property string type
    property string file
    property int line
41
    property int column
42
    property bool isBindingLoop
Christiaan Janssen's avatar
Christiaan Janssen committed
43

44
    property bool locked: view.selectionLocked
45

Christiaan Janssen's avatar
Christiaan Janssen committed
46
    width: col.width + 45
47
    height: col.height + 30
Christiaan Janssen's avatar
Christiaan Janssen committed
48
49
    z: 1
    visible: false
50
    x: 200
51
    y: 25
Christiaan Janssen's avatar
Christiaan Janssen committed
52

53
    property int yoffset: root.scrollY
54
55
56
57
    onYoffsetChanged: {
        y = relativey + yoffset
        fitInView();
    }
58
59
60
    property int relativey : y - yoffset
    onYChanged: relativey = y - yoffset

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
    // keep inside view
    Connections {
        target: root
        onWidthChanged: fitInView();
        onCandidateHeightChanged: fitInView();
    }

    function fitInView() {
        // don't reposition if it does not fit
        if (root.width < width || root.candidateHeight < height)
            return;

        if (x + width > root.width)
            x = root.width - width;
        if (x < 0)
            x = 0;
77
78
79
80
        if (y - yoffset + height > root.candidateHeight)
            y = root.candidateHeight - height + yoffset;
        if (y < yoffset)
            y = yoffset;
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
    // shadow
    BorderImage {
        property int px: 4
        source: "dialog_shadow.png"

        border {
            left: px; top: px
            right: px; bottom: px
        }
        width: parent.width + 2*px - 1
        height: parent.height
        x: -px + 1
        y: px + 1
    }

    // title bar
    Rectangle {
        width: parent.width
        height: 20
        color: "#55a3b8"
        radius: 5
        border.width: 1
        border.color: "#a0a0a0"
    }
    Item {
        width: parent.width+1
        height: 11
        y: 10
        clip: true
        Rectangle {
            width: parent.width-1
            height: 15
            y: -5
            color: "#55a3b8"
            border.width: 1
            border.color: "#a0a0a0"
        }
    }

Christiaan Janssen's avatar
Christiaan Janssen committed
122
123
124
    //title
    Text {
        id: typeTitle
125
        text: "  "+rangeDetails.type
Christiaan Janssen's avatar
Christiaan Janssen committed
126
        font.bold: true
127
128
129
130
131
        height: 18
        y: 2
        verticalAlignment: Text.AlignVCenter
        width: parent.width
        color: "white"
Christiaan Janssen's avatar
Christiaan Janssen committed
132
133
    }

134
135
136
137
138
139
140
141
    // Details area
    Rectangle {
        color: "white"
        width: parent.width
        height: col.height + 10
        y: 20
        border.width: 1
        border.color: "#a0a0a0"
142

143
144
145
146
147
148
149
150
        //details
        Column {
            id: col
            x: 10
            y: 5
            Detail {
                label: qsTr("Duration:")
                content: rangeDetails.duration < 1000 ? rangeDetails.duration + "μs" : Math.floor(rangeDetails.duration/10)/100 + "ms"
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
            Detail {
                opacity: content.length !== 0 ? 1 : 0
                label: qsTr("Details:")
                content: {
                    var inputString = rangeDetails.label;
                    if (inputString.length > 7 && inputString.substring(0,7) == "file://") {
                        var pos = inputString.lastIndexOf("/");
                        return inputString.substr(pos+1);
                    }
                    var maxLen = 40;
                    if (inputString.length > maxLen)
                        inputString = inputString.substring(0,maxLen)+"...";

                    return inputString;
                }
            }
            Detail {
                opacity: content.length !== 0 ? 1 : 0
                label: qsTr("Location:")
                content: {
                    var file = rangeDetails.file;
                    var pos = file.lastIndexOf("/");
                    if (pos != -1)
                        file = file.substr(pos+1);
                    return (file.length !== 0) ? (file + ":" + rangeDetails.line) : "";
                }
Christiaan Janssen's avatar
Christiaan Janssen committed
178
            }
179
180
181
182
183
            Detail {
                visible: isBindingLoop
                opacity: content.length != 0 ? 1 : 0
                label: qsTr("Binding loop detected")
            }
Christiaan Janssen's avatar
Christiaan Janssen committed
184
185
        }
    }
186

187
    MouseArea {
188
189
        width: col.width + 45
        height: col.height + 30
190
        drag.target: parent
191
192
        drag.minimumX: 0
        drag.maximumX: root.width - parent.width
193
194
        drag.minimumY: yoffset
        drag.maximumY: root.candidateHeight - parent.height + yoffset
195
        onClicked: {
196
            root.gotoSourceLocation(file, line, column);
197
            root.recenterOnItem(view.selectedItem);
198
199
200
        }
    }

201
202
203
204
205
206
207
208
209
210
    Image {
        id: lockIcon
        source: locked?"lock_closed.png" : "lock_open.png"
        anchors.top: closeIcon.top
        anchors.right: closeIcon.left
        anchors.rightMargin: 4
        width: 8
        height: 12
        MouseArea {
            anchors.fill: parent
211
            onClicked: {
212
                root.selectionLocked = !root.selectionLocked;
213
            }
214
215
216
        }
    }

217

218
219
    Text {
        id: closeIcon
220
221
        x: col.width + 30
        y: 4
222
        text:"X"
223
        color: "white"
224
225
        MouseArea {
            anchors.fill: parent
226
227
            onClicked: {
                root.hideRangeDetails();
228
                view.selectedItem = -1;
229
            }
230
231
232
        }
    }

Christiaan Janssen's avatar
Christiaan Janssen committed
233
}