calendarui/caleneditor/src/caleneditor_p.cpp
changeset 75 7ac58b2aae6f
parent 70 a5ed90760192
child 83 5aadd1120515
equal deleted inserted replaced
72:27feeedec790 75:7ac58b2aae6f
    18 // System includes
    18 // System includes
    19 #include <QObject>
    19 #include <QObject>
    20 #include <QTimer>
    20 #include <QTimer>
    21 #include <QGraphicsLinearLayout>
    21 #include <QGraphicsLinearLayout>
    22 #include <QApplication>
    22 #include <QApplication>
       
    23 
       
    24 #include <bacntf.h>                   // CEnvironmentChangeNotifier
       
    25 #include <coemain.h>                  // EActivePriorityLogonA
    23 
    26 
    24 #include <hbdataform.h>
    27 #include <hbdataform.h>
    25 #include <hbmainwindow.h>
    28 #include <hbmainwindow.h>
    26 #include <hbinstance.h>
    29 #include <hbinstance.h>
    27 #include <hbdataformmodel.h>
    30 #include <hbdataformmodel.h>
   231 		mOwnsAgendaUtil = true;
   234 		mOwnsAgendaUtil = true;
   232 	} else {
   235 	} else {
   233 		mAgendaUtil = agendaUtil;
   236 		mAgendaUtil = agendaUtil;
   234 		mOwnsAgendaUtil = false;
   237 		mOwnsAgendaUtil = false;
   235 	}
   238 	}
       
   239 
       
   240 	// Register for system environment changes
       
   241 	// TODO: these are temporary changes done in symbian way
       
   242 	// till we get proper QT support to listem for locale changes
       
   243 	TCallBack envCallback( EnvChangeCallbackL, this );
       
   244 	iEnvChangeNotifier =
       
   245 			CEnvironmentChangeNotifier::NewL( EActivePriorityLogonA, envCallback );
       
   246 	iEnvChangeNotifier->Start();
       
   247 	iIgnoreFirstLocaleChange = ETrue;
       
   248 	
   236 	OstTraceFunctionExit0( CALENEDITORPRIVATE_CALENEDITORPRIVATE_EXIT );
   249 	OstTraceFunctionExit0( CALENEDITORPRIVATE_CALENEDITORPRIVATE_EXIT );
   237 }
   250 }
   238 
   251 
   239 /*!
   252 /*!
   240 	Destructor.
   253 	Destructor.
   283 	// delete the mainwindow object if created any
   296 	// delete the mainwindow object if created any
   284 	if (mMainWindow) {
   297 	if (mMainWindow) {
   285 		delete mMainWindow;
   298 		delete mMainWindow;
   286 		mMainWindow = 0;
   299 		mMainWindow = 0;
   287 	}
   300 	}
       
   301 
       
   302 	if(iEnvChangeNotifier) {
       
   303 		iEnvChangeNotifier->Cancel();
       
   304 		delete iEnvChangeNotifier;
       
   305 		iEnvChangeNotifier = 0;
       
   306 	}
       
   307 	
   288 	OstTraceFunctionExit0( DUP1_CALENEDITORPRIVATE_CALENEDITORPRIVATE_EXIT );
   308 	OstTraceFunctionExit0( DUP1_CALENEDITORPRIVATE_CALENEDITORPRIVATE_EXIT );
   289 }
   309 }
   290 
   310 
   291 /*!
   311 /*!
   292 	Shows the caleneditor by parsing a .vcs.
   312 	Shows the caleneditor by parsing a .vcs.
   554 	HbGroupBox *headingWidget = qobject_cast<HbGroupBox *> (
   574 	HbGroupBox *headingWidget = qobject_cast<HbGroupBox *> (
   555 							mEditorDocLoader->findWidget(CALEN_EDITOR_HEADING));
   575 							mEditorDocLoader->findWidget(CALEN_EDITOR_HEADING));
   556 
   576 
   557 	mCalenEditorForm = qobject_cast<HbDataForm *> (
   577 	mCalenEditorForm = qobject_cast<HbDataForm *> (
   558 							mEditorDocLoader->findWidget(CALEN_EDITOR_DATAFORM));
   578 							mEditorDocLoader->findWidget(CALEN_EDITOR_DATAFORM));
   559 
   579 	
       
   580     // Enable the pixmap cache for better scrolling performance
       
   581 	mCalenEditorForm->setItemPixmapCacheEnabled(true);
       
   582 	    
   560 	mDescriptionAction = qobject_cast<HbAction *> (
   583 	mDescriptionAction = qobject_cast<HbAction *> (
   561 							mEditorDocLoader->findObject(
   584 							mEditorDocLoader->findObject(
   562 										CALEN_EDITOR_ADD_DESCRIPTION_ACTION));
   585 										CALEN_EDITOR_ADD_DESCRIPTION_ACTION));
   563 
   586 
   564 	if (mDescriptionItemAdded) {
   587 	if (mDescriptionItemAdded) {
  1805 	OstTraceFunctionExit0( DUP3_CALENEDITORPRIVATE_HANDLEDONE_EXIT );
  1828 	OstTraceFunctionExit0( DUP3_CALENEDITORPRIVATE_HANDLEDONE_EXIT );
  1806 	return CalenEditorPrivate::ActionNothing;
  1829 	return CalenEditorPrivate::ActionNothing;
  1807 }
  1830 }
  1808 
  1831 
  1809 /*!
  1832 /*!
       
  1833 	Launch the notification dialog popup.
       
  1834  */
       
  1835 void CalenEditorPrivate::launchDialog(QString title)
       
  1836 {
       
  1837 	OstTraceFunctionEntry0( CALENEDITORPRIVATE_LAUNCHDIALOG_ENTRY );
       
  1838 	HbNotificationDialog *notificationDialog = new HbNotificationDialog();
       
  1839 	notificationDialog->setTitle(title);
       
  1840 	notificationDialog->setTimeout(HbPopup::ConfirmationNoteTimeout);
       
  1841 	notificationDialog->show();
       
  1842 	OstTraceFunctionExit0( CALENEDITORPRIVATE_LAUNCHDIALOG_EXIT );
       
  1843 }
       
  1844 /*!
  1810 	Save the entry
  1845 	Save the entry
  1811 	\return true if entry is saved ,false otherwise
  1846 	\return true if entry is saved ,false otherwise
  1812  */
  1847  */
  1813 bool CalenEditorPrivate::saveEntry()
  1848 bool CalenEditorPrivate::saveEntry()
  1814 {
  1849 {
  1824 			mAgendaUtil->store(*mEditedEntry);
  1859 			mAgendaUtil->store(*mEditedEntry);
  1825 		}
  1860 		}
  1826 	}
  1861 	}
  1827 	if (mNewEntry) {
  1862 	if (mNewEntry) {
  1828 		if(mEditedEntry->type() == AgendaEntry::TypeAppoinment) {
  1863 		if(mEditedEntry->type() == AgendaEntry::TypeAppoinment) {
  1829 			HbNotificationDialog::launchDialog(hbTrId("txt_calendar_dpopinfo_new_meeting_saved"));
  1864 			launchDialog(hbTrId("txt_calendar_dpopinfo_new_meeting_saved"));
  1830 		} else if(isAllDayEvent()) {
  1865 		} else if(isAllDayEvent()) {
  1831 			HbNotificationDialog::launchDialog(hbTrId("txt_calendar_dpopinfo_new_all_day_event_saved"));
  1866 			launchDialog(hbTrId("txt_calendar_dpopinfo_new_all_day_event_saved"));
  1832 		}
  1867 		}
  1833 	} else {
  1868 	} else {
  1834 		if(mEditedEntry->type() == AgendaEntry::TypeAppoinment) {
  1869 		if(mEditedEntry->type() == AgendaEntry::TypeAppoinment) {
  1835 			HbNotificationDialog::launchDialog(hbTrId("txt_calendar_dpopinfo_meeting_updated"));
  1870 			launchDialog(hbTrId("txt_calendar_dpopinfo_meeting_updated"));
  1836 		} else if(isAllDayEvent()) {
  1871 		} else if(isAllDayEvent()) {
  1837 			HbNotificationDialog::launchDialog(hbTrId("txt_calendar_dpopinfo_all_day_event_updated"));
  1872 			launchDialog(hbTrId("txt_calendar_dpopinfo_all_day_event_updated"));
  1838 		}
  1873 		}
  1839 	}
  1874 	}
  1840 	emit q_ptr->entrySaved();
  1875 	emit q_ptr->entrySaved();
  1841 	OstTraceFunctionExit0( DUP2_CALENEDITORPRIVATE_SAVEENTRY_EXIT );
  1876 	OstTraceFunctionExit0( DUP2_CALENEDITORPRIVATE_SAVEENTRY_EXIT );
  1842 	return true;
  1877 	return true;
  2114     	// this else case will get executed
  2149     	// this else case will get executed
  2115     	emit q_ptr->dialogClosed();
  2150     	emit q_ptr->dialogClosed();
  2116     }
  2151     }
  2117     OstTraceFunctionExit0( CALENEDITORPRIVATE_FORCEDSAVEENTRY_EXIT );
  2152     OstTraceFunctionExit0( CALENEDITORPRIVATE_FORCEDSAVEENTRY_EXIT );
  2118 }
  2153 }
       
  2154 
       
  2155 
       
  2156 // ----------------------------------------------------------------------------
       
  2157 //  CCalenNotifier::EnvChangeCallbackL
       
  2158 //  CEnvironmentChangeNotifier callback.  Calendar is only interested in:
       
  2159 //  EChangesLocale              - System locale changed
       
  2160 //  EChangesMidnightCrossover   - System time passed midnight
       
  2161 //  EChangesSystemTime          - System time changed
       
  2162 // (other items were commented in a header).
       
  2163 // ----------------------------------------------------------------------------
       
  2164 //
       
  2165 TInt CalenEditorPrivate::EnvChangeCallbackL( TAny* aThisPtr )
       
  2166 {
       
  2167     // Return value for functions used as TCallBack objects should be EFalse
       
  2168     // unless the function is intended to be called again from a timer.
       
  2169    // return EFalse;
       
  2170     return static_cast<CalenEditorPrivate*>(aThisPtr)->DoEnvChange();
       
  2171 }
       
  2172 // ----------------------------------------------------------------------------
       
  2173 //  CCalenNotifier::DoEnvChange
       
  2174 //  EnvChangeCallbackL calls this function
       
  2175 // ----------------------------------------------------------------------------
       
  2176 //
       
  2177 TInt CalenEditorPrivate::DoEnvChange()
       
  2178 {
       
  2179     if( iEnvChangeNotifier && (iEnvChangeNotifier->Change() & EChangesLocale)
       
  2180             && !iIgnoreFirstLocaleChange) {
       
  2181         mViewFromItem->populateDateTime(mEditedEntry->startTime(), true);
       
  2182         mViewToItem->populateDateTime(mEditedEntry->endTime(), false);
       
  2183         if (isAllDayEvent()) {
       
  2184         	mReminderField->setDisplayTime();
       
  2185         }
       
  2186         if (mRepeatField->isRepeatUntilItemAdded()) {
       
  2187         	mRepeatField->refreshRepeatUntilDate();
       
  2188         }
       
  2189     }
       
  2190     else {
       
  2191         iIgnoreFirstLocaleChange = EFalse;
       
  2192     }
       
  2193     return EFalse ;
       
  2194 }
       
  2195 
  2119 // End of file	--Don't remove this.
  2196 // End of file	--Don't remove this.