HistogramColumn.qml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**
  2. * Copyright © 2010 Digia Plc
  3. * Copyright © 2010 Nokia Corporation
  4. *
  5. * All rights reserved.
  6. *
  7. * Nokia and Nokia Connecting People are registered trademarks of
  8. * Nokia Corporation.
  9. * Java and all Java-based marks are trademarks or registered
  10. * trademarks of
  11. * Sun Microsystems, Inc. Other product and company names
  12. * mentioned herein may be
  13. * trademarks or trade names of their respective owners.
  14. *
  15. *
  16. * Subject to the conditions below, you may, without charge:
  17. *
  18. * · Use, copy, modify and/or merge copies of this software and
  19. * associated documentation files (the "Software")
  20. *
  21. * · Publish, distribute, sub-licence and/or sell new software
  22. * derived from or incorporating the Software.
  23. *
  24. *
  25. * This file, unmodified, shall be included with all copies or
  26. * substantial portions
  27. * of the Software that are distributed in source code form.
  28. *
  29. * The Software cannot constitute the primary value of any new
  30. * software derived
  31. * from or incorporating the Software.
  32. *
  33. * Any person dealing with the Software shall not misrepresent
  34. * the source of the Software.
  35. *
  36. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  37. * KIND, EXPRESS OR IMPLIED,
  38. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  39. * MERCHANTABILITY, FITNESS FOR A
  40. * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  41. * AUTHORS OR COPYRIGHT
  42. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  43. * WHETHER IN AN ACTION
  44. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  45. * CONNECTION WITH THE
  46. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  47. */
  48. import Qt 4.7
  49. Rectangle {
  50. id: column
  51. property int maxHeight: structure.height
  52. property real value: 100
  53. property string label: ""
  54. property real maxValue: structure.maxValue
  55. property real targetHeight: (!rowArea.visible || rowArea.opacity==0)?0:(column.radius + Math.round(column.maxHeight*(column.value/column.maxValue)))
  56. /*onParentChanged: {
  57. targetHeight = 0;
  58. width = 0;
  59. height = 0;
  60. maxHeight = 1;
  61. maxValue = 1;
  62. color = "transparent";
  63. radius = 0;
  64. }*/
  65. color: structure.colorWhenDefault
  66. gradient: (structure.gradientDefaultOn)?structure.gradientWhenDefault:structure.nullGradient
  67. width: Math.round( ( rowArea.width - (structure.spacing*(rowArea.visibleChilds-1)) ) / rowArea.visibleChilds );
  68. height: targetHeight
  69. radius: (column.width/2)*structure.roundness
  70. smooth: true
  71. anchors.bottom: parent.bottom
  72. anchors.bottomMargin: -radius
  73. Behavior on height { SpringAnimation { id: theSpring; velocity: 500; damping: 0.15; spring: 5.0; } }
  74. MouseArea {
  75. anchors.fill: parent
  76. hoverEnabled: true
  77. onClicked: {
  78. structure.currentValue = value;
  79. structure.currentLabel = label;
  80. }
  81. onEntered: {
  82. structure.currentValue = value;
  83. structure.currentLabel = label;
  84. }
  85. }
  86. }