×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Super Contributor
    Join Date
    Jul 2006
    Location
    Oulu, Finland.
    Posts
    1,174

    List Box Updation

    hi all,

    I have created a list box in my container, now what i want is to update ( add or remove) the items from the list box on command from Appui,

    Please ignore the code of label it already handled and working...

    Here is my code for Container..
    *********************************************************
    void CIMSI_testContainer::ConstructL(const TRect& aRect,bool showlist)
    {

    CreateWindowL();
    Expired = showlist;
    if(Expired)
    {
    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL( _L("") );

    iToDoLabel = new (ELeave) CEikLabel;
    iToDoLabel->SetContainerWindowL( *this );
    iToDoLabel->SetTextL( _L("") );

    }
    else
    {
    //iItemList = new (ELeave) CAknSettingItemList;
    iItemList = new (ELeave) CAknSingleStyleListBox();

    iItemList->SetContainerWindowL(*this);
    iItemList->SetMopParent(this);
    //EAknListBoxSelectionList();
    //iItemList->ConstructFromResourceL(R_ENTRY_SETTINGS_LIST);
    iItemList->ConstructL(this,EAknListBoxSelectionList);

    LoadListL();

    iItemList->MakeVisible(true);
    iItemList->SetRect(aRect);
    iItemList->ActivateL();

    iItemList->DrawNow();

    }

    // Set the windows size
    SetRect(aRect);

    // Activate the window, which makes it ready to be drawn
    ActivateL();

    }

    // Destructor
    CIMSI_testContainer::~CIMSI_testContainer()
    {
    if(Expired)
    {
    delete iLabel;
    delete iToDoLabel;
    }
    else
    delete iItemList;


    }

    // ---------------------------------------------------------
    // CIMSI_testContainer::SizeChanged()
    // Called by framework when the view size is changed
    // ---------------------------------------------------------
    //
    void CIMSI_testContainer::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    if(Expired)
    {
    iLabel->SetExtent( TPoint(10,10), iLabel->MinimumSize() );
    iToDoLabel->SetExtent( TPoint(10,100), iToDoLabel->MinimumSize() );
    }
    else
    {
    // if not include this line then the list box is shown awkward.
    iItemList->SetRect( Rect() ); // vasant :Sets rectangle of listbox.
    }
    }

    // ---------------------------------------------------------
    // CIMSI_testContainer::CountComponentControls() const
    // ---------------------------------------------------------
    //
    TInt CIMSI_testContainer::CountComponentControls() const
    {
    // return 2; // return nbr of controls inside this container
    if(Expired)
    {
    return 2; // return nbr of controls inside this container
    }
    else
    {
    TInt count = 0;
    if (iItemList)
    count++;
    return count;
    }
    }

    // ---------------------------------------------------------
    // CIMSI_testContainer::ComponentControl(TInt aIndex) const
    // ---------------------------------------------------------
    //
    CCoeControl* CIMSI_testContainer::ComponentControl(TInt aIndex) const
    {
    if(Expired)
    {
    switch ( aIndex )
    {
    case 0:
    return iLabel;
    case 1:
    return iToDoLabel;
    default:
    return NULL;
    }
    }
    else
    return iItemList;
    }



    // ---------------------------------------------------------
    // CIMSI_testContainer::Draw(const TRect& aRect) const
    // ---------------------------------------------------------
    //
    void CIMSI_testContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...

    if (Expired)
    {
    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( KRgbGray );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );

    gc.Clear( Rect() );
    const CFont* font = LatinBold12();
    gc.UseFont( font );

    gc.DrawText( _L("Trail Expired"), TPoint( 10,20 ) );
    gc.DrawText( _L("Please Register"), TPoint( 10,40 ) );
    }
    else
    {
    TRect rect = Rect();

    // Clears the screen
    gc.Clear(rect);

    }
    }

    // ---------------------------------------------------------
    // CIMSI_testContainer::HandleControlEventL(
    // CCoeControl* aControl,TCoeEvent aEventType)
    // ---------------------------------------------------------
    //
    void CIMSI_testContainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    // TODO: Add your control event handler code here
    }




    void CIMSI_testContainer::LoadListL()
    {

    RFs aFs;
    RFile file;
    aFs.Connect();
    //TBuf8<200> Temp8;
    TBuf8<20> IMSIno;
    TBuf16<30> Temp16;
    TBuf16<20> TempC16;
    array = new (ELeave) CDesCArrayFlat(11);
    TInt cnt=0,i=0;
    TInt iErr = file.Open(aFs,KIMSIFile,EFileRead);

    if(iErr == KErrNone)
    {
    file.Read(Temp8);


    _LIT8(CR,"|");

    TInt index = 0;
    array->AppendL(_L("\t- White SIM List -"));
    while(Temp8.Length() > 14)
    {
    TInt index = Temp8.Find(CR);
    if(index > 0)
    {
    IMSIno.Copy(Temp8.Mid(0,index ));
    Temp8.Delete(0,Temp8.Find(CR)+1);
    TempC16.Copy(IMSIno);
    //Temp16.Format(_L("%d\t%S"),++cnt,&TempC16);
    Temp16.Format(_L("\t%S"),&TempC16);
    array->AppendL(Temp16);
    }
    else
    break;

    }
    //iItemList->Model()->SetItemTextArray(array);
    }
    else
    {
    array->AppendL(_L("\t- No White SIM -"));
    }
    iItemList->Model()->SetItemTextArray(array);
    file.Close();
    aFs.Close();

    }

    // ----------------------------------------------------
    // CDynamicSettingListAppView::StoreSettingsL()
    // Stores the settings of the setting list.
    // ----------------------------------------------------
    //
    void CIMSI_testContainer::StoreSettingsL()
    {
    /* iItemList->StoreSettingsL();*/
    }

    // vasant : added explicitly for scrolling facility.

    TKeyResponse CIMSI_testContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
    TEventCode aType )
    {
    if(aType != EEventKey)
    {
    return EKeyWasNotConsumed;
    }
    else if(iItemList)
    {
    return iItemList->OfferKeyEventL( aKeyEvent, aType );
    }
    else
    {
    return EKeyWasNotConsumed;
    }

    }
    *********************************************************

    so what i want is that when a user presses AddItem command i should be able to add the item and display in the list box , i am not able to find any good example, the example given in the sdk is far more complicated and confusing.

    Thanks waiting for replies.
    -vasant

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: List Box Updation

    Use iItemList->HandleItemAdditionL().

    And a remark: never use conditional deletes in a destructor.

  3. #3
    Super Contributor
    Join Date
    Jul 2006
    Location
    Oulu, Finland.
    Posts
    1,174

    Re: List Box Updation

    hi wizardhu,

    thanks for reply,
    i have already tried with >HandleItemAdditionL();
    but it gives applciation closed kern 3 error , when i access this method in my appui.

    iAppContainer->array->AppendL(_L("\tvasant"));
    iAppContainer->iItemList->Model()->SetItemTextArray(iAppContainer->array);
    iAppContainer->iItemList->HandleItemAdditionL();
    iAppContainer->DrawNow();

    After executing this it gives error
    Thanks and waiting.
    vasant

  4. #4
    Super Contributor
    Join Date
    Jul 2006
    Location
    Oulu, Finland.
    Posts
    1,174

    Re: List Box Updation

    hi ,

    I found the problem,

    MDesCArray* textArray = iAppContainer->iItemList->Model()->ItemTextArray();
    CDesCArray* itemList = static_cast<CDesCArray*>(textArray);
    // construct new item, build
    _LIT(KNewItem, "New item..");
    TBuf<32> item;
    item.Format(_L("\t%S\t\t"), &KNewItem);
    // append new item to the listbox
    itemList->AppendL(item);
    // update listbox
    iAppContainer->iItemList->HandleItemAdditionL();

    This code works perfectly...)
    Acually i was not fetching the list box array properly.


    Thanks for the support.
    -vasant

Similar Threads

  1. 6680 and bluetooth service profiles
    By ceruault in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2005-10-08, 22:24
  2. list box with find box - Series 60
    By white_dragon in forum Symbian
    Replies: 3
    Last Post: 2004-08-16, 09:52
  3. Replies: 1
    Last Post: 2004-03-01, 08:37
  4. Please Solve my problem with List Box
    By Nilesh_Kul in forum Symbian User Interface
    Replies: 10
    Last Post: 2003-04-17, 23:13
  5. List Box control on series -60
    By Nokia_Archive in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2002-05-30, 21:03

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×