homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsbaseviewstate.cpp
author hgs
Fri, 09 Jul 2010 14:36:01 +0300
changeset 63 52b0f64eeb51
parent 62 341166945d65
child 69 87476091b3f5
permissions -rw-r--r--
201027
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
62
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
 * All rights reserved.
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
 *
hgs
parents:
diff changeset
     9
 * Initial Contributors:
hgs
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
 *
hgs
parents:
diff changeset
    12
 * Contributors:
hgs
parents:
diff changeset
    13
 *
hgs
parents:
diff changeset
    14
 * Description: Base for menu view states.
hgs
parents:
diff changeset
    15
 *
hgs
parents:
diff changeset
    16
 */
hgs
parents:
diff changeset
    17
63
hgs
parents: 62
diff changeset
    18
#include <QStateMachine>
hgs
parents: 62
diff changeset
    19
#include <HbMessageBox>
62
hgs
parents:
diff changeset
    20
#include <HbParameterLengthLimiter>
63
hgs
parents: 62
diff changeset
    21
#include <HbAction>
hgs
parents: 62
diff changeset
    22
#include <HbMenu>
hgs
parents: 62
diff changeset
    23
#include <HbAbstractViewItem>
hgs
parents: 62
diff changeset
    24
#include <HbView>
hgs
parents: 62
diff changeset
    25
#include <HbListView>
hgs
parents: 62
diff changeset
    26
62
hgs
parents:
diff changeset
    27
#include <canotifier.h>
hgs
parents:
diff changeset
    28
hgs
parents:
diff changeset
    29
#include "hsbaseviewstate.h"
63
hgs
parents: 62
diff changeset
    30
#include "hsmenueventfactory.h"
hgs
parents: 62
diff changeset
    31
#include "hsmenudialogfactory.h"
hgs
parents: 62
diff changeset
    32
#include "hsmenuitemmodel.h"
hgs
parents: 62
diff changeset
    33
#include "hsmenumodetransition.h"
hgs
parents: 62
diff changeset
    34
#include "hsmainwindow.h"
hgs
parents: 62
diff changeset
    35
62
hgs
parents:
diff changeset
    36
hgs
parents:
diff changeset
    37
/*!
hgs
parents:
diff changeset
    38
 Constructor.
63
hgs
parents: 62
diff changeset
    39
 \param mainWindow main window wrapper object.
hgs
parents: 62
diff changeset
    40
 \param parent Owner.
62
hgs
parents:
diff changeset
    41
 */
63
hgs
parents: 62
diff changeset
    42
HsBaseViewState::HsBaseViewState(HsMainWindow &mainWindow, QState *parent):
hgs
parents: 62
diff changeset
    43
    QState(parent),
hgs
parents: 62
diff changeset
    44
    mNotifier(0),
hgs
parents: 62
diff changeset
    45
    mMessageRelatedItemId(0),
hgs
parents: 62
diff changeset
    46
    mApplicationLaunchFailMessage(0),
hgs
parents: 62
diff changeset
    47
    mModel(0),
hgs
parents: 62
diff changeset
    48
    mContextMenu(0),
hgs
parents: 62
diff changeset
    49
    mContextModelIndex(),
hgs
parents: 62
diff changeset
    50
    mBackKeyAction(0),
hgs
parents: 62
diff changeset
    51
    mMenuView(0),
hgs
parents: 62
diff changeset
    52
    mMenuMode(0),
hgs
parents: 62
diff changeset
    53
    mMainWindow(mainWindow)
hgs
parents: 62
diff changeset
    54
{
hgs
parents: 62
diff changeset
    55
    mBackKeyAction = new HbAction(Hb::BackNaviAction, this);
hgs
parents: 62
diff changeset
    56
}
hgs
parents: 62
diff changeset
    57
hgs
parents: 62
diff changeset
    58
/*!
hgs
parents: 62
diff changeset
    59
 Constructor.
hgs
parents: 62
diff changeset
    60
 \param mainWindow main window wrapper object.
hgs
parents: 62
diff changeset
    61
 \param menuMode menu mode object.
hgs
parents: 62
diff changeset
    62
 \param parent Owner.
hgs
parents: 62
diff changeset
    63
 */
hgs
parents: 62
diff changeset
    64
HsBaseViewState::HsBaseViewState(HsMainWindow &mainWindow, 
hgs
parents: 62
diff changeset
    65
    HsMenuModeWrapper& menuMode, 
62
hgs
parents:
diff changeset
    66
    QState *parent):
hgs
parents:
diff changeset
    67
    QState(parent),
hgs
parents:
diff changeset
    68
    mNotifier(0),
hgs
parents:
diff changeset
    69
    mMessageRelatedItemId(0),
63
hgs
parents: 62
diff changeset
    70
    mApplicationLaunchFailMessage(0),
hgs
parents: 62
diff changeset
    71
    mModel(0),
hgs
parents: 62
diff changeset
    72
    mContextMenu(0),
hgs
parents: 62
diff changeset
    73
    mContextModelIndex(),
hgs
parents: 62
diff changeset
    74
    mBackKeyAction(0),
hgs
parents: 62
diff changeset
    75
    mMenuView(0),
hgs
parents: 62
diff changeset
    76
    mMenuMode(&menuMode),
hgs
parents: 62
diff changeset
    77
    mMainWindow(mainWindow)
62
hgs
parents:
diff changeset
    78
{
63
hgs
parents: 62
diff changeset
    79
    mBackKeyAction = new HbAction(Hb::BackNaviAction, this);
62
hgs
parents:
diff changeset
    80
}
63
hgs
parents: 62
diff changeset
    81
/*!
hgs
parents: 62
diff changeset
    82
 Initialize contained objects.
hgs
parents: 62
diff changeset
    83
 \param menuViewBuilder object providing widgets for menu view.
hgs
parents: 62
diff changeset
    84
 \param viewContext state context of the view the builder is to provide widgets for.
hgs
parents: 62
diff changeset
    85
 */
hgs
parents: 62
diff changeset
    86
void HsBaseViewState::initialize(HsMenuViewBuilder &menuViewBuilder, 
hgs
parents: 62
diff changeset
    87
    HsViewContext viewContext)
hgs
parents: 62
diff changeset
    88
{
hgs
parents: 62
diff changeset
    89
    mMenuView.reset(new HsMenuView(menuViewBuilder, viewContext));
hgs
parents: 62
diff changeset
    90
    mMenuView->view()->setNavigationAction(mBackKeyAction);
62
hgs
parents:
diff changeset
    91
63
hgs
parents: 62
diff changeset
    92
    connect(this, SIGNAL(entered()),SLOT(stateEntered()));
hgs
parents: 62
diff changeset
    93
    connect(this, SIGNAL(exited()),SLOT(stateExited()));
62
hgs
parents:
diff changeset
    94
}
hgs
parents:
diff changeset
    95
hgs
parents:
diff changeset
    96
/*!
hgs
parents:
diff changeset
    97
 Creates and open application launch fail message.
hgs
parents:
diff changeset
    98
 \param errorCode eroor code to display.
63
hgs
parents: 62
diff changeset
    99
 \param itemId id of the launched item.
62
hgs
parents:
diff changeset
   100
 */
63
hgs
parents: 62
diff changeset
   101
void HsBaseViewState::createApplicationLaunchFailMessage(int errorCode,
hgs
parents: 62
diff changeset
   102
    int itemId)
62
hgs
parents:
diff changeset
   103
{
hgs
parents:
diff changeset
   104
    QString message;
hgs
parents:
diff changeset
   105
    message.append(
hgs
parents:
diff changeset
   106
        HbParameterLengthLimiter("txt_applib_info_launching_the_application_failed").arg(
hgs
parents:
diff changeset
   107
            errorCode));
hgs
parents:
diff changeset
   108
    
hgs
parents:
diff changeset
   109
    mMessageRelatedItemId = itemId;
hgs
parents:
diff changeset
   110
hgs
parents:
diff changeset
   111
    // create and show message box
63
hgs
parents: 62
diff changeset
   112
    mApplicationLaunchFailMessage = HsMenuDialogFactory().create(message, HsMenuDialogFactory::Close);
62
hgs
parents:
diff changeset
   113
hgs
parents:
diff changeset
   114
    mApplicationLaunchFailMessage->open(this, SLOT(applicationLaunchFailMessageFinished(HbAction*)));
hgs
parents:
diff changeset
   115
    
hgs
parents:
diff changeset
   116
    subscribeForMemoryCardRemove();
hgs
parents:
diff changeset
   117
}
hgs
parents:
diff changeset
   118
hgs
parents:
diff changeset
   119
/*!
hgs
parents:
diff changeset
   120
 Subscribe for memory card remove.
hgs
parents:
diff changeset
   121
 */
hgs
parents:
diff changeset
   122
void HsBaseViewState::subscribeForMemoryCardRemove()
hgs
parents:
diff changeset
   123
{
hgs
parents:
diff changeset
   124
    if (mMessageRelatedItemId !=0 ) {
hgs
parents:
diff changeset
   125
        CaNotifierFilter filter;
hgs
parents:
diff changeset
   126
        filter.setIds(QList<int>() << mMessageRelatedItemId);
hgs
parents:
diff changeset
   127
        mNotifier = CaService::instance()->createNotifier(filter);
hgs
parents:
diff changeset
   128
        mNotifier->setParent(this);
hgs
parents:
diff changeset
   129
        connect(mNotifier,
hgs
parents:
diff changeset
   130
            SIGNAL(entryChanged(CaEntry,ChangeType)),
hgs
parents:
diff changeset
   131
            SLOT(cleanUpApplicationLaunchFailMessage()));
hgs
parents:
diff changeset
   132
    }
hgs
parents:
diff changeset
   133
}
hgs
parents:
diff changeset
   134
hgs
parents:
diff changeset
   135
/*!
hgs
parents:
diff changeset
   136
 Clean up application launch fail message box.
hgs
parents:
diff changeset
   137
 \retval void
hgs
parents:
diff changeset
   138
 */
hgs
parents:
diff changeset
   139
void HsBaseViewState::cleanUpApplicationLaunchFailMessage()
hgs
parents:
diff changeset
   140
{
hgs
parents:
diff changeset
   141
    if (mApplicationLaunchFailMessage) {
hgs
parents:
diff changeset
   142
        mApplicationLaunchFailMessage->close();
hgs
parents:
diff changeset
   143
        mApplicationLaunchFailMessage = NULL;
hgs
parents:
diff changeset
   144
    }
hgs
parents:
diff changeset
   145
    if (mNotifier) {
hgs
parents:
diff changeset
   146
        delete mNotifier;
hgs
parents:
diff changeset
   147
        mNotifier = NULL;
hgs
parents:
diff changeset
   148
    }
hgs
parents:
diff changeset
   149
    mMessageRelatedItemId = 0;
hgs
parents:
diff changeset
   150
}
hgs
parents:
diff changeset
   151
hgs
parents:
diff changeset
   152
/*!
hgs
parents:
diff changeset
   153
 Action after closed application launch fail dialog.
hgs
parents:
diff changeset
   154
 \param finishedAction chosen action.
hgs
parents:
diff changeset
   155
 \retval void
hgs
parents:
diff changeset
   156
 */
hgs
parents:
diff changeset
   157
void HsBaseViewState::applicationLaunchFailMessageFinished(HbAction*)
hgs
parents:
diff changeset
   158
{
hgs
parents:
diff changeset
   159
    mApplicationLaunchFailMessage = NULL;
hgs
parents:
diff changeset
   160
    cleanUpApplicationLaunchFailMessage();
hgs
parents:
diff changeset
   161
}
hgs
parents:
diff changeset
   162
63
hgs
parents: 62
diff changeset
   163
hgs
parents: 62
diff changeset
   164
/*!
hgs
parents: 62
diff changeset
   165
 Slot invoked when a state is entered.
hgs
parents: 62
diff changeset
   166
 */
hgs
parents: 62
diff changeset
   167
void HsBaseViewState::stateEntered()
hgs
parents: 62
diff changeset
   168
{
hgs
parents: 62
diff changeset
   169
    qDebug("HsBaseViewState::stateEntered()");
hgs
parents: 62
diff changeset
   170
    HSMENUTEST_FUNC_ENTRY("HsBaseViewState::stateEntered");
hgs
parents: 62
diff changeset
   171
hgs
parents: 62
diff changeset
   172
    mMainWindow.setCurrentView(*mMenuView);
hgs
parents: 62
diff changeset
   173
    mMenuView->activate();
hgs
parents: 62
diff changeset
   174
hgs
parents: 62
diff changeset
   175
    HSMENUTEST_FUNC_EXIT("HsBaseViewState::stateEntered");
hgs
parents: 62
diff changeset
   176
}
hgs
parents: 62
diff changeset
   177
62
hgs
parents:
diff changeset
   178
/*!
hgs
parents:
diff changeset
   179
 Slot invoked when a state is exited.
hgs
parents:
diff changeset
   180
 */
hgs
parents:
diff changeset
   181
void HsBaseViewState::stateExited()
hgs
parents:
diff changeset
   182
{
hgs
parents:
diff changeset
   183
    HSMENUTEST_FUNC_ENTRY("HsBaseViewState::stateExited");
63
hgs
parents: 62
diff changeset
   184
    mMenuView->setSearchPanelVisible(false);
hgs
parents: 62
diff changeset
   185
    mMenuView->disconnect(this);
hgs
parents: 62
diff changeset
   186
    mMenuView->view()->setMenu(NULL);
hgs
parents: 62
diff changeset
   187
    mMenuView->inactivate();
62
hgs
parents:
diff changeset
   188
    cleanUpApplicationLaunchFailMessage();
63
hgs
parents: 62
diff changeset
   189
    if (mContextMenu){
hgs
parents: 62
diff changeset
   190
        mContextMenu->close();
hgs
parents: 62
diff changeset
   191
    }
62
hgs
parents:
diff changeset
   192
    HSMENUTEST_FUNC_EXIT("HsBaseViewState::stateExited");
hgs
parents:
diff changeset
   193
}
hgs
parents:
diff changeset
   194
hgs
parents:
diff changeset
   195
/*!
63
hgs
parents: 62
diff changeset
   196
 Add mode entered.
hgs
parents: 62
diff changeset
   197
 */
hgs
parents: 62
diff changeset
   198
void HsBaseViewState::addModeEntered()
hgs
parents: 62
diff changeset
   199
{
hgs
parents: 62
diff changeset
   200
    connect(mMenuView.data(),
hgs
parents: 62
diff changeset
   201
            SIGNAL(activated(QModelIndex)),
hgs
parents: 62
diff changeset
   202
            SLOT(addActivated(QModelIndex)));
hgs
parents: 62
diff changeset
   203
    connect(mMenuView.data(),
hgs
parents: 62
diff changeset
   204
            SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
hgs
parents: 62
diff changeset
   205
            SLOT(addLongPressed(HbAbstractViewItem *, QPointF)));
hgs
parents: 62
diff changeset
   206
}
hgs
parents: 62
diff changeset
   207
hgs
parents: 62
diff changeset
   208
/*!
hgs
parents: 62
diff changeset
   209
 Slot invoked when add mode entered.
hgs
parents: 62
diff changeset
   210
 */
hgs
parents: 62
diff changeset
   211
void HsBaseViewState::normalModeEntered()
hgs
parents: 62
diff changeset
   212
{
hgs
parents: 62
diff changeset
   213
    setMenuOptions();
hgs
parents: 62
diff changeset
   214
    connect(mMenuView.data(),
hgs
parents: 62
diff changeset
   215
            SIGNAL(activated(QModelIndex)),
hgs
parents: 62
diff changeset
   216
            mMenuView.data(),
hgs
parents: 62
diff changeset
   217
            SLOT(hideSearchPanel()));
hgs
parents: 62
diff changeset
   218
    connect(mMenuView.data(),
hgs
parents: 62
diff changeset
   219
            SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
hgs
parents: 62
diff changeset
   220
            SLOT(showContextMenu(HbAbstractViewItem *, QPointF)));
hgs
parents: 62
diff changeset
   221
}
hgs
parents: 62
diff changeset
   222
hgs
parents: 62
diff changeset
   223
/*!
62
hgs
parents:
diff changeset
   224
 Destructor.
hgs
parents:
diff changeset
   225
 */
hgs
parents:
diff changeset
   226
HsBaseViewState::~HsBaseViewState()
hgs
parents:
diff changeset
   227
{
63
hgs
parents: 62
diff changeset
   228
    mMenuView->setModel(NULL);
hgs
parents: 62
diff changeset
   229
    delete mModel;
62
hgs
parents:
diff changeset
   230
}
63
hgs
parents: 62
diff changeset
   231
hgs
parents: 62
diff changeset
   232
/*!
hgs
parents: 62
diff changeset
   233
 Slot connected to List widget in normal mode.
hgs
parents: 62
diff changeset
   234
 \param index Model index of the activated item.
hgs
parents: 62
diff changeset
   235
 */
hgs
parents: 62
diff changeset
   236
void HsBaseViewState::launchItem(const QModelIndex &index)
hgs
parents: 62
diff changeset
   237
{
hgs
parents: 62
diff changeset
   238
    HSMENUTEST_FUNC_ENTRY("HsBaseViewState::launchItem");
hgs
parents: 62
diff changeset
   239
hgs
parents: 62
diff changeset
   240
    QSharedPointer<const CaEntry> entry = mModel->entry(index);
hgs
parents: 62
diff changeset
   241
hgs
parents: 62
diff changeset
   242
    if (entry->entryTypeName() == widgetTypeName()) {
hgs
parents: 62
diff changeset
   243
        EntryFlags flags = index.data(CaItemModel::FlagsRole).value<
hgs
parents: 62
diff changeset
   244
                               EntryFlags> ();
hgs
parents: 62
diff changeset
   245
        if (!(flags & UninstallEntryFlag)) {
hgs
parents: 62
diff changeset
   246
            machine()->postEvent(
hgs
parents: 62
diff changeset
   247
                HsMenuEventFactory::createPreviewHSWidgetEvent(
hgs
parents: 62
diff changeset
   248
                    entry->id(), entry->entryTypeName(), entry->attribute(
hgs
parents: 62
diff changeset
   249
                        widgetUriAttributeName()), entry->attribute(
hgs
parents: 62
diff changeset
   250
                        widgetLibraryAttributeName())));
hgs
parents: 62
diff changeset
   251
hgs
parents: 62
diff changeset
   252
            const int itemId = index.data(CaItemModel::IdRole).toInt();
hgs
parents: 62
diff changeset
   253
            HsMenuService::touch(itemId);
hgs
parents: 62
diff changeset
   254
        }
hgs
parents: 62
diff changeset
   255
    } else {
hgs
parents: 62
diff changeset
   256
        QVariant data = mModel->data(index, CaItemModel::IdRole);
hgs
parents: 62
diff changeset
   257
        int errCode = HsMenuService::executeAction(data.toInt());
hgs
parents: 62
diff changeset
   258
        if (errCode != 0) {
hgs
parents: 62
diff changeset
   259
            createApplicationLaunchFailMessage(errCode,index.data(CaItemModel::IdRole).toInt());
hgs
parents: 62
diff changeset
   260
        }
hgs
parents: 62
diff changeset
   261
    }
hgs
parents: 62
diff changeset
   262
hgs
parents: 62
diff changeset
   263
    HSMENUTEST_FUNC_EXIT("HsBaseViewState::launchItem");
hgs
parents: 62
diff changeset
   264
}
hgs
parents: 62
diff changeset
   265
hgs
parents: 62
diff changeset
   266
/*!
hgs
parents: 62
diff changeset
   267
 Slot connected to List widget in normal mode.
hgs
parents: 62
diff changeset
   268
 \param index Model index of the activated item.
hgs
parents: 62
diff changeset
   269
 */
hgs
parents: 62
diff changeset
   270
void HsBaseViewState::openCollection(const QModelIndex &index)
hgs
parents: 62
diff changeset
   271
{
hgs
parents: 62
diff changeset
   272
    HSMENUTEST_FUNC_ENTRY("HsBaseViewState::openCollection");
hgs
parents: 62
diff changeset
   273
    QVariant data = mModel->data(index, CaItemModel::IdRole);
hgs
parents: 62
diff changeset
   274
    int id = data.toInt();
hgs
parents: 62
diff changeset
   275
    QString collectionType =
hgs
parents: 62
diff changeset
   276
        mModel->data(index, CaItemModel::TypeRole).toString();
hgs
parents: 62
diff changeset
   277
    qDebug("HsBaseViewState::openCollection - MCS ID: %d",
hgs
parents: 62
diff changeset
   278
           data.toInt());
hgs
parents: 62
diff changeset
   279
hgs
parents: 62
diff changeset
   280
    machine()->postEvent(HsMenuEventFactory::createOpenCollectionFromAppLibraryEvent(id,
hgs
parents: 62
diff changeset
   281
                         collectionType));
hgs
parents: 62
diff changeset
   282
    HSMENUTEST_FUNC_EXIT("HsBaseViewState::openCollection");
hgs
parents: 62
diff changeset
   283
}
hgs
parents: 62
diff changeset
   284
hgs
parents: 62
diff changeset
   285
/*!
hgs
parents: 62
diff changeset
   286
 Slot connected to List widget in normal mode.
hgs
parents: 62
diff changeset
   287
 \param index Model index of the activated item.
hgs
parents: 62
diff changeset
   288
 */
hgs
parents: 62
diff changeset
   289
void HsBaseViewState::showContextMenu(HbAbstractViewItem *item, const QPointF &coords)
hgs
parents: 62
diff changeset
   290
{
hgs
parents: 62
diff changeset
   291
hgs
parents: 62
diff changeset
   292
    HSMENUTEST_FUNC_ENTRY("HsBaseViewState::showContextMenu");
hgs
parents: 62
diff changeset
   293
hgs
parents: 62
diff changeset
   294
    EntryFlags flags = item->modelIndex().data(
hgs
parents: 62
diff changeset
   295
                           CaItemModel::FlagsRole).value<EntryFlags> ();
hgs
parents: 62
diff changeset
   296
hgs
parents: 62
diff changeset
   297
    if (!(flags & UninstallEntryFlag)) {
hgs
parents: 62
diff changeset
   298
        mContextMenu = new HbMenu;
hgs
parents: 62
diff changeset
   299
        setContextMenuOptions(item,flags);
hgs
parents: 62
diff changeset
   300
        mContextModelIndex = item->modelIndex();
hgs
parents: 62
diff changeset
   301
        mContextMenu->setPreferredPos(coords);
hgs
parents: 62
diff changeset
   302
        mContextMenu->setAttribute(Qt::WA_DeleteOnClose);
hgs
parents: 62
diff changeset
   303
        mContextMenu->open(this, SLOT(contextMenuAction(HbAction*)));
hgs
parents: 62
diff changeset
   304
    }
hgs
parents: 62
diff changeset
   305
    HSMENUTEST_FUNC_EXIT("HsBaseViewState::showContextMenu");
hgs
parents: 62
diff changeset
   306
hgs
parents: 62
diff changeset
   307
}
hgs
parents: 62
diff changeset
   308
hgs
parents: 62
diff changeset
   309
/*!
hgs
parents: 62
diff changeset
   310
 Open task switcher.
hgs
parents: 62
diff changeset
   311
 \retval true if operation is successful.
hgs
parents: 62
diff changeset
   312
 */
hgs
parents: 62
diff changeset
   313
bool HsBaseViewState::openTaskSwitcher()
hgs
parents: 62
diff changeset
   314
{
hgs
parents: 62
diff changeset
   315
    return HsMenuService::launchTaskSwitcher();
hgs
parents: 62
diff changeset
   316
}
hgs
parents: 62
diff changeset
   317
hgs
parents: 62
diff changeset
   318
/*!
hgs
parents: 62
diff changeset
   319
 Menu softkey back action slot
hgs
parents: 62
diff changeset
   320
 */
hgs
parents: 62
diff changeset
   321
void HsBaseViewState::openAppLibrary()
hgs
parents: 62
diff changeset
   322
{
hgs
parents: 62
diff changeset
   323
    machine()->postEvent(HsMenuEventFactory::createOpenAppLibraryEvent());
hgs
parents: 62
diff changeset
   324
}
hgs
parents: 62
diff changeset
   325
hgs
parents: 62
diff changeset
   326
/*!
hgs
parents: 62
diff changeset
   327
 Check software updates.
hgs
parents: 62
diff changeset
   328
 \retval 0 if operation is successful.
hgs
parents: 62
diff changeset
   329
 */
hgs
parents: 62
diff changeset
   330
int HsBaseViewState::checkSoftwareUpdates()
hgs
parents: 62
diff changeset
   331
{
hgs
parents: 62
diff changeset
   332
    int errCode = HsMenuService::launchSoftwareUpdate();
hgs
parents: 62
diff changeset
   333
    if (errCode != 0){
hgs
parents: 62
diff changeset
   334
        createApplicationLaunchFailMessage(errCode,0);
hgs
parents: 62
diff changeset
   335
    }
hgs
parents: 62
diff changeset
   336
    return errCode;
hgs
parents: 62
diff changeset
   337
}
hgs
parents: 62
diff changeset
   338
/*!
hgs
parents: 62
diff changeset
   339
 Scrolls view to first item at top
hgs
parents: 62
diff changeset
   340
 */
hgs
parents: 62
diff changeset
   341
void HsBaseViewState::scrollToBeginning()
hgs
parents: 62
diff changeset
   342
{
hgs
parents: 62
diff changeset
   343
    mMenuView->listView()->scrollTo(
hgs
parents: 62
diff changeset
   344
        mModel->index(0), HbAbstractItemView::PositionAtTop);
hgs
parents: 62
diff changeset
   345
}
hgs
parents: 62
diff changeset
   346
hgs
parents: 62
diff changeset
   347
/*!
hgs
parents: 62
diff changeset
   348
 Normal mode exited dummy implementation.
hgs
parents: 62
diff changeset
   349
 */
hgs
parents: 62
diff changeset
   350
void HsBaseViewState::normalModeExited()
hgs
parents: 62
diff changeset
   351
{
hgs
parents: 62
diff changeset
   352
}
hgs
parents: 62
diff changeset
   353
hgs
parents: 62
diff changeset
   354
/*!
hgs
parents: 62
diff changeset
   355
 Defines transitions
hgs
parents: 62
diff changeset
   356
 */
hgs
parents: 62
diff changeset
   357
void HsBaseViewState::defineTransitions()
hgs
parents: 62
diff changeset
   358
{
hgs
parents: 62
diff changeset
   359
    QState *initialState = new QState(this);
hgs
parents: 62
diff changeset
   360
    setInitialState(initialState);
hgs
parents: 62
diff changeset
   361
hgs
parents: 62
diff changeset
   362
    QState *addModeState = new QState(this);
hgs
parents: 62
diff changeset
   363
    connect(addModeState, SIGNAL(entered()),SLOT(addModeEntered()));
hgs
parents: 62
diff changeset
   364
hgs
parents: 62
diff changeset
   365
    QState *normalModeState = new QState(this);
hgs
parents: 62
diff changeset
   366
    connect(normalModeState, SIGNAL(entered()),SLOT(normalModeEntered()));
hgs
parents: 62
diff changeset
   367
    connect(normalModeState, SIGNAL(exited()),SLOT(normalModeExited()));
hgs
parents: 62
diff changeset
   368
hgs
parents: 62
diff changeset
   369
    initialState->addTransition(new HsMenuModeTransition(
hgs
parents: 62
diff changeset
   370
                                    *mMenuMode, NormalHsMenuMode, normalModeState));
hgs
parents: 62
diff changeset
   371
    initialState->addTransition(new HsMenuModeTransition(
hgs
parents: 62
diff changeset
   372
                                    *mMenuMode, AddHsMenuMode, addModeState));
hgs
parents: 62
diff changeset
   373
}