⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 settingdlg.cpp

📁 手机天气预报系统
💻 CPP
字号:
/*
 ============================================================================
 Name		: SettingDlg.cpp
 Author	  : Richie Chyi
 Copyright   : Copyright?2008
 Description : Setting class implementation
 ============================================================================
 */

#include <eikedwin.h> 
#include <aknpopupfieldtext.h> 
#include <eikmfne.h>
#include <QiQiWeather_0xE6E51F33.rsg>

#include "SettingDlg.h"
#include "QiQiWeather.hrh"
#include "Setting.h"
#include "WeatherShow.h"

TInt CSettingDlg::RunDlgLD()
	{
	CSettingDlg* dlg = CSettingDlg::NewL();
	return dlg->ExecuteLD(R_SETTING_DLG);
	}

CSettingDlg* CSettingDlg::NewL()
	{
	CSettingDlg* self = new (ELeave) CSettingDlg;
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop(self);
	
	return self;
	}

CSettingDlg::CSettingDlg()
	{
	
	}

void CSettingDlg::ConstructL()
	{
	//CAknDialog::ConstructL();
	}

void CSettingDlg::PreLayoutDynInitL()
	{
	CAknForm::PreLayoutDynInitL();
	
	// 读取设置
	CSetting* setting = CSetting::NewLC();
	setting->ReadFromFileL();
	
	CAknPopupFieldText* popup = 
			static_cast<CAknPopupFieldText*>(ControlOrNull(ECitySettingField));
	if (popup)
		{
		popup->SetCurrentValueIndex(setting->CityIndex());
		popup->SetFocus(ETrue);
		}
	
	CEikTimeEditor* timeEditor =
			static_cast<CEikTimeEditor*>(ControlOrNull(ETimeSettingField));
	if (timeEditor)
		{
		TDateTime dateTime;
		dateTime.SetHour(setting->Hour());
		dateTime.SetMinute(setting->Minute());
		
		TTime time(dateTime);
		timeEditor->SetTime(time);
		}
	
	CleanupStack::PopAndDestroy(setting);
	}

TBool CSettingDlg::OkToExitL(TInt /*aButtonId*/)
	{
	TInt city = 0;
	TInt hour = 0;
	TInt minute = 0;
	
	CAknPopupFieldText* popup = 
			static_cast<CAknPopupFieldText*>(ControlOrNull(ECitySettingField));
	if (popup)
		{
		city = popup->CurrentValueIndex();
		}
	
	CEikTimeEditor* timeEditor =
			static_cast<CEikTimeEditor*>(ControlOrNull(ETimeSettingField));
	if (timeEditor)
		{
		TTime time = timeEditor->Time();
		
		TDateTime dateTime = time.DateTime();
		hour = dateTime.Hour();
		minute = dateTime.Minute();
		}
	
	// 保存配置
	CSetting* setting = CSetting::NewLC();
	setting->ReadFromFileL();
	
	TInt oldCityIndex = setting->CityIndex();
	
	setting->SetCityIndex(city);
	setting->SetHour(hour);
	setting->SetMinute(minute);
	
	setting->SaveToFileL();
	
	CleanupStack::PopAndDestroy(setting);
	
	// 如果城市设置改变,则立即请求新设置的天气情况
	if(city != oldCityIndex)
		{
		CWeatherShow* weatherShow = CWeatherShow::NewLC();
		weatherShow->ShowWeatherL();
		CleanupStack::PopAndDestroy(weatherShow);
		}
	
	return ETrue;
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -