creator/engine/src/creator_notepadwrapper.cpp
changeset 52 36d60d12b4af
parent 31 e7a04a6385be
equal deleted inserted replaced
51:b048e15729d6 52:36d60d12b4af
    14 * Description: 
    14 * Description: 
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
       
    19 #include <QDir>
    19 #include "creator_notepadwrapper.h"
    20 #include "creator_notepadwrapper.h"
    20 
    21 
    21 	/**
    22 	/**
    22 	* Constructor
    23 	* Constructor
    23 	*/
    24 	*/
    28 	/**
    29 	/**
    29 	* Destructor
    30 	* Destructor
    30 	*/
    31 	*/
    31 CCreatorNotepadWrapper::~CCreatorNotepadWrapper()
    32 CCreatorNotepadWrapper::~CCreatorNotepadWrapper()
    32 	{
    33 	{
    33 /*    
    34     
    34 	if(iNotepadApi)
    35     iNotepadApi = NULL;
       
    36 		
       
    37     if(iNotesEditorPluginLoader)
    35         {
    38         {
    36         delete iNotepadApi;
    39 	    iNotesEditorPluginLoader->unload();
    37         iNotepadApi = NULL;
    40         delete iNotesEditorPluginLoader;
       
    41         iNotesEditorPluginLoader = NULL;
    38         }
    42         }
    39  */   
    43         
    40     if(iAgendaUtil)
    44     if(iAgendaUtil)
    41         {
    45         {
    42         delete iAgendaUtil;
    46         delete iAgendaUtil;
    43         iAgendaUtil = NULL;
    47         iAgendaUtil = NULL;
    44         }
    48         }
    70 	*/
    74 	*/
    71 
    75 
    72 void CCreatorNotepadWrapper::ConstructL()
    76 void CCreatorNotepadWrapper::ConstructL()
    73 	{
    77 	{
    74 	iAgendaUtil = new AgendaUtil();
    78 	iAgendaUtil = new AgendaUtil();
    75 //	iNotepadApi = new NotesEditor(iAgendaUtil);
    79 	
       
    80 	//	iNotepadApi = new NotesEditor(iAgendaUtil);
       
    81 	
       
    82 	// Load notes editor plugin.
       
    83     // Launch the notes editor using notes editor plugin api
       
    84     QDir dir(NOTES_EDITOR_PLUGIN_PATH);
       
    85     QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
       
    86 
       
    87     QT_TRYCATCH_LEAVING(
       
    88         // Create NotesEditor plugin loader object.
       
    89         iNotesEditorPluginLoader = new QPluginLoader(pluginName);
       
    90 
       
    91         // Load the plugin
       
    92         bool notesPluginLoaded = iNotesEditorPluginLoader->load();
       
    93         QObject *plugin = qobject_cast<QObject*> ( iNotesEditorPluginLoader->instance());
       
    94 
       
    95         iNotepadApi = qobject_cast<NotesEditorInterface*>(plugin);
       
    96         );
       
    97 
    76 	}
    98 	}
    77 
    99 
    78 TInt CCreatorNotepadWrapper::CreateNoteL( const TDesC& aText )
   100 TInt CCreatorNotepadWrapper::CreateNoteL( const TDesC& aText )
    79 	{
   101 	{
    80 	TInt err = KErrNone;
   102 	User::LeaveIfNull(iNotepadApi);
    81 	QString textNote = QString::fromUtf16( aText.Ptr(),aText.Length());
   103 
       
   104     QString textNote = QString::fromUtf16( aText.Ptr(),aText.Length());
    82     iNotepadApi->edit(textNote,iAgendaUtil);
   105     iNotepadApi->edit(textNote,iAgendaUtil);
    83     iNotepadApi->close(NotesEditorInterface::CloseWithSave, iAgendaUtil);
   106     iNotepadApi->close(NotesEditorInterface::CloseWithSave, iAgendaUtil);
    84 	return err;
   107 	
       
   108     return KErrNone;
    85     }
   109     }
    86 void CCreatorNotepadWrapper::DeleteAllL()
   110 void CCreatorNotepadWrapper::DeleteAllL()
    87 	{
   111 	{
    88 	
   112 	
    89 	QList<AgendaEntry> ael;
   113 	QList<AgendaEntry> ael;