phonebookui/Phonebook2/GroupExtension/src/CPguGroupMembersView.cpp
branchRCL_3
changeset 58 d4f567ce2e7c
parent 35 4ae315f230bc
child 64 c1e8ba0c2b16
equal deleted inserted replaced
57:2666d9724c76 58:d4f567ce2e7c
   466         /**
   466         /**
   467          * Destructor.
   467          * Destructor.
   468          */
   468          */
   469         virtual ~CGroupMembersViewImpl()
   469         virtual ~CGroupMembersViewImpl()
   470             {}
   470             {}
       
   471         
       
   472     public:
       
   473         
       
   474         void SetMarkingModeOn( TBool aMarkingModeOn )
       
   475             {
       
   476             iMarkingModeOn = aMarkingModeOn;
       
   477             }
       
   478         
       
   479         TBool IsMarkingModeOn()
       
   480             {
       
   481             return iMarkingModeOn;
       
   482             }
   471 
   483 
   472     protected: // Implementation
   484     protected: // Implementation
   473         CGroupMembersViewImpl()
   485         CGroupMembersViewImpl() : iMarkingModeOn( EFalse )
   474             {}
   486             {}
       
   487         
       
   488     protected:
       
   489         // Flag to indicate whether Marking mode is active
       
   490         TBool iMarkingModeOn;
   475     };
   491     };
   476 
   492 
   477 
   493 
   478 /**
   494 /**
   479  * Group members view implementation class. This class encapsulates
   495  * Group members view implementation class. This class encapsulates
  1117     {
  1133     {
  1118     // Add this view to observe command events
  1134     // Add this view to observe command events
  1119     iCommandHandler.AddMenuCommandObserver(*this);
  1135     iCommandHandler.AddMenuCommandObserver(*this);
  1120 
  1136 
  1121     iStoreConf = &( Phonebook2::Pbk2AppUi()->ApplicationServices().
  1137     iStoreConf = &( Phonebook2::Pbk2AppUi()->ApplicationServices().
  1122     	StoreConfiguration() );
  1138         StoreConfiguration() );
  1123     iStoreConf->AddObserverL( *this );
  1139     iStoreConf->AddObserverL( *this );
  1124 
  1140 
  1125     // Expand the group members view from the all groups view
  1141     // Expand the group members view from the all groups view
  1126     const MVPbkViewContact& group =
  1142     const MVPbkViewContact& group =
  1127         Phonebook2::Pbk2AppUi()->ApplicationServices().
  1143         Phonebook2::Pbk2AppUi()->ApplicationServices().
  1424                 }
  1440                 }
  1425             case EKeyEnter: // FALLTHROUGH
  1441             case EKeyEnter: // FALLTHROUGH
  1426             case EKeyOK:
  1442             case EKeyOK:
  1427                 {
  1443                 {
  1428                 if ( !ShiftDown(aKeyEvent) ) // pure OK or ENTER key
  1444                 if ( !ShiftDown(aKeyEvent) ) // pure OK or ENTER key
  1429 					{	
  1445                     {
  1430                     if ( iControl->ContactsMarked() && itemSpecEnabled )
  1446                     if ( iControl->ContactsMarked() && itemSpecEnabled )
  1431                     	{
  1447                         {
  1432                     	iView.LaunchPopupMenuL(
  1448                         result = ETrue;
  1433                     		R_PHONEBOOK2_GROUPMEMBERS_CONTEXT_MENUBAR);
  1449                         }
  1434 						result = ETrue;
  1450                     else if ( iControl->NumberOfContacts() == 0 )
  1435 						}
  1451                         {
  1436 					else if ( iControl->NumberOfContacts() == 0 )
  1452                         result = ETrue;
  1437 						{
  1453                         }
  1438 						result = ETrue;
       
  1439 						}
       
  1440                     }
  1454                     }
  1441                 break;
  1455                 break;
  1442                 }
  1456                 }
  1443 
  1457 
  1444             case EKeyPhoneSend:
  1458             case EKeyPhoneSend:
  1529 
  1543 
  1530             if ( iControl->ContactsMarked() )
  1544             if ( iControl->ContactsMarked() )
  1531                 {
  1545                 {
  1532                 aMenuPane->SetItemDimmed( EPbk2CmdBelongsToGroups, ETrue );
  1546                 aMenuPane->SetItemDimmed( EPbk2CmdBelongsToGroups, ETrue );
  1533                 aMenuPane->SetItemDimmed( EPbk2CmdAddMembers, ETrue );
  1547                 aMenuPane->SetItemDimmed( EPbk2CmdAddMembers, ETrue );
  1534                 aMenuPane->SetItemSpecific( EPbk2CmdRemoveFromGroup, EFalse );
       
  1535                 }
  1548                 }
  1536             // Weed out commands not meant to be if names list is empty
  1549             // Weed out commands not meant to be if names list is empty
  1537             if ( Phonebook2::Pbk2AppUi()->ApplicationServices().
  1550             if ( Phonebook2::Pbk2AppUi()->ApplicationServices().
  1538                     ViewSupplier().AllContactsViewL()->ContactCountL() == 0 )
  1551                     ViewSupplier().AllContactsViewL()->ContactCountL() == 0 )
  1539                 {
  1552                 {
  1547             // Weed out commands not meant to be used with empty list
  1560             // Weed out commands not meant to be used with empty list
  1548             if ( iControl->NumberOfContacts() == 0 )
  1561             if ( iControl->NumberOfContacts() == 0 )
  1549                 {
  1562                 {
  1550                 aMenuPane->SetItemDimmed( EPbk2CmdSend, ETrue );
  1563                 aMenuPane->SetItemDimmed( EPbk2CmdSend, ETrue );
  1551                 }
  1564                 }
  1552             if ( iControl->ContactsMarked() )
  1565                 
  1553                 {
  1566             // When Marking mode is active,
  1554                 aMenuPane->SetItemSpecific( EPbk2CmdSend, EFalse );
  1567             // Send as business card item should be shown in pop up menu.
       
  1568             if( iMarkingModeOn )
       
  1569                 {
       
  1570                 aMenuPane->SetItemSpecific( EPbk2CmdSend, ETrue );
  1555                 }
  1571                 }
  1556             break;
  1572             break;
  1557             }
  1573             }
  1558 
  1574 
  1559         case R_PHONEBOOK2_GROUPMEMBERS_CONTEXT_MENU:
  1575         case R_PHONEBOOK2_GROUPMEMBERS_CONTEXT_MENU:
  1784                 // Set middle softkey as Context menu.
  1800                 // Set middle softkey as Context menu.
  1785                 iView.Cba()->SetCommandSetL(
  1801                 iView.Cba()->SetCommandSetL(
  1786                     R_PBK2_SOFTKEYS_OPTIONS_BACK_CONTEXT);
  1802                     R_PBK2_SOFTKEYS_OPTIONS_BACK_CONTEXT);
  1787                 }
  1803                 }
  1788             iView.Cba()->DrawDeferred();
  1804             iView.Cba()->DrawDeferred();
  1789             // Change context menu when marked items
       
  1790             iView.MenuBar()->SetContextMenuTitleResourceId
       
  1791                 ( R_PHONEBOOK2_GROUPMEMBERS_CONTEXT_MENUBAR );
       
  1792             }
  1805             }
  1793         }
  1806         }
  1794     }
  1807     }
  1795 
  1808 
  1796 // --------------------------------------------------------------------------
  1809 // --------------------------------------------------------------------------
  1898                     !iControl->ContactsMarked())
  1911                     !iControl->ContactsMarked())
  1899                     {
  1912                     {
  1900                     // Select key is mapped to "Open Contact" command
  1913                     // Select key is mapped to "Open Contact" command
  1901                     HandleCommandL( EPbk2CmdOpenCca );
  1914                     HandleCommandL( EPbk2CmdOpenCca );
  1902                     }
  1915                     }
  1903                 else
       
  1904                     {
       
  1905                     iView.LaunchPopupMenuL(
       
  1906                             R_PHONEBOOK2_GROUPMEMBERS_CONTEXT_MENUBAR);
       
  1907                     }
       
  1908                 break;
  1916                 break;
  1909                 }
  1917                 }
  1910             default:
  1918             default:
  1911                break;
  1919                break;
  1912             }
  1920             }
  1951               !iSelectionModifierUsed )
  1959               !iSelectionModifierUsed )
  1952         {
  1960         {
  1953         if ( iControl->NumberOfContacts() > 0 && 
  1961         if ( iControl->NumberOfContacts() > 0 && 
  1954                 iPointerEventInspector->FocusedItemPointed() )
  1962                 iPointerEventInspector->FocusedItemPointed() )
  1955             {
  1963             {
  1956             if ( iControl->ContactsMarked() )
  1964             if ( !iControl->ContactsMarked() )
  1957                 {
       
  1958                 iView.LaunchPopupMenuL(
       
  1959                     R_PHONEBOOK2_GROUPMEMBERS_CONTEXT_MENUBAR );
       
  1960                 }
       
  1961             else
       
  1962                 {
  1965                 {
  1963                 // Open contact
  1966                 // Open contact
  1964                 HandleCommandL(EPbk2CmdOpenCca);
  1967                 HandleCommandL(EPbk2CmdOpenCca);
  1965                 }
  1968                 }
  1966             }
  1969             }
  2185         Phonebook2::Pbk2AppUi()->Pbk2StartupMonitor()->
  2188         Phonebook2::Pbk2AppUi()->Pbk2StartupMonitor()->
  2186             NotifyViewActivationL( iView.Id() );
  2189             NotifyViewActivationL( iView.Id() );
  2187         }
  2190         }
  2188 
  2191 
  2189     iViewImpl->CreateControlL(iView.ClientRect());
  2192     iViewImpl->CreateControlL(iView.ClientRect());
  2190     
  2193 
  2191     CPbk2NamesListControl* nlctrl=static_cast <CPbk2NamesListControl*> (iViewImpl->Control());
  2194     CPbk2NamesListControl* nlctrl=static_cast <CPbk2NamesListControl*> (iViewImpl->Control());
       
  2195 
       
  2196     // It will return the listbox by calling nlctrl->ComponentControl(0),
       
  2197     // which is defined in CPbk2NamesListControl::ComponentControl(TInt aIndex).
  2192     CCoeControl* ctrl=nlctrl->ComponentControl(0);
  2198     CCoeControl* ctrl=nlctrl->ComponentControl(0);
  2193     CEikListBox* listbox=static_cast <CEikListBox*> (ctrl);
  2199     CEikListBox* listbox=static_cast <CEikListBox*> (ctrl);
  2194     listbox->SetListBoxObserver( this ); 
  2200     listbox->SetListBoxObserver( this );
       
  2201     listbox->SetMarkingModeObserver( this );
  2195 
  2202 
  2196     iPreviousViewId = aPrevViewId;
  2203     iPreviousViewId = aPrevViewId;
  2197 
  2204 
  2198     viewActivationTransaction->Commit();
  2205     viewActivationTransaction->Commit();
  2199     CleanupStack::PopAndDestroy(); // viewActivationTransaction
  2206     CleanupStack::PopAndDestroy(); // viewActivationTransaction
  2275         {
  2282         {
  2276         switch ( aEventType )
  2283         switch ( aEventType )
  2277             {
  2284             {
  2278             case EEventItemDoubleClicked:
  2285             case EEventItemDoubleClicked:
  2279             case EEventItemSingleClicked:
  2286             case EEventItemSingleClicked:
  2280 		    case EEventEnterKeyPressed:
  2287             case EEventEnterKeyPressed:
  2281                 {
  2288                 {
  2282 
  2289 
  2283                 if ( iViewImpl )
  2290                 if ( iViewImpl )
  2284                     {
  2291                     {
  2285                     // route the events to the view implementing the application
  2292                     // route the events to the view implementing the application
  2304 // --------------------------------------------------------------------------
  2311 // --------------------------------------------------------------------------
  2305 //
  2312 //
  2306 void CPguGroupMembersView::HandlePointerEventL(
  2313 void CPguGroupMembersView::HandlePointerEventL(
  2307         const TPointerEvent& aPointerEvent)
  2314         const TPointerEvent& aPointerEvent)
  2308     {
  2315     {
  2309     if ( iViewImpl )
  2316     if ( iViewImpl && !iViewImpl->IsMarkingModeOn() )
  2310         {
  2317         {
  2311         // route the pointer events to the view implementing the application
  2318         // Route the pointer events to the view implementing the application
  2312         // view currently
  2319         // view currently except the Marking mode is active, 
       
  2320         // because the event is handled by avkon when marking mode is active.
  2313         iViewImpl->HandlePointerEventL(aPointerEvent);
  2321         iViewImpl->HandlePointerEventL(aPointerEvent);
  2314         }
  2322         }
  2315     }
  2323     }
  2316 
  2324 
  2317 // --------------------------------------------------------------------------
  2325 // --------------------------------------------------------------------------
  2327         // route the long tap event to the view implementing the application
  2335         // route the long tap event to the view implementing the application
  2328         // view currently
  2336         // view currently
  2329         iViewImpl->HandleLongTapEventL(
  2337         iViewImpl->HandleLongTapEventL(
  2330             aPenEventLocation, aPenEventScreenLocation );
  2338             aPenEventLocation, aPenEventScreenLocation );
  2331         }
  2339         }
       
  2340     }
       
  2341 
       
  2342 // -----------------------------------------------------------------------------
       
  2343 // CPguGroupMembersView::MarkingModeStatusChanged
       
  2344 // -----------------------------------------------------------------------------
       
  2345 //
       
  2346 void CPguGroupMembersView::MarkingModeStatusChanged( TBool aActivated )
       
  2347     {
       
  2348     if( iViewImpl )
       
  2349         {
       
  2350         iViewImpl->SetMarkingModeOn( aActivated );
       
  2351         CPbk2NamesListControl* nlctrl = 
       
  2352             static_cast <CPbk2NamesListControl*> (iViewImpl->Control());
       
  2353         if( !aActivated )
       
  2354             {
       
  2355             // It will return the findbox by calling 
       
  2356             // nlctrl->ComponentControl(1), which is defined in 
       
  2357             // CPbk2NamesListControl::ComponentControl(TInt aIndex).
       
  2358             CCoeControl* ctrl=nlctrl->ComponentControl(1);
       
  2359             if( ctrl->IsVisible() )
       
  2360                 {
       
  2361                 // Clear the text of the FindBox
       
  2362                 // when canceling from Marking mode.
       
  2363                 TRAP_IGNORE( nlctrl->ResetFindL() );
       
  2364                 }
       
  2365             }
       
  2366         nlctrl->SetMarkingMode( aActivated );
       
  2367         }
       
  2368     }
       
  2369 
       
  2370 // -----------------------------------------------------------------------------
       
  2371 // CPguGroupMembersView::ExitMarkingMode
       
  2372 // Called by avkon, if the return value is ETrue, 
       
  2373 // the Marking mode will be canceled after any operation,
       
  2374 // otherwise the Marking mode keep active.
       
  2375 // -----------------------------------------------------------------------------
       
  2376 //
       
  2377 TBool CPguGroupMembersView::ExitMarkingMode() const
       
  2378     {
       
  2379     return EFalse; 
  2332     }
  2380     }
  2333 
  2381 
  2334 // --------------------------------------------------------------------------
  2382 // --------------------------------------------------------------------------
  2335 // CPguGroupMembersView::TransformViewActivationStateToReady
  2383 // CPguGroupMembersView::TransformViewActivationStateToReady
  2336 // --------------------------------------------------------------------------
  2384 // --------------------------------------------------------------------------