calendarui/agendaeventviewer/src/agendaeventviewer_p.cpp
changeset 45 b6db4fd4947b
parent 23 fd30d51f876b
child 55 2c54b51f39c4
equal deleted inserted replaced
23:fd30d51f876b 45:b6db4fd4947b
    14 * Description: Definition of AgendaEventViewerPrivate class
    14 * Description: Definition of AgendaEventViewerPrivate class
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // System includes.
    18 // System includes.
    19 #include <QDebug>
       
    20 #include <QFile>
    19 #include <QFile>
    21 #include <QDir>
    20 #include <QDir>
    22 
    21 
    23 // User includes.
    22 // User includes.
    24 #include <agendautil.h>
    23 #include <agendautil.h>
    41 	\param agendaUtil Pointer to AgendaUtil.
    40 	\param agendaUtil Pointer to AgendaUtil.
    42 	\param parent Pointer to QObject.
    41 	\param parent Pointer to QObject.
    43  */
    42  */
    44 AgendaEventViewerPrivate::AgendaEventViewerPrivate(
    43 AgendaEventViewerPrivate::AgendaEventViewerPrivate(
    45 		AgendaUtil *agendaUtil, QObject *parent)
    44 		AgendaUtil *agendaUtil, QObject *parent)
    46 : QObject(parent)
    45 : QObject(parent),mShowEventViewById(false),mShowEventViewByFileHandle(false),mFileName(NULL),mAction(AgendaEventViewer::ActionNothing)
    47 {
    46 {
    48 	qDebug() <<"AgendaEventViewerPrivate::AgendaEventViewerPrivate -->";
       
    49 
    47 
    50 	// Get the q-pointer.from parent
    48 	// Get the q-pointer.from parent
    51 	q_ptr = static_cast<AgendaEventViewer *> (parent);
    49 	q_ptr = static_cast<AgendaEventViewer *> (parent);
    52 
    50 
    53 	// Check for agendaUtil sent by client. If null agendaUtil will be
    51 	// Check for agendaUtil sent by client. If null agendaUtil will be
    63 	// Register for the entry change signal when the same entry is updated
    61 	// Register for the entry change signal when the same entry is updated
    64 	// by other application.This is to handle the db conflict changes.
    62 	// by other application.This is to handle the db conflict changes.
    65 	connect(
    63 	connect(
    66 			mAgendaUtil, SIGNAL(entriesChanged(QList<ulong> )),
    64 			mAgendaUtil, SIGNAL(entriesChanged(QList<ulong> )),
    67 			this, SLOT(handleEntriesChanged(QList<ulong> )));
    65 			this, SLOT(handleEntriesChanged(QList<ulong> )));
    68 
    66 	
    69 	qDebug() <<"AgendaEventViewerPrivate::AgendaEventViewerPrivate <--";
    67 	// Register for the calenInstance view creation sucessfully
       
    68 	connect(
       
    69 	        mAgendaUtil, SIGNAL(entryViewCreationCompleted(int)),
       
    70 	        this, SLOT(viewCreationCompleted(int)));
       
    71 
    70 }
    72 }
    71 
    73 
    72 /*!
    74 /*!
    73 	Destructor.
    75 	Destructor.
    74  */
    76  */
    75 AgendaEventViewerPrivate::~AgendaEventViewerPrivate()
    77 AgendaEventViewerPrivate::~AgendaEventViewerPrivate()
    76 {
    78 {
    77 	qDebug() <<"AgendaEventViewerPrivate::~AgendaEventViewerPrivate -->";
       
    78 
    79 
    79 	if (mViewerOwnsAgendaUtil) {
    80 	if (mViewerOwnsAgendaUtil) {
    80 		delete mAgendaUtil;
    81 		delete mAgendaUtil;
    81 		mAgendaUtil = 0;
    82 		mAgendaUtil = 0;
    82 	}
    83 	}
    83 
    84 
    84 	qDebug() <<"AgendaEventViewerPrivate::~AgendaEventViewerPrivate <--";
       
    85 }
    85 }
    86 
    86 
    87 /*!
    87 /*!
    88 	Launches the event viewer.Id is used for fetching
    88 	Launches the event viewer.Id is used for fetching
    89 	the calendar entry information.
    89 	the calendar entry information.
    91 	\param id Local Uid of the calendar entry to be viewed
    91 	\param id Local Uid of the calendar entry to be viewed
    92  */
    92  */
    93 void AgendaEventViewerPrivate::view(const ulong id, 
    93 void AgendaEventViewerPrivate::view(const ulong id, 
    94                                     AgendaEventViewer::Actions action)
    94                                     AgendaEventViewer::Actions action)
    95 {
    95 {
    96 	qDebug() <<"AgendaEventViewerPrivate::view(id) -->";
       
    97 	
    96 	
    98 	AgendaEntry entry = mAgendaUtil->fetchById(id);
    97 	AgendaEntry entry = mAgendaUtil->fetchById(id);
    99 	
    98 	
   100 	if (entry.isNull()) {
    99 	if (entry.isNull()) {
       
   100         // save the entries , to show the entry once instances are created
       
   101         // if entry is null exit ,later  call back comes in viewCreationCompleted 
       
   102 	    mAction = action;
       
   103         mId =id;
       
   104         //to avoid view creation multiple times
       
   105         mShowEventViewById = true;
   101 		return;
   106 		return;
   102 	}
   107 	}
   103 	// Construct the agenda event view
   108 	// Construct the agenda event view
   104 	mAgendaEventView = new AgendaEventView(this);
   109 	mAgendaEventView = new AgendaEventView(this);
   105 	mAgendaEventView->execute(entry, action);
   110 	mAgendaEventView->execute(entry, action);
   106 
   111 
   107 	qDebug() <<"AgendaEventViewerPrivate::view(id) <--";
       
   108 }
   112 }
   109 
   113 
   110 /*!
   114 /*!
   111 	Launches the event viewer.File handle of any vcs/ics
   115 	Launches the event viewer.File handle of any vcs/ics
   112 	file can be given as input to view the calendar entry information.
   116 	file can be given as input to view the calendar entry information.
   114 	\param fileHandle reference to the file handle of vcs/ics file
   118 	\param fileHandle reference to the file handle of vcs/ics file
   115  */
   119  */
   116 void AgendaEventViewerPrivate::view(const QFile &fileHandle, 
   120 void AgendaEventViewerPrivate::view(const QFile &fileHandle, 
   117                                     AgendaEventViewer::Actions action)
   121                                     AgendaEventViewer::Actions action)
   118 {
   122 {
   119 	qDebug() <<"AgendaEventViewerPrivate::view(fileHandle) -->";
       
   120 
   123 
   121 	// Using calendar importer read the filehandle and generate agenda entry
   124 	// Using calendar importer read the filehandle and generate agenda entry
   122 	QString filePath = fileHandle.fileName();
   125 	QString filePath = fileHandle.fileName();
   123 	QString nativeFilePath = QDir::toNativeSeparators(filePath);
   126 	QString nativeFilePath = QDir::toNativeSeparators(filePath);
   124 	AgendaEntry entry;
   127 	AgendaEntry entry;
   125 	mAgendaUtil->importvCalendar(nativeFilePath, entry);
   128 	mAgendaUtil->importvCalendar(nativeFilePath, entry);
   126 	if (!entry.isNull()) {
   129 	if (!entry.isNull()) {
   127 		mAgendaEventView = new AgendaEventView(this);
   130 		mAgendaEventView = new AgendaEventView(this);
   128 		mAgendaEventView->execute(entry, action);
   131 		mAgendaEventView->execute(entry, action);
   129 	}
   132 	} else {
   130 	qDebug() <<"AgendaEventViewerPrivate::view(fileHandle) <--";
   133         //store the file name
       
   134         mFileName = filePath ;
       
   135         mAction = action ;
       
   136         mShowEventViewByFileHandle = true;
       
   137         q_ptr->viewingCompleted(QDateTime::currentDateTime().date());
       
   138 	}
   131 }
   139 }
   132 
   140 
   133 /*!
   141 /*!
   134 	Launches the event viewer.AgendaEntry can be given as input to view the
   142 	Launches the event viewer.AgendaEntry can be given as input to view the
   135 	calendar entry information
   143 	calendar entry information
   136  */
   144  */
   137 void AgendaEventViewerPrivate::view(AgendaEntry entry, 
   145 void AgendaEventViewerPrivate::view(AgendaEntry entry, 
   138                                     AgendaEventViewer::Actions action)
   146                                     AgendaEventViewer::Actions action)
   139 {
   147 {
   140 	qDebug() <<"AgendaEventViewerPrivate::view(entry) -->";
       
   141 
   148 
   142 	if (entry.isNull()) {
   149 	if (entry.isNull()) {
   143 			return;
   150 			return;
   144 		}
   151 		}
   145 	// Construct the agenda event view
   152 	// Construct the agenda event view
   146 	mAgendaEventView = new AgendaEventView(this);
   153 	mAgendaEventView = new AgendaEventView(this);
   147 	mAgendaEventView->execute(entry, action);
   154 	mAgendaEventView->execute(entry, action);
   148 
   155 
   149 	qDebug() <<"AgendaEventViewerPrivate::view(entry) <--";
       
   150 }
   156 }
   151 
   157 
   152 /*!
   158 /*!
   153 	Emits the signal viewing completed to the clients
   159 	Emits the signal viewing completed to the clients
   154 
   160 
   155 	\param status true if viewing completed otherwise false.
   161 	\param status true if viewing completed otherwise false.
   156  */
   162  */
   157 void AgendaEventViewerPrivate::viewingCompleted(const QDate date)
   163 void AgendaEventViewerPrivate::viewingCompleted(const QDate date)
   158 {
   164 {
   159 	qDebug() <<"AgendaEventViewerPrivate::viewingCompleted -->";
       
   160 
   165 
   161 	emit q_ptr->viewingCompleted(date);
   166 	emit q_ptr->viewingCompleted(date);
   162 
   167 
   163 	// Cleanup viewer.
   168 	// Cleanup viewer.
   164 	if (mAgendaEventView) {
   169 	if (mAgendaEventView) {
   165 		mAgendaEventView->deleteLater();
   170 		mAgendaEventView->deleteLater();
   166 	}
   171 	}
   167 
   172 
   168 	qDebug() <<"AgendaEventViewerPrivate::viewingCompleted -->";
       
   169 }
   173 }
   170 
   174 
   171 /*!
   175 /*!
   172 	Emits the signal editing started to the clients
   176 	Emits the signal editing started to the clients
   173  */
   177  */
   174 void AgendaEventViewerPrivate::editingStarted()
   178 void AgendaEventViewerPrivate::editingStarted()
   175 {
   179 {
   176 	qDebug() <<"AgendaEventViewerPrivate::editingStarted -->";
       
   177 
   180 
   178 	emit q_ptr->editingStarted();
   181 	emit q_ptr->editingStarted();
   179 
   182 
   180 	qDebug() <<"AgendaEventViewerPrivate::editingStarted -->";
       
   181 }
   183 }
   182 
   184 
   183 /*!
   185 /*!
   184 	Emits the signal editing completed to the clients
   186 	Emits the signal editing completed to the clients
   185  */
   187  */
   186 void AgendaEventViewerPrivate::editingCompleted()
   188 void AgendaEventViewerPrivate::editingCompleted()
   187 {
   189 {
   188 	qDebug() <<"AgendaEventViewerPrivate::editingCompleted -->";
       
   189 
   190 
   190 	emit q_ptr->editingCompleted();
   191 	emit q_ptr->editingCompleted();
   191 
   192 
   192 	qDebug() <<"AgendaEventViewerPrivate::editingCompleted -->";
       
   193 }
   193 }
   194 
   194 
   195 /*!
   195 /*!
   196 	Emits the signal deleting started to the clients
   196 	Emits the signal deleting started to the clients
   197  */
   197  */
   198 void AgendaEventViewerPrivate::deletingStarted()
   198 void AgendaEventViewerPrivate::deletingStarted()
   199 {
   199 {
   200 	qDebug() <<"AgendaEventViewerPrivate::deletingStarted -->";
       
   201 
   200 
   202 	emit q_ptr->deletingStarted();
   201 	emit q_ptr->deletingStarted();
   203 
   202 
   204 	qDebug() <<"AgendaEventViewerPrivate::deletingStarted -->";
       
   205 }
   203 }
   206 
   204 
   207 /*!
   205 /*!
   208 	Emits the signal deleting completed to the clients
   206 	Emits the signal deleting completed to the clients
   209  */
   207  */
   210 void AgendaEventViewerPrivate::deletingCompleted()
   208 void AgendaEventViewerPrivate::deletingCompleted()
   211 {
   209 {
   212 	qDebug() <<"AgendaEventViewerPrivate::deletingCompleted -->";
       
   213 
   210 
   214 	emit q_ptr->deletingCompleted();
   211 	emit q_ptr->deletingCompleted();
   215 
   212 
   216 	qDebug() <<"AgendaEventViewerPrivate::deletingCompleted -->";
   213 }
   217 }
   214 
   218 
   215 
       
   216 /*!
       
   217      calls when instances of calenInstanceview and 
       
   218      entryInstanceview is created successfully
       
   219  */
       
   220 void AgendaEventViewerPrivate::viewCreationCompleted(int error)
       
   221     {
       
   222     
       
   223     if((KErrNone == error))
       
   224         {
       
   225         AgendaEntry entry;
       
   226         if (mShowEventViewById)
       
   227             {
       
   228             entry = mAgendaUtil->fetchById(mId);
       
   229             }
       
   230         else if(mShowEventViewByFileHandle)
       
   231             {
       
   232             QString nativeFilePath = QDir::toNativeSeparators(mFileName);
       
   233             mAgendaUtil->importvCalendar(nativeFilePath, entry);
       
   234             }
       
   235         //if entry is there , then show the view
       
   236         if (!entry.isNull()) 
       
   237             {
       
   238             mAgendaEventView = new AgendaEventView(this);
       
   239             mAgendaEventView->execute(entry, mAction);
       
   240             }
       
   241         }      
       
   242     //reset the variables
       
   243     mId = 0;
       
   244     mFileName.clear();
       
   245     mShowEventViewById = false;
       
   246     mShowEventViewByFileHandle = false;
       
   247     mAction = AgendaEventViewer::ActionNothing;
       
   248 	}
   219 // End of file
   249 // End of file