-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from neochapay/master
Add ListView
- Loading branch information
Showing
10 changed files
with
429 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import QtQuick 2.1 | ||
import QtQuick.Controls 1.0 | ||
import QtQuick.Controls.Nemo 1.0 | ||
import QtQuick.Controls.Styles.Nemo 1.0 | ||
|
||
Page { | ||
id: listViewPage | ||
|
||
headerTools: HeaderToolsLayout { showBackButton: false; title: "MediumListView" } | ||
|
||
|
||
ListModel { | ||
id: animalsModel | ||
ListElement { name: "Ant"; desc: "Small description"; size: "Tiny" } | ||
ListElement { name: "Flea"; desc: ""; size: "Tiny" } | ||
ListElement { name: "Parrot"; desc: ""; size: "Small" } | ||
ListElement { name: "Guinea pig"; desc: "The guinea pig, cavy or domestic guinea pig, or cuy for livestock breeds, is a species of rodent belonging to the family Caviidae and the genus Cavia"; size: "Small" } | ||
ListElement { name: "Rat"; desc: ""; size: "Small" } | ||
ListElement { name: "Butterfly"; desc: ""; size: "Small" } | ||
ListElement { name: "Dog"; desc: ""; size: "Medium" } | ||
ListElement { name: "Cat"; desc: ""; size: "Medium" } | ||
ListElement { name: "Pony"; desc: ""; size: "Medium" } | ||
ListElement { name: "Koala"; desc: ""; size: "Medium" } | ||
ListElement { name: "Horse"; desc: ""; size: "Large" } | ||
ListElement { name: "Tiger"; desc: ""; size: "Large" } | ||
ListElement { name: "Giraffe"; desc: ""; size: "Large" } | ||
ListElement { name: "Elephant"; desc: ""; size: "Huge" } | ||
ListElement { name: "Whale"; desc: ""; size: "Huge" } | ||
} | ||
|
||
ListView { | ||
id: view | ||
anchors.fill: parent | ||
clip: true | ||
model: animalsModel | ||
delegate: ListViewItemWithActions { | ||
label: name | ||
description: desc | ||
} | ||
section.property: "size" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import QtQuick 2.1 | ||
import QtQuick.Controls 1.0 | ||
import QtGraphicalEffects 1.0 | ||
import QtQuick.Controls.Styles.Nemo 1.0 | ||
|
||
ListView { | ||
id: listView | ||
|
||
signal hideAllActions(int hideIndex) | ||
|
||
section.criteria: ViewSection.FullString | ||
section.delegate: Component{ | ||
id: sectionHeading | ||
Rectangle { | ||
width: listView.width | ||
height: 44 | ||
color: "black" | ||
|
||
Text { | ||
id: sectionText | ||
text: section | ||
font.capitalization: Font.AllUppercase | ||
font.pixelSize: 20 | ||
color: "white" | ||
anchors{ | ||
left: parent.left | ||
leftMargin: 10 | ||
verticalCenter: parent.verticalCenter | ||
} | ||
} | ||
|
||
Rectangle{ | ||
id: line | ||
height: 1 | ||
color: "white" | ||
width: listView.width-sectionText.width-30 | ||
anchors{ | ||
left: sectionText.right | ||
leftMargin: 10 | ||
verticalCenter: sectionText.verticalCenter | ||
} | ||
} | ||
} | ||
} | ||
|
||
Item{ | ||
id: bottom | ||
width: parent.width | ||
height: 30 | ||
anchors.bottom: parent.bottom | ||
|
||
visible: listView.contentHeight >= listView.height | ||
|
||
LinearGradient{ | ||
anchors.fill: parent | ||
start: Qt.point(0, 0) | ||
end: Qt.point(0, 30) | ||
gradient: Gradient { | ||
GradientStop { position: 0.0; color: "transparent" } | ||
GradientStop { position: 1.0; color: "black" } | ||
} | ||
|
||
} | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
import QtQuick 2.1 | ||
import QtQuick.Controls.Nemo 1.0 | ||
|
||
import QtGraphicalEffects 1.0 | ||
|
||
Item { | ||
id: root | ||
width: parent.width | ||
height: 60 | ||
|
||
property string label: "" | ||
|
||
property string description: "" | ||
property string subdescription: "" | ||
property string icon: "" | ||
property string page: "" | ||
|
||
property alias actions: actionsLoader.sourceComponent | ||
|
||
signal clicked | ||
|
||
function hideAllActions() { | ||
root.ListView.view.hideAllActions(index) | ||
} | ||
|
||
Connections { | ||
target: root.ListView.view | ||
onHideAllActions: { | ||
if (hideIndex != index) { | ||
listArea.x = 0 | ||
} | ||
} | ||
} | ||
|
||
Rectangle{ | ||
id: actionsArea | ||
color: "#474747" | ||
|
||
anchors.right: listArea.left | ||
|
||
height: listArea.height | ||
width: childrenRect.width | ||
|
||
Loader { | ||
id: actionsLoader | ||
} | ||
} | ||
|
||
Rectangle{ | ||
id: listArea | ||
width: root.width | ||
height: root.height | ||
color: "transparent" | ||
|
||
Behavior on x{ | ||
NumberAnimation { duration: 200} | ||
} | ||
|
||
Rectangle { | ||
anchors.fill: parent | ||
color: "#11ffffff" | ||
visible: mouse.pressed | ||
} | ||
|
||
Image{ | ||
id: itemIcon | ||
height: parent.height-10 | ||
width: height | ||
anchors{ | ||
left: parent.left | ||
leftMargin: 20 | ||
top: parent.top | ||
topMargin: 5 | ||
} | ||
|
||
sourceSize.width: width | ||
sourceSize.height: height | ||
|
||
source: (icon != "") ? icon : "images/listview-icon-template-s.svg" | ||
//visible: (icon != "") | ||
} | ||
|
||
Rectangle{ | ||
id: dataArea | ||
width: parent.width-itemIcon.width-arrowItem.width-60 | ||
height: labelItem.height+(description != "" ? descriptionItem.height : 0)+(subdescription != "" ? subDescriptionItem.height : 0) | ||
clip: true | ||
|
||
anchors{ | ||
left:itemIcon.right | ||
leftMargin: 20 | ||
verticalCenter: itemIcon.verticalCenter | ||
} | ||
color: "transparent" | ||
|
||
Text { | ||
id: labelItem | ||
color: "#ffffff" | ||
text: label | ||
anchors{ | ||
left: parent.left | ||
right: parent.right | ||
} | ||
font.pixelSize: 30 | ||
clip: true | ||
} | ||
|
||
Text{ | ||
id: descriptionItem | ||
color: "#ffffff" | ||
text: description | ||
anchors{ | ||
left: parent.left | ||
right: parent.right | ||
top: labelItem.bottom | ||
} | ||
font.pixelSize: 18 | ||
clip: true | ||
visible: description != "" | ||
} | ||
|
||
Text{ | ||
id: subDescriptionItem | ||
color: "#ffffff" | ||
text: subdescription | ||
anchors{ | ||
left: parent.left | ||
right: parent.right | ||
top: descriptionItem.bottom | ||
} | ||
font.pixelSize: 18 | ||
clip: true | ||
visible: subdescription != "" | ||
} | ||
|
||
Item{ | ||
width: 15 | ||
height: parent.height | ||
anchors{ | ||
top: parent.top | ||
right: parent.right | ||
} | ||
visible: !mouse.pressed | ||
LinearGradient{ | ||
anchors.fill: parent | ||
start: Qt.point(0, 0) | ||
end: Qt.point(15, 0) | ||
gradient: Gradient { | ||
GradientStop { position: 0.0; color: "transparent" } | ||
GradientStop { position: 1.0; color: "black" } | ||
} | ||
} | ||
} | ||
} | ||
|
||
Image { | ||
id: arrowItem | ||
height: parent.height-10 | ||
width: height | ||
|
||
anchors{ | ||
right: parent.right | ||
rightMargin: 20 | ||
verticalCenter: parent.verticalCenter | ||
} | ||
|
||
sourceSize.width: width | ||
sourceSize.height: height | ||
|
||
source: "images/listview-icon-arrow.svg" | ||
//visible: (page != "") | ||
} | ||
|
||
MouseArea { | ||
id: mouse | ||
anchors.fill: parent | ||
onClicked: { | ||
//if actions is hide | ||
if(listArea.x === 0) | ||
{ | ||
root.clicked() | ||
} | ||
else | ||
{ | ||
listArea.x = 0 | ||
} | ||
} | ||
|
||
onPressed: { | ||
hideAllActions() | ||
} | ||
|
||
onPressAndHold: { | ||
if (actionsLoader.item) { | ||
listArea.x = actionsArea.width | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.