📄 sendas.cpp
字号:
//
// SendAs.cpp - SendAs example
//
// Copyright (C) UIQ Technology AB, 2007
//
// This material is provided "as is" without any warranty to its performance or functionality.
// In no event shall UIQ Technology be liable for any damages whatsoever arising out of the
// use or inabilty to use this material.
//
#include "SendAs.h"
#include "SendAs.hrh"
#include <SendAs.rsg>
#include <QikViewBase.h>
#include <QikCommand.h>
#include <QikListBoxModel.h>
#include <QikListBox.h>
#include <MQikListBoxData.h>
#include <eikstart.h>
#include <QikSendAsLogic.h>
#include <QikSendAs.h>
#include <MtmUids.h>
//////////////////////////////////////////////////////////////////////////////
// The application Uid here MUST match UID3 defined in the MMP file
// This is a development UID and must NOT be used in production type software
const TUid KAppSpecificUid={0xEDEAD00D};
// internal secondary view id, must be unique amongst this applications views
const TUid KUidListView={0x00000001};
// views within applications are fully identified by the app Uid and secondary view id
#define KViewIdListView TVwsViewId(KAppSpecificUid,KUidListView)
//////////////////////////////////////////////////////////////////////////////////
class CAppSpecificListView : public CQikViewBase
{
protected:
// from CQikViewBase
TVwsViewId ViewId() const;
void HandleCommandL(CQikCommand& aCommand);
void ViewConstructL();
void ViewDeactivated();
void ViewActivatedL(const TVwsViewId& aPrevViewId,const TUid aCustomMessageId,const TDesC8& aCustomMessage);
// new methods
void SendTextAsL();
public:
// new methods
CAppSpecificListView(CAppSpecificUi& aAppUi);
protected:
};
CAppSpecificListView::CAppSpecificListView(CAppSpecificUi& aAppUi) :
CQikViewBase(aAppUi,KNullViewId)
{}
TVwsViewId CAppSpecificListView::ViewId() const
//
// All views are uniquely identified within the entire system. A TVwsViewId consists of
// the application uid (uid3) and app specific view uid
//
{
return(KViewIdListView);
}
void CAppSpecificListView::SendTextAsL()
//
// Send the text.
//
{
CQikSendAsLogic* sendAs=CQikSendAsLogic::NewL();
CleanupStack::PushL(sendAs);
// set the body text to be content of the currently selected list box entry
CQikListBox* listbox=LocateControlByUniqueHandle<CQikListBox>(EAppSpecificListViewListId);
MQikListBoxData* lbData=listbox->Model().RetrieveDataL(listbox->CurrentItemIndex());
CleanupClosePushL(*lbData); // its retrieved in an 'Open' state
sendAs->SetBodyTextL(lbData->Text(EQikListBoxSlotText1));
CleanupStack::PopAndDestroy(lbData); // closes the item
CQikSendAsDialog::RunDlgLD(sendAs);
CleanupStack::Pop(sendAs); //
}
void CAppSpecificListView::HandleCommandL(CQikCommand& aCommand)
//
// Handle the commands coming in from the controls that can deliver cmds..
//
{
switch (aCommand.Id())
{
case EAppCmdSendAs:
SendTextAsL();
break;
default: // e.g. the back button...
CQikViewBase::HandleCommandL(aCommand);
break;
}
}
const TInt KListViewItems=7; // we have 7 strings defined in rsc file for this example app
const TInt KMaxListItemText=128; // all of which must be <128 chars in length
void CAppSpecificListView::ViewConstructL()
{
// Loads information about the UI configurations this view supports
// together with definition of each view.
ViewConstructFromResourceL(R_LIST_VIEW_CONFIGURATIONS);
CQikListBox* listbox=LocateControlByUniqueHandle<CQikListBox>(EAppSpecificListViewListId);
MQikListBoxModel& model(listbox->Model());
model.ModelBeginUpdateLC();
TBuf<KMaxListItemText>bb;
for (TInt i=0;i<KListViewItems;i++)
{
MQikListBoxData* lbData=model.NewDataL(MQikListBoxModel::EDataNormal);
CleanupClosePushL(*lbData); // alternativly use NewDataLC() to save this line of code
iEikonEnv->ReadResourceL(bb,R_STR_LIST_CONTENT_1+i);
lbData->AddTextL(bb,EQikListBoxSlotText1);
CleanupStack::PopAndDestroy(lbData);
}
model.ModelEndUpdateL();
// set the line below app name to be "List title"
iEikonEnv->ReadResourceL(bb,R_STR_LIST_TITLE);
ViewContext()->AddTextL(1,bb);
}
void CAppSpecificListView::ViewDeactivated()
{
}
void CAppSpecificListView::ViewActivatedL(
const TVwsViewId& aPrevViewId,
const TUid aCustomMessageId,
const TDesC8& aCustomMessage)
{
}
//////////////////////////////////////////////////////////////////////////////
CAppSpecificUi::~CAppSpecificUi()
{
}
void CAppSpecificUi::ConstructL()
//
// Normal primary entry point to a Symbian App
//
{
CQikAppUi::ConstructL();
// We create and add a list view.
CAppSpecificListView* list=new(ELeave)CAppSpecificListView(*this);
CleanupStack::PushL(list);
list->ConstructL();
AddViewL(*list); // takes ownership
CleanupStack::Pop(list);
SetDefaultViewL(*list);
}
/////////////////////////////////////////////////////////////////////////////////////////////
// Standard Symbian application framework code when creating an application
class CAppSpecificDocument : public CQikDocument
{
protected:
CQikAppUi* CreateAppUiL();
public:
CAppSpecificDocument(CQikApplication& aApp);
static CAppSpecificDocument* NewL(CQikApplication& aApp);
protected:
};
CAppSpecificDocument::CAppSpecificDocument(CQikApplication& aApp) :
CQikDocument(aApp)
{
__DECLARE_NAME(_S("CAppSpecificDocument"));
}
CAppSpecificDocument* CAppSpecificDocument::NewL(CQikApplication& aApp)
{
return(new(ELeave)CAppSpecificDocument(aApp));
}
CQikAppUi* CAppSpecificDocument::CreateAppUiL()
{
return(new(ELeave)CAppSpecificUi);
}
//////////////////////////////////////////////////////////////////////////////////
// Standard Symbian application framework code when creating an application
class CAppSpecificApplication : public CQikApplication
{
protected:
TUid AppDllUid() const;
CApaDocument* CreateDocumentL();
};
TUid CAppSpecificApplication::AppDllUid() const
{
return(KAppSpecificUid);
}
CApaDocument* CAppSpecificApplication::CreateDocumentL()
{
return(CAppSpecificDocument::NewL(*this));
}
//////////////////////////////////////////////////////////////////////////////////
// Standard Symbian application start up code
LOCAL_C CApaApplication* NewApplication()
{
return(new CAppSpecificApplication);
}
GLDEF_C TInt E32Main()
{
return(EikStart::RunApplication(NewApplication));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -