idlehomescreen/xmluirendering/uiengine/src/xnlistquerydialogadapter.cpp
branchRCL_3
changeset 11 ff572dfe6d86
parent 2 08c6ee43b396
child 26 1b758917cafc
equal deleted inserted replaced
9:f966699dea19 11:ff572dfe6d86
    33 #include "xndomdocument.h"
    33 #include "xndomdocument.h"
    34 #include "xndomnode.h"
    34 #include "xndomnode.h"
    35 #include "xndomlist.h"
    35 #include "xndomlist.h"
    36 #include "xndomattribute.h"
    36 #include "xndomattribute.h"
    37 
    37 
       
    38 
    38 // ======== LOCAL FUNCTIONS ========
    39 // ======== LOCAL FUNCTIONS ========
       
    40 
    39 // ---------------------------------------------------------------------------
    41 // ---------------------------------------------------------------------------
    40 // Finds recursively node by type
    42 // Finds recursively node by type
    41 // @return    returns pointer to desired node, NULL if nothing found 
    43 // @return    returns pointer to desired node, NULL if nothing found 
    42 // ---------------------------------------------------------------------------
    44 // ---------------------------------------------------------------------------
    43 //
    45 //
   223 // -----------------------------------------------------------------------------
   225 // -----------------------------------------------------------------------------
   224 // Replaces or appends item into list
   226 // Replaces or appends item into list
   225 // -----------------------------------------------------------------------------
   227 // -----------------------------------------------------------------------------
   226 // 
   228 // 
   227 void CXnListQueryDialogAdapter::ReplaceItemL(const TDesC& aText, TInt aIndex )
   229 void CXnListQueryDialogAdapter::ReplaceItemL(const TDesC& aText, TInt aIndex )
   228     {
   230     {    
       
   231     if ( iDialog )
       
   232         {
       
   233         iDialog->DismissQueryL();        
       
   234         }    
       
   235 
       
   236     iDialog = NULL;
       
   237     
   229     aIndex += iStaticItems.Count();
   238     aIndex += iStaticItems.Count();
   230     TInt count( iItemArray->Count());
   239     TInt count( iItemArray->Count());
       
   240     
   231     if( aIndex >= count )
   241     if( aIndex >= count )
   232         {
   242         {
   233         iItemArray->AppendL( aText );
   243         iItemArray->AppendL( aText );
   234         }
   244         }
   235     else
   245     else
   236         {
   246         {
   237         iItemArray->Delete( aIndex );
   247         iItemArray->Delete( aIndex );
   238         iItemArray->InsertL( aIndex, aText );
   248         iItemArray->InsertL( aIndex, aText );
   239         }
   249         }    
   240     }
   250     }
   241 
   251 
   242 // -----------------------------------------------------------------------------
   252 // -----------------------------------------------------------------------------
   243 // Inserts or appends item into list
   253 // Inserts or appends item into list
   244 // -----------------------------------------------------------------------------
   254 // -----------------------------------------------------------------------------
   245 // 
   255 // 
   246 void CXnListQueryDialogAdapter::InsertItemL(const TDesC& aText, TInt aIndex )
   256 void CXnListQueryDialogAdapter::InsertItemL(const TDesC& aText, TInt aIndex )
   247     {
   257     {    
       
   258     if ( iDialog )
       
   259         {
       
   260         iDialog->DismissQueryL();
       
   261         }    
       
   262     
       
   263     iDialog = NULL;
       
   264     
   248     aIndex += iStaticItems.Count();
   265     aIndex += iStaticItems.Count();
   249     TInt count( iItemArray->Count());
   266     TInt count( iItemArray->Count());
       
   267     
   250     if( count < aIndex )
   268     if( count < aIndex )
   251         {
   269         {
   252         aIndex = count;
   270         aIndex = count;
   253         }
   271         }
       
   272     
   254     iItemArray->InsertL( aIndex, aText );
   273     iItemArray->InsertL( aIndex, aText );
   255     }
   274     }
   256 
   275 
   257 // -----------------------------------------------------------------------------
   276 // -----------------------------------------------------------------------------
   258 // Deletes item from the list
   277 // Deletes item from the list
   259 // -----------------------------------------------------------------------------
   278 // -----------------------------------------------------------------------------
   260 // 
   279 // 
   261 void CXnListQueryDialogAdapter::DeleteItem( TInt aIndex )
   280 void CXnListQueryDialogAdapter::DeleteItem( TInt aIndex )
   262     {
   281     {
       
   282     if ( iDialog )
       
   283         {
       
   284         TRAP_IGNORE( iDialog->DismissQueryL() );
       
   285         }
       
   286     
       
   287     iDialog = NULL;
       
   288     
   263     aIndex += iStaticItems.Count();
   289     aIndex += iStaticItems.Count();
       
   290     
   264     if( aIndex < iItemArray->Count())
   291     if( aIndex < iItemArray->Count())
   265         {
   292         {
   266         iItemArray->Delete( aIndex );
   293         iItemArray->Delete( aIndex );
   267         }    
   294         }       
   268     }
   295     }
   269 
   296 
   270 // -----------------------------------------------------------------------------
   297 // -----------------------------------------------------------------------------
   271 // Displays the list query dialog
   298 // Displays the list query dialog
   272 // -----------------------------------------------------------------------------
   299 // -----------------------------------------------------------------------------
   273 //
   300 //
   274 void CXnListQueryDialogAdapter::TryDisplayingDialogL( )
   301 void CXnListQueryDialogAdapter::TryDisplayingDialogL( )
   275     {
   302     {
       
   303     if ( iDialog )
       
   304         {
       
   305         iDialog->DismissQueryL();
       
   306         }
       
   307     
       
   308     iDialog = NULL;
       
   309     
   276     CXnAppUiAdapter& appui( static_cast< CXnAppUiAdapter& >( *iAvkonAppUi ) );
   310     CXnAppUiAdapter& appui( static_cast< CXnAppUiAdapter& >( *iAvkonAppUi ) );
   277     
   311     
   278     appui.HideFocus();
   312     appui.HideFocus();
   279     
   313     
   280     TInt selectedIndex( 0 );
   314     TInt selectedIndex( 0 );
   281     
   315     
   282     CAknListQueryDialog* query =
   316     CAknListQueryDialog* dialog =
   283        new ( ELeave ) CAknListQueryDialog( &selectedIndex );
   317        new ( ELeave ) CAknListQueryDialog( &selectedIndex );                 
   284 
   318     dialog->PrepareLC( R_XML_LISTQUERY );
   285     query->PrepareLC( R_XML_LISTQUERY );
   319     
   286 /* Not tested
   320 /* Not tested
   287     CAknPopupHeadingPane* heading( query->QueryHeading() );
   321     CAknPopupHeadingPane* heading( query->QueryHeading() );
   288     if ( heading )
   322     if ( heading )
   289         {
   323         {
   290         CXnProperty* prop( iNode.GetPropertyL(
   324         CXnProperty* prop( iNode.GetPropertyL(
   301             {
   335             {
   302             heading->SetTextL( KNullDesC() );
   336             heading->SetTextL( KNullDesC() );
   303             }
   337             }
   304         }
   338         }
   305 */
   339 */
   306     query->SetItemTextArray( iItemArray );
   340     dialog->SetItemTextArray( iItemArray );
   307     query->SetOwnershipType( ELbmDoesNotOwnItemArray );
   341     dialog->SetOwnershipType( ELbmDoesNotOwnItemArray );
   308 
   342     
   309     if ( query->RunLD() )
   343     iDialog = dialog;
       
   344     
       
   345     if ( dialog->RunLD() )
   310         {
   346         {
   311         ActivateItemL( selectedIndex );
   347         ActivateItemL( selectedIndex );
   312         }
   348         }            
       
   349            
       
   350     iDialog = NULL;
   313     }
   351     }
   314 
   352 
   315 // -----------------------------------------------------------------------------
   353 // -----------------------------------------------------------------------------
   316 // Runs the activate event for the item node 
   354 // Runs the activate event for the item node 
   317 // -----------------------------------------------------------------------------
   355 // -----------------------------------------------------------------------------
   344     CXnDomNode* eventNode = FindNodeByType( iDynamicItem->Node().DomNode(), XnPropertyNames::action::KEvent );
   382     CXnDomNode* eventNode = FindNodeByType( iDynamicItem->Node().DomNode(), XnPropertyNames::action::KEvent );
   345 
   383 
   346     CXnDomAttribute* attribute = static_cast<CXnDomAttribute*> 
   384     CXnDomAttribute* attribute = static_cast<CXnDomAttribute*> 
   347         (eventNode->AttributeList().FindByName( XnPropertyNames::action::event::KName ));
   385         (eventNode->AttributeList().FindByName( XnPropertyNames::action::event::KName ));
   348     
   386     
       
   387     if ( !attribute )
       
   388         {
       
   389         return;
       
   390         }
       
   391     
   349     HBufC8* nameStr( attribute->Value().AllocLC());
   392     HBufC8* nameStr( attribute->Value().AllocLC());
   350     TPtr8 namePtr = nameStr->Des();
   393     TPtr8 namePtr = nameStr->Des();
   351     
   394     
   352     TInt startIndex = namePtr.Locate( '(' );
   395     TInt startIndex = namePtr.Locate( '(' );
   353     TInt endIndex = namePtr.Locate( ')' );
   396     TInt endIndex = namePtr.Locate( ')' );