shoppinglist code
Login to reply to this topic.
Tue, 2006-03-14 21:06
Joined: 2006-03-14
Forum posts: 2
Hi,guys i need your help.I need to enter a box for insert number in the quantity bar (case EShoppingListQuantity:) for my shopping list application.I want it to display after the name of the food.Thx Grin

CShoppingListAppUi::HandleCommandL()
// ---------------------------------------------------------
//
void CShoppingListAppUi::HandleCommandL( TInt aCommand )
    {
    TInt selectedItemIndex = 0;
    CShoppingItem* item;

    switch( aCommand )
        {
        case EEikCmdExit:
        case EAknSoftkeyExit:
            TRAPD( Err, SaveL() );  // Ignore any errors
                        Exit();
            break;

        case EShoppingListNewItem:
            {
            if( GetDocument()->ItemCount() > 0 )
                    {
                    selectedItemIndex = iAppView->CurrentItemIndex();
                    }
            item = CShoppingItem::NewLC();

            item->SetNameL( KNewitem().AllocL() );

            GetDocument()->InsertItemL( item, selectedItemIndex );
            CleanupStack::Pop( item );
            HandleModelChangeL();

            TBuf<KTextBufferLength> name;
            CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL( name );
            if ( dlg->ExecuteLD( R_DIALOG_TEXT_ITEM_NAME ) )
                {
                GetDocument()->Item( iAppView->CurrentItemIndex() )->
                                SetNameL( name.AllocL() );
                }
            HandleModelChangeL();
            break;
        }

        case EShoppingListMarkUnmark:
            if( GetDocument()->ItemCount() > 0 )
                    {
                    item = GetDocument()->Item( iAppView->CurrentItemIndex() );
                    item->SetFlags( item->Flags() ^ CShoppingItem::EMarked );
                    HandleModelChangeL();
                    }
            break;
           
         case EShoppingListQuantity:
            if( GetDocument()->ItemCount() > 0 )
                    {
                    item = GetDocument()->Item( iAppView->CurrentItemIndex() );
                    HuhHuhHuhHuhHuhHuhHuhHuhHuhHuhHuhHuhHuhHuhHuh??
                    }
            break;
           

        case EShoppingListRemove:
            if( GetDocument()->ItemCount() > 0 )
                {
                selectedItemIndex = iAppView->CurrentItemIndex();
                GetDocument()->RemoveItem( selectedItemIndex );
                TInt count = GetDocument()->ItemCount();
                if( count > 0 && iAppView->CurrentItemIndex() == count )
                    {
                    iAppView->SetCurrentItemIndex( iAppView->CurrentItemIndex() - 1 );
                    }
                HandleModelChangeL();
                }
            break;
         
        default:
            Panic( EShoppingListUi );
            break;
        }
    }

copyright 2003-2009 NewLC SARL