Advertisement
Guest User

ScrollView

a guest
Feb 25th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 7.21 KB | None | 0 0
  1.         Rectangle {
  2.             id: mainCategories // mainCtegory
  3.             color: "white"
  4.             anchors.top: header.bottom
  5.             anchors.left: parent.left
  6.             anchors.right: parent.right
  7.             anchors.bottom: parent.bottom
  8.             z: -10
  9.  
  10.             ScrollView {
  11.                 id: listLayout
  12.                 x: 0
  13.                 y: 0
  14.                 anchors.fill: parent
  15.                 property int numberCollapsed: -1
  16.  
  17.                 ListView {
  18.                     id: listViewLeft
  19.                     x: 0
  20.                     y: 0
  21.  
  22.                     property ListModel categoryListModel: ListModel {
  23.                         id: leftCategories
  24.                     }
  25.                     delegate: categoryDelegateLeft
  26.                 }
  27.             }
  28.             //список
  29.             Component {
  30.                 id: categoryDelegateLeft
  31.                 Column {
  32.                     width: 600
  33.  
  34.                     Rectangle {
  35.                         height: 50
  36.                         width: 600
  37.  
  38.                         Text {
  39.                             anchors.verticalCenter: parent.verticalCenter
  40.                             x: 50
  41.                             font.pixelSize: 16
  42.                             font.family: "Droid sans"
  43.                             text: title
  44.                             color: "#325A81"
  45.                             wrapMode: Text.WordWrap
  46.                             MouseArea {
  47.                                 anchors.fill: parent
  48.                                 cursorShape: Qt.PointingHandCursor
  49.                                 onClicked: {
  50.                                     funcCategoris.categoryId = product_category_id
  51.                                     mainCategories.visible = false
  52.                                     funcCategoris.visible = true
  53.                                     funcCategoris.idCategory = product_category_id
  54.                                     funcCategoris.setModel()
  55.                                 }
  56.                             }
  57.                         }
  58.  
  59.                         Image {
  60.                             id: arrowImage
  61.                             source: arrow
  62.                             width: 30
  63.                             height: 30
  64.                             anchors.left: parent.left
  65.                             anchors.leftMargin: 15
  66.                             anchors.verticalCenter: parent.verticalCenter
  67.  
  68.  
  69.                             MouseArea {
  70.                                 anchors.fill: parent
  71.                                 cursorShape: Qt.PointingHandCursor
  72.                                 // Toggle the 'collapsed' property
  73.                                 onClicked: {
  74.                                     listViewLeft.currentIndex = index
  75.                                     leftCategories.setProperty(index,
  76.                                                                "collapsed",
  77.                                                                !collapsed)
  78.  
  79.                                     if (listLayout.numberCollapsed != -1
  80.                                             && listLayout.numberCollapsed != index) {
  81.                                         leftCategories.setProperty(
  82.                                                     listLayout.numberCollapsed,
  83.                                                     "collapsed", !collapsed)
  84.                                         leftCategories.setProperty(
  85.                                                     listLayout.numberCollapsed,
  86.                                                     "arrow", "content/arrow_down.png")
  87.                                         arrowImage.source = "content/arrow_down.png"
  88.                                         listLayout.numberCollapsed = index
  89.                                     }
  90.                                     if (listLayout.numberCollapsed == -1) {
  91.                                         listLayout.numberCollapsed = index
  92.                                     }
  93.  
  94.                                     if (listLayout.numberCollapsed == index) {
  95.                                         if (!collapsed) {
  96.                                             parent.source = "content/arrow_up.png"
  97.                                         } else {
  98.                                             parent.source = "content/arrow_down.png"
  99.                                         }
  100.                                     }
  101.                                 }
  102.                             }
  103.                         }
  104.                     }
  105.  
  106.                     Loader {
  107.                         id: subItemLoaderLeft
  108.                         onVisibleChildrenChanged: {
  109.                             arrowImage.source = arrow
  110.                         }
  111.  
  112.                         // This is a workaround for a bug/feature in the Loader element. If sourceComponent is set to null
  113.                         // the Loader element retains the same height it had when sourceComponent was set. Setting visible
  114.                         // to false makes the parent Column treat it as if it's height was 0.
  115.                         visible: !collapsed
  116.                         property variant subItemModel: subItems
  117.                         sourceComponent: collapsed ? null : subItemColumnDelegate
  118.                         onStatusChanged: if (status == Loader.Ready) {
  119.                                              item.model = subItemModel
  120.                                          }
  121.  
  122.                     }
  123.                 }
  124.             }
  125.  
  126.             Component {
  127.                 id: subItemColumnDelegate
  128.                 Column {
  129.                     property alias model: subItemRepeater.model
  130.                     width: 384
  131.                     Repeater {
  132.                         id: subItemRepeater
  133.                         delegate: Rectangle {
  134.                             x: 10
  135.                             height: 30
  136.                             width: 670
  137.  
  138.                             Text {
  139.                                 anchors.verticalCenter: parent.verticalCenter
  140.                                 x: 30
  141.                                 width: 670
  142.                                 height: 30
  143.                                 font.pixelSize: 14
  144.                                 font.family: "Droid sans"
  145.                                 color: "#325A81"
  146.                                 text: title
  147.                                 wrapMode: Text.WordWrap
  148.                                 MouseArea {
  149.                                     anchors.fill: parent
  150.                                     cursorShape: Qt.PointingHandCursor
  151.                                     onClicked: {
  152.                                         console.log(product_category_id)
  153.                                         mainCategories.visible = false
  154.                                         prodCategoris.visible = true
  155.                                         prodCategoris.setModel(
  156.                                                     product_category_id)
  157.                                     }
  158.                                 }
  159.                             }
  160.                         }
  161.                     }
  162.                 }
  163.             }
  164.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement