Guest User

SearchField

a guest
Jul 22nd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 0.95 KB | None | 0 0
  1. SearchField {
  2.         id: searchField
  3.  
  4.         readonly property bool searchIsActive: text.length > 0
  5.         property Item currentView: searchIsActive ? listView : gridView
  6.  
  7.         parent: currentView.contentItem
  8.         onParentChanged: forceActiveFocus()
  9.  
  10.         y: currentView.headerItem.y
  11.         width: currentView.width
  12.  
  13.         placeholderText: qsTr("Search")
  14.     }
  15.  
  16.     SilicaGridView {
  17.         id: gridView
  18.         anchors.fill: parent
  19.         visible: !searchField.searchIsActive
  20.  
  21.         // Placeholder for searchField
  22.         header: Item {
  23.             width: gridView.width
  24.             height: searchField.height
  25.         }
  26.  
  27.         ...
  28.     }
  29.  
  30.     SilicaListView {
  31.         id: listView
  32.         anchors.fill: parent
  33.         visible: searchField.searchIsActive
  34.  
  35.         // Placeholder for searchField
  36.         header: Item {
  37.             width: gridView.width
  38.             height: searchField.height
  39.         }
  40.  
  41.         ...
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment