×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Apr 2007
    Location
    Netherlands
    Posts
    115

    Generated code issues

    Although the UI designer is really helpful for getting to a working interface quickly, I found that the generated code blocks quite often limit the developer.

    Some examples:

    - I needed to change the list items of a CAknEnumeratedTextPopupSettingItem during runtime. An easy solution is to derive a custom control from this, and override its CompleteConstructL method where the list items can be changed. However, this does not nicely fit into the UI designer, and requires the developer to manually insert/manage/handle his own custom control outside the various generated code blocks.

    - When creating a list query dialog (CAknListQueryDialog), the following code is generated:
    Code:
    TInt CMyContainerView::RunListQueryL( 
    		const TDesC* aOverrideText,
    		CDesCArray* aOverrideItemArray,
    		CArrayPtr< CGulIcon >* aOverrideIconArray )
    	{
    	TInt index;
    	CAknListQueryDialog* queryDialog = new (ELeave) CAknListQueryDialog( &index );	
    	CleanupStack::PushL( queryDialog );
    	
    	queryDialog->PrepareLC( R_MY_CLIENT_CONTAINER_LIST_QUERY );
    	if ( aOverrideText != NULL )
    		queryDialog->SetPromptL( *aOverrideText );
    	
    	(...)
    
    	}
    Very nice, but the aOverrideText parameter is used in a call to SetPromptL which has zero effect on a list query dialog. Instead it should use SetHeaderTextL, so right now I manually change this in the generated code each time I save the UI design. And this feels dirty...

    What do others think about this? And how do you solve this?
    Also I was wondering: is there a way to change the code that will be generated, perhaps by editing a textfile in the Carbide directory?
    Last edited by dracula78; 2007-04-21 at 14:51.

  2. #2
    Regular Contributor
    Join Date
    Jun 2004
    Posts
    55

    Re: Generated code issues

    Hi,

    Thanks very much for this report -- we're very interested in comments and suggestions on the generated source code.

    On the first issue, there is no support yet for directly specifying a different class to use. You can customize the generated source code in a way that your change is not overridden, though. It sounded like you knew that though. Could you elaborate on the problem with that, i.e. what that isn't satisfactory? Were you looking for a solution that didn't require you to insert your own code, are too many changes to the code required, or something else?

    We are looking at a couple of additions in the next major release after 1.2, perhaps you have an opinion? The first is allowing you to specify the name of an alternative C++ class for a control, which is presumably of subclass of the C++ class the generated code would use. This would be limited to cases where the subclass is API and RSS- compatible as the generated code can't handle anything else.

    The second approach is to provide documentation for you to provide your own UI designer components. While it's much more flexible it's also more work.

    On the second issue, I reproduced the bug and confirmed your change. I'll log this as a bug. Thank you.

    On your last item, here's how to fix this locally, until we provide an update with a fix.
    1) Locate your Carbide.c++ installation, open the 'plugins' folder, and then locate the 'com.nokia.sdt.series60.componentlibrary...' folder. There will some version numbering at the end depending on your Carbide version.

    2) Open this folder and locate the file:
    \components\listbox\CAknListMultiQueryDialog.component

    3) Open the file in any text editor (it's XML) and search for SetPromptL. There's only one match in the file. Change it to SetHeaderTextL. Save and restart Carbide.

    I'm sorry about the bug, but thanks again for the report and other feedback.

    Dan Podwall
    Nokia

  3. #3
    Regular Contributor
    Join Date
    Apr 2007
    Location
    Netherlands
    Posts
    115

    Re: Generated code issues

    Thanks for the quick and useful reply! Your fix worked when I changed the file CAknListQueryDialog.component, perfect

    I currently use a regular enumerated text setting item, created and managed by the UI designer; from within LoadSettingValuesL(), which is called during activation of the setting list, I call my own function that sets the items by changing the contents of EnumeratedTextArray() and PoppedUpTextArray():
    Code:
    void CMySettingItemList::LoadItemDataL()
    {
    	// The items to be used are stored here:
    	// RPointerArray< TDes > MyItemNames;
    	// RArray< TInt > MyItemIds;
    
    	CAknSettingItemArray* itemArray = SettingItemArray();
    	
    	for (int i = 0; i < itemArray->Count(); i++) {    	
    		CAknSettingItem* item =	( *itemArray ) [ i ];
    		
    		switch ( item->Identifier() ) {
    		case EMySettingItemListViewSet_Profile:
    
    			CAknEnumeratedTextPopupSettingItem* enumList =
    				STATIC_CAST(CAknEnumeratedTextPopupSettingItem*, item);	
    				
    			CArrayPtr< CAknEnumeratedText >* aEnumeratedTextArray = enumList->EnumeratedTextArray();
    				
    			CArrayPtr< HBufC >* aPopupTextArray = enumList->PoppedUpTextArray();
    
    			aEnumeratedTextArray->Reset();
    			aPopupTextArray->Reset();
    
    			for (TInt i = 0; i < MyItemNames.Count(); i++ ) {
    				HBufC* buf = MyItemNames[i]->AllocL();
    				
    				CAknEnumeratedText* enumItem = new (ELeave) CAknEnumeratedText(MyItemIds[i], buf );
    			
    				aEnumeratedTextArray->AppendL( enumItem, 1 );
    				aPopupTextArray->AppendL( buf, 1 );
    			}
    		
    			enumList->HandleTextArrayUpdateL();
    			enumList->UpdateListBoxTextL();
    			
    		default:
    			break;
    		}
    	}
    }
    This seems to work fine, but I still have an unexplainable application crash during the destruction of the setting list (upon deactivation), unless I use a destructor similar to the function above, only to reset the EnumeratedTextArray() and PoppedUpTextArray()...

    In general, I think the UI designer is ideal for static controls that can be entirely created and specified during design-time. But it can be quite troublesome to find out how exactly controls can be changed during run-time, i.e. where you are supposed to insert code among all the [[ generated code ]] tags.
    Last edited by dracula78; 2007-04-23 at 08:40.

  4. #4
    Regular Contributor
    Join Date
    Apr 2007
    Location
    Netherlands
    Posts
    115

    Re: Generated code issues

    Another issue with generated code is the fixed naming of items: one time I had created a view in the UI designer, for which the wizard provided some defaults, so it ended up being named like "AppNameContainerView"...

    Later, the project had grown, and I had added some more views, and I realized that "...ContainerView" was not a proper name for the first view. I tried to change this name, but this was a mission impossible. I do realize that at the moment the wizard finishes, several files and related classes and constants are created. But this way it takes valuable time to either (1) manually dig through all source files and replace the name, or (2) recreate the view and its contents from scratch.

    Is there any way to rename a view, with code refactoring?

  5. #5
    Regular Contributor
    Join Date
    Apr 2007
    Location
    Netherlands
    Posts
    115

    Re: Generated code issues

    On your last item, here's how to fix this locally, until we provide an update with a fix.
    Btw, this fix didn't make it into Carbide.c++ 1.2 build 29 ?

    Both in CAknListMultiQueryDialog.component and in CAknListQueryDialog.component it says SetPromptL instead of SetHeaderTextL.

  6. #6
    Regular Contributor
    Join Date
    Jun 2004
    Posts
    55

    Re: Generated code issues

    No, your report came in after we had gone final with build 29. But I did make the fix in our source base, so it will be fixed in subsequent releases.

    Dan Podwall
    Nokia

Similar Threads

  1. how to retrieve security code for Nokia 6310i
    By rajeev238 in forum General Development Questions
    Replies: 3
    Last Post: 2006-12-06, 14:25
  2. UI Designer generated error in his code
    By andipro in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 4
    Last Post: 2006-11-16, 21:00
  3. Security code bug on 6230!
    By dabII in forum General Development Questions
    Replies: 1
    Last Post: 2005-05-17, 17:21
  4. Why is client code to CSocketEngine hanging at Access Point dialogue?
    By nawkboy in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2003-03-11, 11:16
  5. Replies: 0
    Last Post: 2003-02-24, 04:00

Posting Permissions

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