homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsbaseviewstate.cpp
changeset 97 66b5fe3c07fd
parent 90 3ac3aaebaee5
child 98 e6f74eb7f69f
equal deleted inserted replaced
95:32e56106abf2 97:66b5fe3c07fd
   112     // create and show message box
   112     // create and show message box
   113     mApplicationLaunchFailMessage = HsMenuDialogFactory().create(
   113     mApplicationLaunchFailMessage = HsMenuDialogFactory().create(
   114             message, HsMenuDialogFactory::Close);
   114             message, HsMenuDialogFactory::Close);
   115 
   115 
   116     QScopedPointer<HsMenuEntryRemovedHandler> entryObserver(
   116     QScopedPointer<HsMenuEntryRemovedHandler> entryObserver(
   117             new HsMenuEntryRemovedHandler(itemId, 
   117             new HsMenuEntryRemovedHandler(itemId,
   118                     mApplicationLaunchFailMessage.data(), SLOT(close())));
   118                     mApplicationLaunchFailMessage.data(), SLOT(close())));
   119 
   119 
   120     entryObserver.take()->setParent(mApplicationLaunchFailMessage.data());
   120     entryObserver.take()->setParent(mApplicationLaunchFailMessage.data());
   121 
   121 
   122     mApplicationLaunchFailMessage->open();
   122     mApplicationLaunchFailMessage->open();
   157  Add mode entered.
   157  Add mode entered.
   158  */
   158  */
   159 void HsBaseViewState::addModeEntered()
   159 void HsBaseViewState::addModeEntered()
   160 {
   160 {
   161     mViewOptions = mMenuView->view()->takeMenu();
   161     mViewOptions = mMenuView->view()->takeMenu();
       
   162     mMenuView->disableOviStore(true);
   162     connect(mMenuView.data(),
   163     connect(mMenuView.data(),
   163             SIGNAL(activated(QModelIndex)),
   164             SIGNAL(activated(QModelIndex)),
   164             SLOT(addActivated(QModelIndex)));
   165             SLOT(addActivated(QModelIndex)));
   165     connect(mMenuView.data(),
   166     connect(mMenuView.data(),
   166             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
   167             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
   179  Slot invoked when normal mode entered.
   180  Slot invoked when normal mode entered.
   180  */
   181  */
   181 void HsBaseViewState::normalModeEntered()
   182 void HsBaseViewState::normalModeEntered()
   182 {
   183 {
   183     setMenuOptions();
   184     setMenuOptions();
       
   185     mMenuView->disableOviStore(false);
   184     connect(mMenuView.data(),
   186     connect(mMenuView.data(),
   185             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
   187             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
   186             SLOT(showContextMenu(HbAbstractViewItem *, QPointF)));
   188             SLOT(showContextMenu(HbAbstractViewItem *, QPointF)));
   187 }
   189 }
   188 
   190 
   208     if (!entry.isNull() && !(entry->flags() & UninstallEntryFlag)) {
   210     if (!entry.isNull() && !(entry->flags() & UninstallEntryFlag)) {
   209         if (entry->entryTypeName() == Hs::widgetTypeName) {
   211         if (entry->entryTypeName() == Hs::widgetTypeName) {
   210             machine()->postEvent(HsMenuEventFactory::createPreviewHSWidgetEvent(entry->id(),
   212             machine()->postEvent(HsMenuEventFactory::createPreviewHSWidgetEvent(entry->id(),
   211                 entry->entryTypeName(), entry->attribute(Hs::widgetUriAttributeName),
   213                 entry->entryTypeName(), entry->attribute(Hs::widgetUriAttributeName),
   212                 entry->attribute(Hs::widgetLibraryAttributeName)));
   214                 entry->attribute(Hs::widgetLibraryAttributeName)));
   213             HsMenuService::touch(entry->id());
   215             HsMenuService::touch(*entry);
   214         }
   216         } else {
   215         else {
   217             int errCode = HsMenuService::executeAction(*entry);
   216             int errCode = HsMenuService::executeAction(entry->id());
       
   217             if (errCode != 0) {
   218             if (errCode != 0) {
   218                 createApplicationLaunchFailMessage(errCode, entry->id());
   219                 createApplicationLaunchFailMessage(errCode, entry->id());
   219             }
   220             }
   220         }
   221         }
   221     }
   222     }
   231     HSMENUTEST_FUNC_ENTRY("HsBaseViewState::openCollection");
   232     HSMENUTEST_FUNC_ENTRY("HsBaseViewState::openCollection");
   232     QVariant data = mModel->data(index, CaItemModel::IdRole);
   233     QVariant data = mModel->data(index, CaItemModel::IdRole);
   233     int id = data.toInt();
   234     int id = data.toInt();
   234     QString collectionType = mModel->data(
   235     QString collectionType = mModel->data(
   235             index, CaItemModel::TypeRole).toString();
   236             index, CaItemModel::TypeRole).toString();
   236     qDebug("HsBaseViewState::openCollection - MCS ID: %d", data.toInt());
   237     qDebug("HsBaseViewState::openCollection - ID: %d", data.toInt());
   237 
   238 
   238     machine()->postEvent(
   239     machine()->postEvent(
   239             HsMenuEventFactory::createOpenCollectionFromAppLibraryEvent(
   240             HsMenuEventFactory::createOpenCollectionFromAppLibraryEvent(
   240                     id, collectionType));
   241                     id, collectionType));
   241     HSMENUTEST_FUNC_EXIT("HsBaseViewState::openCollection");
   242     HSMENUTEST_FUNC_EXIT("HsBaseViewState::openCollection");
   251     HSMENUTEST_FUNC_ENTRY("HsBaseViewState::showContextMenu");
   252     HSMENUTEST_FUNC_ENTRY("HsBaseViewState::showContextMenu");
   252 
   253 
   253     EntryFlags flags = item->modelIndex().data(
   254     EntryFlags flags = item->modelIndex().data(
   254             CaItemModel::FlagsRole).value<EntryFlags> ();
   255             CaItemModel::FlagsRole).value<EntryFlags> ();
   255 
   256 
   256     if (!(flags & UninstallEntryFlag)) {
   257     if ((!(flags & UninstallEntryFlag)) && (flags & VisibleEntryFlag)) {
   257         mContextMenu = new HbMenu;
   258         mContextMenu = new HbMenu;
   258         setContextMenuOptions(item,flags);
   259         setContextMenuOptions(item,flags);
   259         mContextModelIndex = item->modelIndex();
   260         mContextModelIndex = item->modelIndex();
   260         mContextMenu->setPreferredPos(coords);
   261         mContextMenu->setPreferredPos(coords);
   261         mContextMenu->setAttribute(Qt::WA_DeleteOnClose);
   262         mContextMenu->setAttribute(Qt::WA_DeleteOnClose);
   314  */
   315  */
   315 void HsBaseViewState::closeContextMenu()
   316 void HsBaseViewState::closeContextMenu()
   316 {
   317 {
   317     if (mContextMenu) {
   318     if (mContextMenu) {
   318         mContextMenu->close();
   319         mContextMenu->close();
   319     }    
   320     }
   320 }
   321 }
   321 
   322 
   322 /*!
   323 /*!
   323  Handles context menu actions
   324  Handles context menu actions
   324  \param action action taken in context menu
   325  \param action action taken in context menu
   327 {
   328 {
   328     Hs::HsContextAction command =
   329     Hs::HsContextAction command =
   329         static_cast<Hs::HsContextAction>(action->data().toInt());
   330         static_cast<Hs::HsContextAction>(action->data().toInt());
   330 
   331 
   331     const int itemId = mContextModelIndex.data(CaItemModel::IdRole).toInt();
   332     const int itemId = mContextModelIndex.data(CaItemModel::IdRole).toInt();
   332     
   333 
   333     if (itemId > 0) {
   334     if (itemId > 0) {
   334         switch (command) {
   335         switch (command) {
   335             case Hs::AddToHomeScreenContextAction:
   336             case Hs::AddToHomeScreenContextAction:
   336                 addToHomeScreen(itemId);
   337                 addToHomeScreen(itemId);
   337                 break;
   338                 break;