📄 myxmlparsecontainer.cpp
字号:
/*
* ============================================================================
* Name : CMyXMLParseContainer from MyXMLParseContainer.h
* Part of : MyXMLParse
* Created : 19.05.2008 by
* Implementation notes:
* Initial content was generated by Series 60 Application Wizard.
* Version :
* Copyright:
* ============================================================================
*/
// INCLUDE FILES
#include "MyXMLParseContainer.h"
#include "FileListEngine.h"
#include "Myxmlparse.hrh"
#include <myxmlparse.rsg>
#include <EIKAPP.H>
#include <eikbtgpc.h>
#include "MyXMLParseAppui.h"
#include <eiklabel.h> // for example label control
#include "MyXMLParseView.h"
#include <eikmenup.h>
#include <eikenv.h>///iEikonEnv
#include <AknQueryDialog.h> //弹出对话框
#include <f32file.h >//文件
#include <aknnotewrappers.h>//非阻塞对话框
#include "MyXMLParseAppUi.h"
#include "s32file.h"//for readstream
#include <charconv.h>//// for char set convert GBK - Unicode
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CMyXMLParseContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CMyXMLParseContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
iListBox = new (ELeave) CAknDoubleNumberStyleListBox;
iListBox->SetContainerWindowL( *this );
iListBox->ConstructL( this, EAknListBoxMarkableList);
// Create the scroll indicator
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()
->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
iListBox->ActivateL();
// Create the FileListEngine
iAppEngine = new (ELeave) CFileListEngine;
#ifdef __SERIES60_3X__
iAppEngine->ConstructL();
#else
iAppEngine->ConstructL((CEikProcess*)(((CEikAppUi*)iCoeEnv->AppUi())->Application()->Process()));
#endif
SetFileListL(EFileListDefaults);
SetRect(aRect);
ActivateL();
}
//
//CMyXMLParseContainer::CMyXMLParseContainer(CMyXMLParseView& aView):
// iView(aView)
// {
// }
// Destructor
CMyXMLParseContainer::~CMyXMLParseContainer()
{
delete iAppEngine;
delete iListBox;
}
// ---------------------------------------------------------
// CMyXMLParseContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CMyXMLParseContainer::SizeChanged()
{
TRect rect = Rect();
iListBox->SetExtent(TPoint(0,0),rect.Size());
}
// ---------------------------------------------------------
// CMyXMLParseContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CMyXMLParseContainer::CountComponentControls() const
{
return 1; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CMyXMLParseContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CMyXMLParseContainer::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
return iListBox;
default:
return NULL;
}
}
// ---------------------------------------------------------
// CMyXMLParseContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CMyXMLParseContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
// TODO: Add your drawing code here
// example code...
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( KRgbGray );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect( aRect );
}
// ---------------------------------------------------------
// CMyXMLParseContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CMyXMLParseContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
// TODO: Add your control event handler code here
}
// End of File
void CMyXMLParseContainer::LaunchCurrentL()
{
iAppEngine->LaunchCurrentL(iListBox->CurrentItemIndex());
}
void CMyXMLParseContainer::SetFileListL(TInt aDirectory)
{
// Set the listbox to use the file list model
CDesCArray* items = static_cast<CDesCArray*>(iListBox->Model()->ItemTextArray());
// If there are items, they will be removed here
if (iAppEngine->RemoveItems(items))
{
// This makes changes to the actual listbox
iListBox->HandleItemRemovalL();
}
// Let's show directory
iAppEngine->SetDirectory(aDirectory);
// Do preparations for the FileList
if(iAppEngine->StartFileList() == KErrNone)
{
// Create FileList Items in the ListBox
iAppEngine->GetFileListItemsL(items);
}
// Close FileList session
iAppEngine->EndFileList();
// Refresh the listbox due to model change
iListBox->HandleItemAdditionL();
iListBox->SetCurrentItemIndex(0);
// Set correct middle softkey
// CEikButtonGroupContainer * cbaGroup = iEikonEnv->AppUiFactory()->Cba();
// if( iAppEngine->IsDirListEmpty() )
// {
// // Don't use middle softkey at all
// cbaGroup->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_EXIT );
// }
// else
// {
// cbaGroup->SetCommandSetL( R_FILELIST_SOFTKEYS_OPTIONS_EXIT__OPEN );
// }
iListBox->DrawNow();
}
//响应按键事件
TKeyResponse CMyXMLParseContainer::OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType)
{
TKeyResponse ret;
// See if we have a selection
TInt code = aKeyEvent.iCode;
switch(code)
{
// is navigator button pressed
case EKeyOK:
{
// TBuf<128> itemContent;
// MDesCArray* itemList = iListBox->Model()->ItemTextArray();
// itemContent.Copy(itemList->MdcaPoint(iListBox->CurrentItemIndex()));
// itemContent.Trim();
//
// CMyXMLParseAppUi* appUi = static_cast<CMyXMLParseAppUi*>(CCoeEnv::Static()->AppUi());
// appUi->Getfilename(itemContent);//获取当前listbox中的文件名
iView.SwitchToViewL(TUid::Uid(EMultiViewsView2Id));//切换到view1
break;
}
/*AppUi()->ActivateLocalViewL( TUid::Uid( EMultiViewsView2Id ) );*/
// iAppEngine->LaunchCurrentL(iListBox->CurrentItemIndex());
// ret = EKeyWasConsumed;
//break;
default:
// Let Listbox take care of its key handling
ret = iListBox->OfferKeyEventL(aKeyEvent, aType);
break;
}
return ret;
}
//创建新文件
void CMyXMLParseContainer::CreateFile(TFileName aFile)
{
iAppEngine->CreateFile(aFile);
Refresh();
}
void CMyXMLParseContainer::Refresh()
{
SetFileListL(EFileListDefaults);////重新生成当前目录的listbox
}
//void CMyXMLParseContainer::HandleCommandL(TInt aCommand)
//{
// switch ( aCommand )
// {
// case EXMLParseCmdAppOpen:
// {
// TBuf<128> itemContent;
// MDesCArray* itemList = iListBox->Model()->ItemTextArray();
// itemContent.Copy(itemList->MdcaPoint(iListBox->CurrentItemIndex()));
// itemContent.Trim();
//
// CMyXMLParseAppUi* appUi = static_cast<CMyXMLParseAppUi*>(CCoeEnv::Static()->AppUi());
// // appUi->Getfilename(itemContent);//获取当前listbox中的文件名
// iView.SwitchToViewL(TUid::Uid(EMultiViewsView2Id));//切换到view2
//
// break;
// }
// default:
// break;
// }
//}
TInt CMyXMLParseContainer::ReturnPos()
{
return iListBox->CurrentItemIndex();
}
void CMyXMLParseContainer::GetMyName()
{
TBuf<128> itemContent;
MDesCArray* itemList = iListBox->Model()->ItemTextArray();
itemContent.Copy(itemList->MdcaPoint(iListBox->CurrentItemIndex()));
itemContent.Trim();
CMyXMLParseAppUi* appUi = static_cast<CMyXMLParseAppUi*>(CCoeEnv::Static()->AppUi());
appUi->Getfilename(itemContent);//获取当前listbox中的文件名
}
//CMyXMLParseContainer* CMyXMLParseContainer::NewL(CMyXMLView &aView, const TRect &aRect)
//{
//
//}
//
//CMyXMLParseContainer* CMyXMLParseContainer::NewLC(CMyXMLParseView &aView, const TRect &aRect)
//{
//
//}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -