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