// -----------------------------------------------------------------------------
// CTestSDKQueries::TestLqdlgListBoxL
// -----------------------------------------------------------------------------
//
TInt CTestSDKQueries::TestLqdlgListBoxL( CStifItemParser& /*aItem*/ )
    {
    TInt selectedOption( KZero );
    
    CDesCArrayFlat* mArray = new (ELeave) CDesCArrayFlat( KTen );
    CleanupStack::PushL( mArray );
     
    TBuf< KTen > palabra;
    for (TInt num = KZero; num< KTen; num++)
        {
       palabra.Format(_L("option %d"), num);
       mArray->AppendL(palabra);
        }
    
    CAknListQueryDialog* dlg = new( ELeave ) CAknListQueryDialog( &selectedOption );
    dlg->PrepareLC( R_UPDATE_QUERY_DIALOG );
    dlg->SetItemTextArray( mArray );
    dlg->SetOwnershipType( ELbmDoesNotOwnItemArray );
    
    CEikListBox* listBox = dlg->ListBox();
    STIF_ASSERT_NOT_NULL( listBox );
    
    CleanupStack::PopAndDestroy( dlg );
    CleanupStack::PopAndDestroy( mArray );
    return KErrNone;
    }
Exemplo n.º 2
0
void CStarDictAppUi::ShowDictionaryListL()
{
	TDesC *name, *path;
	TBuf<KDataBaseNameSizeMax> str;

	CDesCArray *itemTextArray = new (ELeave) CDesCArrayFlat(16);
	CleanupStack::PushL(itemTextArray);

	for(TInt i=0; i<iDictFactory->GetDataBaseCount(); i++)
	{
		name = path = NULL;
		if (iDictFactory->GetDataBaseName(i, &name, &path) && name)
		{
			str.Copy(*name);
		}
		else
		{
			TBuf<100> resourceString;
			CEikonEnv::Static()->ReadResource(resourceString,
											  R_CORRUPT_STRING);
			str.Copy(resourceString);
		}

		itemTextArray->AppendL(str);
	}

	TInt itemSelected(0), prevSelection;
	CAknListQueryDialog* listQuery = new (ELeave) CAknListQueryDialog(&itemSelected);
	listQuery->PrepareLC(R_DICTIONARY_LIST_DIALOG);
	listQuery->SetItemTextArray(itemTextArray);
	listQuery->SetOwnershipType(ELbmDoesNotOwnItemArray);

	prevSelection = iDictFactory->GetCurrentDataBase();
	if (prevSelection >= 0 && prevSelection < itemTextArray->Count())
	{
		listQuery->ListBox()->SetCurrentItemIndex(prevSelection);
	}
	if(listQuery->RunLD())
	{
		iDictFactory->SetCurrentDataBase(itemSelected);
		iStarDictContainerView->SetDictionaryName((*itemTextArray)[itemSelected]);
		iStarDictContainerView->UpdateListBox();
	}
	CleanupStack::PopAndDestroy();
}