Nokia N97 SDK
Example Applications Guide

CCECustomSorter.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : CCECustomSorter.cpp
00004 *  Part of     : Content Listing Framework Sample Application
00005 *  Interface   :
00006 *  Description :
00007 *  Version     :
00008 *
00009 *  Copyright (c) 2006 Nokia Corporation.
00010 *  This material, including documentation and any related
00011 *  computer programs, is protected by copyright controlled by
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 
00017 // INCLUDE FILES
00018 #include "CCECustomSorter.h"
00019 
00020 #include "CLFExample.hrh"
00021 
00022 #include <e32math.h>
00023 #include <MCLFContentListingEngine.h>
00024 #include <ContentListingFactory.h>
00025 #include <MCLFItem.h>
00026 #include <CLFContentListing.hrh>
00027 #include <CLFExample.rsg>
00028 
00029 // ============================ MEMBER FUNCTIONS ===============================
00030 
00031 // -----------------------------------------------------------------------------
00032 // CCECustomSorter::CCECustomSorter
00033 // C++ default constructor can NOT contain any code, that
00034 // might leave.
00035 // -----------------------------------------------------------------------------
00036 //
00037 CCECustomSorter::CCECustomSorter()
00038     {
00039     }
00040 
00041 // -----------------------------------------------------------------------------
00042 // CCECustomSorter::NewL
00043 // Two-phased constructor.
00044 // -----------------------------------------------------------------------------
00045 //
00046 CCECustomSorter* CCECustomSorter::NewL()
00047     {
00048     CCECustomSorter* self = new (ELeave) CCECustomSorter;
00049     return self;
00050     }
00051 
00052 // Destructor
00053 CCECustomSorter::~CCECustomSorter()
00054     {
00055     }
00056 
00057 // -----------------------------------------------------------------------------
00058 // CCECustomSorter::SortItemsL
00059 // Method for sorting Content Listing Framework items.
00060 // -----------------------------------------------------------------------------
00061 //
00062 void CCECustomSorter::SortItemsL( RPointerArray<MCLFItem>& aItemArray )
00063     {
00064     // TLinearOrder can be used to sort RPointerArrays. TLinearOrder
00065     // defines a position for each item by comparing two items at a time.
00066     // It does the comparison by calling static method
00067     // CCECustomSorter::Compare. In this case, the Compare method
00068     // returns a random value and the array will be randomized. The
00069     // comparison process is started when RPointerArray::Sort method
00070     // is called.
00071     TLinearOrder<MCLFItem> sorter( CCECustomSorter::Compare );
00072     aItemArray.Sort( sorter );
00073     }
00074 
00075 // -----------------------------------------------------------------------------
00076 // CCECustomSorter::Compare
00077 // "Compare" two items for ordering the list model by random.
00078 // -----------------------------------------------------------------------------
00079 //
00080 TInt CCECustomSorter::Compare( const MCLFItem& /*aFirst*/,
00081                                const MCLFItem& /*aSecond*/ )
00082     {
00083     // return a random value
00084     return Math::Random();
00085     }
00086 
00087 //  End of File

© Nokia 2009

Back to top