homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsdeletecollectionitemstate.cpp
changeset 35 f9ce957a272c
child 39 4e8ebe173323
equal deleted inserted replaced
5:c743ef5928ba 35:f9ce957a272c
       
     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.h>
       
    19 #include <hsmenuservice.h>
       
    20 #include <hsmenueventfactory.h>
       
    21 
       
    22 #include "hsdeletecollectionitemstate.h"
       
    23 #include "hsmenuevent.h"
       
    24 
       
    25 /*!
       
    26  \class HsDeleteCollectionItemState
       
    27  \ingroup group_hsmenustateplugin
       
    28  \brief Delete Collection Item State.
       
    29  Deletes app from collection.
       
    30  */
       
    31 
       
    32 /*!
       
    33  Constructor.
       
    34  \param parent Owner.
       
    35  */
       
    36 HsDeleteCollectionItemState::HsDeleteCollectionItemState(QState *parent) :
       
    37     QState(parent)
       
    38 {
       
    39     construct();
       
    40 }
       
    41 
       
    42 /*!
       
    43  Destructor.
       
    44  */
       
    45 HsDeleteCollectionItemState::~HsDeleteCollectionItemState()
       
    46 {
       
    47 }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 void HsDeleteCollectionItemState::construct()
       
    53 {
       
    54     setObjectName(this->parent()->objectName()
       
    55                   + "/DeleteCollectionItemState");
       
    56 }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 #ifdef COVERAGE_MEASUREMENT
       
    62 #pragma CTC SKIP
       
    63 #endif //COVERAGE_MEASUREMENT
       
    64 void HsDeleteCollectionItemState::onEntry(QEvent *event)
       
    65 {
       
    66     HSMENUTEST_FUNC_ENTRY("HsDeleteCollectionItemState::onEntry");
       
    67     QState::onEntry(event);
       
    68     qDebug("CollectionState::onEntry()");
       
    69     HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
       
    70     QVariantMap data = menuEvent->data();
       
    71 
       
    72     const int itemId = data.value(itemIdKey()).toInt();
       
    73 
       
    74     const int collectionId = data.value(collectionIdKey()).toInt();
       
    75 
       
    76     QString message;
       
    77     message.append(
       
    78         hbTrId("txt_applib_dialog_remove_1_from_collection").arg(
       
    79             HsMenuService::getName(itemId)));
       
    80 
       
    81     if (HbMessageBox::question(message, hbTrId(
       
    82                                    "txt_common_button_ok"), hbTrId("txt_common_button_cancel"))) {
       
    83         HsMenuService::removeApplicationFromCollection(itemId, collectionId);
       
    84     }
       
    85     HSMENUTEST_FUNC_EXIT("HsDeleteCollectionItemState::onEntry");
       
    86 }
       
    87 #ifdef COVERAGE_MEASUREMENT
       
    88 #pragma CTC ENDSKIP
       
    89 #endif //COVERAGE_MEASUREMENT