📄 listview.cpp
字号:
if (oldOrder!=aOrder)
{
TBool val=EFalse;
if (oldOrder==ESortOrderAscending)
val=ETrue;
cm.SetChecked(*this,EAppCmdSortOrder,val);
}
LocateControlByUniqueHandle<CQikListBox>(EListViewListId)->
SetCurrentItemIndexL(iEngine->CurrentEntryIndex(),ETrue,EDrawNow);
// inform user via a system type dlg
User::Leave(err);
}
}
void CListView::SendFileAsL()
//
// Send the file, via a user chosen transport.
//
{
CQikSendAsLogic* sendAs=CQikSendAsLogic::NewL();
CleanupStack::PushL(sendAs);
// If you wanted to have subject and body text they would be obtained and set here.. This simply
// supports sending a file
// _LIT(KSubjectText,"Subject text");
// _LIT(KBodyText,"Body text");
// sendAs->SetSubjectL(KSubjectText);
// sendAs->SetBodyTextL(KBodyText);
TFileName fullName;
iEngine->EntryFullName(fullName);
sendAs->AddAttachmentL(fullName);
CleanupStack::Pop(sendAs); // CQikSendAsDialog guarantees to take ownership
// KUidMtmQuerySupportAttachments = only display transports that support attachments, as thats
// what we are attempting to send. (e.g. SMS gets filtered out)
CQikSendAsDialog::RunDlgLD(sendAs,KUidMtmQuerySupportAttachments);
}
void CListView::DeleteCurrentEntryL()
//
// User may want to remove the current entry. Firstly request the user confirms they really want to
// do this. If confirmed then go ahead.
//
{
SetCurrentEntry();
const TFolderEntry& entry=iEngine->CurrentEntry();
TBuf<256>bb;
iEikonEnv->Format256(bb,R_STR_ABOUT_TO_DELETE,&entry.EntryName());
TBuf<64>bb2;
iEikonEnv->ReadResourceL(bb2,R_STR_ATTENTION);
if (iEikonEnv->QueryWinL(bb2,bb))
{
// before the entry is deleted use any properties
iEikonEnv->Format256(bb,R_STR_DELETED,&entry.EntryName());
// remove entry from disk
iEngine->DeleteCurrentEntryL();
// remove from the list view list display as its been deleted
CQikListBox* listbox=LocateControlByUniqueHandle<CQikListBox>(EListViewListId);
listbox->RemoveItemL(listbox->CurrentItemIndex());
// now ensure engine and listBox think the same entry is the current entry
TInt i=iEngine->CurrentEntryIndex();
if (i>=0)
listbox->SetCurrentItemIndexL(i,ETrue,EDrawNow);
// give some +ve feedback to the user that the delete has occured
iEikonEnv->InfoMsg(bb);
// e.g. if no more entries in the current list, make items unavailable.
UpdateCommandAvailability();
}
}
void CListView::HandleCommandL(CQikCommand& aCommand)
//
// Handle the commands coming in from the controls that can deliver cmds..
//
{
if (aCommand.Type()==EQikCommandTypeCategory)
{
if (aCommand.Id()==EAppCmdEditCategories)
CQikEditCategoriesDialog::RunDlgLD(CategoryModel(),this);
else
{ // one of the category entries has been chosen, update selected category...
iEngine->ChangeCategoryL(aCommand.CategoryHandle());
SelectCategoryL(aCommand.CategoryHandle());
UpdateListBoxL();
UpdateCommandAvailability();
}
}
else
{
switch (aCommand.Id())
{
case EAppCmdNew:
case EAppCmdOpen:
User::Leave(KErrNotSupported);
break;
case EAppCmdDelete:
case EAppCmdDelete2:
DeleteCurrentEntryL();
break;
case EAppCmdSortCascade:
break;
case EAppCmdSortByName:
SortListL(EFolderEntrySortByName,iEngine->SortOrder(),EAppCmdSortByName);
break;
case EAppCmdSortBySize:
SortListL(EFolderEntrySortBySize,iEngine->SortOrder(),EAppCmdSortBySize);
break;
case EAppCmdSortByDate:
SortListL(EFolderEntrySortByModified,iEngine->SortOrder(),EAppCmdSortByDate);
break;
case EAppCmdSortByType:
SortListL(EFolderEntrySortByType,iEngine->SortOrder(),EAppCmdSortByType);
break;
case EAppCmdSortOrder: // swap between ascending and descending
SortListL(iEngine->SortType(),(TFolderEntrySortOrder)(ESortOrderAscending+
ESortOrderDescending-iEngine->SortOrder()),EAppCmdSortOrder);
break;
case EAppCmdSendAs:
SendFileAsL();
break;
case EAppCmdZoom: // Launch the system std zoom dialog
CQikZoomDialog::RunDlgLD(iEngine->ListViewZoomState(),*this);
break;
case EQikCmdZoomLevel1: // delivered by the std system zoom dlg...
case EQikCmdZoomLevel2:
case EQikCmdZoomLevel3:
if (iEngine->SetListViewZoomState(aCommand.Id()))
{ // zoom state has changed
CQikViewBase::SetZoomFactorL(CQikAppUi::ZoomFactorL(aCommand.Id(),*iEikonEnv));
PerformLayout();
}
break;
case EAppCmdRegister:
iQikAppUi.HandleCommandL(EAppCmdRegister);
break;
case EAppCmdAbout:
iQikAppUi.HandleCommandL(EAppCmdAbout);
break;
case EEikCmdExit:
iQikAppUi.HandleCommandL(EEikCmdExit);
break;
default: // e.g. the back button...
CQikViewBase::HandleCommandL(aCommand);
break;
}
}
}
CQikCommand* CListView::DynInitOrDeleteCommandL(
//
// As commands are added to the view we get the opportunity to perform some actions.
// In this case we want to ensure the Radio buttons and SortOrder check item are correct.
//
CQikCommand* aCommand,
const CCoeControl& aControlAddingCommands)
{
TBool val=EFalse;
switch (aCommand->Id())
{
// determine which of the radio buttons should be checked
case EAppCmdSortByName:
if (iEngine->SortType()==EFolderEntrySortByName)
val=ETrue;
aCommand->SetChecked(val);
break;
case EAppCmdSortBySize:
if (iEngine->SortType()==EFolderEntrySortBySize)
val=ETrue;
aCommand->SetChecked(val);
break;
case EAppCmdSortByType:
if (iEngine->SortType()==EFolderEntrySortByType)
val=ETrue;
aCommand->SetChecked(val);
break;
case EAppCmdSortByDate:
if (iEngine->SortType()==EFolderEntrySortByModified)
val=ETrue;
aCommand->SetChecked(val);
break;
// determine whether the single check box type menu option should be checked
case EAppCmdSortOrder:
if (iEngine->SortOrder()==ESortOrderAscending)
val=ETrue;
aCommand->SetChecked(val);
break;
default:
break;
}
return(aCommand);
}
void CListView::ViewConstructL()
{
// Loads information about the UI configurations this view supports
// together with definition of each view.
ViewConstructFromResourceL(R_LIST_VIEW_CONFIGURATIONS);
// we want to HandleListBoxEventL() - so observe all the listboxes
LocateControlByUniqueHandle<CQikListBox>(EListViewListId)->SetListBoxObserver(this);
// Create the category list, this version creates it from the set within the engine
CQikCategoryModel* categories=CQikCategoryModel::NewLC();
const TInt count=iEngine->CategoryListCount();
for (TInt i=0;i<count;i++)
{
const TAppCategoryEntry& entry=iEngine->CategoryListAt(i);
TInt16 flags;
if (entry.iCategoryId==EAppCategoryAll)
flags=EQikCategoryCantBeRenamed | EQikCategoryCantBeDeleted | EQikCategoryAll;
else if (entry.iCategoryId==EAppCategoryUnfiled)
flags=EQikCategoryCantBeRenamed | EQikCategoryCantBeDeleted | EQikCategoryUnfiled;
else
flags=0;
categories->AddCategoryL(entry.iCategoryId,entry.iCategoryName,flags);
}
SetCategoryModel(categories); // takes ownership
CleanupStack::Pop(categories);
// by default we view the 'All' category
SelectCategoryL(EAppCategoryAll);
// Cause the category picker to be visible/softkey command group to exist.
SetCategoryModelAsCommandsL();
// set the line below app name to be "List title"
TBuf<64>bb;
iEikonEnv->ReadResourceL(bb,R_STR_LIST_TITLE);
ViewContext()->AddTextL(1,bb);
}
void CListView::ViewDeactivated()
//
// The view is being de-activated.
//
{
// we always rebuild when come foreground so remove all items here
CQikListBox* listbox=LocateControlByUniqueHandle<CQikListBox>(EListViewListId);
TRAPD(junk,listbox->RemoveAllItemsL());
}
void CListView::ViewActivatedL(
//
// The view is being activated.
//
const TVwsViewId& aPrevViewId,
const TUid aCustomMessageId,
const TDesC8& aCustomMessage)
{
UpdateListBoxL();
TInt i=iEngine->CurrentEntryIndex();
if (i>=0)
LocateControlByUniqueHandle<CQikListBox>(EListViewListId)->SetCurrentItemIndexL(i,ETrue,EDrawNow);
UpdateCommandAvailability();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -