📄 griddemocontainer.cpp
字号:
{
HandleFunctionCall();
}
}
void CGridDemoContainer::LockCurrentColumn()
{
iSheetContainer->LockCurrentColumn();
}
void CGridDemoContainer::UnLockCurrentColumn()
{
iSheetContainer->UnLockCurrentColumn();
}
void CGridDemoContainer::HandleSheetTop()
{
if(!iCanUpdate)
return;
iStartNumber = 0;
ShowSheet();
}
void CGridDemoContainer::HandleSheetBottom()
{
if(!iCanUpdate)
return;
TInt c = iSheetContainer->GetShowRowCount();
TInt record_c = 0;
if(iSheetShowType == EShowSheetSmokeUser)
{
record_c = iMyAppUi->iSmokeUsers.Count();
}
else if (iSheetShowType == EShowSheetSmokeType || iSheetShowType == EShowSheetSmokeInfo)
{
record_c = iIndexArray.Count();
}
else if( iSheetShowType == EShowSheetSmokeFlow)
{
record_c = iIndexArray.Count();
}
else
{
record_c = iRecordRowCount;
}
if(record_c <= c)
return;
iStartNumber = record_c - c;
ShowSheet();
}
void CGridDemoContainer::HandleSheetPageUp()
{
if(!iCanUpdate)
return;
TInt c = iSheetContainer->GetShowRowCount();
if(iStartNumber > c)
iStartNumber -= c;
else
iStartNumber = 0;
ShowSheet();
}
void CGridDemoContainer::HandleSheetPageDown()
{
if(!iCanUpdate)
return;
TInt c = iSheetContainer->GetShowRowCount();
TInt record_c = 0;
if(iSheetShowType == EShowSheetSmokeUser)
{
record_c = iMyAppUi->iSmokeUsers.Count();
}
else if(iSheetShowType == EShowSheetSmokeType || iSheetShowType == EShowSheetSmokeInfo)
{
record_c = iIndexArray.Count();
}
else if( iSheetShowType == EShowSheetSmokeFlow)
{
record_c = iIndexArray.Count();
}
else
{
record_c = iRecordRowCount;
}
if((iStartNumber + c) < (record_c - c))
iStartNumber += c;
else
iStartNumber = record_c - c;
ShowSheet();
}
void CGridDemoContainer::HandleSheetScrollUp()
{
if(!iCanUpdate)
return;
if(iStartNumber < 1)
return;
iStartNumber--;
ShowSheet();
}
void CGridDemoContainer::HandleSheetScrollDown()
{
if(!iCanUpdate)
return;
TInt c = iSheetContainer->GetShowRowCount();
TInt record_c = 0;
if(iSheetShowType == EShowSheetSmokeUser)
{
record_c = iMyAppUi->iSmokeUsers.Count();
}
else if(iSheetShowType == EShowSheetSmokeType || iSheetShowType == EShowSheetSmokeInfo)
{
record_c = iIndexArray.Count();
}
else if( iSheetShowType == EShowSheetSmokeFlow)
{
record_c = iIndexArray.Count();
}
else
record_c = iRecordRowCount;
if((iStartNumber + c) < record_c)
iStartNumber++;
else
return;
ShowSheet();
}
void CGridDemoContainer::HandleSheetEnterEvent()
{
if(!iCanUpdate)
return;
if(iAllowEdit)
{
TPoint pt = iSheetContainer->GetCurrentPos();
if(pt.iX < 12 && pt.iX > 5)
{
TInt r = pt.iY + iStartNumber + iRecordRowOffset;
if(r >=0 && r < iIndexArray.Count())
r = iIndexArray[r];
else
return;
if(iEditFlow)
delete iEditFlow;
iEditFlow = NULL;
if(!iEditFlow)
{
iEditFlow = new (ELeave) TSmokeFlow;
ReadFlowData(r, iEditFlow);
}
if(iIsShowStatus)
iStatusContainer->MakeVisible(EFalse);
switch(pt.iX)
{
case 6: iNumberEditor->SetNumber(String2Int(iEditFlow->iCount3)); break;
case 7: iNumberEditor->SetNumber(String2Int(iEditFlow->iCount2)); break;
case 8: iNumberEditor->SetNumber(String2Int(iEditFlow->iCount4)); break;
case 9: iNumberEditor->SetNumber(String2Int(iEditFlow->iCount5)); break;
case 10: iNumberEditor->SetNumber(String2Int(iEditFlow->iCount6)); break;
case 11: iNumberEditor->SetNumber(String2Int(iEditFlow->iCount7)); break;
default:
return;
}
iIsShowNumberEditor = ETrue;
iNumberEditor->MakeVisible(ETrue);
SizeChanged();
iMyAppUi->ChangeCBA(R_EDIT_CBA, 0);
}
}
else
{
HBufC* txt = iSheetContainer->CurrentRowDetailL();
if(txt)
{
TBuf<32> buf;
iEikonEnv->ReadResourceL(buf, R_DETAIL);
iMyAppUi->ShowMessageQueryDialog(buf, *txt);
delete txt;
}
}
}
void CGridDemoContainer::ReadFlowData(TInt pos, TSmokeFlow* aFlow)
{
RFile file;
User::LeaveIfError(file.Open(iMyAppUi->FsSession(), iTempFilename, EFileRead));
TInt seek = pos * TSmokeFlow::Size();
file.Seek(ESeekStart, seek);
TBuf8<128> buf;
file.Read(buf, aFlow->iNo.MaxLength());
buf.Trim();
aFlow->iNo.Copy(buf);
file.Read(buf, aFlow->iType.MaxLength());
buf.Trim();
aFlow->iType.Copy(buf);
file.Read(buf, aFlow->iCode.MaxLength());
buf.Trim();
aFlow->iCode.Copy(buf);
file.Read(buf, aFlow->iCount1.MaxLength());
buf.Trim();
aFlow->iCount1.Copy(buf);
file.Read(buf, aFlow->iCount2.MaxLength());
buf.Trim();
aFlow->iCount2.Copy(buf);
file.Read(buf, aFlow->iCount3.MaxLength());
buf.Trim();
aFlow->iCount3.Copy(buf);
file.Read(buf, aFlow->iCount4.MaxLength());
buf.Trim();
aFlow->iCount4.Copy(buf);
file.Read(buf, aFlow->iCount5.MaxLength());
buf.Trim();
aFlow->iCount5.Copy(buf);
file.Read(buf, aFlow->iCount6.MaxLength());
buf.Trim();
aFlow->iCount6.Copy(buf);
file.Read(buf, aFlow->iCount7.MaxLength());
buf.Trim();
aFlow->iCount7.Copy(buf);
file.Read(buf, aFlow->iCount8.MaxLength());
buf.Trim();
aFlow->iCount8.Copy(buf);
file.Read(buf, aFlow->iCount9.MaxLength());
buf.Trim();
aFlow->iCount9.Copy(buf);
file.Read(buf, aFlow->iCount10.MaxLength());
buf.Trim();
aFlow->iCount10.Copy(buf);
file.Read(buf, aFlow->iCount11.MaxLength());
buf.Trim();
aFlow->iCount11.Copy(buf);
file.Read(buf, aFlow->iSepLine.MaxLength());
buf.Trim();
aFlow->iSepLine.Copy(buf);
file.Close();
}
void CGridDemoContainer::WriteFlowData(TInt aPos, TSmokeFlow* aFlow)
{
RFile file;
User::LeaveIfError(file.Open(iMyAppUi->FsSession(), iTempFilename, EFileWrite));
TInt seek = aPos * TSmokeFlow::Size();
file.Seek(ESeekStart, seek);
TBuf<1024> buf;
buf.Format(_L("%-13S%-2S%-10S%+11S%+11S%+11S%+11S%+11S%+11S%+11S%+11S%+11S%+11S%+11S\r\n"),
&aFlow->iNo,
&aFlow->iType,
&aFlow->iCode,
&aFlow->iCount1,
&aFlow->iCount2,
&aFlow->iCount3,
&aFlow->iCount4,
&aFlow->iCount5,
&aFlow->iCount6,
&aFlow->iCount7,
&aFlow->iCount8,
&aFlow->iCount9,
&aFlow->iCount10,
&aFlow->iCount11);
TBuf8<1024> buf8;
buf8.Copy(buf);
file.Write(buf8);
file.Flush();
file.Close();
}
void CGridDemoContainer::HandleSheetEditEvent()
{
// if(!iEditFlow)
// return;
//
// TPoint pt = iSheetContainer->GetCurrentPos();
// TInt r = pt.iY + iStartNumber + iRecordRowOffset;
//
// WriteFlowData(r, iEditFlow);
//
// delete iEditFlow;
// iEditFlow = NULL;
}
//数字编辑框出现后点确定调用这个函数
void CGridDemoContainer::HandleEditOk()
{
TPoint pt = iSheetContainer->GetCurrentPos();
if(UpdateAndCheckValue(iEditFlow, pt.iX))
{
TInt r = pt.iY + iStartNumber + iRecordRowOffset;
if(r >=0 && r < iIndexArray.Count())
r = iIndexArray[r];
else
return;
WriteFlowData(r, iEditFlow);
delete iEditFlow;
iEditFlow = NULL;
ShowStatus(iIsShowStatus);
iIsShowNumberEditor = EFalse;
iNumberEditor->MakeVisible(EFalse);
SizeChanged();
ShowSmokeFlowSheet();
iMyAppUi->ChangeCBA(R_SHEET_CBA, R_SHEET_MENUBAR);
}
}
void CGridDemoContainer::HandleEditCancel()
{
if(iEditFlow)
delete iEditFlow;
iEditFlow = NULL;
iIsShowNumberEditor = EFalse;
iNumberEditor->MakeVisible(EFalse);
ShowStatus(iIsShowStatus);
SizeChanged();
iMyAppUi->ChangeCBA(R_SHEET_CBA, R_SHEET_MENUBAR);
}
void CGridDemoContainer::HandleSheetSizeChangeEvent(TBool aExpand)
{
if(!iCanUpdate)
return;
TInt c = iSheetContainer->GetShowRowCount();
TPoint pos = iSheetContainer->GetCurrentPos();
if(!aExpand)
{
if(pos.iY >= c)
{
TInt a = pos.iY - c + 1;
iStartNumber += a;
pos.iY -= a;
}
}
ShowSheet();
iSheetContainer->SetFocusPos(pos);
}
TBool CGridDemoContainer::ShowSheet()
{
if(iSheetShowType == EShowSheetSmokeUser)
return ShowUserSheet();
else if(iSheetShowType == EShowSheetSmokeType)
return ShowTypeSheet();
else if(iSheetShowType == EShowSheetSmokeInfo)
return ShowSmokeInfoSheet();
else if(iSheetShowType == EShowSheetSmokePlan)
return ShowSmokePlanSheet();
else if(iSheetShowType == EShowSheetSmokeRealInfo)
return ShowSmokeRealInfoSheet();
else if(iSheetShowType == EShowSheetSmokeCampaign)
return ShowSmokeCampaignSheet();
else if(iSheetShowType == EShowSheetSmokeYearAccount)
return ShowSmokeYearSheet(iYearAccountFlag);
else if(iSheetShowType == EShowSheetSmokeMonthAccount)
return ShowSmokeMonthSheet(iTempFilename);
else if(iSheetShowType == EShowSheetSmokeFlow)
return ShowSmokeFlowSheet();
else if(iSheetShowType == EShowSheetSmokeFlowSum)
return ShowSmokeFlowSumSheet(iTempFilename);
else
return EFalse;
}
TBool CGridDemoContainer::LoadYearIndex()
{
iSmokeYearIndex.ResetAndDestroy();
TBuf<256> filename;
filename = KSmokeYearFile;
filename.Replace(filename.Length() - 3, 3, _L("idx"));
iMyAppUi->CompleteWithDataPath(filename);
RFile file;
TInt file_err = file.Open(iMyAppUi->FsSession(), filename, EFileRead);
if(file_err != KErrNone)
{
return EFalse;
}
TInt size;
file.Size(size);
TInt c = size / TSmokeYearIndex::Size();
TBuf8<32> buf;
for(TInt i=0; i<c; i++)
{
TSmokeYearIndex* yi = new (ELeave) TSmokeYearIndex;
buf.Zero();
file.Read(buf, TSmokeYearIndex::Size());
yi->iYear.Copy(buf.Left(yi->iYear.MaxLength()));
yi->iYear.Trim();
yi->iNo.Copy(buf.Mid(yi->iYear.MaxLength(),yi->iNo.MaxLength()));
yi->iNo.Trim();
buf.Copy(buf.Mid(yi->iYear.MaxLength() + yi->iNo.MaxLength(), 8));
buf.Trim();
TLex8 lex(buf);
lex.Val(yi->iStartLine);
iSmokeYearIndex.Append(yi);
}
file.Close();
return ETrue;
}
TBool CGridDemoContainer::LoadRealInfoIndex()
{
iSmokeRealInfoIndex.ResetAndDestroy();
TBuf<256> filename;
filename = KSmokeRealInfoFile;
filename.Replace(filename.Length() - 3, 3, _L("idx"));
iMyAppUi->CompleteWithDataPath(filename);
RFile file;
TInt file_err = file.Open(iMyAppUi->FsSession(), filename, EFileRead);
if(file_err != KErrNone)
{
return EFalse;
}
TInt size;
file.Size(size);
TInt c = size / TSmokeRealInfoIndex::Size();
TBuf8<32> buf;
for(TInt i=0; i<c; i++)
{
TSmokeRealInfoIndex* yi = new (ELeave) TSmokeRealInfoIndex;
buf.Zero();
file.Read(buf, TSmokeRealInfoIndex::Size());
yi->iNo.Copy(buf.Left(yi->iNo.MaxLength()));
yi->iNo.Trim();
buf.Copy(buf.Mid(yi->iNo.MaxLength(), 8));
buf.Trim();
TLex8 lex(buf);
lex.Val(yi->iStartLine);
iSmokeRealInfoIndex.Append(yi);
}
file.Close();
return ETrue;
}
TBool CGridDemoContainer::LoadMonthIndex(const TDesC& aFilename)
{
iSmokeMonthIndex.ResetAndDestroy();
TBuf<256> filename;
filename = aFilename;
filename.Replace(filename.Length() - 3, 3, _L("idx"));
RFile file;
TInt file_err = file.Open(iMyAppUi->FsSession(), filename, EFileRead);
if(file_err != KErrNone)
{
return EFalse;
}
TInt size;
file.Size(size);
TInt c = size / TSmokeMonthIndex::Size();
TBuf8<32> buf;
for(TInt i=0; i<c; i++)
{
TSmokeMonthIndex* yi = new (ELeave) TSmokeMonthIndex;
buf.Zero();
file.Read(buf, TSmokeMonthIndex::Size());
yi->iNo.Copy(buf.Left(yi->iNo.MaxLength()));
yi->iNo.Trim();
buf.Copy(buf.Mid(yi->iNo.MaxLength(), 8));
buf.Trim();
TLex8 lex(buf);
lex.Val(yi->iStartLine);
iSmokeMonthIndex.Append(yi);
}
file.Close();
return ETrue;
}
TBool CGridDemoContainer::LoadFlowNoIndex(const TDesC& aFilename)
{
iSmokeFlowNoIndex.ResetAndDestroy();
TBuf<256> filename;
filename = aFilename;
filename.Replace(filename.Length() - 4, 4, _L("_no.idx"));
RFile file;
TInt file_err = file.Open(iMyAppUi->FsSession(), filename, EFileRead);
if(file_e
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -