📄 griddemoappui.cpp
字号:
file.Size(size);
size = size/ TSmokeUser::Size();
for(TInt i=0; i<size; i++)
{
TSmokeUser* user = new (ELeave) TSmokeUser;
ReadBuf(file, user->iNo);
ReadBuf(file, user->iName);
ReadBuf(file, user->iPhone);
ReadBuf(file, user->iUserName);
ReadBuf(file, user->iUserPhone);
ReadBuf(file, user->iAddress);
ReadBuf(file, user->iArea);
ReadBuf(file, user->iUserOper);
ReadBuf(file, user->iUserType);
ReadBuf(file, user->iPersons);
ReadBuf(file, user->iIdentifyNo);
ReadBuf(file, user->iServArea);
ReadBuf(file, user->iPath);
ReadBuf(file, user->iMgrName);
ReadBuf(file, user->iMgrPhone);
ReadBuf(file, user->iHuguanName);
ReadBuf(file, user->iHuguanPhone);
ReadBuf(file, user->iSendName);
ReadBuf(file, user->iSendPhone);
ReadBuf(file, user->iData);
ReadBuf(file, user->iSepLine);
iSmokeUsers.Append(user);
}
CleanupStack::PopAndDestroy(); // Close file
}
TSmokeUser* CGridDemoAppUi::SelectUser()
{
TSmokeUser* user = NULL;
CDesCArray* userArray = new (ELeave) CDesCArrayFlat(10);
TBuf<128> buf;
for(TInt i=0; i<iSmokeUsers.Count(); i++)
{
buf.Zero();
buf.AppendFormat(_L("\t%S(%S)"), &iSmokeUsers[i]->iNo, &iSmokeUsers[i]->iName);
userArray->AppendL(buf);
}
MDesCArray* userList = STATIC_CAST(MDesCArray*, userArray);
TInt index(0);
CAknSelectionListDialog* dialog = CAknSelectionListDialog::NewL(index, userList, 0);
dialog->PrepareLC (R_LISTSELECT_DIALOG);
if (dialog->RunLD ())
{
user = iSmokeUsers[index];
}
userArray->Reset();
delete userArray;
return user;
}
void CGridDemoAppUi::LoadSmokeType()
{
TBuf<256> filename;
filename = KSmokeTypeFile;
CompleteWithDataPath(filename);
if(!BaflUtils::FileExists(iFs, filename))
{
ShowInformationNoteL(_L("no found smoketype.dat"));
return;
}
RFile file;
User::LeaveIfError(file.Open(iFs, filename, EFileRead));
CleanupClosePushL(file);
TInt size = 0;
file.Size(size);
size = size / TSmokeType::Size();
for(TInt i=0; i<size; i++)
{
TSmokeType* type = new (ELeave) TSmokeType;
ReadBuf(file, type->iCode);
ReadBuf(file, type->iType);
ReadBuf(file, type->iName);
ReadBuf(file, type->iPrice1);
ReadBuf(file, type->iPrice2);
ReadBuf(file, type->iData);
ReadBuf(file, type->iSepLine);
iSmokeTypes.Append(type);
}
CleanupStack::PopAndDestroy(); // Close file
}
TSmokeType* CGridDemoAppUi::SelectSmoke()
{
TSmokeType* type = NULL;
CDesCArray* typeArray = new (ELeave) CDesCArrayFlat(10);
TBuf<128> buf;
for(TInt i=0; i<iSmokeTypes.Count(); i++)
{
buf.Zero();
buf.AppendFormat(_L("\t%S(%S)"), &iSmokeTypes[i]->iCode, &iSmokeTypes[i]->iName);
typeArray->AppendL(buf);
}
MDesCArray* typeList = STATIC_CAST(MDesCArray*, typeArray);
TInt index(0);
CAknSelectionListDialog* dialog = CAknSelectionListDialog::NewL(index, typeList, 0);
dialog->PrepareLC (R_LISTSELECT_DIALOG);
if (dialog->RunLD ())
{
type = iSmokeTypes[index];
}
typeArray->Reset();
delete typeArray;
return type;
}
void CGridDemoAppUi::LoadSmokeInfo()
{
TBuf<256> filename;
filename = KSmokeInfoFile;
CompleteWithDataPath(filename);
if(!BaflUtils::FileExists(iFs, filename))
{
ShowInformationNoteL(_L("no found smokeinfo.dat"));
return;
}
RFile file;
User::LeaveIfError(file.Open(iFs, filename, EFileRead));
CleanupClosePushL(file);
TInt size = 0;
file.Size(size);
size = size / TSmokeInfo::Size();
for(TInt i=0; i<size; i++)
{
TSmokeInfo* info = new (ELeave) TSmokeInfo;
ReadBuf(file, info->iCode);
ReadBuf(file, info->iNumb);
ReadBuf(file, info->iSepLine);
iSmokeInfos.Append(info);
}
CleanupStack::PopAndDestroy(); // Close file
}
void CGridDemoAppUi::CreateIndex(TBool aIsAll)
{
if(!iCreater)
{
iCreater = CCreateIndex::NewL(iFs, *this);
}
iCreater->CreateExistsIndex(aIsAll);
TBuf<32> buf;
iEikonEnv->ReadResource(buf, R_PROGRESS_TEXT);
ShowProgressDialog(buf , iCreater->ProgressCount() + 1);
iCreater->Start();
}
void CGridDemoAppUi::ReadBuf(RFile& aFile, TDes& aBuf)
{
TBuf8<512> buf;
aFile.Read(buf, aBuf.MaxLength());
Gb23122Unicode(aBuf, buf);
aBuf.Trim();
}
void CGridDemoAppUi::Gb23122Unicode(TDes& aBuf, const TDesC8& aData)
{
TInt state = CCnvCharacterSetConverter::KStateDefault;
converter->ConvertToUnicode( aBuf, aData, state );
}
void CGridDemoAppUi::Unicode2Gb2312(TDes8& aBuf, const TDesC& aData)
{
converter->ConvertFromUnicode(aBuf, aData);
}
void CGridDemoAppUi::CompleteWithDataPath(TDes& aPath)
{
if(aPath.Length() < 4)
return;
if(aPath[1] == ':')
return;
aPath.Insert(0, KDefaultDataFolder);
#ifdef __WINS__
aPath[0] = 'C';
#endif
}
void CGridDemoAppUi::ShowInformationNoteL(TInt aResBuf)
{
HBufC* noteText = CCoeEnv::Static()->AllocReadResourceLC(aResBuf);
ShowInformationNoteL(*noteText);
CleanupStack::PopAndDestroy(noteText); // noteText
}
void CGridDemoAppUi::ShowInformationNoteL(const TDesC& aText)
{
CAknInformationNote* infoNote = new(ELeave) CAknInformationNote;
infoNote->ExecuteLD(aText);
}
TInt CGridDemoAppUi::ShowListQueryL(const TDesC& aTitle, MDesCArray* aDesArray)
{
CAknListQueryDialog* dlg;
TInt index = 0;
dlg = new( ELeave ) CAknListQueryDialog( &index );
dlg->PrepareLC(R_QUERY_LIST);
dlg->QueryHeading()->SetTextL(aTitle);
dlg->SetItemTextArray(aDesArray);
dlg->SetOwnershipType(ELbmDoesNotOwnItemArray); //
TInt answer( dlg->RunLD() );
if ( answer )
return index;
else
return -1;
}
TInt CGridDemoAppUi::ShowMessageQueryDialog(const TDesC& aTitle, TDesC& aMessage)
{
CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(aMessage);
dlg->PrepareLC(R_AVKON_MESSAGE_QUERY_DIALOG);
dlg->QueryHeading()->SetTextL(aTitle);
return dlg->RunLD();
}
TInt CGridDemoAppUi::ShowInputDlalogL(TDes& aTextInput, TDesC& aPrompt, TBool aNumber, TInt aMaxLen /* = 0 */)
{
CAknTextQueryDialog* dlg = new(ELeave)CAknTextQueryDialog(aTextInput, aPrompt, CAknQueryDialog::ENoTone );
CleanupStack::PushL(dlg);
if(aMaxLen)
dlg->SetMaxLength(aMaxLen);
TInt answer;
if(aNumber)
answer = dlg->ExecuteLD(R_QUERY_NUMBER_DIALOG);
else
answer = dlg->ExecuteLD(R_QUERY_TEXT_DIALOG);
CleanupStack::Pop();
return answer;
}
void CGridDemoAppUi::SetNavigationLabelL(TInt aRes)
{
HBufC* text = iEikonEnv->AllocReadResourceL(aRes) ;
if(text)
SetNavigationLabelL(*text);
delete text;
}
void CGridDemoAppUi::SetNavigationLabelL(const TDesC& aText)
{
TUid naviPaneUid;
naviPaneUid.iUid = EEikStatusPaneUidNavi;
CEikStatusPane* statusPane = StatusPane();
CEikStatusPaneBase::TPaneCapabilities subPane = statusPane->PaneCapabilities(naviPaneUid);
if(subPane.IsPresent() && subPane.IsAppOwned())
{
CAknNavigationControlContainer* naviPane =
(CAknNavigationControlContainer *) statusPane->ControlL(naviPaneUid);
if(iNaviDecorator)
{
naviPane->Pop(iNaviDecorator);
delete iNaviDecorator;
iNaviDecorator = NULL;
}
if(aText.Length() > 0)
{
iNaviDecorator = naviPane->CreateNavigationLabelL(aText);
naviPane->PushL(*iNaviDecorator);
}
else
{
naviPane->PushDefaultL();
}
}
}
void CGridDemoAppUi::SetStatusPaneTitleL(const TDesC& aTitle)
{
TUid titlePaneUid;
titlePaneUid.iUid = EEikStatusPaneUidTitle;
CEikStatusPane* statusPane = StatusPane();
CEikStatusPaneBase::TPaneCapabilities subPane =
statusPane->PaneCapabilities(titlePaneUid);
// if we can access the title pane
if (subPane.IsPresent() && subPane.IsAppOwned())
{
CAknTitlePane* titlePane = (CAknTitlePane*) statusPane->ControlL(titlePaneUid);
// set the title pane's text
titlePane->SetTextL(aTitle);
}
}
void CGridDemoAppUi::ShowProgressDialog(const TDesC& aText, TInt aFinalValue)
{
if(!iProgressDialog)
{
iProgressDialog = new (ELeave) CAknProgressDialog (reinterpret_cast<CEikDialog**>(&iProgressDialog),ETrue);
iProgressDialog->PrepareLC(R_UPLOAD_PROGRESS);
iProgressDialog->SetTextL(aText);
iProgressDialog->SetCallback (this);
iProgressDialog->RunLD();
}
CEikProgressInfo* progressBar = iProgressDialog->GetProgressInfoL(); // not taking ownership
progressBar->SetFinalValue(aFinalValue); // Set final value of progress bar
progressBar->IncrementAndDraw(0);
}
void CGridDemoAppUi::HideProgressDialog()
{
if(iProgressDialog)
{
iProgressDialog->ProcessFinishedL();
iProgressDialog=NULL;
}
}
void CGridDemoAppUi::UpdateProgressL(TInt aValue)
{
if(iProgressDialog)
{
CEikProgressInfo* progressBar = iProgressDialog->GetProgressInfoL(); // not taking ownership
progressBar->IncrementAndDraw(1);
}
}
void CGridDemoAppUi::DialogDismissedL(TInt /*aButtonId*/)
{
}
CGridDemoAppUi* CGridDemoAppUi::GetAppUi()
{
CEikAppUi* pAppUi = CEikonEnv::Static()->EikAppUi();
while(pAppUi->ContainerAppUi())
{
pAppUi = pAppUi->ContainerAppUi();
}
return (CGridDemoAppUi*)pAppUi;
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -