MainPageDelegate.qml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2012 Róbert Márki
  4. **
  5. ** This file is part of Web Feeds.
  6. **
  7. ** Web Feeds is free software: you can redistribute it and/or modify
  8. ** it under the terms of the GNU General Public License as published by
  9. ** the Free Software Foundation, either version 3 of the License, or
  10. ** (at your option) any later version.
  11. **
  12. ** Web Feeds is distributed in the hope that it will be useful,
  13. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ** GNU General Public License for more details.
  16. **
  17. ** You should have received a copy of the GNU General Public License
  18. ** along with Web Feeds. If not, see <http://www.gnu.org/licenses/>.
  19. ****************************************************************************/
  20. import QtQuick 1.1
  21. import com.nokia.meego 1.0
  22. import "../../shared/qml" as Shared
  23. import "../../shared/qml/UIConstants.js" as UIConstants
  24. Item {
  25. id: root
  26. signal released(int row)
  27. signal holded(int row)
  28. property int titleSize: UIConstants.LIST_TILE_SIZE
  29. property int titleWeight: Font.Bold
  30. property color titleColor: UIConstants.LIST_TITLE_COLOR
  31. property int subtitleSize: UIConstants.LIST_SUBTILE_SIZE
  32. property int subtitleWeight: Font.Light
  33. property color subtitleColor: UIConstants.LIST_SUBTITLE_COLOR
  34. height: UIConstants.DEFAULT_DELEGATE_HEIGHT
  35. width: parent.width
  36. BorderImage {
  37. id: background
  38. anchors.fill: parent
  39. // Fill page porders
  40. anchors.leftMargin: -UIConstants.DEFAULT_MARGIN
  41. anchors.rightMargin: -UIConstants.DEFAULT_MARGIN
  42. visible: mouseArea.pressed
  43. source: "image://theme/meegotouch-panel-background-pressed"
  44. }
  45. Shared.Separator {
  46. id: separator
  47. anchors.top: parent.top
  48. anchors.left: parent.left
  49. anchors.leftMargin: UIConstants.DEFAULT_MARGIN
  50. anchors.right: parent.right
  51. anchors.rightMargin: UIConstants.DEFAULT_MARGIN
  52. visible: index
  53. }
  54. Item {
  55. id: conents
  56. anchors.top: parent.top
  57. anchors.bottom: parent.bottom
  58. anchors.left: parent.left
  59. anchors.leftMargin: UIConstants.DEFAULT_MARGIN
  60. anchors.right: parent.right
  61. anchors.rightMargin: UIConstants.DEFAULT_MARGIN
  62. Image {
  63. id: iconImage
  64. anchors.left: parent.left
  65. anchors.verticalCenter: parent.verticalCenter
  66. visible: model.iconSource
  67. width: UIConstants.LIST_ICON_SIZE
  68. height: UIConstants.LIST_ICON_SIZE
  69. source: model.iconSource
  70. asynchronous: true
  71. }
  72. Label {
  73. id: mainText
  74. anchors.left: iconImage.right
  75. anchors.leftMargin: UIConstants.LIST_ITEM_SPACING
  76. anchors.right: parent.right
  77. anchors.verticalCenter: parent.verticalCenter
  78. text: model.title
  79. font.weight: root.titleWeight
  80. font.pixelSize: root.titleSize
  81. color: root.titleColor
  82. width: parent.width
  83. elide: Text.ElideRight
  84. wrapMode: Text.Wrap
  85. maximumLineCount: 2
  86. }
  87. }
  88. MouseArea {
  89. id: mouseArea;
  90. anchors.fill: parent
  91. onReleased: {
  92. if(!mouse.wasHeld)
  93. root.released(index);
  94. }
  95. onPressAndHold: {
  96. root.holded(index);
  97. }
  98. }
  99. }