notepad/notepad1/LibSrc/NpdListDialog.cpp
branchRCL_3
changeset 21 9711e452b5e9
parent 20 21239b3bcd78
child 27 55d60436f00b
equal deleted inserted replaced
20:21239b3bcd78 21:9711e452b5e9
   174         }
   174         }
   175     else 
   175     else 
   176         {
   176         {
   177         iFlags &= ~ENotepadItemAdded;
   177         iFlags &= ~ENotepadItemAdded;
   178         }
   178         }
   179     if ( aEagerSync )
   179     if ( aEagerSync && iClockValueChange )
   180         {
   180         {
   181         if(iClockValueChange)
   181         iModel->SetItemArrayFlags();
   182         	{
   182         iClockValueChange = EFalse;        
   183         	iModel->SetItemArrayFlags();
       
   184         	iClockValueChange = EFalse;
       
   185         	}
       
   186         iModel->SyncL(EFalse);
       
   187         RestoreCurrentAndSelectionsL();
       
   188         DrawNow();
       
   189         }
   183         }
   190     if (aStatOfSave == CNotepadModel::ENotepadModelRowDeleted)
   184     if (aStatOfSave == CNotepadModel::ENotepadModelRowDeleted)
   191     	{
   185     	{
   192     	iListBox->HandleItemRemovalL();
   186     	iListBox->HandleItemRemovalL();
   193     	DrawNow();
   187     	DrawNow();
   194     	}
   188     	}
       
   189     iModel->SyncL(EFalse);
       
   190     RestoreCurrentAndSelectionsL();
       
   191     DrawNow();
   195         // MSK 
   192         // MSK 
   196         MiddleSoftKeyL();
   193         MiddleSoftKeyL();
   197     }
   194     }
   198 
   195 
   199 // -----------------------------------------------------------------------------
   196 // -----------------------------------------------------------------------------
   873 		{
   870 		{
   874 		return;
   871 		return;
   875 		}
   872 		}
   876     iModel->SyncL(EFalse);
   873     iModel->SyncL(EFalse);
   877     CNotepadDialogBase::DynInitMenuPaneL( aResourceId, aMenuPane );
   874     CNotepadDialogBase::DynInitMenuPaneL( aResourceId, aMenuPane );
   878     const TInt memoCount( iModel->MdcaCount() );
   875     const TInt memoCount( iModel->MdcaCount() - 1 );
   879    	const TInt markCount( iListBox->SelectionIndexes()->Count() );
   876    	const TInt markCount(iListBox->SelectionIndexes()->Count());
   880     TInt index;
   877 	TInt index;
   881     switch ( aResourceId )
   878 	switch (aResourceId )
   882         {
   879         {
   883         case R_SENDUI_MENU:
   880         case R_SENDUI_MENU:
   884             index = 2;
   881             index = 2;
   885 			iSendUi->AddSendMenuItemL(*aMenuPane, index, ENotepadCmdSend );
   882 			iSendUi->AddSendMenuItemL(*aMenuPane, index, ENotepadCmdSend );
   886             break;
   883             break;
   963             if ( (memoCount == 0) ||  ( markCount >= 1  ) )
   960             if ( (memoCount == 0) ||  ( markCount >= 1  ) )
   964                 {
   961                 {
   965                 // this must after InsertSendMenuItemAfterL
   962                 // this must after InsertSendMenuItemAfterL
   966                 aMenuPane->DeleteMenuItem(ENotepadCmdOpen);
   963                 aMenuPane->DeleteMenuItem(ENotepadCmdOpen);
   967                 }
   964                 }
   968             }
   965             if ( iListBox->CurrentItemIndex() == 0 && IsNotepad() && memoCount > 0)
       
   966 				{                    
       
   967 				aMenuPane->SetItemDimmed( ENotepadCmdDelete, ETrue );				 
       
   968 				aMenuPane->SetItemDimmed( ENotepadCmdSend, ETrue );				 
       
   969 				}
       
   970 			}
   969             break;
   971             break;
   970         default:
   972         default:
   971             AknSelectionService::HandleMarkableListDynInitMenuPane(
   973 			{
   972                 aResourceId, aMenuPane, iListBox);
   974 			if ( IsTemplates() )
   973             break;
   975 				{
   974         }
   976 				AknSelectionService::HandleMarkableListDynInitMenuPane(
       
   977 						aResourceId, aMenuPane, iListBox );				
       
   978 				}
       
   979 			else
       
   980 				{			
       
   981 			    HandleMarkListDynInitMenuPane( aResourceId, aMenuPane, iListBox );
       
   982 				}	
       
   983 			break;
       
   984 			}
       
   985 		}
   975     }
   986     }
   976     
   987     
   977 // -----------------------------------------------------------------------------
   988 // -----------------------------------------------------------------------------
   978 // CNotepadListDialog::DynInitMenuBarL
   989 // CNotepadListDialog::DynInitMenuBarL
   979 // from MEikMenuObserver
   990 // from MEikMenuObserver
  1023             OnCmdDeleteL();
  1034             OnCmdDeleteL();
  1024             break;
  1035             break;
  1025         case ENotepadCmdSend:
  1036         case ENotepadCmdSend:
  1026         	OnCmdSendL(aCommandId);
  1037         	OnCmdSendL(aCommandId);
  1027         	break;
  1038         	break;
       
  1039 		case EAknMarkAll:
       
  1040 			{
       
  1041 			if ( IsNotepad() )
       
  1042 				{
       
  1043 				iListBox->ClearSelection();
       
  1044 				TInt num = iListBox->Model()->NumberOfItems();
       
  1045 				if ( num < 2 )
       
  1046 					return;
       
  1047 				TInt ii = 0;
       
  1048 				CArrayFixFlat<TInt>* array = new (ELeave) CArrayFixFlat<TInt> (
       
  1049 						20 );
       
  1050 				CleanupStack::PushL(array);
       
  1051 				array->SetReserveL(num);
       
  1052 				for ( ii = 1; ii < num; ii++ )
       
  1053 					{
       
  1054 					array->AppendL( ii );
       
  1055 					}
       
  1056 				iListBox->SetSelectionIndexesL( array );
       
  1057 				CleanupStack::PopAndDestroy(); //array
       
  1058 				break;
       
  1059 				}
       
  1060 			}
  1028         default:
  1061         default:
  1029             {
  1062             {
  1030             const TInt aiwServiceCmd( iServiceHandler ? iServiceHandler->ServiceCmdByMenuCmd( aCommandId ) : 0 );                
  1063             const TInt aiwServiceCmd( iServiceHandler ? iServiceHandler->ServiceCmdByMenuCmd( aCommandId ) : 0 );                
  1031             if ( aiwServiceCmd == KAiwCmdPrint )
  1064             if ( aiwServiceCmd == KAiwCmdPrint )
  1032                 {
  1065                 {
  1297         {
  1330         {
  1298         case EEventEnterKeyPressed:
  1331         case EEventEnterKeyPressed:
  1299             OnCmdOpenL(aListBox->CurrentItemIndex());
  1332             OnCmdOpenL(aListBox->CurrentItemIndex());
  1300             break;
  1333             break;
  1301         case EEventItemSingleClicked:
  1334         case EEventItemSingleClicked:
  1302             if ( aListBox->Model()->NumberOfItems() != 0 
  1335         	if ( IsNotepad() )
  1303                 && aListBox->SelectionIndexes()->Count() == 0 )
  1336 				{     
  1304                 {
  1337 				if ( aListBox->Model()->NumberOfItems() != 0
  1305                 HandleListBoxPointerEventL( CNotepadListDialog::EOpenListBoxItem );
  1338 						&& aListBox->SelectionIndexes()->Count() == 0 )
  1306                 }
  1339 					{
  1307             else
  1340 				
  1308                 {
  1341 					HandleListBoxPointerEventL(
  1309                 HandleListBoxPointerEventL( CNotepadListDialog::EOpenListBoxContextMenu );
  1342 							CNotepadListDialog::EOpenListBoxItem);
  1310                 }
  1343 					}
       
  1344 				else
       
  1345 					{
       
  1346 					HandleListBoxPointerEventL(
       
  1347 							CNotepadListDialog::EOpenListBoxContextMenu );
       
  1348 					}
       
  1349 				}
       
  1350             
  1311             if(  IsTemplates() && AknLayoutUtils::PenEnabled() ) 
  1351             if(  IsTemplates() && AknLayoutUtils::PenEnabled() ) 
  1312                 {
  1352                 {
  1313                   if( !aListBox->SelectionIndexes()->Count()  )
  1353                   if( !aListBox->SelectionIndexes()->Count()  )
  1314                     {
  1354                     {
  1315                      OnCmdOpenL(aListBox->CurrentItemIndex());       
  1355                      OnCmdOpenL(aListBox->CurrentItemIndex());       
  1570 //
  1610 //
  1571 void CNotepadListDialog::HandleListBoxPointerEventL(TNotepadListBoxEvent aEvent)
  1611 void CNotepadListDialog::HandleListBoxPointerEventL(TNotepadListBoxEvent aEvent)
  1572 	{
  1612 	{
  1573 	if(aEvent == EOpenListBoxContextMenu && !MenuShowing())
  1613 	if(aEvent == EOpenListBoxContextMenu && !MenuShowing())
  1574 		{
  1614 		{
  1575 		if(iEditorFlag==EFalse)
  1615 		if (iListBox->CurrentItemIndex() == 0)
       
  1616 			{		
       
  1617 		    OnCmdAddL();
       
  1618 			}
       
  1619 		else if (iEditorFlag == EFalse)
  1576 		{
  1620 		{
  1577 		iFlags |= ENotepadMenuByOkKey;
  1621 		iFlags |= ENotepadMenuByOkKey;
  1578 		iMskFlag=ETrue;
  1622 		iMskFlag=ETrue;
  1579 		DisplayMenuL();	
  1623 		DisplayMenuL();	
  1580 		}
  1624 		}
  1581 		}
  1625 		}
  1582 	else if(aEvent == EOpenListBoxItem)
  1626 	else if(aEvent == EOpenListBoxItem)
  1583 		{
  1627 		{
  1584         if ( !iEditorDialog&& !IsTemplates() )
  1628 		if ( iListBox->CurrentItemIndex() == 0 )
       
  1629 			{		
       
  1630 			OnCmdAddL();
       
  1631 			}
       
  1632 		else if (!iEditorDialog && !IsTemplates())
  1585             {
  1633             {
  1586             OnCmdOpenL( iListBox->CurrentItemIndex() );
  1634             OnCmdOpenL( iListBox->CurrentItemIndex() );
  1587             }
  1635             }
  1588 		}
  1636 		}
  1589 	}
  1637 	}
  1597     {	
  1645     {	
  1598     const TInt markCount( iListBox->SelectionIndexes()->Count() );
  1646     const TInt markCount( iListBox->SelectionIndexes()->Count() );
  1599     
  1647     
  1600     if( !IsTemplates() ) // Notepad ListView
  1648     if( !IsTemplates() ) // Notepad ListView
  1601         {
  1649         {
  1602             if( (iModel->MdcaCount() == 0))
  1650             if( (iModel->MdcaCount() == 1))
  1603             {
  1651             {
  1604               ButtonGroupContainer().SetCommandSetL( R_NOTEPAD_SOFTKEYS_OPTIONS_EXIT_NEW );
  1652               ButtonGroupContainer().SetCommandSetL( R_NOTEPAD_SOFTKEYS_OPTIONS_EXIT_NEW );
  1605             }
  1653             }
  1606             else
  1654             else
  1607             {
  1655             {
  1670 #endif // 0
  1718 #endif // 0
  1671 
  1719 
  1672     return KErrNone;
  1720     return KErrNone;
  1673     }
  1721     }
  1674     
  1722     
       
  1723 // -----------------------------------------------------------------------------
       
  1724 // CNotepadListDialog::HandleMarkListDynInitMenuPane
       
  1725 // -----------------------------------------------------------------------------
       
  1726 //
       
  1727 void CNotepadListDialog::HandleMarkListDynInitMenuPane( TInt aResourceId, CEikMenuPane *aMenu, CEikListBox *aListBox )
       
  1728 	{
       
  1729 	if ( aResourceId == R_MENUPANE_MARKABLE_LIST_IMPLEMENTATION )
       
  1730 		{
       
  1731 		TInt currentItemIndex = aListBox->View()->CurrentItemIndex();
       
  1732 		TBool markHidden = aListBox->View()->ItemIsSelected( currentItemIndex ) || currentItemIndex == 0;
       
  1733 		TBool unmarkHidden =
       
  1734 				!aListBox->View()->ItemIsSelected(currentItemIndex) || currentItemIndex == 0;
       
  1735 		TBool markAllHidden = aListBox->Model()->NumberOfItems() == 0
       
  1736 				|| aListBox->SelectionIndexes()->Count()
       
  1737 						== aListBox->Model()->NumberOfItems() - 1;
       
  1738 		TBool unmarkAllHidden = aListBox->Model()->NumberOfItems() == 0
       
  1739 				|| aListBox->SelectionIndexes()->Count() == 0;
       
  1740 		aMenu->SetItemDimmed(EAknCmdMark, markHidden);
       
  1741 		aMenu->SetItemDimmed(EAknCmdUnmark, unmarkHidden);
       
  1742 		aMenu->SetItemDimmed(EAknMarkAll, markAllHidden);
       
  1743 		aMenu->SetItemDimmed(EAknUnmarkAll, unmarkAllHidden);		
       
  1744 		}
       
  1745 	if ( aResourceId == R_MENUPANE_MARKABLE_LIST_EDIT_LIST_IMPLEMENTATION )
       
  1746 		{
       
  1747 		TBool editListHidden = aListBox->Model()->NumberOfItems() == 0;
       
  1748 
       
  1749 		aMenu->SetItemDimmed(EAknCmdEditListMenu, editListHidden);
       
  1750 		}
       
  1751 	}
  1675 // End of File  
  1752 // End of File  
  1676 
  1753 
  1677 
  1754