174 */ |
174 */ |
175 void NmSettingsViewFactory::launchSettingView(const NmId &mailboxId, |
175 void NmSettingsViewFactory::launchSettingView(const NmId &mailboxId, |
176 const QString &mailboxName) const |
176 const QString &mailboxName) const |
177 { |
177 { |
178 NM_FUNCTION; |
178 NM_FUNCTION; |
179 |
179 |
180 // There's always at least one valid main window available. |
180 // There's always at least one valid main window available. |
181 HbMainWindow *mainWindow = hbInstance->allMainWindows().takeFirst(); |
181 HbMainWindow *mainWindow = hbInstance->allMainWindows().takeFirst(); |
182 |
182 |
183 NmMailboxSettingView *currentSettingsView = |
183 NmMailboxSettingView *currentSettingsView = |
184 qobject_cast<NmMailboxSettingView*>(mainWindow->currentView()); |
184 qobject_cast<NmMailboxSettingView*>(mainWindow->currentView()); |
185 |
185 |
186 // Let's have only one same settings view at a time open, |
186 // Let's have only one same settings view at a time open, |
187 // but if some other mailboxes settings view want's to open while |
187 // but if some other mailboxes settings view want's to open while |
188 // there is a settings view open let's open it also. |
188 // there is a settings view open let's open it also. |
189 if (!currentSettingsView || (currentSettingsView->mailboxId().id() != mailboxId.id())) { |
189 if (!currentSettingsView || (currentSettingsView->mailboxId().id() != mailboxId.id())) { |
190 CpBaseSettingView *view = |
190 CpBaseSettingView *view = |
191 new NmMailboxSettingView(mailboxId, mailboxName, *mSettingsManager); |
191 new NmMailboxSettingView(mailboxId, mailboxName, *mSettingsManager); |
192 |
192 |
193 connect(mSettingsManager, |
193 connect(mSettingsManager, |
194 SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)), |
194 SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)), |
195 view, SLOT(mailboxListChanged(const NmId &, NmSettings::MailboxEventType))); |
195 view, SLOT(mailboxListChanged(const NmId &, NmSettings::MailboxEventType))); |
196 |
196 |
197 connect(mSettingsManager, |
197 connect(mSettingsManager, |
198 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)), |
198 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)), |
199 view, SLOT(mailboxPropertyChanged(const NmId &, QVariant, QVariant))); |
199 view, SLOT(mailboxPropertyChanged(const NmId &, QVariant, QVariant))); |
200 |
200 |
201 // Disconnect mSettingsViewLauncher's previous connections to |
201 // Disconnect mSettingsViewLauncher's previous connections to |
202 // be sure that signals which are offered out will be sent last. |
202 // be sure that signals which are offered out will be sent last. |
203 mSettingsManager->disconnect( |
203 mSettingsManager->disconnect( |
204 SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)), |
204 SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)), |
205 mSettingsViewLauncher, |
205 mSettingsViewLauncher, |
206 SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType))); |
206 SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType))); |
207 |
207 |
208 mSettingsManager->disconnect( |
208 mSettingsManager->disconnect( |
209 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)), |
209 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)), |
210 mSettingsViewLauncher, |
210 mSettingsViewLauncher, |
211 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant))); |
211 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant))); |
212 |
212 |
213 // Reconnect mSettingsViewLauncher. |
213 // Reconnect mSettingsViewLauncher. |
214 connect(mSettingsManager, |
214 connect(mSettingsManager, |
215 SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)), |
215 SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)), |
216 mSettingsViewLauncher, |
216 mSettingsViewLauncher, |
217 SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType))); |
217 SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType))); |
218 |
218 |
219 connect(mSettingsManager, |
219 connect(mSettingsManager, |
220 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)), |
220 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)), |
221 mSettingsViewLauncher, |
221 mSettingsViewLauncher, |
222 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant))); |
222 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant))); |
223 |
223 |
224 connect(mSettingsManager, |
224 connect(mSettingsManager, |
225 SIGNAL(goOnline(const NmId &)), |
225 SIGNAL(goOnline(const NmId &)), |
226 mSettingsViewLauncher, |
226 mSettingsViewLauncher, |
227 SIGNAL(goOnline(const NmId &)), Qt::UniqueConnection); |
227 SIGNAL(goOnline(const NmId &)), Qt::UniqueConnection); |
228 |
228 |
229 connect(mSettingsManager, |
229 connect(mSettingsManager, |
230 SIGNAL(goOffline(const NmId &)), |
230 SIGNAL(goOffline(const NmId &)), |
231 mSettingsViewLauncher, |
231 mSettingsViewLauncher, |
232 SIGNAL(goOffline(const NmId &)), Qt::UniqueConnection); |
232 SIGNAL(goOffline(const NmId &)), Qt::UniqueConnection); |
233 |
233 |
234 connect(this, |
234 connect(this, |
235 SIGNAL(aboutToClose()), |
235 SIGNAL(aboutToClose()), |
236 mSettingsManager, |
236 mSettingsManager, |
237 SIGNAL(aboutToClose()), Qt::UniqueConnection); |
237 SIGNAL(aboutToClose()), Qt::UniqueConnection); |
238 |
238 |
239 // Create back navigation action for a view. |
239 // Create back navigation action for a view. |
240 HbAction *action = new HbAction(Hb::BackNaviAction, view); |
240 HbAction *action = new HbAction(Hb::BackNaviAction, view); |
241 connect(action, SIGNAL(triggered()), this, SLOT(backPress())); |
241 connect(action, SIGNAL(triggered()), this, SLOT(backPress())); |
242 view->setNavigationAction(action); |
242 view->setNavigationAction(action); |
243 mPrevView = mainWindow->currentView(); |
243 mPrevView = mainWindow->currentView(); |
244 mainWindow->addView(view); |
244 mainWindow->addView(view); |
245 mainWindow->setCurrentView(view); |
245 mainWindow->setCurrentView(view); |
246 } |
246 } |
247 } |
247 } |
248 |
248 |
249 /*! |
249 /*! |
250 Handels back button press. |
250 Handels back button press. |
251 Removes the current view from the main window and activates the previous view. |
251 Removes the current view from the main window and activates the previous view. |
252 Destroys removed view. |
252 Destroys removed view. |
253 */ |
253 */ |
254 void NmSettingsViewFactory::backPress() |
254 void NmSettingsViewFactory::backPress() |
255 { |
255 { |
256 NM_FUNCTION; |
256 NM_FUNCTION; |
257 |
257 |
258 emit aboutToClose(); |
258 emit aboutToClose(); |
259 HbMainWindow *mainWindow = hbInstance->allMainWindows().takeFirst(); |
259 HbMainWindow *mainWindow = hbInstance->allMainWindows().takeFirst(); |
260 QList<HbView *> views = mainWindow->views(); |
260 QList<HbView *> views = mainWindow->views(); |
261 if (views.count() > 1) { |
261 if (views.count() > 1) { |
262 HbView *currentView = mainWindow->currentView(); |
262 HbView *currentView = mainWindow->currentView(); |