45
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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: Day view control of calendar
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
// System includes
|
|
18 |
#include <QPainter>
|
63
|
19 |
#include <HbColorScheme>
|
45
|
20 |
|
|
21 |
// User includes
|
63
|
22 |
#include "calendayeventspane.h"
|
|
23 |
#include "calendaycommonheaders.h"
|
45
|
24 |
|
|
25 |
/*!
|
|
26 |
\class CalenDayEventsPane
|
|
27 |
\brief Events pane draws timelines in content view.
|
|
28 |
*/
|
|
29 |
|
|
30 |
/*!
|
|
31 |
\brief Constructor
|
|
32 |
|
|
33 |
\param parent The parent of widget
|
|
34 |
*/
|
|
35 |
CalenDayEventsPane::CalenDayEventsPane(HbWidget *parent) : HbWidget(parent),
|
|
36 |
mDrawTopLine(false)
|
|
37 |
{
|
|
38 |
// Necessary when widget implements own paint method
|
|
39 |
setFlag(QGraphicsItem::ItemHasNoContents, false);
|
|
40 |
|
|
41 |
HbDeviceProfile deviceProfile;
|
|
42 |
mUnitInPixels = deviceProfile.unitValue();
|
63
|
43 |
mHourLineColor = HbColorScheme::color(KCalenHourLineColor);
|
45
|
44 |
|
|
45 |
// Set custom dashed pen
|
63
|
46 |
mCustomDashedPen.setWidth(KCalenHourLineThickness);
|
45
|
47 |
QVector<qreal> dashes;
|
63
|
48 |
dashes << KCalenHalfHourLineDashWidth * mUnitInPixels
|
|
49 |
<< KCalenHalfHourLineDashWidth * mUnitInPixels;
|
45
|
50 |
mCustomDashedPen.setDashPattern(dashes);
|
|
51 |
mCustomDashedPen.setCapStyle(Qt::FlatCap);
|
|
52 |
mCustomDashedPen.setColor(mHourLineColor);
|
|
53 |
}
|
|
54 |
|
|
55 |
/*!
|
|
56 |
\brief Destructor
|
|
57 |
*/
|
|
58 |
CalenDayEventsPane::~CalenDayEventsPane()
|
|
59 |
{
|
|
60 |
}
|
|
61 |
|
|
62 |
/*!
|
|
63 |
\brief Shows/hides a line at top of event pane.
|
|
64 |
|
|
65 |
\param drawTopLine Flag to be set if top line should be drawn.
|
|
66 |
*/
|
55
|
67 |
void CalenDayEventsPane::setDrawTopLine(bool drawTopLine)
|
45
|
68 |
{
|
|
69 |
mDrawTopLine = drawTopLine;
|
|
70 |
}
|
|
71 |
|
|
72 |
/*!
|
55
|
73 |
\brief It return if top line is drawed.
|
|
74 |
*/
|
|
75 |
bool CalenDayEventsPane::isTopLineDrawed() const
|
|
76 |
{
|
|
77 |
return mDrawTopLine;
|
|
78 |
}
|
|
79 |
|
|
80 |
/*!
|
45
|
81 |
\brief Paints the item with given painter.
|
|
82 |
|
|
83 |
\param painter
|
|
84 |
\param option
|
|
85 |
\param widget
|
|
86 |
*/
|
|
87 |
void CalenDayEventsPane::paint(QPainter *painter,
|
|
88 |
const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
89 |
{
|
|
90 |
Q_UNUSED(widget)
|
|
91 |
|
|
92 |
QRectF drawArea = option->rect;
|
|
93 |
|
63
|
94 |
const qreal hourLineThickness = KCalenHourLineThickness;
|
45
|
95 |
|
|
96 |
painter->save();
|
|
97 |
|
|
98 |
// Draw full hour line
|
|
99 |
QPen linePen = QPen(mHourLineColor, hourLineThickness * mUnitInPixels);
|
|
100 |
painter->setPen(linePen);
|
|
101 |
QLineF fullHourLine(drawArea.bottomLeft(), drawArea.bottomRight());
|
|
102 |
painter->drawLine(fullHourLine);
|
|
103 |
|
|
104 |
// Draw extra line on top if needed
|
|
105 |
if (mDrawTopLine) {
|
|
106 |
fullHourLine = QLineF(drawArea.topLeft(), drawArea.topRight());
|
|
107 |
painter->drawLine(fullHourLine);
|
|
108 |
}
|
|
109 |
|
|
110 |
// Draw half hour line
|
|
111 |
painter->setPen(mCustomDashedPen);
|
|
112 |
qreal halfHourYPos = drawArea.height() / 2;
|
|
113 |
QLineF halfHourLine(drawArea.left(), halfHourYPos, drawArea.right(), halfHourYPos);
|
|
114 |
painter->drawLine(halfHourLine);
|
|
115 |
|
|
116 |
painter->restore();
|
|
117 |
}
|
|
118 |
|