⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calendarapiexampledocument.h

📁 该源码实现个人日程管理以及备忘功能
💻 H
字号:
/*
* ============================================================================
*  Name     : CCalendarAPIexampleDocument from CalendarAPIexampleDocument.h
*  Part of  : CalendarAPIexample
*  Created  : 02/22/2005 by Forum Nokia
*  Description:
*     Declares document for application.
*  Version  : 1.0
*  Copyright: Nokia Corporation
* ============================================================================
*/

#ifndef CALENDARAPIEXAMPLEDOCUMENT_H
#define CALENDARAPIEXAMPLEDOCUMENT_H 

// INCLUDE FILES
#include <akndoc.h>	  //CAknDocument
#include <agmentry.h> //CAgnAnniv
#include <agmcallb.h> //MAgnProgressCallBack
#include "CalendarAPIexample.hrh"

// FORWARD DECLARATIONS
class  CEikAppUi;
class  CCalendarAPIexampleEngine;
class  CEntry;

enum TSearchType
	{
	EWeek,
	EMonth,
	ESixMonths,
	EYear
	};
	
// CLASS DECLARATION

/*!
*  CCalendarAPIexampleDocument application class.
*/
class CCalendarAPIexampleDocument : public CAknDocument
    {
public: // Constructors and destructor
   /*!
	* Two-phased constructor.
	*/
	static CCalendarAPIexampleDocument* NewL(CEikApplication& aApp);

   /*!
	* Destructor.
	*/
	virtual ~CCalendarAPIexampleDocument();

public: // New functions

   /*!
    * EntryCount()
    * 
	* Returns the number of found anniversaries.
    */
	TInt EntryCount() const;

   /*!
    * Entry()
    * 
	* Returns a reference to an entry.
	* param aIndex - index of the wanted entry.
    */
    CEntry& Entry(const TInt& aIndex);
    
   /*!
    * DoSearchL()
    * 
	* Finds all anniversaries in given time interval.
	* param aType - search interval (week, month...)
	* param aProgressCallBack - pointer to a class that observes agenda progress
    */    
    void DoSearchL(	const TSearchType& aType,
    				MAgnProgressCallBack* aProgressCallBack = NULL);
    				
   /*!
    * ResetModifyIndex()
    * 
    * Resets the modify index. By Reseting the modify index, the next call to 
    * EntryForModificationL() will create a new entry instead of returning
    * a reference to an existing entry.
    */        				
    void ResetModifyIndex();
    
    
   /*!
    * ModifyIndex()
    * 
    * Returns the modify index. 
    */        				
    TInt ModifyIndex() const;
    
   /*!
    * SetModifyIndex()
    * 
    * Sets the modify index to given index. Modify index is used when calling
    * EntryForModificationL. 
    * param aIndex - modify index is set to this index
    */        				    
	void SetModifyIndex(const TInt& aIndex);
	
   /*!
    * EntryForModificationL()
    * 
    * Returns a reference to an entry. If iModifyIndex is negative, a new entry is created,
    * otherwise a reference to an existing entry (defined by iModifyIndex) is returned.
    * param aModify - is set to EFalse if a new entry was created and ETrue if existing
    *				  entry was returned.
    */        				    	
	CEntry& EntryForModificationL(TBool& aModify);
	
   /*!
    * SaveL()
    * 
    * Adds or updates the current entry to the agenda file. Current entry is defined by
    * calling EntryForModificationL().
    */        				    	
	void SaveL();
	
   /*!
    * DeleteEntryL()
    * 
    * Deletes an entry from the agenda file.
    * param aIndex - index of which entry is deleted.
    */        				    		
	void DeleteEntryL(const TInt& aIndex);

private:

   /*!
	* Symbian OS default constructor.
	*/
	CCalendarAPIexampleDocument(CEikApplication& aApp);
	void ConstructL();

   /*!
    * From CEikDocument, create CCalendarAPIexampleAppUi "App UI" object.
    */
    CEikAppUi* CreateAppUiL();

private: // data members   

    CCalendarAPIexampleEngine* iEngine;
    RPointerArray<CEntry> iEntries;
    TSearchType iCurrentSearchType;
    CEntry* iEntry;
    TInt iModifyIndex;
    };


// CLASS DECLARATION

/*!
*  CEntry - wrapper class for handling CAgnAnniv.
*/    
class CEntry : public CBase
	{
public: // Constructors and destructor
   /*!
	* Two-phased constructor.
	*/	static CEntry* NewL(CAgnAnniv* aAnniv);
	static CEntry* NewLC(CAgnAnniv* aAnniv);

   /*!
	* Destructor.
	*/
	~CEntry();
	
public:

   /*!
    * NewAnnivLC()
    * 
    * Creates a new CAgnAnniv object, initializes it with entrys data and returns it.
    */        				    		
	CAgnAnniv* NewAnnivLC();
	
   /*!
    * SaveValuesL()
    * 
    * Sets entrys values to entrys member CAgnAnniv object (iAnniv). Use SaveValuesL first 
    * to set values to entry. Call to SaveValuesL is required only just before anniversary 
    * is added or updated to the agenda file.
    */        				    		
	void SaveValuesL();
	
   /*!
    * SetValuesL()
    * 
    * Sets given values to entry. Returns ETrue if values are valid, EFalse if not.
    * After setting values, use SaveValuesL() to set entrys 
    * values to entrys member CAgnAnniv object (iAnniv).
    * param aName - name of description of anniversary.
    * param aAge - age of the anniversary
    * param aDate - date when the anniversary occurs.
    * param aAlarm - defines whether the anniversary has an alarm
    * param aAlarmTime - time when the alarm goes off.
    * param aSynchronizationMethod - defines how the anniversary is synchronized with e.g. PC.
    */        				    			
	TBool SetValuesL(	const TDesC& aName,
						const TInt& aAge,
						const TDateTime& aDate,
						const TBool& aAlarm,
						const TDateTime& aAlarmTime,
						const TInt& aSynchronizationMethod);

	// Getters
	TBuf<KMaxNameLength> Name() const;
	TInt Age() const;
	TDateTime Date() const;
	TBool Alarm() const;
	TDateTime AlarmTime() const;
	TInt SynchronizationMethod() const;
	CAgnAnniv* Anniv();
	TBool Modified() const;
	TBool DateHasChanged() const;
	
private:
   /*!
	* Symbian OS default constructor.
	*/
	CEntry();
	void ConstructL(CAgnAnniv* aAnniv);
	
   /*!
    * CreateAnnivL()
    * 
    * Creates a new CAgnAnniv object and returns it.
    */        				    		
	CAgnAnniv* CreateAnnivL();

   /*!
    * SaveValuesToAnnivL()
    * 
    * Sets entrys values to given CAgnAnniv object.
    * param aAnniv - CAgnAnniv object where entrys values are set.
    */        				    		
	void SaveValuesToAnnivL(CAgnAnniv* aAnniv);
	
   /*!
    * ResetTimeL()
    * 
    * Sets given dates time to midnight.
    * param aDate - date to be reset.
    */        				    		
	void ResetTimeL(TDateTime& aDate) const;

   /*!
    * GetDaysAndMinutesL()
    * 
    * Calculates how many days and minutes aTime is from aFromTime
    * param aTime - time that is compared to aFromTime.
    * param aFromTime - time that aTime is compared to.
    * param aDays - Calculated days.
    * param aMinutes - Calculated.
    */        				    		
	void CEntry::GetDaysAndMinutesL(const TDateTime& aTime, 
									const TDateTime& aFromTime,
									TTimeIntervalDays& aDays, 
									TTimeIntervalMinutes& aMinutes) const;


   /*!
    * Setters()
    * 
    * Sets values to member variables, and also checks has the data changed.
    * If data has changed, iModified is set ETrue.
    */        				    			
	void SetName(const TDesC& aName);
	void SetDate(const TDateTime& aDate);
	void SetAge(const TInt& aAge);
	void SetAlarm(const TBool& aAlarm);
	void SetSynchronizationMethod(const TInt& aSynchronizationMethod);


private: // data members

	TBuf<KMaxNameLength> iName;
	TInt iAge;
	TDateTime iDate;
	TBool iAlarm;
	TDateTime iAlarmTime;
	TInt iSynchronizationMethod;
	TTimeIntervalDays iAlarmDays;
	TTimeIntervalMinutes iAlarmMinutes;
	TBool iModified;
	TBool iDateModified;
	
	CAgnAnniv* iAnniv;
	};

#endif

// End of File

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -