homescreenapp/stateplugins/hsapplibrarystateplugin/src/hscollectionstate.cpp
changeset 36 cdae8c6c3876
parent 35 f9ce957a272c
child 39 4e8ebe173323
equal deleted inserted replaced
35:f9ce957a272c 36:cdae8c6c3876
   120         mCollectionModel->root().data(Qt::DisplayRole).toString());
   120         mCollectionModel->root().data(Qt::DisplayRole).toString());
   121 
   121 
   122 
   122 
   123     if (!mOptions) {
   123     if (!mOptions) {
   124         mOptions = new HbMenu();
   124         mOptions = new HbMenu();
       
   125         mOptions->addAction(hbTrId("txt_applib_opt_task_switcher"),
       
   126                             this,
       
   127                             SLOT(openTaskSwitcher()));
   125 
   128 
   126         EntryFlags flags =
   129         EntryFlags flags =
   127             mCollectionModel->root().data(CaItemModel::FlagsRole).value<
   130             mCollectionModel->root().data(CaItemModel::FlagsRole).value<
   128             EntryFlags> ();
   131             EntryFlags> ();
   129 
   132 
   168         }
   171         }
   169 
   172 
   170         mOptions->setParent(this);
   173         mOptions->setParent(this);
   171         mMenuView.view()->setMenu(mOptions);
   174         mMenuView.view()->setMenu(mOptions);
   172     }
   175     }
   173 
   176     mOldNavigationAction = mMenuView.view()->navigationAction();
   174     HbMainWindow *hbMainWindow =
   177     mMenuView.view()->setNavigationAction(mSecondarySoftkeyAction);
   175         HbInstance::instance()->allMainWindows().value(0);
   178     
   176     // add BackStepping action
       
   177 
       
   178     hbMainWindow->addSoftKeyAction(Hb::SecondarySoftKey,
       
   179                                    mSecondarySoftkeyAction);
       
   180     makeConnect();
   179     makeConnect();
   181     HSMENUTEST_FUNC_EXIT("HsCollectionState::stateEntered");
   180     HSMENUTEST_FUNC_EXIT("HsCollectionState::stateEntered");
   182 }
   181 }
   183 
   182 
   184 // ---------------------------------------------------------------------------
   183 // ---------------------------------------------------------------------------
   192     mOptions = NULL;
   191     mOptions = NULL;
   193 
   192 
   194     mMenuView.view()->setMenu(NULL);
   193     mMenuView.view()->setMenu(NULL);
   195     mMenuView.setLabelVisible(false);
   194     mMenuView.setLabelVisible(false);
   196 
   195 
   197     HbMainWindow *hbW = HbInstance::instance()->allMainWindows().value(0);
   196     // revert navigation action
   198     if (hbW) {
   197     mMenuView.view()->setNavigationAction(mOldNavigationAction);
   199         //remove BackStepping action
   198 
   200         hbW->removeSoftKeyAction(Hb::SecondarySoftKey,
       
   201                                  mSecondarySoftkeyAction);
       
   202     }
       
   203     HSMENUTEST_FUNC_EXIT("HsCollectionState::stateExited");
   199     HSMENUTEST_FUNC_EXIT("HsCollectionState::stateExited");
   204     qDebug("CollectionState::stateExited()");
   200     qDebug("CollectionState::stateExited()");
   205 }
   201 }
   206 
   202 
   207 // ---------------------------------------------------------------------------
   203 // ---------------------------------------------------------------------------
   232     disconnect(&mMenuView, SIGNAL(activated(QModelIndex)),
   228     disconnect(&mMenuView, SIGNAL(activated(QModelIndex)),
   233                this, SLOT(listItemActivated(QModelIndex)));
   229                this, SLOT(listItemActivated(QModelIndex)));
   234 
   230 
   235     disconnect(&mMenuView, SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
   231     disconnect(&mMenuView, SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
   236                this, SLOT(listItemLongPressed(HbAbstractViewItem *, QPointF)));
   232                this, SLOT(listItemLongPressed(HbAbstractViewItem *, QPointF)));
       
   233 }
       
   234 
       
   235 /*!
       
   236  Open task switcher.
       
   237  \retval true if operation is successful.
       
   238  */
       
   239 bool HsCollectionState::openTaskSwitcher()
       
   240 {
       
   241     return HsMenuService::launchTaskSwitcher();
   237 }
   242 }
   238 
   243 
   239 // ---------------------------------------------------------------------------
   244 // ---------------------------------------------------------------------------
   240 // ---------------------------------------------------------------------------
   245 // ---------------------------------------------------------------------------
   241 //
   246 //
   384   \retval void
   389   \retval void
   385  */
   390  */
   386 void HsCollectionState::addElementToHomeScreen(const QModelIndex &index)
   391 void HsCollectionState::addElementToHomeScreen(const QModelIndex &index)
   387 {
   392 {
   388     const CaEntry *entry = mCollectionModel->entry(index);
   393     const CaEntry *entry = mCollectionModel->entry(index);
   389 
   394     
   390     machine()->
   395     QMap<QString, QString> attributes = entry->attributes();
   391     postEvent(
   396 
       
   397     machine()->postEvent(
   392         HsMenuEventFactory::createAddToHomeScreenEvent(
   398         HsMenuEventFactory::createAddToHomeScreenEvent(
   393             entry->id(),
   399             entry->id(),
   394             entry->entryTypeName(),
   400             entry->entryTypeName(),
   395             entry->attribute(widgetUriAttributeName()),
   401             entry->attribute(widgetUriAttributeName()),
   396             entry->attribute(widgetLibraryAttributeName())));
   402             entry->attribute(widgetLibraryAttributeName()),
       
   403             &attributes));
   397 }
   404 }
   398 
   405 
   399 /*!
   406 /*!
   400   A Slot called when an action for sorting (latest
   407   A Slot called when an action for sorting (latest
   401   on top) is invoked for Downloaded collection.
   408   on top) is invoked for Downloaded collection.