creator/engine/src/creator_notepadwrapper.cpp
branchRCL_3
changeset 21 b3cee849fa46
equal deleted inserted replaced
20:48060abbbeaf 21:b3cee849fa46
       
     1 /*
       
     2 * Copyright (c) 2010 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 #include "creator_notepadwrapper.h"
       
    20 
       
    21 	/**
       
    22 	* Constructor
       
    23 	*/
       
    24 CCreatorNotepadWrapper::CCreatorNotepadWrapper()
       
    25 	{
       
    26 	}
       
    27 	
       
    28 	/**
       
    29 	* Destructor
       
    30 	*/
       
    31 CCreatorNotepadWrapper::~CCreatorNotepadWrapper()
       
    32 	{
       
    33 /*    
       
    34 	if(iNotepadApi)
       
    35         {
       
    36         delete iNotepadApi;
       
    37         iNotepadApi = NULL;
       
    38         }
       
    39  */   
       
    40     if(iAgendaUtil)
       
    41         {
       
    42         delete iAgendaUtil;
       
    43         iAgendaUtil = NULL;
       
    44         }
       
    45 	}
       
    46 	
       
    47 	/**
       
    48 	* Two-Phased constructor
       
    49 	*/
       
    50 CCreatorNotepadWrapper* CCreatorNotepadWrapper::NewL()
       
    51 	{
       
    52 	CCreatorNotepadWrapper* self = CCreatorNotepadWrapper::NewLC();
       
    53 	CleanupStack::Pop(self);
       
    54     return self;
       
    55 	}
       
    56 
       
    57 	/**
       
    58 	* Two-Phased constructor
       
    59 	*/
       
    60 CCreatorNotepadWrapper* CCreatorNotepadWrapper::NewLC()
       
    61 	{
       
    62 	CCreatorNotepadWrapper* self = new (ELeave) CCreatorNotepadWrapper;
       
    63 	CleanupStack::PushL(self);
       
    64 	self->ConstructL();
       
    65     return self;
       
    66 	}
       
    67 	
       
    68 	/**
       
    69 	* ConstructL()
       
    70 	*/
       
    71 
       
    72 void CCreatorNotepadWrapper::ConstructL()
       
    73 	{
       
    74 	iAgendaUtil = new AgendaUtil();
       
    75 //	iNotepadApi = new NotesEditor(iAgendaUtil);
       
    76 	}
       
    77 
       
    78 TInt CCreatorNotepadWrapper::CreateNoteL( const TDesC& aText )
       
    79 	{
       
    80 	TInt err = KErrNone;
       
    81 	QString textNote = QString::fromUtf16( aText.Ptr(),aText.Length());
       
    82     iNotepadApi->edit(textNote,iAgendaUtil);
       
    83     iNotepadApi->close(NotesEditorInterface::CloseWithSave, iAgendaUtil);
       
    84 	return err;
       
    85     }
       
    86 void CCreatorNotepadWrapper::DeleteAllL()
       
    87 	{
       
    88 	
       
    89 	QList<AgendaEntry> ael;
       
    90     AgendaUtil::FilterFlags filter = AgendaUtil::FilterFlags(AgendaUtil::IncludeNotes);
       
    91 
       
    92     ael = iAgendaUtil->fetchAllEntries(filter);
       
    93     for(int i=0 ; i<ael.count() ; i++)
       
    94     	{
       
    95         iAgendaUtil->deleteEntry(ael[i].id());
       
    96     	}
       
    97 		
       
    98 	}
       
    99