|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CalenThickLinesDrawer implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <QtGui> |
|
20 #include <QPainter> |
|
21 #include <QPen> |
|
22 #include <hbdeviceprofile.h> |
|
23 |
|
24 // User includes |
|
25 #include "calenthicklinesdrawer.h" |
|
26 |
|
27 // CONSTANTS |
|
28 #define CALENTHICKLINEWIDTH 0.15 // Units |
|
29 #define CALENDAYNAMEANDGRIDSEPERATOR 0.75 // Units |
|
30 |
|
31 /*! |
|
32 \class CalenThickLinesDrawer |
|
33 |
|
34 Class to draw day names widget a,d week number widget seperators |
|
35 */ |
|
36 |
|
37 /*! |
|
38 Constructor |
|
39 */ |
|
40 CalenThickLinesDrawer::CalenThickLinesDrawer( CalendarNamespace::WidgetType type, |
|
41 QGraphicsItem* parent): |
|
42 HbWidget(parent), |
|
43 mGridBorderColor(Qt::black) |
|
44 { |
|
45 typeOfWidget = type; |
|
46 } |
|
47 |
|
48 /*! |
|
49 To paint grid item border |
|
50 */ |
|
51 CalenThickLinesDrawer::~CalenThickLinesDrawer() |
|
52 { |
|
53 |
|
54 } |
|
55 |
|
56 /*! |
|
57 To paint grid item border |
|
58 */ |
|
59 void CalenThickLinesDrawer::paint(QPainter* painter, |
|
60 const QStyleOptionGraphicsItem* option, |
|
61 QWidget* widget) |
|
62 { |
|
63 Q_UNUSED(option); |
|
64 Q_UNUSED(widget); |
|
65 QPen pen; |
|
66 pen.setStyle(Qt::SolidLine); |
|
67 |
|
68 // Get the proper width, layout specificaiton says, width has to be 0.15un |
|
69 // Convert 0.15un to pixels |
|
70 HbDeviceProfile deviceProf; |
|
71 qreal unitValue = deviceProf.unitValue(); |
|
72 qreal widthInPixels = CALENTHICKLINEWIDTH * unitValue; |
|
73 pen.setWidth(widthInPixels); |
|
74 pen.setBrush(mGridBorderColor); |
|
75 painter->setPen(pen); |
|
76 QRectF controlRect = this->boundingRect(); |
|
77 |
|
78 // Check the type of the widget and paint the necessary things |
|
79 if ( typeOfWidget == CalendarNamespace::CalenDayNameWidget ) { |
|
80 // Calculate the seperation to be added so that line coincides with |
|
81 // top border of the grid |
|
82 qreal seperation = CALENDAYNAMEANDGRIDSEPERATOR * unitValue; |
|
83 // Get the start point and end point to draw the line |
|
84 QPointF startPoint(controlRect.bottomLeft().x(), controlRect.bottomLeft().y() + seperation); |
|
85 QPointF endPoint(controlRect.bottomRight().x(), controlRect.bottomRight().y() + seperation); |
|
86 painter->drawLine(startPoint, endPoint); |
|
87 } else if ( typeOfWidget == CalendarNamespace::CalenWeekNumWidget ) { |
|
88 // Check if this widget is visible |
|
89 if(this->isEnabled()) { |
|
90 // Get the start point and end point to draw the line |
|
91 QPointF startPoint = controlRect.topRight(); |
|
92 QPointF endPoint = controlRect.bottomRight(); |
|
93 painter->drawLine(startPoint, endPoint); |
|
94 } |
|
95 } |
|
96 } |
|
97 |
|
98 // End of file --Don't remove this. |