notepad/notepad1/LibSrc/NpdListDialog.cpp
branchRCL_3
changeset 16 55d60436f00b
parent 15 9711e452b5e9
child 18 d68a4b5d5885
equal deleted inserted replaced
15:9711e452b5e9 16:55d60436f00b
    62 // Next is for KNotepadPseudoKeyIdForNewNote
    62 // Next is for KNotepadPseudoKeyIdForNewNote
    63 //
    63 //
    64 #include "NpdApi.h"
    64 #include "NpdApi.h"
    65 #include "NpdLibPanic.h"
    65 #include "NpdLibPanic.h"
    66 
    66 
       
    67 //number of fixed item
       
    68 //currently, Notepad application have one fixed "New Note" item in main view. 
       
    69 const TInt KNumberOfFixedItem = 1; 
    67 
    70 
    68 // ============================ MEMBER FUNCTIONS ===============================
    71 // ============================ MEMBER FUNCTIONS ===============================
    69 
    72 
    70 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    71 // CNotepadListDialog::NewL
    74 // CNotepadListDialog::NewL
   870 		{
   873 		{
   871 		return;
   874 		return;
   872 		}
   875 		}
   873     iModel->SyncL(EFalse);
   876     iModel->SyncL(EFalse);
   874     CNotepadDialogBase::DynInitMenuPaneL( aResourceId, aMenuPane );
   877     CNotepadDialogBase::DynInitMenuPaneL( aResourceId, aMenuPane );
   875     const TInt memoCount( iModel->MdcaCount() - 1 );
   878     const TInt memoCount( iModel->MdcaCount() - KNumberOfFixedItem );
   876    	const TInt markCount(iListBox->SelectionIndexes()->Count());
   879    	const TInt markCount(iListBox->SelectionIndexes()->Count());
   877 	TInt index;
   880 	TInt index;
   878 	switch (aResourceId )
   881 	switch (aResourceId )
   879         {
   882         {
   880         case R_SENDUI_MENU:
   883         case R_SENDUI_MENU:
  1724 // CNotepadListDialog::HandleMarkListDynInitMenuPane
  1727 // CNotepadListDialog::HandleMarkListDynInitMenuPane
  1725 // -----------------------------------------------------------------------------
  1728 // -----------------------------------------------------------------------------
  1726 //
  1729 //
  1727 void CNotepadListDialog::HandleMarkListDynInitMenuPane( TInt aResourceId, CEikMenuPane *aMenu, CEikListBox *aListBox )
  1730 void CNotepadListDialog::HandleMarkListDynInitMenuPane( TInt aResourceId, CEikMenuPane *aMenu, CEikListBox *aListBox )
  1728 	{
  1731 	{
       
  1732     TInt numofNotes = aListBox->Model()->NumberOfItems() - KNumberOfFixedItem;
       
  1733     
  1729 	if ( aResourceId == R_MENUPANE_MARKABLE_LIST_IMPLEMENTATION )
  1734 	if ( aResourceId == R_MENUPANE_MARKABLE_LIST_IMPLEMENTATION )
  1730 		{
  1735 		{
  1731 		TInt currentItemIndex = aListBox->View()->CurrentItemIndex();
  1736 		TInt currentItemIndex = aListBox->View()->CurrentItemIndex();
  1732 		TBool markHidden = aListBox->View()->ItemIsSelected( currentItemIndex ) || currentItemIndex == 0;
  1737 		TBool markHidden = aListBox->View()->ItemIsSelected( currentItemIndex ) || currentItemIndex == 0;
  1733 		TBool unmarkHidden =
  1738 		TBool unmarkHidden =
  1734 				!aListBox->View()->ItemIsSelected(currentItemIndex) || currentItemIndex == 0;
  1739 				!aListBox->View()->ItemIsSelected(currentItemIndex) || currentItemIndex == 0;
  1735 		TBool markAllHidden = aListBox->Model()->NumberOfItems() == 0
  1740 		TBool markAllHidden = ( numofNotes == 0 ) || ( aListBox->SelectionIndexes()->Count() == numofNotes );
  1736 				|| aListBox->SelectionIndexes()->Count()
  1741 		TBool unmarkAllHidden = ( numofNotes == 0 ) || ( aListBox->SelectionIndexes()->Count() == 0 );
  1737 						== aListBox->Model()->NumberOfItems() - 1;
       
  1738 		TBool unmarkAllHidden = aListBox->Model()->NumberOfItems() == 0
       
  1739 				|| aListBox->SelectionIndexes()->Count() == 0;
       
  1740 		aMenu->SetItemDimmed(EAknCmdMark, markHidden);
  1742 		aMenu->SetItemDimmed(EAknCmdMark, markHidden);
  1741 		aMenu->SetItemDimmed(EAknCmdUnmark, unmarkHidden);
  1743 		aMenu->SetItemDimmed(EAknCmdUnmark, unmarkHidden);
  1742 		aMenu->SetItemDimmed(EAknMarkAll, markAllHidden);
  1744 		aMenu->SetItemDimmed(EAknMarkAll, markAllHidden);
  1743 		aMenu->SetItemDimmed(EAknUnmarkAll, unmarkAllHidden);		
  1745 		aMenu->SetItemDimmed(EAknUnmarkAll, unmarkAllHidden);		
  1744 		}
  1746 		}
  1745 	if ( aResourceId == R_MENUPANE_MARKABLE_LIST_EDIT_LIST_IMPLEMENTATION )
  1747 	if ( aResourceId == R_MENUPANE_MARKABLE_LIST_EDIT_LIST_IMPLEMENTATION )
  1746 		{
  1748 		{
  1747 		TBool editListHidden = aListBox->Model()->NumberOfItems() == 0;
  1749 		TBool editListHidden = numofNotes == 0;
  1748 
  1750 
  1749 		aMenu->SetItemDimmed(EAknCmdEditListMenu, editListHidden);
  1751 		aMenu->SetItemDimmed(EAknCmdEditListMenu, editListHidden);
  1750 		}
  1752 		}
  1751 	}
  1753 	}
  1752 // End of File  
  1754 // End of File