|
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 name collection state |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <hbaction.h> |
|
19 #include <hblineedit.h> |
|
20 #include <hsmenuservice.h> |
|
21 |
|
22 #include "hscollectionnamestate.h" |
|
23 #include "hsmenuevent.h" |
|
24 #include "hscollectionnamedialog.h" |
|
25 |
|
26 /*! |
|
27 \class HsCollectionNameState |
|
28 \ingroup group_hsmenustateplugin |
|
29 \brief Rename Collection State. |
|
30 Collection name state |
|
31 */ |
|
32 |
|
33 /*! |
|
34 \fn void commit(const QString &collectionName); |
|
35 Signal emitted when collection name is given. |
|
36 \param collectionName name of collection. |
|
37 */ |
|
38 |
|
39 /*! |
|
40 \fn void commitCheckList(const QString &collectionName); |
|
41 Signal emitted when collection name is given - version to trigger |
|
42 transition to HsAppsCheckListState. |
|
43 \param collectionName name of collection. |
|
44 */ |
|
45 |
|
46 /*! |
|
47 \fn void cancel(); |
|
48 Signal emitted when user selects cancel. |
|
49 */ |
|
50 |
|
51 /*! |
|
52 Constructor |
|
53 \param parent owner |
|
54 \retval void |
|
55 */ |
|
56 HsCollectionNameState::HsCollectionNameState(QState *parent) : |
|
57 QState(parent) |
|
58 { |
|
59 construct(); |
|
60 } |
|
61 |
|
62 /*! |
|
63 Destructor |
|
64 \retval void |
|
65 */ |
|
66 HsCollectionNameState::~HsCollectionNameState() |
|
67 { |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 void HsCollectionNameState::construct() |
|
74 { |
|
75 setObjectName(this->parent()->objectName() + "/collectionnamestate"); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 #ifdef COVERAGE_MEASUREMENT |
|
82 #pragma CTC SKIP |
|
83 #endif //COVERAGE_MEASUREMENT |
|
84 void HsCollectionNameState::onEntry(QEvent *event) |
|
85 { |
|
86 qDebug("CollectionState::onEntry()"); |
|
87 HSMENUTEST_FUNC_ENTRY("HsCollectionNameState::onEntry"); |
|
88 QState::onEntry(event); |
|
89 |
|
90 int itemId = 0; |
|
91 if (event->type() == HsMenuEvent::eventType()) { |
|
92 HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event); |
|
93 QVariantMap data = menuEvent->data(); |
|
94 |
|
95 itemId = data.value(itemIdKey()).toInt(); |
|
96 } |
|
97 |
|
98 HsCollectionNameDialog editor(itemId); |
|
99 |
|
100 HbAction *result = editor.exec(); |
|
101 if (result == editor.primaryAction()) { |
|
102 QString newName(editor.newName(editor.value().toString(), true)); |
|
103 if (itemId) { |
|
104 if (newName != HsMenuService::getName(itemId)) { |
|
105 HsMenuService::renameCollection(itemId, newName); |
|
106 } |
|
107 } else { |
|
108 HsMenuService::createCollection(newName); |
|
109 } |
|
110 } |
|
111 HSMENUTEST_FUNC_EXIT("HsCollectionNameState::onEntry"); |
|
112 } |
|
113 |
|
114 #ifdef COVERAGE_MEASUREMENT |
|
115 #pragma CTC ENDSKIP |
|
116 #endif //COVERAGE_MEASUREMENT |