|
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: Menu delete collection item state |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <HbMessageBox> |
|
19 #include "hsuinstallfailedstate.h" |
|
20 #include "hsmenuevent.h" |
|
21 #include "hsapp_defs.h" |
|
22 |
|
23 const int installerBusyError = 4; |
|
24 |
|
25 /*! |
|
26 Constructor. |
|
27 /param parent Parent state. |
|
28 */ |
|
29 HsUninstallFailedState::HsUninstallFailedState(QState *parent) : |
|
30 QState(parent), mBox(0) |
|
31 { |
|
32 construct(); |
|
33 } |
|
34 |
|
35 /*! |
|
36 Destructor |
|
37 */ |
|
38 HsUninstallFailedState::~HsUninstallFailedState() |
|
39 { |
|
40 cleanUp(); // in case of throw |
|
41 } |
|
42 |
|
43 /*! |
|
44 Construction |
|
45 */ |
|
46 void HsUninstallFailedState::construct() |
|
47 { |
|
48 setObjectName("/HsUninstallFailedState"); |
|
49 if (this->parent()) { |
|
50 setObjectName(this->parent()->objectName() + objectName()); |
|
51 } |
|
52 |
|
53 connect(this, SIGNAL(exited()), SLOT(cleanUp())); |
|
54 } |
|
55 |
|
56 |
|
57 /*! |
|
58 Sets entry event. |
|
59 \param event entry event. |
|
60 */ |
|
61 void HsUninstallFailedState::onEntry(QEvent *event) |
|
62 { |
|
63 |
|
64 |
|
65 QState::onEntry(event); |
|
66 HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event); |
|
67 QVariantMap data = menuEvent->data(); |
|
68 int error = data.value(Hs::uninstallError).toInt(); |
|
69 if (error == installerBusyError) { |
|
70 // Installer is in use |
|
71 mBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
|
72 mBox->setText(hbTrId("txt_applib_info_installer_is_currently_busy")); |
|
73 } else { |
|
74 // other errors |
|
75 mBox = new HbMessageBox(HbMessageBox::MessageTypeWarning); |
|
76 mBox->setText(hbTrId("txt_applib_info_uninstallation_failed")); |
|
77 } |
|
78 |
|
79 mBox->setAttribute(Qt::WA_DeleteOnClose); |
|
80 mBox->setStandardButtons(HbMessageBox::Close); |
|
81 mBox->open(this, SLOT(stateExited())); |
|
82 } |
|
83 |
|
84 /*! |
|
85 Invoked on exiting state |
|
86 */ |
|
87 void HsUninstallFailedState::onExit(QEvent *event) |
|
88 { |
|
89 QState::onExit(event); |
|
90 } |
|
91 |
|
92 /*! |
|
93 State exited. |
|
94 */ |
|
95 void HsUninstallFailedState::stateExited() |
|
96 { |
|
97 mBox = NULL; |
|
98 emit exit(); |
|
99 } |
|
100 |
|
101 /*! |
|
102 Slot launched after state has exited and in destructor. |
|
103 \retval void |
|
104 */ |
|
105 void HsUninstallFailedState::cleanUp() |
|
106 { |
|
107 // Close popups if App key was pressed |
|
108 if (mBox) { |
|
109 mBox->close(); |
|
110 mBox = NULL; |
|
111 } |
|
112 } |