59 const QString &text, |
59 const QString &text, |
60 const QString &description, |
60 const QString &description, |
61 const HbIcon &icon, |
61 const HbIcon &icon, |
62 const HbDataFormModelItem *parent) |
62 const HbDataFormModelItem *parent) |
63 : CpSettingFormEntryItemData(itemDataHelper, text, description, icon, parent), |
63 : CpSettingFormEntryItemData(itemDataHelper, text, description, icon, parent), |
64 mSettingsManager(new NmMailboxSettingsManager()), mSettingsViewLauncher(0),mPrevView(0) |
64 mSettingsManager(new NmMailboxSettingsManager()), mSettingsViewLauncher(0),mPrevView(0), |
65 { |
65 mMessageBox(0) |
|
66 { |
|
67 createMessageBox(); |
66 } |
68 } |
67 |
69 |
68 |
70 |
69 /*! |
71 /*! |
70 Constructor of NmSettingsViewFactory. |
72 Constructor of NmSettingsViewFactory. |
83 const QString &text, |
85 const QString &text, |
84 const QString &description, |
86 const QString &description, |
85 const HbIcon &icon, |
87 const HbIcon &icon, |
86 const HbDataFormModelItem *parent) |
88 const HbDataFormModelItem *parent) |
87 : CpSettingFormEntryItemData(itemDataHelper, text, description, icon, parent), |
89 : CpSettingFormEntryItemData(itemDataHelper, text, description, icon, parent), |
88 mSettingsManager(new NmMailboxSettingsManager()), mSettingsViewLauncher(viewLauncher), mPrevView(0) |
90 mSettingsManager(new NmMailboxSettingsManager()), mSettingsViewLauncher(viewLauncher), |
89 { |
91 mPrevView(0), mMessageBox(0) |
|
92 { |
|
93 createMessageBox(); |
90 } |
94 } |
91 |
95 |
92 |
96 |
93 /*! |
97 /*! |
94 Destructor of NmSettingsViewFactory. |
98 Destructor of NmSettingsViewFactory. |
95 */ |
99 */ |
96 NmSettingsViewFactory::~NmSettingsViewFactory() |
100 NmSettingsViewFactory::~NmSettingsViewFactory() |
97 { |
101 { |
98 delete mSettingsManager; |
102 delete mSettingsManager; |
|
103 delete mMessageBox; |
99 } |
104 } |
100 |
105 |
101 |
106 |
102 /*! |
107 /*! |
103 Constructs a setting view. The type of the view depends on the number of |
108 Constructs a setting view. The type of the view depends on the number of |
117 |
122 |
118 // Log the number of mailboxes. |
123 // Log the number of mailboxes. |
119 NMLOG(QString("NmSettingsViewFactory::createSettingView(): Mailbox count is ") + |
124 NMLOG(QString("NmSettingsViewFactory::createSettingView(): Mailbox count is ") + |
120 QString::number(mailboxCount)); |
125 QString::number(mailboxCount)); |
121 |
126 |
122 if (mailboxCount == 0) { |
127 switch(mailboxCount) { |
123 // Query the user whether to launch the wizard or not. |
128 case 0: { |
124 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
129 // Query the user whether to launch the wizard or not. |
125 messageBox->setText(hbTrId("txt_mail_dialog_no_mailboxes_create_new")); |
130 mMessageBox->open(const_cast<NmSettingsViewFactory *>(this), |
126 messageBox->setTimeout(HbMessageBox::NoTimeout); |
131 SLOT(launchWizard(HbAction *))); |
127 |
132 break; |
128 // Read the user selection. |
133 } |
129 HbAction *action = messageBox->exec(); |
134 case 1: { |
130 |
135 // Construct setting view for the only available mailbox |
131 if (action == messageBox->primaryAction()) { |
136 NmMailbox *mailbox = mailboxList.at(0); |
132 // Launch mail wizard. |
137 view = new NmMailboxSettingView(mailbox->id(), |
133 NMLOG(QString("NmSettingsViewFactory::createSettingView(): Launching the mail wizard.")); |
138 mailbox->name(), |
134 QStringList args; |
139 *mSettingsManager); |
135 args << mailWizardStartArgs; |
140 break; |
136 QProcess::startDetached(mailWizardStartExe, args); |
141 } |
137 } |
142 default: { |
138 } |
143 // Construct mailbox selection view |
139 else if (mailboxCount == 1) { |
144 view = new NmMailboxSelectionView(*this, *mSettingsManager, mailboxList); |
140 // Construct setting view for the only available mailbox |
145 break; |
141 NmMailbox *mailbox = mailboxList.at(0); |
146 } |
142 view = new NmMailboxSettingView(mailbox->id(), |
147 |
143 mailbox->name(), |
|
144 *mSettingsManager); |
|
145 } |
|
146 else if (mailboxCount > 1) { |
|
147 // Construct mailbox selection view |
|
148 view = new NmMailboxSelectionView(*this, *mSettingsManager, mailboxList); |
|
149 } |
148 } |
150 |
149 |
151 if (view) { |
150 if (view) { |
152 connect(mSettingsManager, |
151 connect(mSettingsManager, |
153 SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)), |
152 SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)), |
213 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant))); |
212 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant))); |
214 |
213 |
215 connect(mSettingsManager, |
214 connect(mSettingsManager, |
216 SIGNAL(goOnline(const NmId &)), |
215 SIGNAL(goOnline(const NmId &)), |
217 mSettingsViewLauncher, |
216 mSettingsViewLauncher, |
218 SIGNAL(goOnline(const NmId &))); |
217 SIGNAL(goOnline(const NmId &)), Qt::UniqueConnection); |
219 |
218 |
220 connect(mSettingsManager, |
219 connect(mSettingsManager, |
221 SIGNAL(goOffline(const NmId &)), |
220 SIGNAL(goOffline(const NmId &)), |
222 mSettingsViewLauncher, |
221 mSettingsViewLauncher, |
223 SIGNAL(goOffline(const NmId &))); |
222 SIGNAL(goOffline(const NmId &)), Qt::UniqueConnection); |
224 |
223 |
225 connect(this, |
224 connect(this, |
226 SIGNAL(aboutToClose()), |
225 SIGNAL(aboutToClose()), |
227 mSettingsManager, |
226 mSettingsManager, |
228 SIGNAL(aboutToClose())); |
227 SIGNAL(aboutToClose()), Qt::UniqueConnection); |
229 |
228 |
230 // Create back navigation action for a view. |
229 // Create back navigation action for a view. |
231 HbAction *action = new HbAction(Hb::BackNaviAction, view); |
230 HbAction *action = new HbAction(Hb::BackNaviAction, view); |
232 connect(action, SIGNAL(triggered()), this, SLOT(backPress())); |
231 connect(action, SIGNAL(triggered()), this, SLOT(backPress())); |
233 view->setNavigationAction(action); |
232 view->setNavigationAction(action); |
263 } |
262 } |
264 |
263 |
265 NMLOG(QString("NmSettingsViewFactory::backPress - OK")); |
264 NMLOG(QString("NmSettingsViewFactory::backPress - OK")); |
266 } |
265 } |
267 |
266 |
|
267 /*! |
|
268 Handles user selection from "No mailboxes defined" dialog. Launches the Mail Wizard if \a action |
|
269 is the dialog's primary action ("Yes"). Otherwise does nothing. |
|
270 \param action. Action selected by the user. |
|
271 */ |
|
272 void NmSettingsViewFactory::launchWizard(HbAction *action) |
|
273 { |
|
274 if (action == mMessageBox->primaryAction()) { |
|
275 // Launch mail wizard. |
|
276 NMLOG(QString("NmSettingsViewFactory::launchWizard(): Launching the mail wizard.")); |
|
277 QStringList args; |
|
278 args << mailWizardStartArgs; |
|
279 QProcess::startDetached(mailWizardStartExe, args); |
|
280 } |
|
281 } |
|
282 |
|
283 /*! |
|
284 Creates the "No mailboxes defined" dialog. Called from the constructors. |
|
285 */ |
|
286 void NmSettingsViewFactory::createMessageBox() |
|
287 { |
|
288 mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
|
289 mMessageBox->setText(hbTrId("txt_mail_dialog_no_mailboxes_create_new")); |
|
290 mMessageBox->setTimeout(HbMessageBox::NoTimeout); |
|
291 } |
|
292 |
|
293 |
268 // End of file. |
294 // End of file. |