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