|
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: Definition file for class CalenGridItem. |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <QString> |
|
20 #include <QGraphicsWidget> |
|
21 #include <hbstyle.h> |
|
22 #include <hbwidget.h> |
|
23 #include <hbtextitem.h> |
|
24 #include <hbframeitem.h> |
|
25 #include <hbframedrawer.h> |
|
26 #include <hbiconitem.h> |
|
27 #include <hbcolorscheme.h> |
|
28 |
|
29 // User includes |
|
30 #include "calengriditem.h" |
|
31 |
|
32 #define PLUGINPATH "calengriditemstyleplugin.dll" |
|
33 |
|
34 /*! |
|
35 \class CalenGridItem |
|
36 |
|
37 Custom Calendar Grid Item class |
|
38 */ |
|
39 |
|
40 /*! |
|
41 Default constructor. |
|
42 */ |
|
43 CalenGridItem::CalenGridItem(QGraphicsWidget *parent): |
|
44 HbWidget(parent), |
|
45 mEventIndicatorItem(NULL), |
|
46 mMonthDayInfoItem(NULL), |
|
47 mFocusIndicatorItem(NULL), |
|
48 mTodayIndicatorItem(NULL) |
|
49 { |
|
50 qDebug("CalenGridItem::CalenGridItem"); |
|
51 |
|
52 // Here we register the plugin. |
|
53 setPluginBaseId(style()->registerPlugin(pluginPath())); |
|
54 |
|
55 // Now create each of the primitives. |
|
56 init(); |
|
57 |
|
58 } |
|
59 |
|
60 /*! |
|
61 Destructor. |
|
62 */ |
|
63 CalenGridItem::~CalenGridItem() |
|
64 { |
|
65 // Here we un-register the plugin . |
|
66 style()->unregisterPlugin(pluginPath()); |
|
67 } |
|
68 |
|
69 /*! |
|
70 To update the month day info |
|
71 */ |
|
72 void CalenGridItem::updateMonthDayInfo(QString monthDayText) |
|
73 { |
|
74 mMonthDayInfoItem->setText(monthDayText); |
|
75 mMonthDayInfoItem->setElideMode(Qt::ElideNone); |
|
76 } |
|
77 |
|
78 /*! |
|
79 To update the month day info color |
|
80 */ |
|
81 void CalenGridItem::updateMonthDayInfoColor(QColor monthTextColor) |
|
82 { |
|
83 mMonthDayInfoItem->setTextColor(monthTextColor); |
|
84 } |
|
85 |
|
86 /*! |
|
87 To update the event indicator icon |
|
88 */ |
|
89 void CalenGridItem::updateEventIndicator(QString eventIconPath) |
|
90 { |
|
91 mEventIndicatorItem->setIconName(eventIconPath); |
|
92 } |
|
93 |
|
94 /*! |
|
95 To update the focus indicator icon |
|
96 */ |
|
97 void CalenGridItem::updateFocusIndicator(QString focusIconPath) |
|
98 { |
|
99 mFocusIndicatorItem->frameDrawer().setFrameGraphicsName(focusIconPath); |
|
100 } |
|
101 |
|
102 /*! |
|
103 If underlineEnabled is true then will draw underline else not |
|
104 */ |
|
105 void CalenGridItem::drawUnderline(bool underlineEnabled) |
|
106 { |
|
107 if (underlineEnabled) { |
|
108 if (!mTodayIndicatorItem) { |
|
109 mTodayIndicatorItem = new HbIconItem(this); |
|
110 HbStyle::setItemName(mTodayIndicatorItem, |
|
111 QLatin1String("todayIndicatorItem")); |
|
112 // Get the color from the theme |
|
113 QColor todayColor = HbColorScheme::color("qtc_cal_month_current_day"); |
|
114 if (todayColor.isValid()) { |
|
115 mTodayIndicatorItem->setColor(todayColor); |
|
116 } |
|
117 } |
|
118 } else { |
|
119 if (mTodayIndicatorItem) { |
|
120 delete mTodayIndicatorItem; |
|
121 mTodayIndicatorItem = NULL; |
|
122 } |
|
123 } |
|
124 } |
|
125 |
|
126 /*! |
|
127 Returns the style plugin path |
|
128 */ |
|
129 QString CalenGridItem::pluginPath() |
|
130 { |
|
131 QString pluginPath; |
|
132 pluginPath.append(PLUGINPATH); |
|
133 return pluginPath; |
|
134 } |
|
135 |
|
136 /*! |
|
137 Create primitives |
|
138 */ |
|
139 void CalenGridItem::init() |
|
140 { |
|
141 |
|
142 mEventIndicatorItem = new HbIconItem(this); |
|
143 HbStyle::setItemName(mEventIndicatorItem, QLatin1String("eventIconItem")); |
|
144 |
|
145 mMonthDayInfoItem = new HbTextItem(this); |
|
146 HbStyle::setItemName(mMonthDayInfoItem, |
|
147 QLatin1String("monthDayInfoTextItem")); |
|
148 |
|
149 mFocusIndicatorItem = new HbFrameItem(this); |
|
150 mFocusIndicatorItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
151 mFocusIndicatorItem->setZValue(-1); |
|
152 HbStyle::setItemName(mFocusIndicatorItem, QLatin1String("focusIconItem")); |
|
153 |
|
154 } |
|
155 |
|
156 // End of file --Don't remove this. |