profilesservices/FileList/Src/CFLDChangedItemObserver.cpp
branchRCL_3
changeset 54 7e0eff37aedb
parent 0 8c5d936e5675
equal deleted inserted replaced
53:8ee96d21d9bf 54:7e0eff37aedb
       
     1 /*
       
     2 * Copyright (c) 2005 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 the CFLDChangedItemObserver.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // CLASS HEADER
       
    21 #include "CFLDChangedItemObserver.h"
       
    22 
       
    23 // INTERNAL INCLUDES
       
    24 #include "CFLDFileListModel.h"
       
    25 #include "CFLDWaitNote.h"
       
    26 #include "CFLDPopupList.h"
       
    27 #include "CFLDController.h"
       
    28 
       
    29 const TInt KDefaultDelay( 3000000 );
       
    30 // EXTERNAL INCLUDES
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CFLDChangedItemObserver::CFLDChangedItemObserver
       
    36 // C++ default constructor can NOT contain any code, that
       
    37 // might leave.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CFLDChangedItemObserver::CFLDChangedItemObserver()
       
    41 	: iModel( NULL )
       
    42     {
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CFLDChangedItemObserver::CFLDChangedItemObserver
       
    47 // C++ constructor can NOT contain any code, that
       
    48 // might leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CFLDChangedItemObserver::CFLDChangedItemObserver(CFLDWaitNote* aWaitNote)
       
    52 	: iModel( NULL ),
       
    53 	iDelay(KDefaultDelay)
       
    54     {
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CFLDChangedItemObserver::NewL
       
    59 // Two-phased constructor.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CFLDChangedItemObserver* CFLDChangedItemObserver::NewL()
       
    63     {
       
    64     CFLDChangedItemObserver* self = new (ELeave) CFLDChangedItemObserver();
       
    65     return self;
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CFLDChangedItemObserver::NewL
       
    70 // Two-phased constructor.
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 CFLDChangedItemObserver* CFLDChangedItemObserver::NewL(CFLDWaitNote* aWaitNote)
       
    74 	{
       
    75 	CFLDChangedItemObserver* self = new (ELeave) CFLDChangedItemObserver(aWaitNote);
       
    76 	CleanupStack::PushL( self );
       
    77 	self->ConstructL(aWaitNote);
       
    78 	CleanupStack::Pop( self );
       
    79 	return self;
       
    80 	
       
    81 	}
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CFLDChangedItemObserver::ConstructL
       
    85 // Symbian 2nd phase constructor can leave.
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 void CFLDChangedItemObserver::ConstructL( CFLDWaitNote* aWaitNote)
       
    89 	{
       
    90 	iTimer = CPeriodic::NewL( EPriorityNormal );
       
    91 	iWaitNote = aWaitNote;
       
    92 	}
       
    93 
       
    94 // Destructor
       
    95 CFLDChangedItemObserver::~CFLDChangedItemObserver()
       
    96     {
       
    97     if (iTimer)
       
    98     	{
       
    99     	  iTimer->Cancel();
       
   100     	  delete iTimer;
       
   101     	}
       
   102   
       
   103     }
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // CFLDFileListModel::SetFileListModel
       
   107 // (other items were commented in a header).
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 void CFLDChangedItemObserver::SetFileListModel( CFLDFileListModel* aModel )
       
   111 	{
       
   112 	iModel = aModel;	
       
   113 	}
       
   114 
       
   115 // -----------------------------------------------------------------------------
       
   116 // CFLDFileListModel::HandleItemChangeL
       
   117 // (other items were commented in a header).
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void CFLDChangedItemObserver::HandleItemChangeL( const TArray<TCLFItemId>& /*aItemIDArray*/ )
       
   121 	{
       
   122 	if( iModel )
       
   123 		{
       
   124 		TRAP_IGNORE( static_cast<CFLDController*>(iModel->GetPopupList()->GetFileListBoxObserver())->Release());
       
   125 		}
       
   126 	
       
   127 	if( iWaitNote && !iWaitNote->IsRunning() )
       
   128 		{
       
   129 		iWaitNote->OpenWaitNoteL();
       
   130 		}
       
   131 
       
   132 	
       
   133     if (iModel)
       
   134     	{
       
   135     	iTimer->Cancel();
       
   136 		iTimer->Start( iDelay, iDelay, TCallBack( HandleModelRefreshL, this ) ); // CSI: 10 # iTimer is cancelled in Release()
       
   137 		
       
   138 		// When video screen is closed,
       
   139 		// listbox must be forced to be refreshed
       
   140 		// ( otherwise scrollbar is not redrawn)
       
   141 		iModel->GetPopupList()->ListBox()->SetDimmed( EFalse );
       
   142 		iModel->GetPopupList()->ListBox()->ScrollBarFrame()->VerticalScrollBar()->SetDimmed( EFalse );
       
   143 		iModel->GetPopupList()->DrawNow( CEikonEnv::Static()->EikAppUi()->ApplicationRect() );
       
   144 		}
       
   145 	}
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CFLDFileListModel::HandleModelRefreshL
       
   149 // (other items were commented in a header).
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 TInt CFLDChangedItemObserver::HandleModelRefreshL( TAny* aPtr )
       
   153 	{
       
   154 	CFLDChangedItemObserver* observer= reinterpret_cast< CFLDChangedItemObserver* >( aPtr );
       
   155 	observer->iTimer->Cancel();
       
   156 	observer->iModel->RefreshEntryListL();
       
   157 	
       
   158 	return 0;
       
   159 	}
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // CFLDFileListModel::HandleError
       
   163 // (other items were commented in a header).
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 void CFLDChangedItemObserver::HandleError( TInt /*aError*/ )
       
   167 	{
       
   168 	}
       
   169 //  End of File