clock/ftudatetimewizard/src/ftudatetimewizard.cpp
changeset 18 c198609911f9
child 23 fd30d51f876b
equal deleted inserted replaced
0:f979ecb2b13e 18:c198609911f9
       
     1 /*
       
     2  * Copyright (c) 2009 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 // System includes
       
    19 #include <QGraphicsLayout>
       
    20 #include <centralrepository.h>
       
    21 #include <xqsettingsmanager.h>
       
    22 #include <xqsettingskey.h>
       
    23 // User includes
       
    24 #include "ftudatetimewizard.h"
       
    25 #include "ftudatetimeview.h"
       
    26 #include "ftudatetimeprivatecrkeys.h"
       
    27 
       
    28 static const char* dateTimeTitle = "Date and Time";
       
    29 static const char* dateTimeInfoText = "Set your Date Time and Location";
       
    30 static const char* dateTimeStripIcon =
       
    31 		":/images/ftudatetimewizard_menustrip_icon.svg";
       
    32 static const char* dateTimeTocIcon = ":/images/ftudatetimewizard_toc_icon.svg";
       
    33 
       
    34 /*!
       
    35     \class FtuDateTimeWizard
       
    36     This is the FTU Date time plugin wizard
       
    37  */
       
    38 
       
    39 /*!
       
    40     Constructor.
       
    41  */
       
    42 FtuDateTimeWizard::FtuDateTimeWizard()
       
    43 {
       
    44 	// Set up wizard settings 
       
    45 	mWizardSettings.mMenustripDefaultIcon = QFileInfo(dateTimeStripIcon);
       
    46 	mWizardSettings.mMenustripPressedIcon = QFileInfo(dateTimeStripIcon);
       
    47 	mWizardSettings.mMenustripFocussedIcon = QFileInfo(dateTimeStripIcon);
       
    48 	mWizardSettings.mMenustripLabel = tr(dateTimeTitle);
       
    49 
       
    50 	mWizardSettings.mTocDefaultIcon = QFileInfo(dateTimeTocIcon);
       
    51 	mWizardSettings.mTocPressedIcon = QFileInfo(dateTimeTocIcon);
       
    52 	mWizardSettings.mTocFocussedIcon = QFileInfo(dateTimeTocIcon);
       
    53 	mWizardSettings.mTocLabel = tr(dateTimeTitle);
       
    54 }
       
    55 
       
    56 /*!
       
    57     Destructor.
       
    58  */
       
    59 FtuDateTimeWizard::~FtuDateTimeWizard()
       
    60 {
       
    61 	//delete mWizardSettings;
       
    62 }
       
    63 
       
    64 /*!
       
    65     Initialises the wizard.This is called by the FTU framework
       
    66  */
       
    67 void FtuDateTimeWizard::initializeWizard()
       
    68 {
       
    69 	//Check if valid Nitz info is received
       
    70 	XQSettingsManager *settingsManager = new XQSettingsManager();
       
    71 	XQSettingsKey *validNitzCenrepKey = 
       
    72 			new XQSettingsKey(XQSettingsKey::TargetCentralRepository, KCRUidNitz, KValidNitz);
       
    73 	// Read the initial values from the cenrep
       
    74 	int validNitz = settingsManager->readItemValue(*validNitzCenrepKey).toInt();
       
    75 
       
    76 	//Clean up
       
    77 	delete validNitzCenrepKey;
       
    78 	delete settingsManager;
       
    79 
       
    80 	// The plugin will be loaded only if valid Nitz info is not received
       
    81 	if(validNitz == 0) {
       
    82 		// Set up view
       
    83 		if (mFtuDateTimeView == NULL) {
       
    84 			mFtuDateTimeView = new FtuDateTimeView();
       
    85 			mFtuDateTimeView->setAutomaticTimeUpdateOff(false);
       
    86 		}
       
    87 		// If our main view is not created, signal with false.
       
    88 		emit wizardInitialized(this, ((mFtuDateTimeView) ? true: false));
       
    89 	}
       
    90 	else {
       
    91 		emit wizardInitialized(this, false);
       
    92 	}
       
    93 }
       
    94 
       
    95 /*!
       
    96     Activates the wizard.
       
    97     Is called by the FTU framework when wizard becomes the current wizard
       
    98  */
       
    99 void FtuDateTimeWizard::activateWizard()
       
   100 {
       
   101 	mFtuDateTimeView->constructView();
       
   102 	// Signal info text to FTU framework
       
   103 	emit
       
   104 	infoTextUpdated(this, tr(dateTimeInfoText));
       
   105 
       
   106 	// Signal view change
       
   107 	emit viewChanged(this, mFtuDateTimeView);
       
   108 }
       
   109 
       
   110 /*!
       
   111     Deactivates the wizard.Is called by FTU framework when wizard is no longer displayed.
       
   112     Frees up resources that need not persist between wizard plugin activations.
       
   113  */
       
   114 void FtuDateTimeWizard::deactivateWizard()
       
   115 {
       
   116 	// Destroy everything but the initial view and data that takes a long time
       
   117 	// to reacquire when the plugin is later re-activated.
       
   118 }
       
   119 
       
   120 /*!
       
   121     Notifies the FTU FW how the wizard is been shutdown.
       
   122     Its called by FTU framework before the wizard plugin destructor is called.
       
   123     /param reason for the ShutDown
       
   124  */
       
   125 bool FtuDateTimeWizard::shutdownWizard(FtuWizard::ShutdownReason reason)
       
   126 {
       
   127 	// Destroy all views
       
   128 	Q_UNUSED(reason);
       
   129 	return true;
       
   130 }
       
   131 
       
   132 /*!
       
   133     Relayoutes the views for new size.
       
   134     /param geometry
       
   135  */
       
   136 void FtuDateTimeWizard::resizeWizard(const QRectF& geometry)
       
   137 {
       
   138 	Q_UNUSED(geometry)
       
   139 	// Relayout view for new size   
       
   140 }
       
   141 
       
   142 /*!
       
   143     Returns the settings for FTU framework.
       
   144  */
       
   145 const FtuWizardSetting& FtuDateTimeWizard::wizardSettings()
       
   146 {
       
   147 	return mWizardSettings;
       
   148 }
       
   149 
       
   150 /*!
       
   151     Handles the back event.
       
   152  */
       
   153 bool FtuDateTimeWizard::handleBackEvent()
       
   154 {
       
   155 	return false;
       
   156 }
       
   157 
       
   158 /*!
       
   159     Returns the wizard completed date.
       
   160  */
       
   161 QDate FtuDateTimeWizard::wizardCompletedDate()
       
   162 {
       
   163 	return (mFtuDateTimeView->getWizardCompletedDate());
       
   164 }
       
   165 
       
   166 // End of file  --Don't remove this.