menufw/hierarchynavigator/hnmetadatamodel/inc/hnmditem.h
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_HNMDITEM_H
       
    21 #define C_HNMDITEM_H
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 #include "hnmdmodel.h"
       
    26 #include "hnmdeventmapping.h"
       
    27 #include "hnqueryresultcollector.h"
       
    28 
       
    29 class CHnMdQuery;
       
    30 class CHnMdButton;
       
    31 class CHnMdQueries;
       
    32 class CHnMdNotifyRequests;
       
    33 class CHnSuiteModel;
       
    34 class CLiwGenericParamList;
       
    35 class CLiwDefaultMap;
       
    36 class THnIdGenerator;
       
    37 class CHnFilter;
       
    38 class CHnMdUiMapping;
       
    39 class CHnMdMenuItem;
       
    40 class CHnItemId;
       
    41 class CHnMdSuite;
       
    42 class CHnXmlModelProvider;
       
    43 class CHnItemModel;
       
    44 class CHnMenuItemModel;
       
    45 class CHnActionModel;
       
    46 class CHnMdToolbar;
       
    47 struct THnMdCommonPointers;
       
    48 class CHnConditionInterface;
       
    49 
       
    50 /**
       
    51  * Item.
       
    52  *
       
    53  * This is the item's class. Each item (or items' group -
       
    54  * the count attribute has a value greater then 1) is represented
       
    55  * by an object of the CHnMdItem class.
       
    56  *
       
    57  * This class comprises different classes which are responsible for
       
    58  * conditions, queries, notifications (refreshing), etc.
       
    59  *
       
    60  * @lib hnmetadatamodel
       
    61  * @since S60 v5.0
       
    62  * @ingroup group_hnmetadatamodel
       
    63  */
       
    64 NONSHARABLE_CLASS(CHnMdItem) : public CBase,
       
    65     public MHnQueryResultCollectorNotification
       
    66     {
       
    67 public:
       
    68 
       
    69     /**
       
    70      * Standard factory method.
       
    71      *
       
    72      * since S60 v5.0
       
    73      * @param aElement Xml element.
       
    74      * @param aCmnPtrs Common pointers container.
       
    75      * @return Fully constructed object.
       
    76      */
       
    77     static CHnMdItem* NewL( TXmlEngElement aElement,
       
    78                                       THnMdCommonPointers* aCmnPtrs );
       
    79 
       
    80     /**
       
    81      * Standard factory method.
       
    82      *
       
    83      * since S60 v5.0
       
    84      * @param aElement Xml element.
       
    85      * @param aCmnPtrs Common pointers container.
       
    86      * @return Fully constructed object.
       
    87      */
       
    88     static CHnMdItem* NewLC( TXmlEngElement aElement,
       
    89                                        THnMdCommonPointers* aCmnPtrs );
       
    90 
       
    91     /**
       
    92      * Default destructor.
       
    93      */
       
    94     virtual ~CHnMdItem();
       
    95 
       
    96     /**
       
    97      * Updates an item.
       
    98      *
       
    99      * @param aGraphicalList A graphical list.
       
   100      * @param aId Item's identifier.
       
   101      * @param aResultMap A results map.
       
   102      * @return An error code.
       
   103      */
       
   104     void UpdateItemL( CHnSuiteModel* aGraphicalList, TInt aId,
       
   105             RHashMap< HBufC*, CLiwGenericParamList*>& aResultMap );
       
   106     /**
       
   107      * Compares entries.
       
   108      *
       
   109      * @param aSearchCriteria Search critieria item id.
       
   110      * @return True if this item matches aSearchCriteria.
       
   111      */
       
   112     TBool CompareItems( CHnItemId* aSearchCriteria );
       
   113 
       
   114     /**
       
   115      * Evaluates an item.
       
   116      *
       
   117      * @since S60 v3.2
       
   118      * @param aSuiteModel A suite's model.
       
   119      * @param aParamList Paramters of the evaluation.
       
   120      * @param aItemPosition A position of an item in the aParamList.
       
   121      */
       
   122     void EvaluateItemL( CHnSuiteModel & aSuiteModel,
       
   123                         CLiwGenericParamList& aParamList,
       
   124                         TInt aItemPosition );
       
   125 
       
   126     /**
       
   127      * Marks according to filter which item should be evaluated.
       
   128      *
       
   129      * @since S60 5.0
       
   130      * @param aFilter Filter.
       
   131      */
       
   132     void MarkEvaluationL( CHnFilter& aFilter );
       
   133 
       
   134     /**
       
   135      * Sets template.
       
   136      *
       
   137      * @param aOption Option - an identifier of alternative template bo be set.
       
   138      */
       
   139     void SetAlternativeTemplateL( TInt aOption );
       
   140 
       
   141     /**
       
   142      * Sets edit mode version of the item.
       
   143      *
       
   144      * @param aEditModeItem Edit mode item.
       
   145      * @return Meta data model of the edit mode version.
       
   146      */
       
   147     void SetAlternativeModeItem(CHnMdItem* aEditModeItem);
       
   148 
       
   149     /**
       
   150      * Sets edit mode version of the item.
       
   151      * Transfers ownership.
       
   152      *
       
   153      * @return Meta data model of the edit mode version.
       
   154      */
       
   155     CHnMdItem* TakeAlternativeModeItem();
       
   156 
       
   157      /**
       
   158       * Checks if mode version of the item is present.
       
   159       *
       
   160       * @return True if an item has an alternative model to be set.
       
   161       */
       
   162      TBool HasAlternativeModeItem() const;
       
   163 
       
   164      /**
       
   165       * Template property getter.
       
   166       *
       
   167       * @return The name of the template.
       
   168       */
       
   169      IMPORT_C TDesC8& Template();
       
   170 
       
   171      /**
       
   172       * Type property getter.
       
   173       *
       
   174       * @return Type of an item.
       
   175       */
       
   176      IMPORT_C TDesC8& Type();
       
   177      
       
   178      /**
       
   179       * Type property getter.
       
   180       *
       
   181       * @return Type of an item.
       
   182       */
       
   183      IMPORT_C TDesC8& Uid();
       
   184 
       
   185      // from queries collector
       
   186      /**
       
   187       * Triggered when results have been collected.
       
   188       *
       
   189       * @param aResults Results.
       
   190       */
       
   191      virtual void ResultsCollectedL( CLiwGenericParamList* aResults );
       
   192 
       
   193 private:
       
   194 
       
   195     /**
       
   196      * Sets edit mode item.
       
   197      *
       
   198      * @param aElement Xml element.
       
   199      */
       
   200     void SetEditModeItemL( TXmlEngElement aElement );
       
   201 
       
   202     /**
       
   203      * Sets count.
       
   204      *
       
   205      * @param aElement Xml element.
       
   206      */
       
   207     void SetCountL( TXmlEngElement aElement );
       
   208 
       
   209     /**
       
   210      * Sets template.
       
   211      *
       
   212      * @param aAttr Xml attribute.
       
   213      */
       
   214     void SetTemplateL( TXmlEngAttr aAttr );
       
   215 
       
   216     /**
       
   217      * Sets queries.
       
   218      *
       
   219      * @param aElement Xml element.
       
   220      */
       
   221     void SetQueriesL( TXmlEngElement aElement );
       
   222 
       
   223     /**
       
   224      * Sets item id.
       
   225      *
       
   226      * @param aItemElement Xml element.
       
   227      */
       
   228     void SetItemIdL( TXmlEngElement aItemElement );
       
   229 
       
   230     /**
       
   231      * Sets item id.
       
   232      *
       
   233      * @param aAttrFileName Xml attribute - file name.
       
   234      * @param aId Xml attribute - item's identifier.
       
   235      */
       
   236     void SetItemId2L( TXmlEngAttr aAttrFileName, TXmlEngAttr aId );
       
   237 
       
   238     /**
       
   239      * Evaluates item.
       
   240      *
       
   241      * @param aSuiteModel A model of the suite.
       
   242      * @param aItemId Item's id.
       
   243      * @param aParamList Parameters of the evaluation in the form of the CLiwGenericParamList.
       
   244      * @param aItemPosition A position of the record of the parameters list.
       
   245      * @return Error code.
       
   246      */
       
   247     TInt EvaluateItemL( CHnSuiteModel & aSuiteModel,
       
   248             const CHnItemId* aItemId, CLiwGenericParamList& aParamList,
       
   249             TInt aItemPosition );
       
   250 
       
   251     /**
       
   252      * Evaluates item.
       
   253      *
       
   254      * @param aSuiteModel A model of the suite.
       
   255      * @param aParamList Parameters of the evaluation in the form of the CLiwGenericParamList.
       
   256      * @param aItemPosition A position of the record of the parameters list.
       
   257      */
       
   258     void EvaluateItemItselfL( CHnSuiteModel & aSuiteModel,
       
   259             CLiwGenericParamList& aParamList, TInt aItemPosition );
       
   260 
       
   261     /**
       
   262      * Sets template attribute on item model.
       
   263      *
       
   264      * @param aItemModel Item's model.
       
   265      */
       
   266     void SetTemplateL( CHnItemModel* aItemModel );
       
   267 
       
   268     /**
       
   269      * Mode.
       
   270      *
       
   271      * @returns Mode of an item, e.g. normal / edit mode.
       
   272      */
       
   273     TMdMode Mode();
       
   274     
       
   275     /**
       
   276      * Retrieves values from outputs containing the [$index] string.
       
   277      * 
       
   278      * @param aValues Array containing found strings.
       
   279      * @param aElement The xml element.
       
   280      * @return Number of found strings.
       
   281      */
       
   282     TInt GetIndexValuesFromOutputsL( RPointerArray<HBufC8> &aValues, TXmlEngElement aElement );
       
   283 
       
   284 private:
       
   285 
       
   286     /**
       
   287      * Standard constructor.
       
   288      */
       
   289     CHnMdItem();
       
   290 
       
   291     /**
       
   292      * EPOC default constructor for performing 2nd stage construction.
       
   293      *
       
   294     * @param aElement Xml element.
       
   295     * @param aCmnPtrs Common pointers containter.
       
   296      */
       
   297     void ConstructL( TXmlEngElement aElement,THnMdCommonPointers* aCmnPtrs );
       
   298 
       
   299     /**
       
   300      * Fills item model with data.
       
   301      *
       
   302      * @param aItemModel Model to be filled.
       
   303      * @param aQueriesResultsList Parameters of in the form of the CLiwGenericParamList.
       
   304      * @param aPosition A position of the record in the parameters list.
       
   305      * @return True if filling finihed with success.
       
   306      */
       
   307     TBool FillItemModelL( CHnItemModel* aItemModel,
       
   308             const CLiwGenericParamList& aQueriesResultsList,
       
   309             TInt aPosition );
       
   310 
       
   311     /**
       
   312      * Fills item model with menu items created from meta data model.
       
   313      *
       
   314      * @param aItemModel Model to be filled.
       
   315      * @param aQueriesResultsList Parameters of in the form of the CLiwGenericParamList.
       
   316      * @param aPos A position of the record in the parameters list.
       
   317      */
       
   318     void FillItemModelWithMenuItemsL( CHnItemModel* aItemModel,
       
   319             const CLiwGenericParamList& aQueriesResultsList, TInt aPos = 0 );
       
   320 
       
   321     /**
       
   322      * Fills item model with toolbar created from meta data model.
       
   323      *
       
   324      * @param aItemModel Model to be filled.
       
   325      * @param aQueriesResultsList Parameters of in the form of the CLiwGenericParamList.
       
   326      * @param aPos A position of the record in the parameters list.
       
   327      */
       
   328     void FillItemModelWithToolbarL( CHnItemModel* aItemModel,
       
   329             const CLiwGenericParamList& aQueriesResultsList, TInt aPos = 0 );
       
   330 
       
   331     /**
       
   332      * Fills item model with MSK created from meta data model.
       
   333      *
       
   334      * @param aItemModel Model to be filled.
       
   335      * @param aQueriesResultsList Parameters of in the form of the CLiwGenericParamList.
       
   336      * @param aPos A position of the record in the parameters list.
       
   337      */
       
   338     void FillItemModelWithMiddleSoftKeyL( CHnItemModel* aItemModel,
       
   339             const CLiwGenericParamList& aQueriesResultsList, TInt aPos = 0 );
       
   340 
       
   341     /**
       
   342      * Fills menu model with data from mdmenuitem.
       
   343      *
       
   344      * @param aSuiteModel Suite's model.
       
   345      * @param aItemId Item's identifier.
       
   346      * @param aQueriesResultsList Queries results in form of the CLiwGenericParamList.
       
   347      * @param aItemModelNumber Item's model number.
       
   348      * @param aItemPos Position of an item in the queries results list.
       
   349      * @return KErrNone if an item was successfully added.
       
   350      */
       
   351     TInt AddItemL( CHnSuiteModel & aSuiteModel, TInt aItemId,
       
   352             const CLiwGenericParamList& aQueriesResultsList,
       
   353             TInt aItemModelNumber,
       
   354             TInt aItemPos );
       
   355 
       
   356     /**
       
   357      * Fills menu model with data from mdmenuitem.
       
   358      *
       
   359      * @param aSuiteModel Suite's model.
       
   360      * @param aItemId Item's identifier.
       
   361      * @param aQueriesResultsList Queries results in form of the CLiwGenericParamList.
       
   362      * @param aItemPos Position of an item in the queries results list.
       
   363      * @return KErrNone if an item was successfully updated.
       
   364      */
       
   365     TInt UpdateItemL( CHnSuiteModel & aSuiteModel, TInt aItemId,
       
   366             const CLiwGenericParamList& aQueriesResultsList, TInt aItemPos );
       
   367 
       
   368     /**
       
   369      * Fills menu model with data from mdmenuitem.
       
   370      *
       
   371      * @param aSuiteModel Suite's model.
       
   372      * @param aId Items identifier.
       
   373      */
       
   374     void RemoveItemL( CHnSuiteModel & aSuiteModel, TInt aId );
       
   375 
       
   376     /**
       
   377      * Sets move/remove locked attribute.
       
   378      *
       
   379      * @param aElement Xml item element.
       
   380      */
       
   381     void SetAttributesL( TXmlEngElement aElement );
       
   382 
       
   383     /**
       
   384      * Sets item type string.
       
   385      *
       
   386      * @param aElement Xml item element.
       
   387      */
       
   388     void SetTypeL( TXmlEngElement aElement );
       
   389     
       
   390     /**
       
   391      * Sets uid string.
       
   392      *
       
   393      * @param aElement Xml item element.
       
   394      */
       
   395     void SetUidL( TXmlEngElement aElement );
       
   396 
       
   397     /**
       
   398      * Sets delete / move locked attributes.
       
   399      *
       
   400      * @param aItemModel Model to be filled.
       
   401      * @param aQueriesResultsList Parameters of in the form of the CLiwGenericParamList.
       
   402      * @param aPos A position of the record in the parameters list.
       
   403      */
       
   404     void SetDeleteMoveAttributesL( CHnItemModel* aItemModel,
       
   405             const CLiwGenericParamList& aQueriesResultsList, TInt aPos );
       
   406 
       
   407 
       
   408     /**
       
   409      * Sets custom id.
       
   410      *
       
   411      * @param aElement Xml item element.
       
   412      */
       
   413     void SetCustomIdL( TXmlEngElement aElement );
       
   414 
       
   415     /**
       
   416      * Sets middle soft key.
       
   417      *
       
   418      * @param aElement Xml item element.
       
   419      * @param aCmnPtrs Common pointers.
       
   420      */
       
   421     void SetMiddleSoftKeyL( TXmlEngElement aElement,
       
   422             THnMdCommonPointers* aCmnPtrs );
       
   423 
       
   424     /**
       
   425      * Checks if an item is valid (the condition returns true).
       
   426      *
       
   427      * @param aQueryResults Query results.
       
   428      * @param aPos Position of the item in the results list.
       
   429      * @return ETrue or EFalse dependeing on whether the item is valid.
       
   430      */
       
   431     TBool IsValidL( const CLiwGenericParamList& aQueryResults, TInt aPos );
       
   432 
       
   433     /**
       
   434      * Sets the evaluated remove lock to the item model.
       
   435      *
       
   436      * @param aQueryResults Query results.
       
   437      * @param aPos Position of the item in the results list.
       
   438      * @param aItemModel Item model to set custom id on.
       
   439      */
       
   440     void SetRemoveLockedL( const CLiwGenericParamList& aQueryResults,
       
   441             TInt aPos, CHnItemModel* aItemModel );
       
   442 
       
   443     /**
       
   444      * Sets the evaluated move lock to the item model.
       
   445      *
       
   446      * @param aQueryResults Query results.
       
   447      * @param aPos Position of the item in the results list.
       
   448      * @param aItemModel Item model to set custom id on.
       
   449      */
       
   450     void SetMoveLockedL( const CLiwGenericParamList& aQueryResults,
       
   451             TInt aPos, CHnItemModel* aItemModel );
       
   452 
       
   453     /**
       
   454      * Sets the evaluated type to the item model.
       
   455      *
       
   456      * @param aQueryResults Query results.
       
   457      * @param aPos Position of the item in the results list.
       
   458      * @param aItemModel Item model to set custom id on.
       
   459      */
       
   460     void SetTypeL( CHnItemModel* aItemModel,
       
   461             const CLiwGenericParamList& aQueryResults, TInt aPos );
       
   462     
       
   463     /**
       
   464      * Sets the uid to the item model.
       
   465      *
       
   466      * @param aQueryResults Query results.
       
   467      * @param aPos Position of the item in the results list.
       
   468      * @param aItemModel Item model to set custom id on.
       
   469      */
       
   470     void SetUidL( CHnItemModel* aItemModel,
       
   471             const CLiwGenericParamList& aQueryResults, TInt aPos );
       
   472 
       
   473     /**
       
   474      * Sets custom id.
       
   475      *
       
   476      * @param aItemModel Model to be filled.
       
   477      * @param aParams Parameters of in the form of the CLiwGenericParamList.
       
   478      * @param aPos A position of the record in the parameters list.
       
   479      */
       
   480     void SetCustomIdL( CHnItemModel* aItemModel,
       
   481           const CLiwGenericParamList& aParams, TInt aPos );
       
   482 
       
   483     /**
       
   484      * Returns the maximum possible number of items.
       
   485      *
       
   486      * @return Maximum number of items.
       
   487      */
       
   488     TInt GetItemsMaxCountL();
       
   489 
       
   490 private: // data
       
   491 
       
   492     /**
       
   493      * Own - edit mode version of the item.
       
   494      * However TakeAlternativeModeItem transfers ownership.
       
   495      */
       
   496     CHnMdItem *iAlternativeModeItem;
       
   497 
       
   498     /**
       
   499      * Count.
       
   500      */
       
   501     RBuf8 iCount8;
       
   502 
       
   503     /**
       
   504      * Template.
       
   505      */
       
   506     RBuf8 iTemplate;
       
   507 
       
   508     /**
       
   509      * Own - List of allowable widget types.
       
   510      */
       
   511     CDesC8Array * iAllowableTemplate;
       
   512 
       
   513     /**
       
   514      * Item id.
       
   515      */
       
   516     CHnItemId* iItemId;
       
   517 
       
   518     /**
       
   519      * Queries.
       
   520      */
       
   521     CHnMdQueries* iQueries;
       
   522 
       
   523     /**
       
   524      * Notify Requests.
       
   525      */
       
   526     CHnMdNotifyRequests* iNotifyRequests;
       
   527 
       
   528     /**
       
   529      * Event mapping.
       
   530      */
       
   531     CHnMdEventMapping* iEventMapping;
       
   532 
       
   533     /**
       
   534      * UI mapping.
       
   535      */
       
   536     CHnMdUiMapping* iUiMapping;
       
   537 
       
   538     /**
       
   539      * Menu item.
       
   540      */
       
   541     CHnMdMenuItem* iMenu;
       
   542 
       
   543     /**
       
   544      * Toolbar.
       
   545      */
       
   546     CHnMdToolbar* iToolbar;
       
   547 
       
   548     /**
       
   549      * Middle soft key button.
       
   550      */
       
   551     CHnMdButton* iMsk;
       
   552 
       
   553     /**
       
   554      * Delete locked indicator
       
   555      */
       
   556     RBuf8 iRemoveLocked8;
       
   557 
       
   558     /**
       
   559      * MoveLocked indicator.
       
   560      */
       
   561     RBuf8 iMoveLocked8;
       
   562 
       
   563     /**
       
   564      * Type of an item.
       
   565      */
       
   566     RBuf8 iType8;
       
   567     
       
   568     /**
       
   569      * Uid of the item.
       
   570      */
       
   571     RBuf8 iUid8;
       
   572 
       
   573     /**
       
   574      * Custom identifier.
       
   575      */
       
   576     RBuf8 iCustomId8;
       
   577 
       
   578     /**
       
   579      * Common pointers.
       
   580      */
       
   581     THnMdCommonPointers* iCmnPtrs;
       
   582 
       
   583     /**
       
   584      * Mode.
       
   585      */
       
   586     TMdMode iMode;
       
   587 
       
   588     /**
       
   589      * Query results list.
       
   590      *  Own - queries results.
       
   591      */
       
   592     CLiwGenericParamList* iQueriesResultsList;
       
   593 
       
   594     /**
       
   595      * Query collector.
       
   596      * Own.
       
   597      */
       
   598     CHnQueryResultCollector* iQc;
       
   599 
       
   600     /**
       
   601      * Suite model.
       
   602      * Not own - suite model.
       
   603      */
       
   604     CHnSuiteModel* iSuiteModel;
       
   605 
       
   606     /**
       
   607      * Position of item.
       
   608      * Own - item's positions.
       
   609      */
       
   610     TInt iItemPosition;
       
   611 
       
   612     /**
       
   613      * Own - condition.
       
   614      */
       
   615     CHnConditionInterface* iCondition;
       
   616 
       
   617     /**
       
   618      * Running indicator.
       
   619      */
       
   620     RBuf8 iRunning8;
       
   621     
       
   622     /**
       
   623      * DRM protection indicator.
       
   624      */
       
   625     RBuf8 iDrmProtection8;
       
   626 
       
   627 public:
       
   628     /**
       
   629      * Marks if evaulation should take place.
       
   630      */
       
   631     TBool iEvaluationNeeded;
       
   632 
       
   633     };
       
   634 
       
   635 #endif // C_HNMMITEM_H