|
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 "cntserviceviewmanager.h" |
|
19 |
|
20 #include "cntbaseview.h" |
|
21 #include "cntservicehandler.h" |
|
22 |
|
23 #include "cntservicecontactfetchview.h" |
|
24 #include "cntservicecontactselectionview.h" |
|
25 #include "cntserviceeditview.h" |
|
26 #include "cntservicecontactcardview.h" |
|
27 #include "cntservicesubeditview.h" |
|
28 #include "cntserviceassigncontactcardview.h" |
|
29 |
|
30 /*! |
|
31 Constructor |
|
32 */ |
|
33 CntServiceViewManager::CntServiceViewManager(CntMainWindow *mainWindow, CntViewParameters::ViewId defaultView, CntServiceHandler *aHandler): |
|
34 CntViewManager(mainWindow, defaultView), |
|
35 mServiceHandler(aHandler) |
|
36 { |
|
37 connect(mServiceHandler, SIGNAL(launchFetch(const QString&, const QString&, const QString&)), |
|
38 this, SLOT(launchFetch(const QString&, const QString&, const QString&))); |
|
39 connect(mServiceHandler, SIGNAL(launchEditor(QContact)), this, SLOT(launchEditor(QContact))); |
|
40 connect(mServiceHandler, SIGNAL(launchContactSelection(QContactDetail)), this, SLOT(launchContactSelection(QContactDetail))); |
|
41 connect(mServiceHandler, SIGNAL(launchContactCard(QContact)), this, SLOT(launchContactCard(QContact))); |
|
42 connect(mServiceHandler, SIGNAL(launchAssignContactCard(QContact, QContactDetail)), this, |
|
43 SLOT(launchAssignContactCard(QContact, QContactDetail))); |
|
44 } |
|
45 |
|
46 /*! |
|
47 Destructor |
|
48 */ |
|
49 CntServiceViewManager::~CntServiceViewManager() |
|
50 { |
|
51 /*Remove all views*/ |
|
52 } |
|
53 |
|
54 /*! |
|
55 Launch fetch service view |
|
56 */ |
|
57 void CntServiceViewManager::launchFetch(const QString &title, const QString &action, const QString &filter) |
|
58 { |
|
59 CntBaseView *view = getView(CntViewParameters::serviceContactFetchView); |
|
60 if (view) |
|
61 { |
|
62 //add view to main window |
|
63 addViewToWindow(view); |
|
64 view->setTitle(title); |
|
65 static_cast<CntServiceContactFetchView*>(view)->setActionFilter(action, filter); |
|
66 CntViewParameters viewParameters(CntViewParameters::noView); |
|
67 view->activateView(viewParameters); |
|
68 } |
|
69 } |
|
70 |
|
71 /*! |
|
72 Launch editor service view |
|
73 */ |
|
74 void CntServiceViewManager::launchEditor(QContact contact) |
|
75 { |
|
76 CntBaseView *view = getView(CntViewParameters::serviceEditView); |
|
77 if (view) |
|
78 { |
|
79 //add view to main window |
|
80 addViewToWindow(view); |
|
81 CntViewParameters viewParameters(CntViewParameters::noView); |
|
82 viewParameters.setSelectedContact(contact); |
|
83 view->activateView(viewParameters); |
|
84 } |
|
85 } |
|
86 |
|
87 /*! |
|
88 Launch contact selection service view (update existing contact with detail) |
|
89 */ |
|
90 void CntServiceViewManager::launchContactSelection(QContactDetail detail) |
|
91 { |
|
92 CntBaseView *view = getView(CntViewParameters::serviceContactSelectionView); |
|
93 if (view) |
|
94 { |
|
95 //add view to main window |
|
96 addViewToWindow(view); |
|
97 CntViewParameters viewParameters(CntViewParameters::noView); |
|
98 viewParameters.setSelectedDetail(detail); |
|
99 view->activateView(viewParameters); |
|
100 } |
|
101 } |
|
102 |
|
103 /*! |
|
104 Launch contact card service view |
|
105 */ |
|
106 void CntServiceViewManager::launchContactCard(QContact contact) |
|
107 { |
|
108 CntBaseView *view = getView(CntViewParameters::serviceContactCardView); |
|
109 if (view) |
|
110 { |
|
111 //add view to main window |
|
112 addViewToWindow(view); |
|
113 CntViewParameters viewParameters(CntViewParameters::noView); |
|
114 viewParameters.setSelectedContact(contact); |
|
115 view->activateView(viewParameters); |
|
116 } |
|
117 } |
|
118 |
|
119 /*! |
|
120 Launch assign (temporary) contact card service view |
|
121 */ |
|
122 void CntServiceViewManager::launchAssignContactCard(QContact contact, QContactDetail detail) |
|
123 { |
|
124 CntBaseView *view = getView(CntViewParameters::serviceAssignContactCardView); |
|
125 if (view) |
|
126 { |
|
127 //add view to main window |
|
128 addViewToWindow(view); |
|
129 CntViewParameters viewParameters(CntViewParameters::noView); |
|
130 viewParameters.setSelectedContact(contact); |
|
131 viewParameters.setSelectedDetail(detail); |
|
132 view->activateView(viewParameters); |
|
133 } |
|
134 } |
|
135 |
|
136 /*! |
|
137 Create a view based on ID. \Return pointer to new object if success, 0 if not. |
|
138 */ |
|
139 CntBaseView *CntServiceViewManager::getView(CntViewParameters::ViewId id) |
|
140 { |
|
141 CntBaseView* view(0); |
|
142 |
|
143 switch (id) |
|
144 { |
|
145 // contact fetch service view (fetching contacts from for example messaging) |
|
146 case CntViewParameters::serviceContactFetchView: |
|
147 { |
|
148 view = new CntServiceContactFetchView(mServiceHandler, this); |
|
149 break; |
|
150 } |
|
151 // contact selection service view (selecting contact to edit when updating existing contact) |
|
152 case CntViewParameters::serviceContactSelectionView: |
|
153 { |
|
154 view = new CntServiceContactSelectionView(mServiceHandler, this); |
|
155 break; |
|
156 } |
|
157 // communication launcher service view |
|
158 case CntViewParameters::serviceContactCardView: |
|
159 { |
|
160 view = new CntServiceContactCardView(mServiceHandler, this); |
|
161 break; |
|
162 } |
|
163 // communication launcher service view |
|
164 case CntViewParameters::serviceAssignContactCardView: |
|
165 { |
|
166 view = new CntServiceAssignContactCardView(mServiceHandler, this); |
|
167 break; |
|
168 } |
|
169 // contact edit service view (editing a contact from outside phonebook app) |
|
170 case CntViewParameters::serviceEditView: |
|
171 { |
|
172 view = new CntServiceEditView(mServiceHandler, this); |
|
173 break; |
|
174 } |
|
175 // edit view when editor opened from comm laucher service view |
|
176 case CntViewParameters::serviceSubEditView: |
|
177 { |
|
178 view = new CntServiceSubEditView(mServiceHandler, this); |
|
179 break; |
|
180 } |
|
181 default: |
|
182 { |
|
183 view = CntViewManager::getView(id); |
|
184 break; |
|
185 } |
|
186 } |
|
187 |
|
188 return view; |
|
189 } |
|
190 |
|
191 // end of file |