|
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 |
|
18 #include <hbdocumentloader.h> |
|
19 #include <hbview.h> |
|
20 #include <hbdataform.h> |
|
21 #include <hbaction.h> |
|
22 #include "cntsettingsview.h" |
|
23 |
|
24 const char *CNT_SETTINGS_XML = ":/xml/contacts_settings.docml"; |
|
25 |
|
26 CntSettingsView::CntSettingsView() : QObject(), |
|
27 mView( NULL ), |
|
28 mDoc( NULL ), |
|
29 mForm( NULL ), |
|
30 mViewMgr( NULL ), |
|
31 mModel( NULL ) |
|
32 { |
|
33 bool ok; |
|
34 document()->load(CNT_SETTINGS_XML, &ok); |
|
35 if (!ok) { |
|
36 qFatal("Unable to read %S", CNT_SETTINGS_XML); |
|
37 } |
|
38 mModel = new CntDefaultSettingsModel(); // default implementation |
|
39 |
|
40 mView = static_cast<HbView*> (document()->findWidget(QString("view"))); |
|
41 mForm = static_cast<HbDataForm*> (document()->findWidget(QString("dataForm"))); |
|
42 mForm->setItemRecycling(true); |
|
43 mForm->setModel( mModel ); |
|
44 |
|
45 mBack = new HbAction(Hb::BackNaviAction, mView); |
|
46 connect( mBack, SIGNAL(triggered()), this, SLOT(back()) ); |
|
47 } |
|
48 |
|
49 CntSettingsView::~CntSettingsView() |
|
50 { |
|
51 mView->deleteLater(); |
|
52 delete mForm; |
|
53 delete mModel; |
|
54 delete mDoc; |
|
55 } |
|
56 |
|
57 void CntSettingsView::activate( CntAbstractViewManager* aMgr, const CntViewParameters aArgs ) |
|
58 { |
|
59 mViewMgr = aMgr; |
|
60 mArgs = aArgs; |
|
61 |
|
62 if ( mView->navigationAction() != mBack) { |
|
63 mView->setNavigationAction(mBack); |
|
64 } |
|
65 |
|
66 mModel->loadSettings(); |
|
67 } |
|
68 |
|
69 void CntSettingsView::deactivate() |
|
70 { |
|
71 } |
|
72 |
|
73 bool CntSettingsView::isDefault() const |
|
74 { |
|
75 return false; |
|
76 } |
|
77 |
|
78 HbView* CntSettingsView::view() const |
|
79 { |
|
80 return mView; |
|
81 } |
|
82 |
|
83 int CntSettingsView::viewId() const |
|
84 { |
|
85 return settingsView; |
|
86 } |
|
87 |
|
88 void CntSettingsView::back() |
|
89 { |
|
90 mModel->saveSettings(); |
|
91 mViewMgr->back( mArgs ); |
|
92 } |
|
93 HbDocumentLoader* CntSettingsView::document() |
|
94 { |
|
95 if ( !mDoc ) |
|
96 { |
|
97 mDoc = new HbDocumentLoader(); |
|
98 } |
|
99 return mDoc; |
|
100 } |