calendarui/views/dayview/src/calendayitem.cpp
changeset 57 bb2d3e476f29
parent 55 2c54b51f39c4
child 63 a3cb48f6c889
equal deleted inserted replaced
55:2c54b51f39c4 57:bb2d3e476f29
    27 //User inlcudes
    27 //User inlcudes
    28 #include "calendayitem.h"
    28 #include "calendayitem.h"
    29 #include "calendaystatusstrip.h"
    29 #include "calendaystatusstrip.h"
    30 #include "calendaymodel.h"
    30 #include "calendaymodel.h"
    31 #include "calendayutils.h"
    31 #include "calendayutils.h"
       
    32 #include "calenagendautils.h"
    32 #include "calendaycontainer.h"
    33 #include "calendaycontainer.h"
    33 
    34 
    34 // -----------------------------------------------------------------------------
    35 /*!
    35 // CalenDayItem()
    36    \brief Constructor.
    36 // Constructor.
    37 */
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CalenDayItem::CalenDayItem(const CalenDayContainer *container):
    38 CalenDayItem::CalenDayItem(const CalenDayContainer *container):
    40     mContainer(container), mUpdated(false), mBg(0), mEventDesc(0), mColorStripe(0), 
    39     mContainer(container), mUpdated(false), mBg(0), mEventDesc(0), mColorStripe(0), 
    41     mEventDescMinWidth(0.0), mFrameMinWidth(0.0)
    40     mEventDescMinWidth(0.0), mFrameMinWidth(0.0)
    42 {
    41 {
    43 }
    42 }
    44 
    43 
    45 // -----------------------------------------------------------------------------
    44 /*!
    46 // CalenBCDayView()
    45    \brief Constructor.
    47 // Copy constructor.
    46 */
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 CalenDayItem::CalenDayItem(const CalenDayItem & source) :
    47 CalenDayItem::CalenDayItem(const CalenDayItem & source) :
    51     HbAbstractViewItem(source), mContainer(source.container()), mUpdated(false), mBg(0), mEventDesc(0), 
    48     HbAbstractViewItem(source), mContainer(source.container()), mUpdated(false), mBg(0), mEventDesc(0), 
    52     mColorStripe(0), mEventDescMinWidth(0.0), mFrameMinWidth(0.0)
    49     mColorStripe(0), mEventDescMinWidth(0.0), mFrameMinWidth(0.0)
    53 {	
    50 {
    54     // TODO: "qtg_fr_btn_pressed" need to replaced with qtg_fr_cal_meeting_bg
    51     // TODO: "qtg_fr_btn_pressed" need to replaced with qtg_fr_cal_meeting_bg
    55 	// when available
    52 	// when available
    56     mBg = new HbFrameItem("qtg_fr_btn_pressed", HbFrameDrawer::NinePieces, this);
    53     mBg = new HbFrameItem("qtg_fr_btn_pressed", HbFrameDrawer::NinePieces, this);
    57     mEventDesc = new HbTextItem(this);
    54     mEventDesc = new HbTextItem(this);
    58     // TODO: probably ElideLeft needed for mirrored layout
    55     // TODO: probably ElideLeft needed for mirrored layout
    85     //additionally called here to prevent minimum size hint caching inside effectiveSizeHint
    82     //additionally called here to prevent minimum size hint caching inside effectiveSizeHint
    86     setMinimumWidth(stripeWidth);
    83     setMinimumWidth(stripeWidth);
    87 
    84 
    88 }
    85 }
    89 
    86 
    90 // -----------------------------------------------------------------------------
    87 /*!
    91 // ~CalenDayItem()
    88    \brief Destructor.
    92 // Destructor.
    89 */
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 CalenDayItem::~CalenDayItem()
    90 CalenDayItem::~CalenDayItem()
    96 {
    91 {
    97 }
    92 }
    98 
    93 
    99 // -----------------------------------------------------------------------------
    94 /*!
   100 // 
    95    \brief Creates new instance of day item.
   101 // -----------------------------------------------------------------------------
    96    
   102 //
    97    \return New instance of day item.
       
    98 */
   103 HbAbstractViewItem * CalenDayItem::createItem()
    99 HbAbstractViewItem * CalenDayItem::createItem()
   104 {
   100 {
   105     CalenDayItem* newItem = new CalenDayItem(*this);
   101     CalenDayItem* newItem = new CalenDayItem(*this);
   106     return newItem;
   102     return newItem;
   107 }
   103 }
   108 
   104 
   109 
   105 
   110 // -----------------------------------------------------------------------------
   106 /*!
   111 // -----------------------------------------------------------------------------
   107    \brief Sets data to be displayed on item.
   112 //
   108 */
   113 void CalenDayItem::updateChildItems()
   109 void CalenDayItem::updateChildItems()
   114 {
   110 {
   115 	// there is no need to update items after creation
   111     // there is no need to update items after creation
   116 	if (!mUpdated)
   112     if (!mUpdated) {
   117 		{
   113         AgendaEntry entry;
   118 		AgendaEntry entry;
   114         entry = modelIndex().data(CalenDayEntry).value<AgendaEntry>();
   119 		entry = modelIndex().data( CalenDayEntry ).value<AgendaEntry>();
   115 
   120 		
   116 		bool isAllDayEvent = CalenAgendaUtils::isAlldayEvent(entry); 
   121 		bool isAllDayEvent = (entry.type() == AgendaEntry::TypeEvent)
   117 
   122 								&& !entry.isTimedEntry(); 
   118         setDescription(entry, isAllDayEvent);
   123 		
   119         setStatusStrip(entry, isAllDayEvent);
   124 		setDescription(entry, isAllDayEvent);
   120 
   125 		setStatusStrip(entry, isAllDayEvent);
   121         mUpdated = true;
   126 		
   122     }
   127 		mUpdated = true;
   123 
   128 		}
   124     //TODO: check if needed
   129 	
   125     //repolish(); 
   130 	//TODO: check if needed
   126     //HbAbstractViewItem::updateChildItems();
   131 	//repolish(); 
   127 }
   132 	//HbAbstractViewItem::updateChildItems();
   128 
   133 }
   129 
   134 
   130 /*!
   135 
   131    \brief Adds event description for the item.
   136 // -----------------------------------------------------------------------------
   132    
   137 // setDescription()
   133    \param entry An for which description needs to be displayed.
   138 // -----------------------------------------------------------------------------
   134    \param allDayEvent Flag that indicates whether an item is all day event
   139 //
   135 */
   140 void CalenDayItem::setDescription(const AgendaEntry &entry, bool allDayEvent)
   136 void CalenDayItem::setDescription(const AgendaEntry &entry, bool allDayEvent)
   141 {
   137 {
   142 	QString description(entry.summary());
   138 	QString description(entry.summary());
   143 	QString location(entry.location());
   139 	QString location(entry.location());
   144 	
   140 	
   180 
   176 
   181 /*!
   177 /*!
   182    \brief It set all needed things for status strip from Agenda Entry.
   178    \brief It set all needed things for status strip from Agenda Entry.
   183    
   179    
   184    \param entry Status Strip is created from Agenda Entry
   180    \param entry Status Strip is created from Agenda Entry
   185  */
   181 */
   186 void CalenDayItem::setStatusStrip(const AgendaEntry &entry, bool allDayEvent)
   182 void CalenDayItem::setStatusStrip(const AgendaEntry &entry, bool allDayEvent)
   187 {
   183 {
   188     QColor color = HbColorScheme::color("qtc_cal_month_current_day");
   184     QColor color = HbColorScheme::color("qtc_cal_month_current_day");
   189     mColorStripe->setColor(color);
   185     mColorStripe->setColor(color);
   190     
   186     
   223             mColorStripe->setDrawingStyle(CalenDayStatusStrip::Filled);
   219             mColorStripe->setDrawingStyle(CalenDayStatusStrip::Filled);
   224         break;
   220         break;
   225     }
   221     }
   226 }
   222 }
   227 
   223 
       
   224 /*!
       
   225    \brief Reimplemented from HbWidget. Handles resize event.
       
   226    
       
   227    \param event Instance of an event to be handled.
       
   228 */
   228 void CalenDayItem::resizeEvent(QGraphicsSceneResizeEvent *event)
   229 void CalenDayItem::resizeEvent(QGraphicsSceneResizeEvent *event)
   229 {
   230 {
   230     Q_UNUSED(event)
   231     Q_UNUSED(event)
   231 
   232 
   232     qreal width = rect().width();
   233     qreal width = rect().width();