calendarui/views/inc/calenmonthgrid.h
changeset 89 b57382753122
parent 83 5aadd1120515
equal deleted inserted replaced
83:5aadd1120515 89:b57382753122
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  CalenMonthGrid class definition.
    14 * Description:   Grid of month view.
    15 *
    15  *
    16 */
    16 */
       
    17 
       
    18 
    17 
    19 
    18 #ifndef CALENMONTHGRID_H
    20 #ifndef CALENMONTHGRID_H
    19 #define CALENMONTHGRID_H
    21 #define CALENMONTHGRID_H
    20 
    22 
    21 // System includes
    23 //  INCLUDES
    22 #include <hbview.h>
    24 #include <AknGrid.h>
    23 #include <QGraphicsWidget>
       
    24 #include <QAbstractItemModel>
       
    25 #include <QtGui>
       
    26 #include <hbgridviewitem.h>
       
    27 #include <hbgridview.h>
       
    28 #include <hbframebackground.h>
       
    29 #include <hbframedrawer.h>
       
    30 
    25 
    31 // Forward declarations
    26 class CCalenMonthContainer;
    32 class QStandardItemModel;
       
    33 class CalenGridItemPrototype;
       
    34 class CalenMonthData;
       
    35 class CalenMonthView;
       
    36 
    27 
    37 #ifdef  CALENVIEWS_DLL
    28 // CLASS DECLARATION
    38 #define CALENGRID_EXPORT Q_DECL_EXPORT
       
    39 #else
       
    40 #define CALENGRID_EXPORT Q_DECL_IMPORT
       
    41 #endif
       
    42 
    29 
    43 // enums
    30 /**
    44 enum scrollDirection{
    31  *  Grid of month view
    45 	up,
    32  */
    46 	down,
    33 NONSHARABLE_CLASS( CCalenMonthGrid ) : public CAknGrid 
    47 	invalid
    34     {
    48 };
    35 public:  // Constructors and destructor
    49 
    36 
    50 class CALENGRID_EXPORT CalenMonthGrid : public HbGridView
    37     /**
    51 {
    38      * C++ constructor.
    52 	Q_OBJECT
    39      * @param aFirstDayOfGrid first day of grid
       
    40      */
       
    41     CCalenMonthGrid(TTime aFirstDayOfGrid, CCalenMonthContainer* aMonthCont);
       
    42     /**
       
    43      * Destructor.
       
    44      */
       
    45     virtual ~CCalenMonthGrid();
       
    46 public:  // new functions
       
    47     /**
       
    48      * Return first day of grid
       
    49      * @return first day of grid
       
    50      */
       
    51     TTime FirstDayOfGrid();
       
    52     /**
       
    53      * Set argument aDay to first day of Grid
       
    54      * @param aDay New first day of grid
       
    55      */
       
    56     void SetFirstDayOfGrid(TTime aDay);
    53 
    57 
    54 public:
    58 protected: // From CAknGrid
    55 	CalenMonthGrid(QGraphicsItem *parent = NULL);
    59     /**
    56 	~CalenMonthGrid();
    60      * From CAknGrid Creates CFormattedCellListBoxItemDrawer,
    57 	void setView(CalenMonthView *view);
    61      * actually CCalenMonthCellListBoxItemDrawer.
    58 	void updateMonthGridModel(QList<CalenMonthData> &monthDataArray,
    62      */
    59                                 int indexToBeScrolled, bool isFirstTime);
    63     void CreateItemDrawerL();
    60 	void updateMonthGridWithInActiveMonths(
       
    61 										QList<CalenMonthData> &monthDataArray);
       
    62 	void updateMonthGridWithEventIndicators(
       
    63 										QList<CalenMonthData> &monthDataArray);
       
    64 	void setCurrentIdex(int index);
       
    65 	int getCurrentIndex();
       
    66 
    64 
    67 protected:
    65     /**
    68 	void gestureEvent(QGestureEvent *event);
    66      * Override default scrollbar implementation to prevent scrollbar 
    69 		
    67      * to be drawn.
    70 private:
    68      */
    71 	void downGesture();
    69     void UpdateScrollBarsL();
    72     void upGesture();
       
    73 	void handlePrependingRows(QList<CalenMonthData > &monthDataList);
       
    74 	void handleAppendingRows(QList<CalenMonthData > &monthDataList);
       
    75 	void handlePanGestureFinished();
       
    76 	void mousePressEvent(QGraphicsSceneMouseEvent* event);
       
    77 	void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
       
    78 	void setFocusToProperDay();
       
    79 	void setActiveDates(QDate activeDate);
       
    80 	void paint(QPainter* painter, 
       
    81 	           const QStyleOptionGraphicsItem* option, QWidget* widget);
       
    82 	bool checkIfWeCanScroll(scrollDirection direction);
       
    83 	
       
    84 public slots:
       
    85 	void scrollingFinished();
       
    86 	void prependRows();
       
    87 	void appendRows();
       
    88 	void itemActivated(const QModelIndex &index);
       
    89 
    70 
    90 private slots:
    71 private: // new data
       
    72     
       
    73     /**
       
    74       * From CCoeControl drawing month view
       
    75       */
       
    76      void Draw(const TRect& /*aRect*/) const;
       
    77      
       
    78      /**
       
    79        * Draw secondary grid lines.
       
    80        */   
       
    81      void DrawGridLines() const;
       
    82      
       
    83      TTime iFirstDayOfGrid;
       
    84      
       
    85      CCalenMonthContainer* iMonthContainer;
       
    86      
    91 
    87 
    92 	void handleThemeChange();
    88     };
    93 	
       
    94 private:
       
    95 	QStandardItemModel *mModel;
       
    96 	scrollDirection mDirection;
       
    97 	bool mIsPanGesture;
       
    98 	bool mIsAtomicScroll;
       
    99 	CalenMonthView *mView;
       
   100 	int mCurrentRow;
       
   101 	bool mIsNonActiveDayFocused;
       
   102 	bool mIgnoreItemActivated;
       
   103 	QPointF mPressedPos;
       
   104 	QGraphicsWidget* mContentWidget;
       
   105 	QList<QString> mLocalisedDates;
       
   106 	QPointF mStartPos;
       
   107 	qreal mFutureMonthHeight;
       
   108 	QColor mGridLineColor;
       
   109 	bool mActiveDatesSet;
       
   110 	bool mIsGridAdjusting;
       
   111 	bool mEventIndicatorNotSet;
       
   112 };
       
   113 
    89 
   114 #endif // CALENMONTHGRID_H
    90 #endif // CALENMONTHGRID_H
   115 
    91 
   116 // End of file  --Don't remove this.
    92 
       
    93 // End of File