2010-02-16 19:07:59 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2010-02-16 19:07:59 +02:00
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
2010-02-16 19:07:59 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2010-02-16 19:07:59 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-02-16 19:07:59 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2012-09-27 10:50:54 +02:00
|
|
|
import QtQuick 1.0
|
2010-02-16 17:24:18 +02:00
|
|
|
|
2010-03-10 12:45:49 +02:00
|
|
|
// view displaying an item library grid item
|
|
|
|
|
|
2010-02-16 17:24:18 +02:00
|
|
|
Item {
|
|
|
|
|
id: itemView
|
|
|
|
|
|
2010-02-25 09:45:00 +02:00
|
|
|
// public
|
2010-03-10 12:45:49 +02:00
|
|
|
|
2010-02-19 14:21:36 +02:00
|
|
|
signal itemPressed()
|
2010-02-16 17:24:18 +02:00
|
|
|
signal itemDragged()
|
|
|
|
|
|
2010-02-25 09:45:00 +02:00
|
|
|
// internal
|
|
|
|
|
|
|
|
|
|
ItemsViewStyle { id: style }
|
2010-03-10 12:45:49 +02:00
|
|
|
|
|
|
|
|
// frame
|
2010-02-16 17:24:18 +02:00
|
|
|
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
|
2010-02-25 09:45:00 +02:00
|
|
|
anchors.topMargin: style.cellVerticalMargin
|
2010-02-16 17:24:18 +02:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
2010-03-10 12:45:49 +02:00
|
|
|
width: itemLibraryIconWidth // to be set in Qml context
|
|
|
|
|
height: itemLibraryIconHeight // to be set in Qml context
|
2010-07-13 10:11:05 +10:00
|
|
|
source: itemLibraryIconPath // to be set by model
|
2010-02-16 17:24:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
id: text
|
2010-03-18 13:17:24 +02:00
|
|
|
elide: Text.ElideMiddle
|
2010-02-16 17:24:18 +02:00
|
|
|
anchors.top: itemIcon.bottom
|
2010-02-25 09:45:00 +02:00
|
|
|
anchors.topMargin: style.cellVerticalSpacing
|
2010-03-10 12:45:49 +02:00
|
|
|
anchors.left: parent.left
|
2010-03-18 13:17:24 +02:00
|
|
|
anchors.leftMargin: style.cellHorizontalMargin
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: style.cellHorizontalMargin
|
2010-02-16 17:24:18 +02:00
|
|
|
width: style.textWidth
|
|
|
|
|
height: style.textHeight
|
|
|
|
|
|
|
|
|
|
verticalAlignment: "AlignVCenter"
|
|
|
|
|
horizontalAlignment: "AlignHCenter"
|
2010-03-10 12:45:49 +02:00
|
|
|
text: itemName // to be set by model
|
2010-02-16 17:24:18 +02:00
|
|
|
color: style.itemNameTextColor
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-05 10:19:38 +01:00
|
|
|
MouseArea {
|
2010-03-10 12:45:49 +02:00
|
|
|
id: mouseRegion
|
2010-02-16 17:24:18 +02:00
|
|
|
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 &&
|
2010-03-10 12:45:49 +02:00
|
|
|
(Math.abs(mouse.x - pressedX) +
|
|
|
|
|
Math.abs(mouse.y - pressedY)) > 3) {
|
2010-02-19 14:21:36 +02:00
|
|
|
itemDragged()
|
2010-03-10 12:45:49 +02:00
|
|
|
reallyPressed = false
|
2010-02-19 14:21:36 +02:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|