|
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: |
|
15 * |
|
16 */ |
|
17 #include "cntdateeditormodel.h" |
|
18 #include "cntdetailmodelitem.h" |
|
19 #include <hbdataformmodelitem.h> |
|
20 #include <qcontactbirthday.h> |
|
21 #include <qcontactanniversary.h> |
|
22 |
|
23 CntDateEditorModel::CntDateEditorModel( QContact* aContact ) : |
|
24 CntDetailEditorModel( aContact ) |
|
25 { |
|
26 QList<QContactBirthday> bdList = mContact->details<QContactBirthday>(); |
|
27 if ( bdList.isEmpty() ) |
|
28 { |
|
29 QContactBirthday birthday; |
|
30 bdList << birthday; |
|
31 } |
|
32 |
|
33 QList<QContactAnniversary> anniversaryList = mContact->details<QContactAnniversary>(); |
|
34 if ( anniversaryList.isEmpty() ) |
|
35 { |
|
36 QContactAnniversary anniversary; |
|
37 anniversaryList << anniversary; |
|
38 } |
|
39 |
|
40 mBirthday = bdList.first(); |
|
41 mAnniversary = anniversaryList.first(); |
|
42 |
|
43 HbDataFormModelItem* root = invisibleRootItem(); |
|
44 appendDataFormItem( new CntDetailModelItem( mBirthday, qtTrId("Birthday")), root ); |
|
45 appendDataFormItem( new CntDetailModelItem( mAnniversary, qtTrId("Anniversary")), root ); |
|
46 } |
|
47 |
|
48 CntDateEditorModel::~CntDateEditorModel() |
|
49 { |
|
50 } |
|
51 |
|
52 void CntDateEditorModel::saveContactDetails() |
|
53 { |
|
54 HbDataFormModelItem* root = invisibleRootItem(); |
|
55 // Birthday |
|
56 CntDetailModelItem* birthday = static_cast<CntDetailModelItem*>( root->childAt(0) ); |
|
57 mBirthday = birthday->detail(); |
|
58 if ( mBirthday.date().isValid() ) |
|
59 mContact->saveDetail( &mBirthday ); |
|
60 |
|
61 // Anniversary |
|
62 CntDetailModelItem* anniversary = static_cast<CntDetailModelItem*>( root->childAt(1) ); |
|
63 mAnniversary = anniversary->detail(); |
|
64 if ( mAnniversary.originalDate().isValid() ) |
|
65 mContact->saveDetail( &mAnniversary ); |
|
66 |
|
67 } |
|
68 // End of File |