calendarui/views/inc/calendayviewwidget.h
branchGCC_SURGE
changeset 54 e6894b852bc6
parent 40 4b686cfad39d
parent 53 e08ac1a3ba2b
equal deleted inserted replaced
40:4b686cfad39d 54:e6894b852bc6
     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:  CalenDayViewWidget class definition.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CALENDAYVIEWWIDGET_H
       
    19 #define CALENDAYVIEWWIDGET_H
       
    20 
       
    21 // System includes
       
    22 #include <QGraphicsLinearLayout>
       
    23 #include <QDateTime>
       
    24 #include <hbwidget.h>
       
    25 
       
    26 // User includes
       
    27  
       
    28 // Forward declarations
       
    29 class QStandardItemModel;
       
    30 class QGraphicsSceneMouseEvent; // TODO: Remove this after gestures are supported
       
    31 class HbAbstractViewItem;
       
    32 class HbGroupBox;
       
    33 class HbListView;
       
    34 class HbLabel;
       
    35 class HbAction;
       
    36 class HbDateTimePicker;
       
    37 class XQSettingsManager;
       
    38 class MCalenServices;
       
    39 class CalenDayView;
       
    40 class AgendaEntry;
       
    41 class CalenDocLoader;
       
    42 class CalenEventListViewItem;
       
    43 class NotesEditor;
       
    44 
       
    45 /**
       
    46  * @class CalenDayViewWidget
       
    47  * @brief The content widget for the day/agenda view.
       
    48  * It is responsible for showing all the events &/ to-do's
       
    49  * (if any) for a particular day selected by the user
       
    50  */
       
    51 class CalenDayViewWidget : public HbWidget
       
    52     {
       
    53     Q_OBJECT
       
    54 
       
    55 public:
       
    56     
       
    57     /**
       
    58      * @brief Constructor
       
    59      * @param services The reference to the MCalenServices object
       
    60      * @param docLoader The document loader object
       
    61      */
       
    62 	IMPORT_C CalenDayViewWidget(MCalenServices &services,
       
    63 	                                 CalenDocLoader *docLoader);
       
    64 	
       
    65 	/**
       
    66 	 * @brief Default C++ destructor
       
    67 	 */
       
    68 	IMPORT_C ~CalenDayViewWidget();
       
    69 	
       
    70 	/**
       
    71 	 * @brief Initializes the widget to show all the events/to-do's
       
    72 	 * for the selected day
       
    73 	 * @param view Pointer to the view to which this is the content
       
    74 	 */
       
    75     void setupWidget(CalenDayView *view);
       
    76     
       
    77     /**
       
    78      * @brief Prepares the widget to be shown.
       
    79      * Initializes the widget with the day's events and other details 
       
    80      */
       
    81     void showWidget();
       
    82     
       
    83     /**
       
    84      * @brief Called from the view whenever the orientation of the
       
    85      * device changes
       
    86      */
       
    87     void orientationChanged(Qt::Orientation);
       
    88     
       
    89     /**
       
    90      * @brief Callback function to handle system locale change
       
    91      */
       
    92     void handleLocaleChange();
       
    93     
       
    94     /**
       
    95      * @brief clears the list model from the view
       
    96      */
       
    97     void clearListModel();
       
    98     
       
    99 private:
       
   100     
       
   101     /**
       
   102      * @brief Sets the context based on the item selected by the user
       
   103      * @param entry The entry using which the context is deduced
       
   104      */
       
   105     void setContextFromHighlight(AgendaEntry entry);
       
   106     
       
   107     /**
       
   108      * @brief Initializes the child widgets of this widget
       
   109      */
       
   110     void initChildWidgets();
       
   111     
       
   112     /**
       
   113      * @brief Populates the list with the events for the current day.
       
   114      * Does nothing if the day has no events. To be called whenever
       
   115      * the view has to be refreshed
       
   116      */
       
   117     void populateListWidget();
       
   118     
       
   119     /**
       
   120      * @brief Gets the instance list for day
       
   121      */
       
   122     void getInstanceList();
       
   123     
       
   124     /**
       
   125      * @brief Sets the heading text to show the date for which this
       
   126      * widget is being shown
       
   127      */
       
   128     void setHeadingText();
       
   129     
       
   130     /**
       
   131      * @brief Creates and adds an item to the list at position index
       
   132      * @param index The position in the list when the item is added
       
   133      * @param entry The entry whose details must be shown in the item
       
   134      */
       
   135     void createListItem(int index, AgendaEntry entry);
       
   136     
       
   137     /**
       
   138      * @brief Creates and add a list item for the event
       
   139      * @param index The position in the list when the item is added
       
   140      * @param entry The entry whose details must be shown in the item
       
   141      */
       
   142     void addTimedEventToList(int index, AgendaEntry entry);
       
   143     
       
   144     /**
       
   145      * @brief Creates and add a list item for the event which is non timed
       
   146      * @param index The position in the list when the item is added
       
   147      * @param entry The entry whose details must be shown in the item
       
   148      */
       
   149     void addNonTimedEventToList(int index, AgendaEntry entry);
       
   150     
       
   151     /**
       
   152      * @brief Sets strecthing to list items showing non-timed events
       
   153      */
       
   154     void handleListItemStretching(Qt::Orientation orientation);
       
   155     
       
   156     /**
       
   157      * @brief Returns the index in the list to which scrolling must
       
   158      * happen. For ex: After creating a new event, the list must scroll
       
   159      * to the newly created event
       
   160      */
       
   161     int getIndexToScrollTo();
       
   162     
       
   163     /**
       
   164      * @brief To Show and hide regional plugin label depends upon settings
       
   165      */
       
   166     
       
   167     void showHideRegionalInformation();
       
   168     
       
   169 private slots:
       
   170 
       
   171     /**
       
   172      * @brief Opens the editor to create a new entry
       
   173      */
       
   174     void createNewEvent();
       
   175     
       
   176     /**
       
   177      * @brief Opens the entry at position index in the list for
       
   178      * editing in the editor. Does nothing if the index is invalid
       
   179      */
       
   180     void editEntry();
       
   181     
       
   182     /**
       
   183      * @brief Opens the entry at position index in the list for
       
   184      * viewing in the viewer. Does nothing if the index is invalid
       
   185      */
       
   186     void viewEntry();
       
   187 	
       
   188     /**
       
   189      * @brief Deletes the entry at position index in the list.
       
   190      * Does nothing if the list is empty
       
   191      */
       
   192     void deleteEntry();
       
   193     
       
   194     /**
       
   195      * @brief Marks a to-do as done
       
   196      */
       
   197     void markAsDone(); 
       
   198     
       
   199     /**
       
   200      * @brief Handles long press on a particular item. Presents a
       
   201      * context menu with various operations that the user can
       
   202      * perform
       
   203      * @param ite, The index item which is being long pressed
       
   204      * @param coords The (x, y) co-ordinates where the long tap has
       
   205      * occured
       
   206      */
       
   207     void itemLongPressed(HbAbstractViewItem *item, const QPointF &coords);
       
   208     
       
   209     /**
       
   210      * @brief Handles user selection on a particular item of a
       
   211      * particular event in the list. Default action is to view it
       
   212      * @param index Index of the item which was selected 
       
   213      */
       
   214     void itemActivated(const QModelIndex &index);
       
   215     
       
   216     /**
       
   217      * @brief Called whenever a editing a to-do is completed
       
   218      * @param status Inidcates if the editing was successful or not
       
   219      */
       
   220     void noteEditingCompleted(bool status);
       
   221     
       
   222     /**
       
   223      * @brief Callback function for navigating to today's agenda
       
   224      * This option must be available only if the view is showing
       
   225      * events for some day other than the current day
       
   226      */
       
   227     void goToToday();
       
   228     
       
   229     /**
       
   230      * @brief This slot connected to aboutToClose()signal of contextmenu
       
   231      * To reset the flag of mLongTapEventFlag
       
   232      */
       
   233     void contextMenuClosed();
       
   234     
       
   235     /**
       
   236      * @brief Called when contextMenu item is triggered
       
   237      */
       
   238     void contextManuTriggered(HbAction *action);
       
   239 
       
   240 private:
       
   241     /**
       
   242      * @var mDate
       
   243      * @brief Stores the date for which this widget is being shown
       
   244      */
       
   245     QDateTime mDate;
       
   246     
       
   247     /**
       
   248      * @var mInstanceArray
       
   249      * @brief Holds the list of instances for the day
       
   250      */
       
   251     QList<AgendaEntry> mInstanceArray;
       
   252     
       
   253     /**
       
   254      * @var mHeadingLabel
       
   255      * @brief The heading widget which shows the date
       
   256      */
       
   257     HbGroupBox *mHeadingLabel;
       
   258     
       
   259     /**
       
   260      * @var mEventsList
       
   261      * @brief The list view which shows the list of events
       
   262      */
       
   263     HbListView *mEventsList;
       
   264 
       
   265     /**
       
   266      * @var mServices
       
   267      * @brief The reference to the MCalenServices object
       
   268      */
       
   269     MCalenServices &mServices;
       
   270     
       
   271     /**
       
   272      * @var mView
       
   273      * @brief The pointer to the view
       
   274      */
       
   275     CalenDayView *mView;
       
   276     
       
   277     /**
       
   278      * @var mDocLoader
       
   279      * @brief The pointer to the document loader which has
       
   280      * loaded this widget
       
   281      */
       
   282     CalenDocLoader *mDocLoader;
       
   283     
       
   284     /**
       
   285      * @var mListViewPrototype
       
   286      * @brief Acts as the item prototype for list view.
       
   287      * Allows providing own layout for list items
       
   288      */
       
   289     CalenEventListViewItem *mListViewPrototype;
       
   290 	
       
   291     /**
       
   292      * @var mEmptyListLabel
       
   293      * @brief The pointer to the empty view label
       
   294      */
       
   295 	HbLabel *mEmptyListLabel;
       
   296 	
       
   297 	/**
       
   298 	 * @var mListModel
       
   299 	 * @brief The event list model
       
   300 	 */
       
   301 	QStandardItemModel *mListModel;
       
   302 	
       
   303 	/**
       
   304 	 * @var mSelectedIndex
       
   305 	 * @brief Stores the index of the item being acted upon
       
   306 	 * Since there is no focus, it becomes necessary to store the
       
   307 	 * index of the item on which user is performing some action
       
   308 	 */
       
   309 	int mSelectedIndex;
       
   310 	
       
   311 	/**
       
   312 	 * @var NotesEditor
       
   313 	 * @brief Pointer to the notes editor
       
   314 	 */
       
   315 	NotesEditor *mNotesEditor;
       
   316 	
       
   317 	/**
       
   318 	 * @var mDatePicker
       
   319 	 * @brief The date picker component
       
   320 	 */
       
   321 	HbDateTimePicker *mDatePicker;
       
   322 	
       
   323 	/**
       
   324 	 * @var mRegionalPluginLayout
       
   325 	 * @brief Regional Plugin layout pointer
       
   326 	 */
       
   327 	QGraphicsLinearLayout* mRegionalPluginLayout;
       
   328 	
       
   329 	/**
       
   330 	 * @var mRegionalInfoGroupBox
       
   331 	 * @brief Regional Plugin Info groupbox
       
   332 	 */
       
   333 	HbGroupBox *mRegionalInfoGroupBox;
       
   334 
       
   335 	/**
       
   336 	 * @var mSettingsManager
       
   337 	 * @brief Setting Manager pointer
       
   338 	 */
       
   339 	
       
   340 	XQSettingsManager *mSettingsManager;
       
   341 	
       
   342 	/**
       
   343 	 * @var mLongTapeventFlag
       
   344 	 * @brief Set flag true if contextmenu is opened
       
   345 	 */
       
   346 	bool mLongTapEventFlag;
       
   347 	
       
   348 };
       
   349 
       
   350 #endif //CALENDAYVIEWWIDGET_H
       
   351 
       
   352 // End of file	--Don't remove this.