calendarui/globaldata/src/calencontextimpl.cpp
changeset 45 b6db4fd4947b
parent 18 c198609911f9
child 83 5aadd1120515
equal deleted inserted replaced
23:fd30d51f876b 45:b6db4fd4947b
    69 // CalenContextImpl::~CalenContextImpl
    69 // CalenContextImpl::~CalenContextImpl
    70 // Destructor.
    70 // Destructor.
    71 // (other items were commented in a header).
    71 // (other items were commented in a header).
    72 // ----------------------------------------------------------------------------
    72 // ----------------------------------------------------------------------------
    73 //
    73 //
    74 CalenContextImpl::~CalenContextImpl()
    74 EXPORT_C CalenContextImpl::~CalenContextImpl()
    75     {
    75 	{
    76     }
    76 	if(mMutlipleContextIds.count())
       
    77 		{
       
    78 		mMutlipleContextIds.clear();
       
    79 		}
       
    80 	}
    77 
    81 
    78 // ----------------------------------------------------------------------------
    82 // ----------------------------------------------------------------------------
    79 // CalenContextImpl::DefaultTimeForViews
    83 // CalenContextImpl::DefaultTimeForViews
    80 // If a view knows what day they should be looking at, but doesn't know what
    84 // If a view knows what day they should be looking at, but doesn't know what
    81 // time (for example the month view only deals in days), they should set the
    85 // time (for example the month view only deals in days), they should set the
   109 // CalenContextImpl::SetFocusDateAndTimeL
   113 // CalenContextImpl::SetFocusDateAndTimeL
   110 // Sets the focus time
   114 // Sets the focus time
   111 // (other items were commented in a header).
   115 // (other items were commented in a header).
   112 // ----------------------------------------------------------------------------
   116 // ----------------------------------------------------------------------------
   113 //
   117 //
   114 void CalenContextImpl::setFocusDateAndTimeL( const QDateTime& focusDateTime,
   118 void CalenContextImpl::setFocusDateAndTime( const QDateTime& focusDateTime)
   115                                                    const int& viewId )
   119     {
   116     {
   120 
       
   121     mFocusDate = focusDateTime;
       
   122     mFocusTime = focusDateTime.time().minute() + 1;
       
   123     
       
   124     if( mFocusTime < 0 )
       
   125         mFocusTime = 0;
       
   126     mInstanceId = TCalenInstanceId::nullInstanceId();
   117 
   127 
   118     // If this fails you're using a context that was constructed yourself.
   128     // If this fails you're using a context that was constructed yourself.
   119     // Use the accessor from the global data instead, or don't try to set
   129     // Use the accessor from the global data instead, or don't try to set
   120     // anything on this context.
   130     // anything on this context.
   121     ASSERT( mObserver );
   131     if(mObserver)
   122 
   132         mObserver->ContextChanged();
   123     mFocusDate = focusDateTime;
       
   124     mFocusTime = focusDateTime.time().minute() + 1;
       
   125     
       
   126     ASSERT( mFocusTime >= 0 );
       
   127     mInstanceId = TCalenInstanceId::nullInstanceId();
       
   128     mViewId = viewId;
       
   129 
       
   130     mObserver->ContextChanged();
       
   131     }
   133     }
   132 
   134 
   133 // ----------------------------------------------------------------------------
   135 // ----------------------------------------------------------------------------
   134 // CalenContextImpl::SetFocusDateL
   136 // CalenContextImpl::SetFocusDateL
   135 // Sets the focus date
   137 // Sets the focus date
   136 // (other items were commented in a header).
   138 // (other items were commented in a header).
   137 // ----------------------------------------------------------------------------
   139 // ----------------------------------------------------------------------------
   138 //
   140 //
   139 void CalenContextImpl::setFocusDateL( const QDateTime& focusDateTime,
   141 void CalenContextImpl::setFocusDate( const QDateTime& focusDateTime)
   140                                                 const int& viewId )
   142     {
   141     {
   143     mFocusDate = focusDateTime;
       
   144     mFocusTime = -1;
       
   145     mInstanceId = TCalenInstanceId::nullInstanceId();
       
   146 
   142     // If this fails you're using a context that was constructed yourself.
   147     // If this fails you're using a context that was constructed yourself.
   143     // Use the accessor from the global data instead, or don't try to set
   148     // Use the accessor from the global data instead, or don't try to set
   144     // anything on this context.
   149     // anything on this context.
   145     ASSERT( mObserver );
   150     if(mObserver)
   146 
   151         mObserver->ContextChanged();
   147     mFocusDate = focusDateTime;
       
   148     mFocusTime = -1;
       
   149     mInstanceId = TCalenInstanceId::nullInstanceId();
       
   150     mViewId = viewId;
       
   151 
       
   152     mObserver->ContextChanged();
       
   153     }
   152     }
   154 
   153 
   155 // ----------------------------------------------------------------------------
   154 // ----------------------------------------------------------------------------
   156 // CalenContextImpl::SetInstanceIdL
   155 // CalenContextImpl::SetInstanceIdL
   157 // Sets the instance id
   156 // Sets the instance id
   158 // (other items were commented in a header).
   157 // (other items were commented in a header).
   159 // ----------------------------------------------------------------------------
   158 // ----------------------------------------------------------------------------
   160 //
   159 //
   161 void CalenContextImpl::setInstanceIdL( const TCalenInstanceId& aInstanceId,
   160 void CalenContextImpl::setInstanceId( const TCalenInstanceId& aInstanceId )
   162                                              const int& viewId )
   161     {
   163     {
   162 
   164 
       
   165     // If this fails you're using a context that was constructed yourself.
       
   166     // Use the accessor from the global data instead, or don't try to set
       
   167     // anything on this context.
       
   168     ASSERT( mObserver );
       
   169     
       
   170     // Set the null date and time
   163     // Set the null date and time
   171     mFocusDate = QDateTime();
   164     mFocusDate = QDateTime();
   172     mFocusTime = -1;
   165     mFocusTime = -1;
   173     mInstanceId = aInstanceId;
   166     mInstanceId = aInstanceId;
   174     mViewId = viewId;
       
   175 
       
   176     mObserver->ContextChanged();
       
   177     }
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // CalenContextImpl::SetFocusDateAndTimeAndInstanceL
       
   181 // Sets the currently focused time and instance
       
   182 // (other items were commented in a header).
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 void CalenContextImpl::setFocusDateAndTimeAndInstanceL( const QDateTime& focusDateTime,
       
   186                                                               const TCalenInstanceId& instanceId,
       
   187                                                               const int& viewId )
       
   188     {
       
   189 
   167 
   190     // If this fails you're using a context that was constructed yourself.
   168     // If this fails you're using a context that was constructed yourself.
   191     // Use the accessor from the global data instead, or don't try to set
   169     // Use the accessor from the global data instead, or don't try to set
   192     // anything on this context.
   170     // anything on this context.
   193     ASSERT( mObserver );
   171     if(mObserver)
   194 
   172         mObserver->ContextChanged();
       
   173     }
       
   174 
       
   175 // -----------------------------------------------------------------------------
       
   176 // CalenContextImpl::SetFocusDateAndTimeAndInstanceL
       
   177 // Sets the currently focused time and instance
       
   178 // (other items were commented in a header).
       
   179 // -----------------------------------------------------------------------------
       
   180 //
       
   181 void CalenContextImpl::setFocusDateAndTimeAndInstance( const QDateTime& focusDateTime,
       
   182                                                               const TCalenInstanceId& instanceId )
       
   183     {
   195     mFocusDate = focusDateTime;
   184     mFocusDate = focusDateTime;
   196     mFocusTime = focusDateTime.time().minute() + 1;
   185     mFocusTime = focusDateTime.time().minute() + 1;
   197     ASSERT( mFocusTime >= 0 );
   186     if( mFocusTime < 0 )
       
   187 		mFocusTime = 0;
   198     mInstanceId = instanceId;
   188     mInstanceId = instanceId;
   199     mViewId = viewId;
   189 
   200 
   190     // If this fails you're using a context that was constructed yourself.
   201     mObserver->ContextChanged();
   191     // Use the accessor from the global data instead, or don't try to set
       
   192     // anything on this context.
       
   193     if(mObserver)
       
   194         mObserver->ContextChanged();
   202     }
   195     }
   203 
   196 
   204 // -----------------------------------------------------------------------------
   197 // -----------------------------------------------------------------------------
   205 // CalenContextImpl::FocusDateAndTimeL
   198 // CalenContextImpl::FocusDateAndTimeL
   206 // Returns the focus time
   199 // Returns the focus time
   207 // (other items were commented in a header).
   200 // (other items were commented in a header).
   208 // -----------------------------------------------------------------------------
   201 // -----------------------------------------------------------------------------
   209 //
   202 //
   210 QDateTime CalenContextImpl::focusDateAndTimeL() const
   203 QDateTime CalenContextImpl::focusDateAndTime() const
   211     {
   204     {
   212     QDateTime ret;
   205     QDateTime ret;
   213 
   206 
   214     if( mFocusDate.isValid() )
   207     if( mFocusDate.isValid() )
   215         {
   208         {
   248     TRACE_EXIT_POINT;
   241     TRACE_EXIT_POINT;
   249     return mInstanceId;
   242     return mInstanceId;
   250     }
   243     }
   251 
   244 
   252 // -----------------------------------------------------------------------------
   245 // -----------------------------------------------------------------------------
   253 // CalenContextImpl::ViewId
       
   254 // Returns the view id
       
   255 // (other items were commented in a header).
       
   256 // -----------------------------------------------------------------------------
       
   257 //
       
   258 int CalenContextImpl::viewId() const
       
   259     {
       
   260     TRACE_ENTRY_POINT;
       
   261     TRACE_EXIT_POINT;
       
   262     return mViewId;
       
   263     }
       
   264 
       
   265 // -----------------------------------------------------------------------------
       
   266 // CalenContextImpl::SetMutlipleContextIds
   246 // CalenContextImpl::SetMutlipleContextIds
   267 // Set multiple context ids
   247 // Set multiple context ids
   268 // (other items were commented in a header).
   248 // (other items were commented in a header).
   269 // -----------------------------------------------------------------------------
   249 // -----------------------------------------------------------------------------
   270 //
   250 //