homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsinstalledappsstate.cpp
author hgs
Mon, 18 Oct 2010 10:20:15 +0300
changeset 98 e6f74eb7f69f
parent 97 66b5fe3c07fd
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
 * All rights reserved.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
 *
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
 * Initial Contributors:
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
 *
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
 * Contributors:
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
 *
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
 * Description: Menu All Applications state.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
 *
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
 */
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
63
hgs
parents: 62
diff changeset
    18
#include <QStateMachine>
hgs
parents: 62
diff changeset
    19
#include <HbView>
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    20
#include <HbGroupBox>
63
hgs
parents: 62
diff changeset
    21
#include <HbListView>
hgs
parents: 62
diff changeset
    22
#include <HbAction>
hgs
parents: 62
diff changeset
    23
#include <HbMenu>
hgs
parents: 62
diff changeset
    24
#include <HbAbstractViewItem>
hgs
parents: 62
diff changeset
    25
hgs
parents: 62
diff changeset
    26
#include <cadefs.h>
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <caentry.h>
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
63
hgs
parents: 62
diff changeset
    29
#include "hsapp_defs.h"
hgs
parents: 62
diff changeset
    30
#include "hsmenueventfactory.h"
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include "hsmenuitemmodel.h"
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include "hsinstalledappsstate.h"
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
#include "hsaddappstocollectionstate.h"
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
#include "hsmenumodetransition.h"
90
hgs
parents: 86
diff changeset
    35
#include "hsmenuevent.h"
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
 \class HsInstalledAppsState
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
 \ingroup group_hsapplibrarystateplugin
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
 \brief Manages displaying installed applications
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    41
 Displays all installed packages present on the device.
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    42
 \see StateMachine
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    43
 \lib ?library
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    44
 */
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    45
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    46
/*!
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
 Constructor.
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    48
 \param menuViewBuilder Menu view builder.
63
hgs
parents: 62
diff changeset
    49
 \param mainWindow main window wrapper.
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    50
 \param parent Owner.
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
 */
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    52
HsInstalledAppsState::HsInstalledAppsState(HsMenuViewBuilder &menuViewBuilder,
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
    53
        HsMainWindow &mainWindow,
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    54
        QState *parent):
81
hgs
parents: 71
diff changeset
    55
    HsBaseViewState(mainWindow, parent),
86
hgs
parents: 81
diff changeset
    56
    mSortAttribute(Hs::OldestOnTopHsSortAttribute),
hgs
parents: 81
diff changeset
    57
    mLatestOnTopMenuAction(0),
hgs
parents: 81
diff changeset
    58
    mOldestOnTopMenuAction(0)
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
{
63
hgs
parents: 62
diff changeset
    60
    initialize(menuViewBuilder, HsInstalledAppsContext);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
    construct();
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
 Constructor part.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
 */
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
void HsInstalledAppsState::construct()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
    HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::construct");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
    const QString parentName =
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
        parent() != 0 ? parent()->objectName() : QString("");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
    setObjectName(parentName + "/installedappsstate");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
90
hgs
parents: 86
diff changeset
    75
    connect(mBackKeyAction,
hgs
parents: 86
diff changeset
    76
        SIGNAL(triggered()),
hgs
parents: 86
diff changeset
    77
        this,
hgs
parents: 86
diff changeset
    78
        SLOT(backFromInstalledView()));
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
    HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::construct");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
90
hgs
parents: 86
diff changeset
    83
void HsInstalledAppsState::onEntry(QEvent *event)
hgs
parents: 86
diff changeset
    84
{
hgs
parents: 86
diff changeset
    85
    qDebug("HsInstalledAppsState::onEntry()");
hgs
parents: 86
diff changeset
    86
    HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::onEntry");
hgs
parents: 86
diff changeset
    87
    QState::onEntry(event);
hgs
parents: 86
diff changeset
    88
hgs
parents: 86
diff changeset
    89
    if (event->type() == HsMenuEvent::eventType()) {
hgs
parents: 86
diff changeset
    90
        HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
hgs
parents: 86
diff changeset
    91
        QVariantMap data = menuEvent->data();
hgs
parents: 86
diff changeset
    92
        mCollectionId = data.value(Hs::itemIdKey).toInt();
hgs
parents: 86
diff changeset
    93
        mCollectionType = data.value(Hs::entryTypeNameKey).toString();
hgs
parents: 86
diff changeset
    94
    }
hgs
parents: 86
diff changeset
    95
hgs
parents: 86
diff changeset
    96
    HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::onEntry");
hgs
parents: 86
diff changeset
    97
}
hgs
parents: 86
diff changeset
    98
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
 Method seting menu options.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
 */
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
void HsInstalledAppsState::setMenuOptions()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
    HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::setMenuOptions");
71
hgs
parents: 69
diff changeset
   105
hgs
parents: 69
diff changeset
   106
    mViewOptions->clearActions();
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
71
hgs
parents: 69
diff changeset
   108
    mViewOptions->addAction(hbTrId("txt_applib_opt_task_switcher"),
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
                        this, SLOT(openTaskSwitcher()));
81
hgs
parents: 71
diff changeset
   110
    if (mModel->rowCount() > 0) {
86
hgs
parents: 81
diff changeset
   111
hgs
parents: 81
diff changeset
   112
        mLatestOnTopMenuAction = mViewOptions->addAction(
hgs
parents: 81
diff changeset
   113
            hbTrId("txt_applib_menu_sort_by_latest_on_top"),
hgs
parents: 81
diff changeset
   114
            this, SLOT(latestOnTopMenuAction()));
hgs
parents: 81
diff changeset
   115
        mOldestOnTopMenuAction = mViewOptions->addAction(
hgs
parents: 81
diff changeset
   116
            hbTrId("txt_applib_menu_sort_by_oldest_on_top"),
hgs
parents: 81
diff changeset
   117
            this, SLOT(oldestOnTopMenuAction()));
hgs
parents: 81
diff changeset
   118
hgs
parents: 81
diff changeset
   119
        // as we geting already reversed list from query
hgs
parents: 81
diff changeset
   120
        // we set it to OldestOnTopHsSortAttribute
81
hgs
parents: 71
diff changeset
   121
        if(mSortAttribute == Hs::LatestOnTopHsSortAttribute)
86
hgs
parents: 81
diff changeset
   122
        {
hgs
parents: 81
diff changeset
   123
            mOldestOnTopMenuAction->setVisible(false);
hgs
parents: 81
diff changeset
   124
        } else {
hgs
parents: 81
diff changeset
   125
            mLatestOnTopMenuAction->setVisible(false);
81
hgs
parents: 71
diff changeset
   126
        }
hgs
parents: 71
diff changeset
   127
    }
90
hgs
parents: 86
diff changeset
   128
    mViewOptions->addAction(hbTrId("txt_applib_opt_installation_log"),
hgs
parents: 86
diff changeset
   129
                        this, SLOT(openInstallationLog()));
71
hgs
parents: 69
diff changeset
   130
    mMenuView->view()->setMenu(mViewOptions);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
    HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::setMenuOptions");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
/*!
63
hgs
parents: 62
diff changeset
   135
 Method seting context menu options.
hgs
parents: 62
diff changeset
   136
 \param item the context menu is built for.
hgs
parents: 62
diff changeset
   137
 \param flags of the \item.
hgs
parents: 62
diff changeset
   138
 */
97
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   139
void HsInstalledAppsState::setContextMenuOptions(
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   140
        HbAbstractViewItem *item, EntryFlags flags)
63
hgs
parents: 62
diff changeset
   141
{
97
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   142
    Q_UNUSED(item)
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   143
    Q_UNUSED(flags)
63
hgs
parents: 62
diff changeset
   144
    HbAction *uninstallAction = mContextMenu->addAction(
97
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   145
            hbTrId("txt_common_menu_delete"));
81
hgs
parents: 71
diff changeset
   146
    uninstallAction->setData(Hs::UninstallContextAction);
63
hgs
parents: 62
diff changeset
   147
97
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   148
    HbAction *appDetailsAction = mContextMenu->addAction(
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   149
            hbTrId("txt_common_menu_details"));
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   150
    appDetailsAction->setData(Hs::AppDetailsContextAction);
63
hgs
parents: 62
diff changeset
   151
}
hgs
parents: 62
diff changeset
   152
hgs
parents: 62
diff changeset
   153
hgs
parents: 62
diff changeset
   154
/*!
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
 Destructor.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
 */
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
HsInstalledAppsState::~HsInstalledAppsState()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
{
63
hgs
parents: 62
diff changeset
   159
    mMenuView->inactivate();
hgs
parents: 62
diff changeset
   160
    mMenuView->view()->setNavigationAction(NULL);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
 Slot connected to entered() signal.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
 Invoked when a state is entered.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
 */
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
void HsInstalledAppsState::stateEntered()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
    qDebug("AllAppsState::stateEntered()");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
    HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::stateEntered");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
63
hgs
parents: 62
diff changeset
   172
    if (!mModel) {
hgs
parents: 62
diff changeset
   173
        mModel
81
hgs
parents: 71
diff changeset
   174
            = HsMenuService::getInstalledModel(mSortAttribute);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
    }
97
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   176
    
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   177
    updateLabel();
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   178
    
69
hgs
parents: 63
diff changeset
   179
    if (mModel->rowCount() == 0) {
hgs
parents: 63
diff changeset
   180
        mMenuView->reset(HsEmptyLabelContext);
hgs
parents: 63
diff changeset
   181
    }
hgs
parents: 63
diff changeset
   182
    else {
hgs
parents: 63
diff changeset
   183
		mMenuView->reset(HsItemViewContext);
hgs
parents: 63
diff changeset
   184
        mMenuView->setModel(mModel);
98
hgs
parents: 97
diff changeset
   185
        mMenuView->itemView()->scrollTo(
69
hgs
parents: 63
diff changeset
   186
            mModel->index(0));
hgs
parents: 63
diff changeset
   187
    }
97
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   188
69
hgs
parents: 63
diff changeset
   189
    setMenuOptions();
71
hgs
parents: 69
diff changeset
   190
63
hgs
parents: 62
diff changeset
   191
    connect(mMenuView.data(),
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   192
            SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
63
hgs
parents: 62
diff changeset
   193
            SLOT(showContextMenu(HbAbstractViewItem *, QPointF)));
97
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   194
86
hgs
parents: 81
diff changeset
   195
    connect(mMenuView.data(),
hgs
parents: 81
diff changeset
   196
                SIGNAL(activated(QModelIndex)),
hgs
parents: 81
diff changeset
   197
                SLOT(launchDetails(QModelIndex)));
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   198
63
hgs
parents: 62
diff changeset
   199
    connect(mModel, SIGNAL(empty(bool)),this,
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   200
            SLOT(setEmptyLabelVisibility(bool)));
97
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   201
    
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   202
    connect(mModel, SIGNAL(countChange()),this,
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   203
            SLOT(updateLabel()));
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   204
    
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   205
    
69
hgs
parents: 63
diff changeset
   206
    HsBaseViewState::stateEntered();
hgs
parents: 63
diff changeset
   207
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
    HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateEntered");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
 Slot invoked when a state is exited.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
 */
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
void HsInstalledAppsState::stateExited()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
    HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::stateExited");
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   217
97
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   218
    disconnect(mModel, SIGNAL(countChange()),this,
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   219
            SLOT(updateLabel()));
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   220
    
63
hgs
parents: 62
diff changeset
   221
    disconnect(mModel, SIGNAL(empty(bool)),this,
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   222
               SLOT(setEmptyLabelVisibility(bool)));
97
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   223
86
hgs
parents: 81
diff changeset
   224
    disconnect(mMenuView.data(),
hgs
parents: 81
diff changeset
   225
                SIGNAL(activated(QModelIndex)), this,
hgs
parents: 81
diff changeset
   226
                SLOT(launchDetails(QModelIndex)));
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   227
63
hgs
parents: 62
diff changeset
   228
    disconnect(mMenuView.data(),
62
hgs
parents: 55
diff changeset
   229
            SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), this,
63
hgs
parents: 62
diff changeset
   230
            SLOT(showContextMenu(HbAbstractViewItem *, QPointF)));
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
62
hgs
parents: 55
diff changeset
   232
    HsBaseViewState::stateExited();
69
hgs
parents: 63
diff changeset
   233
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
    HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateExited");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
    qDebug("AllAppsState::stateExited()");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
/*!
63
hgs
parents: 62
diff changeset
   239
 Handles button visibility.
hgs
parents: 62
diff changeset
   240
 \param visibility indicates whether show or not to show 'empty' label.
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   241
 */
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   242
void HsInstalledAppsState::setEmptyLabelVisibility(bool visibility)
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   243
{
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   244
    if(visibility){
69
hgs
parents: 63
diff changeset
   245
        mMenuView->reset(HsEmptyLabelContext);
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   246
    } else {
69
hgs
parents: 63
diff changeset
   247
        mMenuView->reset(HsItemViewContext);
hgs
parents: 63
diff changeset
   248
        mMenuView->setModel(mModel);
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   249
    }
81
hgs
parents: 71
diff changeset
   250
    setMenuOptions();
69
hgs
parents: 63
diff changeset
   251
    mMenuView->activate();
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   252
}
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   253
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   254
/*!
97
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   255
 Slot update label.
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   256
 */
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   257
void HsInstalledAppsState::updateLabel()
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   258
{
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   259
    mMenuView->viewLabel()->setHeading(
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   260
            hbTrId("txt_applib_subtitle_installed").arg(
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   261
                    mModel->rowCount()));    
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   262
}
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   263
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   264
/*!
90
hgs
parents: 86
diff changeset
   265
 Menu softkey back action slot
hgs
parents: 86
diff changeset
   266
 */
hgs
parents: 86
diff changeset
   267
#ifdef COVERAGE_MEASUREMENT
hgs
parents: 86
diff changeset
   268
#pragma CTC SKIP
hgs
parents: 86
diff changeset
   269
#endif //COVERAGE_MEASUREMENT
hgs
parents: 86
diff changeset
   270
void HsInstalledAppsState::backFromInstalledView()
hgs
parents: 86
diff changeset
   271
{
hgs
parents: 86
diff changeset
   272
    machine()->postEvent(
hgs
parents: 86
diff changeset
   273
        HsMenuEventFactory::createBackFromInstalledViewEvent(
hgs
parents: 86
diff changeset
   274
        mCollectionId, mCollectionType));
hgs
parents: 86
diff changeset
   275
}
hgs
parents: 86
diff changeset
   276
#ifdef COVERAGE_MEASUREMENT
hgs
parents: 86
diff changeset
   277
#pragma CTC ENDSKIP
hgs
parents: 86
diff changeset
   278
#endif //COVERAGE_MEASUREMENT
hgs
parents: 86
diff changeset
   279
hgs
parents: 86
diff changeset
   280
/*!
63
hgs
parents: 62
diff changeset
   281
 Open installation log.
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
 */
63
hgs
parents: 62
diff changeset
   283
void HsInstalledAppsState::openInstallationLog()
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
{
63
hgs
parents: 62
diff changeset
   285
    machine()->postEvent(
hgs
parents: 62
diff changeset
   286
        HsMenuEventFactory::createInstallationLogEvent());
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
86
hgs
parents: 81
diff changeset
   289
#ifdef COVERAGE_MEASUREMENT
hgs
parents: 81
diff changeset
   290
#pragma CTC SKIP
hgs
parents: 81
diff changeset
   291
#endif //COVERAGE_MEASUREMENT
hgs
parents: 81
diff changeset
   292
hgs
parents: 81
diff changeset
   293
// calls tested factory method
hgs
parents: 81
diff changeset
   294
hgs
parents: 81
diff changeset
   295
/*!
hgs
parents: 81
diff changeset
   296
 Launches detail for app under index
hgs
parents: 81
diff changeset
   297
 */
hgs
parents: 81
diff changeset
   298
void HsInstalledAppsState::launchDetails(const QModelIndex &index)
hgs
parents: 81
diff changeset
   299
{
97
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   300
    QSharedPointer<const CaEntry> entry = mModel->entry(index);
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   301
    if (!entry.isNull() && !(entry->flags() & UninstallEntryFlag)) {
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   302
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   303
        machine()->postEvent(HsMenuEventFactory::createAppDetailsViewEvent(
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   304
                index.data(CaItemModel::IdRole).toInt()));
66b5fe3c07fd 201039_01
hgs
parents: 90
diff changeset
   305
    }
86
hgs
parents: 81
diff changeset
   306
}
hgs
parents: 81
diff changeset
   307
hgs
parents: 81
diff changeset
   308
#ifdef COVERAGE_MEASUREMENT
hgs
parents: 81
diff changeset
   309
#pragma CTC ENDSKIP
hgs
parents: 81
diff changeset
   310
#endif //COVERAGE_MEASUREMENT
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
/*!
81
hgs
parents: 71
diff changeset
   312
  A Slot called when an action for sorting (latest
hgs
parents: 71
diff changeset
   313
  on top) is invoked for Installed.
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   314
 */
81
hgs
parents: 71
diff changeset
   315
void HsInstalledAppsState::latestOnTopMenuAction()
69
hgs
parents: 63
diff changeset
   316
{
81
hgs
parents: 71
diff changeset
   317
    // as we geting already reversed list from query
hgs
parents: 71
diff changeset
   318
    // we set it to OldestOnTopHsSortAttribute
hgs
parents: 71
diff changeset
   319
    mSortAttribute = Hs::OldestOnTopHsSortAttribute;
hgs
parents: 71
diff changeset
   320
    mModel->setSort(mSortAttribute);
86
hgs
parents: 81
diff changeset
   321
    mLatestOnTopMenuAction->setVisible(false);
hgs
parents: 81
diff changeset
   322
    mOldestOnTopMenuAction->setVisible(true);
81
hgs
parents: 71
diff changeset
   323
}
69
hgs
parents: 63
diff changeset
   324
81
hgs
parents: 71
diff changeset
   325
/*!
hgs
parents: 71
diff changeset
   326
  A Slot called when an action for sorting (oldest
hgs
parents: 71
diff changeset
   327
  on top) is invoked for Installed.
hgs
parents: 71
diff changeset
   328
 */
hgs
parents: 71
diff changeset
   329
void HsInstalledAppsState::oldestOnTopMenuAction()
hgs
parents: 71
diff changeset
   330
{
hgs
parents: 71
diff changeset
   331
    // as we geting already reversed list from query
hgs
parents: 71
diff changeset
   332
    // we set it to LatestOnTopHsSortAttribute
hgs
parents: 71
diff changeset
   333
    mSortAttribute = Hs::LatestOnTopHsSortAttribute;
hgs
parents: 71
diff changeset
   334
    mModel->setSort(mSortAttribute);
86
hgs
parents: 81
diff changeset
   335
    mLatestOnTopMenuAction->setVisible(true);
hgs
parents: 81
diff changeset
   336
    mOldestOnTopMenuAction->setVisible(false);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   337
}