mmuifw_plat/mul_datamodel_api/inc/mul/imulmodel.h
branchRCL_3
changeset 26 0e9bb658ef58
parent 0 e83bab7cf002
equal deleted inserted replaced
25:4ea6f81c838a 26:0e9bb658ef58
       
     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:  Interface for model
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef I_MULMODEL_H
       
    20 #define I_MULMODEL_H
       
    21 
       
    22 //Includes
       
    23 #include <alf/ialfinterfacebase.h>
       
    24 #include <alf/ialfmodel.h>
       
    25 #include <alf/alftypes.h>
       
    26 #include <mul/imulmodelbase.h>
       
    27 #include <mul/imulwidgetdef.h>
       
    28 #include <mul/imulwidget.h>
       
    29 #include <mul/muldatapath.h>
       
    30 #include <vector>
       
    31 #include <memory>
       
    32 
       
    33 namespace osncore
       
    34     {
       
    35     class UString;
       
    36     }
       
    37 using namespace osncore;
       
    38 
       
    39 namespace Alf
       
    40     {
       
    41     
       
    42 namespace mulmodel
       
    43     {
       
    44     static const IfId Ident=
       
    45         {
       
    46         0, "mulmodel"
       
    47         };
       
    48    
       
    49     static const char* const KBaseElementName = "base" ;
       
    50     static const char* const KItemElementName = "item" ;
       
    51     }
       
    52 
       
    53 // Forward Declarations
       
    54 class MulVisualItem;
       
    55 class MulDataPath;
       
    56 class IMulModelProvider;
       
    57 
       
    58 /*! @class IMulModel
       
    59 *
       
    60 *  @brief An interface for the data model.   
       
    61 *
       
    62 *  Client that creates the model own the model.
       
    63 *  Client can use this interface to update data model.
       
    64 *
       
    65 */
       
    66 class IMulModel : public IMulModelBase, public IAlfModel
       
    67     {
       
    68 
       
    69 public:
       
    70 
       
    71 	/**
       
    72 	 * Getter for the type identifier of this interface.
       
    73 	 *
       
    74 	 * @return A descriptor to identify the type of this interface.
       
    75 	 */
       
    76 	static inline const IfId& type()
       
    77 	    {
       
    78 	    return mulmodel::Ident;    
       
    79 	    }
       
    80 
       
    81 	/** 
       
    82 	 * Virtual destructor.
       
    83 	 */ 
       
    84  	virtual ~IMulModel() {}
       
    85     
       
    86     /**
       
    87      * Informs the data model that new items have been added to client's
       
    88      * internal model. Data model is expected to sync its indices as a 
       
    89      * result.
       
    90      * <b>Note:</b> This API will never give an exception.
       
    91      * 
       
    92      * @param aIndex Position where items were inserted.
       
    93      * @param aCount Number of items inserted.
       
    94      * @param aPath  Path of parent item in the data hierarchy. 
       
    95      *               Default is Null path i.e. no parent.
       
    96      */ 
       
    97     virtual void Insert( int aIndex, int aCount, 
       
    98                          const MulDataPath& aPath = MulDataPath() ) = 0 ;
       
    99         
       
   100      /**
       
   101       * Informs the data model that items have been removed from the client's.
       
   102       * internal data model. Data model is expected to sync its indices as a 
       
   103       * result.
       
   104       * <b>Note:</b> This API will never give an exception.
       
   105       * 
       
   106       * @param aIndex Position from where items have to be removed.
       
   107       * @param aCount Number of items to be removed.\
       
   108       * @param aPath  Path of parent item in the data hierarchy. 
       
   109       *               Default is Null path i.e. no parent.
       
   110       */ 
       
   111      virtual void Remove( int aIndex, int aCount, 
       
   112     		 			  const MulDataPath& aPath = MulDataPath() ) = 0;
       
   113      
       
   114      /**
       
   115       * Informs the data model that an item has been updated in the client's
       
   116       * internal model. Data model will use to input to determine whether
       
   117       * a visualization change is required. If yes, the model will request the
       
   118       * provider for updated data.
       
   119       * <b>Note:</b> This API will never give an exception.
       
   120       * 
       
   121       * @param aIndex Position from where items have to be updated.
       
   122       * @param aCount Number of items to be updated.
       
   123       * @param aPath  Path of parent item in the data hierarchy. 
       
   124       *               Default is Null path i.e. no parent.
       
   125       */ 
       
   126      virtual void Update( int aIndex, int aCount, 
       
   127                           const MulDataPath& aPath = MulDataPath() ) = 0;
       
   128 
       
   129     /**
       
   130       * A refresh data request. Informs that the data model has to be 
       
   131       * repopulated with mentioned number of items. So the data model
       
   132       * will remove all the existing data and issue request to the 
       
   133       * provider for new data.
       
   134       * <b>Note:</b> This API will never give an exception.
       
   135       * 
       
   136       * @param aCount Number of items to be repopulated.
       
   137       * @param aPath  Path of parent item in the data hierarchy. 
       
   138       *               Default is Null path i.e. no parent.
       
   139       */ 
       
   140      virtual void Refresh( int aCount, const MulDataPath& aPath = MulDataPath() ) = 0;
       
   141           
       
   142      /**
       
   143       * Provide data for the specified item. This is a unified API for 
       
   144       * adding & updating data. 
       
   145       *
       
   146       * @param aIndex Position of item to be updated.
       
   147       * @param aVisualItem Collection of attributes. Ownership is transfered.
       
   148       * @param aPath  Path of parent item in the data hierarchy. 
       
   149       *               Default is Null path i.e. no parent.
       
   150       * @throw Invalid Argument, in case index is out of bound or visual 
       
   151       *                         item is NULL.
       
   152       * @throw Logic Error, in case item could not be updated.
       
   153       */ 
       
   154      virtual void SetData( int aIndex, std::auto_ptr<MulVisualItem> aVisualItem, 
       
   155                             const MulDataPath& aPath = MulDataPath() ) = 0;
       
   156      
       
   157      /**
       
   158       * Get the data for item at the specified index.
       
   159       *
       
   160       * @param aIndex Position of item in the data model.
       
   161       * @param aPath  Path of parent item in the data hierarchy. 
       
   162       *               Default is Null path i.e. no parent.
       
   163       * @return A constant reference to the data at the given index.
       
   164       * @throw Invalid Argument, in case index is out of bound.
       
   165       */ 
       
   166      virtual const MulVisualItem* Data( int aIndex, 
       
   167                                 		const MulDataPath& aPath = MulDataPath() ) const = 0;
       
   168      
       
   169     /**
       
   170       * Get the count of items in the model.
       
   171       *
       
   172       * @param aPath  Path of parent item in the data hierarchy. 
       
   173       *               Default is Null path i.e. no parent.
       
   174       * @return Count of items in the model.
       
   175       */ 
       
   176      virtual int Count( const MulDataPath& aPath = MulDataPath() ) const = 0; 
       
   177           
       
   178     /**
       
   179      * Set the data provider for the model. 
       
   180      * <b>Note:</b> This API will be removed in future. 
       
   181      * Clients would be able to specify the provider to the model at 
       
   182      * the time of the construction.
       
   183      * 
       
   184      * @param aDataProvider Handle to the data provider.
       
   185      * @throw Logic Error, in case same accessor object is passed again.
       
   186      */ 
       
   187      virtual void SetDataProvider( const IMulModelProvider& aDataProvider ) = 0;
       
   188      
       
   189     /**
       
   190      * Set the default logical template id for widget elements. 
       
   191      * Logical templates map to visualization of the element(s).
       
   192      * 
       
   193      * @param aTemplateId Logical template id for the widget elements.
       
   194      */ 
       
   195      virtual void SetTemplate( mulwidget::TLogicalTemplate aDefaultTemplate ) = 0;
       
   196      
       
   197      /**
       
   198       * Set the logical template id for a specific widget element. 
       
   199       * Logical templates map to visualization of the element.
       
   200       * 
       
   201       * @param aItemIndex Unique id of item of which template needs to be applied.
       
   202       * @param aTemplateId Logical template id for the widget element.
       
   203       * @param aPath  Path of parent item in the data hierarchy. 
       
   204       *               Default is Null path i.e. no parent.
       
   205       * @throw Invalid Argument, in case index is out of bound.
       
   206       */ 
       
   207      virtual void SetTemplate( int aItemIndex, mulwidget::TLogicalTemplate aDefaultTemplate ,
       
   208                                 const MulDataPath& aPath = MulDataPath() )=0;
       
   209 	 
       
   210     /**
       
   211      * Set the data window/cache size of the Data model.
       
   212      * This API can be used to over-ride the data window size of the data model
       
   213      * already set by the widget. This can be used by clients to set the buffer
       
   214      * size different from what the widget has specified. 
       
   215      * 
       
   216      * @param aSize Size of buffer.
       
   217      * @throw Invalid Argument, incase the buffer size is negative.
       
   218      */ 
       
   219     virtual void SetDataWindow( int aSize ) = 0;
       
   220     
       
   221     /**
       
   222      * Get the buffer size defined for the data model.
       
   223      * 
       
   224      * @return Size of data window.
       
   225      */ 
       
   226     virtual int DataWindow( ) const = 0;        
       
   227     
       
   228      /**
       
   229 	  * Set highlighted item in the model.
       
   230       * 
       
   231 	  * @param aItemIndex Index of item.
       
   232 	  * @param aPath  Path of parent item in the data hierarchy. 
       
   233       *               Default is Null path i.e. no parent.
       
   234 	  *
       
   235 	  * <B>Examples:</b>
       
   236 	  * @code
       
   237 	  * Set index of the item to be highlighted.
       
   238 	  *
       
   239 	  *         mListWidget->SetHighlight(highlight);
       
   240 	  * @endcode
       
   241       */ 
       
   242 	virtual void SetHighlight( int aItemIndex, const MulDataPath& aPath = MulDataPath() ) = 0; 
       
   243 
       
   244     /**
       
   245      * Get the index of the current highlighted item from the model.
       
   246      * 
       
   247      * @return Highlighted item index.
       
   248      *
       
   249 	 * <B>Examples:</b>
       
   250 	 * @code
       
   251 	 * Get index of the highlighted item.
       
   252 	 *
       
   253 	 *      int highlight = mListWidget->Highlight();
       
   254 	 * @endcode
       
   255      */ 
       
   256      virtual int Highlight() = 0;
       
   257      
       
   258     /**
       
   259      * Get the index of the current highlighted item along with the path 
       
   260      * of the root item in the data hierarchy.
       
   261      * 
       
   262      * @param aPath  Path of parent item in the data hierarchy. Out parameter.
       
   263      * @return Highlighted item index.
       
   264      *
       
   265 	 * <B>Examples:</b>
       
   266 	 * @code
       
   267 	 * Get index of the highlighted item.
       
   268 	 *
       
   269 	 *      int highlight = mListWidget->Highlight();
       
   270 	 * @endcode
       
   271      */ 
       
   272      virtual int Highlight( MulDataPath& aPath ) = 0;     
       
   273      
       
   274     /**
       
   275 	 * Function for setting the item(s) Marked or Unmarked. For mark and
       
   276 	 * unmark operations, indices of items should be provided.
       
   277 	 * 
       
   278 	 * @param aType Type of marking operation to be performed. 
       
   279 	 * @param aItemsIndex Indices of the items to be changed
       
   280 	 * @throw Invalid Argument, if type is specified as mark-all and unmark-all. 
       
   281 	 *
       
   282 	 * <B>Examples:</b>
       
   283 	 * @code
       
   284      * Mark the selected item
       
   285      *
       
   286 	 *      mListWidget->SetMarkedIndices( MulWidgetDef::EMulMark, itemIndex );
       
   287 	 * @endcode
       
   288 	 */ 
       
   289 	virtual void SetMarkedIndices( MulWidgetDef::TMulWidgetMarkingType aType ,
       
   290 								   const std::vector<int>& aItemsIndex,
       
   291 								   const MulDataPath& aPath = MulDataPath() ) = 0;
       
   292 
       
   293 	/**
       
   294 	 * Function for setting the item(s) Marked or Unmarked.
       
   295 	 * For mark all and unmark all operations use this overloaded version.
       
   296 	 * 
       
   297 	 * @param aType Type of marking operation to be performed.
       
   298 	 * @throw Invalid Argument, if type is specified as mark and unmark. 
       
   299      *
       
   300 	 * <B>Examples:</b>
       
   301 	 * @code
       
   302 	 * Mark all items
       
   303 	 *
       
   304 	 *      mListWidget->SetSelection( MulWidgetDef::EMulMarkAll );
       
   305 	 * @endcode
       
   306 	 */		 
       
   307 	virtual	void SetMarkedIndices(
       
   308 			MulWidgetDef::TMulWidgetMarkingType aType = MulWidgetDef::EMulMarkAll
       
   309 			) = 0;
       
   310 			
       
   311 	/**
       
   312 	 * Gets the indices of the currently marked items.
       
   313 	 * 
       
   314 	 * @return Array of maked indices. This would return an empty container if no items are marked. 
       
   315 	 *
       
   316 	 * <B>Examples:</b>
       
   317 	 * @code
       
   318 	 * Get the array of all marked items
       
   319 	 *
       
   320 	 *      std::vector<int> markedItems = mListWidget->MarkIndices();
       
   321 	 * @endcode
       
   322 	 */
       
   323 	virtual const std::vector<int>& MarkedIndices( const MulDataPath& aPath = MulDataPath() ) = 0;    
       
   324           
       
   325     };
       
   326 
       
   327     } // namespace Alf
       
   328 
       
   329 #endif // I_MULMODEL_H
       
   330 
       
   331 //End of file
       
   332