2010-02-16 19:07:59 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-02-16 17:24:18 +02:00
|
|
|
import Qt 4.6
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: itemView
|
|
|
|
|
|
|
|
|
|
property var style
|
|
|
|
|
|
|
|
|
|
width: GridView.view.cellWidth
|
|
|
|
|
height: style.cellHeight
|
|
|
|
|
|
2010-02-19 14:21:36 +02:00
|
|
|
signal itemPressed()
|
2010-02-16 17:24:18 +02:00
|
|
|
signal itemDragged()
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.left: parent.left
|
2010-02-17 11:58:33 +01:00
|
|
|
anchors.right: parent.right
|
2010-02-16 17:24:18 +02:00
|
|
|
height: 1
|
2010-02-17 11:56:16 +01:00
|
|
|
color: style.gridLineLighter
|
2010-02-16 17:24:18 +02:00
|
|
|
}
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
height: 1
|
2010-02-17 11:56:16 +01:00
|
|
|
color: style.gridLineDarker
|
2010-02-16 17:24:18 +02:00
|
|
|
}
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
width: 1
|
2010-02-17 11:56:16 +01:00
|
|
|
color: style.gridLineLighter
|
2010-02-16 17:24:18 +02:00
|
|
|
}
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
width: 1
|
2010-02-17 11:56:16 +01:00
|
|
|
color: style.gridLineDarker
|
|
|
|
|
}
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.top:parent.top
|
|
|
|
|
anchors.right:parent.right
|
|
|
|
|
width:1
|
|
|
|
|
height:1
|
|
|
|
|
color: style.backgroundColor
|
|
|
|
|
}
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.bottom:parent.bottom
|
|
|
|
|
anchors.left:parent.left
|
|
|
|
|
width:1
|
|
|
|
|
height:1
|
|
|
|
|
color: style.backgroundColor
|
2010-02-16 17:24:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Image {
|
|
|
|
|
id: itemIcon
|
|
|
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: style.cellMargin
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
|
|
width: itemLibraryIconWidth
|
|
|
|
|
height: itemLibraryIconHeight
|
|
|
|
|
pixmap: itemPixmap
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
id: text
|
|
|
|
|
|
|
|
|
|
anchors.top: itemIcon.bottom
|
|
|
|
|
anchors.topMargin: itemView.style.cellSpacing
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
width: style.textWidth
|
|
|
|
|
height: style.textHeight
|
|
|
|
|
|
|
|
|
|
verticalAlignment: "AlignVCenter"
|
|
|
|
|
horizontalAlignment: "AlignHCenter"
|
|
|
|
|
text: itemName
|
|
|
|
|
// workaround: text color not updated when 'style' var finally assigned
|
|
|
|
|
color: style.itemNameTextColor
|
|
|
|
|
Component.onCompleted: text.color = style.itemNameTextColor
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MouseRegion {
|
|
|
|
|
id: mouseRegion
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
2010-02-19 14:21:36 +02:00
|
|
|
property bool reallyPressed: false
|
|
|
|
|
property int pressedX
|
|
|
|
|
property int pressedY
|
|
|
|
|
|
|
|
|
|
onPressed: {
|
|
|
|
|
reallyPressed = true
|
|
|
|
|
pressedX = mouse.x
|
|
|
|
|
pressedY = mouse.y
|
|
|
|
|
itemPressed()
|
2010-02-16 17:24:18 +02:00
|
|
|
}
|
2010-02-19 14:21:36 +02:00
|
|
|
onPositionChanged: {
|
|
|
|
|
if (reallyPressed &&
|
|
|
|
|
(Math.abs(mouse.x - pressedX) > 2 ||
|
|
|
|
|
Math.abs(mouse.y - pressedY) > 2)) {
|
|
|
|
|
itemDragged()
|
|
|
|
|
reallyPressed = false;
|
|
|
|
|
}
|
2010-02-16 17:24:18 +02:00
|
|
|
}
|
2010-02-19 14:21:36 +02:00
|
|
|
onReleased: reallyPressed = false
|
2010-02-16 17:24:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|