calendarui/views/src/calenthicklinesdrawer.cpp
changeset 58 ef813d54df51
parent 49 5de72ea7a065
child 68 a5a1242fd2e8
equal deleted inserted replaced
50:579cc610882e 58:ef813d54df51
    22 #include <hbdeviceprofile.h>
    22 #include <hbdeviceprofile.h>
    23 #include <hbcolorscheme.h>
    23 #include <hbcolorscheme.h>
    24 
    24 
    25 // User includes
    25 // User includes
    26 #include "calenthicklinesdrawer.h"
    26 #include "calenthicklinesdrawer.h"
       
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "calenthicklinesdrawerTraces.h"
       
    30 #endif
       
    31 
    27 
    32 
    28 // CONSTANTS
    33 // CONSTANTS
    29 #define CALENTHICKLINEWIDTH     0.15 // Units
    34 #define CALENTHICKLINEWIDTH     0.15 // Units
    30 #define CALENDAYNAMEANDGRIDSEPERATOR    0.75 // Units
    35 #define CALENDAYNAMEANDGRIDSEPERATOR    0.75 // Units
    31 
    36 
    40  */
    45  */
    41 CalenThickLinesDrawer::CalenThickLinesDrawer( CalendarNamespace::WidgetType type, 
    46 CalenThickLinesDrawer::CalenThickLinesDrawer( CalendarNamespace::WidgetType type, 
    42 	QGraphicsItem* parent):
    47 	QGraphicsItem* parent):
    43 	HbWidget(parent)
    48 	HbWidget(parent)
    44 {
    49 {
       
    50     OstTraceFunctionEntry0( CALENTHICKLINESDRAWER_CALENTHICKLINESDRAWER_ENTRY );
       
    51     
    45 	typeOfWidget = type;
    52 	typeOfWidget = type;
    46 	mGridBorderColor = HbColorScheme::color("qtc_cal_grid_line");
    53 	mGridBorderColor = HbColorScheme::color("qtc_cal_grid_line");
    47 	setFlag(QGraphicsItem::ItemHasNoContents, false);
    54 	setFlag(QGraphicsItem::ItemHasNoContents, false);
       
    55 	
       
    56 	OstTraceFunctionExit0( CALENTHICKLINESDRAWER_CALENTHICKLINESDRAWER_EXIT );
    48 }
    57 }
    49 
    58 
    50 /*!
    59 /*!
    51  To paint grid item border
    60  To paint grid item border
    52  */
    61  */
    53 CalenThickLinesDrawer::~CalenThickLinesDrawer()
    62 CalenThickLinesDrawer::~CalenThickLinesDrawer()
    54 {
    63 {
       
    64     OstTraceFunctionEntry0( DUP1_CALENTHICKLINESDRAWER_CALENTHICKLINESDRAWER_ENTRY );
    55 
    65 
       
    66     OstTraceFunctionExit0( DUP1_CALENTHICKLINESDRAWER_CALENTHICKLINESDRAWER_EXIT );
    56 }
    67 }
    57 
    68 
    58 /*!
    69 /*!
    59  To paint grid item border
    70  To paint grid item border
    60  */
    71  */
    61 void CalenThickLinesDrawer::paint(QPainter* painter,
    72 void CalenThickLinesDrawer::paint(QPainter* painter,
    62 								const QStyleOptionGraphicsItem* option,
    73 								const QStyleOptionGraphicsItem* option,
    63 								QWidget* widget)
    74 								QWidget* widget)
    64 {
    75 {
       
    76     OstTraceFunctionEntry0( CALENTHICKLINESDRAWER_PAINT_ENTRY );
       
    77     
    65 	Q_UNUSED(option);
    78 	Q_UNUSED(option);
    66 	Q_UNUSED(widget);
    79 	Q_UNUSED(widget);
    67 	QPen pen;
    80 	QPen pen;
    68 	pen.setStyle(Qt::SolidLine);
    81 	pen.setStyle(Qt::SolidLine);
    69 
    82 
    72 	HbDeviceProfile deviceProf;
    85 	HbDeviceProfile deviceProf;
    73 	qreal unitValue = deviceProf.unitValue();
    86 	qreal unitValue = deviceProf.unitValue();
    74 	qreal widthInPixels = CALENTHICKLINEWIDTH * unitValue;
    87 	qreal widthInPixels = CALENTHICKLINEWIDTH * unitValue;
    75 	pen.setWidth(widthInPixels);
    88 	pen.setWidth(widthInPixels);
    76 	pen.setBrush(mGridBorderColor);
    89 	pen.setBrush(mGridBorderColor);
       
    90 	
       
    91 	// Store the old pen
       
    92     QPen oldPen = painter->pen();
       
    93 	    
    77 	painter->setPen(pen);
    94 	painter->setPen(pen);
    78 	QRectF controlRect = this->boundingRect();
    95 	QRectF controlRect = this->boundingRect();
    79 
    96 
    80 	// Check the type of the widget and paint the necessary things
    97 	// Check the type of the widget and paint the necessary things
    81 	if ( typeOfWidget == CalendarNamespace::CalenDayNameWidget ) {
    98 	if ( typeOfWidget == CalendarNamespace::CalenDayNameWidget ) {
    82 		// Calculate the seperation to be added so that line coincides with 
    99 		// Calculate the seperation to be added so that line coincides with 
    83 		// top border of the grid
   100 		// top border of the grid
    84 		qreal seperation = CALENDAYNAMEANDGRIDSEPERATOR * unitValue;
   101 		qreal seperation = CALENDAYNAMEANDGRIDSEPERATOR * unitValue;
       
   102 		// Adjust the seperation with the thickness of the line
       
   103 		seperation = seperation - widthInPixels;
    85 		// Get the start point and end point to draw the line
   104 		// Get the start point and end point to draw the line
    86 		QPointF startPoint(controlRect.bottomLeft().x(), controlRect.bottomLeft().y() + seperation);
   105 		QPointF startPoint(controlRect.bottomLeft().x(), controlRect.bottomLeft().y() + seperation);
    87 		QPointF endPoint(controlRect.bottomRight().x(), controlRect.bottomRight().y() + seperation);
   106 		QPointF endPoint(controlRect.bottomRight().x(), controlRect.bottomRight().y() + seperation);
    88 		painter->drawLine(startPoint, endPoint);
   107 		painter->drawLine(startPoint, endPoint);
    89 	} else if ( typeOfWidget == CalendarNamespace::CalenWeekNumWidget ) {
   108 	} else if ( typeOfWidget == CalendarNamespace::CalenWeekNumWidget ) {
    93 			QPointF startPoint = controlRect.topRight();
   112 			QPointF startPoint = controlRect.topRight();
    94 			QPointF endPoint = controlRect.bottomRight();
   113 			QPointF endPoint = controlRect.bottomRight();
    95 			painter->drawLine(startPoint, endPoint);
   114 			painter->drawLine(startPoint, endPoint);
    96 		}
   115 		}
    97 	}
   116 	}
       
   117 	
       
   118 	// Set the old pen back
       
   119     painter->setPen(oldPen);
       
   120     
       
   121     OstTraceFunctionExit0( CALENTHICKLINESDRAWER_PAINT_EXIT );
    98 }
   122 }
    99 
   123 
   100 // End of file  --Don't remove this.
   124 // End of file  --Don't remove this.