EnergyView.qml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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. import "javascript/sql.js" as HCS
  50. import "javascript/energyView.js" as Graph
  51. import "../colibri"
  52. import "../colibri/gradients"
  53. import "styles"
  54. Item {
  55. id: structure
  56. property CLStyle style : StyleHomeControlSystem{}
  57. property bool dummyBool : false
  58. signal closeWindow()
  59. width: 640
  60. height: 424
  61. onDummyBoolChanged: {
  62. if( viewi2.z > 0 ) Graph.loadConsumption();
  63. }
  64. Component.onCompleted: Graph.loadConsumption();
  65. MouseArea {
  66. anchors.fill: parent;
  67. }
  68. Rectangle{
  69. id: rec
  70. width: structure.width*0.955
  71. height: structure.height*0.88
  72. color: structure.style.selectionColor
  73. anchors.horizontalCenter: parent.horizontalCenter
  74. radius:7
  75. y: energyCLTab.tabHeight
  76. }
  77. RoomExitButton {
  78. windowWidth: structure.width
  79. windowHeight: structure.height
  80. style: structure.style
  81. z: 5
  82. onClicked: structure.closeWindow();
  83. }
  84. CLTab {
  85. id: energyCLTab
  86. style: structure.style
  87. tabHeight: parent.width*0.07
  88. contentColor: "transparent"
  89. borderColor: "transparent"
  90. tabColorWhenSelected:style.selectionColor
  91. tabColor:style.colorWhenDefault
  92. headerMarginSides: parent.width*0.03
  93. anchors.fill:parent
  94. Item {
  95. id: viewi1
  96. width: parent.width
  97. height: parent.height * 1.038
  98. anchors.bottom: parent.bottom
  99. property string title : "Monthly history"
  100. Image {
  101. source: "images/control_bg_trans_420x275_png.png";
  102. anchors.fill: parent;
  103. smooth: true
  104. opacity:0.7
  105. }
  106. Rectangle {
  107. id: graph
  108. width: structure.width * 0.7
  109. height: structure.height * 0.55
  110. x: structure.width * 0.22
  111. anchors.verticalCenter: parent.verticalCenter
  112. color: "transparent"
  113. Rectangle {
  114. id: graphRect
  115. border.width: 2
  116. border.color: style.borderColor
  117. width: parent.width - border.width
  118. height: parent.height - border.width
  119. x: border.width / 2
  120. color:"transparent"
  121. CLHistogram {
  122. id: histogram
  123. width: parent.width - parent.border.width/2
  124. height: parent.height - parent.border.width/2
  125. x: parent.border.width / 2
  126. y: parent.border.width / 2
  127. style: structure.style
  128. colorWhenDefault: structure.style.textColor
  129. gradientDefaultOn: false
  130. Component.onCompleted: Graph.onStartUp()
  131. gradientWhenDefault: style.gradientWhenDefault
  132. }
  133. }
  134. }
  135. Text {
  136. text: histogram.maxValue + " - "
  137. verticalAlignment: Text.AlignVCenter
  138. anchors.right: graph.left
  139. anchors.verticalCenter: graph.top
  140. font.pixelSize: 1 + Math.round( 19 * (structure.height/424) )
  141. color: structure.style.textColor
  142. }
  143. Text {
  144. text: Math.round(histogram.maxValue*0.75) + " - "
  145. verticalAlignment: Text.AlignVCenter
  146. anchors.right: graph.left
  147. anchors.verticalCenter: graph.verticalCenter
  148. anchors.verticalCenterOffset: -Math.round(graph.height*0.25)
  149. font.pixelSize: 1 + Math.round( 19 * (structure.height/424) )
  150. color: structure.style.textColor
  151. }
  152. Text {
  153. text: Math.round(histogram.maxValue*0.5) + " - "
  154. verticalAlignment: Text.AlignVCenter
  155. anchors.right: graph.left
  156. anchors.verticalCenter: graph.verticalCenter
  157. font.pixelSize: 1 + Math.round( 19 * (structure.height/424) )
  158. color: structure.style.textColor
  159. }
  160. Text {
  161. text: Math.round(histogram.maxValue*0.25) + " - "
  162. verticalAlignment: Text.AlignVCenter
  163. anchors.right: graph.left
  164. anchors.verticalCenter: graph.verticalCenter
  165. anchors.verticalCenterOffset: Math.round(graph.height*0.25)
  166. font.pixelSize: 1 + Math.round( 19 * (structure.height/424) )
  167. color: structure.style.textColor
  168. }
  169. Text {
  170. text: "0 - "
  171. verticalAlignment: Text.AlignVCenter
  172. anchors.right: graph.left
  173. anchors.verticalCenter: graph.bottom
  174. anchors.verticalCenterOffset: -3
  175. font.pixelSize: 1 + Math.round( 19 * (structure.height/424) )
  176. color: structure.style.textColor
  177. }
  178. Rectangle {
  179. id: controls
  180. gradient: style.gradientWhenDefault //Blue{}
  181. height: Math.round( 40 * (graph.height / (424*0.55)) )
  182. anchors.left: graph.left
  183. anchors.right: graph.right
  184. anchors.bottom: graph.top
  185. anchors.bottomMargin: 0
  186. Text {
  187. id: weekYear
  188. text: "Year " + Graph.yearNumber()
  189. color: structure.style.textColor
  190. font.pixelSize: 1 + Math.round( parent.height * 0.8 );
  191. anchors.centerIn: parent
  192. font.bold: true
  193. }
  194. Rectangle {
  195. height: parent.height
  196. width: parent.width / 2
  197. anchors.left: parent.left
  198. color: "transparent"
  199. Text {
  200. text: "<<"
  201. color: structure.style.textColor
  202. font.pixelSize: 1 + Math.round( parent.height * 0.8 );
  203. anchors.verticalCenter: parent.verticalCenter
  204. anchors.left: parent.left
  205. anchors.leftMargin: 5
  206. font.bold: true
  207. }
  208. MouseArea {
  209. anchors.fill: parent
  210. onClicked: Graph.showWeek( Graph.currentWeek + 1 );
  211. }
  212. }
  213. Rectangle {
  214. height: parent.height
  215. width: parent.width / 2
  216. anchors.right: parent.right
  217. color: "transparent"
  218. Text {
  219. text: ">>"
  220. color: structure.style.textColor
  221. font.pixelSize: 1 + Math.round( parent.height * 0.8 );
  222. anchors.verticalCenter: parent.verticalCenter
  223. anchors.right: parent.right
  224. anchors.rightMargin: 5
  225. font.bold: true
  226. }
  227. MouseArea {
  228. anchors.fill: parent
  229. onClicked: Graph.showWeek( Graph.currentWeek - 1 );
  230. }
  231. }
  232. }
  233. Rectangle {
  234. id: dayNames
  235. gradient: structure.style.gradientWhenDefault
  236. height: Math.round( 40 * (graph.height / (424*0.55)) )
  237. anchors.left: graph.left
  238. anchors.right: graph.right
  239. anchors.top: graph.bottom
  240. anchors.topMargin: -1
  241. Rectangle {
  242. height: parent.height
  243. width: histogram.width - 2*histogram.spacing
  244. x: histogram.spacing
  245. anchors.centerIn: parent
  246. color: "transparent"
  247. Row {
  248. anchors.fill: parent
  249. spacing: histogram.spacing
  250. Text {
  251. text: "J"
  252. color: structure.style.textColor
  253. font.pixelSize: 1 + Math.round( parent.height * 0.5 );
  254. font.bold: true
  255. horizontalAlignment: Text.AlignHCenter
  256. width: Math.round( ( (parent.width) - (histogram.spacing*(histogram.countVisible()-1)) ) / histogram.countVisible() );
  257. }
  258. Text {
  259. text: "F"
  260. color: structure.style.textColor
  261. font.pixelSize: 1 + Math.round( parent.height * 0.5 );
  262. font.bold: true
  263. horizontalAlignment: Text.AlignHCenter
  264. width: Math.round( ( (parent.width) - (histogram.spacing*(histogram.countVisible()-1)) ) / histogram.countVisible() );
  265. }
  266. Text {
  267. text: "M"
  268. color: structure.style.textColor
  269. font.pixelSize: 1 + Math.round( parent.height * 0.5 );
  270. font.bold: true
  271. horizontalAlignment: Text.AlignHCenter
  272. width: Math.round( ( (parent.width) - (histogram.spacing*(histogram.countVisible()-1)) ) / histogram.countVisible() );
  273. }
  274. Text {
  275. text: "A"
  276. color: structure.style.textColor
  277. font.pixelSize: 1 + Math.round( parent.height * 0.5 );
  278. font.bold: true
  279. horizontalAlignment: Text.AlignHCenter
  280. width: Math.round( ( (parent.width) - (histogram.spacing*(histogram.countVisible()-1)) ) / histogram.countVisible() );
  281. }
  282. Text {
  283. text: "M"
  284. color: structure.style.textColor
  285. font.pixelSize: 1 + Math.round( parent.height * 0.5 );
  286. font.bold: true
  287. horizontalAlignment: Text.AlignHCenter
  288. width: Math.round( ( (parent.width) - (histogram.spacing*(histogram.countVisible()-1)) ) / histogram.countVisible() );
  289. }
  290. Text {
  291. text: "J"
  292. color: structure.style.textColor
  293. font.pixelSize: 1 + Math.round( parent.height * 0.5 );
  294. font.bold: true
  295. horizontalAlignment: Text.AlignHCenter
  296. width: Math.round( ( (parent.width) - (histogram.spacing*(histogram.countVisible()-1)) ) / histogram.countVisible() );
  297. }
  298. Text {
  299. text: "J"
  300. color: structure.style.textColor
  301. font.pixelSize: 1 + Math.round( parent.height * 0.5 );
  302. font.bold: true
  303. horizontalAlignment: Text.AlignHCenter
  304. width: Math.round( ( (parent.width) - (histogram.spacing*(histogram.countVisible()-1)) ) / histogram.countVisible() );
  305. }
  306. Text {
  307. text: "A"
  308. color: structure.style.textColor
  309. font.pixelSize: 1 + Math.round( parent.height * 0.5 );
  310. font.bold: true
  311. horizontalAlignment: Text.AlignHCenter
  312. width: Math.round( ( (parent.width) - (histogram.spacing*(histogram.countVisible()-1)) ) / histogram.countVisible() );
  313. }
  314. Text {
  315. text: "S"
  316. color: structure.style.textColor
  317. font.pixelSize: 1 + Math.round( parent.height * 0.5 );
  318. font.bold: true
  319. horizontalAlignment: Text.AlignHCenter
  320. width: Math.round( ( (parent.width) - (histogram.spacing*(histogram.countVisible()-1)) ) / histogram.countVisible() );
  321. }
  322. Text {
  323. text: "O"
  324. color: structure.style.textColor
  325. font.pixelSize: 1 + Math.round( parent.height * 0.5 );
  326. font.bold: true
  327. horizontalAlignment: Text.AlignHCenter
  328. width: Math.round( ( (parent.width) - (histogram.spacing*(histogram.countVisible()-1)) ) / histogram.countVisible() );
  329. }
  330. Text {
  331. text: "N"
  332. color: structure.style.textColor
  333. font.pixelSize: 1 + Math.round( parent.height * 0.5 );
  334. font.bold: true
  335. horizontalAlignment: Text.AlignHCenter
  336. width: Math.round( ( (parent.width) - (histogram.spacing*(histogram.countVisible()-1)) ) / histogram.countVisible() );
  337. }
  338. Text {
  339. text: "D"
  340. color: structure.style.textColor
  341. font.pixelSize: 1 + Math.round( parent.height * 0.5 );
  342. font.bold: true
  343. horizontalAlignment: Text.AlignHCenter
  344. width: Math.round( ( (parent.width) - (histogram.spacing*(histogram.countVisible()-1)) ) / histogram.countVisible() );
  345. }
  346. }
  347. }
  348. }
  349. }
  350. Item {
  351. id: viewi2
  352. width: parent.width
  353. height: parent.height * 1.04
  354. anchors.bottom: parent.bottom
  355. property string title : "Current consumption"
  356. Image {
  357. source: "images/control_bg_trans_420x275_png.png";
  358. anchors.fill: parent;
  359. smooth: true
  360. opacity:0.7
  361. }
  362. MouseArea {
  363. anchors.fill: parent;
  364. }
  365. Text {
  366. text: "Current consumption (kWh)"
  367. font.pointSize:0.001 + structure.height*0.04
  368. color: structure.style.textColor
  369. x: Math.round( structure.width * 0.05 )
  370. y: Math.round( structure.height * 0.2 )
  371. }
  372. Grid {
  373. id: grid
  374. columns: 2
  375. spacing: 2
  376. x: Math.round( structure.width * 0.10 )
  377. y: Math.round( structure.height * 0.3 )
  378. z: 2
  379. Text { text: "Lights "; font.pixelSize: 1 + Math.round( 21 * (structure.height / 404) ); horizontalAlignment: Text.AlignLeft; color: structure.style.textColor; }
  380. Text { text: " 60"; id: lightsW; font.pixelSize: 1 + Math.round( 21 * (structure.height / 404) ); horizontalAlignment: Text.AlignRight; color: structure.style.textColor; }
  381. Text { text: "AV "; font.pixelSize: 1 + Math.round( 21 * (structure.height / 404) ); horizontalAlignment: Text.AlignLeft; color: structure.style.textColor; }
  382. Text { text: " 60"; id: avW; font.pixelSize: 1 + Math.round( 21 * (structure.height / 404) ); horizontalAlignment: Text.AlignRight; color: structure.style.textColor; }
  383. Text { text: "Appliances "; font.pixelSize: 1 + Math.round( 21 * (structure.height / 404) ); horizontalAlignment: Text.AlignLeft; color: structure.style.textColor; }
  384. Text { text: " 60"; id: machinesW; font.pixelSize: 1 + Math.round( 21 * (structure.height / 404) ); horizontalAlignment: Text.AlignRight; color: structure.style.textColor; }
  385. Text { text: "Sauna "; font.pixelSize: 1 + Math.round( 21 * (structure.height / 404) ); horizontalAlignment: Text.AlignLeft; color: structure.style.textColor; }
  386. Text { text: " 60"; id: saunaW; font.pixelSize: 1 + Math.round( 21 * (structure.height / 404) ); horizontalAlignment: Text.AlignRight; color: structure.style.textColor; }
  387. Text { text: "Heating "; font.pixelSize: 1 + Math.round( 21 * (structure.height / 404) ); horizontalAlignment: Text.AlignLeft; color: structure.style.textColor; }
  388. Text { text: " 60"; id: heatingW; font.pixelSize: 1 + Math.round( 21 * (structure.height / 404) ); horizontalAlignment: Text.AlignRight; color: structure.style.textColor; }
  389. Text { text: "Misc. "; font.pixelSize: 1 + Math.round( 21 * (structure.height / 404) ); horizontalAlignment: Text.AlignLeft; color: structure.style.textColor; }
  390. Text { text: " 60"; id: miscW; font.pixelSize: 1 + Math.round( 21 * (structure.height / 404) ); horizontalAlignment: Text.AlignRight; color: structure.style.textColor; }
  391. }
  392. CLHistogram {
  393. id: histogram2
  394. height: structure.width - (grid.x) - (20 * (structure.width/518)) //structure.width - (grid.x + grid.width + 15) - (20 * (structure.width/518))
  395. width: grid.height
  396. spacing: 1
  397. clip: false
  398. anchors.verticalCenter: grid.verticalCenter
  399. x: grid.x - ( (histogram2.width - histogram2.height) / 2) //grid.x + grid.width - ( (histogram2.width - histogram2.height) / 2) + 15
  400. rotation: 90
  401. style: structure.style
  402. colorWhenDefault:style.bgColor
  403. z: 1
  404. }
  405. Rectangle {
  406. id: ruler
  407. color: "black"
  408. width: grid.width + 20
  409. anchors.horizontalCenter: grid.horizontalCenter
  410. height: 1
  411. anchors.top: grid.bottom
  412. anchors.topMargin: 4
  413. }
  414. Text {
  415. text: "Total"
  416. font.pixelSize: 1 + Math.round( 21 * (structure.height / 424) )
  417. anchors.top: ruler.bottom
  418. anchors.topMargin: 6
  419. anchors.left: ruler.left
  420. anchors.leftMargin: 10
  421. color: structure.style.textColor
  422. }
  423. Text {
  424. id: total
  425. text: "600"
  426. font.pixelSize: 1 + Math.round( 21 * (structure.height / 424) )
  427. anchors.top: ruler.bottom
  428. anchors.topMargin: 6
  429. anchors.right: ruler.right
  430. anchors.rightMargin: 10
  431. color: structure.style.textColor
  432. }
  433. }
  434. }
  435. }