examples/ForumNokia/CalendarExample/src/CalendarAPIexampleEntryItemList.cpp

00001 /*
00002  * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003  *    
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *    
00007  *  * Redistributions of source code must retain the above copyright notice, this
00008  *    list of conditions and the following disclaimer.
00009  *  * Redistributions in binary form must reproduce the above copyright notice,
00010  *    this list of conditions and the following disclaimer in the documentation
00011  *    and/or other materials provided with the distribution.
00012  *  * Neither the name of Nokia Corporation nor the names of its contributors
00013  *    may be used to endorse or promote products derived from this software
00014  *    without specific prior written permission.
00015  *    
00016  *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017  *    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018  *    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019  *    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020  *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021  *    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022  *    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023  *    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024  *    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025  *    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026  *    
00027  *    Description:  
00028  */
00029 
00030 // INCLUDE FILES
00031 #include "CalendarAPIexampleEntryItemList.h"
00032 #include "CalendarHelperEntry.h"
00033 #include "CalendarAPIexampleEntryView.h"
00034 #include <AknQueryDialog.h>
00035 
00036 // ================= MEMBER FUNCTIONS =======================
00037 
00038 
00039 // ----------------------------------------------------
00040 // CCalendarAPIexampleEntryItemList::CreateSettingItemL()
00041 // Framework method to create a setting item based upon 
00042 // the user id aSettingId. The client code decides what
00043 // type to construct. new (ELeave) must then be used and
00044 // the resulting pointer returned. Ownership is 
00045 // thereafter base class's responsibility.
00046 // ----------------------------------------------------
00047 //
00048 CAknSettingItem* CCalendarAPIexampleEntryItemList::CreateSettingItemL( 
00049                                                             TInt aIdentifier )
00050     {   
00051     CAknSettingItem* settingItem = NULL;
00052 
00053     // create a setting item for each setting list resource
00054     switch (aIdentifier)
00055     {
00056     case ECalendarAPIexampleNameItem:
00057         {
00058         settingItem = new (ELeave) CAknTextSettingItem(aIdentifier, iName);
00059         break;
00060         }
00061     case ECalendarAPIexampleDateItem:
00062         settingItem = new (ELeave)  CAknTimeOrDateSettingItem(  
00063                                             aIdentifier, 
00064                                             CAknTimeOrDateSettingItem::EDate,
00065                                             iDate);
00066         break;
00067     case ECalendarAPIexampleAlarmItem:
00068         settingItem = new (ELeave) CAknBinaryPopupSettingItem(aIdentifier, 
00069                                                               iAlarm);
00070         break;
00071     case ECalendarAPIexampleAlarmTimeItem:
00072         settingItem = new (ELeave)  CAknTimeOrDateSettingItem(
00073                                             aIdentifier, 
00074                                             CAknTimeOrDateSettingItem::ETime,
00075                                             iAlarmTime);
00076         break;
00077     case ECalendarAPIexampleAlarmDateItem:
00078         settingItem = new (ELeave)  CAknTimeOrDateSettingItem(  
00079                                             aIdentifier, 
00080                                             CAknTimeOrDateSettingItem::EDate,
00081                                             iAlarmDate);
00082         break;
00083     case ECalendarAPIexampleSyncItem:
00084         settingItem = new (ELeave) CAknEnumeratedTextPopupSettingItem(  aIdentifier, 
00085                                                                         iSync);
00086         break;
00087     default:
00088         break;
00089         }
00090     return settingItem;
00091     
00092     }
00093 
00094 
00095     
00096 // ----------------------------------------------------
00097 // CCalendarAPIexampleEntryItemList::SetData()
00098 // Reads values to each item in item list from the given
00099 // entry.
00100 // ----------------------------------------------------
00101 //  
00102 void CCalendarAPIexampleEntryItemList::SetData(const CCalHelperEntry& aData)
00103     {
00104     iName = aData.Name();
00105     iDate = aData.Date();
00106     iAlarm = (aData.Alarm() != 0);
00107     iAlarmTime = aData.AlarmTime();
00108     iAlarmDate = aData.AlarmTime();
00109     iSync = aData.SynchronizationMethod();
00110     }
00111     
00112 // ----------------------------------------------------
00113 // CCalendarAPIexampleEntryItemList::SaveL()
00114 // Sets value from itemlist to the given entry. Returns
00115 // false if user input was invalid, otherwise true is
00116 // returned.
00117 // ----------------------------------------------------
00118 //  
00119 TBool CCalendarAPIexampleEntryItemList::SaveL()
00120     {
00121     StoreSettingsL();
00122     return ETrue;
00123     }
00124 
00125 void CCalendarAPIexampleEntryItemList::GetValues(TDes& aName, TTime& aDate,
00126                    TBool& aAlarm, TTime& aAlarmTime,
00127                             TInt& aSync)
00128     {
00129     TDateTime alarmTime = iAlarmTime.DateTime();
00130     TDateTime alarmDate = iAlarmDate.DateTime();
00131     
00132     alarmTime.SetYear(alarmDate.Year());
00133     alarmTime.SetMonth(alarmDate.Month());
00134     alarmTime.SetDay(alarmDate.Day());    
00135     
00136     aName = iName;
00137     aDate = iDate;
00138     aAlarm = iAlarm;
00139     aAlarmTime = alarmTime;
00140     aSync = iSync;    
00141     
00142     }
00143 
00144 void CCalendarAPIexampleEntryItemList::SetValues(
00145                             const TDesC& aName,
00146                             const TDateTime& aDate,
00147                             const TBool& aAlarm,
00148                             const TDateTime& aAlarmTime,
00149                             const TInt& aSync)                            
00150     {
00151     iName = aName;
00152     iDate = aDate;
00153     iAlarm = aAlarm;
00154     iAlarmTime = aAlarmTime;
00155     iAlarmDate = aAlarmTime;
00156     iSync = aSync;    
00157     }
00158 
00159 
00160 // End of File

Generated by  doxygen 1.6.2