homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallcollectionsstate.cpp
changeset 62 341166945d65
parent 55 03646e8da489
child 63 52b0f64eeb51
child 77 4b195f3bea29
equal deleted inserted replaced
57:2e2dc3d30ca8 62:341166945d65
    75 HsAllCollectionsState::HsAllCollectionsState(
    75 HsAllCollectionsState::HsAllCollectionsState(
    76     HsMenuViewBuilder &menuViewBuilder,
    76     HsMenuViewBuilder &menuViewBuilder,
    77     HsMenuModeWrapper &menuMode,
    77     HsMenuModeWrapper &menuMode,
    78     HsMainWindow &mainWindow,
    78     HsMainWindow &mainWindow,
    79     QState *parent):
    79     QState *parent):
    80     QState(parent),
    80     HsBaseViewState(parent),
    81     mSortAttribute(CustomHsSortAttribute),
    81     mSortAttribute(CustomHsSortAttribute),
    82     mMenuView(menuViewBuilder, HsAllCollectionsContext),
    82     mMenuView(menuViewBuilder, HsAllCollectionsContext),
    83     mMenuMode(menuMode),
    83     mMenuMode(menuMode),
    84     mAllCollectionsModel(0),
    84     mAllCollectionsModel(0),
    85     mMainWindow(mainWindow),
    85     mMainWindow(mainWindow),
   228  Slot invoked when normal mode is entered.
   228  Slot invoked when normal mode is entered.
   229 */
   229 */
   230 void HsAllCollectionsState::normalModeEntered()
   230 void HsAllCollectionsState::normalModeEntered()
   231 {
   231 {
   232     setMenuOptions();
   232     setMenuOptions();
   233 
   233     connect(&mMainWindow, SIGNAL(viewIsReady()),
       
   234         &mMainWindow, SLOT(saveActivity()),
       
   235         Qt::UniqueConnection);
   234     connect(&mMenuView,
   236     connect(&mMenuView,
   235             SIGNAL(activated(QModelIndex)),
   237             SIGNAL(activated(QModelIndex)),
   236             SLOT(listItemActivated(QModelIndex)));
   238             SLOT(listItemActivated(QModelIndex)));
   237     connect(&mMenuView,
   239     connect(&mMenuView,
   238             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
   240             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
   264  Slot invoked when a state is exited.
   266  Slot invoked when a state is exited.
   265  */
   267  */
   266 void HsAllCollectionsState::stateExited()
   268 void HsAllCollectionsState::stateExited()
   267 {
   269 {
   268     HSMENUTEST_FUNC_ENTRY("HsAllCollectionsState::stateExited");
   270     HSMENUTEST_FUNC_ENTRY("HsAllCollectionsState::stateExited");
   269 
   271     
       
   272     disconnect(&mMainWindow, SIGNAL(viewIsReady()),
       
   273                &mMainWindow, SLOT(saveActivity()));
       
   274     
   270     mMenuView.setSearchPanelVisible(false);
   275     mMenuView.setSearchPanelVisible(false);
   271 
   276 
   272     mMenuView.disconnect(this);
   277     mMenuView.disconnect(this);
   273 
   278 
   274     mMenuView.inactivate();
   279     mMenuView.inactivate();
   275 
   280 
   276     if (mContextMenu)
   281     if (mContextMenu)
   277         mContextMenu->close();
   282         mContextMenu->close();
       
   283     
       
   284     HsBaseViewState::stateExited();
   278 
   285 
   279     HSMENUTEST_FUNC_EXIT("HsAllCollectionsState::stateExited");
   286     HSMENUTEST_FUNC_EXIT("HsAllCollectionsState::stateExited");
   280     qDebug("AllCollectionsState::stateExited()");
   287     qDebug("AllCollectionsState::stateExited()");
   281 }
   288 }
   282 
   289 
   303     qDebug("AllCollectionsState::listItemActivated - MCS ID: %d",
   310     qDebug("AllCollectionsState::listItemActivated - MCS ID: %d",
   304            data.toInt());
   311            data.toInt());
   305 
   312 
   306     mMenuView.setSearchPanelVisible(false);
   313     mMenuView.setSearchPanelVisible(false);
   307 
   314 
   308     machine()->postEvent(HsMenuEventFactory::createOpenCollectionEvent(id,
   315     machine()->postEvent(HsMenuEventFactory::createOpenCollectionFromAppLibraryEvent(id,
   309                          collectionType));
   316                          collectionType));
   310     HSMENUTEST_FUNC_EXIT("HsAllCollectionsState::listItemActivated");
   317     HSMENUTEST_FUNC_EXIT("HsAllCollectionsState::listItemActivated");
   311 }
   318 }
   312 
   319 
   313 /*!
   320 /*!
   317 void HsAllCollectionsState::addActivated(const QModelIndex &index)
   324 void HsAllCollectionsState::addActivated(const QModelIndex &index)
   318 {
   325 {
   319     const int itemId = index.data(CaItemModel::IdRole).toInt();
   326     const int itemId = index.data(CaItemModel::IdRole).toInt();
   320     machine()->postEvent(
   327     machine()->postEvent(
   321         HsMenuEventFactory::createAddToHomeScreenEvent(
   328         HsMenuEventFactory::createAddToHomeScreenEvent(
   322             itemId, mMenuMode.getHsMenuMode()));
   329             itemId, mMenuMode.getHsMenuMode(), mMenuMode.getHsToken()));
   323 }
   330 }
   324 
   331 
   325 /*!
   332 /*!
   326  Slot connected to List widget in add mode.
   333  Slot connected to List widget in add mode.
   327  Called when item long pressed.
   334  Called when item long pressed.
   333 {
   340 {
   334     Q_UNUSED(coords);
   341     Q_UNUSED(coords);
   335     const int itemId = item->modelIndex().data(CaItemModel::IdRole).toInt();
   342     const int itemId = item->modelIndex().data(CaItemModel::IdRole).toInt();
   336     machine()->postEvent(
   343     machine()->postEvent(
   337         HsMenuEventFactory::createAddToHomeScreenEvent(itemId,
   344         HsMenuEventFactory::createAddToHomeScreenEvent(itemId,
   338                 mMenuMode.getHsMenuMode()));
   345                 mMenuMode.getHsMenuMode(), mMenuMode.getHsToken()));
   339 }
   346 }
   340 
   347 
   341 /*!
   348 /*!
   342  Slot connected to List widget in normal mode.
   349  Slot connected to List widget in normal mode.
   343  Called when item long pressed.
   350  Called when item long pressed.
   389 
   396 
   390     switch (command) {
   397     switch (command) {
   391         case AddToHomeScreenContextAction:
   398         case AddToHomeScreenContextAction:
   392             machine()->postEvent(
   399             machine()->postEvent(
   393                 HsMenuEventFactory::createAddToHomeScreenEvent(
   400                 HsMenuEventFactory::createAddToHomeScreenEvent(
   394                     itemId, mMenuMode.getHsMenuMode()));
   401                     itemId, mMenuMode.getHsMenuMode(), mMenuMode.getHsToken()));
   395             break;
   402             break;
   396         case RenameContextAction:
   403         case RenameContextAction:
   397             machine()->postEvent(
   404             machine()->postEvent(
   398                 HsMenuEventFactory::createRenameCollectionEvent(itemId));
   405                 HsMenuEventFactory::createRenameCollectionEvent(itemId));
   399             break;
   406             break;
   473     setMenuOptions();
   480     setMenuOptions();
   474     mAllCollectionsModel->setSort(mSortAttribute);
   481     mAllCollectionsModel->setSort(mSortAttribute);
   475     emit sortOrderChanged(mSortAttribute);
   482     emit sortOrderChanged(mSortAttribute);
   476     HSMENUTEST_FUNC_EXIT("HsAllCollectionsState::descendingMenuAction");
   483     HSMENUTEST_FUNC_EXIT("HsAllCollectionsState::descendingMenuAction");
   477 }
   484 }
       
   485