diff -r f979ecb2b13e -r c198609911f9 calendarui/views/src/calengriditem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/calendarui/views/src/calengriditem.cpp Fri Apr 16 14:57:40 2010 +0300 @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Definition file for class CalenGridItem. + * + */ + +// System includes +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// User includes +#include "calengriditem.h" + +#define PLUGINPATH "calengriditemstyleplugin.dll" + +/*! + \class CalenGridItem + + Custom Calendar Grid Item class + */ + +/*! + Default constructor. + */ +CalenGridItem::CalenGridItem(QGraphicsWidget *parent): + HbWidget(parent), + mEventIndicatorItem(NULL), + mMonthDayInfoItem(NULL), + mFocusIndicatorItem(NULL), + mTodayIndicatorItem(NULL) +{ + qDebug("CalenGridItem::CalenGridItem"); + + // Here we register the plugin. + setPluginBaseId(style()->registerPlugin(pluginPath())); + + // Now create each of the primitives. + init(); + +} + +/*! + Destructor. + */ +CalenGridItem::~CalenGridItem() +{ + // Here we un-register the plugin . + style()->unregisterPlugin(pluginPath()); +} + +/*! + To update the month day info + */ +void CalenGridItem::updateMonthDayInfo(QString monthDayText) +{ + mMonthDayInfoItem->setText(monthDayText); + mMonthDayInfoItem->setElideMode(Qt::ElideNone); +} + +/*! + To update the month day info color + */ +void CalenGridItem::updateMonthDayInfoColor(QColor monthTextColor) +{ + mMonthDayInfoItem->setTextColor(monthTextColor); +} + +/*! + To update the event indicator icon + */ +void CalenGridItem::updateEventIndicator(QString eventIconPath) +{ + mEventIndicatorItem->setIconName(eventIconPath); +} + +/*! + To update the focus indicator icon + */ +void CalenGridItem::updateFocusIndicator(QString focusIconPath) +{ + mFocusIndicatorItem->frameDrawer().setFrameGraphicsName(focusIconPath); +} + +/*! + If underlineEnabled is true then will draw underline else not + */ +void CalenGridItem::drawUnderline(bool underlineEnabled) +{ + if (underlineEnabled) { + if (!mTodayIndicatorItem) { + mTodayIndicatorItem = new HbIconItem(this); + HbStyle::setItemName(mTodayIndicatorItem, + QLatin1String("todayIndicatorItem")); + // Get the color from the theme + QColor todayColor = HbColorScheme::color("qtc_cal_month_current_day"); + if (todayColor.isValid()) { + mTodayIndicatorItem->setColor(todayColor); + } + } + } else { + if (mTodayIndicatorItem) { + delete mTodayIndicatorItem; + mTodayIndicatorItem = NULL; + } + } +} + +/*! + Returns the style plugin path + */ +QString CalenGridItem::pluginPath() +{ + QString pluginPath; + pluginPath.append(PLUGINPATH); + return pluginPath; +} + +/*! + Create primitives + */ +void CalenGridItem::init() +{ + + mEventIndicatorItem = new HbIconItem(this); + HbStyle::setItemName(mEventIndicatorItem, QLatin1String("eventIconItem")); + + mMonthDayInfoItem = new HbTextItem(this); + HbStyle::setItemName(mMonthDayInfoItem, + QLatin1String("monthDayInfoTextItem")); + + mFocusIndicatorItem = new HbFrameItem(this); + mFocusIndicatorItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); + mFocusIndicatorItem->setZValue(-1); + HbStyle::setItemName(mFocusIndicatorItem, QLatin1String("focusIconItem")); + +} + +// End of file --Don't remove this.