Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Created April 22, 2014 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/11174995 to your computer and use it in GitHub Desktop.
Save anonymous/11174995 to your computer and use it in GitHub Desktop.
The example code
Component {
id: pageBodyDelegate
Item {
property int currBodyIndex: index
property int pageIndex: index
width: gridViewBg.width
height: pageBodies.height
Item {
id: pageBody
anchors.fill: parent
//List of all packages assigned to the current user.
Component {
id: userPackageListDelegate
Item {
id: userPackageList
property int userIndex: index
property int userNr: ((pageIndex*Lib.user_per_page) + (userIndex+1))
property User user: {
var user_list = employee_model.getUserByIndex((userNr-1));
var user = null;
if(user_list.length > 0)
user = user_list[0]
user;
}
visible: {(user != null)?true:false;}
width: (( pageBody.width / Lib.user_per_page) - columnSpacing)
height: ( navMenu.dayList.count * navMenu.dayHeight ) //calculates the height
Component {
id: packageDelegate
Item {
id: packageItem
height: navMenu.dayHeight
width: userPackageList.width
MouseArea {
id: requestDrag
drag.target: request
anchors.fill: parent
anchors.verticalCenter: parent.verticalCenter
onReleased: if (request.Drag.drop() !== Qt.IgnoreAction) console.log("Accepted!");
//Item to drag
Rectangle {
color: 'lightgreen'
anchors.fill: parent
}
}
//Drag item
Rectangle {
id: request
objectName: {
var current_package = model.modelData;
"Package " + current_package.fplz
}
width: packageItem.width
height: packageItem.height
color: 'gray'
opacity: 0
anchors {
horizontalCenter: parent.horizontalCenter;
verticalCenter: parent.verticalCenter
}
Drag.active: requestDrag.drag.active
Drag.hotSpot.x: width / 2
Drag.hotSpot.y: height / 2
states: [
State {
when: request.Drag.active
PropertyChanges {
target: request
opacity: 0.5
}
AnchorChanges {
target: request
anchors.horizontalCenter: undefined
anchors.verticalCenter: undefined
}
}
]
}
}
}
Rectangle {
id: packageListContainer
anchors.fill: parent
color: "transparent"
Column {
spacing: 1
Repeater {
z: 10
model: {
if(user !== null)
{
if(user.user_id != "")
{
var assignedPackageList = employee_model.getAssignedPackagesByUser(user.user_id);
}
assignedPackageList;
}
}
delegate: packageDelegate
}
}
DropArea {
id: userDropArea
objectName: "DropArea" + index
width: (( pageBody.width / Lib.user_per_page) - columnSpacing)
height: pageBody.height
onDropped: {
console.log("Dropped " + drop.source.objectName + " on " + Drag.source.objectName);
//drop.source.color = targetChunk.color;
drop.accept();
}
}
}
}
}
ScrollView {
id:grid_view
anchors.fill: parent
flickableItem.interactive: true
flickableItem.flickableDirection: Flickable.VerticalFlick
flickableItem.contentY: {
if(currBodyIndex != pageSlider.currentIndex) //only update the contentY if the scrollview is not the currently shown
{
bodyContentY
}
}
flickableItem.onContentYChanged: {
bodyContentY = grid_view.flickableItem.contentY
}
Row {
spacing: columnSpacing
Repeater {
model: Lib.user_per_page
delegate: userPackageListDelegate
}
}
style: ScrollViewStyle {
transientScrollBars: true
handle: Item {
implicitWidth: 14
implicitHeight: 26
Rectangle {
color: "#424246"
anchors.fill: parent
anchors.topMargin: 6
anchors.leftMargin: 4
anchors.rightMargin: 4
anchors.bottomMargin: 6
}
}
scrollBarBackground: Item {
implicitWidth: 14
implicitHeight: 26
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment