📄 detailsview.cpp
字号:
//
// DetailsView.cpp - Details view of the signed app
//
// 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 "DetailsView.h"
#include "SignedAppUids.h"
#include "SignedApp.hrh"
#include <SignedApp_0x20000462.rsg>
#include <QikCommand.h>
#include <QikTimeAndDateEditor.h>
#include <QikSaveChangesDlg.h>
#include <eikchlst.h>
#include <eikedwin.h>
#include <eikrted.h>
//////////////////////////////////////////////////////////////////////////////////
// We act as our own data supplier for the category choice list
// We do however need to filter out the 'All' category as its not sensible to set an entry
// to belong to that 'virtual' category. We always have the Unfiled category in existance
TInt CDetailsView::MdcaCount() const
// report number of entries in the choice list
{
return(iEngine->CategoryListCount()-1);
}
TPtrC CDetailsView::MdcaPoint(TInt aIndex) const
{
return(iEngine->CategoryListAt(aIndex+1).iCategoryName);
}
//////////////////////////////////////////////////////////////////////////////////
CDetailsView::CDetailsView(CQikAppUi& aAppUi,CAppEngine* aEngine) :
CQikViewBase(aAppUi,KViewIdListView),iEngine(aEngine)
{}
TVwsViewId CDetailsView::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(KViewIdDetailsView);
}
TBool CDetailsView::DetailsHaveChanged()
//
// Return ETrue if any of the current details have changed, EFalse otherwise
//
{
const TFolderEntry& entry=iEngine->CurrentEntry();
CEikEdwin* edwin=LocateControlByUniqueHandle<CEikEdwin>(EAppEdwin1);
TFileName bb;
edwin->GetText(bb);
if (entry.EntryName()!=bb)
return(ETrue);
CEikChoiceList* cl=LocateControlByUniqueHandle<CEikChoiceList>(EAppChoiceList1);
if (entry.EntryCategory()!=iEngine->CategoryListAt(cl->CurrentItem()+1).iCategoryId)
return(ETrue);
CQikTimeAndDateEditor* dtEd=LocateControlByUniqueHandle<CQikTimeAndDateEditor>(EAppDateTime1);
if (entry.EntryModified()!=dtEd->Time())
return(ETrue);
return(EFalse);
}
void CDetailsView::HandleCommandL(CQikCommand& aCommand)
//
// Handle the commands coming in from the controls that can deliver cmds..
//
{
switch (aCommand.Id())
{
case EAppCmdAbout:
iQikAppUi.HandleCommandL(EAppCmdAbout);
break;
case EQikCmdGoBack:
if (DetailsHaveChanged())
{
CQikSaveChangesDialog::TExitOption ret=CQikSaveChangesDialog::RunDlgLD();
if (ret==CQikSaveChangesDialog::EShut)
break; // user no longer wants to go back, remain here
if (ret==CQikSaveChangesDialog::ESave)
{ // user wants to save changes and go back
// if we ActivatePreviousViewL(ESave) then the ViewActivateL() of the previous
// view gets called BEFORE our SaveL() gets called. This is a bit of a problem because
// saving an entry may well change the list of items to display (e.g. the category
// gets changed.) We therefore need to ensure we cause a SaveL() before the DNL
SaveThenDnlToL(ParentView());
break;
}
// user wants to abandon changes and go back
}
// FALL through to default:
default: // e.g. the back button...
CQikViewBase::HandleCommandL(aCommand);
break;
}
}
void CDetailsView::ViewConstructL()
{
// Loads information about the UI configurations this view supports
// together with definition of each view.
ViewConstructFromResourceL(R_DETAILS_VIEW_CONFIGURATIONS);
// set the line below app name to be "Entry details"
TBuf<64>bb;
iEikonEnv->ReadResourceL(bb,R_STR_DETAILS_TITLE);
ViewContext()->AddTextL(1,bb);
}
void CDetailsView::SaveL()
//
// As with a standard view the SaveL() is called when you should be saving any changes to the
// user entered data
//
{
TFolderEntry entry;
CEikEdwin* edwin=LocateControlByUniqueHandle<CEikEdwin>(EAppEdwin1);
TFileName bb;
edwin->GetText(bb);
entry.UpdateName(bb);
CEikChoiceList* cl=LocateControlByUniqueHandle<CEikChoiceList>(EAppChoiceList1);
entry.UpdateCategory(iEngine->CategoryListAt(cl->CurrentItem()+1).iCategoryId);
CQikTimeAndDateEditor* dtEd=LocateControlByUniqueHandle<CQikTimeAndDateEditor>(EAppDateTime1);
entry.UpdateModified(dtEd->Time());
// finally update the current item within engine with new content
iEngine->UpdateCurrentEntryL(entry);
}
void CDetailsView::ViewDeactivated()
//
// The view is being de-activated.
//
{
// Since we have chosen to refer directly to the categories in the engine (as opposed to
// building another copy) we need to reset the choice list to refer to a category that cannot
// be deleted - in this case the Unfiled category. If we do not do this then if we delete
// categories such that any currently referenced one is now out of the array bounds
// the app will be panic'ed - EVEN IF THIS VIEW IS NOT ACTIVATE
LocateControlByUniqueHandle<CEikChoiceList>(EAppChoiceList1)->SetCurrentItem(0);
}
void CDetailsView::ViewActivatedL(
//
// The view is being activated.
//
const TVwsViewId& aPrevViewId,
const TUid aCustomMessageId,
const TDesC8& aCustomMessage)
{
const TFolderEntry& entry=iEngine->CurrentEntry();
// locate the edwins and set the entry name
CEikEdwin* edwin=LocateControlByUniqueHandle<CEikEdwin>(EAppEdwin1);
edwin->SetTextL(&entry.EntryName());
// now tell the choice list control about the choice list available to it
CEikChoiceList* cl=LocateControlByUniqueHandle<CEikChoiceList>(EAppChoiceList1);
cl->SetArrayL(this); // we supply the choice list info via the MDesCArray i/f
cl->SetArrayExternalOwnership(ETrue);
// now set the choice list to be current chosen category
// category entry at slot 0 is the 'All' category. This is filtered out from the display
// and its not reasonable to set an entry to the 'All' category
TInt id=entry.EntryCategory();
TInt count=iEngine->CategoryListCount();
for (TInt i=1;i<count;i++)
{
if (iEngine->CategoryListAt(i).iCategoryId==id)
{
cl->SetCurrentItem(i-1);
break;
}
}
// locate and set the Time + Date editor to a default value.
CQikTimeAndDateEditor* dtEd=LocateControlByUniqueHandle<CQikTimeAndDateEditor>(EAppDateTime1);
dtEd->SetTimeL(entry.EntryModified());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -