mulwidgets/muldatamodel/inc/mulmodelimpl.h
changeset 17 3eca7e70b1b8
parent 3 4526337fb576
equal deleted inserted replaced
3:4526337fb576 17:3eca7e70b1b8
     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:  Implementation of model interface
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef MULMODELIMPL_H
       
    20 #define MULMODELIMPL_H
       
    21 
       
    22 //Includes
       
    23 #include <mul/imulmodel.h>
       
    24 
       
    25 #include <osn/ustring.h>
       
    26 #include <memory>
       
    27 #include <vector>
       
    28 
       
    29 #include "mul/imulmodelaccessor.h"
       
    30 #include "imulmodelobserver.h"
       
    31 
       
    32 namespace osncore
       
    33     {
       
    34     class UString;
       
    35     }
       
    36     
       
    37 using namespace osncore;
       
    38 
       
    39 namespace Alf
       
    40     {
       
    41 
       
    42 //Forward Declaration
       
    43 
       
    44 class MulDataWindow;
       
    45 class MulPushMode;
       
    46 class MulPageDataWindow;
       
    47 
       
    48 /**
       
    49  *  Implementation class for Data model.
       
    50  *  @lib 
       
    51  */
       
    52 class MulModelImpl : public IMulModel,
       
    53 					 public IMulModelAccessor
       
    54     {
       
    55     
       
    56 public:
       
    57 	
       
    58 	/**
       
    59 	 * C++ constructor.
       
    60 	 */
       
    61 	OSN_IMPORT MulModelImpl();
       
    62 	
       
    63 	/**
       
    64 	 * Destructor.
       
    65 	 */
       
    66 	OSN_IMPORT virtual ~MulModelImpl();
       
    67     
       
    68 public: //from IMulModel
       
    69    	
       
    70 	void Insert(int aIndex, int aCount, 
       
    71                 const MulDataPath& aPath = MulDataPath());
       
    72 	
       
    73     void Remove( int aIndex, int aCount, 
       
    74     			 const MulDataPath& aPath = MulDataPath() );
       
    75 	
       
    76 	void Update( int aIndex, int aCount, 
       
    77 				 const MulDataPath& aPath = MulDataPath() );
       
    78 	
       
    79 	void Refresh( int aCount, const MulDataPath& aPath = MulDataPath() );
       
    80 	     
       
    81 	void SetData( int aIndex, std::auto_ptr<MulVisualItem> aVisualItem, 
       
    82                   const MulDataPath& aPath = MulDataPath() );
       
    83 	
       
    84 	const MulVisualItem* Data( int aIndex, 
       
    85 	                    	   const MulDataPath& aPath = MulDataPath() ) const;
       
    86 
       
    87 	int Count( const MulDataPath& aPath = MulDataPath() ) const; 
       
    88 
       
    89 	void SetDataProvider( const IMulModelProvider& aDataProvider );
       
    90 
       
    91 	void SetTemplate( mulwidget::TLogicalTemplate aTemplateId );
       
    92 
       
    93 	void SetTemplate( int aItemIndex, mulwidget::TLogicalTemplate aTemplateId, 
       
    94 	                  const MulDataPath& aPath = MulDataPath() );
       
    95 
       
    96 	void SetDataWindow( int aSize );
       
    97 
       
    98 	int DataWindow( ) const;        
       
    99 
       
   100 	void SetHighlight( int aItemIndex, const MulDataPath& aPath = MulDataPath() ); 
       
   101 
       
   102 	int Highlight() ;
       
   103 
       
   104 	int Highlight( MulDataPath& aPath );     
       
   105 
       
   106 	void SetMarkedIndices( MulWidgetDef::TMulWidgetMarkingType aType ,
       
   107 						   const std::vector<int>& aItemsIndex,
       
   108 						   const MulDataPath& aPath = MulDataPath() );
       
   109 
       
   110 	void SetMarkedIndices(
       
   111 			MulWidgetDef::TMulWidgetMarkingType aType = MulWidgetDef::EMulMarkAll );
       
   112 
       
   113 	const std::vector<int>& MarkedIndices( const MulDataPath& aPath = MulDataPath() );
       
   114 
       
   115 public: //from IMulModelBase
       
   116 	    
       
   117 	IMulModelAccessor* Accessor(); 
       
   118 
       
   119 public: //from IMulModelAccessor
       
   120 	 
       
   121 	void SetHighlight( int aItemIndex );
       
   122 	
       
   123 	void ScrollWindow( int aItemIndex );
       
   124 	 		      	
       
   125 	int CurrentItemCount();
       
   126 	 	
       
   127 	void SetVisibleWindow( int aWindowSize, int aPageTopIndex = -1 );
       
   128 		 		
       
   129 	int RelativeIndex( int aAbsoluteIndex ) const;
       
   130  	 
       
   131 	int TopWindowOffset() const;
       
   132 	
       
   133 	int BottomWindowOffset() const;
       
   134 	
       
   135 	int TopOffset() const;
       
   136 			
       
   137 	int BottomOffset() const;
       
   138 	
       
   139 	int RearTopOffset() const;
       
   140 	
       
   141 	int RearBottomOffset() const;
       
   142 	
       
   143 	bool IsItemMarked( int aIndex ); 
       
   144 	
       
   145 	const MulVisualItem& Item( int aAbsoluteIndex );
       
   146 
       
   147     int AbsoluteIndex( int aRelativeIndex );
       
   148     
       
   149     void SetMarkedIndex( MulWidgetDef::TMulWidgetMarkingType aType, int aIndex );
       
   150     
       
   151     bool IsLoopingOn();
       
   152 	
       
   153     void AddModelObserver( IMulModelObserver* aObserver );
       
   154     
       
   155     void RemoveModelObserver( IMulModelObserver* aObserver );
       
   156     
       
   157     mulwidget::TLogicalTemplate Template();
       
   158     
       
   159 private: //from IAlfModel
       
   160 
       
   161 	void addModelChangeObserver( IAlfModelChangeObserver& aObserver );
       
   162 	
       
   163 	void removeModelChangeObserver( IAlfModelChangeObserver& aObserver );
       
   164 	
       
   165 	void setData( IAlfVariantType* aData );
       
   166 	
       
   167 	void updateData(int aNumContainerIndices,int* aContainerIndices, IAlfVariantType* aData );
       
   168 	
       
   169 	void addData(int aNumContainerIndices,int* aContainerIndices, IAlfVariantType* aData );
       
   170 	
       
   171 	void removeData(int aNumContainerIndices,int* aContainerIndices );
       
   172 	  
       
   173 	void executeOperations(AlfPtrVector<AlfModelOperation>&  aOperationsArray);
       
   174 	      
       
   175 	void executeOperation(AlfModelOperation* aOperation); 
       
   176 	
       
   177 	void clearModel(); 
       
   178 	
       
   179 	IAlfVariantType* data() const;
       
   180 	
       
   181 private: // from base class MAlfInterfaceBase
       
   182 
       
   183     /**
       
   184      * Getter for interfaces provided by the list model.
       
   185      *
       
   186      * @param aType A descriptor to identify the type of the queried interface.
       
   187      * @return The queried interface, or NULL if the interface is not
       
   188      *         supported or available.
       
   189      */
       
   190     virtual IAlfInterfaceBase* makeInterface( const IfId& aType );
       
   191     
       
   192 public: //new method
       
   193 
       
   194 	/**
       
   195 	 * When ever data window update data window, it will use this method to notify
       
   196 	 * Data model to update data window and update alf model
       
   197 	 */
       
   198 	void DataWindowUpdated();
       
   199     			
       
   200 private: //New method
       
   201 	
       
   202 	/**
       
   203 	 * Create Update event for selection change to notify Widget
       
   204 	 * for selection change. Widget need to use IsItemMarked API for checking 
       
   205 	 * whether item is marked or unmarked.
       
   206 	 * 
       
   207 	 * @param aAbsoluteIndex Absolute index
       
   208 	 */
       
   209 	void CreateMarkingEvent(int aAbsoluteIndex);
       
   210 		
       
   211 	/**
       
   212 	 * Notify observer about state changed
       
   213 	 * 
       
   214 	 * @param aState Highlight or making changed
       
   215 	 * @param aData Index of new highlight or Index of marked or unmarked item.
       
   216 	 *				( Item is marked or not should be checked using IMulModelAccessor interface)	  
       
   217 	 */
       
   218 	void NotifyStateChange( IMulModelObserver::TMulChangedState aState, std::auto_ptr<IMulVariantType> aData);
       
   219 	
       
   220 	/**
       
   221      * Notify observer about data change event
       
   222      * 
       
   223      * @param aState Event to notify
       
   224      * @param aStartIndex Start index of.
       
   225      * @param aCount No of item affected      
       
   226      */
       
   227 	void NotifyDataChange( IMulModelObserver::TMulChangedState aState, int aStartIndex, int aCount );
       
   228 	
       
   229 	/**
       
   230      * Notify observer about data change event
       
   231      * 
       
   232      * @param aState Event to notify
       
   233      * @param aIndex Start index of.
       
   234      */
       
   235     void NotifyDataChange( IMulModelObserver::TMulChangedState aState, int aIndex );
       
   236     
       
   237     /**
       
   238      * Notify observer about template change
       
   239      * 
       
   240      * @param aIndex index of item.
       
   241      * @param aTamplateId changed template
       
   242      */
       
   243     void NotifyTemplateChange( int aIndex, mulwidget::TLogicalTemplate aTamplateId );
       
   244 				
       
   245 private: //data
       
   246 		
       
   247 	//std::auto_ptr<MulDataWindow>			mDataWindow; //own
       
   248 	std::auto_ptr<MulPageDataWindow>		mDataWindow; //own
       
   249 	std::auto_ptr<MulPushMode> 		        mModelHelper; //own
       
   250 	std::vector<IMulModelObserver*>			mObserverArray;
       
   251     };
       
   252     
       
   253     } // namespace Alf
       
   254 
       
   255 #endif //MULMODELIMPL_H
       
   256     
       
   257 //End of file
       
   258