homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsinstalledappsstate.cpp
author hgs
Mon, 13 Sep 2010 13:03:23 +0300
changeset 86 e4f038c420f7
parent 81 7dd137878ff8
child 90 3ac3aaebaee5
permissions -rw-r--r--
201036
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"
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
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
 \class HsInstalledAppsState
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
 \ingroup group_hsapplibrarystateplugin
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
 \brief Manages displaying installed applications
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    40
 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
    41
 \see StateMachine
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    42
 \lib ?library
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    43
 */
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
/*!
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
 Constructor.
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    47
 \param menuViewBuilder Menu view builder.
63
hgs
parents: 62
diff changeset
    48
 \param mainWindow main window wrapper.
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    49
 \param parent Owner.
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
 */
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    51
HsInstalledAppsState::HsInstalledAppsState(HsMenuViewBuilder &menuViewBuilder,
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
    52
        HsMainWindow &mainWindow,
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    53
        QState *parent):
81
hgs
parents: 71
diff changeset
    54
    HsBaseViewState(mainWindow, parent),
86
hgs
parents: 81
diff changeset
    55
    mSortAttribute(Hs::OldestOnTopHsSortAttribute),
hgs
parents: 81
diff changeset
    56
    mLatestOnTopMenuAction(0),
hgs
parents: 81
diff changeset
    57
    mOldestOnTopMenuAction(0)
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
{
63
hgs
parents: 62
diff changeset
    59
    initialize(menuViewBuilder, HsInstalledAppsContext);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
    construct();
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
}
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
 Constructor part.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
 */
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
void HsInstalledAppsState::construct()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
    HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::construct");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
    const QString parentName =
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
        parent() != 0 ? parent()->objectName() : QString("");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
    setObjectName(parentName + "/installedappsstate");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
63
hgs
parents: 62
diff changeset
    74
    connect(mBackKeyAction, SIGNAL(triggered()), SLOT(openAppLibrary()));
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
    HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::construct");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
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
 Method seting menu options.
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
void HsInstalledAppsState::setMenuOptions()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
    HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::setMenuOptions");
71
hgs
parents: 69
diff changeset
    85
hgs
parents: 69
diff changeset
    86
    mViewOptions->clearActions();
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
71
hgs
parents: 69
diff changeset
    88
    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
    89
                        this, SLOT(openTaskSwitcher()));
71
hgs
parents: 69
diff changeset
    90
    mViewOptions->addAction(hbTrId("txt_applib_opt_installation_log"),
63
hgs
parents: 62
diff changeset
    91
                        this, SLOT(openInstallationLog()));
81
hgs
parents: 71
diff changeset
    92
    if (mModel->rowCount() > 0) {
86
hgs
parents: 81
diff changeset
    93
hgs
parents: 81
diff changeset
    94
        mLatestOnTopMenuAction = mViewOptions->addAction(
hgs
parents: 81
diff changeset
    95
            hbTrId("txt_applib_menu_sort_by_latest_on_top"),
hgs
parents: 81
diff changeset
    96
            this, SLOT(latestOnTopMenuAction()));
hgs
parents: 81
diff changeset
    97
        mOldestOnTopMenuAction = mViewOptions->addAction(
hgs
parents: 81
diff changeset
    98
            hbTrId("txt_applib_menu_sort_by_oldest_on_top"),
hgs
parents: 81
diff changeset
    99
            this, SLOT(oldestOnTopMenuAction()));
hgs
parents: 81
diff changeset
   100
hgs
parents: 81
diff changeset
   101
        // as we geting already reversed list from query
hgs
parents: 81
diff changeset
   102
        // we set it to OldestOnTopHsSortAttribute
81
hgs
parents: 71
diff changeset
   103
        if(mSortAttribute == Hs::LatestOnTopHsSortAttribute)
86
hgs
parents: 81
diff changeset
   104
        {
hgs
parents: 81
diff changeset
   105
            mOldestOnTopMenuAction->setVisible(false);
hgs
parents: 81
diff changeset
   106
        } else {
hgs
parents: 81
diff changeset
   107
            mLatestOnTopMenuAction->setVisible(false);
81
hgs
parents: 71
diff changeset
   108
        }
hgs
parents: 71
diff changeset
   109
    }
71
hgs
parents: 69
diff changeset
   110
    mMenuView->view()->setMenu(mViewOptions);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
    HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::setMenuOptions");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
/*!
63
hgs
parents: 62
diff changeset
   115
 Method seting context menu options.
hgs
parents: 62
diff changeset
   116
 \param item the context menu is built for.
hgs
parents: 62
diff changeset
   117
 \param flags of the \item.
hgs
parents: 62
diff changeset
   118
 */
hgs
parents: 62
diff changeset
   119
void HsInstalledAppsState::setContextMenuOptions(HbAbstractViewItem *item, EntryFlags flags)
hgs
parents: 62
diff changeset
   120
{
hgs
parents: 62
diff changeset
   121
    HbAction *uninstallAction = mContextMenu->addAction(
hgs
parents: 62
diff changeset
   122
                                hbTrId("txt_common_menu_delete"));
hgs
parents: 62
diff changeset
   123
    HbAction *appDetailsAction(NULL);
81
hgs
parents: 71
diff changeset
   124
    uninstallAction->setData(Hs::UninstallContextAction);
63
hgs
parents: 62
diff changeset
   125
hgs
parents: 62
diff changeset
   126
    QSharedPointer<const CaEntry> entry = mModel->entry(item->modelIndex());
hgs
parents: 62
diff changeset
   127
81
hgs
parents: 71
diff changeset
   128
    if (!(entry->attribute(Hs::componentIdAttributeName).isEmpty()) &&
63
hgs
parents: 62
diff changeset
   129
            (flags & RemovableEntryFlag) ) {
hgs
parents: 62
diff changeset
   130
        appDetailsAction = mContextMenu->addAction(hbTrId(
hgs
parents: 62
diff changeset
   131
                                                "txt_common_menu_details"));
81
hgs
parents: 71
diff changeset
   132
        appDetailsAction->setData(Hs::AppDetailsContextAction);
63
hgs
parents: 62
diff changeset
   133
    }
hgs
parents: 62
diff changeset
   134
}
hgs
parents: 62
diff changeset
   135
hgs
parents: 62
diff changeset
   136
hgs
parents: 62
diff changeset
   137
/*!
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
 Destructor.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
 */
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
HsInstalledAppsState::~HsInstalledAppsState()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
{
63
hgs
parents: 62
diff changeset
   142
    mMenuView->inactivate();
hgs
parents: 62
diff changeset
   143
    mMenuView->view()->setNavigationAction(NULL);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
 Slot connected to entered() signal.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
 Invoked when a state is entered.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
 */
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
void HsInstalledAppsState::stateEntered()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
    qDebug("AllAppsState::stateEntered()");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
    HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::stateEntered");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
69
hgs
parents: 63
diff changeset
   155
    mMenuView->viewLabel()->setHeading(
hgs
parents: 63
diff changeset
   156
            hbTrId("txt_applib_subtitle_installed"));
hgs
parents: 63
diff changeset
   157
63
hgs
parents: 62
diff changeset
   158
    if (!mModel) {
hgs
parents: 62
diff changeset
   159
        mModel
81
hgs
parents: 71
diff changeset
   160
            = HsMenuService::getInstalledModel(mSortAttribute);
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
69
hgs
parents: 63
diff changeset
   163
    if (mModel->rowCount() == 0) {
hgs
parents: 63
diff changeset
   164
        mMenuView->reset(HsEmptyLabelContext);
hgs
parents: 63
diff changeset
   165
    }
hgs
parents: 63
diff changeset
   166
    else {
hgs
parents: 63
diff changeset
   167
		mMenuView->reset(HsItemViewContext);
hgs
parents: 63
diff changeset
   168
        mMenuView->setModel(mModel);
hgs
parents: 63
diff changeset
   169
        mMenuView->listView()->scrollTo(
hgs
parents: 63
diff changeset
   170
            mModel->index(0));
hgs
parents: 63
diff changeset
   171
    }
71
hgs
parents: 69
diff changeset
   172
    
69
hgs
parents: 63
diff changeset
   173
    setMenuOptions();
71
hgs
parents: 69
diff changeset
   174
63
hgs
parents: 62
diff changeset
   175
    connect(mMenuView.data(),
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   176
            SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
63
hgs
parents: 62
diff changeset
   177
            SLOT(showContextMenu(HbAbstractViewItem *, QPointF)));
86
hgs
parents: 81
diff changeset
   178
    
hgs
parents: 81
diff changeset
   179
    connect(mMenuView.data(),
hgs
parents: 81
diff changeset
   180
                SIGNAL(activated(QModelIndex)),
hgs
parents: 81
diff changeset
   181
                SLOT(launchDetails(QModelIndex)));
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   182
63
hgs
parents: 62
diff changeset
   183
    connect(mModel, SIGNAL(empty(bool)),this,
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   184
            SLOT(setEmptyLabelVisibility(bool)));
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   185
69
hgs
parents: 63
diff changeset
   186
    HsBaseViewState::stateEntered();
hgs
parents: 63
diff changeset
   187
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
    HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateEntered");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
 Slot invoked when a state is exited.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
 */
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
void HsInstalledAppsState::stateExited()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
    HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::stateExited");
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   197
63
hgs
parents: 62
diff changeset
   198
    disconnect(mModel, SIGNAL(empty(bool)),this,
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   199
               SLOT(setEmptyLabelVisibility(bool)));
86
hgs
parents: 81
diff changeset
   200
    
hgs
parents: 81
diff changeset
   201
    disconnect(mMenuView.data(),
hgs
parents: 81
diff changeset
   202
                SIGNAL(activated(QModelIndex)), this,
hgs
parents: 81
diff changeset
   203
                SLOT(launchDetails(QModelIndex)));
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   204
63
hgs
parents: 62
diff changeset
   205
    disconnect(mMenuView.data(),
62
hgs
parents: 55
diff changeset
   206
            SIGNAL(longPressed(HbAbstractViewItem *, QPointF)), this,
63
hgs
parents: 62
diff changeset
   207
            SLOT(showContextMenu(HbAbstractViewItem *, QPointF)));
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
62
hgs
parents: 55
diff changeset
   209
    HsBaseViewState::stateExited();
69
hgs
parents: 63
diff changeset
   210
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
    HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateExited");
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
    qDebug("AllAppsState::stateExited()");
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
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
/*!
63
hgs
parents: 62
diff changeset
   216
 Handles button visibility.
hgs
parents: 62
diff changeset
   217
 \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
   218
 */
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   219
void HsInstalledAppsState::setEmptyLabelVisibility(bool visibility)
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   220
{
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   221
    if(visibility){
69
hgs
parents: 63
diff changeset
   222
        mMenuView->reset(HsEmptyLabelContext);
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   223
    } else {
69
hgs
parents: 63
diff changeset
   224
        mMenuView->reset(HsItemViewContext);
hgs
parents: 63
diff changeset
   225
        mMenuView->setModel(mModel);
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   226
    }
81
hgs
parents: 71
diff changeset
   227
    setMenuOptions();
69
hgs
parents: 63
diff changeset
   228
    mMenuView->activate();
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   229
}
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   230
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   231
/*!
63
hgs
parents: 62
diff changeset
   232
 Open installation log.
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
 */
63
hgs
parents: 62
diff changeset
   234
void HsInstalledAppsState::openInstallationLog()
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
{
63
hgs
parents: 62
diff changeset
   236
    machine()->postEvent(
hgs
parents: 62
diff changeset
   237
        HsMenuEventFactory::createInstallationLogEvent());
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
86
hgs
parents: 81
diff changeset
   240
#ifdef COVERAGE_MEASUREMENT
hgs
parents: 81
diff changeset
   241
#pragma CTC SKIP
hgs
parents: 81
diff changeset
   242
#endif //COVERAGE_MEASUREMENT
hgs
parents: 81
diff changeset
   243
hgs
parents: 81
diff changeset
   244
// calls tested factory method
hgs
parents: 81
diff changeset
   245
hgs
parents: 81
diff changeset
   246
/*!
hgs
parents: 81
diff changeset
   247
 Launches detail for app under index
hgs
parents: 81
diff changeset
   248
 */
hgs
parents: 81
diff changeset
   249
void HsInstalledAppsState::launchDetails(const QModelIndex &index)
hgs
parents: 81
diff changeset
   250
{
hgs
parents: 81
diff changeset
   251
	machine()->postEvent(HsMenuEventFactory::createAppDetailsViewEvent(
hgs
parents: 81
diff changeset
   252
			index.data(CaItemModel::IdRole).toInt()));	
hgs
parents: 81
diff changeset
   253
}
hgs
parents: 81
diff changeset
   254
hgs
parents: 81
diff changeset
   255
#ifdef COVERAGE_MEASUREMENT
hgs
parents: 81
diff changeset
   256
#pragma CTC ENDSKIP
hgs
parents: 81
diff changeset
   257
#endif //COVERAGE_MEASUREMENT
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
/*!
81
hgs
parents: 71
diff changeset
   259
  A Slot called when an action for sorting (latest
hgs
parents: 71
diff changeset
   260
  on top) is invoked for Installed.
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   261
 */
81
hgs
parents: 71
diff changeset
   262
void HsInstalledAppsState::latestOnTopMenuAction()
69
hgs
parents: 63
diff changeset
   263
{
81
hgs
parents: 71
diff changeset
   264
    // as we geting already reversed list from query
hgs
parents: 71
diff changeset
   265
    // we set it to OldestOnTopHsSortAttribute
hgs
parents: 71
diff changeset
   266
    mSortAttribute = Hs::OldestOnTopHsSortAttribute;
hgs
parents: 71
diff changeset
   267
    mModel->setSort(mSortAttribute);
86
hgs
parents: 81
diff changeset
   268
    mLatestOnTopMenuAction->setVisible(false);
hgs
parents: 81
diff changeset
   269
    mOldestOnTopMenuAction->setVisible(true);
81
hgs
parents: 71
diff changeset
   270
}
69
hgs
parents: 63
diff changeset
   271
81
hgs
parents: 71
diff changeset
   272
/*!
hgs
parents: 71
diff changeset
   273
  A Slot called when an action for sorting (oldest
hgs
parents: 71
diff changeset
   274
  on top) is invoked for Installed.
hgs
parents: 71
diff changeset
   275
 */
hgs
parents: 71
diff changeset
   276
void HsInstalledAppsState::oldestOnTopMenuAction()
hgs
parents: 71
diff changeset
   277
{
hgs
parents: 71
diff changeset
   278
    // as we geting already reversed list from query
hgs
parents: 71
diff changeset
   279
    // we set it to LatestOnTopHsSortAttribute
hgs
parents: 71
diff changeset
   280
    mSortAttribute = Hs::LatestOnTopHsSortAttribute;
hgs
parents: 71
diff changeset
   281
    mModel->setSort(mSortAttribute);
86
hgs
parents: 81
diff changeset
   282
    mLatestOnTopMenuAction->setVisible(true);
hgs
parents: 81
diff changeset
   283
    mOldestOnTopMenuAction->setVisible(false);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   284
}